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

undecidability of d and its decidable fragments
SMART_READER_LITE
LIVE PREVIEW

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:


slide-1
SLIDE 1

Undecidability of D<: and Its Decidable Fragments

Jason Z.S. Hu University of Waterloo − → McGill University zhong.s.hu@mail.mcgill.ca Ondřej Lhoták University of Waterloo

  • lhotak@uwaterloo.ca
slide-2
SLIDE 2

1

Introduction

Historical Overview: Scala and Dependent Object Types

◮ Scala was first released in 2004.

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-3
SLIDE 3

1

Introduction

Historical Overview: Scala and Dependent Object Types

◮ 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

slide-4
SLIDE 4

1

Introduction

Historical Overview: Scala and Dependent Object Types

◮ 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

slide-5
SLIDE 5

1

Introduction

Historical Overview: Scala and Dependent Object Types

◮ 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

slide-6
SLIDE 6

2

Path Dependent Types: An Example

Trait Definitions

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

slide-7
SLIDE 7

2

Path Dependent Types: An Example

Trait Definitions

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

slide-8
SLIDE 8

3

Path Dependent Types: An Example

A Tiny Program

def transfer(amount : Long, from : self.A, toBank : Bank, to : toBank.A) : Unit

  • bject BankOfWaterloo extends Bank { /* ... */ }
  • bject 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

slide-9
SLIDE 9

3

Path Dependent Types: An Example

A Tiny Program

def transfer(amount : Long, from : self.A, toBank : Bank, to : toBank.A) : Unit

  • bject BankOfWaterloo extends Bank { /* ... */ }
  • bject 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

slide-10
SLIDE 10

3

Path Dependent Types: An Example

A Tiny Program

def transfer(amount : Long, from : self.A, toBank : Bank, to : toBank.A) : Unit

  • bject BankOfWaterloo extends Bank { /* ... */ }
  • bject 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

slide-11
SLIDE 11

3

Path Dependent Types: An Example

A Tiny Program

def transfer(amount : Long, from : self.A, toBank : Bank, to : toBank.A) : Unit

  • bject BankOfWaterloo extends Bank { /* ... */ }
  • bject 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)

found: McGillBank.A expect: BankOfWaterloo.A

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-12
SLIDE 12

4

Research Questions

We can see that path dependent types are very expressive, but ...

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-13
SLIDE 13

4

Research Questions

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

slide-14
SLIDE 14

4

Research Questions

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

slide-15
SLIDE 15

5

Definition of D<: (Amin et al., 2016)

Path Dependent Types

Γ ⊢D<: T <: ⊤

TOP

Γ ⊢D<: ⊥ <: T

BOT

Γ ⊢D<: T <: T

REFL

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-16
SLIDE 16

5

Definition of D<: (Amin et al., 2016)

Path Dependent Types

Γ ⊢D<: T <: ⊤

TOP

Γ ⊢D<: ⊥ <: T

BOT

Γ ⊢D<: T <: T

REFL

Γ ⊢D<: S2 <: S1 Γ ⊢D<: U1 <: U2 Γ ⊢D<: {A : S1..U1} <: {A : S2..U2}

BND

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-17
SLIDE 17

5

Definition of D<: (Amin et al., 2016)

Path Dependent Types

Γ ⊢D<: T <: ⊤

TOP

Γ ⊢D<: ⊥ <: T

BOT

Γ ⊢D<: T <: T

REFL

Γ ⊢D<: S2 <: S1 Γ ⊢D<: U1 <: U2 Γ ⊢D<: {A : S1..U1} <: {A : S2..U2}

BND

Γ ⊢D<: S2 <: S1 Γ; x : S2 ⊢D<: U1 <: U2 Γ ⊢D<: ∀(x : S1)U1 <: ∀(x : S2)U2

ALL

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-18
SLIDE 18

5

Definition of D<: (Amin et al., 2016)

Path Dependent Types

Γ ⊢D<: T <: ⊤

TOP

Γ ⊢D<: ⊥ <: T

BOT

Γ ⊢D<: T <: T

REFL

Γ ⊢D<: S2 <: S1 Γ ⊢D<: U1 <: U2 Γ ⊢D<: {A : S1..U1} <: {A : S2..U2}

