Top Banner
Introduction Sequent calculus Benefits The benefits of sequent calculus EtienneMiquey Equipe Gallinee, INRIA LS2N, Universit e de Nantes Logic Mentoring Workshop 22/06/2019 1/ 22
61

The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Jul 20, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

The benefits of sequent calculus

Etienne Miquey

Equipe Galline�e, INRIA

LS2N, Universite de Nantes

Logic Mentoring Workshop

22/06/2019

1/ 22

Page 2: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Forewords

This talk is about:

sequent calculus / Curry-Howard / operational semantics

But also : proofs, programs, type systems, safe computation/compilation, …

A fairy tale

Sequent calculus provides wonderful tools!

Gives principled answers to problems such as:

how to soundly compile ×××?

how to prove normalization of ×××?

how should control operators and ××× interact?

deciding the equivalence of normal forms

2/ 22

Page 3: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Forewords

This talk is about:

sequent calculus / Curry-Howard / operational semantics

But also : proofs, programs, type systems, safe computation/compilation, …

A fairy tale

Sequent calculus provides wonderful tools!

Gives principled answers to problems such as:

how to soundly compile ×××?

how to prove normalization of ×××?

how should control operators and ××× interact?

deciding the equivalence of normal forms

2/ 22

Page 4: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Forewords

This talk is about:

sequent calculus / Curry-Howard / operational semantics

But also : proofs, programs, type systems, safe computation/compilation, …

A fairy tale

Sequent calculus provides wonderful tools!

Gives principled answers to problems such as:

how to soundly compile ×××?

how to prove normalization of ×××?

how should control operators and ××× interact?

deciding the equivalence of normal forms

2/ 22

Page 5: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

ProofsA bit of history, fast-tracked

3/ 22

Page 6: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Once upon a time…

-300

Euclide

Euclide’s Elements4/ 22

Page 7: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Once upon a time…

-300

Euclide

2019

4/ 22

Page 8: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Once upon a time…

-300

Euclide

20191666

Leibniz

Leibniz’scalculus ratiocinator

A crazy dream:

“when there are disputes amongpersons, we can simply say:Let us calculate, without furtherado, to see who is right.”

4/ 22

Page 9: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Once upon a time…

-300

Euclide

20191666

Leibniz

1879

Frege

Frege’s Begri�sschri�:

formal notations

quantifications ∀/∃distinction:

x vs′x ′

signified signifier

Ff

(a C(a)

F(a)

)b

F(b)c d

c = d

F(d)F(c)A(c, d)

4/ 22

Page 10: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Once upon a time…

-300

Euclide

20191666

Leibniz

1879

Frege

1928

Hilbert

Ff

(a C(a)

F(a)

)b

F(b)c d

c = d

F(d)F(c)A(c, d)

Hilbert

Entscheidungsproblem (with Acker-

mann):

To decide if a formula of first-order logic is atautology.

# “to decide” is meant by means of a procedure

4/ 22

Page 11: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Once upon a time…

-300

Euclide

20191666

Leibniz

1879

Frege

1928

Hilbert

Ff

(a C(a)

F(a)

)b

F(b)c d

c = d

F(d)F(c)A(c, d)

1936

Church

Church

λ-calculus - first (negative) answer to the

Entscheidungsproblem !

4/ 22

Page 12: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

A somewhat obvious observation

Deduction rules Typing rules

A ∈ ΓΓ ` A (Ax)

(x : A) ∈ ΓΓ ` x : A (Ax)

Γ,A ` BΓ ` A⇒ B

(→I )Γ,x : A ` t : B

Γ ` λx .t : A→ B(→I )

Γ ` A⇒ B Γ ` AΓ ` B (→E )

Γ ` t : A→ B Γ ` u : AΓ ` t u : B (→E )

5/ 22

Page 13: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Sequent, you said?

Sequent:

Hypotheses A1, . . . ,An ` B Conclusion

Remark:

Γ,A ` BΓ ` A⇒ B

(⇒I ) is almost

[A]....

BA⇒ B

(⇒I )

“a la Gentzen” “a la Prawitz”

… a.k.a. natural deduction

6/ 22

Page 14: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Sequent, you said?

Sequent:

Hypotheses A1, . . . ,An ` B Conclusion

Remark:

