Lectures onType Theory
Chapter 145
Chapter 145Optional

Classical Realizability, Poles, and Orthogonality

Prerequisites. Direct starred prerequisites: none. No later core chapter depends on this route.

An intuitionistic realizer of an implication is a program that turns realizers of the premise into realizers of the conclusion. Try to build one for double-negation elimination. Write ¬A for A. A realizer of ¬¬AA must accept a program z that, given any refutation of A, produces an absurdity, and must return a realizer of A. The only material available is z, and the only way to use z is to supply it with a refutation of A; but a refutation of A is not something the realizer has, and manufacturing one is exactly the problem to be solved. The attempt λz.z(λw.?) stalls at the hole: whatever is written there must already be a realizer of A.

The repair changes what a proposition denotes. Instead of interpreting A by the programs that establish it, interpret A by the stacks that refute it, and recover the programs by an orthogonality condition against a fixed set of forbidden interactions. A program then realizes A when it survives every refutation of A; and a program may survive a refutation by using it, which is what a control operator does. With that change the hole above is filled by a captured continuation, and the term λz.cc(λk.zk) realizes double-negation elimination.

Three parameters are fixed before anything is proved: a machine, a set of processes called the pole, and a language. This chapter fixes the machine and the pole first (section 145.1, section 145.2), then the interpretation (section 145.3), then proves that control operators realize the classical axioms (section 145.4) and that every proof of the frozen system realizes its conclusion (section 145.5). The tripos and forcing connections are named only after all of that, in section 145.6, and no theorem of this chapter depends on them.

The λc-calculus and its machine

Definition 145.1 — Terms, stacks, processes

Fix a countable set K of instructions containing a distinguished element cc, and a nonempty countable set Π0 of stack constants. Terms, stacks and processes are generated by t,u::=xλx.ttuκkπ(κK),π,π::=αtπ(αΠ0, t closed),p,q::=tπ(t closed). Write Λ for the closed terms, Π for the stacks and ΛΠ for the processes. A term containing no continuation constant kπ is proof-like; PL denotes the set of closed proof-like terms.

The two sets are defined by a simultaneous induction: a stack tπ contains a term, and a term kπ contains a stack. Π is nonempty because Π0 is, and that is used in corollary 145.23.

Definition 145.2 — The Krivine machine

Evaluation is a preorder on ΛΠ containing PushtuπtuπGrab(λx.t)uπt[u/x]πSaveccuπukππRestorekπuπuπ and closed under reflexivity and transitivity. The relation is a parameter of the calculus, exactly like K and Π0: it is required to contain these four rules and is not required to be the least such relation.

Push and Grab implement weak head reduction. Save hands the current stack to the program as the term kπ; Restore discards whatever stack has since accumulated and reinstalls π. The pattern in which cc is normally used chains the two: cc(λk.t)πPushcc(λk.t)πSave(λk.t)kππGrabt[kπ/k]π. The body t runs with the name k bound to the stack that was current when cc was reached. Applying k to an argument abandons the computation in progress and restarts that stack.

Example 145.3 — Backtracking

Let t:=cc(λk.λx.k(λy.u)) and evaluate tvπ. By (145.1) with the stack vπ, tvπ(λx.kvπ(λy.u))vπGrabkvπ(λy.u)πPushkvπ(λy.u)π, and then Restore gives (λy.u)vπu[v/y]π. The argument v has been consumed twice: once by the abandoned λx and once by the reinstated λy. No pure λ-term behaves this way: the rules Push and Grab by themselves never lengthen a stack that has already been shortened.

Definition 145.4 — Krivine numerals

Put 0:=λxy.x,s:=λnxy.y(nxy),n+1:=sn. Every n is proof-like.

Exercise 145.1

★☆☆ Evaluate (λxy.t)uvπ to the process t[u/x][v/y]π, naming the rule used at each of the four steps.

Exercise 145.2

★★☆ Evaluate 2uvπ and show that the result is v(vu)π up to the rules of definition 145.2. Then explain why n is not the Church numeral, and exhibit the β-equivalence between them.

Poles and orthogonality

