Appendix A
Proof that Proofs Are Terms
Chapter 4 claimed that every proof in second-order propositional logic can be turned into a term that the kernel accepts (Theorem 4.1). This appendix makes the statement precise and proves it in full. The proof is short once the right bookkeeping is in place: it is an induction on the derivation of the logical judgment, and each case is one row of the table in Chapter 4 read from left to right.
The idea
A derivation in the logic is a tree of rule applications. The translation in Chapter 4 pairs each logical rule with a typing rule. So the natural plan is: walk the derivation from the leaves up, and at each node build the typing derivation that the paired typing rule gives. A hypothesis becomes a variable lookup, an implication introduction becomes a , an implication elimination becomes an application, and the two quantifier rules become a over and an application to a type.
Two details need care, and both are about contexts.
- The logical rules do not say which proposition variables are in scope. The typing side needs to know, because a proposition variable is only usable after the assumption is in the context. The precise statement therefore carries an explicit list of proposition variables.
- The typing rules extend contexts on the right, but the translation of Chapter 4 puts all proposition variables before all hypotheses. The proof is easier if any interleaving is allowed, so we prove the theorem for every context that represents the logical judgment, in a sense defined below.
The precise statement
Theorem 4.1 leaves implicit which proposition variables are in scope. For the proof we make them explicit and write
where is a list of distinct proposition variables, and every proposition variable free in or in belongs to . With this bookkeeping the rules of Chapter 4 read as follows.
The side condition of Chapter 4 is now implied by : every proposition variable free in is in , and is not. Formulas are taken up to -equivalence, so a bound can always be renamed to satisfy the side condition. As in Chapter 4, stands for with fresh.
The context of Chapter 4 lists the proposition variables first and the hypotheses after them. The proof has to extend contexts on the right, so it is convenient to allow any order.
Definition A.1 (Representation). A context represents if and consists of one assumption for each and one assumption for each , in some order.
Theorem A.2 (Theorem 4.1, precise form). If and represents , then for some term .
Theorem 4.1 is the special case . When lists the free proposition variables, the context contains exactly the required assumptions; it is well formed by Lemma A.3 below together with the rule C-Ext, since each hypothesis type is a proposition once the proposition variables are in scope.
Facts about the translation
The translation commutes with substitution:
This is a routine induction on : both sides replace the free occurrences of by , and the translation does nothing to a proposition variable except keep its name. The -elim case of the main proof depends on this equation.
The next lemma is the one place where the universe structure of Chapter 13 enters. It says that every translated formula is a proposition, that is, has type . Without it, the typing rule T-Lam could not be applied to a hypothesis, and the -elim case could not instantiate a quantifier with an arbitrary formula.
Lemma A.3 (Formulas are propositions). If and for every , then .
By induction on .
For a proposition variable , the assumption gives , so by T-Var.
For , the induction hypothesis gives , so is well formed by C-Ext for a fresh . The induction hypothesis for in that extended context gives , and T-Pi gives .
For , rename so that . T-Sort gives , so is well formed by C-Ext. The induction hypothesis for in that context gives , and T-Pi gives .
The proof
We prove Theorem A.2 by induction on the derivation of , for all representing contexts at once. Each case builds the typing derivation shown in the right column of the table in Chapter 4.
Hypothesis. The rule concludes from . Since represents , it contains an assumption , so by T-Var.
-intro. The premise is and the conclusion is . By Lemma A.3, . For a fresh , the context is therefore well formed by C-Ext, and it represents . The induction hypothesis, applied to the premise and this context, gives for some , and T-Lam gives
This type is : the free variables of are proposition variables, and is not one of them, so does not occur in and the is non-dependent.
-elim. The premises are and . The induction hypotheses give with , and . T-App gives , and since does not occur in the substitution does nothing: .
-intro. The premise is with , and the conclusion is . Renaming if necessary, assume ; a routine induction shows that renaming a variable of to a fresh one preserves derivations. By T-Sort and C-Ext, is well formed, and it represents . The induction hypothesis gives , and T-Lam gives
which is the translation of .
-elim. The premise is with , and the conclusion is . The induction hypothesis gives . Since every proposition variable of is in and hence has an assumption in , Lemma A.3 gives . T-App gives
where the last step is the substitution equation from the previous section.
Every rule of the logic has been covered, so the theorem holds for every derivation.
The proof never needs T-Conv. Every typing derivation it builds compares types only syntactically, up to the names of bound variables. Conversion becomes necessary only when the logic is extended with computation, as the inductive types of Part II do.
What to remember
- The precise form of the theorem carries an explicit list of proposition variables, and proves the claim for every context that represents , in any order.
- Every translated formula lives in (Lemma A.3). This uses impredicativity in the case, and it is what lets -elim instantiate a quantifier with any formula.
- The proof is an induction on the derivation; each logical rule maps to exactly one typing rule: Hyp to T-Var, the two introductions to T-Lam, the two eliminations to T-App.
- T-Conv is never used, because the logic has no computation.