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

multi level contextual type theory
SMART_READER_LITE
LIVE PREVIEW

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 )


slide-1
SLIDE 1

Multi-level Contextual Type Theory

Mathieu Boespflug Brigitte Pientka

McGill University

26 August 2011

1 / 25

slide-2
SLIDE 2

Motivating example Theory Conclusion

2 / 25

slide-3
SLIDE 3

∀x. (A[x]) ∧ B

3 / 25

slide-4
SLIDE 4

∀x. (A[x]) ∧ B ⇓ ∀x. (A[x] ∧ B)

3 / 25

slide-5
SLIDE 5

∀A.∀B. ∀x. (A[x]) ∧ B ⇓ ∀A.∀B. ∀x. (A[x] ∧ B)

3 / 25

slide-6
SLIDE 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

slide-7
SLIDE 7

Embedding FOL in LF

  • : 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

slide-8
SLIDE 8

Embedding FOL in LF

  • : 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

slide-9
SLIDE 9

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

6 / 25

slide-10
SLIDE 10

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

7 / 25

slide-11
SLIDE 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

slide-12
SLIDE 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

slide-13
SLIDE 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

slide-14
SLIDE 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

slide-15
SLIDE 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

slide-16
SLIDE 16

Inventory

stand for depend on variables terms meta-variables meta-terms variables meta2-variables meta2-terms meta-variables, variables

13 / 25

slide-17
SLIDE 17

Inventory

stand for depend on variables terms meta-variables meta-terms variables meta2-variables meta2-terms meta-variables, variables . . . . . . . . . metan-variables meta-n-terms meta-n−1-variables, ...

13 / 25

slide-18
SLIDE 18

Motivating example Theory Conclusion

14 / 25

slide-19
SLIDE 19

λx.λy.andI (D1 x) D2

15 / 25

slide-20
SLIDE 20

λx.λy.andI (D1 x) D2 : Πx:ι.Πy:ι.o

What can D1 be instantiated with?

◮ an open term where x can appear free... ◮ ... of type Πy:ι.o.

15 / 25

slide-21
SLIDE 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

slide-22
SLIDE 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

slide-23
SLIDE 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

slide-24
SLIDE 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

slide-25
SLIDE 25

CMTT... to ω...

∆k;∆k−1,x0:A;··· ⊢ M : B ∆k;∆k−1;··· ⊢ λx0 : A.M : Πx0:A.B ∆k;∆k−1;··· ;∆1,x1:A[Φ];∆0 ⊢ M : B ∆k;∆k−1;··· ;∆1;∆0 ⊢ λx1 : A[Φ].M : Πx1:A[Φ].B . . . ∆k;∆k−1;··· ;xk:A[Φ];··· ⊢ M : B ∆k;∆k−1;··· ⊢ λxk : A[Φ].M : Πxk:A[Φ].B                                     

17 / 25

slide-26
SLIDE 26

... to MLCMTT

Ψ + + xn:A[Φn] ⊢ M : B Ψ ⊢ λxn : A[Φn].M : Πxn:A[Φn].B

18 / 25

slide-27
SLIDE 27

... to MLCMTT

Ψ ⊢ R : Πxn:A[Φn].B Ψ|n + + Φn ⊢ N : A Ψ ⊢ R (ˆ Φn.N) : [ˆ Φn.N/xn]B

◮ From a schema of contexts lists to a context schema. ◮ From a schema of rules to a single rule.

19 / 25

slide-28
SLIDE 28

MLCMTT (typing rules for terms)

Ψ(xn) = A[Φn] Ψ ⊢ σ ⇐ Φn Ψ ⊢ xn[σ] ⇒ [σ]A Ψ ⊢ R : Πxn:A[Φn].B Ψ|n + + Φn ⊢ N : A Ψ ⊢ R (ˆ Φn.N) : [ˆ Φn.N/xn]B Ψ + + xn:A[Φn] ⊢ M : B Ψ ⊢ λxn : A[Φn].M : Πxn:A[Φn].B

◮ Single syntactic category of level-indexed variables. ◮ Can abstract at any level at any time.

20 / 25

slide-29
SLIDE 29

Context insertion

x3:ι,w2:ι,x2:ι + +y5:ι,v0:ι,w0:ι = y5:ι,x3:ι,w2:ι,x2:ι,v0:ι,w0:ι

◮ Invariant 2: context assumptions always in decreasing order

  • f level.

21 / 25

slide-30
SLIDE 30

Context insertion

x3:ι,w2:ι,x2:ι + +y5:ι,v0:ι,w0:ι = y5:ι,x3:ι,w2:ι,x2:ι,v0:ι,w0:ι

◮ Invariant 2: context assumptions always in decreasing order

  • f level.

◮ Chopping context at level n stays easy. ◮ Argument that metan-variables don’t depend on

metan−m-variables trivial.

21 / 25

slide-31
SLIDE 31

Example revisited

andI _ _ (allI _ (λx0 . (x0 .D11 )x0 )) .D21 allI _ (λx0 . andI _ _ ((x0 .D11 ) x0 ) .D21 ) where M2 ,N2 ,L2 :

  • [A1:o[],B1:o[],D11:nd A1[x0:ι],D21:nd B1[]]

P2 ,Q2 ,R2 :

  • [A1:o[],B1:o[],D11:nd A1[x0:ι],D21:nd B1[],x0:ι]

22 / 25

slide-32
SLIDE 32

Example revisited

andI .M2 .N2 (allI .L2 (λx0 . (x0 .D11 )x0 )) D21 allI .P2 (λx0 . andI .Q2 .R2 ((x0 .D11 ) x0 ) D21 ) where M2 ,N2 ,L2 :

  • [A1:o[],B1:o[],D11:nd A1[x0:ι],D21:nd B1[]]

P2 ,Q2 ,R2 :

  • [A1:o[],B1:o[],D11:nd A1[x0:ι],D21:nd B1[],x0:ι]

22 / 25

slide-33
SLIDE 33

Results

◮ Usual structural properties. ◮ Substitution property.

−→ “substitution does not go wrong.”

◮ Termination of heredetary substitutions. ◮ Decidability of type checking.

23 / 25

slide-34
SLIDE 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

slide-35
SLIDE 35

Conclusion

What we have:

◮ Uniform language for representing normal metan-terms.

25 / 25

slide-36
SLIDE 36

Conclusion

What we have:

◮ Uniform language for representing normal metan-terms.

Where we are going:

◮ Implement it. ◮ Reasoning about programs conveniently and efficiently. ◮ Reasoning about Beluga in Beluga.

25 / 25