Definition 145.5 — Pole

A pole is a set ΛΠ closed under anti-evaluation: if pq and q∈⟂ then p∈⟂.

Read p∈⟂ as “the interaction p is admissible”. The closure condition is stated backwards along evaluation because a process is judged by what it becomes.

Definition 145.6 — Orthogonal

Fix a pole. For SΠ and TΛ put S:={tΛtπ∈⟂ for every πS},T:={πΠtπ∈⟂ for every tT}.

Lemma 145.7 — Orthogonality is a Galois connection

For all S,SΠ and TΛ:

  1. if SS then SS, and likewise for subsets of Λ;

  2. SS⟂⟂ and TT⟂⟂;

  3. S⟂⟂⟂=S;

  4. (iSi)=iSi.

Proof of Lemma 145.7 — Orthogonality is a Galois connection

Proof. (1) A term orthogonal to every stack in the larger set is orthogonal to every stack in the smaller one.

(2) Let πS and tS. By the definition of S, tπ∈⟂. As t was arbitrary in S, this says πS⟂⟂.

(3) By (2) applied to SΛ we get SS⟂⟂⟂. By (2) applied to S and then (1), SS⟂⟂ gives S⟂⟂⟂S.

(4) t(iSi) says tπ∈⟂ for every π lying in some Si, which is the conjunction over i of tSi. ◻

Example 145.8 — Two poles

The empty set is a pole: the closure condition is vacuous. For it, S=Λ when S= and S= otherwise. For a fixed process q, the set q:={ppq} is a pole, because is transitive. The second is used to prove converses: membership in q is the statement that a process eventually reaches q.

Falsity values, truth values, and realizability

Definition 145.9 — Formulas with parameters

The language has first-order terms built from 0, s and the symbols for primitive recursive functions; first-order variables ranging over N; and second-order variables X of each arity k. Formulas are A,B::=X(e1,,ek)ABxAXAF˙(e1,,ek), where in the last clause F:NkP(Π) is a falsity function and F˙ is a predicate constant added for it. A formula with no free variable is closed with parameters.

Definition 145.10 — Falsity and truth values

Fix a pole. For a closed formula with parameters, define AΠ by F˙(e1,,ek):=F(e1N,,ekN),AB:=|A|B={tπt|A|, πB},xA:=nNA[nN/x],XA:=F:NkP(Π)A[F˙/X], where eN is the value of the closed first-order term e in the standard model, and |A|:=A. A term t realizes A with respect to the pole when t|A|, and t is a universal realizer of A when t|A| for every pole. Both truth and falsity values depend on the pole; the notation suppresses it, and the dependence is displayed whenever two poles occur in one argument.

The definition of is by induction on the formula; the clause for mentions |A|, which is A and therefore already defined at the smaller formula A. Nothing is defined by induction on truth values.

Lemma 145.11 — Truth values of quantifiers

For every closed A with parameters, |xA|=nN|A[nN/x]|,|XA|=F|A[F˙/X]|, and |AB||A||B|, where |A||B|:={tΛtu|B| for all u|A|}.

Proof of Lemma 145.11 — Truth values of quantifiers

Proof. The two equalities are lemma 145.7(4) applied to the unions in definition 145.10. For the inclusion, let t|AB|, u|A| and πB. Then uπAB, so tuπ∈⟂. Since tuπPushtuπ and the pole is closed under anti-evaluation, tuπ∈⟂. As π was arbitrary, tu|B|. ◻

Remark 145.12 — The inclusion is strict

The converse inclusion fails. A term in |A||B| is only required to behave well when it is applied to a realizer, that is, after a Push; a term in |AB| must behave well when it is started against a stack uπ directly, and it may inspect that stack before any application occurs. What survives is the η-expansion: if t|A||B| then λx.tx|AB|, because (λx.tx)uπtuπ and the latter process lies in the pole. This asymmetry has no counterpart in intuitionistic realizability, where the two sets coincide.

Exercise 145.3

★☆☆ Compute XX and |XX| for the empty pole, and for the pole q of example 145.8. Which of the two makes XX realized?

Exercise 145.4

★★☆ Prove the claim of remark 145.12 that t|A||B| implies λx.tx|AB|, naming the rule of definition 145.2 and the closure property of the pole used at each step (four lines).

Control operators realize the classical axioms

Fix a pole throughout this section. The two theorems below are the reason the interpretation was arranged around stacks: they read a computational rule of definition 145.2 directly as a logical property, with no induction on formulas.

Proposition 145.13 — Typing a continuation constant

If πA then kπ|AB| for every closed B with parameters.

Proof of Proposition 145.13 — Typing a continuation constant

Proof. Let πAB. By definition 145.10, π=uπ with u|A| and πB. Then kππ=kπuπRestoreuπ, and uπ∈⟂ because u|A| and πA. Closure under anti-evaluation gives kππ∈⟂. As π was arbitrary, kπAB. ◻

The stack π is discarded by Restore and never examined; that is why B may be any formula. A continuation constant is a realizer of an implication whose conclusion it never has to produce.

Theorem 145.14 — cc realizes Peirce's law

For all closed A,B with parameters, cc|((AB)A)A|. Since the pole was arbitrary, cc is a universal realizer.

Proof of Theorem 145.14 — cc realizes Peirce's law

Proof. Let π((AB)A)A. By definition 145.10, π=tπ with t|(AB)A| and πA. By Save, cctπtkππ. Now πA, so proposition 145.13 gives kπ|AB|, whence kππ|AB|A=(AB)A. Since t realizes that formula, tkππ∈⟂, and closure under anti-evaluation gives ccπ∈⟂. ◻

Neither proof used any property of the pole beyond definition 145.5, and neither inspected A or B. The next proposition shows that the correspondence between machine behavior and realized formulas runs in both directions.

Definition 145.15 — Identity-like

A closed term t is identity-like when tuπuπ for all uΛ and πΠ.

Proposition 145.16 — Behavior determines the formula

A closed term t is identity-like if and only if t is a universal realizer of X(XX).

Proof of Proposition 145.16 — Behavior determines the formula

Proof. From behavior to realizability. Let t be identity-like, fix a pole, and let πX(XX). By definition 145.10 that set is SΠS˙S˙, so πS˙S˙=SS for some S, that is, π=uπ with uS and πS. Then uπ∈⟂ by the definition of S, and tπ=tuπuπ, so tπ∈⟂ by anti-evaluation.

From realizability to behavior. Let t realize X(XX) for every pole, and fix uΛ and πΠ. Choose the pole :={ppuπ} of example 145.8 and the falsity value S:={π}. Then uπ∈⟂ by reflexivity of , so uS, and therefore uπSS=S˙S˙X(XX). Since t realizes the formula at this pole, tuπ∈⟂, which by the definition of this particular pole says tuπuπ. ◻

The second half is the pattern used throughout classical realizability to prove converses: a single process is turned into a pole, and a single stack into a falsity value, so that “realizes” collapses to the one behavioral statement wanted.

Example 145.17 — Realizers need not be pure

Each of λx.x, λx.cc(λk.x) and λx.cc(λk.kx) is identity-like, hence by proposition 145.16 a universal realizer of X(XX). For the second, by (145.1), (λx.cc(λk.x))uπcc(λk.u)πuπ, the captured continuation being discarded. For the third, the captured kπ is applied to u, and Restore sends u to the same π. A realizer therefore carries no information about which proof produced it.

Exercise 145.5

★★☆ Show that λz.cc(λk.zk) is a universal realizer of X((¬X)X), where ¬A:=A and :=XX. Reduce to theorem 145.14 by identifying the instance of Peirce’s law used, and say which step needs =Π.

Exercise 145.6

★★☆ Show that no proof-like term built from λ-abstraction and application alone is a universal realizer of Peirce’s law. Hint: for such a term, every process it produces from tπ has a stack extending π, and no rule shortens a stack; choose a pole recording that invariant.

Adequacy

Definition 145.18 — The system λ NK_2

