quantum hoare type theory
play

Quantum Hoare Type Theory John Reppy Kartik Singhal Department of - PowerPoint PPT Presentation

Quantum Hoare Type Theory John Reppy Kartik Singhal Department of Computer Science University of Chicago Quantum Physics and Logic (QPL) 2020 Quantum programming is inherently imperative and difficult to reason about 2 / 12 Quantum


  1. Quantum Hoare Type Theory John Reppy Kartik Singhal Department of Computer Science University of Chicago Quantum Physics and Logic (QPL) 2020

  2. Quantum programming is inherently imperative and difficult to reason about 2 / 12

  3. Quantum programming is inherently imperative and difficult to reason about In classical programming Hoare triples are used to reason about state changes. { P } c { Q } c is the command to be executed; P , Q are pre and postconditions on state. 2 / 12

  4. Quantum programming is inherently imperative and difficult to reason about In classical programming Hoare triples are used to reason about state changes. { P } c { Q } c is the command to be executed; P , Q are pre and postconditions on state. In pure functional settings, monads can encapsulate effects. 2 / 12

  5. Quantum programming is inherently imperative and difficult to reason about In classical programming Hoare triples are used to reason about state changes. { P } c { Q } c is the command to be executed; P , Q are pre and postconditions on state. In pure functional settings, monads can encapsulate effects. Can we combine Hoare triples with monadic types? 2 / 12

  6. Quantum programming is inherently imperative and difficult to reason about In classical programming Hoare triples are used to reason about state changes. { P } c { Q } c is the command to be executed; P , Q are pre and postconditions on state. In pure functional settings, monads can encapsulate effects. Can we combine Hoare triples with monadic types? Yes, thanks to Hoare Type Theory! 2 / 12

  7. Quantum programming is inherently imperative and difficult to reason about In classical programming Hoare triples are used to reason about state changes. { P } c { Q } c is the command to be executed; P , Q are pre and postconditions on state. In pure functional settings, monads can encapsulate effects. Can we combine Hoare triples with monadic types? Yes, thanks to Hoare Type Theory! For quantum programming? 2 / 12

  8. Outline Motivation Background Hoare Type Theory (HTT). Nanevski et al, ’07 Quantum IO Monad (QIO). Altenkirch & Green, ’09 Quantum Hoare Type Theory (QHTT) Examples Typing Rules Verification Ongoing & Future Work Conclusion 3 / 12

  9. Outline Motivation Background Hoare Type Theory (HTT). Nanevski et al, ’07 Quantum IO Monad (QIO). Altenkirch & Green, ’09 Quantum Hoare Type Theory (QHTT) Examples Typing Rules Verification Ongoing & Future Work Conclusion

  10. Hoare Types specify pre and postconditions and are very expressive ∆ . Ψ . { P } x : A { Q } 4 / 12

  11. Hoare Types specify pre and postconditions and are very expressive ∆ . Ψ . { P } x : A { Q } P , Q are pre and postconditions (as before) 4 / 12

  12. Hoare Types specify pre and postconditions and are very expressive ∆ . Ψ . { P } x : A { Q } P , Q are pre and postconditions (as before) x is the return value of type A 4 / 12

  13. Hoare Types specify pre and postconditions and are very expressive ∆ . Ψ . { P } x : A { Q } P , Q are pre and postconditions (as before) x is the return value of type A ∆ and Ψ are variable and heap contexts 4 / 12

  14. Hoare Types specify pre and postconditions and are very expressive ∆ . Ψ . { P } x : A { Q } P , Q are pre and postconditions (as before) x is the return value of type A ∆ and Ψ are variable and heap contexts For example, the type of the alloc primitive from HTT: ∀ α. Π x : α. { emp } y : nat { y �→ α x } which is a polymorphic function that takes as input x of any type α and returns a new location y of type nat after initializing it with x . 4 / 12

  15. Outline Motivation Background Hoare Type Theory (HTT). Nanevski et al, ’07 Quantum IO Monad (QIO). Altenkirch & Green, ’09 Quantum Hoare Type Theory (QHTT) Examples Typing Rules Verification Ongoing & Future Work Conclusion

  16. QIO is a monadic interface for quantum programming implemented in Haskell QIO monad is indexed by the type of computational result. mkQbit :: Bool → QIO Qbit -- initialization applyU :: U → QIO () -- apply a unitary measQbit :: Qbit → QIO Bool -- measurement 5 / 12

  17. QIO is a monadic interface for quantum programming implemented in Haskell QIO monad is indexed by the type of computational result. mkQbit :: Bool → QIO Qbit -- initialization applyU :: U → QIO () -- apply a unitary measQbit :: Qbit → QIO Bool -- measurement Arbitrary unitaries can be defined using: rot :: Qbit → ((Bool, Bool) → C) → U ifQ :: Qbit → U → U 5 / 12

  18. QIO is a monadic interface for quantum programming implemented in Haskell QIO monad is indexed by the type of computational result. mkQbit :: Bool → QIO Qbit -- initialization applyU :: U → QIO () -- apply a unitary measQbit :: Qbit → QIO Bool -- measurement Arbitrary unitaries can be defined using: rot :: Qbit → ((Bool, Bool) → C) → U ifQ :: Qbit → U → U U is monoid with sequencing as its operation and identity as the neutral element. 5 / 12

  19. Outline Motivation Background Hoare Type Theory (HTT). Nanevski et al, ’07 Quantum IO Monad (QIO). Altenkirch & Green, ’09 Quantum Hoare Type Theory (QHTT) Examples Typing Rules Verification Ongoing & Future Work Conclusion

  20. Programming in Quantum Hoare Type Theory We further index the QIO monad with pre and postconditions to get a Hoare monad. 6 / 12

  21. Programming in Quantum Hoare Type Theory We further index the QIO monad with pre and postconditions to get a Hoare monad. Hello Quantum World: hqw : {emp} r : Bool {emp ∧ Id(r, false)} 6 / 12

  22. Programming in Quantum Hoare Type Theory We further index the QIO monad with pre and postconditions to get a Hoare monad. Hello Quantum World: hqw : {emp} r : Bool {emp ∧ Id(r, false)} = do q ⇐ mkQbit false; measQbit q 6 / 12

  23. Programming in Quantum Hoare Type Theory We further index the QIO monad with pre and postconditions to get a Hoare monad. Hello Quantum World: hqw : {emp} r : Bool {emp ∧ Id(r, false)} = do q ⇐ mkQbit false; measQbit q Quantum Coin Toss: rnd : {emp} r : Bool {emp} = do q ⇐ mkQbit false; applyU (H q); measQbit q 6 / 12

  24. Programming in Quantum Hoare Type Theory We further index the QIO monad with pre and postconditions to get a Hoare monad. Hello Quantum World: hqw : {emp} r : Bool {emp ∧ Id(r, false)} = do q ⇐ mkQbit false; measQbit q Quantum Coin Toss: rnd : {emp} r : Bool {emp} = do q ⇐ mkQbit false; applyU (H q); measQbit q But how do we reason about these programs? 6 / 12

  25. Outline Motivation Background Hoare Type Theory (HTT). Nanevski et al, ’07 Quantum IO Monad (QIO). Altenkirch & Green, ’09 Quantum Hoare Type Theory (QHTT) Examples Typing Rules Verification Ongoing & Future Work Conclusion

  26. Strongest Postcondition for Initialization x ⇐ mkQbit M ; E 7 / 12

  27. Strongest Postcondition for Initialization x ⇐ mkQbit M ; E HTT uses bidirectional typing for type inference, where 7 / 12

  28. Strongest Postcondition for Initialization x ⇐ mkQbit M ; E HTT uses bidirectional typing for type inference, where e ⇐ A means ‘expression e checks against type A ’, and, 7 / 12

  29. Strongest Postcondition for Initialization x ⇐ mkQbit M ; E HTT uses bidirectional typing for type inference, where e ⇐ A means ‘expression e checks against type A ’, and, e ⇒ A means ‘expression e synthesizes the type A ’. 7 / 12

  30. Strongest Postcondition for Initialization x ⇐ mkQbit M ; E HTT uses bidirectional typing for type inference, where e ⇐ A means ‘expression e checks against type A ’, and, e ⇒ A means ‘expression e synthesizes the type A ’. x ⇐ mkQbit M ; E 7 / 12

  31. Strongest Postcondition for Initialization x ⇐ mkQbit M ; E HTT uses bidirectional typing for type inference, where e ⇐ A means ‘expression e checks against type A ’, and, e ⇒ A means ‘expression e synthesizes the type A ’. ∆; P ⊢ x ⇐ mkQbit M ; E 7 / 12

  32. Strongest Postcondition for Initialization x ⇐ mkQbit M ; E HTT uses bidirectional typing for type inference, where e ⇐ A means ‘expression e checks against type A ’, and, e ⇒ A means ‘expression e synthesizes the type A ’. ∆; P ⊢ x ⇐ mkQbit M ; E ⇒ y : B . ( ∃ x : Qbit . Q ) 7 / 12

  33. Strongest Postcondition for Initialization x ⇐ mkQbit M ; E HTT uses bidirectional typing for type inference, where e ⇐ A means ‘expression e checks against type A ’, and, e ⇒ A means ‘expression e synthesizes the type A ’. ∆ ⊢ M ⇐ Bool ∆; P ⊢ x ⇐ mkQbit M ; E ⇒ y : B . ( ∃ x : Qbit . Q ) 7 / 12

  34. Strongest Postcondition for Initialization x ⇐ mkQbit M ; E HTT uses bidirectional typing for type inference, where e ⇐ A means ‘expression e checks against type A ’, and, e ⇒ A means ‘expression e synthesizes the type A ’. ∆ ⊢ M ⇐ Bool ∆ P ⊢ E ⇒ y : B . Q ∆; P ⊢ x ⇐ mkQbit M ; E ⇒ y : B . ( ∃ x : Qbit . Q ) 7 / 12

  35. Strongest Postcondition for Initialization x ⇐ mkQbit M ; E HTT uses bidirectional typing for type inference, where e ⇐ A means ‘expression e checks against type A ’, and, e ⇒ A means ‘expression e synthesizes the type A ’. ∆ ⊢ M ⇐ Bool ∆ , x : Qbit ; P ⊢ E ⇒ y : B . Q ∆; P ⊢ x ⇐ mkQbit M ; E ⇒ y : B . ( ∃ x : Qbit . Q ) 7 / 12

Recommend


More recommend