BND

Γ ⊢D<: S2 <: S1 Γ; x : S2 ⊢D<: U1 <: U2 Γ ⊢D<: ∀(x : S1)U1 <: ∀(x : S2)U2

ALL

Γ ⊢D<: Γ(x) <: {A : S..⊤} Γ ⊢D<: S <: x.A

SEL1’

Γ ⊢D<: Γ(x) <: {A : ⊥..U} Γ ⊢D<: x.A <: U

SEL2’

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-19
SLIDE 19

5

Definition of D<: (Amin et al., 2016)

Path Dependent Types

Γ ⊢D<: T <: ⊤

TOP

Γ ⊢D<: ⊥ <: T

BOT

Γ ⊢D<: T <: T

REFL

Γ ⊢D<: S2 <: S1 Γ ⊢D<: U1 <: U2 Γ ⊢D<: {A : S1..U1} <: {A : S2..U2}

BND

Γ ⊢D<: S2 <: S1 Γ; x : S2 ⊢D<: U1 <: U2 Γ ⊢D<: ∀(x : S1)U1 <: ∀(x : S2)U2

ALL

Γ ⊢D<: Γ(x) <: {A : S..⊤} Γ ⊢D<: S <: x.A

SEL1’

Γ ⊢D<: Γ(x) <: {A : ⊥..U} Γ ⊢D<: x.A <: U

SEL2’

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-20
SLIDE 20

5

Definition of D<: (Amin et al., 2016)

Path Dependent Types

Γ ⊢D<: T <: ⊤

TOP

Γ ⊢D<: ⊥ <: T

BOT

Γ ⊢D<: T <: T

REFL

Γ ⊢D<: S2 <: S1 Γ ⊢D<: U1 <: U2 Γ ⊢D<: {A : S1..U1} <: {A : S2..U2}

BND

Γ ⊢D<: S2 <: S1 Γ; x : S2 ⊢D<: U1 <: U2 Γ ⊢D<: ∀(x : S1)U1 <: ∀(x : S2)U2

ALL

Γ ⊢D<: Γ(x) <: {A : S..⊤} Γ ⊢D<: S <: x.A

SEL1’

Γ ⊢D<: Γ(x) <: {A : ⊥..U} Γ ⊢D<: x.A <: U

SEL2’

Γ ⊢D<: S <: T Γ ⊢D<: T <: U Γ ⊢D<: S <: U

TRANS

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-21
SLIDE 21

6

Outline of Our Undecidability Proof

The actual proof is quite tricky, e.g. the TRANS rule doesn’t provide strong enough inductive hypothesis.

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-22
SLIDE 22

6

Outline of Our Undecidability Proof

The actual proof is quite tricky, e.g. the TRANS rule doesn’t provide strong enough inductive hypothesis. To establish the proof, we

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-23
SLIDE 23

6

Outline of Our Undecidability Proof

The actual proof is quite tricky, e.g. the TRANS 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

slide-24
SLIDE 24

6

Outline of Our Undecidability Proof

The actual proof is quite tricky, e.g. the TRANS rule doesn’t provide strong enough inductive hypothesis. To establish the proof, we 1 find a suitable undecidable problem to reduce from, 2 define D<: normal form by restricting the TRANS rule,

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-25
SLIDE 25

6

Outline of Our Undecidability Proof

The actual proof is quite tricky, e.g. the TRANS rule doesn’t provide strong enough inductive hypothesis. To establish the proof, we 1 find a suitable undecidable problem to reduce from, 2 define D<: normal form by restricting the TRANS rule, 3 show the equivalence between D<: and D<: normal form,

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-26
SLIDE 26

6

Outline of Our Undecidability Proof

The actual proof is quite tricky, e.g. the TRANS rule doesn’t provide strong enough inductive hypothesis. To establish the proof, we 1 find a suitable undecidable problem to reduce from, 2 define D<: normal form by restricting the TRANS rule, 3 show the equivalence between D<: and D<: normal form, 4 conclude undecidability of D<:.

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-27
SLIDE 27

7

Finding An Undecidable Problem

Step 1

function types universal types

F<: F −

<:

D<:

