multi level contextual type theory
play

Multi-level Contextual Type Theory Mathieu Boespflug Brigitte - PowerPoint PPT Presentation

Multi-level Contextual Type Theory Mathieu Boespflug Brigitte Pientka McGill University 26 August 2011 1 / 25 Motivating example Theory Conclusion 2 / 25 x . ( A [ x ]) B 3 / 25 x . ( A [ x ]) B x . ( A [ x ] B )


  1. Multi-level Contextual Type Theory Mathieu Boespflug Brigitte Pientka McGill University 26 August 2011 1 / 25

  2. Motivating example Theory Conclusion 2 / 25

  3. ∀ x . ( A [ x ]) ∧ B 3 / 25

  4. ∀ x . ( A [ x ]) ∧ B ⇓ ∀ x . ( A [ x ] ∧ B ) 3 / 25

  5. ∀ A . ∀ B . ∀ x . ( A [ x ]) ∧ B ⇓ ∀ A . ∀ B . ∀ x . ( A [ x ] ∧ B ) 3 / 25

  6. ∀ A . ∀ B . ∀ x . ( A [ x ]) ∧ B ⇓ ←− meta-level implication ∀ A . ∀ B . ∀ x . ( A [ x ] ∧ B ) Object language: first order predicate logic. Meta- language: LF 3 / 25

  7. Embedding FOL in LF o : type . i : type . all : (i → o) → o. and : o → o → o. nd : o → type . allI : ({x:i} nd (A x)) → nd (all ( λ x. A x)). andI : nd A → nd B → nd (and A B). Object language: first order predicate logic. Meta- language: LF 4 / 25

  8. Embedding FOL in LF o : type . i : type . all : (i → o) → o. and : o → o → o. nd : o → type . allI : {A:i → o} ({x:i} nd (A x)) → nd (all ( λ x. A x)). andI : {A:o} {B:o} nd A → nd B → nd (and A B). Object language: first order predicate logic. Meta- language: LF 5 / 25

  9. andI (allI ( λ x. D1 x)) D2 allI ( λ x. andI (D1 x) D2) Object language: first order predicate logic. Meta- language: ?? 6 / 25

  10. andI _ _ (allI _ ( λ x. D1 x)) D2 allI _ ( λ x. andI _ _ (D1 x) D2) Object language: first order predicate logic. Meta- language: ?? 7 / 25

  11. andI (all ( λ x. A x)) B (allI ( λ x. A x) ( λ x. D1 x)) D2 allI ( λ x. and (A x) B) ( λ x. andI (A x) B (D1 x) D2) Object language: first order predicate logic. Meta- language: ?? 8 / 25

  12. rec proof : (nd (and (all ( λ x. A x)) B))[] → (nd (all ( λ x. and (A x) B)))[] = . . . Object language: first order predicate logic. Meta- language: Beluga 9 / 25

  13. rec proof : {A::(i → o)[]} {B::o[]} (nd (and (all ( λ x. A x)) B))[] → (nd (all ( λ x. and (A x) B)))[] = . . . Object language: first order predicate logic. Meta- language: Beluga 10 / 25

  14. rec proof : {A::(i → o)[]} {B::o[]} (nd (and (all ( λ x. A x)) B))[] → (nd (all ( λ x. and (A x) B)))[] = λ A ⇒ λ B ⇒ fn d ⇒ case d of [] andI (allI D1) D2 ⇒ [] allI ( λ x. andI (D1 x) D2); Object language: first order predicate logic. Meta- language: Beluga 11 / 25

  15. rec proof : {A::(i → o)[]} {B::o[]} (nd (and (all ( λ x. A x)) B))[] → (nd (all ( λ x. and (A x) B)))[] = λ A ⇒ λ B ⇒ fn d ⇒ case d of [] andI _ _ (allI _ D1) D2 ⇒ [] allI _ ( λ x. andI _ _ (D1 x) D2); Object language: first order predicate logic. Meta- language: Beluga 12 / 25

  16. Inventory stand for depend on variables terms meta-variables meta-terms variables meta 2 -variables meta 2 -terms meta-variables, variables 13 / 25

  17. Inventory stand for depend on variables terms meta-variables meta-terms variables meta 2 -variables meta 2 -terms meta-variables, variables . . . . . . . . . meta n -variables meta- n -terms meta- n − 1 -variables, ... 13 / 25

  18. Motivating example Theory Conclusion 14 / 25

  19. λ x . λ y .andI ( D 1 x ) D 2 15 / 25

  20. λ x . λ y .andI ( D 1 x ) D 2 : Π x : ι . Π y : ι . o What can D 1 be instantiated with? ◮ an open term where x can appear free... ◮ ... of type Π y : ι . o . 15 / 25

  21. Contextual Modal Type Theory (Nanevski et al, 2008) ∆( X ) = A [Γ] ∆ ; Ψ ⊢ X : A [Γ] ◮ Well-typed meta-terms do not go wrong on instantiation. ◮ Invariant 1: Meta-variables always associated with “stuck” substitutions, with dom ( ρ ) = dom (Γ) . 16 / 25

  22. Contextual Modal Type Theory (Nanevski et al, 2008) ∆( X ) = A [Γ] ∆ ; Ψ ⊢ ρ : Γ ∆ ; Ψ ⊢ X [ ρ ] : [ ρ ] A ◮ Well-typed meta-terms do not go wrong on instantiation. ◮ Invariant 1: Meta-variables always associated with “stuck” substitutions, with dom ( ρ ) = dom (Γ) . 16 / 25

  23. Contextual Modal Type Theory (Nanevski et al, 2008) ∆( X ) = A [Γ] ∆ ; Ψ ⊢ ρ : Γ ∆ ; Ψ ⊢ X [ ρ ] : [ ρ ] A Ψ( x ) = A ∆ ; Ψ ⊢ x : A ◮ Well-typed meta-terms do not go wrong on instantiation. ◮ Invariant 1: Meta-variables always associated with “stuck” substitutions, with dom ( ρ ) = dom (Γ) . 16 / 25

  24. CMTT... to ω ... ∆ ; Ψ , x : A ⊢ M : B ∆ ; Ψ ⊢ λ x : A . M : Π x : A . B ∆ , X : A [Φ] ; Ψ ⊢ M : B ∆ ; Ψ ⊢ λ X : A [Φ] . M : Π X : A [Φ] . B 17 / 25

  25. CMTT... to ω ... ∆ k ; ∆ k − 1 , x 0 : A ; ··· ⊢ M : B  ∆ k ; ∆ k − 1 ; ··· ⊢ λ x 0 : A . M : Π x 0 : A . B           ∆ k ; ∆ k − 1 ; ··· ; ∆ 1 , x 1 : A [Φ] ; ∆ 0 ⊢ M : B     ∆ k ; ∆ k − 1 ; ··· ; ∆ 1 ; ∆ 0 ⊢ λ x 1 : A [Φ] . M : Π x 1 : A [Φ] . B       .   .  .          ∆ k ; ∆ k − 1 ; ··· ; x k : A [Φ] ; ··· ⊢ M : B     ∆ k ; ∆ k − 1 ; ··· ⊢ λ x k : A [Φ] . M : Π x k : A [Φ] . B 17 / 25

  26. ... to MLCMTT + x n : A [Φ n ] ⊢ M : B Ψ + Ψ ⊢ λ x n : A [Φ n ] . M : Π x n : A [Φ n ] . B 18 / 25

  27. ... to MLCMTT + Φ n ⊢ N : A Ψ ⊢ R : Π x n : A [Φ n ] . B Ψ | n + Ψ ⊢ R (ˆ Φ n . N ) : [ˆ Φ n . N / x n ] B ◮ From a schema of contexts lists to a context schema. ◮ From a schema of rules to a single rule. 19 / 25

  28. MLCMTT (typing rules for terms) Ψ( x n ) = A [Φ n ] Ψ ⊢ σ ⇐ Φ n Ψ ⊢ x n [ σ ] ⇒ [ σ ] A + Φ n ⊢ N : A Ψ ⊢ R : Π x n : A [Φ n ] . B Ψ | n + Ψ ⊢ R (ˆ Φ n . N ) : [ˆ Φ n . N / x n ] B + x n : A [Φ n ] ⊢ M : B Ψ + Ψ ⊢ λ x n : A [Φ n ] . M : Π x n : A [Φ n ] . B ◮ Single syntactic category of level-indexed variables. ◮ Can abstract at any level at any time. 20 / 25

  29. Context insertion x 3 : ι , w 2 : ι , x 2 : ι + + y 5 : ι , v 0 : ι , w 0 : ι = y 5 : ι , x 3 : ι , w 2 : ι , x 2 : ι , v 0 : ι , w 0 : ι ◮ Invariant 2: context assumptions always in decreasing order of level. 21 / 25

  30. Context insertion x 3 : ι , w 2 : ι , x 2 : ι + + y 5 : ι , v 0 : ι , w 0 : ι = y 5 : ι , x 3 : ι , w 2 : ι , x 2 : ι , v 0 : ι , w 0 : ι ◮ Invariant 2: context assumptions always in decreasing order of level. ◮ Chopping context at level n stays easy. ◮ Argument that meta n -variables don’t depend on meta n − m -variables trivial. 21 / 25

  31. Example revisited andI _ _ (allI _ ( λ x 0 . (x 0 .D1 1 )x 0 )) .D2 1 allI _ ( λ x 0 . andI _ _ ((x 0 .D1 1 ) x 0 ) .D2 1 ) where M 2 , N 2 , L 2 o [ A 1 : o [] , B 1 : o [] , D 1 1 :nd A 1 [ x 0 : ι ] , D 2 1 :nd B 1 []] : P 2 , Q 2 , R 2 o [ A 1 : o [] , B 1 : o [] , D 1 1 :nd A 1 [ x 0 : ι ] , D 2 1 :nd B 1 [] , x 0 : ι ] : 22 / 25

  32. Example revisited andI .M 2 .N 2 (allI .L 2 ( λ x 0 . (x 0 .D1 1 )x 0 )) D2 1 allI .P 2 ( λ x 0 . andI .Q 2 .R 2 ((x 0 .D1 1 ) x 0 ) D2 1 ) where M 2 , N 2 , L 2 o [ A 1 : o [] , B 1 : o [] , D 1 1 :nd A 1 [ x 0 : ι ] , D 2 1 :nd B 1 []] : P 2 , Q 2 , R 2 o [ A 1 : o [] , B 1 : o [] , D 1 1 :nd A 1 [ x 0 : ι ] , D 2 1 :nd B 1 [] , x 0 : ι ] : 22 / 25

  33. Results ◮ Usual structural properties. ◮ Substitution property. −→ “substitution does not go wrong.” ◮ Termination of heredetary substitutions. ◮ Decidability of type checking. 23 / 25

  34. Related Work ◮ “A logical basis for explicit substitutions” (Pfenning, 2007) −→ Results only worked out for k = 2, only simple types. ◮ Multi-level logics of contexts (Giunchiglia, Serafini, 1993-1994) ◮ Multi-level meta-variables (Sato et al, 2003) −→ Textual substitution, no confluence ◮ Lambda Context Calculus (Gabbay and Lengrand, 2007) −→ Nominal approach to meta-variabes ◮ “Open proofs and open types” (Geuvers and Gogjov, 2002) −→ Reduction and instantiation do not commute. ◮ Staged computation, code generation (Davies and Pfenning, 2001) (Glück and Jorgensen, 1995-1996) (Yuse and Yigarashi, 2006). 24 / 25

  35. Conclusion What we have: ◮ Uniform language for representing normal meta n -terms. 25 / 25

  36. Conclusion What we have: ◮ Uniform language for representing normal meta n -terms. Where we are going: ◮ Implement it. ◮ Reasoning about programs conveniently and efficiently. ◮ Reasoning about Beluga in Beluga. 25 / 25

Recommend


More recommend