Failure is Not an Option The Curry-Howard-Shadok correspondence - - PowerPoint PPT Presentation

failure is not an option
SMART_READER_LITE
LIVE PREVIEW

Failure is Not an Option The Curry-Howard-Shadok correspondence - - PowerPoint PPT Presentation

Failure is Not an Option The Curry-Howard-Shadok correspondence Pierre-Marie Pdrot joint work with Nicolas Tabareau Max Planck Institute for Software Systems Sminaire PPS P.-M. Pdrot (MPI-SWS) Failure is Not an Option 22/02/2018 1 / 44


slide-1
SLIDE 1

Failure is Not an Option

The Curry-Howard-Shadok correspondence

Pierre-Marie Pédrot joint work with Nicolas Tabareau

Max Planck Institute for Software Systems

Séminaire PPS

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 1 / 44

slide-2
SLIDE 2
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.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 3 / 44

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.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 3 / 44

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.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 3 / 44

slide-6
SLIDE 6

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.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 3 / 44

slide-7
SLIDE 7

Un Coq qui fait de l'efget

My research has been focussed on the extension of CIC with side-efgects.

To Program More!

Obviously you want efgects to program E.g. state, exceptions, non-termination, continuations...

To Prove More!

A well-known fact here at PPS Curry-Howard side-efgects new axioms Archetypical example: callcc and classical logic (Griffjn, Krivine)

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 4 / 44

slide-8
SLIDE 8

Un Coq qui fait de l'efget

My research has been focussed on the extension of CIC with side-efgects.

To Program More!

Obviously you want efgects to program E.g. state, exceptions, non-termination, continuations...

To Prove More!

A well-known fact here at PPS Curry-Howard side-efgects new axioms Archetypical example: callcc and classical logic (Griffjn, Krivine)

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 4 / 44

slide-9
SLIDE 9

Un Coq qui fait de l'efget

My research has been focussed on the extension of CIC with side-efgects.

To Program More!

Obviously you want efgects to program E.g. state, exceptions, non-termination, continuations...

To Prove More!

A well-known fact here at PPS Curry-Howard ⊢ side-efgects ⇔ new axioms Archetypical example: callcc and classical logic (Griffjn, Krivine)

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 4 / 44

slide-10
SLIDE 10

Summary of the Previous Episodes

We already gave two instances of efgectful variants of CIC.

Forcing (LICS 2016)

Bread and butter categorical model factory « Forcing: retour de l’être aimé – permis de conduire – désenvoûtement. » Computationally: a glorifjed monotonous reader monad

Weaning (LICS 2017)

A generic construction adding efgects Handles a rather wide class of monads Somehow dual to forcing

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 5 / 44

slide-11
SLIDE 11

Summary of the Previous Episodes

We already gave two instances of efgectful variants of CIC.

Forcing (LICS 2016)

Bread and butter categorical model factory « Forcing: retour de l’être aimé – permis de conduire – désenvoûtement. » Computationally: a glorifjed monotonous reader monad

Weaning (LICS 2017)

A generic construction adding efgects Handles a rather wide class of monads Somehow dual to forcing

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 5 / 44

slide-12
SLIDE 12

Summary of the Previous Episodes

We already gave two instances of efgectful variants of CIC.

Forcing (LICS 2016)

Bread and butter categorical model factory « Forcing: retour de l’être aimé – permis de conduire – désenvoûtement. » Computationally: a glorifjed monotonous reader monad

Weaning (LICS 2017)

A generic construction adding efgects Handles a rather wide class of monads Somehow dual to forcing

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 5 / 44

slide-13
SLIDE 13

You Can’t Have Your Cake and Eat It Efgects make reduction strategies relevant.

Call-by-value Call-by-name

Weaker conversion rule Full dependent elimination Good old ML semantics Full conversion rule Weaker dependent elimination Strange PL realm

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 6 / 44

slide-14
SLIDE 14

You Can’t Have Your Cake and Eat It Efgects make reduction strategies relevant.

Call-by-value Call-by-name

Weaker conversion rule Full dependent elimination Good old ML semantics Full conversion rule Weaker dependent elimination Strange PL realm

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 6 / 44

slide-15
SLIDE 15

Last Propaganda Slide: A Flurry of Buzzwords

Recall that dependent elimination for booleans amounts to Γ ⊢ M : B Γ ⊢ N1 : P{true} Γ ⊢ N2 : P{false} Γ ⊢ if M then N1 else N2 : P{M} We proposed a generic restriction for efgectful CBN dependent elimination.

P must be linear (

CBV / algebra hom.)

Generalizes Krivine’s storage operators If you weren’t at my Geocal-LAC talk, tant pis pour vous Towards a Linear Dependent {Big Data, Machine Learning, IoT}

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 7 / 44

slide-16
SLIDE 16

Last Propaganda Slide: A Flurry of Buzzwords

Recall that dependent elimination for booleans amounts to Γ ⊢ M : B Γ ⊢ N1 : P{true} Γ ⊢ N2 : P{false} Γ ⊢ if M then N1 else N2 : P{M} We proposed a generic restriction for efgectful CBN dependent elimination.

P must be linear (∼

= CBV / algebra hom.)

Generalizes Krivine’s storage operators If you weren’t at my Geocal-LAC talk, tant pis pour vous Towards a Linear Dependent {Big Data, Machine Learning, IoT}

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 7 / 44

slide-17
SLIDE 17

Shameless Propaganda

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 8 / 44

slide-18
SLIDE 18

Part I

An extension of CIC rooted in Shadok wisdom.

“The more it fails, the more likely it will eventually succeed.”

☺ Add a failure mechanism to CIC ☺ Fully computational exceptions ☺ Features full conversion ☺ Features full dependent elimination 😖 Didn’t I just say this was not possible???

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 9 / 44

slide-19
SLIDE 19

Part I

An extension of CIC rooted in Shadok wisdom.

“The more it fails, the more likely it will eventually succeed.”

