A (quick) tour of MLF (Graphic) Types (Type) Constraints Solving - - PowerPoint PPT Presentation

a quick tour of mlf graphic types type constraints
SMART_READER_LITE
LIVE PREVIEW

A (quick) tour of MLF (Graphic) Types (Type) Constraints Solving - - PowerPoint PPT Presentation

A (quick) tour of MLF (Graphic) Types (Type) Constraints Solving constraints Type inference Type Soundness Didier R emy A Fully Graphical & Presentation of MLF Boris Yakobowski INRIA Didier Rocquencourt Le Botlan A


slide-1
SLIDE 1

A (quick) tour of MLF (Graphic) Types (Type) Constraints Solving constraints Type inference Type Soundness

slide-2
SLIDE 2

A Fully Graphical Presentation of MLF

Didier R´ emy & Boris Yakobowski

INRIA Rocquencourt

Didier Le Botlan

slide-3
SLIDE 3

A (quick) tour of MLF (Graphic) Types (Type) Constraints Solving constraints Type inference Type Soundness

slide-4
SLIDE 4

Motivations

4(1)/22

The original MLF

◮ It is intuitively simple, but ◮ Its purely syntactic presentation is technically involved.

Is it the right definition?

(It is sound, indeed, but where there other better choices?) No, it is not quite right!

We now have the right definition, twice:

◮ “Semantically”, in Recasting MLF (work with Didier Le Botlan) ◮ Graphically, in this work

slide-5
SLIDE 5

This work

5(1)/22

A new fully graphical presentation of Full ML F We build on previous work A Graphical presentation of ML F types (TLDI 06)

Types and the instance relation are either well-known or simple

  • perations on graphs. Allows for an efficient unification algorithm.

We

◮ enrich types with type constraints. ◮ solve type constraints by reducing them to unification problems. ◮ express type inference as typing constraints ◮ obtain a type-inference algorithm about as efficient as the one for ML ◮ show type soundness by reasoning on graphical typing constraints.

slide-6
SLIDE 6

The key to MLF

6(1)/22

let choose = λ(x) λ(y) if true then x else y : ∀ α · α → α → α let id = λ(z) z : ∀ α · α → α

choose (λ(x) x) :

slide-7
SLIDE 7

The key to MLF

6(2)/22

let choose = λ(x) λ(y) if true then x else y : ∀ α · α → α → α let id = λ(z) z : ∀ α · α → α

choose (λ(x) x) :    ∀ α · (α → α) → (α → α) (∀ α · α → α) → (∀ α · α → α)

slide-8
SLIDE 8

The key to MLF

6(3)/22

let choose = λ(x) λ(y) if true then x else y : ∀ α · α → α → α let id = λ(z) z : ∀ α · α → α

choose (λ(x) x) :    ∀ α · (α → α) → (α → α) (∀ α · α → α) → (∀ α · α → α)   

No better choice in F

slide-9
SLIDE 9

The key to MLF

6(4)/22

let choose = λ(x) λ(y) if true then x else y : ∀ α · α → α → α let id = λ(z) z : ∀ α · α → α

choose (λ(x) x) :    ∀ α · (α → α) → (α → α) (∀ α · α → α) → (∀ α · α → α)   

No better choice in F

:

∀(β > ∀(α) α → α) β → β

in MLF

slide-10
SLIDE 10

The key to MLF

6(5)/22

let choose = λ(x) λ(y) if true then x else y : ∀ α · α → α → α let id = λ(z) z : ∀ α · α → α

choose (λ(x) x) :    ∀ α · (α → α) → (α → α) (∀ α · α → α) → (∀ α · α → α)   

No better choice in F

:

∀(β > ∀(α) α → α) β → β

in MLF

  ∀(β = ∀(α) α → α) β → β ∀(α) ∀(β = α → α) β → β

slide-11
SLIDE 11

The key to MLF

6(6)/22

let choose = λ(x) λ(y) if true then x else y : ∀ α · α → α → α let id = λ(z) z : ∀ α · α → α

choose (λ(x) x) :    ∀ α · (α → α) → (α → α) (∀ α · α → α) → (∀ α · α → α)   

No better choice in F

:

∀(β > ∀(α) α → α) β → β

in MLF

  ∀(β = ∀(α) α → α) β → β ∀(α) ∀(β = α → α) β → β