dependent function types ??? ??? Amin et al. (2016) presents an attempt.

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-28
SLIDE 28

7

Finding An Undecidable Problem

Step 1

function types universal types

F<: F −

<:

D<:

dependent function types ??? ??? Amin et al. (2016) presents an attempt.

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-29
SLIDE 29

7

Finding An Undecidable Problem

Step 1

function types universal types

F<: F −

<:

D<:

dependent function types ??? ??? Amin et al. (2016) presents an attempt.

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-30
SLIDE 30

7

Finding An Undecidable Problem

Step 1

function types universal types

F<: F −

<:

D<:

dependent function types ??? ???

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-31
SLIDE 31

7

Finding An Undecidable Problem

Step 1

function types universal types

F<: F −

<:

D<:

dependent function types ??? ???

Theorem

Subtyping of F −

<: is undecidable.

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-32
SLIDE 32

8

Transitivity and Subtyping Reflection

Step 2

The TRANS rule induces an unexpected phenomenon: assume Γ(x) = {A : S..U} Γ ⊢D<: Γ(x) <: {A : S..⊤} Γ ⊢D<: S <: x.A

SEL1’

Γ ⊢D<: Γ(x) <: {A : ⊥..U} Γ ⊢D<: x.A <: U

SEL2’

Γ ⊢D<: S <: U

TRANS

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-33
SLIDE 33

8

Transitivity and Subtyping Reflection

Step 2

The TRANS rule induces an unexpected phenomenon: assume Γ(x) = {A : S..U} Γ ⊢D<: Γ(x) <: {A : S..⊤} Γ ⊢D<: S <: x.A

SEL1’

Γ ⊢D<: Γ(x) <: {A : ⊥..U} Γ ⊢D<: x.A <: U

SEL2’

Γ ⊢D<: S <: U

TRANS

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-34
SLIDE 34

8

Transitivity and Subtyping Reflection

Step 2

The TRANS rule induces an unexpected phenomenon: assume Γ(x) = {A : S..U} Γ ⊢D<: Γ(x) <: {A : S..⊤} Γ ⊢D<: S <: x.A

SEL1’

Γ ⊢D<: Γ(x) <: {A : ⊥..U} Γ ⊢D<: x.A <: U

SEL2’

Γ ⊢D<: S <: U

TRANS

Type declarations reflect bounds into the subtyping relation.

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-35
SLIDE 35

8

Transitivity and Subtyping Reflection

Step 2

The TRANS rule induces an unexpected phenomenon: assume Γ(x) = {A : S..U} Γ ⊢D<: Γ(x) <: {A : S..⊤} Γ ⊢D<: S <: x.A

SEL1’

Γ ⊢D<: Γ(x) <: {A : ⊥..U} Γ ⊢D<: x.A <: U

SEL2’

Γ ⊢D<: S <: U

TRANS

Type declarations reflect bounds into the subtyping relation. This phenomenon is called “subtyping reflection” (or “bad bounds” in the previous literature).

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-36
SLIDE 36

9

D<: Normal Form

Step 2

Subtyping reflection is captured by the following rule: Γ ⊢D<: Γ(x) <: {A : S..⊤} Γ ⊢D<: Γ(x) <: {A : ⊥..U} (for some x) Γ ⊢D<: S <: U

SR

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-37
SLIDE 37

9

D<: Normal Form

Step 2

Subtyping reflection is captured by the following rule: Γ ⊢D<: Γ(x) <: {A : S..⊤} Γ ⊢D<: Γ(x) <: {A : ⊥..U} (for some x) Γ ⊢D<: S <: U

SR

We replace the TRANS rule with this rule. The resulting calculus is called D<: normal form.

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-38
SLIDE 38

10

Properties of D<: Normal Form

Step 3

Theorem

D<: normal form admits transitivity.

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-39
SLIDE 39

10

Properties of D<: Normal Form

Step 3

Theorem

D<: normal form admits transitivity.

Theorem

Subtyping in the original D<: definition and in D<: normal form is equivalent.

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-40
SLIDE 40

11

Undecidability of D<: Subtyping

Step 4

F −

<:

D<: normal form D<:

easy equivalence ???

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-41
SLIDE 41

11

Undecidability of D<: Subtyping

