Lambda-Calculus and Type Theory Part II Ugo Dal Lago Scuola Estiva - - PowerPoint PPT Presentation
Lambda-Calculus and Type Theory Part II Ugo Dal Lago Scuola Estiva - - PowerPoint PPT Presentation
Lambda-Calculus and Type Theory Part II Ugo Dal Lago Scuola Estiva AILA, Gargnano, August 2018 Propositional Intuitionistic Logic: Natural Deduction Formulas are derived by the grammar ::= | p | | | ,
Propositional Intuitionistic Logic: Natural Deduction
◮ Formulas are derived by the grammar
ϕ ::= ⊥ | p | ϕ → ϕ | ϕ ∧ ϕ | ϕ ∨ ϕ, where p ranges
- ver a set Θ of propositional variables.
◮ Judgments have the form Γ ⊢ ϕ, where Γ is a finite set of
- formulas. Given two such sets Γ and ∆, their union is
indicated as Γ, ∆.
◮ The rules of propositional intuitionistic logic are as follows:
Γ, ϕ ⊢ ϕ AX Γ, ϕ ⊢ τ Γ ⊢ ϕ → τ I → Γ ⊢ ϕ → τ Γ ⊢ ϕ Γ ⊢ τ E → Γ ⊢ ϕ Γ ⊢ τ Γ ⊢ ϕ ∧ τ I∧ Γ ⊢ ϕ ∧ τ Γ ⊢ ϕ EL∧ Γ ⊢ ϕ ∧ τ Γ ⊢ τ ER∧ Γ ⊢ ϕ Γ ⊢ ϕ ∨ τ IL∨ Γ ⊢ τ Γ ⊢ ϕ ∨ τ IR∨ Γ ⊢ ϕ Γ ⊢ τ Γ, ϕ ∨ τ ⊢ ρ Γ ⊢ ρ E∨ Γ ⊢ ⊥ Γ ⊢ ϕ E⊥
Propositional Intuitionistic Logic: Semantics
◮ Heyting Algebras
◮ Distributive lattices with top and bottom elements, in
which relative pseudo-complement always exist.
◮ Meet and joins interpret conjunctions and disjunctions,
- respectively. Implication is given semantics by way of
pseudo-complements.
◮ Γ |
= ϕ indicates that every Heyting Algebra validating Γ also validates ϕ.
◮ Kripke Semantics
◮ Propositional variables are put in relation with the elements
- f a partial order or possible worlds.
◮ Conjuction and disjuction are interpreted in Tarski-style,
while implication is given semantics by way of the underlying partial order
◮ Γ ϕ indicates that every Kripke model validating Γ also
validates ϕ.
Theorem (Completeness)
Γ ⊢ ϕ if and only if Γ | = ϕ if and only if Γ ϕ.
Simply-Typed λ-Calculus à la Curry
◮ An implicational propositional formula is called a simple
- type. The set of all simple types is denoted by Φ→.
◮ An environment is a finite set Γ of pairs of the form
{x1 : ϕ1, · · · , xn : ϕn}, where the xi are distinct variables and ϕi are simple types. In this case, dom(Γ) is {x1, · · · , xn}.
◮ A typing judgement is a triple Γ ⊢ M : ϕ, consisting of an
environment, a λ-term and a simple type.
◮ The rules are as follows:
Γ, x : ϕ ⊢ x : ϕ V Γ, x : ϕ ⊢ M : τ Γ ⊢ λxM : ϕ → τ λ Γ ⊢ M : ϕ → τ Γ ⊢ N : ϕ Γ ⊢ MN : τ @
◮ The obtained calculus is referred to as ST →.
Subject Reduction
Lemma (Generation Lemma)
Suppose that Γ ⊢ M : ϕ. Then:
- 1. If M is a variable x, then Γ(x) = ϕ;
- 2. If M is an application NL, then there is τ such that
Γ ⊢ N : τ → ϕ and Γ ⊢ L : τ;
- 3. If M is an abstraction λxN and x /
∈ dom(Γ), then ϕ = τ → ρ, where Γ, x : τ ⊢ N : ρ.
Lemma (Substitution Lemma)
- 1. If Γ ⊢ M : ϕ and Γ(x) = ∆(x) for every x ∈ FV (M), then
∆ ⊢ M : ϕ
- 2. If Γ, x : ϕ ⊢ M : τ and Γ ⊢ N : ϕ, then Γ ⊢ M[x := N] : τ.
Theorem (Subject Reduction Theorem)
If Γ ⊢ M : ϕ and M ։β N, then Γ ⊢ N : ϕ.
Simply-Typed λ-Calculus à la Church
◮ Preterms of the simply-typed λ-calculus à la Church are
defined as follows: M ::= x | (MM) | (λx : ϕM).
◮ The notions of substitution, α-conversion, term, and
reduction can be generalised to terms à la Church.
◮ Typing rules are the obvious ones:
Γ, x : ϕ ⊢ x : ϕ V Γ, x : ϕ ⊢ M : τ Γ ⊢ λx : ϕM : ϕ → τ λ Γ ⊢ M : ϕ → τ Γ ⊢ N : ϕ Γ ⊢ MN : τ @
◮ The Subject Reduction Theorem can be easily reproved.
Curry vs. Church
Proposition
In the Simply-Typed λ-calculus à la Church, if Γ ⊢ M : ϕ and Γ ⊢ M : τ, then ϕ = τ.
◮ The erasing map | · | from terms à la Church to terms à la
Curry is defined by induction on the structure of terms, as follows: |x| := x |λx : ϕM| := λx|M| |MN| := |M||N|
◮ Typability and reduction judgments in the two styles can
be translated into each other relatively easily.
Weak Normalisation
Theorem
Every term typable in ST → has a normal form.
◮ The proof is based on the following key ideas:
◮ One can assign to each typable term M, a pair natural
numbers mM := (δM, nM) in such a way that if M is not a normal form, then there is N with M →β N and mM > mN in the lexicographic order.
◮ Then, one proves the statement for every typable term M
by lexicographic induction on mM.
◮ This is not a proof of strong normalisation.
Strong Normalisation
Theorem
Every term typable in ST → is strongly normalising.
◮ A Proof Based on Reducibility.
◮ For every type ϕ, a set of terms Redϕ, the reducible terms; ◮ A proof that any term of type ϕ is in Redϕ; ◮ A proof that any term in Redϕ is strongly normalizing.
◮ A Proof through λI
◮ η-reduction is the smaller compatible relation →η including
pairs of the form λx(Mx) →η M (where x / ∈ FV (M). →βη is the union of →β and →η.
◮ In the λI-calculus, one can form an abstraction λxM only if
x ∈ FV (M).
◮ In the λI-calculus, WN β = SN β.
The Church-Rosser Property
◮ Let → be a binary relation on a set X.
◮ → has the Church-Rosser property (CR) iff for all
a, b, c ∈ X such that a →+ b and a →+ c there is d such that b →+ d and c →+ d.
◮ → has the Weak Church-Rosser property (WCR) iff for all
a, b, c ∈ X such that a → b and a → c there is d such that b →+ d and c →+ d.
◮ → is strongly normalizing (SN) iff there is no infinite
sequence a1 → a2 → · · · .
Proposition (Newman’s Lemma)
Let → be a binary relation satisfying SN. If → satisfies WCR, then → satisfies CR.
Theorem
Church-style ST → is WCR, thus CR.
Expressivity
◮ The normal form of a term of length n can in the worst
case have size 2
2...2
Θ(n) times which is higher (as a function on n) than any elementary function.
Theorem (Statman)
The problem of deciding whether any two given Church-style terms M and N of the same type are beta-equal is of nonelementary complexity.
Expressivity
◮ Let int = (p → p) → (p → p), where p is an arbitrary type
- variable. A function f : Nk → N is ST →-definable if there is
a term Mf with ∅ ⊢ Mf : intk → int such that Mfn1 · · · nk ։β f(n1, . . . , nk)
◮ The class of extended polynomials is the smallest class of
functions over N which is closed under compositions and contains the constant functions, projections, addition, multiplication, and the conditional function cond(n, m, p) = m if n = 0; p
- therwise.
Theorem (Schwichtenberg)
The ST →-definable functions are exactly the extended polynomials.
The Curry-Howard Correspondence
◮ If Γ = {x1 : ϕ1, · · · , xn : ϕn}, then rg(Γ) is the set of
implicational propositional formulas {ϕ1, . . . , ϕn}.
Proposition (Curry-Howard Isomorphism)
- 1. If Γ ⊢ M : ϕ in ST →, then rg(Γ) ⊢ ϕ in IPL→.
- 2. If Γ ⊢ ϕ in IPL→, then there are ∆, M with rg(∆) = Γ and