Proof terms are t,u::=xλx.ttucc and a typing context is Γ=z1:A1,,zn:An. The judgment Γt:A is generated by (z:A)ΓΓz:A AxΓcc:((AB)A)A PeirceΓ,z:At:BΓλz.t:AB IΓt:ABΓu:AΓtu:B EΓt:AxFV(Γ)Γt:xA 1IΓt:xAΓt:A[e/x] 1EΓt:AXFV(Γ)Γt:XA 2IΓt:XAΓt:A[P/X] 2E where e ranges over first-order terms and P over predicates λx1xk.C of the language.

Only and the two universal quantifiers are primitive; the other connectives are the usual second-order abbreviations, and no rule mentions them. Proof terms are proof-like: no continuation constant occurs in definition 145.18.

Definition 145.19 — Valuation, closure, adequacy

A valuation ρ assigns a natural number ρ(x) to each first-order variable and a falsity function ρ(X):NkP(Π) to each second-order variable of arity k. A[ρ] is the closed formula with parameters obtained by replacing each free x by (the numeral naming) ρ(x) and each free X by ρ(X)˙. Fix a pole. The judgment z1:A1,,zn:Ant:A is adequate when for every valuation ρ and all u1|A1[ρ]|,,un|An[ρ]|, t[u1/z1,,un/zn]|A[ρ]|. A rule is adequate when adequacy of its premises implies adequacy of its conclusion.

Lemma 145.20 — Substitution in falsity values

For every formula A, valuation ρ, first-order term e and predicate P=λx.C, (A[e/x])[ρ]=A[ρ[xeN[ρ]]],(A[P/X])[ρ]=A[ρ[XFP,ρ]], where FP,ρ(n):=C[ρ][n/x].

Proof of Lemma 145.20 — Substitution in falsity values

Proof. Induction on A. At an atom X(e1,,ek) with X the substituted variable, the left-hand side is C[ρ][eN/x] by definition 145.10 and the right-hand side is FP,ρ(eN), the same set by the definition of FP,ρ. At an atom whose head is a different variable or a parameter, both sides are unchanged. The clause for applies the induction hypotheses to the two immediate subformulas, and the two quantifier clauses apply them under each substitution instance, the bound variable being chosen outside dom(ρ), outside the free variables of e and outside those of C. ◻

Theorem 145.21 — Adequacy

Fix a pole. Every rule of definition 145.18 is adequate, and therefore every derivable judgment is adequate.

Proof of Theorem 145.21 — Adequacy

Proof. Induction on the derivation; each case checks definition 145.19 for the conclusion. Fix a valuation ρ, fix realizers ui of Ai[ρ], and abbreviate the simultaneous substitution by θ:=[u1/z1,,un/zn].

Ax. t=zj and A=Aj, so t[θ]=uj, which lies in |Aj[ρ]| by hypothesis.

Peirce. t=cc, which is closed, so t[θ]=cc; theorem 145.14 at the formulas A[ρ] and B[ρ] gives the membership.

-I. Let πA[ρ]B[ρ], so π=uπ with u|A[ρ]| and πB[ρ]. Then (λz.t)[θ]uπ=(λz.t[θ])uπGrabt[θ][u/z]π, the bound name z being chosen distinct from every zi and fresh for every ui. The induction hypothesis for the premise, applied to the extended list of realizers u1,,un,u, gives t[θ][u/z]|B[ρ]|, hence t[θ][u/z]π∈⟂; anti-evaluation finishes the case.

-E. By the induction hypotheses t[θ]|A[ρ]B[ρ]| and u[θ]|A[ρ]|. Lemma 145.11 gives t[θ]u[θ]|B[ρ]|, and (tu)[θ]=t[θ]u[θ].

1-I. By definition 145.10, (xA)[ρ]=nA[ρ[xn]], so by lemma 145.7(4) |(xA)[ρ]|=n|A[ρ[xn]]|. Fix n. Since x is not free in Γ, the hypotheses ui|Ai[ρ]| read equally as ui|Ai[ρ[xn]]|, so the induction hypothesis at the valuation ρ[xn] gives t[θ]|A[ρ[xn]]|. As n was arbitrary, t[θ] lies in the intersection.

