RETT, a Reasonably Exceptional Type Theory Pierre-Marie Pdrot 1 , - - PowerPoint PPT Presentation

rett a reasonably exceptional type theory
SMART_READER_LITE
LIVE PREVIEW

RETT, a Reasonably Exceptional Type Theory Pierre-Marie Pdrot 1 , - - PowerPoint PPT Presentation

RETT, a Reasonably Exceptional Type Theory Pierre-Marie Pdrot 1 , Nicolas Tabareau 1 , Hans Fehrmann 2 , ric Tanter 1, 2 ICFP 2019 Pdrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 1 / 19 1 INRIA, 2


slide-1
SLIDE 1

RETT, a Reasonably Exceptional Type Theory

Pierre-Marie Pédrot1, Nicolas Tabareau1, Hans Fehrmann2, Éric Tanter1, 2

1INRIA, 2University of Chile

ICFP 2019

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 1 / 19

slide-2
SLIDE 2

It’s time to CIC ass and chew bubble-gum CIC, the Calculus of Inductive Constructions.

CIC, a very fancy intuitionistic logical system. Not just higher-order logic, not just fjrst-order logic First class notion of computation and crazy inductive types CIC, a very powerful functional programming language. Finest types to describe your programs No clear phase separation between runtime and compile time

The Pinnacle of the Curry-Howard correspondence

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 2 / 19

slide-3
SLIDE 3

It’s time to CIC ass and chew bubble-gum CIC, the Calculus of Inductive Constructions.

CIC, a very fancy intuitionistic logical system. Not just higher-order logic, not just fjrst-order logic First class notion of computation and crazy inductive types CIC, a very powerful functional programming language. Finest types to describe your programs No clear phase separation between runtime and compile time

The Pinnacle of the Curry-Howard correspondence

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 2 / 19

slide-4
SLIDE 4

It’s time to CIC ass and chew bubble-gum CIC, the Calculus of Inductive Constructions.

CIC, a very fancy intuitionistic logical system. Not just higher-order logic, not just fjrst-order logic First class notion of computation and crazy inductive types CIC, a very powerful functional programming language. Finest types to describe your programs No clear phase separation between runtime and compile time

The Pinnacle of the Curry-Howard correspondence

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 2 / 19

slide-5
SLIDE 5

It’s time to CIC ass and chew bubble-gum CIC, the Calculus of Inductive Constructions.

CIC, a very fancy intuitionistic logical system. Not just higher-order logic, not just fjrst-order logic First class notion of computation and crazy inductive types CIC, a very powerful functional programming language. Finest types to describe your programs No clear phase separation between runtime and compile time

The Pinnacle of the Curry-Howard correspondence

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 2 / 19

slide-6
SLIDE 6

The Cake is Not Not a Lie

¿ CIC, a very powerful functional programming language ?

... as long as you can live in purely functional fantasyland

No native efgects (not even non-termination!) Haskell monadic style awkward with dependent types What is even the point of using Coq then?

CIC, a not so great efgectful programming language ☹

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 3 / 19

slide-7
SLIDE 7

The Cake is Not Not a Lie

¿ CIC, a very powerful functional programming language ?

... as long as you can live in purely functional fantasyland

No native efgects (not even non-termination!) Haskell monadic style awkward with dependent types What is even the point of using Coq then?

CIC, a not so great efgectful programming language ☹

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 3 / 19

slide-8
SLIDE 8

The Cake is Not Not a Lie

¿ CIC, a very powerful functional programming language ?

... as long as you can live in purely functional fantasyland

No native efgects (not even non-termination!) Haskell monadic style awkward with dependent types What is even the point of using Coq then?

CIC, a not so great efgectful programming language ☹

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 3 / 19

slide-9
SLIDE 9

Tainting CIC with Impurities

We have been working on extending CIC with side-efgects.

To program more, but also to prove more Justifjcation via compilation (more on that soon) A lot of interesting stufg to say but time is pressing Efgect du jour We will concentrate today on only one particular, simple efgect.

EXCEPTIONS!

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 4 / 19

slide-10
SLIDE 10

Tainting CIC with Impurities

We have been working on extending CIC with side-efgects.

To program more, but also to prove more Justifjcation via compilation (more on that soon) A lot of interesting stufg to say but time is pressing Efgect du jour We will concentrate today on only one particular, simple efgect.

EXCEPTIONS!

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 4 / 19

slide-11
SLIDE 11

Tainting CIC with Impurities

We have been working on extending CIC with side-efgects.

