Engineering experiment
Auto-discovery of algebraic laws
The setup
Given operations and invariants, the explorer instantiates predefined algebraic templates. Random evaluations can refute a candidate or nominate it for proof.
Two primitives make this tractable. defobject declares a uniform protocol for any algebraic object:
(defobject R_r
:components [a b]
:operations [(add 2) (mul 2)]
:invariants [N_alg sign-alg]
:generator random-instance)
And explore runs systematic property discovery:
(explore 'R_r :samples 500)
The explorer generates candidate identities across five families — multiplicativity of invariants, additivity of invariants, commutativity, associativity, distributivity — and tests each on random instances.
What emerges on R3
First run on R3 = Z[η]/(η²−3η), 500 samples per candidate:
| Candidate | Result | Interpretation |
|---|---|---|
| Nalg(x·y) = Nalg(x)·Nalg(y) | ✓ passed sample | multiplicativity of norm |
| sign(x·y) = sign(x)·sign(y) | ✓ passed sample | Z/2 charge |
| mul commutative | ✓ passed sample | x·y = y·x |
| add commutative | ✓ passed sample | x+y = y+x |
| mul associative | ✓ passed sample | (x·y)·z = x·(y·z) |
| add associative | ✓ passed sample | (x+y)+z = x+(y+z) |
| mul distributes over add | ✓ passed sample | x(y+z) = xy+xz |
| Nalg(x+y) = Nalg(x)+Nalg(y) | × counterexample | norm is not additive |
| add distributes over mul | × counterexample | not a ring in reverse direction |
Seven candidates passed all 500 tests, and two had counterexamples. They were generated from the stated operation templates.
Comparing theories
The same object under different parameter values gives different theories. Each theory can be explored independently:
(with-theory (:name "R_3" :object R_r :params ((r . 3)))
(explore 'R_r :samples 500))
(with-theory (:name "dual" :object R_r :params ((r . 0)))
(explore 'R_r :samples 500))
(compare-theories "R_3" "dual")
Results:
| Comparison | Shared sample passes | Status differences |
|---|---|---|
| R3 vs dual (r=0) | 7 | 1 (sign additivity) |
| R3 vs R5 | 7 | 3 (subtle) |
Seven candidates passed the comparisons. A genuine counterexample establishes parameter-dependent behavior. Different pass/fail counts alone need a common sampling protocol.
Parameter sweeps
For any invariant-candidate, we can sweep the ring parameter systematically:
(sweep-parameter :object R_r :param 'r :range (0 163)
:candidate 'N_alg-multiplicativity
:samples 300)
The norm identity passed 300/300 draws at each r=0,…,163. Here the norm is the determinant of multiplication in a free rank-two algebra, so determinant multiplicativity also gives an algebraic proof.
Distributivity and associativity passed the same sampling protocol.
What "auto-discovery" means here
Three levels of automation:
defobject, generate all identity-candidates at depth 1 (commutativity, associativity, distributivity, multiplicativity, additivity).
No theorem proving. The discovered "universal" laws are empirical — 500 random samples with zero failures. To prove them formally, we hand off to Lean. The value here is hypothesis generation and negative results: the counterexamples (norm not additive, reverse distributivity false) are found before a human would think to check them.
Why this works on our ring
Rr = Z[η]/(η2−rη) has enough structure to generate interesting candidates and enough regularity that most candidates have decisive answers. More exotic rings (non-commutative, non-associative, non-ring-like) would generate messier explore outputs — useful in their own way, but with more nuance.
The test case for scalability is the comparison with Lie algebras or Hopf algebras. Both have defobject templates; both have candidate-law families (Jacobi identity, antipode equations). The explore machinery generalizes directly.
Use in compilers
A counterexample can eliminate an invalid rewrite. A surviving identity needs a proof or a verified guard for the compiler’s actual value domain and partial operations before it is used for unrestricted rewriting.
Related
The Hecke automaton and Hecke confinement papers are built on laws that could have been auto-discovered this way — they were hand-found first, but the algorithmic approach would reach them. The residual structuralism framework treats defobject + explore as the tool that identifies the canonical residue.
Cite this page
Richard Hoekstra. Auto-discovery of algebraic laws. https://richardhoekstra.nl/papers/auto-discovery.html