AFTD Auto-Formalizing Theoretical Domains

codeA

defimported Lean

For naturals $n$ and $d$, $A(n,d)$ is the supremum of the cardinalities $k$ for which there is a finite set $C$ of binary codewords $\mathrm{Fin}\,n \to \mathrm{Bool}$ with $|C| = k$ and such that any two distinct $x, y \in C$ differ in at least $d$ coordinates.

Statement

set_option autoImplicit true in
set_option relaxedAutoImplicit true in
open scoped BigOperators in
set_option maxHeartbeats 800000 in
noncomputable def codeA (n d : ℕ) : ℕ
Defined in
TCSlib, `codeA`
Lean proof
By Frederick Dehmel, Hydroxyi (from the file's git history), from github.com/Shilun-Allan-Li/tcslib at c8a02591b1e5 (Apache-2.0). Compiled here against leanprover/lean4:v4.33.1, Mathlib v4.33.1; written for leanprover/lean4:v4.25.0.
Verified
07 Oct 2026
Axioms
none listed
Used by 1
  • rateFor $\delta \in [0,1]$, the asymptotic rate is \[ R(\delta) \;=\; \limsup_{n\to\infty} \frac{1}{n}\log_2 A(n, \lfloor \delta n \rfloor). \]

Lean source view module on GitHub

set_option autoImplicit true in
set_option relaxedAutoImplicit true in
open scoped BigOperators in
set_option maxHeartbeats 800000 in
/-- **Definition 1 (maximum code size)** from the source file. For integers `n ≥ 1` and `1 ≤ d ≤ n`, `codeA n d` denotes the maximum size of a binary code `C ⊆ {0,1}^n` with minimum Hamming distance at least `d`. The Hamming distance between two codewords is defined as the number of coordinates at which they differ. -/
noncomputable def codeA (n d : ℕ) : ℕ :=
  sSup {k : ℕ | ∃ (C : Finset (Fin n → Bool)),
    C.card = k ∧ ∀ x ∈ C, ∀ y ∈ C, x ≠ y →
      (Finset.univ.filter fun i => x i ≠ y i).card ≥ d}
See it in the graphDiscuss this resultChallenge it