← All papers
First page of A machine-checked proof of the Dong-Yang classification of optimal (n,4) binary codes for BSCs

A machine-checked proof of the Dong-Yang classification of optimal (n,4) binary codes for BSCs

Shenghao Yang, Yanyan Dong

math.HO Sep 5, 2026 · v1 cs.AI cs.IT
Lean 4 formalizes and kernel-checks Dong-Yang's classification of optimal (n,4) binary codes for BSCs, using AI-generated proofs on Mathlib.
We present a machine-checked Lean 4 formalization of Dong and Yang's classification of optimal finite-length $(n,4)$ binary block codes for binary symmetric channels. The formalization was developed mainly by feeding the paper's proofs to an AI tool. To establish correctness, the authors verified the main theorem statements in Lean and the accepted axioms. This note discusses the corrections and simplifications made to the AI-generated formalization, and records discrepancies found in the paper during the formalization. The Lean code is available at https://github.com/shhyang/n4code_lean.

Dong and Yang's 27-page classification of optimal finite-length (n,4) binary block codes for binary symmetric channels is long and complex, making human verification difficult. The goal is a machine-checked correctness guarantee for its classification theorems (Theorems 1-5).

The paper's LaTeX source is fed to AI coding agents (OpenAI Codex models) to autoformalize the proofs in Lean 4, building on Mathlib for finite types, big sums, parity, and real arithmetic. Codes are modeled with columns as the primary object (Code n = Fin n → Column). Parallel AI agents discharge the generated sorry statements, followed by a human-guided axiom audit ensuring dependence only on Lean's standard base axioms (propext, Quot.sound, Classical.choice) and elimination of native_decide.

The resulting library is sorry-free and axiom-audited, totaling 37,561 lines across fourteen modules, with lake build succeeding and every headline theorem proved. Formalization exposed imprecise hypotheses and gaps in the original paper's proofs, leading to strengthened statements and a catalogue of discrepancies.

LocationTypeIssue
§II-AgapMultiset invariance stated, not proved
Cor. 10gapThm. 8 only for w(c3⊕c4) even
Thm. 16, n=3strengthVacuous; Lean adds DistinctRows
Thm. 16, n=2errorn=2 case impossible under Class-I parity
Lem. 15 Case 1labeling"Class-II-b" should be Class-III-b
Selected discrepancies between the published paper and the formalization