Apoth3osis
<_RESEARCH/PROJECTS

Semantic Closure in Lean 4

VERIFIEDLean 4MathlibGitHub
>THE_QUESTION

What makes living systems different from machines?

A car engine converts fuel to motion, but it cannot repair itself. A computer executes programs, but it cannot rewrite its own circuitry. Yet every living cell continuously rebuilds its own components while simultaneously using those components to function.

This is the puzzle of semantic closure: How can a system be both the message and the reader, both the machine and the mechanic?

Robert Rosen called this the "(M,R)-system" problem: metabolism (M) produces components, repair (R) rebuilds the metabolic machinery, but critically—what repairs the repair system? The answer must involve a kind of self-reference that seems paradoxical.

>ORIGINAL_WORK

"Closing the Loop" by Lopez-Diaz & Gershenson

In 2024, Amahury Lopez-Diaz and Carlos Gershenson published a breakthrough paper showing that semantic closure is not just a philosophical concept—it can be formalized mathematically and traced through evolutionary history from simple autocatalytic reactions to self-replicating life.

"Self-referentiality is not only a necessary condition for life but also essential even for the simplest autocatalytic systems."

Their key insight: the closure operator—a mathematical function that iterates until it reaches a fixed point—captures exactly how living systems stabilize their self-reference into something coherent rather than paradoxical.

Expand

Click to expand

>INNOVATION

The Innovation: Proofs That Run

Traditional scientific modeling separates theory from implementation: you write equations on paper, then translate them into code, hoping the translation is correct. Bugs hide in the gap between mathematical intent and computational reality.

We use Lean 4 differently. Instead of treating the proof assistant as just a verifier, we use it as a modeling language. The theorems themselves become executable specifications—when Lean accepts the proof, the model is guaranteed to be mathematically coherent.

This means the visualization you see on our models page is not an artist's interpretation—it's driven directly by data exported from the verified Lean proofs. The closure iterations, the nucleus transformations, the fixed-point convergence are all certified by the proof assistant before they reach your screen.

THE PIPELINE
1
Lean 4 Proofs
Theorems verified by type checker
2
JSON Export
Proof data extracted as structured data
3
WebGL Visualization
Proof-certified parameters drive the scene
4
C Code Generation
Same proofs compile to embeddable runtime
>INTUITION

Understanding Closure: An Analogy

The Paradox

Imagine a factory that makes robots. One robot's job is to repair other robots. But who repairs the repair robot? Another repair robot? This leads to infinite regress.

The Resolution

The closure operator is like a repair robot that can fix itself. When you apply the repair function to the repair function, you get... the same repair function. It's a fixed point.

The Math

Formally: close(close(x)) = close(x). The closure operator is idempotent. This is exactly what the Lean theorem closeSelector.idem proves.

>PROOF_LATTICE
Semantic Closure Proof Lattice Visualization

The proof dependency lattice. Each node is a verified theorem; edges show which theorems depend on which. The structure itself demonstrates the mathematical coherence of semantic closure.

>VERIFIED_THEOREMS

What We Proved

THEOREMPLAIN ENGLISHWHY IT MATTERS
closeSelector.idemApplying closure twice equals applying it onceSelf-repair is stable, not recursive
InjectiveEvalAtEach selector maps to a unique componentNo ambiguity in repair instructions
EvalImage.betaOnImageThe inverse selector exists on the imageRepair can always find its target
reluNucleus_idempotentReLU transformation reaches fixed pointNeural-like gates stabilize
thresholdNucleus_fixed_iffThreshold triggers exactly at boundaryDecision boundaries are precise
VERIFICATION
100%

All core equations machine-verified

EXECUTABLE
C Output

Proofs compile to embeddable code

VISUALIZATION
Live

Proof data drives WebGL scene

See the Proofs in Action

Our visual model shows the closure operator converging to a fixed point. The bars represent actual vector values from the Lean proofs; the color transitions show ReLU and threshold transformations; the particle burst marks the moment of closure.

View Live Model