time credits and time receipts in iris
play

Time credits and time receipts in Iris Glen Mvel , Jacques-Henri - PowerPoint PPT Presentation

Time credits and time receipts in Iris Glen Mvel , Jacques-Henri Jourdan, Franois Pottier Inria CNRS, LRI, Univ. Paris Sud, Universit Paris-Saclay April 8, 2019 Prague Introduction Problem Time receipts in action Soundness Conclusion


  1. Time credits and time receipts in Iris Glen Mével , Jacques-Henri Jourdan, François Pottier Inria CNRS, LRI, Univ. Paris Sud, Université Paris-Saclay April 8, 2019 Prague

  2. Introduction Problem Time receipts in action Soundness Conclusion This talk recent works: time credits aim: prove an upper bound on the running time of a program this talk: time receipts aim: assume an upper bound on the running time of a program These are dual notions. Glen Mével , Jacques-Henri Jourdan, François Pottier Time credits and time receipts in Iris 1 / 17

  3. Introduction Problem Time receipts in action Soundness Conclusion This talk recent works: time credits aim: prove an upper bound on the running time of a program this talk: time receipts aim: assume an upper bound on the running time of a program These are dual notions. Glen Mével , Jacques-Henri Jourdan, François Pottier Time credits and time receipts in Iris 1 / 17

  4. Introduction Problem Time receipts in action Soundness Conclusion Example: a unique symbol generator The function genSym returns fresh symbols: let lastSym = ref 0 let genSym () = lastSym . . = ! lastSym + 1 ; ! lastSym Glen Mével , Jacques-Henri Jourdan, François Pottier Time credits and time receipts in Iris 2 / 17

  5. Introduction Problem Time receipts in action Soundness Conclusion Example: a unique symbol generator The function genSym returns fresh symbols: let lastSym = ref 0 (* unsigned 64-bit integer *) let genSym () = lastSym . . = ! lastSym + 1 ; (* may overflow! *) ! lastSym Strictly speaking, this code is not correct. Glen Mével , Jacques-Henri Jourdan, François Pottier Time credits and time receipts in Iris 2 / 17

  6. Introduction Problem Time receipts in action Soundness Conclusion Example: a unique symbol generator The function genSym returns fresh symbols: let lastSym = ref 0 (* unsigned 64-bit integer *) let genSym () = lastSym . . = ! lastSym + 1 ; (* may overflow! *) ! lastSym Strictly speaking, this code is not correct. We still want to prove that this code is “correct” in some sense. Glen Mével , Jacques-Henri Jourdan, François Pottier Time credits and time receipts in Iris 2 / 17

  7. Introduction Problem Time receipts in action Soundness Conclusion The Bounded Time Hypothesis [Clochard et al. , 2015] Counting from 0 to 2 64 takes centuries with a modern processor. Therefore, this overflow won’t happen in a lifetime. How to express this informal argument in separation logic? Glen Mével , Jacques-Henri Jourdan, François Pottier Time credits and time receipts in Iris 3 / 17

  8. Introduction Problem Time receipts in action Soundness Conclusion The Bounded Time Hypothesis [Clochard et al. , 2015] Counting from 0 to 2 64 takes centuries with a modern processor. Therefore, this overflow won’t happen in a lifetime. How to express this informal argument in separation logic? In this talk: We answer this question using time receipts . We prove that Iris, extended with time receipts, is sound . Glen Mével , Jacques-Henri Jourdan, François Pottier Time credits and time receipts in Iris 3 / 17

  9. A closer look at the problem

  10. Introduction Problem Time receipts in action Soundness Conclusion Specification of genSym A specification (in separation logic):   { P S }   P ∅ ∗ ∀ S . genSym ()   { λ n . n / ∈ S ∗ P ( S ∪ { n } ) } for some proposition P S which represents: the ownership of the generator; the fact that S is the set of all symbols returned so far. Glen Mével , Jacques-Henri Jourdan, François Pottier Time credits and time receipts in Iris 4 / 17

  11. Introduction Problem Time receipts in action Soundness Conclusion Tentative proof of genSym let lastSym = ref 0 let genSym () = lastSym . . = ! lastSym + 1 ; ! lastSym Glen Mével , Jacques-Henri Jourdan, François Pottier Time credits and time receipts in Iris 5 / 17

  12. Introduction Problem Time receipts in action Soundness Conclusion Tentative proof of genSym {} let lastSym = ref 0 { P ∅} { P S } let genSym () = lastSym . . = ! lastSym + 1 ; ! lastSym { λ n . n / ∈ S ∗ P ( S ∪ { n } ) } Glen Mével , Jacques-Henri Jourdan, François Pottier Time credits and time receipts in Iris 5 / 17

  13. Introduction Problem Time receipts in action Soundness Conclusion Tentative proof of genSym Invariant: P S � lastSym �→ max S {} let lastSym = ref 0 { P ∅} { P S } let genSym () = lastSym . . = ! lastSym + 1 ; ! lastSym { λ n . n / ∈ S ∗ P ( S ∪ { n } ) } Glen Mével , Jacques-Henri Jourdan, François Pottier Time credits and time receipts in Iris 5 / 17

  14. Introduction Problem Time receipts in action Soundness Conclusion Tentative proof of genSym Invariant: P S � lastSym �→ max S {} let lastSym = ref 0 { lastSym �→ 0 } { P ∅} { P S } let genSym () = { lastSym �→ max S } lastSym . . = ! lastSym + 1 ; { lastSym �→ ⌊ max S + 1 ⌋ 2 64 } { ⌊ max S + 1 ⌋ 2 64 / ∈ S ∗ lastSym �→ ⌊ max S + 1 ⌋ 2 64 } ! lastSym { λ n . n / ∈ S ∗ lastSym �→ n } { λ n . n / ∈ S ∗ P ( S ∪ { n } ) } Glen Mével , Jacques-Henri Jourdan, François Pottier Time credits and time receipts in Iris 5 / 17

  15. Introduction Problem Time receipts in action Soundness Conclusion Tentative proof of genSym Invariant: P S � lastSym �→ max S {} let lastSym = ref 0 { lastSym �→ 0 } { P ∅} { P S } let genSym () = { lastSym �→ max S } lastSym . . = ! lastSym + 1 ; { lastSym �→ ⌊ max S + 1 ⌋ 2 64 } Wrong {⌊ max S + 1 ⌋ 2 64 / ∈ S ∗ lastSym �→ ⌊ max S + 1 ⌋ 2 64 } ! lastSym { λ n . n / ∈ S ∗ lastSym �→ n } { λ n . n / ∈ S ∗ P ( S ∪ { n } ) } Glen Mével , Jacques-Henri Jourdan, François Pottier Time credits and time receipts in Iris 5 / 17

  16. Introduction Problem Time receipts in action Soundness Conclusion An unpleasant workaround: patch the specification We may add a precondition to exclude any chance of overflow: { P S ∗ | S | < 2 64 − 1 }     P ∅ ∗ ∀ S . genSym ()   { λ n . n / ∈ S ∗ P ( S ∪ { n } ) } This pollutes user proofs with cumbersome proof obligations. . . which may even be unprovable! Glen Mével , Jacques-Henri Jourdan, François Pottier Time credits and time receipts in Iris 6 / 17

  17. Time receipts in action

  18. Introduction Problem Time receipts in action Soundness Conclusion Time receipts in separation logic To count execution steps, we introduce time receipts . Each step produces one time receipt, and only one : { True } x + y { λ z . z = ⌊ x + y ⌋ 2 64 ∗ � 1 } � Time receipts sum up: � 1 ∗ . . . ∗ � 1 ≡ � n � �� � n But time receipts do not duplicate (separation logic): � 1 �− ∗ � 1 ∗ � 1 Therefore, � n is a witness that (at least) n steps have been taken. Glen Mével , Jacques-Henri Jourdan, François Pottier Time credits and time receipts in Iris 7 / 17

  19. Introduction Problem Time receipts in action Soundness Conclusion Proof of genSym using time receipts Invariant: P S � lastSym �→ max S {} let lastSym = ref 0 { lastSym �→ 0 } { P ∅} { P S } let genSym () = { lastSym �→ max S } lastSym . . = ! lastSym + 1 ; { lastSym �→ ⌊ max S + 1 ⌋ 2 64 } {⌊ max S + 1 ⌋ 2 64 / ∈ S ∗ lastSym �→ ⌊ max S + 1 ⌋ 2 64 } ! lastSym { λ n . n / ∈ S ∗ lastSym �→ n } { λ n . n / ∈ S ∗ P ( S ∪ { n } ) } Glen Mével , Jacques-Henri Jourdan, François Pottier Time credits and time receipts in Iris 8 / 17

  20. Introduction Problem Time receipts in action Soundness Conclusion Proof of genSym using time receipts Invariant: P S � lastSym �→ max S ∗ � ( max S ) {} let lastSym = ref 0 { lastSym �→ 0 } We keep track of elapsed time. { P ∅} { P S } let genSym () = { lastSym �→ max S } lastSym . . = ! lastSym + 1 ; { lastSym �→ ⌊ max S + 1 ⌋ 2 64 } {⌊ max S + 1 ⌋ 2 64 / ∈ S ∗ lastSym �→ ⌊ max S + 1 ⌋ 2 64 } ! lastSym { λ n . n / ∈ S ∗ lastSym �→ n } { λ n . n / ∈ S ∗ P ( S ∪ { n } ) } Glen Mével , Jacques-Henri Jourdan, François Pottier Time credits and time receipts in Iris 8 / 17

  21. Introduction Problem Time receipts in action Soundness Conclusion Proof of genSym using time receipts Invariant: P S � lastSym �→ max S ∗ � ( max S ) {} let lastSym = ref 0 { lastSym �→ 0 ∗ � 0 } { P ∅} { P S } let genSym () = { lastSym �→ max S ∗ � max S } lastSym . . = ! lastSym + 1 ; { lastSym �→ ⌊ max S + 1 ⌋ 2 64 ∗ � ( max S + 1 ) } {⌊ max S + 1 ⌋ 2 64 / ∈ S ∗ lastSym �→ ⌊ max S + 1 ⌋ 2 64 ∗ � ( max S + 1 ) } ! lastSym { λ n . n / ∈ S ∗ lastSym �→ n ∗ � n } { λ n . n / ∈ S ∗ P ( S ∪ { n } ) } Glen Mével , Jacques-Henri Jourdan, François Pottier Time credits and time receipts in Iris 8 / 17

  22. Introduction Problem Time receipts in action Soundness Conclusion Proof of genSym using time receipts Invariant: P S � lastSym �→ max S ∗ � ( max S ) {} let lastSym = ref 0 { lastSym �→ 0 ∗ � 0 } Initialization { P ∅} We obtain 0 time receipts for free. { P S } let genSym () = { lastSym �→ max S ∗ � max S } lastSym . . = ! lastSym + 1 ; { lastSym �→ ⌊ max S + 1 ⌋ 2 64 ∗ � ( max S + 1 ) } {⌊ max S + 1 ⌋ 2 64 / ∈ S ∗ lastSym �→ ⌊ max S + 1 ⌋ 2 64 ∗ � ( max S + 1 ) } ! lastSym { λ n . n / ∈ S ∗ lastSym �→ n ∗ � n } { λ n . n / ∈ S ∗ P ( S ∪ { n } ) } Glen Mével , Jacques-Henri Jourdan, François Pottier Time credits and time receipts in Iris 8 / 17

Recommend


More recommend