☺ Add a failure mechanism to CIC ☺ Fully computational exceptions ☺ Features full conversion ☺ Features full dependent elimination 😖 Didn’t I just say this was not possible???

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 9 / 44

slide-20
SLIDE 20

Part I

An extension of CIC rooted in Shadok wisdom.

“The more it fails, the more likely it will eventually succeed.”

☺ Add a failure mechanism to CIC ☺ Fully computational exceptions ☺ Features full conversion ☺ Features full dependent elimination 😖 Didn’t I just say this was not possible???

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 9 / 44

slide-21
SLIDE 21

Part I

An extension of CIC rooted in Shadok wisdom.

“The more it fails, the more likely it will eventually succeed.”

☺ Add a failure mechanism to CIC ☺ Fully computational exceptions ☺ Features full conversion ☺ Features full dependent elimination 😖 Didn’t I just say this was not possible???

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 9 / 44

slide-22
SLIDE 22

The Exceptional Type Theory: Overview

The exceptional type theory extends vanilla CIC with E : □ raise : ΠA : □. E → A As hinted before, we need to be call-by-name to feature full conversion.

raise x A B e x A raise B e match raise e ret P with p raise P raise e e

where P . Remark that in call-by-name, if M A B, in general M raise A e raise B e for otherwise we would not have x A M N M x N .

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 10 / 44

slide-23
SLIDE 23

The Exceptional Type Theory: Overview

The exceptional type theory extends vanilla CIC with E : □ raise : ΠA : □. E → A As hinted before, we need to be call-by-name to feature full conversion.

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

where P : I → □. Remark that in call-by-name, if M A B, in general M raise A e raise B e for otherwise we would not have x A M N M x N .

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 10 / 44

slide-24
SLIDE 24

The Exceptional Type Theory: Overview

The exceptional type theory extends vanilla CIC with E : □ raise : ΠA : □. E → A As hinted before, we need to be call-by-name to feature full conversion.

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

where P : I → □. Remark that in call-by-name, if M : A → B, in general M (raise A e) ̸≡ raise B e for otherwise we would not have (λx : A. M) N ≡ M{x := N}.

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 10 / 44

slide-25
SLIDE 25

Catch Me If You Can

Remember that on functions:

raise (Πx : A. B) e ≡ λx : A. raise B e

It means catching exceptions is limited to positive datatypes! For inductive types, this is a generalized induction principle.

catch P P true P false e E P raise e b P b

rect

P P true P false b P b

where

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

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 11 / 44

slide-26
SLIDE 26

Catch Me If You Can

Remember that on functions:

raise (Πx : A. B) e ≡ λx : A. raise B e

It means catching exceptions is limited to positive datatypes! For inductive types, this is a generalized induction principle.

catchB : ΠP : B → □. P true → P false → (Πe : E. P (raise B e)) → Πb : B. P b Brect : ΠP : B → □. P true → P false → Πb : B. P b

where

catchB P pt pf pe true ≡ pt catchB P pt pf pe false ≡ pf catchB P pt pf pe (raise B e) ≡ pe e

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 11 / 44

slide-27
SLIDE 27

Mot d’Ordre: A Model It’s not just randomly coming up with syntax though.

We want a justifjcation for what we are doing What about normalization? Subject reduction? Other nice properties? ... that’s called a model.

We want a model of the exceptional type theory!

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 12 / 44

slide-28
SLIDE 28

Mot d’Ordre: A Model It’s not just randomly coming up with syntax though.

We want a justifjcation for what we are doing What about normalization? Subject reduction? Other nice properties? ... that’s called a model.

We want a model of the exceptional type theory!

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 12 / 44

slide-29
SLIDE 29

Mot d’Ordre: A Model It’s not just randomly coming up with syntax though.

We want a justifjcation for what we are doing What about normalization? Subject reduction? Other nice properties? ... that’s called a model.

We want a model of the exceptional type theory!

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 12 / 44

slide-30
SLIDE 30

Kardashian Functors, Anyone?

Semantics of CIC has a fame of being horribly complex. I won’t lie: it is. But part of this fame is nonetheless due to its models. Set-theoretical models: because Sets are a (crappy) type theory.

Pro: Sets! Con: Sets!

Realizability models: construct programs that respect properties.

Pro: Computational, computer-science friendly. Con: Not foundational (requires an alien meta-theory), not decidable.

Categorical models: abstract description of type theory.

Pro: Abstract, subsumes the two former ones. Con: Realizability + very low level, gazillion variants, intrisically typed, static.

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 13 / 44

slide-31
SLIDE 31

Kardashian Functors, Anyone?

Semantics of CIC has a fame of being horribly complex. I won’t lie: it is. But part of this fame is nonetheless due to its models. Set-theoretical models: because Sets are a (crappy) type theory.

Pro: Sets! Con: Sets!

Realizability models: construct programs that respect properties.

Pro: Computational, computer-science friendly. Con: Not foundational (requires an alien meta-theory), not decidable.

Categorical models: abstract description of type theory.

Pro: Abstract, subsumes the two former ones. Con: Realizability + very low level, gazillion variants, intrisically typed, static.

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 13 / 44

slide-32
SLIDE 32

Kardashian Functors, Anyone?

Semantics of CIC has a fame of being horribly complex. I won’t lie: it is. But part of this fame is nonetheless due to its models. Set-theoretical models: because Sets are a (crappy) type theory.

Pro: Sets! Con: Sets!

Realizability models: construct programs that respect properties.

Pro: Computational, computer-science friendly. Con: Not foundational (requires an alien meta-theory), not decidable.

Categorical models: abstract description of type theory.

Pro: Abstract, subsumes the two former ones. Con: Realizability + very low level, gazillion variants, intrisically typed, static.

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 13 / 44

slide-33
SLIDE 33

Kardashian Functors, Anyone?

