Lambda-Calculus and Type Theory Part II Ugo Dal Lago Scuola Estiva - - PowerPoint PPT Presentation

lambda calculus and type theory part ii
SMART_READER_LITE
LIVE PREVIEW

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 | | | ,


slide-1
SLIDE 1

Lambda-Calculus and Type Theory Part II

Ugo Dal Lago Scuola Estiva AILA, Gargnano, August 2018

slide-2
SLIDE 2

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⊥

slide-3
SLIDE 3

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 Γ ϕ.

slide-4
SLIDE 4

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 →.

slide-5
SLIDE 5

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 : ϕ.

slide-6
SLIDE 6

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.

slide-7
SLIDE 7

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.

slide-8
SLIDE 8

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.

slide-9
SLIDE 9

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 β.

slide-10
SLIDE 10

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.

slide-11
SLIDE 11

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.

slide-12
SLIDE 12

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.

slide-13
SLIDE 13

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

∆ ⊢ M : ϕ.

Corollary

IPL→ is consistent.

slide-14
SLIDE 14

The Curry-Howard Correspondence

◮ The one we presented is not an isomorphism between

proofs of IPL→ and terms of ST →.

◮ Getting an exact isomorphism requires altering the way we

presented natural deduction: [ϕ]i . . . . τ ϕ → τ (i) ϕ → τ ϕ τ

◮ What corresponds to β-reduction is the following rule:

. . . . ϕ [ϕ]i . . . . τ ϕ → τ (i) τ ⇒ . . . . ϕ . . . . τ

slide-15
SLIDE 15

Hilbert-Style Proofs

◮ Logical axioms are defined as all those instances of the

following t two schemes: ϕ → τ → ϕ; (A1) (ϕ → τ → ρ) → (ϕ → τ) → ϕ → ρ; (A2)

◮ The Hilbert-Style rules for propositional intuitionistic logic

are as follows: Γ, ϕ ⊢H ϕ ϕ is a logical axiom Γ ⊢H ϕ Γ ⊢H ϕ → τ Γ ⊢H ϕ Γ ⊢H τ

Theorem (Deduction Theorem)

If Γ, ϕ ⊢H τ, then Γ ⊢H ϕ → τ.

Theorem

Γ ⊢H ϕ iff Γ ⊢ ϕ

slide-16
SLIDE 16

Combinatory Logic

◮ Terms of combinatory logic are defined as follows:

M ::= x | (MM) | K | S.

◮ The relation →w is the least compatible relation on

combinatory logic terms such that KMN →w M; SMNL →w ML(NL). As usual, ։w is the reflexive and transitive closure of →w.

◮ The notions of normal forms, weak normalization and

strong normalization are defined as usual.

slide-17
SLIDE 17

Typed Combinatory Logic

◮ Typing Rules for Combinatory Logic Terms are defined as

follows:

Γ, x : ϕ ⊢ x : ϕ V Γ ⊢ S : (ϕ → τ → ρ) → (ϕ → τ) → ϕ → ρ S Γ ⊢ K : ϕ → τ → ϕ K Γ ⊢ M : ϕ → τ Γ ⊢ N : ϕ Γ ⊢ MN : τ @

Theorem (Subject Reduction)

If Γ ⊢ M : ϕ and M ։w N, then Γ ⊢ N : ϕ.

Theorem (Strong Normalization)

Γ ⊢ M : ϕ, then M is strongly normalizing.