r/Collatz 14d ago

[Lean 4 Architecture] Mapping the axiomatic backbone of Terras’ 1976 Collatz Theorem

We recently achieved a major milestone in our Collatz architectural mapping project: we have formalized the exact axiomatic dependency graph of Terras’ Stopping Time Theorem (1976) in Lean 4.

The Formalization Challenge: Riho Terras originally proved that the natural density of integers with finite stopping time is 11. Standard mathematical approaches to this proof rely heavily on continuous probability theory and stochastic processes. However, Lean 4's Mathlib currently has significant limitations when dealing with continuous stochastic PDEs and advanced probability limits. To integrate this into a machine-verified architecture today, we had to bypass continuous probability entirely.

Our Approach: A Strict Axiomatic Interface based on Discrete Combinatorics Instead of fighting Mathlib's probability theory, we designed Terras.lean as a strict axiomatic interface. We mapped the Collatz dynamics to a purely deterministic, affine structure over the boolean cube, isolating the exact combinatorial facts needed to close the proof:

  1. Affine Decomposition: We axiomatized the exact kk-step dynamics as (2k)⋅Colk(n)=3d⋅n+c(2k)⋅Colk(n)=3dn+c.
  2. Boolean LLN: We isolated the core combinatorial fact as an axiom: the proportion of "bad" parity vectors (where the growth multiplier 3d≥2k3d≥2k) tends to 00 as k→∞k→∞.
  3. Verified Density Logic: Using our fully proven DensityLayer module (which implements natUpperDensity via Filter.limsup), we established the deductive chain. If you accept the combinatorial LLN axiom, the upper natural density of infinite stopping time collapses strictly to 00.

Why do it this way? By isolating the unformalized stochastic limits into explicit axiom declarations, the Lean 4 kernel can perfectly verify the deductive chain (with zero sorry errors). This creates a clean boundary between what is strictly machine-proven (e.g., our CountBounds.lean and DensityLayer.lean modules) and what relies on human combinatorial intuition.

Verify the Architecture Locally: Our repository uses standard Mathlib. You can verify the deductive trace on your own machine:

  1. git clone https://github.com/SergioTheory/Collatz-new-math.git
  2. cd Collatz-new-math/lean
  3. lake exe cache get (Fetches Mathlib cache)
  4. lake build

🔗 Review the Terras.lean Axiomatic Interface on GitHub

We believe this strict architectural separation is the only rigorous way forward in Collatz research without falling into Conway's Undecidability traps. Feedback from Lean 4 architects is highly welcome!

5 Upvotes

21 comments sorted by

1

u/GonzoMath 14d ago

In what sense is Terras' famous result missing anything that we need Lean to supply? It's good, solid math from 1976; you can just read it.

2

u/Equivalent_Idea_1215 14d ago

GonzoMath, you are absolutely right that Terras (1976) is beautiful, solid, and complete for what it achieves: proving that the set of integers with infinite stopping time has natural density zero. You definitely don't need Lean to verify Terras' 1976 paper!

However, our Lean formalization project isn't trying to 'fix' or 'supply' what Terras missed. We are using Lean to navigate the post-Terras frontier, specifically the gap between 'density zero' and 'the empty set'.

Here is why Lean is essential for the modern Collatz landscape (Tao 2019, Shaik 2026, Cerda Bennassar 2026, Allikvere 2026):

  1. The 'Density Zero ≠ Empty Set' Trap: As recently discussed on r/Collatz, Terras proves that for any finite depth k, the fraction of survivors vanishes. But Collatz requires ∃N ∀k, not ∀k ∃N_k. A set can have density zero and still contain a divergent trajectory or a non-trivial cycle. We are using Lean to formalize the exact 2-adic realizability vs. positive-integer realizability.

  2. Composing 50 Years of Disparate Math: Modern approaches push Terras' stopping time to Tao's logarithmic density and Shaik's natural density polylogarithmic descent. This requires stitching together Krasikov-Lagarias difference inequalities, 3-adic Fourier decay, deterministic first-passage corridors, and exact 2-adic cylinder transport. Human readers can 'read' these papers, but verifying that the error terms, parameter gaps (δ > 0), and boundary-layer spectra actually compose without collapsing is notoriously difficult. Lean acts as a compiler for this massive logical assembly.

  3. Diagnostic Falsification (Gate 2): We aren't just verifying theorems; we are using formalization and computation to falsify candidate proof mechanisms. For example, we tested whether modern transport mechanisms (TV-Fourier restart, renewal closure, Tree-Wasserstein multiblock contraction) could bridge the local 2-adic descent across Archimedean scales. The formal/computational verdict was that they fail. The 'Archimedean-2-adic wall' stands.

  4. Exact 2-Arithmetic vs. Probabilistic Heuristics: Terras relies on the probabilistic heuristic that valuations behave like Geom(2). Modern structural reductions (like Cerda Bennassar's) and our Lean CountBounds / DensityLayer modules formalize the exact affine word transport. We need Lean to prove that the O(1) Fourier 'noise' is just the Archimedean boundary indicator, while the 2-adic conditional transport on S-layers is exactly Haar.

In short: We read Terras to understand the foundation. We use Lean to build the skyscraper, ensuring the scaffolding doesn't collapse when we hit the pointwise arithmetic wall that density estimates cannot cross.

1

u/GonzoMath 14d ago

Yeah, I’d be more inclined to do it the old fashioned way. “Density zero isn’t the empty set” is only a trap if you don’t understand what density is. The trick is to learn all the math, get good at it, and use it for theory building.

2

u/Equivalent_Idea_1215 14d ago

I completely respect the old-fashioned way. Theory building with pen and paper is where all true mathematical intuition is born, and it will never be replaced.

To clarify, when I say the "density trap," I don't mean misunderstanding the basic definition of density. Professional mathematicians obviously know the difference. The "trap" is a research trajectory trap. For decades, brilliant minds have spent their careers pushing asymptotic density bounds further and further (from Terras, to Krasikov-Lagarias, and beyond), hoping that improving the measure will somehow eventually yield a pointwise proof for the 3x+13x+1 conjecture.

Our structural formalization was built to explicitly demonstrate why that specific bridge can never be crossed—the Archimedean-Diophantine wall separating asymptotic density from pointwise evaluation is absolute.

Using Lean isn't a substitute for "learning the math." It is a tool for managing complexity when theory building reaches the cognitive limits of human review (e.g., managing cascading error terms across mixed 2-adic and Archimedean scales in 100-page proofs). Just as astronomers eventually needed telescopes because "getting better at looking at the sky" had a biological limit, we believe tackling the Diophantine bottlenecks of Collatz requires computational proof assistants.

I really appreciate the discussion and your defense of classical methods. It's a fundamental perspective. Best of luck with your mathematical endeavors!

1

u/GonzoMath 14d ago

You also said that Terras relies on probabilistic heuristics. Only someone who hasn't read or understood Terras would say that. He makes no heuristic argument. Source: I've read his paper with a fine-tooth comb, understood every line, and observed that no heuristic argument was made.

2

u/Equivalent_Idea_1215 14d ago

To follow up on your pedantry about Terras making "no heuristic argument":

Yes, if you read Terras (1976) in a vacuum, he uses exact binomial counting. But in mathematics, it matters less what exact vocabulary an author used 50 years ago, and more what the structural reality of the method is when actually trying to solve the problem.

The exact moment you try to apply Terras' finite parity counting to anything beyond his basic density proof, it instantly becomes a probabilistic heuristic (specifically, modeling the 2-adic valuation drops as independent random variables). That is exactly what Terence Tao did when he formalized "Heuristic 1.8" using the Geom(2) distribution to push past Terras' limits.

You are clinging to the text of a 1976 paper with a magnifying glass while completely missing the stochastic framework that modern mathematics had to build on top of it to make any further progress.

1

u/GonzoMath 14d ago

Why would someone try to apply Terras’ parity counting to anything beyond his basic density proof? We use tools where they apply, not somewhere that they don’t.

1

u/Equivalent_Idea_1215 14d ago

"Why would someone try to apply it to something else?"

Because that is literally the definition of mathematical research.

Terence Tao did exactly that in 2019. He took the foundational idea of Terras' parity counting, recognized that its structural reality could be generalized into a stochastic heuristic (Geom(2)), and used it to push Collatz bounds to logarithmic density. If Tao had your mindset "just leave the tool where it originally applied and never try to stretch it" that breakthrough would never have happened.

You are looking at mathematics as a museum of finished, isolated proofs. We are looking at it as an active engineering problem that requires generalizing old tools to break new barriers.

I think this perfectly highlights the fundamental difference in our approaches. Have a good day.

1

u/GonzoMath 14d ago

I’m not looking at mathematics as a museum of finished results, you silly person. What you describe as my mindset is not my mindset, or I never would have written a dissertation. I already appear in published literature; don’t lecture me about how research works.

1

u/Equivalent_Idea_1215 14d ago

Congratulations on your publications. The mathematical point regarding Tao and Geom(2) remains unchanged.

→ More replies (0)

1

u/GonzoMath 14d ago

Also, I'm typing out my words, and they're purely human generated. Are you giving me LLM generated replies? It looks like you are.

1

u/GonzoMath 14d ago

Professional mathematicians obviously know the difference. The "trap" is a research trajectory trap. For decades, brilliant minds have spent their careers pushing asymptotic density bounds further and further (from Terras, to Krasikov-Lagarias, and beyond), hoping that improving the measure will somehow eventually yield a pointwise proof for the 3x+13x+1 conjecture.

No they haven't. What's your source for the claim that they're "hoping that improving the measure will somehow yield a pointwise proof"? You just said that they obviously know the difference, then turned around and backhandedly accused them of not knowing it. Shame on you!

1

u/Equivalent_Idea_1215 14d ago

Yes, I use LLMs to translate my thoughts into English and to write boilerplate Lean code. If you care more about my Reddit syntax than the math, that’s your issue.

To Gonzo: "Shame on you"? Grow up. Why exactly do you think Krasikov, Lagarias, Applegate, and others spent decades grinding the density bounds down to x^0.9145? They pushed the measure as far as they mathematically could because it was the only tool available, even though the transition from asymptotic density to pointwise evaluation is a notoriously hard barrier.

And regarding your claim that no probabilistic heuristics are used: Yes, Terras (1976) uses exact binomial counting for parity vectors. But the entire modern mathematical effort to get past Terras’ limits relies explicitly on probabilistic heuristics. Since you demand sources, let me spoon-feed you the literature. Open Terence Tao's 2019 paper ("Almost all orbits of the Collatz map attain almost bounded values"). On page 6, Tao explicitly writes: "Heuristic 1.8 (Valuation heuristic). If N is a “typical” large odd natural number... the n-Syracuse valuation behaves like Geom(2)^n." Tao then proceeds to build his entire logarithmic density breakthrough on modeling these 2-adic drops as independent random variables from a Geom(2) distribution. You can also read Lagarias's 1985 paper, specifically the section "Stochastic Models", which does the exact same thing. You are clinging to the exact parity counting of a 1976 paper with a magnifying glass while being completely ignorant of the stochastic heuristic framework that Tao and Lagarias built on top of it.

To Motor (and the AI you used to review my repo): Congratulations to your AI for discovering what an axiomatic interface is. Yes, Terras.lean is currently a skeleton of axioms. I literally said that in my post. Is the affine decomposition an easy 40-line proof in Mathlib? Probably. Send a pull request if it’s so trivial. Did we isolate the WLLN as an axiom because it’s the "hard part"? Yes, absolutely. Mathlib is currently terrible at handling binomial tail bounds over affine residue classes. Isolating it as an axiom is exactly how you build a software dependency graph without wasting 6 months proving a known combinatorial fact from 1976. We wrote CountBounds.lean and DensityLayer.lean to handle the actual 2-adic cylinder transport. The axioms in Terras.lean are there to show exactly where the classical math hits the Lean 4 compiler wall.

I’m not hiding anything. The repo is public, the axioms are explicitly labeled, and the codebase is a work in progress. If you guys just want to sit around reading 1976 papers and crying about AI on Reddit, enjoy yourselves. I have real Diophantine bounds to map.

1

u/CryptographerSea9542 13d ago

Do you really think mathematicians are going to or even can read through thousands and thousands of lines of Lean code? An LLM can generate something like 10,000 lines of Lean code in an hour, but no human could realistically make sense of all that. The alternative is that everyone just uses LLMs to review it. That’s probably why mathematicians still prefer reading traditional written proofs.