undecidability of d and its decidable fragments
play

Undecidability of D < : and Its Decidable Fragments Jason Z.S. Hu - PowerPoint PPT Presentation

Undecidability of D < : and Its Decidable Fragments Jason Z.S. Hu Ondej Lhotk University of Waterloo University of Waterloo McGill University olhotak@uwaterloo.ca zhong.s.hu@mail.mcgill.ca Introduction Historical Overview:


  1. Undecidability of D < : and Its Decidable Fragments Jason Z.S. Hu Ondřej Lhoták University of Waterloo − → University of Waterloo McGill University olhotak@uwaterloo.ca zhong.s.hu@mail.mcgill.ca

  2. Introduction Historical Overview: Scala and Dependent Object Types 1 ◮ Scala was first released in 2004. Hu and Lhoták | Undecidability of D < : and Its Decidable Fragments

  3. Introduction Historical Overview: Scala and Dependent Object Types 1 ◮ Scala was first released in 2004. ◮ Formalization of Scala is a long running process (Odersky et al., 2003; Cremet et al., 2006; Moors et al., 2008; Amin et al., 2012; Rompf and Amin, 2016; Amin et al., 2016; Rapoport et al., 2017). Hu and Lhoták | Undecidability of D < : and Its Decidable Fragments

  4. Introduction Historical Overview: Scala and Dependent Object Types 1 ◮ Scala was first released in 2004. ◮ Formalization of Scala is a long running process (Odersky et al., 2003; Cremet et al., 2006; Moors et al., 2008; Amin et al., 2012; Rompf and Amin, 2016; Amin et al., 2016; Rapoport et al., 2017). ◮ How do type soundness proofs help to implement the compiler directly? Hu and Lhoták | Undecidability of D < : and Its Decidable Fragments

  5. Introduction Historical Overview: Scala and Dependent Object Types 1 ◮ Scala was first released in 2004. ◮ Formalization of Scala is a long running process (Odersky et al., 2003; Cremet et al., 2006; Moors et al., 2008; Amin et al., 2012; Rompf and Amin, 2016; Amin et al., 2016; Rapoport et al., 2017). ◮ How do type soundness proofs help to implement the compiler directly? We consider the decidability of path dependent types, and this theoretical result also benefits the implementation. Hu and Lhoták | Undecidability of D < : and Its Decidable Fragments

  6. Path Dependent Types: An Example Trait Definitions 2 trait Account trait Bank { self => type A <: Account def createAccount(initialBalance : Long = 0) : A def transfer(amount : Long, from : self.A, toBank : Bank, to : toBank.A ) : Unit } Hu and Lhoták | Undecidability of D < : and Its Decidable Fragments

  7. Path Dependent Types: An Example Trait Definitions 2 trait Account trait Bank { self => type A <: Account def createAccount(initialBalance : Long = 0) : A def transfer(amount : Long, from : self.A, toBank : Bank, to : toBank.A ) : Unit } toBank.A depends on a previous parameter. Hu and Lhoták | Undecidability of D < : and Its Decidable Fragments

  8. Path Dependent Types: An Example A Tiny Program 3 def transfer(amount : Long, from : self.A, toBank : Bank, to : toBank.A) : Unit object BankOfWaterloo extends Bank { /* ... */ } object McGillBank extends Bank { /* ... */ } val david : BankOfWaterloo.A = BankOfWaterloo.createAccount(200) val elly : McGillBank.A = McGillBank.createAccount(300) Hu and Lhoták | Undecidability of D < : and Its Decidable Fragments

  9. Path Dependent Types: An Example A Tiny Program 3 def transfer(amount : Long, from : self.A, toBank : Bank, to : toBank.A) : Unit object BankOfWaterloo extends Bank { /* ... */ } object McGillBank extends Bank { /* ... */ } val david : BankOfWaterloo.A = BankOfWaterloo.createAccount(200) val elly : McGillBank.A = McGillBank.createAccount(300) BankOfWaterloo.transfer(10, david, McGillBank, elly) This program works and transfers 10 dollars from David to Elly. Hu and Lhoták | Undecidability of D < : and Its Decidable Fragments

  10. Path Dependent Types: An Example A Tiny Program 3 def transfer(amount : Long, from : self.A, toBank : Bank, to : toBank.A) : Unit object BankOfWaterloo extends Bank { /* ... */ } object McGillBank extends Bank { /* ... */ } val david : BankOfWaterloo.A = BankOfWaterloo.createAccount(200) val elly : McGillBank.A = McGillBank.createAccount(300) BankOfWaterloo.transfer(10, david, McGillBank , elly) BankOfWaterloo.transfer(10, david, BankOfWaterloo , elly) What about this program? Hu and Lhoták | Undecidability of D < : and Its Decidable Fragments

  11. Path Dependent Types: An Example A Tiny Program 3 def transfer(amount : Long, from : self.A, toBank : Bank, to : toBank.A) : Unit object BankOfWaterloo extends Bank { /* ... */ } object McGillBank extends Bank { /* ... */ } val david : BankOfWaterloo.A = BankOfWaterloo.createAccount(200) val elly : McGillBank.A = McGillBank.createAccount(300) BankOfWaterloo.transfer(10, david, McGillBank, elly) found: McGillBank.A BankOfWaterloo.transfer(10, david, BankOfWaterloo, elly) expect: BankOfWaterloo.A Hu and Lhoták | Undecidability of D < : and Its Decidable Fragments

  12. Research Questions 4 We can see that path dependent types are very expressive, but ... Hu and Lhoták | Undecidability of D < : and Its Decidable Fragments

  13. Research Questions 4 We can see that path dependent types are very expressive, but ... ◮ Is type checking decidable with path dependent types? Hu and Lhoták | Undecidability of D < : and Its Decidable Fragments

  14. Research Questions 4 We can see that path dependent types are very expressive, but ... ◮ Is type checking decidable with path dependent types? ◮ Is subtyping decidable with path dependent types? Hu and Lhoták | Undecidability of D < : and Its Decidable Fragments

  15. Definition of D < : (Amin et al., 2016) Path Dependent Types 5 T OP B OT R EFL Γ ⊢ D < : T < : ⊤ Γ ⊢ D < : ⊥ < : T Γ ⊢ D < : T < : T Hu and Lhoták | Undecidability of D < : and Its Decidable Fragments

  16. Definition of D < : (Amin et al., 2016) Path Dependent Types 5 T OP B OT R EFL Γ ⊢ D < : T < : ⊤ Γ ⊢ D < : ⊥ < : T Γ ⊢ D < : T < : T Γ ⊢ D < : S 2 < : S 1 Γ ⊢ D < : U 1 < : U 2 B ND Γ ⊢ D < : { A : S 1 .. U 1 } < : { A : S 2 .. U 2 } Hu and Lhoták | Undecidability of D < : and Its Decidable Fragments

  17. Definition of D < : (Amin et al., 2016) Path Dependent Types 5 T OP B OT R EFL Γ ⊢ D < : T < : ⊤ Γ ⊢ D < : ⊥ < : T Γ ⊢ D < : T < : T Γ ⊢ D < : S 2 < : S 1 Γ ⊢ D < : S 2 < : S 1 Γ ⊢ D < : U 1 < : U 2 Γ; x : S 2 ⊢ D < : U 1 < : U 2 B ND A LL Γ ⊢ D < : { A : S 1 .. U 1 } < : { A : S 2 .. U 2 } Γ ⊢ D < : ∀ ( x : S 1 ) U 1 < : ∀ ( x : S 2 ) U 2 Hu and Lhoták | Undecidability of D < : and Its Decidable Fragments

  18. Definition of D < : (Amin et al., 2016) Path Dependent Types 5 T OP B OT R EFL Γ ⊢ D < : T < : ⊤ Γ ⊢ D < : ⊥ < : T Γ ⊢ D < : T < : T Γ ⊢ D < : S 2 < : S 1 Γ ⊢ D < : S 2 < : S 1 Γ ⊢ D < : U 1 < : U 2 Γ; x : S 2 ⊢ D < : U 1 < : U 2 B ND A LL Γ ⊢ D < : { A : S 1 .. U 1 } < : { A : S 2 .. U 2 } Γ ⊢ D < : ∀ ( x : S 1 ) U 1 < : ∀ ( x : S 2 ) U 2 Γ ⊢ D < : Γ( x ) < : { A : S .. ⊤} Γ ⊢ D < : Γ( x ) < : { A : ⊥ .. U } S EL 1’ S EL 2’ Γ ⊢ D < : S < : x . A Γ ⊢ D < : x . A < : U Hu and Lhoták | Undecidability of D < : and Its Decidable Fragments

  19. Definition of D < : (Amin et al., 2016) Path Dependent Types 5 T OP B OT R EFL Γ ⊢ D < : T < : ⊤ Γ ⊢ D < : ⊥ < : T Γ ⊢ D < : T < : T Γ ⊢ D < : S 2 < : S 1 Γ ⊢ D < : S 2 < : S 1 Γ ⊢ D < : U 1 < : U 2 Γ; x : S 2 ⊢ D < : U 1 < : U 2 B ND A LL Γ ⊢ D < : { A : S 1 .. U 1 } < : { A : S 2 .. U 2 } Γ ⊢ D < : ∀ ( x : S 1 ) U 1 < : ∀ ( x : S 2 ) U 2 Γ ⊢ D < : Γ( x ) < : { A : S .. ⊤} Γ ⊢ D < : Γ( x ) < : { A : ⊥ .. U } S EL 1’ S EL 2’ Γ ⊢ D < : S < : x . A Γ ⊢ D < : x . A < : U Hu and Lhoták | Undecidability of D < : and Its Decidable Fragments

  20. Definition of D < : (Amin et al., 2016) Path Dependent Types 5 T OP B OT R EFL Γ ⊢ D < : T < : ⊤ Γ ⊢ D < : ⊥ < : T Γ ⊢ D < : T < : T Γ ⊢ D < : S 2 < : S 1 Γ ⊢ D < : S 2 < : S 1 Γ ⊢ D < : U 1 < : U 2 Γ; x : S 2 ⊢ D < : U 1 < : U 2 B ND A LL Γ ⊢ D < : { A : S 1 .. U 1 } < : { A : S 2 .. U 2 } Γ ⊢ D < : ∀ ( x : S 1 ) U 1 < : ∀ ( x : S 2 ) U 2 Γ ⊢ D < : Γ( x ) < : { A : S .. ⊤} Γ ⊢ D < : Γ( x ) < : { A : ⊥ .. U } S EL 1’ S EL 2’ Γ ⊢ D < : S < : x . A Γ ⊢ D < : x . A < : U Γ ⊢ D < : S < : T Γ ⊢ D < : T < : U T RANS Γ ⊢ D < : S < : U Hu and Lhoták | Undecidability of D < : and Its Decidable Fragments

  21. Outline of Our Undecidability Proof 6 The actual proof is quite tricky, e.g. the T RANS rule doesn’t provide strong enough inductive hypothesis. Hu and Lhoták | Undecidability of D < : and Its Decidable Fragments

  22. Outline of Our Undecidability Proof 6 The actual proof is quite tricky, e.g. the T RANS rule doesn’t provide strong enough inductive hypothesis. To establish the proof, we Hu and Lhoták | Undecidability of D < : and Its Decidable Fragments

  23. Outline of Our Undecidability Proof 6 The actual proof is quite tricky, e.g. the T RANS rule doesn’t provide strong enough inductive hypothesis. To establish the proof, we 1 find a suitable undecidable problem to reduce from, Hu and Lhoták | Undecidability of D < : and Its Decidable Fragments

Recommend


More recommend