Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection...

65
Nicolas Tabareau Eliminating reflection through reflection Matthieu Sozeau Théo Winterhalter joint work with EUTypes 2018

Transcript of Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection...

Page 1: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Nicolas Tabareau

Eliminating reflection through reflection

Matthieu Sozeau

Théo Winterhalter

joint work with

EUTypes 2018

Page 2: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Different notions of equality

Conversion Identity typesExtends the notion of β-equality To handle equalities within type theory

(λx.t) u ≡ t[x← u] refl u : u = u

1

Page 3: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Different notions of equality

Conversion Identity typesExtends the notion of β-equality To handle equalities within type theory

(λx.t) u ≡ t[x← u] refl u : u = u

If u ≡ v then refl u : u = v

1

Page 4: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Reflection

Conversion Identity typesExtends the notion of β-equality To handle equalities within type theory

2

Page 5: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Reflection

Conversion Identity typesExtends the notion of β-equality To handle equalities within type theory

p : u = v

u ≡ v

2

Page 6: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Example

3

Page 7: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

ExamplevecA : nat → Type

3

Page 8: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

ExamplevecA : nat → Type

[] : vecA 0

3

Page 9: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

ExamplevecA : nat → Type

[] : vecA 0

cons : ∀ n, A → vecA n → vecA (S n)

3

Page 10: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

ExamplevecA : nat → Type

[] : vecA 0

cons : ∀ n, A → vecA n → vecA (S n)

rev : ∀ {n m}, vecA n → vecA m → vecA (n + m)

3

Page 11: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

ExamplevecA : nat → Type

[] : vecA 0

cons : ∀ n, A → vecA n → vecA (S n)

rev : ∀ {n m}, vecA n → vecA m → vecA (n + m)

rev [] acc ≐ acc

3

Page 12: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

ExamplevecA : nat → Type

[] : vecA 0

cons : ∀ n, A → vecA n → vecA (S n)

rev : ∀ {n m}, vecA n → vecA m → vecA (n + m)

rev [] acc ≐ acc

rev (cons n a v) acc ≐ rev v (cons m a acc)

3

Page 13: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

ExamplevecA : nat → Type

[] : vecA 0

cons : ∀ n, A → vecA n → vecA (S n)

rev : ∀ {n m}, vecA n → vecA m → vecA (n + m)

rev [] acc ≐ acc

rev (cons n a v) acc ≐ rev v (cons m a acc)

vecA m 3

Page 14: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

ExamplevecA : nat → Type

[] : vecA 0

cons : ∀ n, A → vecA n → vecA (S n)

rev : ∀ {n m}, vecA n → vecA m → vecA (n + m)

rev [] acc ≐ acc

rev (cons n a v) acc ≐ rev v (cons m a acc)

vecA (S m) 3

Page 15: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

ExamplevecA : nat → Type

[] : vecA 0

cons : ∀ n, A → vecA n → vecA (S n)

rev : ∀ {n m}, vecA n → vecA m → vecA (n + m)

rev [] acc ≐ acc

rev (cons n a v) acc ≐ rev v (cons m a acc)

vecA (n + S m) 3

Page 16: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

ExamplevecA : nat → Type

[] : vecA 0

cons : ∀ n, A → vecA n → vecA (S n)

rev : ∀ {n m}, vecA n → vecA m → vecA (n + m)

rev [] acc ≐ acc

rev (cons n a v) acc ≐ rev v (cons m a acc)

vecA (n + S m)expected: vecA (S n + m) ≠ 3

Page 17: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

ExamplevecA : nat → Type

[] : vecA 0

cons : ∀ n, A → vecA n → vecA (S n)

rev : ∀ {n m}, vecA n → vecA m → vecA (n + m)

rev [] acc ≐ acc

rev (cons n a v) acc ≐ rev v (cons m a acc)

vecA (n + S m)reflection ⇒ vecA (S n + m) ≡ 3

Page 18: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Intensional VS Extensionalp : u = v

u ≡ v

ETT = ITT + reflection