Semantics of CIC has a fame of being horribly complex. I won’t lie: it is. But part of this fame is nonetheless due to its models. Set-theoretical models: because Sets are a (crappy) type theory.

Pro: Sets! Con: Sets!

Realizability models: construct programs that respect properties.

Pro: Computational, computer-science friendly. Con: Not foundational (requires an alien meta-theory), not decidable.

Categorical models: abstract description of type theory.

Pro: Abstract, subsumes the two former ones. Con: Realizability + very low level, gazillion variants, intrisically typed, static.

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 13 / 44

slide-34
SLIDE 34

Kardashian Functors, Anyone?

Semantics of CIC has a fame of being horribly complex. I won’t lie: it is. But part of this fame is nonetheless due to its models. Set-theoretical models: because Sets are a (crappy) type theory.

Pro: Sets! Con: Sets!

Realizability models: construct programs that respect properties.

Pro: Computational, computer-science friendly. Con: Not foundational (requires an alien meta-theory), not decidable.

Categorical models: abstract description of type theory.

Pro: Abstract, subsumes the two former ones. Con: Realizability + very low level, gazillion variants, intrisically typed, static.

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 13 / 44

slide-35
SLIDE 35

Curry-Howard Orthodoxy

Instead, let’s look at what Curry-Howard provides in simpler settings.

Logical Interpretations ⇔ Program Translations

On the programming side, implement efgects using e.g. the monadic style. A type transformer T, two combinators, a few equations Interpret mechanically efgectful programs (e.g. in Haskell) On the logic side, extend expressivity through proof translation. Double-negation classical logic (callcc) Friedman’s trick Markov’s rule (exceptions) Forcing CH (global monotonous cell)

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 14 / 44

slide-36
SLIDE 36

Curry-Howard Orthodoxy

Instead, let’s look at what Curry-Howard provides in simpler settings.

Logical Interpretations ⇔ Program Translations

On the programming side, implement efgects using e.g. the monadic style. A type transformer T, two combinators, a few equations Interpret mechanically efgectful programs (e.g. in Haskell) On the logic side, extend expressivity through proof translation. Double-negation classical logic (callcc) Friedman’s trick Markov’s rule (exceptions) Forcing CH (global monotonous cell)

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 14 / 44

slide-37
SLIDE 37

Curry-Howard Orthodoxy

Instead, let’s look at what Curry-Howard provides in simpler settings.

Logical Interpretations ⇔ Program Translations

On the programming side, implement efgects using e.g. the monadic style. A type transformer T, two combinators, a few equations Interpret mechanically efgectful programs (e.g. in Haskell) On the logic side, extend expressivity through proof translation. Double-negation ⇒ classical logic (callcc) Friedman’s trick ⇒ Markov’s rule (exceptions) Forcing ⇒ ¬CH (global monotonous cell)

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 14 / 44

slide-38
SLIDE 38

Syntactic Models

Let us do the same thing with CIC: build syntactic models. Step 0: Fix a theory CIC. Step 1: Defjne

  • n the syntax of

and derive from it s.t. M A implies

CIC M

A Step 2: Flip views and actually pose M A

CIC M

A Step 3: Expand by going down to the CIC assembly language, implementing new terms given by the translation.

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 15 / 44

slide-39
SLIDE 39

Syntactic Models

Let us do the same thing with CIC: build syntactic models. Step 0: Fix a theory T := CIC. Step 1: Defjne

  • n the syntax of

and derive from it s.t. M A implies

CIC M

A Step 2: Flip views and actually pose M A

CIC M

A Step 3: Expand by going down to the CIC assembly language, implementing new terms given by the translation.

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 15 / 44

slide-40
SLIDE 40

Syntactic Models

Let us do the same thing with CIC: build syntactic models. Step 0: Fix a theory T := CIC. Step 1: Defjne [·] on the syntax of T and derive [ [·] ] from it s.t. ⊢T M : A implies ⊢CIC [M] : [ [A] ] Step 2: Flip views and actually pose M A

CIC M

A Step 3: Expand by going down to the CIC assembly language, implementing new terms given by the translation.

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 15 / 44

slide-41
SLIDE 41

Syntactic Models

Let us do the same thing with CIC: build syntactic models. Step 0: Fix a theory T := CIC. Step 1: Defjne [·] on the syntax of T and derive [ [·] ] from it s.t. ⊢T M : A implies ⊢CIC [M] : [ [A] ] Step 2: Flip views and actually pose ⊢T M : A

= ⊢CIC [M] : [ [A] ] Step 3: Expand by going down to the CIC assembly language, implementing new terms given by the translation.

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 15 / 44

slide-42
SLIDE 42

Syntactic Models

Let us do the same thing with CIC: build syntactic models. Step 0: Fix a theory T := CIC. Step 1: Defjne [·] on the syntax of T and derive [ [·] ] from it s.t. ⊢T M : A implies ⊢CIC [M] : [ [A] ] Step 2: Flip views and actually pose ⊢T M : A

= ⊢CIC [M] : [ [A] ] Step 3: Expand T by going down to the CIC assembly language, implementing new terms given by the [·] translation.

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 15 / 44

slide-43
SLIDE 43

« CIC, the LLVM of Type Theory »

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 16 / 44

slide-44
SLIDE 44

The Exceptional Implementation

Let’s implement the exceptional type theory into CIC!

Source is a CBN theory, so usual monadic encoding won’t work. We use a variant of our previous weaning translation. All typing and computations rules mentioned before hold for free. Let’s call the exceptional type theory to disambiguate it from CIC. Only parameter of the translation: a fjxed type of exceptions in the target.

CIC

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 17 / 44

slide-45
SLIDE 45

The Exceptional Implementation

Let’s implement the exceptional type theory into CIC!

Source is a CBN theory, so usual monadic encoding won’t work. We use a variant of our previous weaning translation. All typing and computations rules mentioned before hold for free. Let’s call the exceptional type theory to disambiguate it from CIC. Only parameter of the translation: a fjxed type of exceptions in the target.

CIC

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 17 / 44

slide-46
SLIDE 46

The Exceptional Implementation

Let’s implement the exceptional type theory into CIC!

Source is a CBN theory, so usual monadic encoding won’t work. We use a variant of our previous weaning translation. All typing and computations rules mentioned before hold for free. Let’s call the exceptional type theory TE to disambiguate it from CIC. Only parameter of the translation: a fjxed type of exceptions in the target.

CIC

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 17 / 44

slide-47
SLIDE 47

The Exceptional Implementation

Let’s implement the exceptional type theory into CIC!

Source is a CBN theory, so usual monadic encoding won’t work. We use a variant of our previous weaning translation. All typing and computations rules mentioned before hold for free. Let’s call the exceptional type theory TE to disambiguate it from CIC. Only parameter of the translation: a fjxed type of exceptions in the target. ⊢CIC E : □

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 17 / 44

slide-48
SLIDE 48

The Exceptional Implementation, Negative case

Intuition: ⊢TE A : □ ⇝ ⊢CIC [A] : ΣA : □. E → A. Every exceptional type comes with its own implementation of failure! A A and A A A x A B x A B x A B e x A B e x x M N M N x A M x A M If

CIC M

A then

CIC M

A .

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 18 / 44

slide-49
SLIDE 49

The Exceptional Implementation, Negative case

Intuition: ⊢TE A : □ ⇝ ⊢CIC [A] : ΣA : □. E → A. Every exceptional type comes with its own implementation of failure! [ [A] ] : □ := π1 [A] and [A]∅ : E → [ [A] ] := π2 [A] [ [Πx : A. B] ] ≡ Πx : [ [A] ]. [ [B] ] [Πx : A. B]∅ e ≡ λx : [ [A] ]. [B]∅ e [x] ≡ x [M N] ≡ [M] [N] [λx : A. M] ≡ λx : [ [A] ]. [M] If

CIC M

A then

CIC M

A .

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 18 / 44

slide-50
SLIDE 50

The Exceptional Implementation, Negative case

Intuition: ⊢TE A : □ ⇝ ⊢CIC [A] : ΣA : □. E → A. Every exceptional type comes with its own implementation of failure! [ [A] ] : □ := π1 [A] and [A]∅ : E → [ [A] ] := π2 [A] [ [Πx : A. B] ] ≡ Πx : [ [A] ]. [ [B] ] [Πx : A. B]∅ e ≡ λx : [ [A] ]. [B]∅ e [x] ≡ x [M N] ≡ [M] [N] [λx : A. M] ≡ λx : [ [A] ]. [M] If Γ ⊢CIC M : A then [ [Γ] ] ⊢CIC [M] : [ [A] ].

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 18 / 44

slide-51
SLIDE 51

The Exceptional Implementation, Failure

It is straightforward to implement the failure operation. E : □ raise : ΠA : □. E → A E A A E e e raise A A A A raise Computational rules trivially hold!

raise x A B e x A raise B e x A B e x A B e e x A B e

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 19 / 44

slide-52
SLIDE 52

The Exceptional Implementation, Failure

It is straightforward to implement the failure operation. E : □ raise : ΠA : □. E → A [E] : ΣA : □. E → A [E] := (E, λe : E. e) [raise] : ΠA0 : (ΣA : □. E → A). E → π1 A0 [raise] := π2 Computational rules trivially hold!

raise x A B e x A raise B e x A B e x A B e e x A B e

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 19 / 44

slide-53
SLIDE 53

The Exceptional Implementation, Failure

It is straightforward to implement the failure operation. E : □ raise : ΠA : □. E → A [E] : ΣA : □. E → A [E] := (E, λe : E. e) [raise] : ΠA0 : (ΣA : □. E → A). E → π1 A0 [raise] := π2 Computational rules trivially hold!

[raise (Πx : A. B) e] ≡ [λx : A. raise B e] ≡ ≡ π2 ((Πx : [ [A] ]. [ [B] ]), (λ(e : E) (x : [ [A] ]). π2 [ [B] ] e)) [e] ≡ λx : [ [A] ]. π2 [B] [e]

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 19 / 44

slide-54
SLIDE 54

The Exceptional Implementation, Positive case

The really interesting case is the inductive part of CIC. How to implement [B]∅ : E → [ [B] ]? Could pose and take an arbitrary boolean for ... ... but that would not play well with computation, e.g. catch. Worse, what about ?

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 20 / 44

slide-55
SLIDE 55

The Exceptional Implementation, Positive case

The really interesting case is the inductive part of CIC. How to implement [B]∅ : E → [ [B] ]? Could pose [ [B] ] := B and take an arbitrary boolean for [B]∅... ... but that would not play well with computation, e.g. catch. Worse, what about ?

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 20 / 44

slide-56
SLIDE 56

The Exceptional Implementation, Positive case

The really interesting case is the inductive part of CIC. How to implement [B]∅ : E → [ [B] ]? Could pose [ [B] ] := B and take an arbitrary boolean for [B]∅... ... but that would not play well with computation, e.g. catch. Worse, what about [⊥]∅ : E → [ [⊥] ]?

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 20 / 44

slide-57
SLIDE 57

The Exceptional Implementation, Positive case

Very elegant solution: add a default case to every inductive type!

