Toward a Curry-Howard Correspondence for Linear, Reversible Computation Reversible Computation 2020 Kostia Chardonnet 1 , 2 Alexis Saurin 2 Benoît Valiron 1 1 Université Paris Saclay 2 Université de Paris
Classical vs Quantum Control Known : • Rich Type System • Classical Control QRAM ⟲ Computer 2 / 48
Classical vs Quantum Control Elementary gates Known : • Rich Type System • Classical Control QRAM ⟳ Computer 3 / 48
Classical vs Quantum Control Elementary gates Known : • Rich Type System • Classical Control QRAM Computer Outcome of measurement 4 / 48
Classical vs Quantum Control Elementary gates Known : • Rich Type System • Classical Control QRAM Computer Outcome of measurement 5 / 48
Classical vs Quantum Control Elementary gates Known : • Rich Type System • Classical Control QRAM Missing : • No Rich Type System • No Quantum Control Computer Outcome of measurement 6 / 48
The Curry-Howard Correspondence Types • Types describe data, structure programs. • “Well-typed Programs Cannot Go Wrong” - Robin Milner 7 / 48
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
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) toString ( "toto" ) Well typed ! Ill typed ! 9 / 48
The Curry-Howard Correspondence toString : nat → string 5 : nat toString (5) : string toString (5) toString ( "toto" ) Well typed ! Ill typed ! 10 / 48
The Curry-Howard Correspondence toString : nat → string 5 : nat A → B A toString (5) : string B toString (5) toString ( "toto" ) Well typed ! Ill typed ! 11 / 48
The Curry-Howard Correspondence nat → string nat A → B A string B toString (5) toString ( "toto" ) Well typed ! Ill typed ! 12 / 48
The Curry-Howard Correspondence nat → string nat A → B A string B Curry-Howard Correspondence ! toString (5) toString ( "toto" ) Well typed ! Ill typed ! 13 / 48
The Curry-Howard Correspondence Formal Program Verification Curry-Howard Correspondence ! λ -calculus Logic & Proofs Types Formulas Typed terms Proofs Evaluation Cut Elimination 14 / 48
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
let inv in let in 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 → α 16 / 48
inv let in let in 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 → α • nat = µ X . 1 ⊕ X • lists ( A ) = [ A ] = µ X . 1 ⊕ ( A ⊗ X ) • streams ( A ) = ν X . A ⊗ X 17 / 48
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 → α ω ::= { e 1 ↔ e ′ 1 | . . . | e n ↔ e ′ (Isos) n } | λ f .ω | µ f .ω | f | ω 1 ω 2 | inv ω [ ] ↔ [ ] λ g .µ f . h :: t ↔ let x = g h in : A ↔ B → [ A ] ↔ [ B ] let y = f t in x :: y 18 / 48
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 → α ω ::= { e 1 ↔ e ′ 1 | . . . | e n ↔ e ′ (Isos) n } | λ f .ω | µ f .ω | f | ω 1 ω 2 | inv ω [ ] ↔ [ ] λ g .µ f . h :: t ↔ let x = g h in : A ↔ B → [ A ] ↔ [ B ] let y = f t in x :: y 19 / 48
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 → α ω ::= { e 1 ↔ e ′ 1 | . . . | e n ↔ e ′ (Isos) n } | λ f .ω | µ f .ω | f | ω 1 ω 2 | inv ω [ ] ↔ [ ] λ g .µ f . h :: t ↔ let x = g h in : A ↔ B → [ A ] ↔ [ B ] let y = f t in x :: y 20 / 48
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
A f in A B B A map g let in inv in let in A B B let let g map f Syntax - Example 2 [ ] ↔ [ ] map = λ g .µ f . h :: t ↔ let x = g h in : A ↔ B → [ A ] ↔ [ B ] let y = f t in x :: y
A map B B A in let in inv let f g Syntax - Example 2 [ ] ↔ [ ] map = λ g .µ f . h :: t ↔ let x = g h in : A ↔ B → [ A ] ↔ [ B ] let y = f t in x :: y [ ] ↔ [ ] map ⊥ = λ g .µ f . : A ↔ B → [ B ] ↔ [ A ] let x = g h in ↔ h :: t let y = f t in x :: y
Syntax - Example 2 [ ] ↔ [ ] map = λ g .µ f . h :: t ↔ let x = g h in : A ↔ B → [ A ] ↔ [ B ] let y = f t in x :: y [ ] ↔ [ ] map ⊥ = λ g .µ f . : A ↔ B → [ B ] ↔ [ A ] let x = g h in ↔ h :: t let y = f t in x :: y [ ] ↔ [ ] map ⊥ = λ g .µ f . : A ↔ B → [ B ] ↔ [ A ] x :: y ↔ let h = ( inv ( g )) x in let t = f y in h :: t 24 / 48
Results Confluence ∗ t 1 t 2 ∗ ∗ t 3 t 4 ∗ 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
Words on µ MALL Linear Logic with Induction ( µ X . A ) and Co-Induction ( ν X . A ) A ⊢ B [ X ← µ X . B ] µ R A ⊢ µ X . B 26 / 48
Words on µ MALL Linear Logic with Induction ( µ X . A ) and Co-Induction ( ν X . A ) � 0 � = ⊢ µ X . 1 ⊕ X � �� � nat 27 / 48
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
Words on µ MALL Linear Logic with Induction ( µ X . A ) and Co-Induction ( ν X . A ) ⊢ 1 ⊕ 1 ⊢ 1 ⊕ µ X . 1 ⊕ X µ R � 0 � = ⊢ µ X . 1 ⊕ X � �� � nat 29 / 48
Words on µ MALL Linear Logic with Induction ( µ X . A ) and Co-Induction ( ν X . A ) 1 R ⊢ 1 ⊕ 1 ⊢ 1 ⊕ µ X . 1 ⊕ X µ R � 0 � = ⊢ µ X . 1 ⊕ X � �� � nat 30 / 48
Words on µ MALL Linear Logic with Induction ( µ X . A ) and Co-Induction ( ν X . A ) 1 R ⊢ 1 ⊕ 1 ⊢ 1 ⊕ µ X . 1 ⊕ X µ R � 0 � = � n + 1 � = ⊢ µ X . 1 ⊕ X ⊢ nat � �� � nat 31 / 48
Words on µ MALL Linear Logic with Induction ( µ X . A ) and Co-Induction ( ν X . A ) 1 R ⊢ 1 ⊕ 1 ⊢ 1 ⊕ µ X . 1 ⊕ X µ R � 0 � = � n + 1 � = ⊢ 1 ⊕ nat µ R ⊢ µ X . 1 ⊕ X ⊢ nat � �� � nat 32 / 48
Words on µ MALL Linear Logic with Induction ( µ X . A ) and Co-Induction ( ν X . A ) 1 R ⊢ 1 ⊕ 1 ⊢ nat ⊕ 2 ⊢ 1 ⊕ µ X . 1 ⊕ X µ R � 0 � = � n + 1 � = ⊢ 1 ⊕ nat µ R ⊢ µ X . 1 ⊕ X ⊢ nat � �� � nat 33 / 48
Words on µ MALL Linear Logic with Induction ( µ X . A ) and Co-Induction ( ν X . A ) 1 R � n � ⊢ 1 ⊕ 1 ⊢ 1 ⊕ µ X . 1 ⊕ X µ R ⊢ nat � 0 � = � n + 1 � = ⊕ 2 ⊢ 1 ⊕ nat µ R ⊢ µ X . 1 ⊕ X � �� � ⊢ nat nat 34 / 48
Words on µ MALL Linear Logic with Induction ( µ X . A ) and Co-Induction ( ν X . A ) 1 R � n � ⊢ 1 ⊕ 1 ⊢ 1 ⊕ µ X . 1 ⊕ X µ R ⊢ nat � 0 � = � n + 1 � = ⊕ 2 ⊢ 1 ⊕ nat µ R ⊢ µ X . 1 ⊕ X � �� � ⊢ nat nat 1 R ⊢ 1 ⊕ 1 ⊢ 1 ⊕ nat µ R � 1 � = ⊢ nat ⊕ 2 ⊢ 1 ⊕ nat µ R ⊢ nat 35 / 48
Words on µ MALL Linear Logic with Induction ( µ X . A ) and Co-Induction ( ν X . A ) � 0 � ⊢ nat ⊢ ν X . nat ⊗ X ⊗ � Stream 0 � = ⊢ nat ⊗ ( ν X . nat ⊗ X ) ν R ⊢ ν X . nat ⊗ X 36 / 48
Words on µ MALL Linear Logic with Induction ( µ X . A ) and Co-Induction ( ν X . A ) � 0 � ⊢ nat ⊢ ν X . nat ⊗ X ⊗ � Stream 0 � = ⊢ nat ⊗ ( ν X . nat ⊗ X ) ν R ⊢ ν X . nat ⊗ X 37 / 48
Words on µ MALL Linear Logic with Induction and Co-Induction . . . ⊢ µ X . X µ R µ R ⊢ µ X . X µ R ⊢ µ X . X ⊢ µ X . X Infinite derivations represented as graphs 38 / 48
Words on µ MALL A derivation is valid if in every infinite branch : • Infinity of rules µ L • Infinity of rules ν R 39 / 48
From Type Derivation To Proofs Typed Terms Proofs ω : A ↔ B π : A ⊢ B ω ⊥ : B ↔ A π ⊥ : B ⊢ A 40 / 48
Recommend
More recommend