Toward a Curry-Howard Correspondence for Linear, Reversible - - PowerPoint PPT Presentation

toward a curry howard correspondence for linear
SMART_READER_LITE
LIVE PREVIEW

Toward a Curry-Howard Correspondence for Linear, Reversible - - PowerPoint PPT Presentation

Toward a Curry-Howard Correspondence for Linear, Reversible Computation Reversible Computation 2020 Kostia Chardonnet 1 , 2 Alexis Saurin 2 Benot Valiron 1 1 Universit Paris Saclay 2 Universit de Paris Classical vs Quantum Control Known :


slide-1
SLIDE 1

Toward a Curry-Howard Correspondence for Linear, Reversible Computation

Reversible Computation 2020

Kostia Chardonnet1,2 Alexis Saurin2 Benoît Valiron1

1Université Paris Saclay 2Université de Paris

slide-2
SLIDE 2

Classical vs Quantum Control

Computer Known :

  • Rich Type System
  • Classical Control

QRAM

2 / 48

slide-3
SLIDE 3

Classical vs Quantum Control

Computer Known :

  • Rich Type System
  • Classical Control

QRAM Elementary gates

3 / 48

slide-4
SLIDE 4

Classical vs Quantum Control

Computer Known :

  • Rich Type System
  • Classical Control

QRAM Elementary gates Outcome of measurement

4 / 48

slide-5
SLIDE 5

Classical vs Quantum Control

Computer Known :

  • Rich Type System
  • Classical Control

QRAM Elementary gates Outcome of measurement

5 / 48

slide-6
SLIDE 6

Classical vs Quantum Control

Computer Known :

  • Rich Type System
  • Classical Control

QRAM Elementary gates Outcome of measurement Missing :

  • No Rich Type System
  • No Quantum Control

6 / 48

slide-7
SLIDE 7

The Curry-Howard Correspondence

Types

  • Types describe data, structure programs.
  • “Well-typed Programs Cannot Go Wrong” - Robin Milner

7 / 48

slide-8
SLIDE 8

The Curry-Howard Correspondence

Types

  • Types describe data, structure programs.
  • “Well-typed Programs Cannot Go Wrong” - Robin Milner

Example : toString : nat → string toString(5) = "five".

8 / 48

slide-9
SLIDE 9

The Curry-Howard Correspondence

Types

  • Types describe data, structure programs.
  • “Well-typed Programs Cannot Go Wrong” - Robin Milner

Example : toString : nat → string toString(5) = "five". toString(5) Well typed ! toString("toto") Ill typed !

9 / 48

slide-10
SLIDE 10

The Curry-Howard Correspondence

toString(5) Well typed ! toString("toto") Ill typed ! toString : nat → string 5 : nat toString(5) : string

10 / 48

slide-11
SLIDE 11

The Curry-Howard Correspondence

toString(5) Well typed ! toString("toto") Ill typed ! toString : nat → string 5 : nat toString(5) : string A → B A B

11 / 48

slide-12
SLIDE 12

The Curry-Howard Correspondence

toString(5) Well typed ! toString("toto") Ill typed ! nat → string nat string A → B A B

12 / 48

slide-13
SLIDE 13

The Curry-Howard Correspondence

toString(5) Well typed ! toString("toto") Ill typed ! nat → string nat string A → B A B Curry-Howard Correspondence !

13 / 48

slide-14
SLIDE 14

The Curry-Howard Correspondence

Curry-Howard Correspondence ! λ-calculus Logic & Proofs Types Formulas Typed terms Proofs Evaluation Cut Elimination Formal Program Verification

14 / 48

slide-15
SLIDE 15

Our Work

Based on [Sabry, Valiron, Vizzotto] and [Baelde, Doumane, Saurin] Sabry et al. Baelde et al. This Work Linear ✓ ✓ ✓ Reversible ✓ ✗ ✓ (Co)-Inductive ✗ ✓ ✓ Curry-Howard ✗ ✗ ✓ Quantum Case ✓ ✗ WIP

15 / 48

slide-16
SLIDE 16

Syntax

(Base types) A, B ::= 1 | X | A ⊕ B | A ⊗ B | µX.A | νX.A (Isos, first-order) α ::= A ↔ B (Isos, higher-order) T ::= α1 → · · · → αn → α inv

let in let in

16 / 48

