Proofs and Type-theory
The presentation of natural deduction so far has concentrated on the nature of propositions without giving a formal definition of a proof. To formalise the notion of proof, we alter the presentation of hypothetical derivations slightly. We label the antecedents with proof variables (from some countable set V of variables), and decorate the succedent with the actual proof. The antecedents or hypotheses are separated from the succedent by means of a turnstile (⊢). This modification sometimes goes under the name of localised hypotheses. The following diagram summarises the change.
---- u_{1} ---- u_{2} ... ---- u_{n} J_{1} J_{2} J_{n} ⋮ J | ⇒ | u_{1}:J_{1}, u_{2}:J_{2}, ..., u_{n}:J_{n} ⊢ J |
The collection of hypotheses will be written as Γ when their exact composition is not relevant. To make proofs explicit, we move from the proof-less judgement "A true" to a judgement: "π is a proof of (A true)", which is written symbolically as "π : A true". Following the standard approach, proofs are specified with their own formation rules for the judgement "π proof". The simplest possible proof is the use of a labelled hypothesis; in this case the evidence is the label itself.
u ∈ V ------- proof-F u proof | --------------------- hyp u:A true ⊢ u : A true |
For brevity, we shall leave off the judgemental label true in the rest of this article, i.e., write "Γ ⊢ π : A". Let us re-examine some of the connectives with explicit proofs. For conjunction, we look at the introduction rule ∧I to discover the form of proofs of conjunction: they must be a pair of proofs of the two conjuncts. Thus:
π_{1} proof π_{2} proof -------------------- pair-F (π_{1}, π_{2}) proof | Γ ⊢ π_{1} : A Γ ⊢ π_{2} : B ------------------------ ∧I Γ ⊢ (π_{1}, π_{2}) : A ∧ B |
The elimination rules ∧E_{1} and ∧E_{2} select either the left or the right conjunct; thus the proofs are a pair of projections — first (fst) and second (snd).
π proof ----------- fst-F fst π proof | Γ ⊢ π : A ∧ B ------------- ∧E_{1} Γ ⊢ fst π : A | |
π proof ----------- snd-F snd π proof | Γ ⊢ π : A ∧ B ------------- ∧E_{2} Γ ⊢ snd π : B |
For implication, the introduction form localises or binds the hypothesis, written using a λ; this corresponds to the discharged label. In the rule, "Γ, u:A" stands for the collection of hypotheses Γ, together with the additional hypothesis u.
π proof ------------ λ-F λu. π proof | Γ, u:A ⊢ π : B ----------------- ⊃I Γ ⊢ λu. π : A ⊃ B | |
π_{1} proof π_{2} proof ------------------- app-F π_{1} π_{2} proof | Γ ⊢ π_{1} : A ⊃ B Γ ⊢ π_{2} : A ---------------------------- ⊃E Γ ⊢ π_{1} π_{2} : B |
With proofs available explicitly, one can manipulate and reason about proofs. The key operation on proofs is the substitution of one proof for an assumption used in another proof. This is commonly known as a substitution theorem, and can be proved by induction on the depth (or structure) of the second judgement.
- Substitution theorem
- If Γ ⊢ π_{1} : A and Γ, u:A ⊢ π_{2} : B, then Γ ⊢ π_{2} : B.
So far the judgement "Γ ⊢ π : A" has had a purely logical interpretation. In type theory, the logical view is exchanged for a more computational view of objects. Propositions in the logical interpretation are now viewed as types, and proofs as programs in the lambda calculus. Thus the interpretation of "π : A" is "the program π has type A". The logical connectives are also given a different reading: conjunction is viewed as product (×), implication as the function arrow (→), etc. The differences are only cosmetic, however. Type theory has a natural deduction presentation in terms of formation, introduction and elimination rules; in fact, the reader can easily reconstruct what is known as simple type theory from the previous sections.
The difference between logic and type theory is primarily a shift of focus from the types (propositions) to the programs (proofs). Type theory is chiefly interested in the convertibility or reducibility of programs. For every type, there are canonical programs of that type which are irreducible; these are known as canonical forms or values. If every program can be reduced to a canonical form, then the type theory is said to be normalising (or weakly normalising). If the canonical form is unique, then the theory is said to be strongly normalising. Normalisability is a rare feature of most non-trivial type theories, which is a big departure from the logical world. (Recall that every logical derivation has an equivalent normal derivation.) To sketch the reason: in type theories that admit recursive definitions, it is possible to write programs that never reduce to a value; such looping programs can generally be given any type. In particular, the looping program has type ⊥, although there is no logical proof of "⊥ true". For this reason, the propositions as types; proofs as programs paradigm only works in one direction, if at all: interpreting a type theory as a logic generally gives an inconsistent logic.
Like logic, type theory has many extensions and variants, including first-order and higher-order versions. An interesting branch of type theory, known as dependent type theory, allows quantifiers to range over programs themselves. These quantified types are written as Π and Σ instead of ∀ and ∃, and have the following formation rules:
Γ ⊢ A type Γ, x:A ⊢ B type ----------------------------- Π-F Γ ⊢ Πx:A. B type | Γ ⊢ A type Γ, x:A ⊢ B type ---------------------------- Σ-F Γ ⊢ Σx:A. B type |
These types are generalisations of the arrow and product types, respectively, as witnessed by their introduction and elimination rules.
Γ, x:A ⊢ π : B -------------------- ΠI Γ ⊢ λx. π : Πx:A. B | Γ ⊢ π_{1} : Πx:A. B Γ ⊢ π_{2} : A ----------------------------- ΠE Γ ⊢ π_{1} π_{2} : B |
Γ ⊢ π_{1} : A Γ, x:A ⊢ π_{2} : B ----------------------------- ΣI Γ ⊢ (π_{1}, π_{2}) : Σx:A. B | Γ ⊢ π : Σx:A. B ---------------- ΣE_{1} Γ ⊢ fst π : A | Γ ⊢ π : Σx:A. B ------------------------ ΣE_{2} Γ ⊢ snd π : B |
Dependent type theory in full generality is very powerful: it is able to express almost any conceivable property of programs directly in the types of the program. This generality comes at a steep price — either typechecking is undecidable (extensional type theory), or extensional reasoning is more difficult (intensional type theory). For this reason, some dependent type theories do not allow quantification over arbitrary programs, but rather restrict to programs of a given decidable index domain, for example integers, strings, or linear programs.
Since dependent type theories allow types to depend on programs, a natural question to ask is whether it is possible for programs to depend on types, or any other combination. There are many kinds of answers to such questions. A popular approach in type theory is to allow programs to be quantified over types, also known as parametric polymorphism; of this there are two main kinds: if types and programs are kept separate, then one obtains a somewhat more well-behaved system called predicative polymorphism; if the distinction between program and type is blurred, one obtains the type-theoretic analogue of higher-order logic, also known as impredicative polymorphism. Various combinations of dependency and polymorphism have been considered in the literature, the most famous being the lambda cube of Henk Barendregt.
The intersection of logic and type theory is a vast and active research area. New logics are usually formalised in a general type theoretic setting, known as a logical framework. Popular modern logical frameworks such as the calculus of constructions and LF are based on higher-order dependent type theory, with various trade-offs in terms of decidability and expressive power. These logical frameworks are themselves always specified as natural deduction systems, which is a testament to the versatility of the natural deduction approach.
Read more about this topic: Natural Deduction
Famous quotes containing the words proofs and and/or proofs:
“Would you convey my compliments to the purist who reads your proofs and tell him or her that I write in a sort of broken-down patois which is something like the way a Swiss waiter talks, and that when I split an infinitive, God damn it, I split it so it will stay split, and when I interrupt the velvety smoothness of my more or less literate syntax with a few sudden words of bar- room vernacular, that is done with the eyes wide open and the mind relaxed but attentive.”
—Raymond Chandler (1888–1959)
“Would you convey my compliments to the purist who reads your proofs and tell him or her that I write in a sort of broken-down patois which is something like the way a Swiss waiter talks, and that when I split an infinitive, God damn it, I split it so it will stay split, and when I interrupt the velvety smoothness of my more or less literate syntax with a few sudden words of bar- room vernacular, that is done with the eyes wide open and the mind relaxed but attentive.”
—Raymond Chandler (1888–1959)