To program more, but also to prove more Justifjcation via compilation (more on that soon) A lot of interesting stufg to say but time is pressing Efgect du jour We will concentrate today on only one particular, simple efgect.

EXCEPTIONS!

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 4 / 19

slide-12
SLIDE 12

Tainting CIC with Impurities

We have been working on extending CIC with side-efgects.

To program more, but also to prove more Justifjcation via compilation (more on that soon) A lot of interesting stufg to say but time is pressing Efgect du jour We will concentrate today on only one particular, simple efgect.

EXCEPTIONS!

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 4 / 19

slide-13
SLIDE 13

Summary of the Previous Episodes

Pédrot & Tabareau, ESOP 2018

ExTT, an extension of CIC with exceptions.

▷ Add a failure mechanism to CIC ▷ Fully computational call-by-name exceptions ▷ Contains the whole of CIC (including krazy dependent stufg) ▷ Compiled away to vanilla CIC (so-called syntactic model)

Let’s have a look at ExTT!

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 5 / 19

slide-14
SLIDE 14

Summary of the Previous Episodes

Pédrot & Tabareau, ESOP 2018

ExTT, an extension of CIC with exceptions.

▷ Add a failure mechanism to CIC ▷ Fully computational call-by-name exceptions ▷ Contains the whole of CIC (including krazy dependent stufg) ▷ Compiled away to vanilla CIC (so-called syntactic model)

Let’s have a look at ExTT!

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 5 / 19

slide-15
SLIDE 15

The Exceptional Type Theory: Overview

ExTT extends CIC with an exception-raising primitive (ITT: no payload). raise : ΠA : □. A

raise (Πx : A. B) ≡ λx : A. raise B match (raise I) ret P with ⃗ p ≡ raise (P (raise I))

They can be caught on inductive types via a generalization of eliminators.

rec

P P true P false b P b catch P P true P false P raise b P b catch P pt pf pe true pt catch P pt pf pe false pf catch P pt pf pe raise pe

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 6 / 19

slide-16
SLIDE 16

The Exceptional Type Theory: Overview

ExTT extends CIC with an exception-raising primitive (ITT: no payload). raise : ΠA : □. A

raise (Πx : A. B) ≡ λx : A. raise B match (raise I) ret P with ⃗ p ≡ raise (P (raise I))

They can be caught on inductive types via a generalization of eliminators.

Brec : ΠP : B → □. P true → P false → Πb : B. P b

catchB : ΠP : B → □. P true → P false → P (raise B) → Πb : B. P b catchB P pt pf pe true ≡ pt catchB P pt pf pe false ≡ pf catchB P pt pf pe (raise B) ≡ pe

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 6 / 19

slide-17
SLIDE 17

Exception is the Rule

While a fairly simple efgect, exceptions are already super useful!

Dead code stays so.

« Come on Coq, I know this branch cannot occur! »

Use raise.

Post-hoc reasoning.

« Why do I need to thread decidable hypotheses everywhere? »

Use raise.

Failure as a default.

« Why on earth do I have to return an option? »

Use raise.

Typical problems from the wild: mathcomp, hs-to-coq...

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 7 / 19

slide-18
SLIDE 18

Exception is the Rule

While a fairly simple efgect, exceptions are already super useful!

Dead code stays so.

« Come on Coq, I know this branch cannot occur! »

Use raise.

Post-hoc reasoning.

« Why do I need to thread decidable hypotheses everywhere? »

Use raise.

Failure as a default.

« Why on earth do I have to return an option? »

Use raise.

Typical problems from the wild: mathcomp, hs-to-coq...

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 7 / 19

slide-19
SLIDE 19

Exception is the Rule

While a fairly simple efgect, exceptions are already super useful!

Dead code stays so.

« Come on Coq, I know this branch cannot occur! »

Use raise.

Post-hoc reasoning.

« Why do I need to thread decidable hypotheses everywhere? »

Use raise.

Failure as a default.

« Why on earth do I have to return an option? »

Use raise.

Typical problems from the wild: mathcomp, hs-to-coq...

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 7 / 19

slide-20
SLIDE 20

Exception is the Rule

While a fairly simple efgect, exceptions are already super useful!

Dead code stays so.

« Come on Coq, I know this branch cannot occur! »

Use raise.

Post-hoc reasoning.

« Why do I need to thread decidable hypotheses everywhere? »

Use raise.

Failure as a default.

« Why on earth do I have to return an option? »

Use raise.

Typical problems from the wild: mathcomp, hs-to-coq...

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 7 / 19

slide-21
SLIDE 21

Bottom Model How do we prove that ExTT makes any sense?