slide-17
SLIDE 17

Syntax

(Base types) A, B ::= 1 | X | A ⊕ B | A ⊗ B | µX.A | νX.A (Isos, first-order) α ::= A ↔ B (Isos, higher-order) T ::= α1 → · · · → αn → α inv

  • nat = µX.1 ⊕ X
  • lists(A) = [A] = µX. 1 ⊕ (A ⊗ X)
  • streams(A) = νX. A ⊗ X

let in let in

17 / 48

slide-18
SLIDE 18

Syntax

(Base types) A, B ::= 1 | X | A ⊕ B | A ⊗ B | µX.A | νX.A (Isos, first-order) α ::= A ↔ B (Isos, higher-order) T ::= α1 → · · · → αn → α (Isos) ω ::= {e1 ↔ e′

1 | . . . | en ↔ e′ n} | λf .ω |

µf .ω | f | ω1 ω2 | inv ω

λg.µf .      [ ] ↔ [ ] h :: t ↔ let x = g h in let y = f t in x :: y      : A ↔ B → [A] ↔ [B]

18 / 48

slide-19
SLIDE 19

Syntax

(Base types) A, B ::= 1 | X | A ⊕ B | A ⊗ B | µX.A | νX.A (Isos, first-order) α ::= A ↔ B (Isos, higher-order) T ::= α1 → · · · → αn → α (Isos) ω ::= {e1 ↔ e′

1 | . . . | en ↔ e′ n} | λf .ω |

µf .ω | f | ω1 ω2 | inv ω

λg.µf .      [ ] ↔ [ ] h :: t ↔ let x = g h in let y = f t in x :: y      : A ↔ B → [A] ↔ [B]

19 / 48

slide-20
SLIDE 20

Syntax

(Base types) A, B ::= 1 | X | A ⊕ B | A ⊗ B | µX.A | νX.A (Isos, first-order) α ::= A ↔ B (Isos, higher-order) T ::= α1 → · · · → αn → α (Isos) ω ::= {e1 ↔ e′

1 | . . . | en ↔ e′ n} | λf .ω |

µf .ω | f | ω1 ω2 | inv ω

λg.µf .      [ ] ↔ [ ] h :: t ↔ let x = g h in let y = f t in x :: y      : A ↔ B → [A] ↔ [B]

20 / 48

slide-21
SLIDE 21

Properties

Syntax

  • Language comes with a rewriting system and a type system.
  • Ensuring exhaustivity and non-overlapping of clauses.
  • Ensuring productivity.

Semantic

  • Isos denote computations from A → B and B → A.

21 / 48

slide-22
SLIDE 22

Syntax - Example 2

map = λg.µf.      [ ] ↔ [ ] h :: t ↔ let x = g h in let y = f t in x :: y      : A ↔ B → [A] ↔ [B] map g f let in let in A B B A map g f let inv in let in A B B A

slide-23
SLIDE 23

Syntax - Example 2

map = λg.µf.      [ ] ↔ [ ] h :: t ↔ let x = g h in let y = f t in x :: y      : A ↔ B → [A] ↔ [B] map⊥ = λg.µf.      [ ] ↔ [ ] let x = g h in ↔ h :: t let y = f t in x :: y      : A ↔ B → [B] ↔ [A] map g f let inv in let in A B B A

slide-24
SLIDE 24

Syntax - Example 2

map = λg.µf.      [ ] ↔ [ ] h :: t ↔ let x = g h in let y = f t in x :: y      : A ↔ B → [A] ↔ [B] map⊥ = λg.µf.      [ ] ↔ [ ] let x = g h in ↔ h :: t let y = f t in x :: y      : A ↔ B → [B] ↔ [A] map⊥ = λg.µf.      [ ] ↔ [ ] x :: y ↔ let h = (inv (g)) x in let t = f y in h :: t      : A ↔ B → [B] ↔ [A]

24 / 48

slide-25
SLIDE 25

Results

Confluence

t1 t2 t3 t4 ∗ ∗ ∗ ∗

Type Preservation

If ⊢ t : A and t → t′ then ⊢ t′ : A.

Progress

If ⊢ t : A either t → t′ or t is a value.

Isos

For each ω we have ω ◦ (inv ω) = id = (inv ω) ◦ ω.

25 / 48

slide-26
SLIDE 26