4

Page 19: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Intensional VS Extensionalp : u = v

u ≡ v

ETT = ITT + reflection

What is the relation between the two?

4

Page 20: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Intensional VS ExtensionalWhat is the relation between the two?

1995 Martin HofmannETT is conservative over ITT + K + funext

5

Page 21: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Intensional VS ExtensionalWhat is the relation between the two?

1995 Martin HofmannETT is conservative over ITT + K + funext

5

Page 22: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Intensional VS ExtensionalWhat is the relation between the two?

1995 Martin HofmannETT is conservative over ITT + K + funext

K : ∀ A (x : A) (e : x = x), e = refl x

5

Page 23: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Intensional VS ExtensionalWhat is the relation between the two?

1995 Martin HofmannETT is conservative over ITT + K + funext

K : ∀ A (x : A) (e : x = x), e = refl x

funext : ∀ A B (f g : A → B), (∀ (x : A), f x = g x) → f = g

5

Page 24: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Intensional VS ExtensionalWhat is the relation between the two?

2005 Nicolas OuryETT can be translated to ITT + K + funext + ?

K : ∀ A (x : A) (e : x = x), e = refl x

funext : ∀ A B (f g : A → B), (∀ (x : A), f x = g x) → f = g

6

Page 25: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Intensional VS ExtensionalWhat is the relation between the two?

2005 Nicolas OuryETT can be translated to ITT + K + funext + ?

K : ∀ A (x : A) (e : x = x), e = refl x

funext : ∀ A B (f g : A → B), (∀ (x : A), f x = g x) → f = g

‘?’ : « heterogenous equality is a congruence for application »6

Page 26: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Intensional VS ExtensionalWhat is the relation between the two?

TODAYETT can be translated to ITT + K + funext

K : ∀ A (x : A) (e : x = x), e = refl x

funext : ∀ A B (f g : A → B), (∀ (x : A), f x = g x) → f = g

‘?’ : « heterogenous equality is a congruence for application »7

Page 27: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Intensional VS ExtensionalWhat is the relation between the two?

TODAYETT can be translated to ITT + K + funext

K : ∀ A (x : A) (e : x = x), e = refl x

funext : ∀ A B (f g : A → B), (∀ (x : A), f x = g x) → f = g

‘?’ : « heterogenous equality is a congruence for application »7

Page 28: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Intensional VS ExtensionalWhat is the relation between the two?

TODAYETT can be translated to ITT + K + funext

8

Page 29: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Intensional VS ExtensionalWhat is the relation between the two?

TODAYETT can be translated to ITT + K + funext

+ Minimal (axiom-wise)

+ Constructive (formalised in Coq)

+ Computes (produces Coq terms)8

Page 30: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Fundamental differenceOury Hofmann / us

9

Page 31: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Fundamental differenceOury Hofmann / us

Minimal annotations

λ(x : A).t

t u

9

Page 32: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Fundamental differenceOury Hofmann / us

Minimal annotations Fully annotated terms

λ(x : A).t

t u

λ(x : A).B.t

t @(x:A).B u

9

Page 33: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Fundamental differenceOury Hofmann / us

Minimal annotations Fully annotated terms

λ(x : A).t

t u

λ(x : A).B.t

t @(x:A).B u

Blocked β-reduction

(λ(x : A).B.t) @(x:A).B u≡ t[x := u]

9

Page 34: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Fundamental differenceOury Hofmann / us

Minimal annotations Fully annotated terms

λ(x : A).t

t u

λ(x : A).B.t

t @(x:A).B u

Blocked β-reduction

(λ(x : A).B.t) @(x:A).B u≡ t[x := u]

Free β-reduction

(λ(x : A).t) u≡ t[x := u]

9

Page 35: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Fundamental differenceOury Hofmann / us

Free β-reduction Blocked β-reduction

(λ(x : A).B.t) @(x:A).B u≡ t[x := u]

(λ(x : A).t) u≡ t[x := u]

9

Page 36: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Fundamental differenceOury Hofmann / us