We want a justifjcation for what we are doing What about normalization? Subject reduction? Other nice properties?

We want a model of the exceptional type theory!

« CIC, the LLVM of Type Theory »

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 8 / 19

slide-22
SLIDE 22

Bottom Model How do we prove that ExTT makes any sense?

We want a justifjcation for what we are doing What about normalization? Subject reduction? Other nice properties?

We want a model of the exceptional type theory!

« CIC, the LLVM of Type Theory »

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 8 / 19

slide-23
SLIDE 23

Bottom Model How do we prove that ExTT makes any sense?

We want a justifjcation for what we are doing What about normalization? Subject reduction? Other nice properties?

We want a model of the exceptional type theory!

« CIC, the LLVM of Type Theory »

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 8 / 19

slide-24
SLIDE 24

The Exceptional Implementation (sketch)

A Truly Simple Model!

⊢ExTT A : □ ⇝ ⊢CIC [ [A] ] : □ + ⊢CIC [A]∅ : [ [A] ] ⊢ExTT M : A ⇝ ⊢CIC [M] : [ [A] ] Every exceptional type comes with its own implementation of failure! A A x A B x A B x A B x A B M raise A A

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 9 / 19

slide-25
SLIDE 25

The Exceptional Implementation (sketch)

A Truly Simple Model!

⊢ExTT A : □ ⇝ ⊢CIC [ [A] ] : □ + ⊢CIC [A]∅ : [ [A] ] ⊢ExTT M : A ⇝ ⊢CIC [M] : [ [A] ] Every exceptional type comes with its own implementation of failure! [ [□] ] := ΣA : □. A [ [Πx : A. B] ] := Πx : [ [A] ]. [ [B] ] x A B x A B M raise A A

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 9 / 19

slide-26
SLIDE 26

The Exceptional Implementation (sketch)

A Truly Simple Model!

⊢ExTT A : □ ⇝ ⊢CIC [ [A] ] : □ + ⊢CIC [A]∅ : [ [A] ] ⊢ExTT M : A ⇝ ⊢CIC [M] : [ [A] ] Every exceptional type comes with its own implementation of failure! [ [□] ] := ΣA : □. A [ [Πx : A. B] ] := Πx : [ [A] ]. [ [B] ] [□]∅ := . . . [Πx : A. B]∅ := λx : [ [A] ]. [B]∅ M raise A A

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 9 / 19

slide-27
SLIDE 27

The Exceptional Implementation (sketch)

A Truly Simple Model!

⊢ExTT A : □ ⇝ ⊢CIC [ [A] ] : □ + ⊢CIC [A]∅ : [ [A] ] ⊢ExTT M : A ⇝ ⊢CIC [M] : [ [A] ] Every exceptional type comes with its own implementation of failure! [ [□] ] := ΣA : □. A [ [Πx : A. B] ] := Πx : [ [A] ]. [ [B] ] [□]∅ := . . . [Πx : A. B]∅ := λx : [ [A] ]. [B]∅ [M] := . . . [raise A] := [A]∅

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 9 / 19

slide-28
SLIDE 28

The Exceptional Implementation, Positive case

Add an error case to every inductive type!

Inductive [ [B] ] := [true] : [ [B] ] | [false] : [ [B] ] | B∅ : [ [B] ] Pattern-matching is translated pointwise, except for the new case. P P true P false b P b P P true P false b P b If b is true , use fjrst hypothesis If b is false , use second hypothesis If b is an error , reraise using P b

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 10 / 19

slide-29
SLIDE 29

The Exceptional Implementation, Positive case

Add an error case to every inductive type!

Inductive [ [B] ] := [true] : [ [B] ] | [false] : [ [B] ] | B∅ : [ [B] ] Pattern-matching is translated pointwise, except for the new case. [ [ΠP : B → □. P true → P false → Πb : B. P b] ] ≡ ΠP : [ [B] ] → [ [□] ]. P [true] → P [false] → Πb : [ [B] ]. P b If b is [true], use fjrst hypothesis If b is [false], use second hypothesis If b is an error B∅, reraise using [P b]∅

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 10 / 19

slide-30
SLIDE 30

Where is the fjsh?

Theorem

ExTT contains CIC... but it also proves everything. 😗 (Use raise!) An Impure Dependently-typed Programming Language Do you whine about the fact that OCaml is logically inconsistent?

Theorem (Exceptional Canonicity a.k.a. Progress a.k.a. Meaningless explanations)

If

ExTT M

, then M raise .

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 11 / 19

slide-31
SLIDE 31

Where is the fjsh?

Theorem

