Barendregt’s Lambda Cube
I Classification of type λω λPω systems: dependency
I Simply Typed Lambda Calculus λ2 λP2 I Extensions: 1. Polymorphic Types λω λPω 2. Type Operations 3. Dependent Types I Variation over same λ→ λP theme: functions Dependencies between types and terms
λω λPω I Terms depending on terms — Normal functions
I Terms depending on types λ2 λP2 — Polymorphism Types depending on types I λω λPω — Type operators
I Types depending on terms — Dependent types λ→ λP Terms depending on terms
Syntax:
M,N ::= x | (λx : τ.N) | (MN) τ, σ ::= α | τ → σ
Rules:
Γ(x) = τ Var Γ ` x : τ
Γ, x : τ ` M : σ Abs Γ ` λx : τ.M : τ → σ
Γ ` M : τ Γ ` N : τ → σ App Γ ` NM : σ About Simply Typed Lambda Calculus
I Not very expressive
I No genereal identity function
I Propositional logic Terms depending on types
Syntax:
M,N ::= x | (λx : τ.N) | (MN) | Λα.M τ, σ ::= α | τ → σ | ∀α.τ
Two new rules: Γ ` M : ∀α.σ Inst Γ ` Mτ : σ[α := τ]
Γ ` M : τ α 6∈ Γ Gen Γ ` Λα.M : ∀α.τ About Polymorphic Lambda Calculus
I Can express the parametric identity function: ` Λα.λx : α.x : ∀α.α → α
I Second order logic
I Many names, among other: System F
I Type inference not computable
I Impredicative — ML/Haskell predicative Types depending on types Syntax: a, b, A, B, F, T ::= x | ∗ | | T T | λx : T .T | T → T Rules (s ranges over {∗, }):
Axiom ` ∗ : Γ ` A : s Γ ` B : s Intro → Γ ` A → B : s Γ ` A : s x 6∈ Γ Var Γ, x : A ` x : A Γ ` F : A → B Γ ` a : A App Γ ` F a : B Γ ` a : A Γ ` B : s x 6∈ Γ Weak Γ, x : B ` a : A Γ, x : A ` b : B Γ ` A → B : s Abs Γ ` λx : A.b : A → B 0 0 Γ ` A : B Γ ` B : s B =β B Conv Γ ` A : B0 About Type Operators
I Makes type operators a part of the object language
I Type Operators + Polymorphism = Higher-Order logic
I Not that much explored Types depending on terms Syntax: a, b, A, B, F, T ::= x | ∗ | | T T | λx : T .T | Πx : T .T Rules (s ranges over {∗, }):
Axiom ` ∗ : Γ ` A : ∗ Γ, x : A ` B : s Intro → Γ ` A : s x 6∈ Γ Γ ` (Πx : A.B): s Var Γ, x : A ` x : A Γ ` F :Πx : A.B Γ ` a : A App Γ ` F a : B[x := a] Γ ` a : A Γ ` B : s x 6∈ Γ Weak Γ, x : B ` a : A Γ, x : A ` b : B Γ ` Πx : A.B : s Abs Γ ` λx : A.b :Πx : A.B 0 0 Γ ` A : B Γ ` B : s B =β B Conv Γ ` A : B0 Proposition as Types
I Let P be a predicate on the set S
I P : S → ∗ is the type of the predicate I P o the claim that P holds for o from S
I Universal quantifiaction. ∀x ∈ S, ϕ coded as Πx : S, ϕ
I A proposition M : ∗ holds if M is inhabited
I Example: (∀x, y ∈ S. P xy) → ∀x ∈ S.P xx
I Translated to: (Πx : S, Πy : S, P xy) → Πx : S, P xx
I Inhabited by: λH : (Πx : S, Πy : S, P xy).λx : S.Hxx
I Without types: λHx.Hxx Sigma types
I A pair ha, bi is of the type Σx : A, B if:
I Γ ` a : A, and
I Γ, x : A ` b : B
I Called a dependent sum Combining extensions
I Poly + Type operators, second order logic
I Dependent types, first order predicate logic
I Dependent types + poly, second order predicate logic
I Dependent types + poly + type ops, higher order predicate logic What else
I Extend with: induction or co-induction definitions
I Sub typing
I Pure Type Systems