But

λ(x) x x :

ill-typed, as we do not guess polymorphism!

λ(x : ∀(α) α → α) x x : ∀(β = ∀(α) α → α) β → β

slide-12
SLIDE 12

The key to MLF

6(7)/22

let choose = λ(x) λ(y) if true then x else y : ∀ α · α → α → α let id = λ(z) z : ∀ α · α → α

choose (λ(x) x) :    ∀ α · (α → α) → (α → α) (∀ α · α → α) → (∀ α · α → α)   

No better choice in F

:

∀(β > ∀(α) α → α) β → β

in MLF

  ∀(β = ∀(α) α → α) β → β ∀(α) ∀(β = α → α) β → β

But

λ(x) x x :

ill-typed, as we do not guess polymorphism!

λ(x : ∀(α) α → α) x x : ∀(β = ∀(α) α → α) β → β

Function parameters that are used polymorphically and only those need an annotation.

slide-13
SLIDE 13

Graphical Types

7(1)/22

→ → → ⊥

β α

  • α ≥ ∀(β) β → β
  • α → (α → α)
slide-14
SLIDE 14

Graphical Types

7(2)/22

→ → → ⊥

β α

  • α ≥ ∀(β) β → β
  • α → (α → α)
slide-15
SLIDE 15

Graphical Types

7(3)/22

→ → → ⊥

β α

  • α ≥ ∀(β) β → β
  • α → (α → α)
slide-16
SLIDE 16

Graphical Types

7(4)/22

→ → → ⊥

β α

∀(β) ∀

  • α ≥ β → β
  • α → α → α
slide-17
SLIDE 17

Graphical Types

7(5)/22

→ → → ⊥

β α

  • α ≥ ∀(β) β → β
  • α → (α → α)
slide-18
SLIDE 18

Graphical Types

7(6)/22

Binding all nodes allows for a more regular representation

→ → → ⊥

β α γ

  • α ≥ ∀(β) β → β
  • γ ≥ α → α
  • α → γ
slide-19
SLIDE 19

Graphical Types

7(7)/22

→ → → ⊥

Superposition of a term-dag (first-order terms sharing suffixes)

slide-20
SLIDE 20

Graphical Types

7(8)/22

→ → → ⊥

and a binding tree structure (+ well-formedness conditions between both)

slide-21
SLIDE 21

Graphical Types

7(9)/22

→ → → ⊥

slide-22
SLIDE 22

Graphical Types

7(10)/22

Instance relation Grafting

→ → → → ⊥ ⊥

slide-23
SLIDE 23

Graphical Types

7(11)/22

Instance relation Raising

→ → → → ⊥ ⊥

slide-24
SLIDE 24

Graphical Types

7(12)/22

Instance relation Raising

→ → → → ⊥ ⊥

slide-25
SLIDE 25

Graphical Types

7(13)/22

Instance relation Merging

→ → → → ⊥

slide-26
SLIDE 26

Graphical Types

7(14)/22

Instance relation Weakening Changes permissions

→ → → → ⊥

slide-27
SLIDE 27

Graphical Types

7(15)/22

Instance relation Weakening Changes permissions

→ → → → ⊥

slide-28
SLIDE 28

Graphical Types

7(16)/22

Instance relation Weakening Changes permissions

→ → → → ⊥

  • α = ∀(β) β → β
  • γ ≥ α → α
  • α → γ
slide-29
SLIDE 29

Inner nodes

8(1)/22

The interior of a node n is the set of nodes, said inner n, that are transitively bound at n.

→ → ⊥ → → ⊥ → ⊥ → ⊥ → ⊥

slide-30
SLIDE 30

Inner nodes

8(2)/22

It can be transformed locally, as long as the interface (struture edges crossing the frontier) is maintained.

→ → ⊥ → → ⊥ → ⊥ → ⊥ → ⊥

slide-31
SLIDE 31

Inner nodes

8(3)/22

It can be transformed locally, as long as the interface (struture edges crossing the frontier) is maintained.

→ → ⊥ → → ⊥ → ⊥ → ⊥ → ⊥ → →

slide-32
SLIDE 32

Constraints

9(1)/22

They are graphic types extended with. . . 1) Existential nodes and unification edges

→ → → ⊥ → ⊥