Free β-reduction Blocked β-reduction

(λ(x : A).B.t) @(x:A).B u≡ t[x := u]

(λ(x : A).x) u≡ x[x := u]

9

Page 37: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Fundamental differenceOury Hofmann / us

Free β-reduction Blocked β-reduction

(λ(x : A).B.t) @(x:A).B u≡ t[x := u]

(λ(x : A).x) u≡ u

9

Page 38: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Fundamental differenceOury Hofmann / us

Free β-reduction Blocked β-reduction

(λ(x : A).B.t) @(x:A).B u≡ t[x := u]

(λ(x : nat).x) 0 ≡ 0

9

Page 39: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Fundamental differenceOury Hofmann / us

Free β-reduction Blocked β-reduction

(λ(x : A).B.t) @(x:A).B u≡ t[x := u]

(λ(x : nat).x) 0 ≡ 0

nat → nat

9

Page 40: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Fundamental differenceOury Hofmann / us

Free β-reduction Blocked β-reduction

(λ(x : A).B.t) @(x:A).B u≡ t[x := u]

(λ(x : nat).x) 0 ≡ 0

nat → nat

≡ nat → bool

9

under consistent context

Page 41: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Fundamental differenceOury Hofmann / us

Free β-reduction Blocked β-reduction

(λ(x : A).B.t) @(x:A).B u≡ t[x := u]

(λ(x : nat).x) 0 ≡ 0

bool

9

Page 42: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Fundamental differenceOury Hofmann / us

Free β-reduction Blocked β-reduction

(λ(x : A).B.t) @(x:A).B u≡ t[x := u]

(λ(x : nat).x) 0 ≡ 0

bool nat

9

Page 43: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Fundamental differenceOury Hofmann / us

Free β-reduction Blocked β-reduction

(λ(x : A).B.t) @(x:A).B u≡ t[x := u]

(λ(x : nat).x) 0 ≡ 0

bool nat≠

9

under consistent context

Page 44: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Fundamental differenceOury Hofmann / us

Free β-reduction Blocked β-reduction

(λ(x : A).B.t) @(x:A).B u≡ t[x := u]

(λ(x : nat).x) 0 ≡ 0

bool nat≠

No Uniqueness of type

No Subject reductionOR

9

Page 45: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Fundamental differenceOury Hofmann / us

Free β-reduction Blocked β-reduction

(λ(x : A).B.t) @(x:A).B u≡ t[x := u]

(λ(x : nat).x) 0 ≡ 0

bool nat≠

No Uniqueness of type

No Subject reductionOR

Uniqueness of typeandΓ ⊢ t : A Γ ⊢ t : B

⇒ Γ ⊢ A ≡ B 9

Page 46: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Principle of the translationETT ITT

10

Page 47: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Principle of the translationETT ITT

Typing derivation Well typed term

10

Page 48: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Principle of the translationETT ITT

Typing derivation Well typed term

Γ’ ⊢i t’ : A’

Γ ⊢x t : A

… ……… ⋮⋮⋮

10

Page 49: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Principle of the translationETT ITT

Typing derivation Well typed term

Γ’ ⊢i t’ : A’

Γ ⊢x t : A

… ……… ⋮⋮⋮

Idea: Conversion is translated to transport.10

Page 50: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Principle of the translationETT ITT

Typing derivation Well typed term

Γ’ ⊢i t’ : B’

Γ ⊢x t : A

⋮⋮

Idea: Conversion is translated to transport.

Γ ⊢x t : B Γ ⊢x B ≡ A Γ’ ⊢i e : B’ = A’

Γ’ ⊢i transp(e,t’) : A’⇓

10

Page 51: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Principle of the translationETT ITT

Typing derivation Well typed term

Γ’ ⊢i t’ : B’

Γ ⊢x t : A

⋮⋮

Idea: Conversion is translated to transport.

Γ ⊢x t : B Γ ⊢x B ≡ A Γ’ ⊢i e : B’ = A’

Γ’ ⊢i transp(e,t’) : A’⇓

