# Singer's Theorem — Lean 4 Formalization A complete, zero-sorry Lean 4 formalization of Singer's theorem on cyclic difference sets and Sidon set infrastructure for additive combinatorics. ## Overview This repository contains a verified Lean 4 proof of Singer's theorem (1938). It formalizes the prime-field construction and its prime-power extension: for every prime power `q = p^k`, the projective-line construction over a degree-three extension of `GaloisField p k` gives a Sidon set modulo `q² + q + 1` of size `q + 1`. The formalization builds reusable infrastructure for Sidon set theory, including: - **`IsSidon`** / **`IsSidonMod`** / **`IsIntervalSidon`** — predicates for Sidon sets in various contexts - **Singer construction** — the full algebraic chain from finite field trace through kernel dimension to the combinatorial Sidon property, including the prime-power family theorem - **Lindström's bounds** — the classical √(2N) counting bound and the improved √N + N^(1/4) + O(1) Johnson/Lindström upper bound - **Unconditional two-sided Θ(√N) bounds** — matching upper and lower bounds for the extremal Sidon function - **Structural Sidon identities** — exact cardinalities for sumsets and difference sets, additive energy, and a sumset-cardinality characterization of finite Sidon sets - **Representation functions** — ordered pair-sum bounds and exact L¹/L² identities for integer Sidon sets - **Conditional reduction** — a verified reduction from prime gap hypotheses to asymptotic Sidon set bounds (Erdős Problem B₃₀) ## Prime-power export provenance The prime-power Singer modules were exported from `d0d1/erdos/work/erdos-30/formal/Erdos30/` at commit `ca225a0bb39ce131d31d8a949133b3c17f60acfa`. The public-export edits are limited to neutralized comments/docstrings plus a local `PrimeGapExponent` definition in `PrimePowerLowerBound.lean`, needed because this public artifact predates that interface in its older `ConditionalLowerBound.lean`. ## Mathematical Content The core algebraic chain establishes: 1. `finrank_ker_trace`: The kernel of the finite field trace has dimension 2. 2. `no_proper_invariant_subspace`: No proper subspace is invariant under the Frobenius action. 3. `finrank_inf_of_distinct_twodim`: Distinct Frobenius orbits yield distinct two-dimensional subspaces. 4. `singer_sidon_mod`: The prime-field Singer set is Sidon modulo p² + p + 1. 5. `singer_theorem`: Prime-field statement — existence of a Sidon set of size p + 1 in ℤ/(p² + p + 1)ℤ. 6. `SingerPrimePower.singer_primePower_sidon_set_KL`: Prime-power statement for `q = p^k`, giving a Sidon set of size q + 1 in ℤ/(q² + q + 1)ℤ. 7. `singerPrimePowerFamilyHypothesis_holds`: Discharge of the prime-power Singer family hypothesis used by the prime-power lower-bound reduction. The structural Sidon modules also prove: 1. `IsSidon.card_add`: exact sumset cardinality `|A + A| = |A|(|A|+1)/2`. 2. `isSidon_iff_card_add`: the corresponding characterization by maximum sumset cardinality. 3. `IsSidon.card_sub`: exact difference-set cardinality `|A - A| = |A|² - |A| + 1` for nonempty Sidon sets. 4. `IsSidon.addEnergy_eq`: exact additive energy `2|A|² - |A|`. 5. `IsSidon.card_sub_ge_card_add`: difference-dominance `|A - A| ≥ |A + A|` for nonempty Sidon sets. The extremal-bound and representation-function modules additionally prove: 1. `sidonMaximum_le_lindstrom`: the improved upper bound `h(N) ≤ ⌊√N⌋ + ⌊√⌊√N⌋⌋ + 2` for `N ≥ 16`. 2. `sidonUpperBound_quarter`: the upper-bound hypothesis holds unconditionally for every exponent `ε ≥ 1/4`. 3. `erdos30_of_gap_and_upper`: after discharging the Singer-family hypothesis, subpolynomial prime gaps plus the Sidon upper-bound hypothesis imply `Erdos30Statement`. 4. `IsSidon.repr_le_two`: for an integer Sidon set, every ordered pair-sum representation count is at most `2`. 5. `IsSidon.sum_addConvolution_sq`: exact L² identity `∑ r_A(n)^2 = 2|A|² - |A|`. 6. `IsSidon.sum_deficiency`: exact deficiency identity `∑ (2 - r_A(n)) = |A|`. ## Project Structure ``` ├── Erdos30.lean # Root module (imports all) ├── Erdos30/ │ ├── Sidon.lean # Sidon set predicates │ ├── Interval.lean # Interval Sidon infrastructure │ ├── Singer.lean # Core algebraic construction │ ├── SingerBridge.lean # Algebra → combinatorics bridge │ ├── SingerSidon.lean # Modular Sidon property │ ├── SingerTheorem.lean # Full Singer theorem │ ├── SingerPrimePower*.lean # Prime-power Singer family theorem │ ├── Lindstrom.lean # Classical upper bound │ ├── LindstromImproved.lean # Johnson/Lindström improved upper bound │ ├── RepresentationFunction.lean # Pair-sum representation bound │ ├── RepresentationL2.lean # L¹/L² representation identities │ ├── AdditiveEnergy.lean # Exact additive energy for Sidon sets │ ├── DifferenceSet.lean # Exact difference-set cardinality │ ├── SumsetCard.lean # Exact sumset cardinality │ ├── SidonCharacterization.lean # Sumset-cardinality characterization │ ├── SumDiffComparison.lean # Sumset/difference-set comparison │ ├── FormalStatement.lean # Extremal function definition │ ├── UnconditionalBounds.lean # Two-sided Θ(√N) │ ├── PrimePowerLowerBound.lean # Prime-power lower-bound reduction │ ├── ConditionalLowerBound.lean # Conditional reduction │ ├── ConditionalErdos30.lean # Discharged conditional Erdős 30 │ ├── FinalTheoremSurface.lean # Final theorem assembly │ ├── Boundary*.lean # Boundary analysis infrastructure │ └── ... # Supporting modules ├── lakefile.toml # Lake project configuration ├── lean-toolchain # Lean version (v4.29.0) ├── lake-manifest.json # Dependency lock file └── LICENSE # GPL-3.0-only ``` ## Building ### Prerequisites - [Lean 4](https://lean-lang.org/) (v4.29.0, specified in `lean-toolchain`) - [Lake](https://github.com/leanprover/lean4/tree/master/src/lake) (bundled with Lean) ### Steps ```bash lake exe cache get # Fetch precompiled Mathlib artifacts for the pinned manifest lake build # Build the full project (requires ~32 GB RAM for Mathlib) ``` The cited theorem targets build successfully and contain no `sorry` proof placeholders. Some pre-existing modules currently emit linter warnings; the new Lindström and representation-function targets build without warnings. ### Verification To confirm zero sorry usage: ```bash lake env lean --run Erdos30.lean 2>&1 | grep -i sorry # Expected: no output ``` Or inspect the `.olean` files: ```bash grep -r "sorry" .lake/build/lib/ 2>/dev/null # Expected: no output ``` ## Dependencies - **Mathlib** v4.29.0 (`leanprover-community/mathlib4`) ## License This project is licensed under the **GNU General Public License v3.0 only** — see the [LICENSE](LICENSE) file for details. ## Citation If you use this formalization in your work, please cite: ```bibtex @software{hulak2026singer, author = {Hulak, David B. and Ramos, Arthur F. and de Queiroz, Ruy J. G. B.}, title = {Singer's Theorem --- Lean 4 Formalization}, year = {2026}, url = {https://github.com/d0d1/singer-theorem-lean} } ```