
Introduction to Dependent Type Theory (3/4) Matthieu Sozeau, Inria Paris & IRIF, University Paris 7 TYPES 2018 August 9th 2018 Ohrid, Macedonia Lectures 1 Typed Lambda Calculi 2 The Curry-Howard Correspondence 3 Pure Type Systems 4 Dependent Type Theory Matthieu Sozeau - Introduction to Dependent Type Theory (3/4) 2 Pure Type Systems 1 Pure type systems 2 PTS metatheory Canonicity 3 Beyond PTS: Extending the Calculus of Constructions Predicative types and Prop Dependent sums Matthieu Sozeau - Introduction to Dependent Type Theory (3/4) 3 A unifiorm framework for typed lambda-calculi We’ve seen three calculi: I λ!: simply-typed λ-calculus, only one binder: λ for terms depending on terms (i.e. functions). I System F: extended with a new binder Λ for type variables. I System F !: extended with a new binder λ for type variables (of arbitrary kind) at the type level. We’re missing term quantification in types, i.e. dependent types! Pure Type Systems aim to give abstract treatment of these languages, accomodating all these binding choices. Matthieu Sozeau - Introduction to Dependent Type Theory (3/4) 4 The λ-cube Axis: I x: Types depend on values (dependent types): Πx : B:x = x I y: Values depend on types (polymorphism) (λ2 is System F): Λα(x : α):x :Πα.α ! α I z: Types depend on types (type operators) (λω is F !): F : ∗ ! ∗; α β : ∗; f : α ! β ` map f : F α ! F β Matthieu Sozeau - Introduction to Dependent Type Theory (3/4) 5 The λ-cube I The Calculus of Constructions (λC) combines all three features. I It only has one λ-abstraction and one Π quantification constructs. I Formalized as a particular Pure Type System. Matthieu Sozeau - Introduction to Dependent Type Theory (3/4) 6 PTS definition Pure Type Systems are parameterized by: I a set of sorts S (similar to F !’s kinds) I axioms A ⊆ S × S giving the types of sorts. I rules A ⊆ S × S × S giving the types of products. For now, set S = {∗; g and A = f(∗; )g. For the sake of example we also assume nat : ∗, 0 : nat, S : nat ! nat and its associated operations. Terms and types: T; U; t; u ::= x 2 V variable s 2 S sort λx : T:u abstraction t u application Πx : T:U product / pi-type Contexts: ordered sequences of pairs (x : T ) with distinct x. Matthieu Sozeau - Introduction to Dependent Type Theory (3/4) 7 PTS typing definition Start Weakening Γ ` T : s x 62 Γ Γ ` t : T Γ ` U : s x 62 Γ Γ; x : T ` x : T Γ; x : U ` t : T Ax Product 0 (s; s ) 2 A Γ ` T : s1 Γ; x : T ` U : s2 (s1; s2; s3) 2 R 0 ` s : s Γ ` Πx : T:U : s3 Abs Γ; x : U ` t : V Γ ` Πx : U:V : s Γ ` (λx : U:t):Πx : U:V App Γ ` t :Πx : U:V Γ ` u : U Γ ` t u : V [x := u] Matthieu Sozeau - Introduction to Dependent Type Theory (3/4) 8 PTS typing definition Conv Γ ` t : T Γ ` U : s T ≡β U Γ ` t : U Matthieu Sozeau - Introduction to Dependent Type Theory (3/4) 9 Allowed products Assume R = f(∗; ∗; ∗)g, then the product rule becomes: Product Γ ` T : ∗ Γ; x : T ` U : ∗ Γ ` Πx : T:U : ∗ I This corresponds to simply typed lambda-calculus. I The only inhabitants of ∗ are formed from nat and Πx : T:U. I The dependent product degenerates to the non-dependent T ! U as U can not depend on x. Matthieu Sozeau - Introduction to Dependent Type Theory (3/4) 10 Example PTSs I λ!: R = f(∗; ∗; ∗)g I λ2, System F: R = f(∗; ∗; ∗); (; ∗; ∗)g One can quantify on a type to build a term. I λP : R = f(∗; ∗; ∗); (∗; ; )g One can quantify on a term to build a type. Type level quantification on terms. I λω: R = f(∗; ∗; ∗); (; ; )g One can quantify on a type to build a type: type level operators. ! I λω, System F : R = f(∗; ∗; ∗); (; ; ); (; ∗; ∗)g Mixes λω with λ2. I λC: R = f(∗; ∗; ∗); (; ; ); (; ∗; ∗); (∗; ; )g All of the above. Matthieu Sozeau - Introduction to Dependent Type Theory (3/4) 11 Dependent types and conversion In λP (and λC), one can quantify on terms in types. (∗; ; ) 2 R so the product rule allows: Product Γ ` T : ∗ Γ; x : T ` U : Γ ` Πx : T:U : Assume an equality predicate eq : nat ! nat ! . We can form the dependent type: Product Γ ` nat : ∗ Γ; x : nat ` eq x x : Γ ` Πx : nat:eq x x : Matthieu Sozeau - Introduction to Dependent Type Theory (3/4) 12 Dependent types and conversion Assume a proof eqrefl :Πx : nat:eq x x. The following type is also valid in λC: ` Πx : nat:eq x (0 + x) To give a witness we have to find: x : nat ` ?: eq x (0 + x) We can derive this using the conversion rule assuming 0 + x ≡β x: x : nat ` eqrefl x : eq x x x : nat ` eq x (0 + x): ∗ eq x x ≡β eq x (0 + x) x : nat ` eqrefl x : eq x (0 + x) Matthieu Sozeau - Introduction to Dependent Type Theory (3/4) 13 Type dependency I As a logic, λP corresponds to: many-sorted first-order intuitionistic logic. I We have the universal quantifier for terms: 8x 2 N:P ::= Πx : nat:P 8-intro 8-elim Γ ` P x 62 FV(Γ) Γ ` 8x 2 τ:P ` 8x 2 τ:P Γ ` P [t] Product Application Γ ` T : ∗ Γ; x : T ` P : Γ ` f :Πx : T:P Γ ` t : T Γ ` Πx : T:P : Γ ` f t : P [x := t] I Systems based on this were proposed by de Bruijn, Harper I At the basis of AUTOMATH, LF and λΠ-modulo (Dedukti) Matthieu Sozeau - Introduction to Dependent Type Theory (3/4) 14 Pure Type Systems 1 Pure type systems 2 PTS metatheory Canonicity 3 Beyond PTS: Extending the Calculus of Constructions Predicative types and Prop Dependent sums Matthieu Sozeau - Introduction to Dependent Type Theory (3/4) 15 Properties of interest of PTSs I Church-Rosser / Confluence I Subject Reduction / Type preservation I Strong Normalization / (relative) Consistency We now assume an arbitrary PTS (S; A; R). Matthieu Sozeau - Introduction to Dependent Type Theory (3/4) 16 Church-Rosser Definition (Church-Rosser property) ∗ ∗ ∗ If t !β u and t !β v then there exists w s.t. u !β w and ∗ v !β w. Holds on well-typed terms for all functional, strongly-normalizing PTSs (Geuvers’92) Definition (Functional PTS) A PTS (S; A; R) is functional when A is a function from S to itself and R is a function from S × S to S. All the example PTSs we gave are functional. Matthieu Sozeau - Introduction to Dependent Type Theory (3/4) 17 Free variables Definition (Valid context) I is valid I For all Γ, T, if Γ is valid and there exists s s.t. Γ ` T : s then Γ; x : T is valid. Lemma (Context validity) If Γ ` t : T , then Γ is valid. Lemma (Free variables) −−−! Assume Γ ≡ xi : Ti ` t : T , then: −! I Variables xi are mutually distinct −! I FV(t); FV(T ) ⊆ fxi g I FV(Ti) ⊆ fx1; : : : xi−1g for i = 1; : : : n Matthieu Sozeau - Introduction to Dependent Type Theory (3/4) 18 Start Lemma (Start) Assume Γ a valid context then: I If (s; s0) 2 A then Γ ` s : s0 I If x : T 2 Γ then Γ ` x : T Proof sketch. Using the Ax, Start and Weakening rules and context validity. Matthieu Sozeau - Introduction to Dependent Type Theory (3/4) 19 Weakening Lemma (Weakening) If Γ; ∆ are valid contexts such that Γ ⊆ ∆ then: Γ ` t : T implies ∆ ` t : T Proof sketch. By induction on the typing derivation, using weakening. Matthieu Sozeau - Introduction to Dependent Type Theory (3/4) 20 Substitution Definition (Context Substitution) If Γ; ∆ are valid contexts then a substitution σ :Γ ` ∆ is defined inductively as: σ :Γ ` ∆ Γ ` t : T [σ] :Γ ` σ; x := t :Γ ` ∆; x : T It associates to each variable of ∆ a term of Γ. Lemma (Substitution) If δ :Γ ` ∆ and ∆ ` t : T then Γ ` t[σ]: T [σ] Matthieu Sozeau - Introduction to Dependent Type Theory (3/4) 21 Thinning Lemma (Thinning) If Γ; x : T; ∆ ` t : T and x 62 FV(∆) [FV(t) [FV(T ) then Γ; ∆ ` t : T . I This lemma is not necessary in general but allows removing useless abstractions in terms. I Note that it cannot be derived from substitution if T is not inhabited. I It is not valid in extentional type theories where dependencies on hypothesis can be implicit in the term and type. Matthieu Sozeau - Introduction to Dependent Type Theory (3/4) 22 Generation Lemma (Generation) 0 0 0 Γ ` s : T ) 9 s :T ≡β s ^ (s; s ) 2 A 0 0 0 0 Γ ` x : T ) 9 T s: T ≡β T ^ Γ ` T : s ^ (x : T ) 2 Γ Γ ` (Πx : U:V ): T ) 9(s1; s2; s3) 2 R:T ≡β s3 ^ Γ ` U : s1 ^ Γ; x : U ` V : s2 0 0 Γ ` (λx : U:t): T ) 9 T s: T ≡β (Πx : U:T ) Γ ` Πx : U:T 0 : s ^ Γ; x : U ` t : T 0 Γ ` t u : T ) 9 U V: T ≡β V [x := u] Γ ` t :Πx : U:V ^ Γ ` u : U Proof. By case analysis of the last rule of the derivation. Matthieu Sozeau - Introduction to Dependent Type Theory (3/4) 23 Validity In all the cases we consider we can prove: Lemma (Validity) If Γ ` t : T then T = or 9 s:Γ ` T : s.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages50 Page
-
File Size-