ExTT contains CIC...but it also proves everything. 😗 (Use raise!) An Impure Dependently-typed Programming Language Do you whine about the fact that OCaml is logically inconsistent?

Theorem (Exceptional Canonicity a.k.a. Progress a.k.a. Meaningless explanations)

If

ExTT M

, then M raise .

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 11 / 19

slide-32
SLIDE 32

Where is the fjsh?

Theorem

ExTT contains CIC...but it also proves everything. 😗 (Use raise!) An Impure Dependently-typed Programming Language Do you whine about the fact that OCaml is logically inconsistent?

Theorem (Exceptional Canonicity a.k.a. Progress a.k.a. Meaningless explanations)

If

ExTT M

, then M raise .

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 11 / 19

slide-33
SLIDE 33

Where is the fjsh?

Theorem

ExTT contains CIC...but it also proves everything. 😗 (Use raise!) An Impure Dependently-typed Programming Language Do you whine about the fact that OCaml is logically inconsistent?

Theorem (Exceptional Canonicity a.k.a. Progress a.k.a. Meaningless explanations)

If ⊢ExTT M : ⊥, then M ≡ raise ⊥.

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 11 / 19

slide-34
SLIDE 34

With Great Efgects Come Great Responsibility

In ESOP 2018 we described pExTT, a consistent restriction of ExTT. Variant of Bernardy-Lasson style parametricity (syntactic model) Toplevel exceptions forbidden, but can still be raised locally (meh)

CIC ⊊ pExTT ⊊ ExTT Now we have a dilemma!

ExTT pExTT

☹ Inconsistent ☺ Unrestricted use of exceptions ☺ Good for programming ☺ Consistent ☹ Exceptions virtually unusable ☹ Strange logical properties

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 12 / 19

slide-35
SLIDE 35

With Great Efgects Come Great Responsibility

In ESOP 2018 we described pExTT, a consistent restriction of ExTT. Variant of Bernardy-Lasson style parametricity (syntactic model) Toplevel exceptions forbidden, but can still be raised locally (meh)

CIC ⊊ pExTT ⊊ ExTT Now we have a dilemma!

ExTT pExTT

☹ Inconsistent ☺ Unrestricted use of exceptions ☺ Good for programming ☺ Consistent ☹ Exceptions virtually unusable ☹ Strange logical properties

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 12 / 19

slide-36
SLIDE 36

CIC ⊊ pExTT ⊊ ExTT

Tired to have to make a choice? We have the answer! with not one, not two, but three universe hierarchies

Pure Layer

p i

CIC Exceptional Layer

e i

ExTT Mediating Layer

m i

pExTT

Consistent No exceptions For proving Inconsistent Full exceptions For programming Consistent Local exceptions For communication

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 13 / 19

slide-37
SLIDE 37

CIC ⊊ pExTT ⊊ ExTT

Tired to have to make a choice? We have the answer! with not one, not two, but three universe hierarchies

Pure Layer

p i

CIC Exceptional Layer

e i

ExTT Mediating Layer

m i

pExTT

Consistent No exceptions For proving Inconsistent Full exceptions For programming Consistent Local exceptions For communication

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 13 / 19

slide-38
SLIDE 38

CIC ⊊ pExTT ⊊ ExTT

Tired to have to make a choice? We have the answer! with not one, not two, but three universe hierarchies

Pure Layer

p i

CIC Exceptional Layer

e i

ExTT Mediating Layer

m i

pExTT

Consistent No exceptions For proving Inconsistent Full exceptions For programming Consistent Local exceptions For communication

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 13 / 19

slide-39
SLIDE 39

CIC ⊊ pExTT ⊊ ExTT

Tired to have to make a choice? We have the answer! with not one, not two, but three universe hierarchies

Pure Layer □p

i ∼ CIC

Exceptional Layer

e i

ExTT Mediating Layer

m i

pExTT

▷ Consistent ▷ No exceptions ▷ For proving Inconsistent Full exceptions For programming Consistent Local exceptions For communication

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 13 / 19

slide-40
SLIDE 40

CIC ⊊ pExTT ⊊ ExTT

Tired to have to make a choice? We have the answer! with not one, not two, but three universe hierarchies

Pure Layer □p

i ∼ CIC

Exceptional Layer □e

i ∼ ExTT

Mediating Layer

m i

pExTT

▷ Consistent ▷ No exceptions ▷ For proving ▷ Inconsistent ▷ Full exceptions ▷ For programming Consistent Local exceptions For communication

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 13 / 19

slide-41
SLIDE 41

CIC ⊊ pExTT ⊊ ExTT