Step 4

F −

<:

D<: normal form D<:

easy equivalence ???

Theorem

Subtyping in D<: normal form is undecidable.

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-42
SLIDE 42

11

Undecidability of D<: Subtyping

Step 4

F −

<:

D<: normal form D<:

easy equivalence ???

Theorem

Subtyping in D<: normal form is undecidable.

Theorem

D<: subtyping is undecidable.

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-43
SLIDE 43

12

A Thought about D<:

Subtyping reflection and transitivity are two sides of the same coin.

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-44
SLIDE 44

13

Step toward Decidable Fragments

Capturing subtyping reflection inspires us to a straightforward study of decidable fragments of D<:.

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-45
SLIDE 45

14

Kernel D<:

Consider the following rules from D<: normal form: Γ ⊢D<: S2 <: S1 Γ; x : S2 ⊢D<: U1 <: U2 Γ ⊢D<: ∀(x : S1)U1 <: ∀(x : S2)U2

ALL

Γ ⊢D<: Γ(x) <: {A : S..⊤} Γ ⊢D<: Γ(x) <: {A : ⊥..U} (for some x) Γ ⊢D<: S <: U

SR

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-46
SLIDE 46

14

Kernel D<:

Consider the following rules from D<: normal form: Γ ⊢D<: S2 <: S1 Γ; x : S2 ⊢D<: U1 <: U2 Γ ⊢D<: ∀(x : S1)U1 <: ∀(x : S2)U2

ALL

Γ ⊢D<: Γ(x) <: {A : S..⊤} Γ ⊢D<: Γ(x) <: {A : ⊥..U} (for some x) Γ ⊢D<: S <: U

SR

✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭ ✭ ❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤ ❤

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-47
SLIDE 47

14

Kernel D<:

Consider the following rules from D<: normal form: Γ; x : S ⊢D<:K U1 <: U2 Γ ⊢D<:K ∀(x : S)U1 <: ∀(x : S)U2

K-ALL

Γ ⊢D<: Γ(x) <: {A : S..⊤} Γ ⊢D<: Γ(x) <: {A : ⊥..U} (for some x) Γ ⊢D<: S <: U

SR

✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭ ✭ ❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤ ❤

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-48
SLIDE 48

14

Kernel D<:

Consider the following rules from D<: normal form: Γ; x : S ⊢D<:K U1 <: U2 Γ ⊢D<:K ∀(x : S)U1 <: ∀(x : S)U2

K-ALL

Γ ⊢D<: Γ(x) <: {A : S..⊤} Γ ⊢D<: Γ(x) <: {A : ⊥..U} (for some x) Γ ⊢D<: S <: U

SR

✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭ ✭ ❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤ ❤ These modifications define kernel D<:.

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-49
SLIDE 49

15

Kernel D<:

Decidability

Theorem

Kernel D<: is decidable.

Proof.

The decision procedure is step subtyping designed by Nieto (2017).

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-50
SLIDE 50

16

A Limitation of Kernel D<:

x : {A : ⊤..⊤} ⊢D<: ∀(y : x.A)⊤ <: ∀(y : ⊤)⊤ is rejected by kernel D<:.

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-51
SLIDE 51

16

A Limitation of Kernel D<:

x : {A : ⊤..⊤} ⊢D<: ∀(y : x.A)⊤ <: ∀(y : ⊤)⊤ is rejected by kernel D<:.

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-52
SLIDE 52

17

Asymmetry and Symmetry

We want to lift the previous limitation.

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-53
SLIDE 53

17

Asymmetry and Symmetry

We want to lift the previous limitation. The undecidability proof indicates the problem being the asymmetry of the parameter types of dependent function types.

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-54
SLIDE 54

17

Asymmetry and Symmetry

We want to lift the previous limitation. The undecidability proof indicates the problem being the asymmetry of the parameter types of dependent function types. The idea is to recover the symmetry by operating on two contexts at the same time.

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-55
SLIDE 55

18

Strong Kernel D<:

Γ ⊢D<:K S <: U ⇒ (Γ1 ⊢ S) <: (U ⊣ Γ2) Kernel D<: Strong kernel D<:

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-56
SLIDE 56

18

Strong Kernel D<:

