Reflective Subsystems: an introduction
An introduction to Reflective Subsystems, a research program in pure mathematics checked by Lean 4, and to how its proofs are written with a coding agent.
Lumps of matter, given enough time, start doing mathematics. They do not only obey rules; some of them represent the rules and use the representation. Reflective Subsystems asks where that comes from, and asks it inside mathematics, with no physics assumed.
The program is a series of papers, in preparation, and three Lean 4 libraries on top of Mathlib that machine-check what the papers claim. The proofs are written with a coding agent, which raises a second question the post also takes up: how anyone, including me, is supposed to know they are right.
The question
How much can a bounded observer, living inside a system, work out about the rules of that system, and what does it cost to hold on to what it works out?
A subsystem that keeps a model of the world it is part of, and can use that model, is called reflective. The claim the program works toward is that reflection is forced, not lucky: a bounded thing in a rich but learnable world is pushed to compress the world into a rule it can hold, and holding and using that rule is reflection.
The papers price each step of that story. A model that is overwritten every time it is used cannot be iterated, so predicting several steps ahead needs a read-only copy of the rule, separate from the scratchpad; that separation, with enough memory, is what makes the system’s internal world rich enough to represent arithmetic, and so to inherit Gödel’s blind spot. Learning the rule beats memorizing the data in any world with enough structure, and a bounded learner’s mistakes are capped however long it lives. Doing this with reasonable computation works only for nice worlds, and the parity-style rules are the clean counterexample. A world that overwrites every cell can still carry a message through a moving window, but the window’s reading instructions turn out to contain the world’s own rule, and for a bounded reader they cost more than the world holds. And the learner’s data has to come from somewhere: a finite deterministic world eventually loops and can vouch for its loop and nothing else, so the world has to grow, and a growing world can emit its own teacher. The capstone builds one explicit system that meets every prerequisite and, conditional on a named damage model, proves reflective subsystems inevitable in an abstract class of systems.
One line is drawn hard: all of this is mathematics about a class of systems. Whether our universe belongs to that class is a separate, largely empirical question, and the program defers it; nothing in the papers or the libraries says that it does.
The second question: can a coding agent help, and how does anyone know
The Lean proofs, the probes and most of the prose are written by a coding agent under my direction. Nobody has to trust the agent, because nothing it writes counts until a machine has checked it.
What machine-checked means here is the usual Lean bar, enforced by the build rather than promised in a README: no sorry, admit or native_decide; standard axioms only, propext, Classical.choice and Quot.sound.
Every main result carries a #guard_msgs in #print axioms guard that pins its exact axiom set, so a proof that quietly starts leaning on something extra fails the build the way a typo fails a program, and CI audits every declaration, not only the guarded ones.
A release is replayed from a clean cache before it is tagged.
The harness around the agent is where the rest of the checking lives, and it was built one incident at a time.
A theorem starts as a sentence in a paper; the prompt that hands it to a prover session quotes the statement and the declarations it builds on, and is checked before it is sent.
The session works under the language server and lake build, and never commits.
Its report is checked against the built library rather than read as the truth: the manifest of declarations is diffed, and a fresh agent with no context reads the bare Lean statements and writes them out in prose, which is compared with what the paper says.
On every commit, every Lean name a paper cites is resolved against the library and every count a paper derives from the code is recomputed.
A theorem can pass all of that and still say nothing, so each headline theorem comes with a witness that there was something to prove, usually a counterexample that breaks exactly one hypothesis and keeps the rest.
That habit has rewritten several of my own claims, including two I was confident about.
What the agent does not do is decide what is worth proving, whether a Lean statement is the one the paper means, or whether a result is new. The last of these is where it has been least reliable: a literature search once returned a plausible, confidently described competing project that did not exist, and since then every “first in a prover” claim is checked against primary sources, with the searches that came up empty listed in the paper.
How the work is organized, and where it came from
The project began in June 2026 as one manuscript. An internal review found citation errors, an inconsistency over whether a sub-problem was open or solved, and an unproved proposition the argument rested on. So the manuscript was split into named papers, each a result that stands on its own, with the dependencies between them explicit and cited as black boxes rather than reconstructed, and a capstone that imports all of them. The Lean workspace was opened in the first week, the first public release went out in July, and the classical and cellular-automata parts were cut into packages of their own in October.
Two rules carry through everything. Every claim is labeled proved, conditional or open, and a condition is a named hypothesis, never buried in prose. And a paper’s statement of a result is written from the landed proof, not from the plan that commissioned it, because the two come apart exactly where the theorem needed less than the plan assumed.
The process itself turned out to be worth keeping. The records of what was tried, decided and settled, the reference library with how far each work was read, and the checks that run on every commit were extracted into research-kit, and this project now runs on the released kit like any other user of it. How that happened, and what it did for the research, is its own post.
Three repositories, and why
The Lean development is three Lake packages, each requiring the one before it.
lean-classical-upstreamholds classical theorems of algorithmic information theory, learning theory, information theory, ergodic theory, realizability and combinatorics. Every statement in it is one the literature already makes; the package adds its proof in Lean, labeled by its standing there: formalized first here as far as a search of the Lean libraries found, ported from a proof in another library that could not be used, or duplicating one. API reference · DOI 10.5281/zenodo.23257423lean-elementary-cellular-automataholds the 256 rules on a line of binary cells in which a cell’s next value depends on itself and its two neighbors: which rules grow from a finite configuration, what a column, a window or a ray of an orbit looks like, which rules reproduce a pattern, and what it costs a rule to erase a local perturbation. API reference · DOI 10.5281/zenodo.23275249lean-reflective-subsystemsholds the program’s own results: what nobody had stated before, however small. API reference · DOI 10.5281/zenodo.21284775
The split follows one rule. A sentence with prior art, stated in the literature or proved in another Lean library, moves down to the classical package with its proof, however much of the proof is new; a sentence nobody has made stays up. The point is that a classical theorem should be usable, and upstreamable to Mathlib or its neighbors, by someone with no interest in this program, and the cellular automata are a subject of their own that a reader may want without any learning theory attached. The import direction, classical to automata to the program’s own library, is checked at every module.
Some results
Each of these is a theorem in one of the three libraries, with its axiom set pinned in the build. The companion papers state them with their boundaries; here is the short form.
- A finite machine proved to meet a learning theory’s prerequisites from its own dynamics.
The statistical-query framework assumes an oracle whose averages behave like samples;
LearningWitness.leanbuilds a concrete system and proves, from the system’s own update rule, that what the learner inside it observes satisfies the condition its queries need. - A growing world that emits its own teacher.
A finite deterministic world cannot be its learner’s oracle, because it loops.
GrowingHostWitness.leanbuilds a machine with a read-only program and a tape that appends one cell per step, and proves that its own emitted history has statistics stable enough, with an explicit identification horizon, to serve as that oracle. - The price of memory in a world that overwrites everything.
PersistenceCapacity.leanprices the decoder an observer must store to read a message through a moving window, with exact constants. It agrees with Putnam’s argument that everything computes everything, and then shows that no bounded reader can afford it. - The threshold where self-representation turns into incompleteness.
GodelThreshold.leangives the capacity at which a system’s internal world is rich enough to state truths it cannot prove, andChaitinPrefixProgression.leanbuilds a progression of theories, each with its Chaitin sentence at its own threshold, gaining at least a bit of prefix complexity per step, so that no computable family names the progression uniformly. - Every quiescent elementary rule decided for growth.
In the automata package, the growing width of a rule is zero at every time or unbounded at every one of the quiescent rules, and the census of which is which is one theorem over the rule’s Wolfram number (
growth_census), its counts checked by the kernel. From a single cell, no ray of rule 90 at a rational speed strictly between zero and one is eventually periodic. - Classical theorems proved in Lean for the first time, as far as a dated search found. Chaitin’s incompleteness theorem under consistency alone, over Mathlib’s universal machine, in its plain and its additive form; the statistical-query model with its dimension and parity’s lower bound; the conjunction and decision-list learners verified correct and polynomial-step in one statement, on a cost model over Mathlib’s codes; and the category of assemblies over Kleene’s first algebra, Cartesian closed with finite coproducts.
Where to go next
The project card on this site keeps the links to the three repositories current. Their API references, generated from the source, are the best way into the mathematics, and an issue on any of them is welcome; a statement you think is wrong is the most valuable one you could open. The tooling the project runs on is research-kit, extracted from this project and released on its own.
Later posts will take the threads one at a time, starting with the threshold.