Chapter 22: Self-Reference and Emergence — When a Reasoning System Starts Reasoning About Itself
The Curry-Howard correspondence tells us: a proof is a program. So what is a program proving?
The last paragraph of Chapter 21 brought us here: a reasoning system strong enough to start including propositions about itself. At this moment, the Gödel structure of Chapter 15 reappears.
But Chapter 22 is not a repeat of Chapter 15. Gödel was about the boundary — the true propositions you can never reach. Chapter 22 is about the openings — the new things emerging around that boundary.
Nine chapters of logical deduction into Volume 2, and we are finally high enough to look down. This is one of the most honest chapters: some questions, we can only state, not solve.
22.1 Curry-Howard: A Proof Is a Program
Chapter 14 built a formal system: propositions, inference rules, proofs. Chapter 19 found that computation and logic are equivalent at the level of complexity: SAT is NP-complete, and finding a proof in propositional logic is, in the worst case, exactly as hard as SAT.
But how deep is the equivalence?
The Curry-Howard correspondence (also called the propositions-as-types correspondence) gives the answer: as deep as it can possibly be.
Precisely, it sets up the following correspondence:
| Logic | Type Theory / Programs |
|---|---|
| Proposition | Type |
| Proof of proposition | Term of type |
| Function type | |
| Product type | |
| Sum type | |
| Empty type (uninhabited type) | |
| Modus ponens | Function application |
| Deduction theorem | Function abstraction ( |
This is not a metaphor — it is an isomorphism: every step of a logical derivation corresponds to a step of computation in a program; normalization of a proof (reducing it to its simplest form) corresponds to evaluation of a program (running it until it terminates).
Many people nod at this point and then go right on treating "logic" and "program" as two different things. An isomorphism means: every step you prove in logic is one computation step in a programming language; every function you write is "proving" some proposition. If this doesn't blow your mind, you haven't really understood what this correspondence is saying.
A proposition "has a proof" exactly when its corresponding type "has a program" — the corresponding type is "inhabited". A proof is a program, a proposition is a type, and verification is running the program.
Before the Curry-Howard correspondence, mathematics and computer science were two neighboring but separate fields. The correspondence tells us: they are two languages for the same thing. Every mathematical theorem can be understood as a program; every program is "proving" some proposition — proving that its output type can be constructed from its input type. This is not a philosophical similarity; it is an equivalence that can be verified precisely with formal machinery. The proof assistants Lean, Coq, and Agda are built on exactly this equivalence: writing a program is writing a proof, and type checking is proof verification.
22.2 Fixed Points: The Algebra of Self-Reference
The Gödel sentence
But self-reference does not only appear in Gödel's theorem. It has a more general algebraic structure: the fixed point.
Definition (fixed point): given a function
In the lambda calculus (the simplest core language of programs), there is a famous fixed-point combinator
For any function
Unrolled, this equation shows that
The Y Combinator and the Lambda Calculus: The "Simplest Core" of Programs
The lambda calculus is a model of computation proposed by Alonzo Church in the same era as Turing (the 1930s), and it is more compact than the Turing machine: only three kinds of elements — variables, function abstraction (
The def f(x): return f(x-1) directly, but in the pure lambda calculus functions have no names, so they cannot refer to themselves directly. The
Why does this relate to self-reference? The
Gödel's diagonalization lemma, in this language, is a fixed point of the "provability predicate": there exists a proposition
Self-reference, fixed points, and diagonalization are different names for the same mathematical structure in different contexts.
22.2.3 Hands-on: Unrolling the Y Combinator in Three Steps
The definition of the
Trace the unrolling with the recursive definition of the factorial function. Let
Note that the self parameter of
Now compute the behavior of
Step 0 (definition):
Let
Step 1 (unroll one layer):
Pass self parameter of
Now
Step 2 (evaluate at
Compute
Step 3 (keep unrolling):
Collecting results:
The key observation: at every step, self and calls it. But the construction of self is
Compare this with the Gödel sentence
: — is a fixed point of ; every unrolling of passes itself back to : — is a fixed point of the predicate "not provable", and asserts a proposition about its own provability
Both are the same mathematical structure: find an object such that the result of applying a certain transformation to it is, in an equivalence sense, the object itself. The
Unrolling the Y combinator three steps by hand gives you a feeling you cannot get from the definition: self-reference is not black magic, but a mechanism you can trace step by step.
22.2.5 The MP Game: Proof Sequences as Dynamical Systems
Modus ponens (MP) is the most basic inference rule of propositional logic: with
Textbooks give a static definition of proof: a finite sequence of formulas
But what if we look at it dynamically?
Setting up the game: define a function
Each application of
Three fates of an orbit:
- Apparent stopping: the sequence reaches some
such that — formally a fixed point. But this only says the successor term equals itself; it does not guarantee that is a true QED. might be a self-referential construction; "stopping" is just the special case of a cycle of period 1. - Finite cycle: there exist
such that — the orbit circles around, no new content emerges. - Infinite extension: the sequence never terminates — this corresponds to undecidability. No algorithm can decide, for an arbitrary given
and initial formula, whether the orbit will stop.
The Cauchy condition and the subtlety of halting: determining whether the first fate is "truly complete" is equivalent to asking: does the sequence become Cauchy?
On a state space like
degenerates into "the sequence is eventually constant" — that is, eventually fixed.
Real computers have finite stack space, so we impose a truncation condition by hand — not stopping automatically at the limit, but halting imposed from outside. This external condition, in a sufficiently strong system, cannot be internalized by the system itself.
A fixed point is the end of a proof — but only when the limit point is meaningful. When
This is not just a metaphor. The diagonalization lemma says: for any formula
Curry-Howard in view: under the CH isomorphism, formulas correspond to types, proof sequences correspond to reduction sequences of programs, and
The MP game brings three things together in one framework: the structure of proofs, the orbits of a dynamical system, and the fixed points of recursive types. They are different readings, in the languages of logic, analysis, and type theory, of the same mathematical object.
The real danger of this game is in the third fate: an orbit that extends forever. You cannot tell from outside whether an orbit will stop — this is not because your computing power is insufficient, but because it is undecidable in principle. Every time you write down a proof, you are actually claiming: this orbit will stop, and it will stop where I want it to. In a sufficiently strong system, this claim cannot be verified by the system itself.
22.2.6 The MP Game in Code
The orbits are small enough to run. The program below shows all three fates of an orbit – apparent stopping, finite cycle, infinite extension – then the Cauchy trap, and finally a miniature of the mirror: the Goedel sentence as a fixed point of the transformation "not provable."
#!/usr/bin/env python3
"""
mp_game.py -- the MP Game of Chapter 22: proof sequences as orbits.
Book reference: The Reasoning Kingdom, Volume 2, Chapter 22, Section
22.2.5 "The MP Game: Proof Sequences as Dynamical Systems."
A proof is usually a finished object: a finite sequence of formulas. The
MP game reads it dynamically: p_{n+1} = f(p_n), one modus ponens per
step, and a proof becomes an orbit of a dynamical system. An orbit has
exactly three fates -- and this program runs all three, plus the two
subtleties the book warns about:
1. apparent stopping: f(p) = p, but is p a TRUE QED?
2. finite cycle: no new content ever appears;
3. infinite extension: the orbit never ends (undecidable, in general);
4. the Cauchy trap: a converging sequence whose limit point is not
where the transformation rests;
5. the mirror: the Goedel sentence as a fixed point of the
transformation F(phi) = "not provable(phi)",
built here as a tiny self-referential program
(Chapter 15's companion script runs the full
numbering machinery; this is the miniature).
Run: python3 mp_game.py
"""
def orbit(f, x0, n):
"""The first n+1 points of the orbit x0, f(x0), f(f(x0)), ..."""
out = [x0]
x = x0
for _ in range(n):
x = f(x)
out.append(x)
return out
def demo():
print("=" * 70)
print(" THE MP GAME -- proof sequences as dynamical systems")
print(" The Reasoning Kingdom, Volume 2, Chapter 22 (Sec. 22.2.5)")
print("=" * 70)
# Fate 1: apparent stopping.
f1 = lambda x: x if x <= 0 else x - 1
print("\nFate 1 -- apparent stopping: f(x) = max(x-1, 0), start at 5")
print(" orbit:", orbit(f1, 5, 8))
print(" f(0) = 0, a fixed point. But 'stopping' only says the")
print(" successor equals itself -- it does not guarantee 0 is a TRUE")
print(" QED. Apparent stopping is a cycle of period 1.")
# Fate 2: finite cycle.
f2 = lambda x: (x + 1) % 3
print("\nFate 2 -- finite cycle: f(x) = (x+1) mod 3, start at 0")
print(" orbit:", orbit(f2, 0, 7))
print(" round and round; no new content ever emerges.")
# Fate 3: infinite extension.
f3 = lambda x: x + 1
print("\nFate 3 -- infinite extension: f(x) = x+1, start at 0")
print(" orbit (first 8 points):", orbit(f3, 0, 7))
print(" it never terminates. And for an arbitrary f, no algorithm")
print(" can decide whether the orbit will ever stop -- that is")
print(" undecidability in principle, not slow hardware.")
# The Cauchy trap.
print("\nThe Cauchy trap:")
print(" sequence p_n = 1/n is Cauchy and converges to 0,")
print(" but under the transformation f(x) = x + 1, f(0) = 1.")
print(" the limit exists; the transformation does not rest there.")
print(" The Cauchy condition guarantees the limit EXISTS -- not that")
print(" the limit point is the TRUE answer.")
# The mirror: fixed point of "not provable".
THEOREMS = {"T1", "T2"} # a toy provability predicate over strings
def provable(s):
return s in THEOREMS
q = "q = %r; content = not provable(q %% q)"
G = q % q
scope = {"provable": provable}
exec(G, {"__builtins__": {}}, scope)
print("\nThe mirror -- G as a fixed point of F = 'not provable':")
print(f" G = {G}")
print(f" what G says, computed: {scope['content']}")
print(f" provable(G) = {provable(G)}")
print(" so G <-> not provable(G): G is a fixed point of the")
print(" transformation F(phi) = not Prov(<<phi>>). The diagonalization")
print(" lemma in Chapter 15 is the same fixed point, grown to full")
print(" arithmetic; the miniature here shows its shape.")
print("=" * 70)
if __name__ == "__main__":
demo()22.3 Dependent Types: Propositions as Objects
The Curry-Howard correspondence holds in simple type theory. But what happens if the type system is made strong enough — allowing types to depend on values?
Dependent types allow expressions like: the type
Dependent Types: Making Types Carry "Proofs" (Earlier Work: Martin-Löf, 1975)
In ordinary programming languages, types and values are separate: int is a type, 42 is a value, and a type does not know what the specific value is.
Dependent types break this separation: types can depend on values.
Example:
- Ordinary type:
Vec<int>(a vector of integers, length unexplained) - Dependent type:
Vec<int, 5>(a vector of exactly 5 integers; the length is encoded in the type)
Why is this useful? Because a more precise type = stronger compile-time checking. If the function signature is concat : Vec<A, m> -> Vec<A, n> -> Vec<A, m+n>, the compiler automatically verifies that the length after concatenation is correct — no runtime check needed, out-of-bounds is impossible.
Relation to Curry-Howard: in dependent types, "
Under dependent types, the Curry-Howard correspondence extends to first-order logic:
| First-Order Logic | Dependent Types |
|---|---|
Dependent type systems (such as Martin-Löf type theory) realize an old dream of mathematics: constructing mathematical objects and proving mathematical propositions, handled together in the same language. Proving a proposition is constructing a program with the corresponding type; constructing a mathematical object is writing an inhabitant of the corresponding type.
This is not formal trickery, but a deep unification: mathematics and computation, propositions and data, proofs and programs — in a language precise enough, they are the same thing.
22.4 A Reasoning System Reasoning About Itself: The Boundary Returns
Now to the most central question of this chapter.
A reasoning system — whether a formal logic system, a learning algorithm, or a large language model — once it is complex enough and starts reasoning about itself, the pattern of Chapter 15 inevitably appears.
At the level of formal systems: Gödel's theorem says that any sufficiently strong consistent system has true propositions it cannot prove (including the proposition about its own consistency). Add
At the level of learning systems: Chapter 21 concluded that a learning system's inductive bias cannot be determined from inside the data — it is external input. A learning system cannot infer from its own training data whether its inductive bias is appropriate, just as a formal system cannot prove its own consistency from its own axioms.
Read that sentence twice. This is not saying that inductive bias is hard to choose; it is saying that, in principle, the data cannot tell you whether your inductive bias is appropriate — just as a formal system cannot prove its own consistency from inside. The real connection between Chapter 21 and Chapter 15 is here: the blind spot of learning and the incompleteness of logic are two languages for the same structural limit.
At the level of large language models: this is the frontier, and the most unsettled question. Through training, a large language model obtains some internal representation of linguistic structure. Does this representation contain some form of approximation of "inference rules"? When the model "reasons" about its own reasoning process (for instance, chain-of-thought), what is it doing?
An informal conjecture discussed in the research community: the attention mechanism of a Transformer, at sufficient scale and with sufficient training, implements some kind of implicit causal inference — by selecting relevant positions in the context, it performs an approximate test of conditional independence, which has a structural similarity to the d-separation of Chapter 18. This is not a proven theorem, but a conjecture that needs precise mathematical characterization. If it holds in some sense, then large language models are not merely pattern matchers; they are performing some approximate causal inference — and this conclusion would deeply reshape our understanding of AI reasoning ability. But "in some sense" is a large escape hatch; existing theoretical tools cannot yet turn this conjecture into a theorem.
22.5 Emergence: When Quantity Turns Into Quality
Self-reference and fixed points explain the algebraic structure of "a system reasoning about itself". But there is another phenomenon, widespread in complex systems and even harder to formalize: emergence.
Emergence says: when the parts are numerous enough and the interactions rich enough, the system exhibits properties that no single part has, and that cannot be predicted from a simple sum of the parts.
In the training practice of large language models, emergence has been observed: when the model scale crosses some threshold, certain abilities (such as arithmetic reasoning, multi-step inference) suddenly appear, and are completely absent in smaller models. These "suddenly appearing" abilities are called emergent capabilities.
Three Levels of Emergence
Emergence is not a single phenomenon; it happens on at least three levels, each corresponding to different theoretical tools.
Level 1: compositional emergence. Simple atoms combine into new behavioral capacity, even though no single atom has it on its own. A water molecule consists of hydrogen and oxygen — hydrogen and oxygen are each not "wet", but combined they acquire the macroscopic property of "wet". This is the most basic form of emergence, and phase-transition theory can roughly describe it — near the critical point, the system's behavior changes drastically.
Level 2: computational emergence. The single rule of a Turing machine (the
Level 3: representational emergence. In large language models, the abilities that billions of parameters produce after training (such as analogical reasoning, emotion recognition, code generation) are not the function of any single parameter, and were not in the designer's plans. The training objective (next-token prediction) contains no explicit instruction to "understand emotions" or "write code" — but these abilities show up at sufficient scale.
The Problem: Is There a Theory of Emergence?
But emergence is extremely hard to handle in formal theory. It is not a mathematical concept that can be precisely defined — at least, the current mathematical tools are not enough. We have descriptions, no explanations; observations, no predictions.
Information theory offers some clues. Emergence can be understood as: the system has a total description length shorter than that of its parts. A gas consists of
Dynamical systems theory offers another view: emergence corresponds to phase transitions — when a parameter crosses some critical value, the behavior changes drastically and qualitatively. This view is explanatory for physical systems, but for neural-network emergence (abilities suddenly appearing as scale grows) there is no precise predictive framework yet.
Some researchers point out: what is called "emergence" may be, in part, a product of the way it is measured. If measured with continuous (rather than discrete) performance metrics, some abilities taken to be suddenly emergent actually grow smoothly — just at some threshold, the smooth growth crosses the minimum ability bar required by the task and is noticed by the observer. This does not deny the existence of emergence, but demands a more precise characterization: does the performance curve really have a discontinuity, or do our measuring tools introduce a false discontinuity? There is currently no consensus.
22.6 The Boundary of Volume 2, Which Is Also an Opening
From Chapter 14 to Chapter 22, the path has been this:
From the foundations of formal systems, to the limits of consistency and completeness, to resource-sensitive linear logic, to the expansion of probability over truth, to the formalization of intervention in causal inference, to complexity theory's geometric characterization of the cost of reasoning, to the formal contract of heuristics, to learning as inverse inference, and finally to self-reference and emergence.
Each chapter was forced out by the questions left by the previous one. The ending of each chapter left a question, and that question made the next chapter inevitable.
Along this path, we have touched several boundaries:
- The Gödel boundary: sufficiently strong systems have true propositions they cannot see from inside.
- The Turing boundary: certain problems cannot, in principle, be answered by any algorithm.
- The complexity boundary: certain problems cannot, in principle, be solved efficiently.
- The inductive bias boundary: a learning system cannot determine from inside whether its own inductive bias is appropriate.
These boundaries are not obstacles; they are maps. They tell us: in this business of reasoning, which places are unreachable by both humans and machines, which are reachable but costly, and which can be traded for feasibility with approximations.
Finally, there is one question this book does not answer, and cannot:
Where does the reasoning ability AI systems currently display sit on this map?
How far has it reached, where are its boundaries, is it approaching the boundaries of some formal theory, or is it working in a completely different place? This is not a question answerable with existing tools — not because the question is unimportant, but because we do not yet have a language precise enough to state it.
Building such a language is the work of the coming decades.
22.7 From Logic to Dynamics: Three Leftover Questions
The MP game gave us a new perspective: a proof sequence
An orbit has three fates: finite stopping (fixed point), finite cycle, infinite extension.
But the game leaves three questions that the tools of logic cannot answer:
Question 1: where does the orbit stop?
A fixed point
Question 2: what is the energy of convergence?
If the orbit does converge, there must be some quantity decreasing monotonically — some "energy". Logic has no concept of energy. But if we view the belief space
Question 3: where does the energy come from?
The traditional approach is to hand-guess an energy function and verify that it decreases. But if we have already observed the system converging to some prior anchor
Of these three questions, the first two already have rigorous answers in Chapter 12: the Yonglin theorem pins the direction of convergence to the prior anchor
The MP game is the ferry between logic and dynamics. On the logic shore, we ask "does a proof exist?"; on the dynamics shore, we ask "where does the system go?". The fixed point is the landmark shared by both shores — in logic it is the end of a proof; in dynamics it is the attractor. Cross over, and you will find that the attractor has a name: the Yonglin limit.
Open Questions
How far can the Curry-Howard correspondence extend? At present, the correspondence is exact at the level of simple type theory and first-order logic. Higher-order logic (second-order logic, higher-order logic), modal logic, and linear logic (Chapter 16) all have Curry-Howard correspondences of different forms, but with differing degrees of exactness and completeness. Is there a unified framework that brings all formal logic systems into the "propositions as types" view? This is the question Homotopy Type Theory (HoTT) attempts to answer, but HoTT itself is still developing.
Is there a mathematical theory of emergence? Complexity science, phase-transition theory, and information theory each provide partial characterizations of emergence, but there is no unified, predictive theory of emergence. Can the emergent capabilities of large language models be predicted and explained within some formal framework, or is it in essence an empirical phenomenon that theory cannot capture in advance?
The capability boundary of self-referential reasoning: when an AI system reasons about its own reasoning process, what true propositions about itself can it discover, and which boundaries must it inevitably fail to see from inside? This is not just a philosophical question, but a practical question about AI safety and interpretability — under what circumstances will a system that cannot reason about its own limits substitute confident error for honest uncertainty?
The dynamical gap left by the MP game: if a proof sequence is an orbit, then a fixed point is only the name for "stopping", not a guarantee of "stopping in the right place". Chapter 12 answers "what is the energy, and why does it decrease" with the KL energy surface and the contraction mapping; Chapter 23 goes on to answer "how fast does it converge, and how does that rate change with scale". The language of logic ends here; dynamics takes over.
Exercises
★ Warm-up
The core of the Curry-Howard correspondence: propositions correspond to types, proofs correspond to programs. For each of the following logical propositions, write the corresponding type in type theory (using the function type
(law of identity) (weakening) (conjunction elimination) (disjunction introduction)
For item 1, write out a concrete program (function) that "inhabits" this type, and verify that what it corresponds to is indeed "a proof of
★★ Derivation
Fixed-point unrolling: the
combinator satisfies . Manually unroll the first three steps of (read this as the recursive definition of the factorial function). Trace the unrolling and explain clearly how "creates" recursion. Gödel sentence vs. the Y combinator: the Gödel sentence
says "I am unprovable"; satisfies . Both are self-referential constructions, but with different results: leads to undecidability, leads to infinite looping (or recursive unrolling). List their similarities and differences in: (1) the mechanism of self-reference; (2) the consequence of self-reference; (3) the way self-reference is "resolved" (if any).
★★★ Challenge
Dependent type systems (such as Martin-Löf type theory) correspond "
Consider the proposition: "for all natural numbers
- In dependent type theory, what type does this proposition correspond to? Write it in the language of
-types. - What does the "proof" of this proposition (that is, the program inhabiting this type) look like? What input does it take, and what does it return?
- Now consider: type checking (verifying that a program has a given type) is equivalent to verifying a proof. Is this verification operation decidable? (Hint: dependent types make type checking harder — compared with simple type systems, how does the complexity change?)
Question 3 touches the practical limits of dependent type systems: the more powerful the functionality, the higher the cost of type checking; the type checking of some dependent type systems is even undecidable — yet another performance of the book-wide law "the more powerful, the more costly".
Question 3 has no standard answer. It is the last open question Volume 2 raises at the technical level — formal tools at the boundary begin to touch problems beyond the reach of formalization. On that boundary, logic and intuition, proof and conjecture, form and meaning, entangle each other in ways we have not yet fully understood. The book's final answer is in Chapter 23.