1-E. By the induction hypothesis t[θ]|(xA)[ρ]|=n|A[ρ[xn]]|. Take n:=eN[ρ]; then t[θ]|A[ρ[xn]]|, which equals |(A[e/x])[ρ]| by lemma 145.20.

2-I and 2-E. The same two arguments with falsity functions in place of natural numbers: the union in definition 145.10 is over all F:NkP(Π), the side condition XFV(Γ) makes the hypotheses on the ui independent of F, and the elimination case instantiates F at FP,ρ, which is the falsity function named by lemma 145.20.

Every rule being adequate, an induction on the derivation gives adequacy of every derivable judgment. ◻

Corollary 145.22 — Proofs give universal realizers

If t:A with A closed, then tPL and t|A| for every pole.

Proof of Corollary 145.22 — Proofs give universal realizers

Proof. t is proof-like because definition 145.18 produces no continuation constant. Apply theorem 145.21 with n=0 at an arbitrary pole and an arbitrary valuation; A is closed, so A[ρ]=A. ◻

Corollary 145.23 — Consistency

There is no proof term t with t:XX.

Proof of Corollary 145.23 — Consistency

Proof. By definition 145.10, XX is the union of F˙=F over all F:P(Π) of arity 0, that is, over all subsets of Π; so XX=Π. Take the empty pole (example 145.8). Then |XX|=Π={tΛtπ for every πΠ}=, the last equality because Π: the set Π0 of stack constants is nonempty by definition 145.1. If t:XX held, corollary 145.22 would put t in the empty set. ◻

Corollary 145.23 is the payoff of the arrangement. It uses the whole chapter: the syntax to know that Π is nonempty, the pole axiom to know that is admissible, the definition of falsity values to compute XX, and adequacy to connect the computation to derivability.

What the model does not do

The machine of definition 145.2 is not required to normalize, and nothing above uses confluence. Definition 145.2 fixes as a parameter containing four rules; adding instructions and rules to K and to preserves every proof in this chapter, because each proof used only closure of the pole under anti-evaluation and the four displayed rules in the forward direction. That extensibility is the point of axiomatizing evaluation rather than defining it.

Remark 145.24 — Induction is not realized

The second-order induction axiom Ind:=Z[0Zy(yZs(y)Z)x(xZ)] is not realized, because x is interpreted uniformly: by definition 145.10 a realizer of x(xZ) must be orthogonal to the union of the falsity values over all n at once, with no access to n. The standard repair, which this chapter does not carry out, restricts to the theory without Ind and relativizes every first-order quantifier to the predicate N:={xZ[0Zy(yZs(y)Z)xZ]}. The relativization theorem, that a proof of A in second-order arithmetic yields a proof of AN without induction, is stated in section 145.6 with its locator and is not proved here.

Remark 145.25 — Triposes and forcing are separate constructions

A pole together with the operations of definition 145.10 determines an indexed preorder in which a predicate over I is a map IP(Π) and entailment is uniform realizability. Comparing that structure with definition 144.2 requires exhibiting the generic predicate and checking each clause, which is a construction and not an observation; chapter 144 owns the tripos axioms, and nothing in the present chapter has been shown to satisfy them. Likewise, forcing arises as the degenerate case in which the added instructions make the realizability structure collapse to a complete Boolean or Heyting algebra — for instance after adding a nondeterministic choice instruction with forkuvπuπ and forkuvπvπ — and identifying the collapse is again a theorem with hypotheses, not a reading of the definitions. No model of set theory, no Boolean-valued model and no topos is constructed in this chapter.

Suggested first pass.

Begin with exercise 145.7 and exercise 145.9, then complete exercise 145.11.

Exercise 145.7

★★☆ Write the complete machine trace of cc(λk.λx.kx)uπ, naming the rule at each step, and identify the stack that is discarded. Then say which line of the proof of theorem 145.14 corresponds to each step.

Exercise 145.8

★★☆ Show that the poles of definition 145.5 are closed under arbitrary intersection and arbitrary union, so that they form a complete lattice ordered by inclusion. Identify its top and bottom elements, and show that A is realized with respect to the top pole for every closed A.