slide-33
SLIDE 33

Constraints

9(2)/22

They are graphic types extended with. . . 2) Type schemes and instantiation edges

→ ∀ → ⊥ → ⊥ ⊥

Use sorts Scheme and Type to constraint formation of edges

slide-34
SLIDE 34

Semantics of constraints

10(1)/22

General picture

◮ Constraints are given a meaning as a set of types that are solutions of

the constraints. (Hence two constraints with the same meaning may have completely different shapes, e.g. two unsolvable constraints are equivalent)

◮ Constraints are also types. As such, they can be instantiated along ⊑.

slide-35
SLIDE 35

Semantics of constraints

10(2)/22

General picture

◮ Constraints are given a meaning as a set of types that are solutions of

the constraints. (Hence two constraints with the same meaning may have completely different shapes, e.g. two unsolvable constraints are equivalent)

◮ Constraints are also types. As such, they can be instantiated along ⊑.

Definition:

◮ A presolution of a constraint χ is an instance of χ

in which all constraint edge are solved.

◮ A solution of χ is of a the projection of a presolution of χ

slide-36
SLIDE 36

Semantics of constraints

10(3)/22

Projection of a constraint

1) Remove all existential nodes, 2) garbage collect from the root node, 3) remove all dangling edges.

slide-37
SLIDE 37

Semantics of constraints

10(4)/22

Projection of a constraint

1) Remove all existential nodes, 2) garbage collect from the root node, 3) remove all dangling edges.

→ ∀ → ⊥ → ⊥ ⊥

slide-38
SLIDE 38

Semantics of constraints

10(5)/22

Projection of a constraint

1) Remove all existential nodes, 2) garbage collect from the root node, 3) remove all dangling edges.

→ → ⊥ ⊥

slide-39
SLIDE 39

Semantics of constraints

10(6)/22

A unification edge p

q if p = q

Unification edges are solved by unification :-)

slide-40
SLIDE 40

Semantics of constraints

10(7)/22

An instantiation edge s

m is solved if

the type at m matches the type scheme at s

slide-41
SLIDE 41

Semantics of constraints

10(8)/22

An instantiation edge s

m is solved if

the type at m matches the type scheme at s

i.e. the unification of a copy of s with m leaves the constaint unchanged.

slide-42
SLIDE 42

Semantics of constraints

10(9)/22

An instantiation edge s

m is solved if

→ n p f q

  • d

→ n p f q

  • d

⋄ nc pc qc ≥

slide-43
SLIDE 43

Principal presolutions

11(1)/22

A key property A solvable constraint has a principal presolution,

i.e. an instance of the original constraint that is a presolution and

  • f which all other presolutions are instances.
slide-44
SLIDE 44

Entailment

12(1)/22

χ χ′ if all solutions of χ are solutions of χ′.

slide-45
SLIDE 45

Entailment

12(2)/22

χ χ′ if all solutions of χ are solutions of χ′.

In particular χ χ′ whenever χ′ ⊑ χ (χ′ is more constrained than χ.)

However, interesting entailments are not along ⊑.

χ ⊣⊢ χ′ if the solutions of χ are exactly the solutions of χ′.

slide-46
SLIDE 46

Sound and complete transformations

13(1)/22

Unif-Elim

Solving unification edges

Exists-Elim

Elimination of existential nodes without inner constraints

slide-47
SLIDE 47

Sound and complete transformations

13(2)/22

Inst-Elim-Poly (Existential nodes and constraint edges also copied)

m

  • n

⊣⊢

m ⋄

  • mc

n

slide-48
SLIDE 48

Sound and complete transformations

13(3)/22

Inst-Elim-Mono