Γ ⊢D<:K S <: U ⇒ (Γ1 ⊢ S) <: (U ⊣ Γ2) Kernel D<: Strong kernel D<: In (Γ1 ⊢ S) <: (U ⊣ Γ2), a type only concerns the context on its side: (Γ1 ⊢ Γ1(x)) <: ({A : ⊥..U} ⊣ Γ2) (Γ1 ⊢ x.A) <: (U ⊣ Γ2)

SK-SEL2

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-57
SLIDE 57

18

Strong Kernel D<:

Γ ⊢D<:K S <: U ⇒ (Γ1 ⊢ S) <: (U ⊣ Γ2) Kernel D<: Strong kernel D<: In (Γ1 ⊢ S) <: (U ⊣ Γ2), a type only concerns the context on its side: (Γ1 ⊢ Γ1(x)) <: ({A : ⊥..U} ⊣ Γ2) (Γ1 ⊢ x.A) <: (U ⊣ Γ2)

SK-SEL2

(Γ2 ⊢ S2) <: (S1 ⊣ Γ1) (Γ1; x : S1 ⊢ U1) <: (U2 ⊣ Γ2; x : S2) (Γ1 ⊢ ∀(x : S1)U1) <: (∀(x : S2)U2 ⊣ Γ2)

SK-ALL

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-58
SLIDE 58

18

Strong Kernel D<:

Γ ⊢D<:K S <: U ⇒ (Γ1 ⊢ S) <: (U ⊣ Γ2) Kernel D<: Strong kernel D<: In (Γ1 ⊢ S) <: (U ⊣ Γ2), a type only concerns the context on its side: (Γ1 ⊢ Γ1(x)) <: ({A : ⊥..U} ⊣ Γ2) (Γ1 ⊢ x.A) <: (U ⊣ Γ2)

SK-SEL2

(Γ2 ⊢ S2) <: (S1 ⊣ Γ1) (Γ1; x : S1 ⊢ U1) <: (U2 ⊣ Γ2; x : S2) (Γ1 ⊢ ∀(x : S1)U1) <: (∀(x : S2)U2 ⊣ Γ2)

SK-ALL

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-59
SLIDE 59

19

Strong Kernel D<:

Properties

Theorem

Strong kernel D<: is decidable.

Proof.

The decision procedure is stare-at subtyping (defined in the paper).

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-60
SLIDE 60

19

Strong Kernel D<:

Properties

Theorem

Strong kernel D<: is strictly stronger than kernel D<:. x : {A : ⊤..⊤} ⊢D<: ∀(y : x.A)⊤ <: ∀(y : ⊤)⊤ becomes admissible.

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-61
SLIDE 61

19

Strong Kernel D<:

Properties

Theorem

Strong kernel D<: is strictly stronger than kernel D<:. x : {A : ⊤..⊤} ⊢D<: ∀(y : x.A)⊤ <: ∀(y : ⊤)⊤ becomes admissible. let Γ = x : {A : ⊤..⊤} (Γ ⊢ ⊤) <: (x.A ⊣ Γ) (Γ; y : x.A ⊢ ⊤) <: (⊤ ⊣ Γ; y : ⊤) (Γ ⊢ ∀(y : x.A)⊤) <: (∀(y : ⊤)⊤ ⊣ Γ)

SK-ALL

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-62
SLIDE 62

20

Summary

− + Kernel D<: Strong kernel D<: D<: without SR (full) D<: D<: normal form

Decidable Undecidable Expressive Power

◮ For theorists: we present a systematic way of investigating (un)decidability! ◮ For practitioners: we develop algorithms for path dependent types!

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-63
SLIDE 63

21

References