Exercise 145.9

★★★ (Storage.) Call a closed term M a storage operator when Mtuπtnuπ for every t realizing nN, where N is the relativization predicate of remark 145.24. Prove that M:=λn.λf.n(λg.g0)(λh.λg.h(λy.g(sy)))(λz.z)f satisfies this specification for the numerals of definition 145.4, or repair it and prove the repaired term correct. State exactly which clause of definition 145.10 makes the specification a statement about all poles.

Exercise 145.10

★★★ Prove that |AB| is in general a proper subset of |A||B| (remark 145.12), by exhibiting a pole, formulas A and B, and a term belonging to the second set and not the first. Hint: choose a pole in which a term can detect whether its stack has the shape uπ before any Push occurs.

Exercise 145.11

★★★ Practical project.krivine-machine-and-realizer-checker Implement the Krivine machine of definition 145.2 together with a checker for the two decidable specifications used in this chapter. The machine takes a closed term and a stack, both given as syntax trees over the grammar of definition 145.1, and a step budget; it returns either the process reached after that many steps or the first process on which no rule applies. Continuation constants are represented by the stack they carry, so that Restore is a genuine stack replacement and not a return.

Invariant. After every step the machine’s state is a well-formed process: the term is closed, and every kπ occurring in it carries a stack built only from closed terms and stack constants. The implementation checks this invariant after each step and aborts, naming the offending subterm, rather than continuing on a malformed state.

Concrete result. For the identity-like test the program takes a closed term t, a finite list of test pairs (u,π), and reports for each pair either identity-like together with the trace witnessing tuπuπ, or not identity-like together with the process at which the trace stopped. For the storage test it takes a term M and a bound N and reports, for each nN, whether Mnuπ reaches unπ.

Acceptance test. With Π0={α} and u:=λx.x: the three terms of example 145.17 must all report identity-like on the pair (u,α); the trace of the third must contain a Save step followed by a Restore step, and the trace of the second must contain a Save step and no Restore step. On the pair (ω,α) with ω:=λz.zz, the term λx.xx must report not identity-like with budget exhausted, and the printed last process must have a stack strictly longer than α. Finally, run the term of example 145.3 applied to two copies of u, against the stack α, for nine steps: the trace must contain two Grab steps and must end with a Restore step whose stack is the saved uα and not the caller’s α. A run in which Restore returns to the caller instead of installing π passes the three identity-like checks unchanged and fails only here, which is why the acceptance test includes it: the two stacks coincide on the identity-like probes and differ exactly on this one.

Sources. The λc-calculus, the Krivine abstract machine, poles, falsity and truth values, and the adequacy theorem follow A. Miquel, An Introduction to Krivine Realizability, course notes, Universidad de la República, 2021 (79 slides). Definition 145.1 and definition 145.4 are on physical page 30 and 31; the machine rules of definition 145.2 and the derived pattern (145.1) are on physical pages 31–32; the type system of definition 145.18 is on physical page 15, and the classical axioms it derives on page 17; the second-order arithmetic of remark 145.24 and the relativization AAN are on physical pages 19–21; poles, falsity values and truth values by orthogonality are on physical pages 40–42; the typing of kπ and of cc proved as proposition 145.13, theorem 145.14 and the identity-like characterization of proposition 145.16 are on physical pages 45–46 and 43–45; and the definition of adequate judgment together with the statement proved here as theorem 145.21 is on physical page 53, where the source leaves the proof as an exercise. The peer-reviewed development of the same apparatus, with the specification and witness-extraction results that this chapter does not import, is M. Guillermo and É. Miquey, Classical realizability and arithmetical formulæ, Mathematical Structures in Computer Science 27 (2017), 1068–1107. A gradual route with solved exercises is Barbarossa and Guerrieri [BG25]; the comparison with forcing, including the machine-checked historical development, is Rieg [Rie14b, Rie14a], and the categorical reading is Miquey [Miq17]. Realizability as a source of categorical models is developed in chapter 144; see remark 145.25 for what would have to be proved to connect the two.

Search the book

Type to search the local edition.