(Degenerate case

m n ⊣⊢

m n

slide-49
SLIDE 49

Sound and complete transformations

13(4)/22

Inst-Copy

(Existential nodes and constraint edges also copied)

  • ⊣⊢
slide-50
SLIDE 50

A strategy

14(1)/22

s1 depends on s2 if s2 n and n is inner s1.

A constraint χ is admissible if the dependency relation is acyclic. (Except for pathological cases, other cases do not have solutions).

Strategy for solving admissible constraints

◮ Independent schemes may be solved first, by Inst-Elim-Poly ◮ The unification edge that is introduced may be solved immediately. ◮ This way, no constaint edge is ever duplicated.

slide-51
SLIDE 51

Typing constraints

15(1)/22

x x¯ y ⇓ ∀ ⊥ x let x = a1 in a2 ⇓ a2 a1 x λ(x) a ⇓ ∀ → ⊥ a ⊥ x a1 a2 ⇓ ∀ a1 a2 → ⊥ ⊥

slide-52
SLIDE 52

Typing example λ(x) x

16(1)/22

λ(x) x

slide-53
SLIDE 53

Typing example λ(x) x

16(2)/22

λ(x) x ⇒

→ ∀ ⊥ ⊥

slide-54
SLIDE 54

Typing example λ(x) x

16(3)/22

→ ⊥ ⊥ ⇐

→ ∀ ⊥ ⊥

slide-55
SLIDE 55

Typing example λ(x) x

16(4)/22

→ ⊥ ⊥ ⇒

→ ⊥

slide-56
SLIDE 56

Example let y = λ(x) x in y y

17(1)/22

let y = λ(x) x

in y y

slide-57
SLIDE 57

Example let y = λ(x) x in y y

17(2)/22

let y = λ(x) x

in y y

⇒ y y λ(x) x y

slide-58
SLIDE 58

Example let y = λ(x) x in y y

17(3)/22

∀ ∀ ⊥ ∀ → ⊥ ∀ ⊥ → ⊥ ⊥ ⇐ y y λ(x) x y

slide-59
SLIDE 59

Example let y = λ(x) x in y y

17(4)/22

∀ ∀ ⊥ ∀ → ⊥ ∀ ⊥ → ⊥ ⊥ ⇒ ∀ ∀ → ⊥ → ⊥ ⊥

slide-60
SLIDE 60

Example let y = λ(x) x in y y

17(5)/22

∀ → ⊥ → ⊥ → ⊥ ⊥ ⇐ ∀ ∀ → ⊥ → ⊥ ⊥

slide-61
SLIDE 61

Example let y = λ(x) x in y y

17(6)/22

∀ → ⊥ → ⊥ → ⊥ ⊥ ⇒ ∀ → → ⊥

slide-62
SLIDE 62

Example let y = λ(x) x in y y

17(7)/22

∀ → ⊥ ⇐ ∀ → → ⊥

slide-63
SLIDE 63

Coercions: (a : κ) is typed as cκ a

18(1)/22

∀ κ τ

τ =

  • τ

  • ∀(α) τ

∀(γ = ∀(α) τ) ∀(γ′ > ∀(α) τ) γ → γ′

slide-64
SLIDE 64

Coercions: (a : κ) is typed as cκ a

18(2)/22

∀ κ τ

τ =

  • τ

  • ∃¯

β∀(α) τ ∀(¯ β) ∀(γ = ∀(α) τ) ∀(γ′ > ∀(α) τ) γ → γ′

slide-65
SLIDE 65

Type soundness

19(1)/22

We show type soundness in IMLF a fully implicitly typed version of XMLF.

slide-66
SLIDE 66

Type soundness

19(2)/22

We show type soundness in IMLF a fully implicitly typed version of XMLF. XMLF is defined as IMLF, replacing ⊑ by ⊑⊏

− ⊐ − everywhere

where ⊑⊏

− ⊐ − is (⊑ ∪ ⊐

−)∗

No type inference and no principal types in IMLF This changes the semantics of contraints, which have more

  • solutions. Entailment is incomparable.

Transformations rules of XMLF are not not complete or not sound in IMLF

slide-67
SLIDE 67

Type soundness

20(1)/22

Subject reduction means that → is a subrelation of · · .

We show that · · satisfies the rules defining →.

Progress is easy.

slide-68
SLIDE 68

β preserves typings

21(1)/22

(λ(x) a1) a2

slide-69
SLIDE 69

β preserves typings

21(2)/22

(λ(x) a1) a2 = ⇒ ∀ ∀ → ⊥ a1 ⊥ x a2 → ⊥ ⊥

Equivalence, by definition

slide-70
SLIDE 70

β preserves typings

21(3)/22

∀ → ⊥ a1 ⊥ x a2 → ⊥ ⊥

⇐ = ∀ ∀ → ⊥ a1 ⊥ x a2 → ⊥ ⊥

Entailment, †

slide-71
SLIDE 71

β preserves typings

21(4)/22

∀ → ⊥ a1 ⊥ x a2 → ⊥ ⊥

= ⇒ ∀ a2 → ⊥ a1 ⊥ x

Equivalence, Unification

slide-72
SLIDE 72

β preserves typings

21(5)/22

∀ a2 ⊥ a1 ⊥ x ⇐ = ∀ a2 → ⊥ a1 ⊥ x

Equivalence, by existential elimination

slide-73
SLIDE 73

β preserves typings

21(6)/22

∀ a2 ⊥ a1 ⊥ x = ⇒ ∀ a2 ⊥ a1 ⊥ x

Entailment, by inverse instance

slide-74
SLIDE 74

β preserves typings

21(7)/22

a1 a2 ⊥ x ⇐ = ∀ a2 ⊥ a1 ⊥ x

Entailment, by Inst-Bot, †

slide-75
SLIDE 75

β preserves typings

21(8)/22

a1 a2 ⊥ x = ⇒ a1 a2 ⊥ x x

Equivalence, decomposition of ⊑⊏

− ⊐ −

slide-76
SLIDE 76

β preserves typings

21(9)/22

a1 a2 x ⇐ = a1 a2 ⊥ x x

Entailment, just dropping constraints

slide-77
SLIDE 77

β preserves typings

21(10)/22

a1 a2 x = ⇒ let x = a1 in a2

Equivalence, by definition

slide-78
SLIDE 78

β preserves typings

21(11)/22

a1 a2 x1 xk ⇐ = let x = a1 in a2

Equivalence, by definition

slide-79
SLIDE 79

β preserves typings

21(12)/22

a1 a2 x1 xk = ⇒ a1 a2 . . . a2 x1 xk

Entailment, by

  • Inst-Copy, †
slide-80
SLIDE 80

β preserves typings

21(13)/22

a1 a2 ∀ ⊥ . . . ∀ ⊥ a2 ⇐ = a1 a2 . . . a2 x1 xk

Equivalence, zooing on details.

slide-81
SLIDE 81

β preserves typings

21(14)/22

a1 a2 ∀ ⊥ . . . ∀ ⊥ a2 = ⇒ a1 a2 1 . . . a2 k

Entailment, by Inst-Bot

slide-82
SLIDE 82

β preserves typings

21(15)/22

a1[a2/x] ⇐ = a1 a2 1 . . . a2 k

Equivalence, by definition,

slide-83
SLIDE 83

Conclusions

22(1)/22

◮ Simpler, canonical definition of MLF. ◮ Efficient, scalable type inference. ◮ Generalizing type constraint for ML.

Makes type inference independent of the underlying language.

◮ Good basis for further extensions:

higher-order types, recusive types, existential types, ...

◮ Also to be explored: semi-unification problem for MLF types.

See http://gallium.inria.fr/∼remy/mlf/

slide-84
SLIDE 84

Appendices

slide-85
SLIDE 85

Permissions

24(1)/22

Nodes/contexts are partitioned into four categories: I irreversible Re explicitly reversible Ri implicitly reversible U unsafe. They are uniquely determined by the binding tree.

◮ Ri-nodes are non-bottom nodes whose incoming binding edges all

  • riginate from other Ri-nodes.

◮ The remaining nodes are further classified by looking at the sequence

  • f labels obtained from following their binding edges in the inverse

direction (starting from the root) in the automaton drawn here. I Re U

slide-86
SLIDE 86

Permissions

24(2)/22

Relations

Grafting Merging Raising Weakening Instance

I I, R I, R I Abstraction

⊏ − −

R R

Similarity

Ri Ri

Decompositions

We may always treat types up to , since (⊑ ∪ )∗ = (⊑; ) We may also (sometimes) treat types up to ⊏

−, since (⊑ ∪ ⊐ −)∗ = (⊑; ⊐ −)

slide-87
SLIDE 87

Reset:

25(1)/22

Applying

→ → ⊥ → ⊥

to

→ ⊥

returns

→ ⊥

equivalent to

→ ⊥

Similarly,

→ ⊥

equivalent to

→ ⊥

See Gen typing rule.

slide-88
SLIDE 88

Recasting ML

26(1)/22

A revisited syntactic presentation of MLF, with an interpretation of types as sets of System-F types.

◮ It justifies the choice of types and type instance. ◮ We exhibit a correspondance with implicitly typed and explicitly typed

versions of MLF

◮ We encodes MLF into Flet (an extension of F with intersection types)

The instance relation is (slightly) enhanced by correcting artifacts of the syntactic definition in the original relation. However, this presentation is restricted to Plain MLF (types are stratified).

slide-89
SLIDE 89

A family of languages

27(1)/22

F (Full) MLF Standard ∀ α· Flexible ∀(α > σ) Graphical MLF

slide-90
SLIDE 90

A family of languages

27(2)/22

F (Full) MLF ML Plain MLF Simple Types Simple MLF Standard ∀ α· Flexible ∀(α > σ)

+ let-∀ + λ-∀ + let-∀≥ + λ-∀≥

+ ∀≥

Graphical MLF

slide-91
SLIDE 91

Syntactic instance

28(1)/22

Type Equivalence

Eq-Refl

(Q) σ ≡ σ

Eq-Trans

(Q) σ1 ≡ σ2 (Q) σ2 ≡ σ3 (Q) σ1 ≡ σ3

Eq-Context-R

(Q, α ⋄ σ) σ1 ≡ σ2 (Q) ∀(α ⋄ σ) σ1 ≡ ∀(α ⋄ σ) σ2

Eq-Context-L

(Q) σ1 ≡ σ2 (Q) ∀(α ⋄ σ1) σ ≡ ∀(α ⋄ σ2) σ

Eq-Free

α / ∈ ftv(σ1) (Q) ∀(α ⋄ σ) σ1 ≡ σ1

Eq-Comm

α1 / ∈ ftv(σ2) α2 / ∈ ftv(σ1) (Q) ∀(α1 ⋄1 σ1) ∀(α2 ⋄2 σ2) σ ≡ ∀(α2 ⋄2 σ2) ∀(α1 ⋄1 σ1) σ

Eq-Var

(Q) ∀(α ⋄ σ) α ≡ σ

Eq-Mono

(α ⋄ σ0) ∈ Q (Q) σ0 ≡ τ0 (Q) τ ≡ τ[τ0/α]

Type Abstraction

A-Equiv

(Q) σ1 ≡ σ2 (Q) σ1 ⊏ − σ2

A-Trans

(Q) σ1 ⊏ − σ2 (Q) σ2 ⊏ − σ3 (Q) σ1 ⊏ − σ3

A-Context-R

(Q, α ⋄ σ) σ1 ⊏ − σ2 (Q) ∀(α ⋄ σ) σ1 ⊏ − ∀(α ⋄ σ) σ2

A-Hyp

(α1 = σ1) ∈ Q (Q) σ1 ⊏ − α1

A-Context-L

(Q) σ1 ⊏ − σ2 (Q) ∀(α = σ1) σ ⊏ − ∀(α = σ2) σ

Type Instance

I-Abstract

(Q) σ1 ⊏ − σ2 (Q) σ1 σ2

I-Trans

(Q) σ1 σ2 (Q) σ2 σ3 (Q) σ1 σ3

I-Context-R

(Q, α ⋄ σ) σ1 σ2 (Q) ∀(α ⋄ σ) σ1 ∀(α ⋄ σ) σ2

I-Hyp

(α1 ≥ σ1) ∈ Q (Q) σ1 α1

I-Context-L

(Q) σ1 σ2 (Q) ∀(α > σ1) σ ∀(α > σ2) σ

I-Bot

(Q) ⊥ σ

I-Rigid

(Q) ∀(α > σ1) σ ∀(α = σ1) σ

slide-92
SLIDE 92

Syntactic instance

28(2)/22

Type Equivalence

Eq-Refl

(Q) σ ≡ σ

Eq-Trans

(Q) σ1 ≡ σ2 (Q) σ2 ≡ σ3 (Q) σ1 ≡ σ3

Eq-Context-R

(Q, α ⋄ σ) σ1 ≡ σ2 (Q) ∀(α ⋄ σ) σ1 ≡ ∀(α ⋄ σ) σ2

Eq-Context-L

(Q) σ1 ≡ σ2 (Q) ∀(α ⋄ σ1) σ ≡ ∀(α ⋄ σ2) σ

Eq-Free

α / ∈ ftv(σ1) (Q) ∀(α ⋄ σ) σ1 ≡ σ1

Eq-Comm

α1 / ∈ ftv(σ2) α2 / ∈ ftv(σ1) (Q) ∀(α1⋄1σ1) ∀(α2⋄2 σ2) σ ≡ ∀(α2⋄2σ2) ∀(α1⋄1σ1) σ

Eq-Var

(Q) ∀(α ⋄ σ) α ≡ σ

Eq-Mono

(α ⋄ σ0) ∈ Q (Q) σ0 ≡ τ0

slide-93
SLIDE 93

Syntactic instance

28(3)/22

Type Abstraction

A-Equiv

(Q) σ1 ≡ σ2 (Q) σ1 ⊏ − σ2

A-Trans

(Q) σ1 ⊏ − σ2 (Q) σ2 ⊏ − σ3 (Q) σ1 ⊏ − σ3

A-Context-R

(Q, α ⋄ σ) σ1 ⊏ − σ2 (Q) ∀(α ⋄ σ) σ1 ⊏ − ∀(α ⋄ σ) σ2

A-Hyp

(α1 = σ1) ∈ Q (Q) σ1 ⊏ − α1

A-Context-L

(Q) σ1 ⊏ − σ2 (Q) ∀(α = σ1) σ ⊏ − ∀(α = σ2) σ

slide-94
SLIDE 94

Syntactic instance

28(4)/22

Type Instance

I-Abstract

(Q) σ1 ⊏ − σ2 (Q) σ1 σ2

I-Trans

(Q) σ1 σ2 (Q) σ2 σ3 (Q) σ1 σ3

I-Context-R

(Q, α ⋄ σ) σ1 σ2 (Q) ∀(α ⋄ σ) σ1 ∀(α ⋄ σ) σ2

I-Hyp

(α1 ≥ σ1) ∈ Q (Q) σ1 α1

I-Context-L

(Q) σ1 σ2 (Q) ∀(α > σ1) σ ∀(α > σ2) σ

I-Bot

(Q) ⊥ σ

I-Rigid

(Q) ∀(α > σ1) σ ∀(α = σ1) σ

slide-95
SLIDE 95

Typing λ(y : ∀(α) α → α) y y

29(1)/22

λ(y : ∀(α) α → α) y y

(0)

slide-96
SLIDE 96

Typing λ(y : ∀(α) α → α) y y

29(2)/22

λ(y : ∀(α) α → α) y y

= ⇒

λ(y) let y = cκid y in y y

(1) by definition

slide-97
SLIDE 97

Typing λ(y : ∀(α) α → α) y y

29(3)/22

→ ⊥ ∀ → → ⊥ → ⊥ ∀ ⊥ → ⊥ ⊥ y y ⊥ y

⇐ =

λ(y) let y = cκid y in y y

(2) by definition

slide-98
SLIDE 98

Typing λ(y : ∀(α) α → α) y y

29(4)/22

→ ⊥ ∀ → → ⊥ → ⊥ ∀ ⊥ → ⊥ ⊥ y y ⊥ y

= ⇒

→ ∀ → → ⊥ → ⊥ → ⊥ ⊥ y y ⊥ y

(3) unification

slide-99
SLIDE 99

Typing λ(y : ∀(α) α → α) y y

29(5)/22

→ ∀ → → ⊥ → ⊥ y y ⊥ y

⇐ =

→ ∀ → → ⊥ → ⊥ → ⊥ ⊥ y y ⊥ y

(4) existential elimination

slide-100
SLIDE 100

Typing λ(y : ∀(α) α → α) y y

29(6)/22

→ ∀ → → ⊥ → ⊥ y y ⊥ y

= ⇒

→ → ⊥ ∀ → ⊥ y y ⊥ y

(5)

slide-101
SLIDE 101

Typing λ(y : ∀(α) α → α) y y

29(7)/22

→ → ⊥ ∀ → ⊥ → ⊥ ⊥

⇐ =

→ → ⊥ ∀ → ⊥ y y ⊥ y

(6) by definition

slide-102
SLIDE 102

Typing λ(y : ∀(α) α → α) y y

29(8)/22

→ → ⊥ ∀ → ⊥ → ⊥ ⊥

= ⇒

→ → ⊥ → ⊥

(7) many steps

slide-103
SLIDE 103

The End