a linear dependent type theory
play

A Linear Dependent Type Theory Zhaohui Luo Yu Zhang Royal Holloway - PowerPoint PPT Presentation

A Linear Dependent Type Theory Zhaohui Luo Yu Zhang Royal Holloway Institute of Software University of London Chinese Academy of Sciences Linear types and dependent types Linear types (Girard 1987): A - B Dependent types


  1. A Linear Dependent Type Theory Zhaohui Luo Yu Zhang Royal Holloway Institute of Software University of London Chinese Academy of Sciences

  2. Linear types and dependent types  Linear types (Girard 1987): A - º B  Dependent types (Martin-Löf 1970s):  x:A.B[x]  How to combine them?  In most of existing work (Pfenning et al 2002, Krishnaswami et al 2015, Vákár 2015)  B[x] only when x is intuitionistic.  Hence it is possible to separate intuitionistic Γ and linear Δ : Γ ; Δ |- a : A  Δ depends on Γ , but not the other way around.  McBride (2016)  “Prices” in contextual entries and typing and allow type dependency on 0 -priiced variables – discussion later.  Independent with this work (we became aware of Conor’s work only two weeks ago – detailed comparison due.)  This paper: LDTT, where types can depend on linear variables. May 2016 TYPES 2016 2

  3. LDTT: Linear and Intuitionistic Variables  Contexts are sequences of two forms of entries: x:A, y::B[x], z:C[x,y], …  Intuitionistic variables x : A  Linear variables y :: B  Types dependent on linear variables  Example: x::A, f : A - º A  - Eq A (f x, x) type May 2016 TYPES 2016 3

  4. Intuitionistic  -types  – the intuitionistic part of context Γ  = Γ \ FV LD ( Γ ) – removing the linear dependent variables  FV LD (  ) =   FV LD ( Γ ,x:A) = FV LD ( Γ ) if FV(A)  FV LD ( Γ ) =  ; = FV LD ( Γ )  {x} otherwise  FV LD ( Γ ,x::A) = FV LD ( Γ )  {x}  Example: Γ ≡ x:A, y::B, z:C ≡ x:A, z:C if y  FV(C) ≡ x:A, if y  FV(C) May 2016 TYPES 2016 4

  5. Linear  -types  Merge( Γ ; Δ ) is only defined if  (the intuitionistic parts are the same)  FV LD ( Γ )  FV LD ( Δ )=  ( Γ / Δ do not share linear dependent variables)  When the above are the case, Merge is defined as:  Example: Γ ≡ x:A, y 1 ::B 1 , z:C Δ ≡ x:A, y 2 ::B 2 , z:C Merge( Γ ; Δ ) ≡ x:A, z:C, y 1 ::B 1 , y 2 ::B 2 Note: y 1  y 2 and y 1, y 2  FV(C) for otherwise, Merge( Γ ; Δ ) would be undefined. May 2016 TYPES 2016 5

  6. Equality Types  Formation rule  merge( Γ ; Δ ) is defined only when var-sharing is OK: x?A  Γ , x?B  Δ  A ≡ B and ? is both : or both ::  merge( Γ ; Δ ) is defined as  Examples: x::A, f : A - º A  - f x : A and x::A  - x : A  x::A, f : A - º A  - Eq A (f x, x) type  x::A  - x : A and y::A  - y : A  x::A, y::A  - Eq(x,y) type  May 2016 TYPES 2016 6

  7.  Introduction and elimination rules May 2016 TYPES 2016 7

  8. Variable Typing where  Γ’ intuitionistic means that it does not have linear ::-entries  D Γ (x) is defined as:  x  D Γ (x);  For any y  D Γ (x), FV( Γ y )  D Γ (x).  Examples: Judgements derivable intuitionistically are derivable.  x::A,y:B(x) | - x:A and x::A,y:B(x) | - y:B(x) are derivable since x  B(x).  x::A, x’::A, y:B(x) | - y : B(x) is not derivable if x’  B(x).  May 2016 TYPES 2016 8

  9. Other Rules (for completeness)  Context validity  Context permutation rule:  Conversions and conversion rule: May 2016 TYPES 2016 9

  10. Weak Linearality  Defn (essential occurrences) Let Γ |- a:A. The multiset E Γ (a) of variables essentially occurring in a under Γ is inductively defined as follows (Eq-types omitted): Variable typing:   -typing:  Intuitionistic applications:  Linear applications:   Theorem (weak linearality) In LDTT, every linear variable occurs essentially for exactly once in a well-typed term. Formally, Γ , y::B, Γ’ | - a : A  y  E Γ, y::B, Γ’ (a) only once. May 2016 TYPES 2016 10

  11. Implementation  Type checking algorithm  Follows the traditional algorithm for type inference/checking.  Decidability, if assuming meta-theoretic results (expected).  Prototype implementation in Haskell  Merging oprns correspond to splitting oprns.  Available online: https://github.com/yveszhang/ldtyping May 2016 TYPES 2016 11

  12. Related Work  Work on linearity in dependent types  Eg, (Pfenning et al, I&C02), (Krishnaswami et al, POPL15), (Vákár, FoSSaCS 15)  Lambek calculus with dependent types (Luo, TYPES 2015)  Types in all above are non-dependent on linear/Lambek variables  McBride 2016 (Walder Festschrift)  More general setting: considering “prices” in {0,1,w}:  1 x 1 : A 1 , …  n x n : A n |-  a:A and different  -types (  x:A)  B:  (  x:A)  B corresponds to intuitionistic  -types  (1x:A)  B corresponds to linear  -types  T ype dependency B[x] only on “0 - priced” variables x.  Independent with the current work and comparison to be done. May 2016 TYPES 2016 12

  13. Future Work  LDTT: allowing types to depend on linear variables  Simplicity  LDTT gives a “straightforward” extension with linearality  cf, McBride’s work, analysis to be done  Examples of reasoning  to be done with our prototype implementation  Extension to other linear/Lambek type constructors May 2016 TYPES 2016 13

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend