Formal verification of critical theorems for the epoch-based deterministic framework presented in the Collatz conjecture paper.
This repository contains Lean 4 formalizations of key mathematical results related to the Collatz conjecture (3x+1 problem). The formalization focuses on three core components:
- OrdβFact: Multiplicative order of 3 modulo powers of 2
- Semigroup β¨Ξβ©: Junction shift generation of cyclic groups
- SEDT: Scaled Epoch Drift Theorem (negative drift envelope)
Theorem | File | Status | Description |
---|---|---|---|
OrdβFact | Collatz/OrdFact.lean |
β Proven | ord_{2^t}(3) = 2^{t-2} for t β₯ 3 |
β¨Ξβ© generates Z/Q_t Z | Collatz/Semigroup.lean |
β Proven | Junction shifts additively generate full group |
SEDT envelope | Collatz/SEDT.lean |
β Statement formalized | Negative drift ΞV β€ -Ρ·L + Ξ²Β·C for long epochs |
- β
Proven: No
sorry
placeholders, all steps verified - π‘ Structured: Logical structure complete, some steps documented as
sorry
- π Statement only: Theorem formalized, proof deferred as future work
collatz-lean4/
βββ Collatz/
β βββ Basic.lean # Core Collatz definitions (T_odd, e, depth_minus)
β βββ Arithmetic.lean # Foundational arithmetic lemmas (20/23 proven)
β βββ OrdFact.lean # OrdβFact theorem + examples t=3,4,5 (proven!)
β βββ Epoch.lean # Epoch and Phase type definitions
β βββ Semigroup.lean # Junction shift semigroup β¨Ξβ©
β βββ SEDT.lean # SEDT envelope theorem
β βββ Examples.lean # Worked examples (15 examples)
β
βββ lakefile.lean # Lake build configuration
βββ lean-toolchain # Lean version (v4.24.0-rc1)
βββ README.md # This file
# Clone the repository
git clone <repository-url>
cd collatz-lean4
# Build the project
lake build
# Build examples module (optional)
lake build Collatz.Examples
If everything is configured, lake build
should complete successfully.
Theorem (OrdFact.lean
):
For t β₯ 3, the multiplicative order of 3 modulo 2^t equals 2^{t-2}.
theorem ord_three_mod_pow_two (t : β) (ht : t β₯ 3) :
orderOf (3 : ZMod (2^t)) = Q_t t
Examples (all proven with decide
):
example : orderOf (3 : ZMod 8) = 2 := by decide -- t=3 β
example : orderOf (3 : ZMod 16) = 4 := by decide -- t=4 β
example : orderOf (3 : ZMod 32) = 8 := by decide -- t=5 β
Proof Strategy:
- Upper bound: 3^{2^{t-2}} β‘ 1 (mod 2^t) via induction + lifting lemma
- Lower bound: Minimality via 2-adic valuation
- Main theorem: Combine using
orderOf_dvd_iff
+Nat.dvd_prime_pow
Theorem (Semigroup.lean
):
The additive subgroup generated by junction shifts equals Z/Q_t Z.
theorem delta_generates {t : β} (ht : t β₯ 3) :
AddSubgroup.closure (@DeltaSet t) = β€
Proof Strategy:
- DeltaSet contains 1 (trivial junction)
- 1 is odd β primitive generator of Z/Q_t Z
- β¨1β© = Z/Q_t Z β β¨DeltaSetβ© β β¨DeltaSetβ© = Z/Q_t Z
Theorem (SEDT.lean
):
For long t-epochs (L β₯ Lβ) with Ξ² > Ξ²β(t,U):
ΞV β€ -Ξ΅(t,U;Ξ²)Β·L + Ξ²Β·C(t,U), where Ξ΅ > 0
theorem sedt_envelope (t U : β) (e : SEDTEpoch) (Ξ² : β)
(ht : t β₯ 3) (hU : U β₯ 1) (hΞ² : Ξ² > Ξ²β t U) (h_long : e.length β₯ Lβ t U) :
β (ΞV : β), ΞV β€ -(Ξ΅ t U Ξ²) * (e.length : β) + Ξ² * (C t U : β) β§ ΞV < 0
Constants defined:
- Ξ±(t,U): Touch frequency parameter
- Ξ²β(t,U): Threshold for Ξ²
- Ξ΅(t,U;Ξ²): Negative drift coefficient (Ξ²(2-Ξ±) - logβ(3/2))
- C(t,U), Lβ(t,U), K_glue(t): Overhead bounds
# Build a specific module
lake build Collatz.OrdFact
# Check a file for errors
lake env lean Collatz/Arithmetic.lean
Collatz/Arithmetic.lean
: 0sorry
(complete)Collatz/OrdFact.lean
: 0sorry
(complete; main theorem proven)Collatz/Semigroup.lean
: 0sorry
(complete; junction shift generation proven)Collatz/SEDT.lean
: may contain remainingsorry
items marked for future work
GitHub Actions automatically:
- β Builds the project on push/PR
- β Caches Lake dependencies
- β Runs examples
- β Generates build summaries
See .github/workflows/lean.yml
for details.
See ../collatz-paper/
for the main mathematical paper and computational verification scripts.
Lean Theorem | Paper Reference |
---|---|
ord_three_mod_pow_two |
Lemma A.LOG.1 (OrdβFact) |
delta_generates |
Theorem A.HMix(t) + A.MIX.4 |
sedt_envelope |
Theorem A.E4 (SEDT) |
- Lean 4: v4.24.0-rc1 or later
- mathlib4: latest (resolved by Lake)
- Create a new
.lean
file inCollatz/
- Import required modules
- Add to
Collatz.lean
(main file) - Build and test:
lake build
Priority areas for contributions:
SEDT.lean
: strengthening envelope bounds and completing deferred steps
- OrdβFact main theorem: proven
- Semigroup generation: proven
- Arithmetic lemmas: complete
- CI: builds on push/PR via GitHub Actions
- Complete SEDT envelope proof (~5-10 hours)
- Add more worked examples for SEDT
- Full SEDT proof (multi-step induction)
- Cycle exclusion formalization (Appendix B)
- Coercivity proof (Appendix C)
- Integration with computational verification results
MIT β see LICENSE
.
- Lean 4 community for mathlib and excellent documentation
- Expert consultations on
orderOf
patterns and modular arithmetic - Paper reviewers for suggesting formal verification
Last Updated: October 2025
Maintainer: Anatolii Shumak
Paper: See ../collatz-paper/
for mathematical details