Skip to content
READING MAP

zlib × Lean

Follow the data through the algorithm. Follow the implementation through the proof.

These articles explain how zlib compresses and recovers data, how applications use it, and what the implementation’s proofs must establish. Start with the component map below, then choose the algorithm overview, implementation detail, or a function’s complete contract.

Part one builds the overall picture of algorithms and interfaces. Part two opens each topic’s algorithms and optimizations before developing its proof argument. Chapters link their background and next step; global contents are always available at the side.

ZLIB / THE WHOLE SYSTEM

The compression and decoding map

See each component’s job before opening its algorithm or proof. Hover, focus, or select a node to explore its inputs, outputs, and reading links.

Input bytesSymbolsCodesCompressed streamRecovered bytes
Main data flow for coded blocksSupport from shared mechanismsStored blocks carry original bytes directly
01

Algorithms & interfaces

From repetition to a compressed stream and back to caller-owned bytes. Build the overall picture, then consult exact interfaces.

Read the algorithm overview →Explore calls and interfaces ↗
02

Algorithm detail and formal verification

Follow an implementation path: how data is laid out, how optimizations work, and which facts the proof must establish.

Choose a detailed topic →Consult the other component arguments ↗
FOLLOW THE SAME DATA

Three symbols, five bytes

This detailed route starts with A, B, and a length-6, distance-2 match. Choose the block representation, emit its bits, follow reads and writes in shared memory, then connect those facts into a proof.

  1. 01
    IMPLEMENTATION DETAIL

    Block selection and symbol costs

    Compare three block representations and see when sending new codes is worth its cost.

    ↗
  2. 02
    IMPLEMENTATION DETAIL

    Bit output and byte buffering

    Pack variable-length codes into bytes and deliver them to the caller.

    ↗
  3. 03
    IMPLEMENTATION DETAIL

    Shared storage and output prefixes

    Understand how shared memory can preserve symbols that have not yet been read.

    ↗
  4. 04
    PROOF ARGUMENT

    The output proof argument

    Explain how each write preserves meaning from symbols to delivered output.

    ↗

All detailed topics

01 / 3 CHAPTERS

Windows and matching ↗

Where match lengths and distances come from, and why recent history is enough.

02 / 3 CHAPTERS

Huffman construction ↗

Use fewer bits for frequent symbols and reconstruct the same codes at the decoder.

03 / 4 CHAPTERS

Blocks and compression output ↗

Write selected symbols into compressed blocks and safely deliver their bytes.

04 / 4 CHAPTERS

Bit input, decode tables, and copying ↗

Read compressed bytes, identify symbols, and recover the original data.

05 / 3 CHAPTERS

Streaming state and wrappers ↗

Understand why one task spans calls and how it resumes after a pause.

06 / 3 CHAPTERS

State operations and resource lifetime ↗

Start, reuse, copy, and end tasks while handling allocation failure.

07 / 3 CHAPTERS

Checksums and composition ↗

Check data across batches and retain the information needed to combine sequences.

08 / 4 CHAPTERS

Application interfaces and external interaction ↗

Choose suitable calls for whole buffers, callbacks, and gzip files.

From overview to detailed reading

Overview topicImplementation detailProof connection
Block types and costsSymbol accounting and block costsSymbol and format meaning
Bit order and buffersThe bit register, valid-bit count, and pending bytesThe bitstring across a write
Streaming callsShared storage and output deliveryPrefix bounds and call composition

Complete reference

Function pages retain complete domains, results, and error paths. Follow chapter links into component arguments and Lean proof bodies.

All public APIs ↗inflate / deflate ↗Documentation index ↗
ZLIB × LEAN

Global contents

READING NOWzlib × Lean