Words on µMALL

Linear Logic with Induction (µX.A) and Co-Induction (νX.A) A ⊢ B[X ← µX.B] A ⊢ µX.B µR

26 / 48

slide-27
SLIDE 27

Words on µMALL

Linear Logic with Induction (µX.A) and Co-Induction (νX.A) 0 = ⊢ µX.1 ⊕ X

  • nat

27 / 48

slide-28
SLIDE 28

Words on µMALL

Linear Logic with Induction (µX.A) and Co-Induction (νX.A) 0 = ⊢ 1 ⊕ µX.1 ⊕ X µR ⊢ µX.1 ⊕ X

  • nat

28 / 48

slide-29
SLIDE 29

Words on µMALL

Linear Logic with Induction (µX.A) and Co-Induction (νX.A) 0 = ⊢ 1 ⊕1 ⊢ 1 ⊕ µX.1 ⊕ X µR ⊢ µX.1 ⊕ X

  • nat

29 / 48

slide-30
SLIDE 30

Words on µMALL

Linear Logic with Induction (µX.A) and Co-Induction (νX.A) 0 = 1R ⊢ 1 ⊕1 ⊢ 1 ⊕ µX.1 ⊕ X µR ⊢ µX.1 ⊕ X

  • nat

30 / 48

slide-31
SLIDE 31

Words on µMALL

Linear Logic with Induction (µX.A) and Co-Induction (νX.A) 0 = 1R ⊢ 1 ⊕1 ⊢ 1 ⊕ µX.1 ⊕ X µR ⊢ µX.1 ⊕ X

  • nat

n + 1 = ⊢ nat

31 / 48

slide-32
SLIDE 32

Words on µMALL

Linear Logic with Induction (µX.A) and Co-Induction (νX.A) 0 = 1R ⊢ 1 ⊕1 ⊢ 1 ⊕ µX.1 ⊕ X µR ⊢ µX.1 ⊕ X

  • nat

n + 1 = ⊢ 1 ⊕ nat µR ⊢ nat

32 / 48

slide-33
SLIDE 33

Words on µMALL

Linear Logic with Induction (µX.A) and Co-Induction (νX.A) 0 = 1R ⊢ 1 ⊕1 ⊢ 1 ⊕ µX.1 ⊕ X µR ⊢ µX.1 ⊕ X

  • nat

n + 1 = ⊢ nat ⊕2 ⊢ 1 ⊕ nat µR ⊢ nat

33 / 48

slide-34
SLIDE 34

Words on µMALL

Linear Logic with Induction (µX.A) and Co-Induction (νX.A) 0 = 1R ⊢ 1 ⊕1 ⊢ 1 ⊕ µX.1 ⊕ X µR ⊢ µX.1 ⊕ X

  • nat

n + 1 = n ⊢ nat ⊕2 ⊢ 1 ⊕ nat µR ⊢ nat

34 / 48

slide-35
SLIDE 35

Words on µMALL

Linear Logic with Induction (µX.A) and Co-Induction (νX.A) 0 = 1R ⊢ 1 ⊕1 ⊢ 1 ⊕ µX.1 ⊕ X µR ⊢ µX.1 ⊕ X

  • nat

n + 1 = n ⊢ nat ⊕2 ⊢ 1 ⊕ nat µR ⊢ nat 1 = 1R ⊢ 1 ⊕1 ⊢ 1 ⊕ nat µR ⊢ nat ⊕2 ⊢ 1 ⊕ nat µR ⊢ nat

35 / 48

slide-36
SLIDE 36

Words on µMALL

Linear Logic with Induction (µX.A) and Co-Induction (νX.A) Stream0 = ⊢ nat ⊢νX.nat ⊗ X ⊗ ⊢ nat ⊗ (νX.nat ⊗ X) νR ⊢νX.nat ⊗ X

36 / 48

slide-37
SLIDE 37

Words on µMALL

Linear Logic with Induction (µX.A) and Co-Induction (νX.A) Stream0 = ⊢ nat ⊢νX.nat ⊗ X ⊗ ⊢ nat ⊗ (νX.nat ⊗ X) νR ⊢νX.nat ⊗ X

37 / 48

slide-38
SLIDE 38

Words on µMALL

Linear Logic with Induction and Co-Induction . . . µR ⊢ µX.X µR ⊢ µX.X ⊢µX.X µR ⊢ µX.X Infinite derivations represented as graphs