Γ,A ` BΓ ` A⇒ B

(⇒I ) is almost

[A]....

BA⇒ B

(⇒I )

“a la Gentzen” “a la Prawitz”

… a.k.a. natural deduction

6/ 22

Page 15: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Gentzen’s sequent calculus (1934)

Sequent:

Hypotheses A1, . . . ,An ` B1, . . . ,Bp Conclusions

Identity rules connect hypotheses/conclusions

Γ ` A,∆ Γ,A ` ∆Γ ` ∆ (Cut)

A ` A (Ax)

Structural rules weaken, contract, permute

Γ ` ∆Γ ` A,∆ (wr )

Γ ` A,A,∆Γ ` A,∆ (cr )

Γ ` σ (∆)Γ ` ∆ (σr ) …

Logical rules le�/right introduction of connectives

Γ,A ` B,∆Γ ` A⇒ B,∆

(⇒r )Γ ` A,∆ Γ,B ` ∆

Γ,A⇒ B ` ∆ (⇒l )Γ ` A,∆ Γ ` B,∆

Γ ` A ∧ B,∆ (∧r )

7/ 22

Page 16: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Gentzen’s sequent calculus (1934)

Sequent:

Hypotheses A1, . . . ,An ` B1, . . . ,Bp Conclusions

Identity rules connect hypotheses/conclusions

Γ ` A,∆ Γ,A ` ∆Γ ` ∆ (Cut)

A ` A (Ax)

Structural rules weaken, contract, permute

Γ ` ∆Γ ` A,∆ (wr )

Γ ` A,A,∆Γ ` A,∆ (cr )

Γ ` σ (∆)Γ ` ∆ (σr ) …

Logical rules le�/right introduction of connectives

Γ,A ` B,∆Γ ` A⇒ B,∆

(⇒r )Γ ` A,∆ Γ,B ` ∆

Γ,A⇒ B ` ∆ (⇒l )Γ ` A,∆ Γ ` B,∆

Γ ` A ∧ B,∆ (∧r )

7/ 22

Page 17: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Gentzen’s sequent calculus (1934)

Sequent:

Hypotheses A1, . . . ,An ` B1, . . . ,Bp Conclusions

Proof-theoretic properties:cut elimination

last rule

subformula

classical logic built-in

7/ 22

Page 18: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Gentzen’s sequent calculus (1934)

Sequent:

Hypotheses A1, . . . ,An ` B1, . . . ,Bp Conclusions

Identity rules connect hypotheses/conclusions

Γ ` A,∆ Γ,A ` ∆Γ ` ∆ (Cut)

A ` A (Ax)

Structural rules weaken, contract, permute

Γ ` ∆Γ ` A,∆ (wr )

Γ ` A,A,∆Γ ` A,∆ (cr )

Γ ` σ (∆)Γ ` ∆ (σr ) …

Logical rules le�/right introduction of connectives

Γ,A ` B,∆Γ ` A⇒ B,∆

(⇒r )Γ ` A,∆ Γ,B ` ∆

Γ,A⇒ B ` ∆ (⇒l )Γ ` A,∆ Γ ` B,∆

Γ ` A ∧ B,∆ (∧r )

7/ 22

Symmetry

Page 19: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

What about the computational content?

8/ 22

Page 20: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Curien-Herbelin’s duality of computation

Gri�in (1990): classical logic � control operator

Starting observation:

Computational duality:

Terms Contexts

·⊥

·⊥

Sequent calculus � abstract machine-like calculus

9/ 22

Page 21: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Curien-Herbelin’s duality of computation

Gri�in (1990): classical logic � control operator

Starting observation:

Computational duality:

Terms Contexts

·⊥

·⊥

Sequent calculus � abstract machine-like calculus9/ 22

Page 22: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Curien-Herbelin’s duality of computation

Gri�in (1990): classical logic � control operator

Starting observation:

Computational duality:

Terms Contexts

·⊥

·⊥

Sequent calculus � abstract machine-like calculus9/ 22

Page 23: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Abstract machine

Reduction

〈t u || e〉 Babs〈t ||u · e〉

〈λx . t ||u · e〉 Babs〈t [u/x] || e〉

Syntax

c ::= 〈t || e〉 commands

terms t ,u ::=variable | x ,y, zapplication | t uλ-abstraction | λx . t

e, f ::= contexts

| ? empty

| t · e application stack

10/ 22

Page 24: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Introducing µ

〈t u || e〉 Babs〈t ||u · e〉

This reduction defines (t u):

It is the term that, when put against | e〉, reduces to 〈t ||u · e〉.

Idea: introduce a more primitive syntax

〈µα . c || e〉 Bµ c [e/α]

t u , µα . 〈t ||u · α〉

(actually the intuitionistic version µ?.c is enough)

11/ 22

Page 25: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Introducing µ

〈t u || e〉 Babs〈t ||u · e〉

This reduction defines (t u):

It is the term that, when put against | e〉, reduces to 〈t ||u · e〉.

Idea: introduce a more primitive syntax

〈µα . c || e〉 Bµ c [e/α]

t u , µα . 〈t ||u · α〉

(actually the intuitionistic version µ?.c is enough)

11/ 22

Page 26: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Introducing µ

A regular syntax?

c ::= 〈t || e〉

t ,u ::=| x ,y| λx .t| µα . c

e, f ::=| α , β| t · e| ?

Reminder:

Same idea, in the dual situation:

〈let x = t in u || e〉 Babs

⟨t���� “let x = � in 〈u || e〉′′

⟩〈t || µx .c〉 Bµ c [t/x]

12/ 22

〈(λx .t)u ||e〉 Babs

Page 27: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Introducing µ

A regular syntax?

c ::= 〈t || e〉

t ,u ::=| x ,y| λx .t| µα . c

e, f ::=| α , β| t · e| ?

Same idea, in the dual situation:

〈let x = t in u || e〉 Babs

⟨t���� “let x = � in 〈u || e〉′′

⟩〈t || µx .c〉 Bµ c [t/x]

12/ 22

〈(λx .t)u ||e〉 Babs

Page 28: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Introducing µ

A regular syntax

c ::= 〈t || e〉

t ,u ::=| x ,y| λx .t| µα . c

e, f ::=| α , β| t · e| µx . c

Same idea, in the dual situation:

〈let x = t in u || e〉 Babs

⟨t���� “let x = � in 〈u || e〉′′︸ ︷︷ ︸⟩

µx .〈u || e〉

〈t || µx .c〉 Bµ c [t/x]

12/ 22

〈(λx .t)u ||e〉 Babs

Page 29: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Curien-Herbelin’s λµµ-calculus

Syntax:

t ,u ::=| x ,y| λx .t| µα . c

c ::= 〈t || e〉 e, f ::=| α , β| t · e| µx . c

Reduction:

〈λx .t ||u · e〉 →⟨u

���� µx .〈t || e〉⟩〈t || µx .c〉 → c[t/x]〈µα .c || e〉 → c[e/α]

13/ 22

Page 30: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Curien-Herbelin’s λµµ-calculus

Syntax:

t ,u ::=| x ,y| λx .t| µα . c

c ::= 〈t || e〉 e, f ::=| α , β| t · e| µx . c

Reduction:

〈λx .t ||u · e〉 →⟨u

���� µx .〈t || e〉⟩〈t || µx .c〉 → c[t/x]〈µα .c || e〉 → c[e/α]

Critical pair:〈µα .c || µx .c ′〉

↙ ↘c[µx .c ′/α] c ′[µα .c/x]

13/ 22

Page 31: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Curien-Herbelin’s λµµ-calculus

Syntax:

t ,u ::=| x ,y| λx .t| µα . c

c ::= 〈t || e〉 e, f ::=| α , β| t · e| µx . c

Reduction:

〈λx .t ||u · e〉 →⟨u

���� µx .〈t || e〉⟩〈t || µx .c〉 → c[t/x]〈µα .c || e〉 → c[e/α]

t ∈ Ve ∈ E

Critical pair:〈µα .c || µx .c ′〉

↙ ↘c[µx .c ′/α] c ′[µα .c/x]

13/ 22

Values

{ }Co-values

CbV CbN

Page 32: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Curien-Herbelin’s λµµ-calculus

Syntax:

t ,u ::=| x ,y| λx .t| µα . c

c ::= 〈t || e〉 e, f ::=| α , β| t · e| µx . c

Reduction:

〈λx .t ||u · e〉 →⟨u