Inductive [ [B] ] := [true] : [ [B] ] | [false] : [ [B] ] | B∅ : E → [ [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 e, reraise e using P b e

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 21 / 44

slide-58
SLIDE 58

The Exceptional Implementation, Positive case

Very elegant solution: add a default case to every inductive type!

Inductive [ [B] ] := [true] : [ [B] ] | [false] : [ [B] ] | B∅ : E → [ [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∅ e, reraise e using [P b]∅ e

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 21 / 44

slide-59
SLIDE 59

Shadok Logic Strikes Back

Theorem

The exceptional translation interprets all of CIC. ☺ A type theory with efgects! ☺ Compiled away to CIC! ☺ Features full conversion ☺ Features full dependent elimination 😗 Ah, yeah, and also, the theory is inconsistent. It suffjces to raise an exception to inhabit any type.

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 22 / 44

slide-60
SLIDE 60

Shadok Logic Strikes Back

Theorem

The exceptional translation interprets all of CIC. ☺ A type theory with efgects! ☺ Compiled away to CIC! ☺ Features full conversion ☺ Features full dependent elimination 😗 Ah, yeah, and also, the theory is inconsistent. It suffjces to raise an exception to inhabit any type.

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 22 / 44

slide-61
SLIDE 61

Shadok Logic Strikes Back

Theorem

The exceptional translation interprets all of CIC. ☺ A type theory with efgects! ☺ Compiled away to CIC! ☺ Features full conversion ☺ Features full dependent elimination 😗 Ah, yeah, and also, the theory is inconsistent. It suffjces to raise an exception to inhabit any type.

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 22 / 44

slide-62
SLIDE 62

Shadok Logic Strikes Back

Theorem

The exceptional translation interprets all of CIC. ☺ A type theory with efgects! ☺ Compiled away to CIC! ☺ Features full conversion ☺ Features full dependent elimination 😗 Ah, yeah, and also, the theory is inconsistent. It suffjces to raise an exception to inhabit any type.

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 22 / 44

slide-63
SLIDE 63

Consistency: A Social Construct

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 M , then M raise e for some e E. A Safe Target Framework You can still use the CIC target to prove properties about programs! Clifghanger You can prove that a program does not raise uncaught exceptions.

And now for a little ad before the second part of the show!

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 23 / 44

slide-64
SLIDE 64

Consistency: A Social Construct

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 ⊢TE M : ⊥, then M ≡ raise ⊥ e for some e : E. A Safe Target Framework You can still use the CIC target to prove properties about programs! Clifghanger You can prove that a program does not raise uncaught exceptions.

And now for a little ad before the second part of the show!

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 23 / 44

slide-65
SLIDE 65

Consistency: A Social Construct

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 ⊢TE M : ⊥, then M ≡ raise ⊥ e for some e : E. A Safe Target Framework You can still use the CIC target to prove properties about TE programs! Clifghanger You can prove that a program does not raise uncaught exceptions.

And now for a little ad before the second part of the show!

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 23 / 44

slide-66
SLIDE 66

Consistency: A Social Construct

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 ⊢TE M : ⊥, then M ≡ raise ⊥ e for some e : E. A Safe Target Framework You can still use the CIC target to prove properties about TE programs! Clifghanger You can prove that a program does not raise uncaught exceptions.

And now for a little ad before the second part of the show!

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 23 / 44

slide-67
SLIDE 67

Consistency: A Social Construct

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 ⊢TE M : ⊥, then M ≡ raise ⊥ e for some e : E. A Safe Target Framework You can still use the CIC target to prove properties about TE programs! Clifghanger You can prove that a program does not raise uncaught exceptions.

And now for a little ad before the second part of the show!

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 23 / 44

slide-68
SLIDE 68

Informercial — Did You Know?

The exceptional translation is just a principled Friedman’s A-translation! As such, it can be used for classical proof extraction. Informative double-negation A A First-order purifjcation If P is a type, then

CIC P

P . Friedman’s Trick in CIC If P and Q are types,

CIC

p P Q implies

CIC

p P Q.

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 24 / 44

slide-69
SLIDE 69

Informercial — Did You Know?

The exceptional translation is just a principled Friedman’s A-translation! As such, it can be used for classical proof extraction. Informative double-negation [ [¬¬A] ] ∼ = ([ [A] ] → E) → E First-order purifjcation If P is a type, then

CIC P

P . Friedman’s Trick in CIC If P and Q are types,

CIC

p P Q implies

CIC

p P Q.

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 24 / 44

slide-70
SLIDE 70

Informercial — Did You Know?

The exceptional translation is just a principled Friedman’s A-translation! As such, it can be used for classical proof extraction. Informative double-negation [ [¬¬A] ] ∼ = ([ [A] ] → E) → E First-order purifjcation If P is a Σ0

1 type, then ⊢CIC [

[P] ] ↔ P + E. Friedman’s Trick in CIC If P and Q are types,

CIC

p P Q implies

CIC

p P Q.

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 24 / 44

slide-71
SLIDE 71

Informercial — Did You Know?

The exceptional translation is just a principled Friedman’s A-translation! As such, it can be used for classical proof extraction. Informative double-negation [ [¬¬A] ] ∼ = ([ [A] ] → E) → E First-order purifjcation If P is a Σ0

1 type, then ⊢CIC [

[P] ] ↔ P + E. Friedman’s Trick in CIC If P and Q are Σ0

1 types, ⊢CIC Πp : P. ¬¬Q implies ⊢CIC Πp : P. Q.

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 24 / 44

slide-72
SLIDE 72

Part II

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 25 / 44

slide-73
SLIDE 73

If You Joined the Talk Recently

The exceptional type theory is logically inconsistent! Clifghanger (cont.) You can prove that a program does not raise uncaught exceptions. Let’s call valid a program in that “does not raise exceptions”. For instance, there is no valid proof of the only valid booleans are true and false a function is valid if it produces a valid result out of a valid argument

Validity is a type-directed notion!

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 26 / 44

slide-74
SLIDE 74

If You Joined the Talk Recently

The exceptional type theory is logically inconsistent! Clifghanger (cont.) You can prove that a program does not raise uncaught exceptions. Let’s call valid a program in TE that “does not raise exceptions”. For instance, there is no valid proof of ⊥ the only valid booleans are true and false a function is valid if it produces a valid result out of a valid argument

Validity is a type-directed notion!

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 26 / 44

slide-75
SLIDE 75

If You Joined the Talk Recently

The exceptional type theory is logically inconsistent! Clifghanger (cont.) You can prove that a program does not raise uncaught exceptions. Let’s call valid a program in TE that “does not raise exceptions”. For instance, there is no valid proof of ⊥ the only valid booleans are true and false a function is valid if it produces a valid result out of a valid argument

Validity is a type-directed notion!

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 26 / 44

slide-76
SLIDE 76

The Curry-Howard-Shadok Correspondence

Let’s locally write M ⊩ A if M is valid at A. f A B x A x A f x B What? That’s just logical relations. Come on. That’s intuitionistic realizability. Fools ! That’s parametricity. Zo!

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 27 / 44

slide-77
SLIDE 77

The Curry-Howard-Shadok Correspondence

Let’s locally write M ⊩ A if M is valid at A. f ⊩ A → B ≡ ∀x : [ [A] ]. x ⊩ A → f x ⊩ B What? That’s just logical relations. Come on. That’s intuitionistic realizability. Fools ! That’s parametricity. Zo!

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 27 / 44

slide-78
SLIDE 78

The Curry-Howard-Shadok Correspondence

Let’s locally write M ⊩ A if M is valid at A. f ⊩ A → B ≡ ∀x : [ [A] ]. x ⊩ A → f x ⊩ B What? That’s just logical relations. Come on. That’s intuitionistic realizability. Fools ! That’s parametricity. Zo!

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 27 / 44

slide-79
SLIDE 79

The Curry-Howard-Shadok Correspondence

Let’s locally write M ⊩ A if M is valid at A. f ⊩ A → B ≡ ∀x : [ [A] ]. x ⊩ A → f x ⊩ B What? That’s just logical relations. Come on. That’s intuitionistic realizability. Fools ! That’s parametricity. Zo!

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 27 / 44

slide-80
SLIDE 80

The Curry-Howard-Shadok Correspondence

Let’s locally write M ⊩ A if M is valid at A. f ⊩ A → B ≡ ∀x : [ [A] ]. x ⊩ A → f x ⊩ B What? That’s just logical relations. Come on. That’s intuitionistic realizability. Fools ! That’s parametricity. Zo!

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 27 / 44

slide-81
SLIDE 81

The Curry-Howard-Shadok Correspondence

Let’s locally write M ⊩ A if M is valid at A. f ⊩ A → B ≡ ∀x : [ [A] ]. x ⊩ A → f x ⊩ B What? That’s just logical relations. Come on. That’s intuitionistic realizability. Fools ! That’s parametricity. Zo!

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 27 / 44

slide-82
SLIDE 82

Making Everybody Agree

It’s actually folklore that these techniques are essentially the same. And there is already a parametricity translation for CIC! (Bernardy-Lasson)

We just have to adapt it to our exceptional translation.

Idea: From M A produce two sequents

CIC M

A

CIC M

A M where A A is the validity predicate.

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 28 / 44

slide-83
SLIDE 83

Making Everybody Agree

It’s actually folklore that these techniques are essentially the same. And there is already a parametricity translation for CIC! (Bernardy-Lasson)

We just have to adapt it to our exceptional translation.

Idea: From M A produce two sequents

CIC M

A

CIC M

A M where A A is the validity predicate.

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 28 / 44

slide-84
SLIDE 84

Making Everybody Agree

It’s actually folklore that these techniques are essentially the same. And there is already a parametricity translation for CIC! (Bernardy-Lasson)

We just have to adapt it to our exceptional translation.

Idea: From ⊢ M : A produce two sequents      ⊢CIC [M] : [ [A] ] + ⊢CIC [M]ε : [ [A] ]ε [M] where [ [A] ]ε : [ [A] ] → □ is the validity predicate.

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 28 / 44

slide-85
SLIDE 85

Parametric Exceptional Translation (Sketch)

Most notably, [ [Πx : A. B] ]ε f ≡ Π(x : [ [A] ]) (xε : [ [A] ]ε x). [ [B] ]ε (f x) [ [B] ]ε b ∼ = b = [true] + b = [false] [ [⊥] ]ε s ∼ = ⊥ Every pure term is now automatically parametric. If

CIC M

A then

CIC M

A M .

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 29 / 44

slide-86
SLIDE 86

Parametric Exceptional Translation (Sketch)

Most notably, [ [Πx : A. B] ]ε f ≡ Π(x : [ [A] ]) (xε : [ [A] ]ε x). [ [B] ]ε (f x) [ [B] ]ε b ∼ = b = [true] + b = [false] [ [⊥] ]ε s ∼ = ⊥ Every pure term is now automatically parametric. If Γ ⊢CIC M : A then [ [Γ] ]ε ⊢CIC [M]ε : [ [A] ]ε [M].

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 29 / 44

slide-87
SLIDE 87

A Few Nice Results

Let’s call T p

E the resulting theory. It inherits a lot from CIC!

Theorem (Consistency)

T p

E is consistent.

Theorem (Canonicity)

T p

E enjoys canonicity, i.e if ⊢T p

E M : N then M ⇝∗ ¯

n ∈ ¯ N.

Theorem (Syntax)

T p

E has decidable type-checking, strong normalization and whatnot.

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 30 / 44

slide-88
SLIDE 88

What If There Were No Cake?

Bernardy-Lasson parametricity is a conservative extension of CIC...

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 31 / 44

slide-89
SLIDE 89

What If There Were No Cake?

Bernardy-Lasson parametricity is a conservative extension of CIC...

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 31 / 44

slide-90
SLIDE 90

What If There Were No Cake?

Bernardy-Lasson parametricity is a conservative extension of CIC...

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 31 / 44

slide-91
SLIDE 91

Less Is More

Spoiler

T p

E is not a conservative extension of CIC.

Intuitively, raising uncaught exceptions is forbidden in

p

... but you can still raise them locally ... as long as you prove they don’t escape! is the unsafe Coq fragment, and

p a semantical layer atop of it.

Actually

p is the embodiement of Kreisel modifjed realizability in CIC.

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 32 / 44

slide-92
SLIDE 92

Less Is More

Spoiler

T p

E is not a conservative extension of CIC.

Intuitively, raising uncaught exceptions is forbidden in T p

E

... but you can still raise them locally ... as long as you prove they don’t escape! is the unsafe Coq fragment, and

p a semantical layer atop of it.

Actually

p is the embodiement of Kreisel modifjed realizability in CIC.

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 32 / 44

slide-93
SLIDE 93

Less Is More

Spoiler

T p

E is not a conservative extension of CIC.

Intuitively, raising uncaught exceptions is forbidden in T p

E

... but you can still raise them locally ... as long as you prove they don’t escape! is the unsafe Coq fragment, and

p a semantical layer atop of it.

Actually

p is the embodiement of Kreisel modifjed realizability in CIC.

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 32 / 44

slide-94
SLIDE 94

Less Is More

Spoiler

T p

E is not a conservative extension of CIC.

Intuitively, raising uncaught exceptions is forbidden in T p

E

... but you can still raise them locally ... as long as you prove they don’t escape! TE is the unsafe Coq fragment, and T p

E a semantical layer atop of it.

Actually

p is the embodiement of Kreisel modifjed realizability in CIC.

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 32 / 44

slide-95
SLIDE 95

Less Is More

Spoiler

T p

E is not a conservative extension of CIC.

Intuitively, raising uncaught exceptions is forbidden in T p

E

... but you can still raise them locally ... as long as you prove they don’t escape! TE is the unsafe Coq fragment, and T p

E a semantical layer atop of it.

Actually T p

E is the embodiement of Kreisel modifjed realizability in CIC.

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 32 / 44

slide-96
SLIDE 96

Explaining the Analogy

Kreisel realizability T p

E

Source theory HA or HAω CIC Programming language System T TE (“unsafe Coq”) Logical meta-theory HAω CIC Kreisel realizability extends arithmetic with essentially two principles. AC n m P m n f n P n f n IP A n P n n A P n

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 33 / 44

slide-97
SLIDE 97

Explaining the Analogy

Kreisel realizability T p

E

Source theory HA or HAω CIC Programming language System T TE (“unsafe Coq”) Logical meta-theory HAω CIC Kreisel realizability extends arithmetic with essentially two principles. ACN : (∀n : N. ∃m : N. P (m, n)) → ∃f : N → N. ∀n : N. P (n, f n) IP : (¬A → ∃n : N. P n) → ∃n : N. ¬A → P n

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 33 / 44

slide-98
SLIDE 98

Choice

ACN : (∀n : N. ∃m : N. P (m, n)) → ∃f : N → N. ∀n : N. P (n, f n) Not much to say here. In Kreisel realizability, ACN is a consequence of canonicity of System T. In

p, AC

is a consequence of dependent elimination. The latter is in turn meta-theoretically justifjed by canonicity. In both cases, choice is built-in and a consequence of canonicity.

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 34 / 44

slide-99
SLIDE 99

Choice

ACN : (∀n : N. ∃m : N. P (m, n)) → ∃f : N → N. ∀n : N. P (n, f n) Not much to say here. In Kreisel realizability, ACN is a consequence of canonicity of System T. In T p

E , ACN is a consequence of dependent elimination.

The latter is in turn meta-theoretically justifjed by canonicity. In both cases, choice is built-in and a consequence of canonicity.

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 34 / 44

slide-100
SLIDE 100

Choice

ACN : (∀n : N. ∃m : N. P (m, n)) → ∃f : N → N. ∀n : N. P (n, f n) Not much to say here. In Kreisel realizability, ACN is a consequence of canonicity of System T. In T p

E , ACN is a consequence of dependent elimination.

The latter is in turn meta-theoretically justifjed by canonicity. In both cases, choice is built-in and a consequence of canonicity.

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 34 / 44

slide-101
SLIDE 101

Independence of Premises

IP : (¬A → ∃n : N. P n) → ∃n : N. ¬A → P n That one is interesting! A unforeseen consequence of a subtle bug. Kreisel’s bug Every type of realizers is inhabited. In particular, [ [⊥] ]KR ≡ N. The realizer of IP critically relies on that! Assuming System T had an empty type , and setting

KR

KR is still a model of HA KR still validates AC KR doesn’t validate IP anymore

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 35 / 44

slide-102
SLIDE 102

Independence of Premises

IP : (¬A → ∃n : N. P n) → ∃n : N. ¬A → P n That one is interesting! A unforeseen consequence of a subtle bug. Kreisel’s bug Every type of realizers is inhabited. In particular, [ [⊥] ]KR ≡ N. The realizer of IP critically relies on that! Assuming System T had an empty type 0, and setting [ [⊥] ]KR ≡ 0 KR is still a model of HA KR still validates ACN KR doesn’t validate IP anymore

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 35 / 44

slide-103
SLIDE 103

Volem Independència

IP : (¬A → ∃n : N. P n) → ∃n : N. ¬A → P n

Theorem (CIC + IP)

T p

E validates IP, owing to the fact that in TE, every type is inhabited.

Proof (sketch).

In , build a term ip IP Given f A n P n, apply it to raise A e. If the returned integer is pure, return it with the associated proof. Otherwise, return a dummy integer and failing proof. Easy to show that ip is actually valid in

p.

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 36 / 44

slide-104
SLIDE 104

Volem Independència

IP : (¬A → ∃n : N. P n) → ∃n : N. ¬A → P n

Theorem (CIC + IP)

T p

E validates IP, owing to the fact that in TE, every type is inhabited.

Proof (sketch).

In TE, build a term ip : IP Given f : ¬A → Σn : N. P n, apply it to raise (¬A) e. If the returned integer is pure, return it with the associated proof. Otherwise, return a dummy integer and failing proof. Easy to show that ip is actually valid in T p

E .

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 36 / 44

slide-105
SLIDE 105

Another Result for Free

Recall Markov’s principle: ΠP : N → B. ¬¬(Σn : N. P n = true) → Σn : N. P n = true (MP) Kreisel’s Razor Pick two out of three: {canonicity, IP, MP}. IP MP P n m P m true P n true Together with canonicity, this solves the halting problem. Corollary

p MP and thus

CIC MP.

(This was proved recently by Coquand-Mannaa, although in a completely difgerent way.)

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 37 / 44

slide-106
SLIDE 106

Another Result for Free

Recall Markov’s principle: ΠP : N → B. ¬¬(Σn : N. P n = true) → Σn : N. P n = true (MP) Kreisel’s Razor Pick two out of three: {canonicity, IP, MP}. IP MP P n m P m true P n true Together with canonicity, this solves the halting problem. Corollary

p MP and thus

CIC MP.

(This was proved recently by Coquand-Mannaa, although in a completely difgerent way.)

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 37 / 44

slide-107
SLIDE 107

Another Result for Free

Recall Markov’s principle: ΠP : N → B. ¬¬(Σn : N. P n = true) → Σn : N. P n = true (MP) Kreisel’s Razor Pick two out of three: {canonicity, IP, MP}. IP + MP ⇒ ΠP : N → B. Σn : N. Πm : N. P m = true → P n = true Together with canonicity, this solves the halting problem. Corollary

p MP and thus

CIC MP.

(This was proved recently by Coquand-Mannaa, although in a completely difgerent way.)

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 37 / 44

slide-108
SLIDE 108

Another Result for Free

Recall Markov’s principle: ΠP : N → B. ¬¬(Σn : N. P n = true) → Σn : N. P n = true (MP) Kreisel’s Razor Pick two out of three: {canonicity, IP, MP}. IP + MP ⇒ ΠP : N → B. Σn : N. Πm : N. P m = true → P n = true Together with canonicity, this solves the halting problem. Corollary ̸⊢T p

E MP and thus ̸⊢CIC MP.

(This was proved recently by Coquand-Mannaa, although in a completely difgerent way.)

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 37 / 44

slide-109
SLIDE 109

Function Intensionality

Another interesting consequence that is similar to what happens in KR. T p

E satisfjes defjnitional η-expansion: λx : A. M x ≡ M.

But it violates function extensionality! ⊢T p

E Πi : 1. i = tt

and ⊢T p

E (λi : 1. i) ̸= (λi : 1. tt)

The reason is that there are invalid proofs of . You cannot build them, but they exists as phantom arguments.

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 38 / 44

slide-110
SLIDE 110

Function Intensionality

Another interesting consequence that is similar to what happens in KR. T p

E satisfjes defjnitional η-expansion: λx : A. M x ≡ M.

But it violates function extensionality! ⊢T p

E Πi : 1. i = tt

and ⊢T p

E (λi : 1. i) ̸= (λi : 1. tt)

The reason is that there are invalid proofs of 1. You cannot build them, but they exists as phantom arguments.

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 38 / 44

slide-111
SLIDE 111

What Else?

What kind of similar horrors can we do in T p

E ?

I don’t know! But there are probably lessons to be taken from realizability I’m probably pissing ofg both HoTT and PRL zealots by now

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 39 / 44

slide-112
SLIDE 112

Get You A Larger Coq, Today!

We implemented TE and T p

E in Coq in a plugin.

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

Allows to add exceptions to Coq just today. Compile efgectful terms on the fmy. Allows to reason about them in Coq. Write mind-blowing low-level code!

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 40 / 44

slide-113
SLIDE 113

If You Were Sleeping During The Talk

TE, a type theory that allows failure!

Inconsistent as a logical theory A dependently-typed efgectful programming language Can still be used for proof extraction like Friedman’s A-translation

p, a type theory that allows local failure!

A safe layer atop that enforces consistency Strict superset of CIC: proves IP, funext, disproves MP

Both of them justifjed by purely syntactical means! “The more it fails, the more likely it will eventually succeed.”

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 41 / 44

slide-114
SLIDE 114

If You Were Sleeping During The Talk

TE, a type theory that allows failure!

Inconsistent as a logical theory A dependently-typed efgectful programming language Can still be used for proof extraction like Friedman’s A-translation

T p

E , a type theory that allows local failure!

A safe layer atop TE that enforces consistency Strict superset of CIC: proves IP, ¬funext, disproves MP

Both of them justifjed by purely syntactical means! “The more it fails, the more likely it will eventually succeed.”

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 41 / 44

slide-115
SLIDE 115

If You Were Sleeping During The Talk

TE, a type theory that allows failure!

Inconsistent as a logical theory A dependently-typed efgectful programming language Can still be used for proof extraction like Friedman’s A-translation

T p

E , a type theory that allows local failure!

A safe layer atop TE that enforces consistency Strict superset of CIC: proves IP, ¬funext, disproves MP

Both of them justifjed by purely syntactical means! “The more it fails, the more likely it will eventually succeed.”

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 41 / 44

slide-116
SLIDE 116

If You Were Sleeping During The Talk

TE, a type theory that allows failure!

Inconsistent as a logical theory A dependently-typed efgectful programming language Can still be used for proof extraction like Friedman’s A-translation

T p

E , a type theory that allows local failure!

A safe layer atop TE that enforces consistency Strict superset of CIC: proves IP, ¬funext, disproves MP

Both of them justifjed by purely syntactical means! “The more it fails, the more likely it will eventually succeed.”

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 41 / 44

slide-117
SLIDE 117

TODO When I Have a Permanent Position

TE looks like a good intermediate language for model building The Calculus of Shadok Constructions Potential applications to Gradual Typing? Syntactic models are super cool! Let’s write more!

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 42 / 44

slide-118
SLIDE 118
slide-119
SLIDE 119

Food For Thought

It seems you need to have a name starting with K to name a realizability.

Kleene Kreisel Krivine

P.-M. Pédrot (MPI-SWS) Failure is Not an Option 22/02/2018 44 / 44