38 / 48

slide-39
SLIDE 39

Words on µMALL

A derivation is valid if in every infinite branch :

  • Infinity of rules µL
  • Infinity of rules νR

39 / 48

slide-40
SLIDE 40

From Type Derivation To Proofs

Typed Terms Proofs ω : A ↔ B ω⊥ : B ↔ A π : A ⊢ B π⊥ : B ⊢ A

40 / 48

slide-41
SLIDE 41

From Derivations To Proofs - Example

Let us take the recursive identity on lists µf .      [ ] ↔ [ ] h :: t ↔ let t′ = f t in h :: t′      : [A] ↔ [A] let in

41 / 48

slide-42
SLIDE 42

From Derivations To Proofs - Example

let in µf .      [ ] ↔ [ ] h :: t ↔ let t′ = f t in h :: t′      ⊢ [A] 1L 1 ⊢ [A] A, [A] ⊢ [A] ⊗L A ⊗ [A] ⊢ [A] ⊕L 1 ⊕ (A ⊗ [A]) ⊢ [A] µL [A] ⊢ [A]

42 / 48

slide-43
SLIDE 43

From Derivations To Proofs - Example

let in µf .      [ ] ↔ [ ] h :: t ↔ let t′ = f t in h :: t′      1R ⊢ 1 ⊕1

R

⊢ 1 ⊕ (A ⊗ [a]) µR ⊢ [A] 1L 1 ⊢ [A] A, [A] ⊢ [A] ⊗L A ⊗ [A] ⊢ [A] ⊕L 1 ⊕ (A ⊗ [A]) ⊢ [A] µL [A] ⊢ [A]

43 / 48

slide-44
SLIDE 44

From Derivations To Proofs - Example

let in µf .      [ ] ↔ [ ] h :: t ↔ let t′ = f t in h :: t′      1R ⊢ 1 ⊕1

R

⊢ 1 ⊕ (A ⊗ [a]) µR ⊢ [A] 1L 1 ⊢ [A] [A] ⊢ [A] A, [A] ⊢ [A] cut A, [A] ⊢ [A] ⊗L A ⊗ [A] ⊢ [A] ⊕L 1 ⊕ (A ⊗ [A]) ⊢ [A] µL [A] ⊢ [A]

44 / 48

slide-45
SLIDE 45

From Derivations To Proofs - Example

let in µf .      [ ] ↔ [ ] h :: t ↔ let t′ = f t in h :: t′      1R ⊢ 1 ⊕1

R

⊢ 1 ⊕ (A ⊗ [a]) µR ⊢ [A] 1L 1 ⊢ [A] id [A] ⊢ [A] [A] ⊢ [A] cut [A] ⊢ [A] A, [A] ⊢ [A] cut A, [A] ⊢ [A] ⊗L A ⊗ [A] ⊢ [A] ⊕L 1 ⊕ (A ⊗ [A]) ⊢ [A] µL [A] ⊢ [A]

45 / 48

slide-46
SLIDE 46

From Derivations To Proofs - Example

let in µf .      [ ] ↔ [ ] h :: t ↔ let t′ = f t in h :: t′      1R ⊢ 1 ⊕1

R

⊢ 1 ⊕ (A ⊗ [a]) µR ⊢ [A] 1L 1 ⊢ [A] id [A] ⊢ [A] [A] ⊢ [A] cut [A] ⊢ [A] id a ⊢ a id [a] ⊢ [a] ⊗R A, [A] ⊢ A ⊗ [A] ⊕2

R

A, [A] ⊢ 1 ⊕ A ⊗ [A] µR A, [A] ⊢ [A] cut A, [A] ⊢ [A] ⊗L A ⊗ [A] ⊢ [A] ⊕L 1 ⊕ (A ⊗ [A]) ⊢ [A] µL [A] ⊢ [A]

46 / 48

slide-47
SLIDE 47

Conclusion

Results

  • Confluence.
  • Type Preservation.
  • Progress.
  • Isos are isomorphisms.

In Progress

  • Show that derivations built isos are valid.
  • Show that our reduction simulates cut-elimination.
  • Show that π, π⊥ are isomorphisms.
  • Consider the quantum case.

47 / 48

slide-48
SLIDE 48