generation of verification conditions
play

Generation of Verification Conditions Andreas Podelski November 15, - PowerPoint PPT Presentation

Generation of Verification Conditions Andreas Podelski November 15, 2011 mechanization of correctness proof given a Hoare triple { } C { } , a derivation is a sequence of Hoare triples, each Hoare triple is an axiom (skip, update) or


  1. Generation of Verification Conditions Andreas Podelski November 15, 2011

  2. mechanization of correctness proof ◮ given a Hoare triple { φ } C { ψ } , a derivation is a sequence of Hoare triples, each Hoare triple is an axiom (skip, update) or it is inferred by one of the inference rules (seq, cond, while)

  3. mechanization of correctness proof ◮ given a Hoare triple { φ } C { ψ } , a derivation is a sequence of Hoare triples, each Hoare triple is an axiom (skip, update) or it is inferred by one of the inference rules (seq, cond, while) ◮ mechanization:

  4. mechanization of correctness proof ◮ given a Hoare triple { φ } C { ψ } , a derivation is a sequence of Hoare triples, each Hoare triple is an axiom (skip, update) or it is inferred by one of the inference rules (seq, cond, while) ◮ mechanization: ◮ construct a derivation assuming that side conditions hold, ◮ and then check side conditions “discharge the verification condition”

  5. mechanization of correctness proof ◮ given a Hoare triple { φ } C { ψ } , a derivation is a sequence of Hoare triples, each Hoare triple is an axiom (skip, update) or it is inferred by one of the inference rules (seq, cond, while) ◮ mechanization: ◮ construct a derivation assuming that side conditions hold, ◮ and then check side conditions “discharge the verification condition” ◮ if check does not succeed: try another derivation

  6. mechanization of correctness proof ◮ given a Hoare triple { φ } C { ψ } , a derivation is a sequence of Hoare triples, each Hoare triple is an axiom (skip, update) or it is inferred by one of the inference rules (seq, cond, while) ◮ mechanization: ◮ construct a derivation assuming that side conditions hold, ◮ and then check side conditions “discharge the verification condition” ◮ if check does not succeed: try another derivation ◮ next: deterministic strategy to construct unique derivation

  7. System H (1) ◮ Hoare triple { φ } C { ψ } derivable in H if exists a derivation using the axioms and inference rules of H

  8. System H (1) ◮ Hoare triple { φ } C { ψ } derivable in H if exists a derivation using the axioms and inference rules of H ◮ skip { φ } skip { φ }

  9. System H (1) ◮ Hoare triple { φ } C { ψ } derivable in H if exists a derivation using the axioms and inference rules of H ◮ skip { φ } skip { φ } ◮ assignment { ψ [ e / x ] } x := e { ψ }

  10. System H (2) ◮ sequential command C ≡ C 1 ; C 2 { φ } C 1 { φ ′ } { φ ′ } C { ψ } { φ } C { ψ }

  11. System H (2) ◮ sequential command C ≡ C 1 ; C 2 { φ } C 1 { φ ′ } { φ ′ } C { ψ } { φ } C { ψ } ◮ conditional command C ≡ if b then C 1 else C 2 { φ ∧ b } C 1 { ψ } { φ ∧ ¬ b } C { ψ } { φ } C { ψ }

  12. System H (3) ◮ while command C ≡ while b do { θ } C 0 { θ ∧ b } C 0 { θ } { θ } C { θ ∧ ¬ b }

  13. System H (3) ◮ while command C ≡ while b do { θ } C 0 { θ ∧ b } C 0 { θ } { θ } C { θ ∧ ¬ b } ◮ strengthen precondition, weaken postcondition { φ } C { ψ } { φ ′ } C { ψ ′ } if φ ′ → φ and ψ → ψ ′

  14. System H (3) ◮ while command C ≡ while b do { θ } C 0 { θ ∧ b } C 0 { θ } { θ } C { θ ∧ ¬ b } ◮ strengthen precondition, weaken postcondition { φ } C { ψ } { φ ′ } C { ψ ′ } if φ ′ → φ and ψ → ψ ′

  15. System H (3) ◮ while command C ≡ while b do { θ } C 0 { θ ∧ b } C 0 { θ } { θ } C { θ ∧ ¬ b } ◮ strengthen precondition, weaken postcondition { φ } C { ψ } { φ ′ } C { ψ ′ } if φ ′ → φ and ψ → ψ ′ ◮ Hoare triple derivable in all logicals models in which implications in side condition are valid

  16. backward construction of derivation ◮ given Hoare triple { φ } C { ψ } , “guess inference rule and guess assumptions” generate Hoare triples from which we could infer { φ } C { ψ } . . . and collect side conditions of inference rule (if any)

  17. backward construction of derivation ◮ given Hoare triple { φ } C { ψ } , “guess inference rule and guess assumptions” generate Hoare triples from which we could infer { φ } C { ψ } . . . and collect side conditions of inference rule (if any) ◮ repeat on generated Hoare triples to generate new Hoare triples until every Hoare triple is an axiom

  18. mechanize backward inference ◮ given Hoare triple { φ } C { ψ } , from what Hoare triples could we have inferred it? . . . using what inference rule?

  19. mechanize backward inference ◮ given Hoare triple { φ } C { ψ } , from what Hoare triples could we have inferred it? . . . using what inference rule? ◮ next: go through each form of command C (skip, update, seq, cond, while)

  20. backward inference ◮ ??? { φ } skip { ψ }

  21. backward inference ◮ ??? { φ } skip { ψ } ◮ derivation can use what axiom and what inference rule?

  22. backward inference ◮ ??? { φ } skip { ψ } ◮ derivation can use what axiom and what inference rule? ◮ axiom for skip { φ } skip { φ }

  23. backward inference ◮ ??? { φ } skip { ψ } ◮ derivation can use what axiom and what inference rule? ◮ axiom for skip { φ } skip { φ } ◮ ‘strengthen precondition, weaken postcondition’ inference rule { φ } C { ψ } { φ ′ } C { ψ ′ } if φ ′ → φ and ψ → ψ ′

  24. backward inference ◮ ??? { φ } skip { ψ }

  25. backward inference ◮ ??? { φ } skip { ψ } ◮ possible derivation sequence: axiom for (skip), followed by weaking of postcondition { φ } skip { φ } { φ } skip { ψ }

  26. backward inference ◮ ??? { φ } skip { ψ } ◮ possible derivation sequence: axiom for (skip), followed by weaking of postcondition { φ } skip { φ } { φ } skip { ψ } ◮ side condition: φ → ψ

  27. backward inference ◮ ??? { φ } skip { ψ } ◮ possible derivation sequence: axiom for (skip), followed by weaking of postcondition { φ } skip { φ } { φ } skip { ψ } ◮ side condition: φ → ψ ◮ possible derivation sequence: axiom for (skip), followed by strengthening of precondition { ψ } skip { ψ } { φ } skip { ψ }

  28. backward inference ◮ ??? { φ } skip { ψ } ◮ possible derivation sequence: axiom for (skip), followed by weaking of postcondition { φ } skip { φ } { φ } skip { ψ } ◮ side condition: φ → ψ ◮ possible derivation sequence: axiom for (skip), followed by strengthening of precondition { ψ } skip { ψ } { φ } skip { ψ } ◮ same side condition: φ → ψ

  29. new axiom for skip ◮ { φ } skip { ψ } if φ → ψ

  30. new axiom for skip ◮ { φ } skip { ψ } if φ → ψ ◮ old axiom & strengthening of precondition

  31. new axiom for skip ◮ { φ } skip { ψ } if φ → ψ ◮ old axiom & strengthening of precondition ◮ φ is a precondition for ψ under skip if and only if φ → ψ is valid

  32. new axiom for skip ◮ { φ } skip { ψ } if φ → ψ ◮ old axiom & strengthening of precondition ◮ φ is a precondition for ψ under skip if and only if φ → ψ is valid ◮ ψ is the weakest precondition for ψ under skip

  33. new axiom for update ◮ { φ } x := e { ψ } if φ → ψ [ e / x ]

  34. new axiom for update ◮ { φ } x := e { ψ } if φ → ψ [ e / x ] ◮ old axiom & strengthening of precondition

  35. new axiom for update ◮ { φ } x := e { ψ } if φ → ψ [ e / x ] ◮ old axiom & strengthening of precondition ◮ φ is a precondition for ψ under x := e if and only if φ → ψ [ e / x ] is valid

  36. new axiom for update ◮ { φ } x := e { ψ } if φ → ψ [ e / x ] ◮ old axiom & strengthening of precondition ◮ φ is a precondition for ψ under x := e if and only if φ → ψ [ e / x ] is valid ◮ ψ [ e / x ] is the weakest precondition for ψ under x := e

  37. new rule for seq ◮ old rule: { φ } C 1 { θ } { θ } C 2 { ψ } { φ } C 1 ; C 2 { ψ }

  38. new rule for seq ◮ old rule: { φ } C 1 { θ } { θ } C 2 { ψ } { φ } C 1 ; C 2 { ψ } ◮ new rule: { φ 1 } C 1 { φ 2 } { φ 2 } C 2 { ψ } φ → φ 1 { φ } C 1 ; C 2 { ψ }

  39. new rule for seq ◮ old rule: { φ } C 1 { θ } { θ } C 2 { ψ } { φ } C 1 ; C 2 { ψ } ◮ new rule: { φ 1 } C 1 { φ 2 } { φ 2 } C 2 { ψ } φ → φ 1 { φ } C 1 ; C 2 { ψ } ◮ let φ 2 be the weakest precondition of ψ under C 2 and let φ 1 be the weakest precondition of φ 2 under C 1

  40. new rule for seq ◮ old rule: { φ } C 1 { θ } { θ } C 2 { ψ } { φ } C 1 ; C 2 { ψ } ◮ new rule: { φ 1 } C 1 { φ 2 } { φ 2 } C 2 { ψ } φ → φ 1 { φ } C 1 ; C 2 { ψ } ◮ let φ 2 be the weakest precondition of ψ under C 2 and let φ 1 be the weakest precondition of φ 2 under C 1 ◮ φ is a precondition for ψ under C 1 ; C 2 if and only if φ → φ 1 is valid

  41. new rule for seq ◮ old rule: { φ } C 1 { θ } { θ } C 2 { ψ } { φ } C 1 ; C 2 { ψ } ◮ new rule: { φ 1 } C 1 { φ 2 } { φ 2 } C 2 { ψ } φ → φ 1 { φ } C 1 ; C 2 { ψ } ◮ let φ 2 be the weakest precondition of ψ under C 2 and let φ 1 be the weakest precondition of φ 2 under C 1 ◮ φ is a precondition for ψ under C 1 ; C 2 if and only if φ → φ 1 is valid ◮ the weakest precondition of ψ under C 1 ; C 2 is the weakest precondition of (the weakest precondition of ψ under C 2 ) under C 1

  42. new rule for cond ◮ old rule: { φ ∧ b } C 1 { ψ } { φ ∧ ¬ b } C 2 { ψ } { φ } if b then C 1 else C 2 { ψ }

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend