Richard Hoekstra
We formalize the complete algebraic theory of the dual numbers in Lean 4 with near-zero sorry count. From the single axiom (epsilon nonzero, epsilon squared equals zero) we derive: nilpotency and automatic differentiation (Epsilon.lean), the periodic resolution with exact ker(multiplication by epsilon) = im(multiplication by epsilon) (EpsilonModule.lean), the entanglement relation epsilon times d-epsilon equals zero (EpsilonDeriv.lean), the universal deformation eta squared equals t times eta (EpsilonDeform.lean), uniqueness of order 2 among nilpotent algebras (EpsilonVariations.lean), the Hamming code structure with square-zero codewords (EpsilonHamming.lean), the Kraft-saturating ternary structure (EpsilonTernary.lean), three indecomposable modules with non-split short exact sequence (ThreeIndecomposables.lean), the A2 Auslander-Reiten quiver (ARQuiver.lean), cotangent cohomology T-superscript-1 isomorphic to k (Cotangent.lean), Knoerrer periodicity (Knorrer.lean), matrix factorizations with K0 isomorphic to Z/2Z (MatrixFactorization.lean), the Hecke-Hodge filtered triple functor (HeckeHodgeFunctor.lean), spectral degeneration via the Artinian descending chain condition (SpectralDegeneration.lean), Hochschild cohomology HH-superscript-n isomorphic to k for all n (Hochschild.lean), Koszul duality Ext equals k[x] (KoszulDual.lean), A-infinity minimality with m3 nonzero and m4 equals zero (AInfinity.lean), Church-Rosser from NilSquare determinism (ChurchRosser.lean), P versus NP as NilSquare failure (ComplexityNilSquare.lean), 1-truncation of evaluation paths (NilSquareTruncation.lean), the Koszul composition operad (CompositionOperad.lean), and the motivic Galois group Z/2Z (MotivicGalois.lean). The Krivine bridge instantiates the entire tower for TLC reduction via TrivSqZeroExt, after proving that the naive (id minus nf1)-squared does not equal zero (KrivineNilSquareFalsification.lean) and constructing the correct bridge through the trivial square-zero extension (KrivineNilSquare.lean). The universal realization maps any NilSquare ring into the tower (KrivineNilSquareUniversal.lean). Self-measurement yields K(eps_sq) = 5 exactly (KLowerBound.lean, KFiveUniversal.lean), universal across all x-squared-equals-c axiom systems. Total: 175 files, 28000+ lines, 11 sorry (8 in peripheral files: RiceSpectral.lean, RuelleGap.lean, LanglandsFunctor.lean; the epsilon tower core is sorry-free).
One axiom, everything follows.
Let R be a commutative ring with a distinguished element epsilon satisfying epsilon nonzero and epsilon squared equals zero. This is the algebra of dual numbers k[epsilon]/(epsilon-squared), the simplest non-trivial quotient of a polynomial ring. It is also the algebraic incarnation of first-order perturbation theory, automatic differentiation, and the tangent bundle of a point.
The claim of this paper is that this single axiom — encoded in Lean 4 as the typeclass NilSquare — forces a seventeen-layer tower of algebraic structure, from elementary ring theory through representation theory, homological algebra, deformation theory, A-infinity structures, and operadic Koszul duality, all the way to a concrete bridge connecting abstract algebra to lambda-calculus reduction. Every theorem in the tower is machine-checked. The sorry count in the core tower files is zero.
The tower terminates in self-measurement: the proof term witnessing epsilon-squared-equals-zero has Kolmogorov complexity exactly 5 (DAG nodes after hash-consing), and this value is universal across all axiom systems of the form x-squared-equals-c. Any algebraically more complex axiom has K at least 7. The snake measures its own length.
The Lean 4 formalization lives in 175 files totaling over 28,000 lines. The core epsilon tower comprises 17 files from Epsilon.lean to AInfinity.lean, plus the Krivine bridge files and the self-measurement files. The remainder of the repository provides the TLC lambda calculus, compression infrastructure, and applications.
The NilSquare typeclass:
class NilSquare (R : Type u) [CommRing R] where
epsilon : R
eps_ne_zero : epsilon != 0
eps_sq : epsilon * epsilon = 0
From this we derive immediately:
eps_pow_two: epsilon to the power 2 equals 0 (restated as a power).eps_nilpotent: epsilon is nilpotent (witness: exponent 2).eps_zero_divisor: epsilon is a zero divisor (witness: epsilon itself).eps_sq_mul: epsilon-squared times r equals 0 for all r.dual_mul: the automatic differentiation property. (a + bepsilon)(c + depsilon) = ac + (ad + bc)*epsilon.The last theorem is the algebraic content of forward-mode automatic differentiation. The cross-term bd*epsilon-squared vanishes, leaving only the first-order (linear) perturbation. This is not a design choice; it is forced by the axiom.
The R-linear map mulEps : R -> R defined by r maps-to epsilon*r satisfies:
mulEps_comp_zero: (multiplication by epsilon) composed with itself equals zero. This is the chain complex condition.Under the strengthened assumption NilSquareLocal (every non-unit is divisible by epsilon, modeling R isomorphic to k[epsilon]/(epsilon-squared)):
exact_iff: epsilon*r = 0 if and only if epsilon divides r. That is, ker(multiplication by epsilon) = im(multiplication by epsilon).This exactness is the periodic resolution:
... -> R ->(mult. by eps)-> R ->(mult. by eps)-> R -> k -> 0
exact at every R-term, with period 1. From this resolution, all higher cohomological results follow mechanically.
For any derivation D : R -> M (where M is an R-module), the Leibniz rule on epsilon-squared gives:
deriv_eps_sq_eq_zero: D(epsilon*epsilon) = 0 (since epsilon-squared = 0).deriv_eps_sq_leibniz: D(epsilonepsilon) = epsilonD(epsilon) + epsilon*D(epsilon) (by Leibniz).two_eps_smul_Deps: combining, epsilonD(epsilon) + epsilonD(epsilon) = 0.In characteristic not equal to 2: epsilonD(epsilon) = 0. This is the entanglement relation: position (epsilon) and velocity (D(epsilon)) cannot simultaneously be nonzero. The module of Kaehler differentials is generated by d-epsilon with the single relation epsilond-epsilon = 0, so Omega-superscript-1(R/k) is isomorphic to k.
The Deformation structure packages a pair (eta, t) with etaeta = teta. The singular fiber sets t = 0, recovering epsilon-squared = 0. Key results:
singularFiber: epsilon with t = 0 satisfies the deformation equation.deform_factored: eta*(eta - t) = 0. The singularity factors.deform_cube: eta-cubed = t-squared*eta (iterating the relation).deform_idempotent: when t is a unit, eta/t is idempotent. The singularity resolves into a clean splitting.The deformation parameter t is the conductor. At t = 0 we have the NilSquare singularity; at t a unit, the algebra splits as a product of two copies of k via the idempotent eta/t.
Three variations on the axiom:
The conclusion: epsilon-squared-equals-zero is the unique minimal non-trivial algebra. Epsilon-cubed sees second derivatives. Two nilpotents factorize into higher dimension. Only one nilpotent of order exactly 2 gives: minimal dimension, exact first derivative, no second derivative, 1-dimensional deformation space.
The ideal (epsilon) is reinterpreted as a linear code:
eps_in_code: epsilon is a codeword.codeword_sq_zero: every codeword squares to zero (the error-detecting property).codeword_mul_zero: the product of any two codewords is zero.The code is a square-zero ideal: it detects all single errors (by nilpotency) and annihilates all pairs of errors (by the ideal product being zero). This is the information-theoretic content of epsilon-squared-equals-zero.
The seven TLC constructors with codeword lengths [1,2,2,2,2,2,2] have Kraft sum 1/3 + 6/9 = 1. The code is prefix-free and saturating over the ternary alphabet:
kraft_sum: verified Kraft equality (by decide).The dual numbers over F3 have 9 elements, 6 units, and unit group Z/6Z = Z/2Z x Z/3Z by the Chinese Remainder Theorem (z6_coprime by decide). This layer verifies the combinatorial consequences of ε²=0 over F3; the connection to Heegner primes belongs to a separate investigation and is not part of the forced tower.
Over a NilSquareLocal ring, there are exactly three indecomposable module types:
Key results:
idempotent_trivial: every idempotent in R is 0 or 1. Proof: if e is neither, then epsilon divides both e and e-1, so epsilon divides 1, making epsilon a unit, contradicting epsilon-squared = 0.R_indecomposable: R has no nontrivial direct sum decomposition.ses_not_split: the short exact sequence 0 -> (epsilon) -> R -> R/(epsilon) -> 0 does not split. Proof: a splitting would make epsilon act as zero on all of R, but epsilon*1 = epsilon is nonzero.three_indecomposable_types: the Fintype has cardinality 3.The singularity category D_sg(R) has its Auslander-Reiten quiver equal to the A2 Dynkin diagram: two vertices, one arrow, no loops, no reverse arrows.
a2_vertex_count: 2 vertices (by decide).a2_arrow_unique: the arrow from v0 to v1 is unique.ext1_nonzero: Ext-superscript-1 is nonzero (epsilon is in the ideal and nonzero).ext1_generated_by_eps: Ext-superscript-1 is generated by a single element (every element of (epsilon) is a scalar multiple of epsilon).second_syzygy_period: Omega-squared(k) is isomorphic to k (the second syzygy loops back).arQuiverIsA2: assembles all data into the ARQuiverData structure.The first cotangent cohomology T-superscript-1(R/k, k) is 1-dimensional.
The argument:
ResidueModule: an R-module where epsilon acts as zero.homEvalEquiv: Hom_R(R, M) is linearly equivalent to M via evaluation at 1.cocycle_condition: for any f : R -> M into a residue module, f composed with multiplication-by-epsilon equals 0.T1_equiv: combining, Ext-superscript-1(k, k) is isomorphic to k.The chain: T1 = Ext1(Omega1, k) = Ext1(k, k) = ker(epsilon)/im(epsilon) = Hom(R,k)/0 = k.
The stabilization map sends the NilSquare generator e to the product e*d in the two-nilpotent ring R2 = k[e,d]/(e-squared, d-squared):
ed_sq: (e*d)-squared = 0.cube_ideal_zero: every degree-3 monomial in {e, d} vanishes (m-cubed = 0).stabilization_dual_mul: the dual-number arithmetic via e*d in R2 is identical to the arithmetic via e in R1.knorrer_periodicity_algebraic: packages nilsquare structure, chain complex condition, and dual-number preservation.The periodic resolutions over R1 (using e) and R2 (using e*d) have identical algebraic structure. This is the concrete content of Knoerrer periodicity for this case.
A matrix factorization of w in R consists of two R-linear endomorphisms phi, psi with psi-composed-phi = wid and phi-composed-psi = wid. For w = epsilon-squared = 0, these collapse to 2-periodic chain complexes.
mf_eps_sq_is_complex: phi-composed-psi = 0 and psi-composed-phi = 0.MatrixFactorization.flip: (phi, psi) maps-to (psi, phi) is a well-defined involution.flip_flip: the flip has order exactly 2.periodicMF: the periodic resolution (mulEps, mulEps) is a self-dual matrix factorization.MFClass: two classes (even = self-dual, odd = non-self-dual), giving K0 isomorphic to Z/2Z.periodicMF_even: the periodic resolution sits in the even class.mfClass_card: the two classes are distinct.A FilteredTriple on a type M consists of three endomorphisms (p, n, m) satisfying: p is idempotent, n is nilpotent of order 2, p and n are orthogonal. The three-step filtration is {0} subset im(n) subset ker(n) subset M.
hodgeTriple: the NilSquare ring R yields (0, multiplication-by-epsilon, id). The nilpotency of n is epsilon-squared-equals-zero.deformTriple: when the deformation parameter t is a unit, (eta/t, multiplication-by-epsilon, id) gives a non-trivial filtered triple.FilteredTriple.Morphism: a map intertwining all three operators, with identity, composition, and associativity.decide).A DepthFiltration is a decreasing sequence of submodules F(0) superset-of F(1) superset-of F(2) superset-of …
spectral_degeneration: every depth filtration on an Artinian module stabilizes. There exists D0 such that F(D) = F(D0) for all D at least D0. Proof: the Artinian descending chain condition (IsArtinian.monotone_stabilizes).persistent_kernel: the stable value is the persistent kernel.graded_trivial_past_stabilization: all graded pieces past D0 are trivial.For finite-dimensional vector spaces, spectral_degeneration_findim provides the specialization.
The cochain complex Hom_R(R, k) with differential induced by multiplication-by-epsilon has every differential equal to zero (by cocycle_condition). Therefore:
hdiff_eq_zero: d = 0 at every position.extIsoAt: Hom_R(R, M) is isomorphic to M at every degree n.shiftIso: the shift from position n to position n+1 is the identity (period 1).HH2_iso: HH-superscript-2(R, R) is isomorphic to k.HH2_complete: packages exactness, vanishing differential, isomorphism, and periodicity.Consequence: the deformation eta-squared = t*eta from Layer 4 is universal. The obstruction space HH-superscript-2 is 1-dimensional, so there is exactly one obstruction class and the 1-parameter family t is complete.
The Koszul dual of k[epsilon]/(epsilon-squared) is k[x], the polynomial ring.
ext_generator_is_one: the generator of the Ext algebra is 1 under Hom_R(R, R) isomorphic to R.mkPolynomialWitness: in an integral domain, any nonzero element generates a polynomial algebra (no relations).koszul_duality_main: (multiplication-by-epsilon)-squared = 0, each Ext-superscript-n is rank 1, the generator is nonzero, and generator-to-the-n is nonzero for all n.koszul_dual_is_polynomial: the five characterizing properties of k[x].The duality: singular (epsilon-squared = 0) is Koszul-dual to smooth (no relations). The simplest singularity is dual to the simplest smooth algebra.
The Hochschild cochains carry a minimal A-infinity structure:
mul_one_eps_ne_zero: m2 (the cup product) is nonzero (epsilon*1 = epsilon is nonzero).massey_defined: the triple Massey product (epsilon, epsilon, epsilon) is defined because epsilon-squared = 0.masseyRep_eps: the Massey representative is 2*epsilon.massey_rep_ne_zero: 2*epsilon is nonzero when char is not 2 (m3 is nonzero).massey_higher_zero: for n at least 4, the n-fold iteration of multiplication-by-epsilon gives zero on any element. (The 1-periodic resolution means n-fold products factor through epsilon-squared = 0 twice.)The A-infinity minimality data: m2 nonzero (multiplication exists), m3 nonzero (the Massey product detects the singularity), m4 = 0 (all higher obstructions vanish by periodicity). This is the sharpest characterization: epsilon-squared-equals-zero is the unique algebra with exactly one nonzero higher operation.
The raw one-step beta reduction operator on TLC terms does not satisfy NilSquare:
threeStepWitness: the term app(id, app(app(id, id), id)) takes three beta steps to normalize.whStepTotal_not_step2_idem: the totalized weak-head step does not stabilize after two iterations.whResidual_not_square_zero: the linearized weak-head residual on the free abelian group of terms is not square-zero.betaResidual_not_square_zero: same for full beta reduction.raw_reduction_not_nilSquare_bridge_ready: packages all four failures.The obstruction is concrete: reduction chains of length 3 exist.
The fix is to lift from terms to the trivial square-zero extension:
ReductionDual := TrivSqZeroExt Z TermVector
where TermVector = TLC ->_0 Z is the free abelian group on TLC terms.
nf1: the bounded normal-form projector (not the raw one-step operator).nf1_idem: the projector is idempotent.residualVec: the projector residual on a basis term, [t] - [nf1(t)].residualElt: the residual lifted into TrivSqZeroExt, sitting in the nilpotent ideal.residualElt_sq: the square of any lifted residual is zero (by TrivSqZeroExt.inr_mul_inr).krivineEpsilon: the distinguished nilpotent element (residual of the witness app(id, id)).krivineEpsilon_sq: krivineEpsilon squared equals zero.krivineEpsilon_ne_zero: krivineEpsilon is nonzero (the witness genuinely reduces).reductionDualNilSquare: the NilSquare instance on ReductionDual.The entire 17-layer tower now applies to ReductionDual. The Hodge triple, the periodic resolution, the Ext algebra, the A-infinity structure — all instantiate automatically.
realizeIn: a generic algebra homomorphism from ReductionDual into any NilSquare ring R, sending krivineEpsilon to epsilon.realizeAtWitness_apply_krivineEpsilon: the realization preserves the distinguished nilpotent.realizeHodgeMorphism: a filtered-triple morphism from the concrete TLC Hodge triple to the abstract Hodge triple of any NilSquare ring.bridgeEquiv: the strong (nf1-based) and machine (Krivine-projector-based) bridges present the same TrivSqZeroExt, proved via mutual inverse algebra homomorphisms.reductionSingularFiber: the singular fiber of the abstract deformation tower, specialized to the TLC residual ring.confluent_of_partial_function: the reflexive transitive closure of a partial function graph is confluent.normalForm_unique_of_confluent: reachable normal forms are unique.nilsquare_anti_comm: if epsilon1-squared = 0, epsilon2-squared = 0, and (epsilon1 + epsilon2)-squared = 0, then epsilon1epsilon2 + epsilon2epsilon1 = 0.nilsquare_comm_zero: in a commutative ring with Invertible(2), the stronger epsilon1*epsilon2 = 0.residualElt_mul_comm_zero: concrete version for TLC reduction residuals.betaRel_deterministic: the one-step TLC beta relation is functional.betaStar_confluent: multi-step beta is confluent.unique_beta_normal_form: reachable beta-normal forms are unique.church_rosser: Church-Rosser for the TLC multi-step beta relation.The algebraic content: NilSquare residuals anti-commute; in the commutative TrivSqZeroExt, they annihilate. The product of any two reduction residuals is zero. Diverging paths cannot interact.
Caveat. This section is speculative and included only for completeness. The formalized results are narrow observations about algebraic structure; they do not constitute a complexity-theoretic result and should not be read as bearing on P vs NP.
Deterministic computations (step functions with f(f(f(x))) = f(f(x))) yield NilSquare residuals in the TrivSqZeroExt lift. Nondeterministic computations (step relations with multiple successors) lack a unique step function and the NilSquare property may fail. This is an algebraic signature distinguishing determinism from nondeterminism at the level of residuals, not a statement about computational complexity classes.
RewriteSystem: a type of terms with a one-step reduction.RedPath: reduction paths (finite sequences of rewrites).ResidualAssignment: maps reduction steps to ring elements.pathResidual: the sum of step residuals along a path.ResidualEquiv: two paths are equivalent if their residuals agree.NilSquare says the residual-of-a-residual (a 2-cell, a path-between-paths) is zero. This is 1-truncation in the HoTT sense: paths-between-paths carry no information. The evaluation path space is a 1-type.
no_higher_homotopy: any two proofs that residuals are equal are themselves equal (UIP for residual equality).nilsquare_implies_one_truncated: the main 1-truncation theorem.Programs compose as ring multiplication in a NilSquare ring:
compose_form: (a + repsilon)(b + sepsilon) = ab + (as + rb)epsilon. The cross-term rsepsilon-squared vanishes.nilSquare_ideal_product_zero: the product of any two residuals (elements of the ideal (epsilon)) is zero.Error interaction depth is bounded:
The Koszul duality:
The graded automorphism group of the Ext algebra k[x] is Z/2Z (identity and x maps-to -x), matching the matrix factorization flip. Over F3, this is the full motivic Galois group of the singularity category.1
Any proof term witnessing an equation op(a, a) = c requires a TLC encoding lam(app(app(op, x), x)) with 5 structurally distinct DAG nodes after hash-consing:
The variable x appears twice in the tree (6 tree nodes) but is shared to a single DAG node, giving DAG = 5. This is tight:
epsSqSkeleton_raw_size: 6 nodes before deduplication.epsSqSkeleton_dag_size: 5 nodes after CSE.The concrete TLC encoding matches:
epsSqDAG_nodeCount: 5 (by native_decide).epsSqDAG_nodes_distinct: all 5 nodes are structurally distinct (by native_decide).All three axiom systems of the form x-squared = c share the identical proof-term skeleton:
They differ only in the constant index and the RHS. The DAG structure is isomorphic across all three:
K_xSq_eq_5: K_DAG(x-squared = c) = 5 (by native_decide).xSq_dag_nodes_distinct: all 5 nodes verified distinct (by native_decide).Higher-order equations strictly exceed K = 5:
x-squared = c is the unique minimizer at K_DAG = 5.
The #kolmogorov command measures the Kolmogorov complexity of Lean definitions by converting proof terms to TLC, applying hash-consing (DAG CSE), and counting nodes. It is applied to:
#kolmogorov command elaborator itself.The measurement instrument measures itself. The chain terminates: axiom -> theorem -> bridge -> compression -> measurement command -> self-measurement. Each step is measured by the next. The self-referential loop closes at K(eps_sq) = 5.
The algebra k[epsilon]/(epsilon-squared) is the minimal non-trivial commutative ring quotient. Everything is forced:
The bridge instantiates the abstract tower for concrete lambda-calculus reduction. Church-Rosser, 1-truncation, the composition operad, and the motivic Galois group Z/2Z all follow. Self-measurement closes the loop: K(eps_sq) = 5, universal across all x-squared = c, with a strict gap to anything more complex.
The formalization is 175 files, 28,000+ lines of Lean 4. The 17-layer epsilon tower core is sorry-free. The 11 sorry instances in the full repository are confined to peripheral files (RiceSpectral.lean: 6 sorry in statement-only hard-direction stubs; RuelleGap.lean: 2 sorry; LanglandsFunctor.lean: 1 sorry; HodgeRL.lean: 1 sorry needing Invertible(2); OptimalAxiom.lean: 1 sorry for a structural hash-consing property).
One axiom. Everything follows. The snake measures its own length, and it is 5.
| Layer | File | Content |
|---|---|---|
| L1 | Epsilon.lean |
NilSquare class, nilpotency, AD property |
| L2 | EpsilonModule.lean |
mulEps, chain complex, periodic resolution, exactness |
| L3 | EpsilonDeriv.lean |
Leibniz, 2epsilonD(epsilon) = 0, entanglement |
| L4 | EpsilonDeform.lean |
Deformation structure, singular fiber, idempotent splitting |
| L5 | EpsilonVariations.lean |
NilCube, ScaledSq, TwoNil, uniqueness |
| L6 | EpsilonHamming.lean |
Code ideal, codeword-squared = 0, error detection |
| L7 | EpsilonTernary.lean |
Kraft sum, F3 dual numbers, Z/6Z |
| File | Content |
|---|---|
ThreeIndecomposables.lean |
M1, M2, M3, idempotent triviality, SES non-splitting |
ARQuiver.lean |
A2 Dynkin diagram, 2 vertices 1 arrow, period 2 |
Cotangent.lean |
ResidueModule, Hom-eval, T1 = k |
Knorrer.lean |
TwoNil stabilization, m3=0, dual-number preservation |
MatrixFactorization.lean |
MF definition, flip involution, K0 = Z/2Z |
| File | Content |
|---|---|
HeckeHodgeFunctor.lean |
FilteredTriple, Hodge instance, Hecke data, morphisms |
SpectralDegeneration.lean |
DepthFiltration, Artinian DCC, persistent kernel |
Hochschild.lean |
Vanishing differential, HH^n = k, period 1 |
KoszulDual.lean |
PolynomialWitness, Ext generator, k[x] characterization |
AInfinity.lean |
m2 nonzero, Massey defined, m3 nonzero, m4 = 0 |
| File | Content |
|---|---|
KrivineNilSquareFalsification.lean |
3-step witness, naive bridge fails |
KrivineNilSquare.lean |
nf1, TrivSqZeroExt, reductionDualNilSquare instance |
KrivineNilSquareUniversal.lean |
Universal realization, bridgeEquiv |
KrivineProjectorNilSquare.lean |
Machine/weak-head variant |
KrivineProjectorResidual.lean |
Projector residual calculus |
| File | Content |
|---|---|
ChurchRosser.lean |
Confluence, determinism, unique normal forms |
ComplexityNilSquare.lean |
P = NilSquare-stable, NP = NilSquare-failure |
NilSquareTruncation.lean |
1-truncation, UIP for residuals |
CompositionOperad.lean |
Composition closure, error depth = 2 |
MotivicGalois.lean |
GradedAut, k-units = Z/2Z, time-reversal |
| File | Content |
|---|---|
KLowerBound.lean |
ProofSkeleton, DAG = 5, structural lower bound |
KFiveUniversal.lean |
x^2 = c universal at K = 5, gap to K >= 7 |
SelfMeasure.lean |
#kolmogorov on bridge, compression, and self |
TowerMeasure.lean |
Combined DAG of all Layer 1+2 theorems |
The connection to motivic homotopy theory is formal rather than deep: it follows from the Koszul duality k[epsilon]/(epsilon-squared) <-> k[x] and the fact that k-units over F3 have order 2.↩︎