���� µx .〈t || e〉⟩〈t || µx .c〉 → c[t/x]〈µα .c || e〉 → c[e/α]

t ∈ Ve ∈ E

Critical pair:〈µα .c || µx .c ′〉

↙ ↘c[µx .c ′/α] c ′[µα .c/x]

13/ 22

Values

{ }Co-values

CbV CbN

Duality(again and again)

Page 33: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Curien-Herbelin’s λµµ-calculus

Syntax:

t ,u ::=| x ,y| λx .t| µα . c

c ::= 〈t || e〉 e, f ::=| α , β| t · e| µx . c

Typing rules:Γ ` t : A | ∆ Γ | e : A ` ∆

〈t || e〉 : (Γ ` ∆)(x : A) ∈ ΓΓ ` x : A | ∆

Γ,x : A ` t : B | ∆Γ ` λx .t : A→ B | ∆

c : ( Γ ` ∆,α : A)Γ ` µα .c : A | ∆

(α : A) ∈ ∆Γ | α : A ` ∆

Γ ` u : A | ∆ Γ | e : B ` ∆Γ | u · e : A→ B ` ∆

c : ( Γ,x : A ` ∆)Γ | µx .c : A ` ∆

13/ 22

Values

{ }Co-values

Page 34: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Curien-Herbelin’s λµµ-calculus

Syntax:

t ,u ::=| x ,y| λx .t| µα . c

c ::= 〈t || e〉 e, f ::=| α , β| t · e| µx . c

Typing rules:Γ ` t : A | ∆ Γ | e : A ` ∆

〈t || e〉 : (Γ ` ∆)(x : A) ∈ ΓΓ ` x : A | ∆

Γ,x : A ` t : B | ∆Γ ` λx .t : A→ B | ∆

c : ( Γ ` ∆,α : A)Γ ` µα .c : A | ∆

(α : A) ∈ ∆Γ | α : A ` ∆

Γ ` u : A | ∆ Γ | e : B ` ∆Γ | u · e : A→ B ` ∆

c : ( Γ,x : A ` ∆)Γ | µx .c : A ` ∆

13/ 22

Values

{ }Co-values

Page 35: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Curien-Herbelin’s λµµ-calculus

Syntax:

t ,u ::=| x ,y| λx .t| µα . c

c ::= 〈t || e〉 e, f ::=| α , β| t · e| µx . c

Typing rules:Γ ` t : A | ∆ Γ | e : A ` ∆

〈t || e〉 : (Γ ` ∆)(x : A) ∈ ΓΓ ` x : A | ∆

Γ,x : A ` t : B | ∆Γ ` λx .t : A→ B | ∆

c : ( Γ ` ∆,α : A)Γ ` µα .c : A | ∆

(α : A) ∈ ∆Γ | α : A ` ∆

Γ ` u : A | ∆ Γ | e : B ` ∆Γ | u · e : A→ B ` ∆

c : ( Γ,x : A ` ∆)Γ | µx .c : A ` ∆

13/ 22

Values

{ }Co-values

Page 36: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

“Why should I care?”

14/ 22

Page 37: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

“Why should I care?”Because sequent calculus is well-behaved!

14/ 22

Page 38: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Sequent calculus as IR

You just defined a wonderful calculus, and you are wondering:

Problem

How to define a continuation-passing style translation?

CPS translation:J·K : source → λsomething

preserving reduction

preserving typing

the type J⊥K is not inhabited

Typically:

JV K , λk .k V

JtK , λk .?

Benefits:If λsomething

is sound and normalizing:

1 If JtK normalizes, then t normalizes

2 If t is typed, then t normalizes

3 There is no term ` t : ⊥

15/ 22

Page 39: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Sequent calculus as IR

You just defined a wonderful calculus, and you are wondering:

Problem

How to define a continuation-passing style translation?

Solution

Use sequent calculus!

Slogan:

A sequent calculus is a defunctionalization of CPS representations.

# as such it defines a good intermediate representation for compilation

Method: Danvy’s semantics artifacts

15/ 22

Page 40: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Sequent calculus as IR

You just defined a wonderful calculus, and you are wondering:

Problem

How to define a continuation-passing style translation?

Solution

Use sequent calculus!

Slogan:

A sequent calculus is a defunctionalization of CPS representations.

# as such it defines a good intermediate representation for compilation

Method: Danvy’s semantics artifacts

15/ 22

Page 41: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Semantics artifacts in action

Call-by-name λµµ-calculus:

Terms t ::= V | µα .cValues V ::= x | λx .t

Contexts e ::= E | µx .cCo-values E ::= α | t · e

Commands c ::= 〈t || e〉

Reduction rules:

〈t || µx .c〉 → c[t/x]〈µα .c || E〉 → c[E/α]〈λx .t ||u · e〉 →

⟨u

���� µx .〈t || e〉⟩

16/ 22

Page 42: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Semantics artifacts in action

Terms t ::= V | µα .cValues V ::= x | λx .t

Contexts e ::= E | µx .cCo-values E ::= α | t · e

Commands c ::= 〈t || e〉

Small steps

〈t || µx .c〉e ce [t/x]〈t || E〉e 〈t || E〉t〈µα .c || E〉t ce [E/α]〈V || E〉t 〈V || E〉E〈V ||u · e〉E 〈V ||u · e〉V〈λx .t ||u · e〉V

⟨u

���� µx .〈t || e〉⟩e

CPS

Jµx .cKe t , (λx .JcKc ) tJEKe t , t JEKE

Jµα .cKt E , (λα .JcKc )EJV Kt E , E [[V ]]V

Ju · eKE V , V JuKt JeKe

Jλx .tKV u e , (λx .e JtKt )u

16/ 22

e

t

E

V

Page 43: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Semantics artifacts in action

Terms t ::= V | µα .cValues V ::= x | λx .t

Contexts e ::= E | µx .cCo-values E ::= α | t · e

Commands c ::= 〈t || e〉

Small steps

〈t || µx .c〉e ce [t/x]〈t || E〉e 〈t || E〉t〈µα .c || E〉t ce [E/α]〈V || E〉t 〈V || E〉E〈V ||u · e〉E 〈V ||u · e〉V〈λx .t ||u · e〉V

⟨u

���� µx .〈t || e〉⟩e

CPS

Jµx .cKe t , (λx .JcKc ) tJEKe t , t JEKE

Jµα .cKt E , (λα .JcKc )EJV Kt E , E [[V ]]V

Ju · eKE V , V JuKt JeKe

Jλx .tKV u e , (λx .e JtKt )u

16/ 22

e

t

E

V

Preservation

c1 c ′ ⇒ [[c]]c

+→β [[c ′]]c

Page 44: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Semantics artifacts in action

Terms t ::= V | µα .cValues V ::= x | λx .t

Contexts e ::= E | µx .cCo-values E ::= α | t · e

Commands c ::= 〈t || e〉

CPS

Jµx .cKe t , (λx .JcKc ) tJEKe t , t JEKE

Jµα .cKt E , (λα .JcKc )EJV Kt E , E [[V ]]V

Ju · eKE V , V JuKt JeKe

Jλx .tKV u e , (λx .e JtKt )u

Types translation

[[A]]e , [[A]]t → ⊥

[[A]]t , [[A]]E → ⊥

[[A]]E , [[A]]V → ⊥

[[A→ B]]V , [[A]]t → [[B]]e → ⊥

16/ 22

e

t

E

V

Preservation

Γ ` t : A | ∆ ⇒ [[Γ]]t , [[∆]]E ` [[t]]t : [[A]]t

Page 45: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Semantics artifacts in action

Normalization

Typed commands of the call-by-name λµµ-calculus normalize.

Inhabitation

There is no simply-typed λ-term t such that ` t : [[⊥]]t .

Soundness

There is no proof t such that ` t : ⊥ | .

16/ 22

Page 46: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Normalization proofs

You just defined a wonderful calculus, but the CPS method is too

complex:

Problem

How can I prove normalization?

Solution

Use sequent calculus + Krivine realizability!

Slogan:

A sequent calculus specifies the interactions of terms and contexts.

# as you will see, this helps a lot the definition of a realizability interpretation

Method: Danvy’s semantics artifacts, again

17/ 22

Page 47: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Normalization proofs

You just defined a wonderful calculus, but the CPS method is too

complex:

Problem

How can I prove normalization?

Solution

Use sequent calculus + Krivine realizability!

Slogan:

A sequent calculus specifies the interactions of terms and contexts.

# as you will see, this helps a lot the definition of a realizability interpretation

Method: Danvy’s semantics artifacts, again

17/ 22

Page 48: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Normalization proofs

You just defined a wonderful calculus, but the CPS method is too

complex:

Problem

How can I prove normalization?

Solution

Use sequent calculus + Krivine realizability!

Slogan:

A sequent calculus specifies the interactions of terms and contexts.

# as you will see, this helps a lot the definition of a realizability interpretation

Method: Danvy’s semantics artifacts, again

17/ 22

Page 49: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Realizability a la Krivine

(think of some kind of unary logical relation)

Intuition

falsity value ‖A‖: contexts, opponent to A

truth value |A| : terms, player of A

pole ⊥⊥: commands, referee

〈t || e〉 � c0 � · · · � cn ∈ ⊥⊥?

⊥⊥ ⊂ Λ?Π closed by anti-reduction

Truth value defined by orthogonality :

|A| = ‖A‖⊥⊥ = {t ∈ Λ : ∀e ∈ ‖A‖, 〈t || e〉 ∈ ⊥⊥}

18/ 22

Page 50: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Realizability a la Krivine

(think of some kind of unary logical relation)

Intuition

falsity value ‖A‖: contexts, opponent to A

truth value |A| : terms, player of A

pole ⊥⊥: commands, referee

〈t || e〉 � c0 � · · · � cn ∈ ⊥⊥?

⊥⊥ ⊂ Λ?Π closed by anti-reduction

Truth value defined by orthogonality :

|A| = ‖A‖⊥⊥ = {t ∈ Λ : ∀e ∈ ‖A‖, 〈t || e〉 ∈ ⊥⊥}

18/ 22

Page 51: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Realizability a la Krivine

(think of some kind of unary logical relation)

Intuition

falsity value ‖A‖: contexts, opponent to A

truth value |A| : terms, player of A

pole ⊥⊥: commands, referee

〈t || e〉 � c0 � · · · � cn ∈ ⊥⊥?

⊥⊥ ⊂ Λ?Π closed by anti-reduction

Truth value defined by orthogonality :

|A| = ‖A‖⊥⊥ = {t ∈ Λ : ∀e ∈ ‖A‖, 〈t || e〉 ∈ ⊥⊥}

18/ 22

Page 52: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Semantic artifacts, bis

Terms t ::= V | µα .cValues V ::= x | λx .t

Contexts e ::= E | µx .c

Co-values E ::= α | t · eCommands c ::= 〈t || e〉

Small steps

〈t || µx .c〉e ce [t/x]〈t || E〉e 〈t || E〉t〈µα .c || E〉t ce [E/α]〈V || E〉t 〈V || E〉E〈V ||u · e〉E 〈V ||u · e〉V〈λx .t ||u · e〉V

⟨u

���� µx .〈t || e〉⟩e

Realizability

‖A‖e , |A|t⊥⊥

|A|t , ‖A‖E⊥⊥

‖A→ B‖E , {u · e : u ∈ |A|t∧ e ∈ ‖B‖e }

19/ 22

e

t

E

V

Page 53: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Semantic artifacts, bis

Terms t ::= V | µα .cValues V ::= x | λx .t

Contexts e ::= E | µx .c

Co-values E ::= α | t · eCommands c ::= 〈t || e〉

Small steps

〈t || µx .c〉e ce [t/x]〈t || E〉e 〈t || E〉t〈µα .c || E〉t ce [E/α]〈V || E〉t 〈V || E〉E〈V ||u · e〉E 〈V ||u · e〉V〈λx .t ||u · e〉V

⟨u

���� µx .〈t || e〉⟩e

Realizability

‖A‖e , |A|t⊥⊥

|A|t , ‖A‖E⊥⊥

‖A→ B‖E , {u · e : u ∈ |A|t∧ e ∈ ‖B‖e }

19/ 22

e

t

E

V

Adequacy

1 · ` t : A | · ⇒ t ∈ |A|t2 · | e : A ` · ⇒ e ∈ ‖A‖e

3 c : (· ` ·) ⇒ c ∈ ⊥⊥

Page 54: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Consequences

Normalizing commands

⊥⊥⇓ , {c : c normalizes} defines a valid pole.

Proof. If c → c′ and c′ normalizes, so does c . �

Normalization

For any command c , if c : Γ ` ∆, then c normalizes.

Proof. By adequacy, any typed command c belongs to the pole ⊥⊥⇓. �

Soundness

There is no proof t such that ` t : ⊥ | .

Proof. Otherwise, t ∈ |⊥|t = Π⊥⊥ for any pole, absurd (⊥⊥ , ∅). �

20/ 22

Page 55: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Polarized sequent calculus

You added sums to your favorite λ-calculus, it broke all your proofs:

Problem

What can I do?

Solution

Use sequent calculus + polarities!

Negative polarity Every expression is a value (CBN)

Positive polarity Every context is a covalue (CBV)

Slogan:

Polarized λµµ is a good, regular syntax for programs.

# a.k.a. system L, a great syntax for call-by-push-value

Method: see Munch-Maccagnoni & Scherer’s paper (LICS’15)

21/ 22

Page 56: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Polarized sequent calculus

You added sums to your favorite λ-calculus, it broke all your proofs:

Problem

What can I do?

Solution

Use sequent calculus + polarities!

Negative polarity Every expression is a value (CBN)

Positive polarity Every context is a covalue (CBV)

Slogan:

Polarized λµµ is a good, regular syntax for programs.

# a.k.a. system L, a great syntax for call-by-push-value

Method: see Munch-Maccagnoni & Scherer’s paper (LICS’15)

21/ 22

Page 57: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Polarized sequent calculus

You added sums to your favorite λ-calculus, it broke all your proofs:

Problem

What can I do?

Solution

Use sequent calculus + polarities!

Negative polarity Every expression is a value (CBN)

Positive polarity Every context is a covalue (CBV)

Slogan:

Polarized λµµ is a good, regular syntax for programs.

# a.k.a. system L, a great syntax for call-by-push-value

Method: see Munch-Maccagnoni & Scherer’s paper (LICS’15)

21/ 22

Page 58: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Take away

Sequent calculus:is more regular than natural deduction

corresponds to abstract-machine-like calculi (e.g. λµµ-calculus)

provides great insights on operational semantics

A flexible tool:

can be decomposed with connectives of linear logiccan be polarized (Munch-Maccagnoni’s system L)

supports e�ectful constructors

If you don’t use it already,

What are you waiting for?22/ 22

Page 59: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Take away

Sequent calculus:is more regular than natural deduction

corresponds to abstract-machine-like calculi (e.g. λµµ-calculus)

provides great insights on operational semantics

A flexible tool:

can be decomposed with connectives of linear logiccan be polarized (Munch-Maccagnoni’s system L)

supports e�ectful constructors

If you don’t use it already,

What are you waiting for?22/ 22

Page 60: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

Introduction Sequent calculus Benefits

Take away

Sequent calculus:is more regular than natural deduction

corresponds to abstract-machine-like calculi (e.g. λµµ-calculus)

provides great insights on operational semantics

A flexible tool:

can be decomposed with connectives of linear logiccan be polarized (Munch-Maccagnoni’s system L)

supports e�ectful constructors

If you don’t use it already,

What are you waiting for?22/ 22

Page 61: The benefits of sequent calculusemiquey/content/lmw19.pdf · A fairy tale Sequent calculus provides wonderful tools! ... Euclide’s Elements 4/ 22. Introduction Sequent calculus

SELECTED REFERENCESOn sequent calculus/proofs-as-programs:

The Duality of Computation. Curien & Herbelin (2000)

A Tutorial on Computational Classical Logic and the Sequent CalculusDownen & Ariola (2018)

LKQ and LKT: Sequent calculi for second order logic …Danos, Joinet & Schellinx (1995)

On polarized sequent calculi:

Polarised Intermediate Representation of Lambda Calculus with SumsMunch-Maccagnoni & Scherer (2015)

Syntax and Models of a Non-Associative Composition of Programs and ProofsMunch-Maccagnoni (2013)

A Preview of a Tutorial on Polarised L CalculiMaillard, M., Montillet, Munch-Maccagnoni, Scherer (2018)

Use cases of Danvy’s semantics artifacts:A Constructive Proof of Dependent Choice in Classical Arithmetic viaMemoization. M. (2019)