Skip to content
ZLIB × LEAN / ALGORITHM DETAIL & VERIFICATION

Algorithm detail and formal verification

Open the implementation, then connect the argument at every step.

A compression task begins with caller-provided bytes. Windows and matching produce symbols; the encoder turns symbols into bits; the decoder recovers bytes. Caller buffers can change between calls, and allocation can fail.

The proof follows those actual objects. Read a component’s algorithms, layouts, and optimizations first, then the relations it establishes and passes onward. Each topic ends with a proof chapter, linked back to its algorithm background.

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
Object in the taskProof connection
Input and symbolsChosen symbols expand to the accepted input.
Encoding and decodingActual output satisfies an independent format relation and decodes to the same bytes.
States across callsEvery legal return preserves a usable state and exact consumption and delivery.
Live memory and resourcesAccesses are valid, unrelated objects are preserved, and allocations and frees are accounted for.
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.

Targets, implementation, and acceptance scope

Chapters distinguish source readings, available local results, and remaining composition obligations. Follow links to complete targets, caller premises, and Lean proof bodies. The project progress page records acceptance scope and remaining work.

Complete targets and call sequences ↗Translation and model boundary ↗Project progress ↗
ZLIB × LEAN

Global contents

READING NOWAlgorithm detail and formal verification