Tired to have to make a choice? We have the answer! with not one, not two, but three universe hierarchies

Pure Layer □p

i ∼ CIC

Exceptional Layer □e

i ∼ ExTT

Mediating Layer □m

i ∼ pExTT

▷ Consistent ▷ No exceptions ▷ For proving ▷ Inconsistent ▷ Full exceptions ▷ For programming ▷ Consistent ▷ Local exceptions ▷ For communication

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 13 / 19

slide-42
SLIDE 42

At the Crossroads

Every hierarchy in isolation behaves as a variant of CIC

□p

i ∼ CIC

□e

i ∼ ExTT

□m

i ∼ pExTT

“Write programs in

e,

Prove them in

m or p.”

The expressivity of RETT lies in the interaction between hierarchies

A

i

x A B

j

p e m x A B

i j

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 14 / 19

slide-43
SLIDE 43

At the Crossroads

Every hierarchy in isolation behaves as a variant of CIC

□p

i ∼ CIC

□e

i ∼ ExTT

□m

i ∼ pExTT

“Write programs in □e, Prove them in □m or □p.”

The expressivity of RETT lies in the interaction between hierarchies

A

i

x A B

j

p e m x A B

i j

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 14 / 19

slide-44
SLIDE 44

At the Crossroads

Every hierarchy in isolation behaves as a variant of CIC

□p

i ∼ CIC

□e

i ∼ ExTT

□m

i ∼ pExTT

“Write programs in □e, Prove them in □m or □p.”

The expressivity of RETT lies in the interaction between hierarchies

Γ ⊢ A : □α

i

Γ, x : A ⊢ B : □β

j

α, β ∈ {p, e, m} Γ ⊢ Π(x : A). B : □β

i ∨ j

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 14 / 19

slide-45
SLIDE 45

Eliminating Between Hierarchies Eliminating inductive types is even more interesting

CIC Brec : ΠP : B → □. P true → P false → Πb : B. P b ExTT Bcatch : ΠP : B → □. P true → P false → P (raise B) → Πb : B. P b

Depending on the hierarchy of and P we get difgerent eliminators!

P

e m p e

rec catch catch catch

m

rec rec

p

rec rec rec catch does not make sense when source is consistent catch is mandatory when eliminating from inconsistent to consistent reminiscent of the singleton elimination restriction in CIC.

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 15 / 19

slide-46
SLIDE 46

Eliminating Between Hierarchies Eliminating inductive types is even more interesting

CIC Brec : ΠP : B → □. P true → P false → Πb : B. P b ExTT Bcatch : ΠP : B → □. P true → P false → P (raise B) → Πb : B. P b

Depending on the hierarchy of B and P we get difgerent eliminators!

P : B → □β

□e □m □p

B : □α

□e rec/catch catch catch □m rec rec − □p rec rec rec catch does not make sense when source is consistent catch is mandatory when eliminating from inconsistent to consistent reminiscent of the singleton elimination restriction in CIC.

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 15 / 19

slide-47
SLIDE 47

And Much More

We also have modalities for better interoperability

{−}α

β

: □α → □β ια

β

: Π(A : □α). A → {A}α

β

... as well as an internal purity predicate

P : Π(A : □m). {A}m

e → □m

Σ(x : {A}m

e). P A x

∼ = A

Main interest of □m over □p.

(A lot to say, but I don’t have time.)

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 16 / 19

slide-48
SLIDE 48

CoqRETT

We implemented RETT as a POC Coq plugin.

https://github.com/CoqHott/exceptional-tt

Allows to add exceptions to Coq just today. Piggybacks on the Prop/Type segregation (hack hack hack) Compile RETT on the fmy. Not really practical though, should this go into the kernel?

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 17 / 19

slide-49
SLIDE 49

TODO

Actually provide RETT fjrst class in Coq? Use it for programming for realz? Potential applications to Gradual Typing? One hierarchy = one efgect?

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 18 / 19

slide-50
SLIDE 50

TODO

Actually provide RETT fjrst class in Coq? Use it for programming for realz? Potential applications to Gradual Typing? One hierarchy = one efgect?

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 18 / 19

slide-51
SLIDE 51

If You Were Sleeping During The Talk

RETT, a 3-in-1 type theory!

1 An inconsistent dependently-typed efgectful programming language 2 A consistent dependently-typed proof language 3 A consistent dependently-typed mediating language

Smoothly interacting together! All of this justifjed by purely syntactical means! Implemented in your favourite proof assistant!

Pédrot, Tabareau, Fehrmann & Tanter A Reasonably Exceptional Type Theory 21/08/2019 19 / 19