Barendregt's Lambda Cube
Total Page:16
File Type:pdf, Size:1020Kb
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 j (λx : τ:N) j (MN) τ; σ ::= α j τ ! σ 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 j (λx : τ:N) j (MN) j Λα:M τ; σ ::= α j τ ! σ j 8α.τ Two new rules: Γ ` M : 8α.σ Inst Γ ` Mτ : σ[α := τ] Γ ` M : τ α 62 Γ Gen Γ ` Λα:M : 8α.τ About Polymorphic Lambda Calculus I Can express the parametric identity function: ` Λα.λx : α:x : 8α.α ! α 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 j ∗ j j T T j λx : T :T j T ! T Rules (s ranges over {∗; g): Axiom ` ∗ : Γ ` A : s Γ ` B : s Intro ! Γ ` A ! B : s Γ ` A : s x 62 Γ Var Γ; x : A ` x : A Γ ` F : A ! B Γ ` a : A App Γ ` F a : B Γ ` a : A Γ ` B : s x 62 Γ 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 j ∗ j j T T j λx : T :T j Πx : T :T Rules (s ranges over {∗; g): Axiom ` ∗ : Γ ` A : ∗ Γ; x : A ` B : s Intro ! Γ ` A : s x 62 Γ Γ ` (Π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 62 Γ 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. 8x 2 S; ' coded as Πx : S; ' I A proposition M : ∗ holds if M is inhabited I Example: (8x; y 2 S: P xy) ! 8x 2 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.