Nada Amin, Samuel Grütter, Martin Odersky, Tiark Rompf, and Sandro Stucki. 2016. The Essence of Dependent Object Types. In A List of Successes That Can Change the World - Essays Dedicated to Philip Wadler on the Occasion of His 60th Birthday (Lecture Notes in Computer Science), Sam Lindley, Conor McBride, Philip W. Trinder, and Donald Sannella (Eds.), Vol. 9600. Springer, 249–272. https://doi.org/10.1007/978-3-319-30936-1_14 Nada Amin, Adriaan Moors, and Martin Odersky. 2012. Dependent object types. In 19th International Workshop on Foundations of Object-Oriented Languages. Vincent Cremet, François Garillot, Sergueï Lenglet, and Martin Odersky. 2006. A Core Calculus for Scala Type Checking. In Mathematical Foundations of Computer Science 2006, Rastislav Královiˇ c and Paweł Urzyczyn (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg, 1–23. Adriaan Moors, Frank Piessens, and Martin Odersky. 2008. Safe type-level abstraction in Scala. In Proceedings of the International Workshop on Foundations of Object-Oriented Languages (FOOL 2008). 1–13. Abel Nieto. 2017. Towards Algorithmic Typing for DOT (Short Paper). In Proceedings of the 8th ACM SIGPLAN International Symposium on Scala (SCALA 2017). ACM, New York, NY, USA, 2–7. https://doi.org/10.1145/3136000.3136003 Martin Odersky, Vincent Cremet, Christine Röckl, and Matthias Zenger. 2003. A Nominal Theory of Objects with Dependent Types. In ECOOP 2003 - Object-Oriented Programming, 17th European Conference, Darmstadt, Germany, July 21-25, 2003, Proceedings (Lecture Notes in Computer Science), Luca Cardelli (Ed.), Vol. 2743. Springer, 201–224. https://doi.org/10.1007/978-3-540-45070-2_10 Marianna Rapoport, Ifaz Kabir, Paul He, and Ondˇ rej Lhoták. 2017. A Simple Soundness Proof for Dependent Object Types. Proc. ACM Program. Lang. 1, OOPSLA, Article 46 (Oct. 2017), 27 pages. https://doi.org/10.1145/3133870 Tiark Rompf and Nada Amin. 2016. Type Soundness for Dependent Object Types (DOT). In Proceedings of the 2016 ACM SIGPLAN International Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA 2016). ACM, New York, NY, USA, 624–641. https://doi.org/10.1145/2983990.2984008 Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-64
SLIDE 64

22

Examples

Works for D<: but not strong kernel

⊢D<: {A : ⊥..⊥} <: {A : ⊥..⊤} x : {A : ⊥..⊥} ⊢D<: x.A <: ⊥ ⊢D<: ∀(x : {A : ⊥..⊤})x.A <: ∀(x : {A : ⊥..⊥})⊥

ALL

This judgment is not admissible in strong kernel, because when comparing the return types, the following judgment is required: (x : {A : ⊥..⊤} ⊢ x.A) <: (?⊥ ⊣ x : {A : ⊥..⊥}) Notice that on the left only x.A <: ⊤ is known so it is not admissible.

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-65
SLIDE 65

23

Definition of D<: Normal Form

Γ ⊢D<: T <: ⊤

TOP

Γ ⊢D<: ⊥ <: T

BOT

Γ ⊢D<: T <: T

REFL

Γ ⊢D<: S2 <: S1 Γ ⊢D<: U1 <: U2 Γ ⊢D<: {A : S1..U1} <: {A : S2..U2}

BND

Γ ⊢D<: S2 <: S1 Γ; x : S2 ⊢D<: U1 <: U2 Γ ⊢D<: ∀(x : S1)U1 <: ∀(x : S2)U2

ALL

Γ ⊢D<: Γ(x) <: {A : S..⊤} Γ ⊢D<: S <: x.A

SEL1’

Γ ⊢D<: Γ(x) <: {A : ⊥..U} Γ ⊢D<: x.A <: U

SEL2’

Γ ⊢D<: Γ(x) <: {A : S..⊤} Γ ⊢D<: Γ(x) <: {A : ⊥..U} (for some x) Γ ⊢D<: S <: U

SR

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments

slide-66
SLIDE 66

24

Summary Table

Name the ALL rule the SR rule Decidability D<: and D<: normal form full ALL

  • undecidable

full ALL × undecidable Strong kernel D<: SK-ALL × decidable Kernel D<: K-ALL × decidable K-ALL or SK-ALL

  • unknown

One future work is to check whether kernel D<: + SR is decidable or not. We don’t really understand much about subtyping reflection.

Hu and Lhoták | Undecidability of D<: and Its Decidable Fragments