Pure Type Systems without Explicit Contexts Robbert Krebbers Joint work with Herman Geuvers, James McKinna and Freek Wiedijk Institute for Computing and Information Science Faculty of Science, Radboud University Nijmegen and Faculty of Mathematics and Computer Science Eindhoven University of Technology The Netherlands July 14, 2010
The main traditions of type theory ◮ Descendants of simple type theory ◮ Church’s original system ◮ Polymorphic λ -calculus, System F ◮ HOL’s type theory ◮ . . . Traditionally presented without contexts ◮ Dependent type theories (de Bruijn, Martin-L¨ of) ◮ Automath ◮ Berardi/Terlouw framework of Pure Type Systems ◮ Coq’s type theory ◮ . . . Traditionally presented with contexts
Problem Traditional presentation of dependent type theory ◮ Terms considered with respect to an explicit context Γ Γ ⊢ M : A ◮ A bound variable is bound locally by a λ or Π ◮ A free variable is bound globally by Γ
Problem Traditional presentation of dependent type theory ◮ Terms considered with respect to an explicit context Γ Γ ⊢ M : A ◮ A bound variable is bound locally by a λ or Π ◮ A free variable is bound globally by Γ Can we present dependent type theory without contexts?
Motivation First-order logic and contexts Predicate logic Type theory A ⊢ P ( x ) H : A , x : D ⊢ M 3 : P ( x ) A ⊢ ∀ x . P ( x ) H : A ⊢ M 2 : Π x : D . P ( x ) ⊢ A → ∀ x . P ( x ) ⊢ M 1 : A → Π x : D . P ( x ) ‘sea’ of free variables context of ‘free’ variables What about? ( ∀ x . P ( x )) → ( ∃ x . P ( x ))
Approach ◮ We simulate the sea of free variables ◮ Infinitely many variables x A for each type A
Approach ◮ We simulate the sea of free variables ◮ Infinitely many variables x A for each type A ◮ This gives an “infinite context” called Γ ∞ ◮ For example s N ∗ → N ∗
Approach ◮ We simulate the sea of free variables ◮ Infinitely many variables x A for each type A ◮ This gives an “infinite context” called Γ ∞ ◮ For example s N ∗ → N ∗ ◮ Variable carries history of how it comes to be well-typed
Approach ◮ We simulate the sea of free variables ◮ Infinitely many variables x A for each type A ◮ This gives an “infinite context” called Γ ∞ ◮ For example s N ∗ → N ∗ ◮ Variable carries history of how it comes to be well-typed ◮ Judgments of the shape A : B ◮ Should be imagined as Γ ∞ ⊢ A : B
Approach Two kinds of variables: free and bound variables Curry λ x . f x λ x A . f A → A x A Church
Approach Two kinds of variables: free and bound variables Curry λ x . f x λ x A . f A → A x A Church Barendregt et al. λ x : A . f x
Approach Two kinds of variables: free and bound variables Curry λ x . f x λ x A . f A → A x A Church Barendregt et al. λ x : A . f x x : A ∗ . f A ∗ → A ∗ ˙ Γ ∞ -style λ ˙ x
Approach Two kinds of variables: free and bound variables Curry λ x . f x λ x A . f A → A x A Church Barendregt et al. λ x : A . f x x : A ∗ . f A ∗ → A ∗ ˙ Γ ∞ -style λ ˙ x That is ◮ Γ ∞ extends Church’s approach to dependent types ◮ But Γ ∞ avoids the need to consider substitution in labels of bound variables
Approach Two kinds of variables: free and bound variables Curry λ x . f x λ x A . f A → A x A Church Barendregt et al. λ x : A . f x x : A ∗ . f A ∗ → A ∗ ˙ Γ ∞ -style λ ˙ x That is ◮ Γ ∞ extends Church’s approach to dependent types ◮ But Γ ∞ avoids the need to consider substitution in labels of bound variables ( λ x A λ P A →∗ λ y P A →∗ x A . . . ) a A → β λ P A →∗ λ y P A →∗ a A . . .
PTS terms ◮ The set T of pseudo-terms is defined as T ::= s | V | Π V : T . T | λ V : T . T | T T ◮ For ordinary PTSs the choice of V does not matter
PTS terms ◮ The set T of pseudo-terms is defined as T ::= s | V | Π V : T . T | λ V : T . T | T T ◮ For ordinary PTSs the choice of V does not matter ◮ For Γ ∞ we have two kinds of variables ˙ X | X T V ::= X ::= x | y | z | . . . | x 0 | x 1 | x 2 | . . . ◮ Variables x A are intended to be free ◮ Variables ˙ x are intended to be bound
Labelling terms ◮ Type labels should be considered as strings ◮ Labels are insensitive to α and β -conversion
Labelling terms ◮ Type labels should be considered as strings ◮ Labels are insensitive to α and β -conversion ◮ That is to say x A [ A := B ] �≡ x B and ( λ ˙ A : ∗ . ˙ A ) B ∗ B ∗ = β x ( λ ˙ A : ∗ . ˙ A ) B ∗ x B ∗ � = β
Labelling terms ◮ Type labels should be considered as strings ◮ Labels are insensitive to α and β -conversion ◮ That is to say x A [ A := B ] �≡ x B and ( λ ˙ A : ∗ . ˙ A ) B ∗ B ∗ = β x ( λ ˙ A : ∗ . ˙ A ) B ∗ x B ∗ � = β ◮ But we do have (by type conversion) A ) B ∗ : B ∗ x ( λ ˙ A : ∗ . ˙
Typing rules Two of the six rules PTS rules Γ ∞ rules A : s Γ ⊢ A : s x / ∈ Γ x A : A Γ , x : A ⊢ x : A Γ ⊢ A : s 1 Γ , x : A ⊢ B : s 2 A : s 1 B : s 2 x : A . B [ y A := ˙ Γ ⊢ Π x : A . B : s 3 Π˙ x ] : s 3 Remark: ◮ Binding a variable in Γ ∞ replace a free variable by a bound variable ◮ No weakening rule
But this does not correspond to PTSs! Now we would have x A ∗ : A ∗ A : ∗ . x A ∗ : Π ˙ λ ˙ A : ∗ . ˙ A but, in ordinary PTS-style A : ∗ , x : A ⊢ x : A x : A ⊢ λ A : ∗ . x : Π A : ∗ . A which is nonsense because A ∗ occurs free in the label of x .
Taking the type annotations seriously It is not enough to consider the free variables in a type label, but the hereditarily free variables of a type label. A : s 1 B : s 2 Incorrect x : A . B [ y A := ˙ Π˙ x ] : s 3
Taking the type annotations seriously It is not enough to consider the free variables in a type label, but the hereditarily free variables of a type label. A : s 1 B : s 2 y A / ∈ hfvT ( B ) x : A . B [ y A := ˙ Π˙ x ] : s 3
Taking the type annotations seriously It is not enough to consider the free variables in a type label, but the hereditarily free variables of a type label. A : s 1 B : s 2 y A / ∈ hfvT ( B ) x : A . B [ y A := ˙ Π˙ x ] : s 3 x : A . B [ y A := ˙ M : B Π˙ x ] : s y A / ∈ hfvT ( M ) ∪ hfvT ( B ) x : A . M [ y A := ˙ x : A . B [ y A := ˙ λ ˙ x ] : Π˙ x ]
Taking the type annotations seriously Hereditarily free type-variables are defined as hfvT ( s ) = hfvT (˙ x ) = ∅ hfvT ( F ) ∪ hfvT ( N ) hfvT ( F N ) = hfvT ( λ ˙ x : A . N ) = hfvT (Π˙ x : A . N ) = hfvT ( A ) ∪ hfvT ( N )
Taking the type annotations seriously Hereditarily free type-variables are defined as hfvT ( s ) = hfvT (˙ x ) = ∅ hfvT ( F ) ∪ hfvT ( N ) hfvT ( F N ) = hfvT ( λ ˙ x : A . N ) = hfvT (Π˙ x : A . N ) = hfvT ( A ) ∪ hfvT ( N ) hfvT ( x A ) = hfv ( A )
Taking the type annotations seriously Hereditarily free type-variables are defined as hfvT ( s ) = hfvT (˙ x ) = ∅ hfvT ( F ) ∪ hfvT ( N ) hfvT ( F N ) = hfvT ( λ ˙ x : A . N ) = hfvT (Π˙ x : A . N ) = hfvT ( A ) ∪ hfvT ( N ) hfvT ( x A ) = hfv ( A ) Where the hereditarily free variables are defined as ∅ hfv ( s ) = hfv (˙ x ) = hfv ( F N ) = hfv ( F ) ∪ hfv ( N ) hfv ( A ) ∪ hfv ( N ) hfv ( λ ˙ x : A . N ) = hfv (Π˙ x : A . N ) =
Taking the type annotations seriously Hereditarily free type-variables are defined as hfvT ( s ) = hfvT (˙ x ) = ∅ hfvT ( F ) ∪ hfvT ( N ) hfvT ( F N ) = hfvT ( λ ˙ x : A . N ) = hfvT (Π˙ x : A . N ) = hfvT ( A ) ∪ hfvT ( N ) hfvT ( x A ) = hfv ( A ) Where the hereditarily free variables are defined as ∅ hfv ( s ) = hfv (˙ x ) = hfv ( F N ) = hfv ( F ) ∪ hfv ( N ) hfv ( A ) ∪ hfv ( N ) hfv ( λ ˙ x : A . N ) = hfv (Π˙ x : A . N ) = hfv ( x A ) { x A } ∪ hfv ( A ) =
The correspondence theorems ← → derivable PTS judgment derivable Γ ∞ judgment
The correspondence theorems ← → derivable PTS judgment derivable Γ ∞ judgment ( α -)rename Γ ⊢ M : A to Γ ′ ⊢ M ′ : A ′ such that Γ ′ ⊂ Γ ∞ and M ′ : A ′ Γ ⊢ M : A = ⇒
The correspondence theorems ← → derivable PTS judgment derivable Γ ∞ judgment ( α -)rename Γ ⊢ M : A to Γ ′ ⊢ M ′ : A ′ such that Γ ′ ⊂ Γ ∞ and M ′ : A ′ Γ ⊢ M : A = ⇒ for M : A generate a context Γ( M , A ) such that Γ( M , A ) ⊢ M : A ⇐ = M : A
Type annotated judgments A type annotated judgment is a judgment of the shape x 1 B 1 : B 1 , . . . , x nB n : B n ⊢ M : A where 1. all free variables in M and A are of the form x i B i 2. all bound variables in B i , M and A are of the form ˙ x
Type annotated judgments Lemma Every judgment Γ ⊢ M : A in a PTS can be ( α -)renamed to a type annotated judgment Γ ′ ⊢ M ′ : A ′ .
Type annotated judgments Lemma Every judgment Γ ⊢ M : A in a PTS can be ( α -)renamed to a type annotated judgment Γ ′ ⊢ M ′ : A ′ . For example consider A : ∗ , a : A ⊢ ( λ x : A . x ) a : A This judgment can be ( α -)renamed to A ∗ : ∗ , a A ∗ : A ∗ ⊢ ( λ ˙ x : A ∗ . ˙ x ) a A ∗
Recommend
More recommend