pure type systems without explicit contexts
play

Pure Type Systems without Explicit Contexts Robbert Krebbers Joint - PowerPoint PPT Presentation

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


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

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

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

  4. 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?

  5. 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 ))

  6. Approach ◮ We simulate the sea of free variables ◮ Infinitely many variables x A for each type A

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

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

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

  10. Approach Two kinds of variables: free and bound variables Curry λ x . f x λ x A . f A → A x A Church

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

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

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

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

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

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

  17. Labelling terms ◮ Type labels should be considered as strings ◮ Labels are insensitive to α and β -conversion

  18. 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 ∗ � = β

  19. 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 : ∗ . ˙

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

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

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

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

  24. 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 ]

  25. 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 )

  26. 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 )

  27. 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 ) =

  28. 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 ) =

  29. The correspondence theorems ← → derivable PTS judgment derivable Γ ∞ judgment

  30. The correspondence theorems ← → derivable PTS judgment derivable Γ ∞ judgment ( α -)rename Γ ⊢ M : A to Γ ′ ⊢ M ′ : A ′ such that Γ ′ ⊂ Γ ∞ and M ′ : A ′ Γ ⊢ M : A = ⇒

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

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

  33. Type annotated judgments Lemma Every judgment Γ ⊢ M : A in a PTS can be ( α -)renamed to a type annotated judgment Γ ′ ⊢ M ′ : A ′ .

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