⇒ Coherence problems10

Page 52: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Heterogenous equality

a A=B b

11

Page 53: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Heterogenous equality

a A=B b

≐ ∑ (p : A = B), transp(p,a) = b

11

Page 54: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Terms up to transportt ∼ t’

t ∼ transp(e,t’)

12

Page 55: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Terms up to transportt ∼ t’

t ∼ transp(e,t’) t @(x:A).B u ∼ t’ @(x:A’).B’ u’

t ∼ t’ A ∼ A’ B ∼ B’ u ∼ u’

12

Page 56: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Terms up to transportt ∼ t’

t ∼ transp(e,t’) t @(x:A).B u ∼ t’ @(x:A’).B’ u’

t ∼ t’ A ∼ A’ B ∼ B’ u ∼ u’…

12

Page 57: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Terms up to transportt ∼ t’

t ∼ transp(e,t’) t @(x:A).B u ∼ t’ @(x:A’).B’ u’

t ∼ t’ A ∼ A’ B ∼ B’ u ∼ u’…

t is translated to t’ with t ∼ t’Invariant

12

Page 58: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Terms up to transportt ∼ t’

t ∼ transp(e,t’) t @(x:A).B u ∼ t’ @(x:A’).B’ u’

t ∼ t’ A ∼ A’ B ∼ B’ u ∼ u’…

t is translated to t’ with t ∼ t’Invariant

Given Γ and t ∼ t’, there exists a term p such that if Γ ⊢i t : A and Γ ⊢i t’ : B then Γ ⊢x p : t A=B t’.

Fundamental lemma

12

Page 59: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Translation⊢x Γ ∑ Γᵗ ∼ Γ, ⊢i Γᵗif then

13

Page 60: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Translation⊢x Γ ∑ Γᵗ ∼ Γ, ⊢i Γᵗif then

∀ Γᵗ ∼ Γ, ⊢i Γᵗ → ∑ (tᵗ ∼ t) (Aᵗ ∼ A), Γᵗ ⊢i tᵗ : AᵗΓ ⊢x t : Aif then

13

Page 61: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Translation⊢x Γ ∑ Γᵗ ∼ Γ, ⊢i Γᵗif then

∀ Γᵗ ∼ Γ, ⊢i Γᵗ → ∑ (tᵗ ∼ t) (Aᵗ ∼ A), Γᵗ ⊢i tᵗ : AᵗΓ ⊢x t : Aif then

13

∀ Γᵗ ∼ Γ, ⊢i Γᵗ → ∑ (tᵗ ∼ t) (Aᵗ ∼ A) (uᵗ ∼ u) (Aˢ ∼ A) p,Γ ⊢x t ≡ u : Aif then

Γᵗ ⊢i p : tᵗ Aᵗ=Aˢ uᵗ

Page 62: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Conclusion

ETT ITT + K + funext

Term

Typing derivation

+

Term

Typing derivation

+

Translation relation

+

Translation

Page 63: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Conclusion

ETT ITT + K + funext

Term

Typing derivation

+

Term

Typing derivation

+

Translation relation

+

Translation

HTS Two Level TTOR OR

Page 64: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Conclusion

Coq + K + funextETT ITT + K + funext

Term

Typing derivation+

Term

Typing derivation

+

Translation relation+

Term

Translation Reflection (TemplateCoq)

Coq

Untyped Term

Reflection (TemplateCoq)

HTS Two Level TTOR OR

Page 65: Eliminating reflection€¦ · reflection 㱺 vec A (S n + m) ... u ≡ v ETT = ITT + reflection 4. Intensional VS Extensional p : u = v u ≡ v ETT = ITT + reflection What is

Conclusion

https://github.com/TheoWinterhalter/ett-to-itt

Coq + K + funextETT ITT + K + funext

Term

Typing derivation+

Term

Typing derivation

+

Translation relation+

Term

Translation Reflection (TemplateCoq)

Coq

Untyped Term

Reflection (TemplateCoq)

HTS Two Level TTOR OR