hoare logic and model checking
play

Hoare Logic and Model Checking Model Checking Lecture 10: - PowerPoint PPT Presentation

Hoare Logic and Model Checking Model Checking Lecture 10: Computation Tree Logic (CTL) Dominic Mulligan Based on previous slides by Alan Mycroft and Mike Gordon Programming, Logic, and Semantics Group University of Cambridge Academic year


  1. Hoare Logic and Model Checking Model Checking Lecture 10: Computation Tree Logic (CTL) Dominic Mulligan Based on previous slides by Alan Mycroft and Mike Gordon Programming, Logic, and Semantics Group University of Cambridge Academic year 2016–2017 1

  2. Learning outcomes By the end of this lecture, you should: • Be familiar with the branching model of time • Be familiar with CTL syntax and semantics • Understand CTL semantic equivalence, and why it is important • Be familiar with important CTL equivalences • Be familiar with Existential Normal Form 2

  3. Branching model of time

  4. Branching time CTL’s conception of time: • At each moment in time exactly potentially multiple futures • Time “branches” into multiple futures at each state • Quantify over possible futures CTL therefore describes “state properties” of systems CTL formulae describe states in transition system 3

  5. A note on models Note: by changing model of time, not changed underlying model CTL models are based on right-serial transition systems, same as LTL Changing conception of time: • Affects properties that can be expressed by formulae • Affects what CTL formulae describe (states, not paths) 4

  6. CTL syntax

  7. Atomic propositions 5 Like in LTL, we fjx a set AP of atomic propositions We continue to use p , q , r , and so on to range over AP

  8. CTL state and path formulae Defjne state formulae with the following grammar: and path formulae with the following grammar: In semantics of CTL: • Path formulae are evaluated relative to a path • State formulae are evaluated relative to a state 6 Φ , Ψ , Ξ ::= ⊤ | ⊥ | p ::= ¬ Φ ::= Φ ∧ Ψ | Φ ∨ Ψ | Φ ⇒ Ψ ::= ∀ φ | ∃ φ φ, ψ, ξ ::= � Φ | � Φ | ♦ Φ | Φ UNTIL Ψ

  9. Intuitive explanation of CTL formulae First line (of state formula grammar): The last should now be familiar too! 7 ⊤ | ⊥ | p ⊤ , ⊥ , and p for p atomic are all primitive CTL state formulae • ⊤ is the logical truth constant (or “true”), • ⊥ is the logical falsity constant (or “false”), • p is the embedding of atomic propositions into CTL formulae

  10. Intuitive explanation of CTL formulae Second line (of state formula grammar): 8 ¬ Φ If Φ is a CTL state formula, then ¬ Φ is a CTL state formula • ¬ Φ is negation of φ (or “not Φ ”)

  11. Intuitive explanation of CTL formulae Third line (of state formula grammar): 9 Φ ∧ Ψ | Φ ∨ Ψ | Φ ⇒ Ψ If Φ and Ψ are CTL state formulae, then so are Φ ∧ Ψ , Φ ∨ Ψ , Φ ⇒ Ψ • Φ ∧ Ψ is conjunction (or “ Φ and Ψ ”) • Φ ∨ Ψ is disjunction (or “ Φ or Ψ ”) • Φ ⇒ Ψ is implication (or “if Φ then Ψ ”, or “ ψ whenever φ ”)

  12. Intuitive explanation of CTL formulae Last line (of state formula grammar): formulae Specifjc to CTL! 10 ∀ φ | ∃ φ If φ and ψ are CTL path formulae, then ∀ φ and ∃ φ are CTL state • ∀ φ is “ φ along every path that starts here” • ∃ φ is “ φ along at least one path that starts here”, or “there exists a path where φ holds”

  13. Intuitive explanation of CTL formulae Path formula grammar: are CTL path formulae 11 � Φ | � Φ | ♦ Φ | Φ UNTIL Ψ If Φ and Ψ are CTL state formulae, then � Φ , � Φ , ♦ Φ , and Φ UNTIL Ψ • � Φ is “henceforth Φ ”, or “from now, always Φ ” • ♦ Φ is “at some future point Φ ” • � Φ is “immediately after Φ ”, or “in the next state Φ ” • Φ UNTIL Ψ is “at some future point Ψ , but until then Φ ”

  14. Alternative syntax for modalities Grammar above enforces path formula be “covered” by quantifjer Effect is to have 12 Impossible to construct � ∀ φ or ∃ φ UNTIL Ψ ∀ � Φ ∃ � Φ ∀ ♦ Φ ∃ ♦ Φ ∀ � Φ ∃ � Φ ∀ (Φ UNTIL Ψ) ∃ (Φ UNTIL Ψ) ∀ � , ∃� , and so on, are “derived modalities”

  15. Alternative syntax for modalities Some collapse grammar of CTL into a single grammar of “formulae” Less clear (to me, anyway) what is going on: • Path formulae evaluated relative to paths • State formulae relative to states Might also see (e.g. in “Logic in Computer Science”): 13 • ∀ and ∃ are instructions: “go off and examine paths” • Grammar closer to grammar of CTL ⋆ • A and E instead of ∀ and ∃ • X , G , F , and U instead of � , � , ♦ , and UNTIL

  16. Operator precedence We add parentheses freely to disambiguate Assign precedence to reduce number of parentheses needed: 14 • Unary ¬ , ∀ , ∃ , � , ♦ , and � bind most tightly • After that UNTIL • After that ∨ and ∧ • Finally ⇒ binds least tightly

  17. Precedence examples So: means means means and so on... 15 Φ ⇒ ∀ � Ψ Φ ⇒ ( ∀ ( � Ψ)) Φ ⇒ Ψ ∨ ∃ � Ψ Φ ⇒ (Φ ∨ ( ∃ ( � Ψ))) ∀ � Φ ∨ Ξ ⇒ Ψ UNTIL Ξ (( ∀ ( � Φ)) ∨ Ξ) ⇒ (Ψ UNTIL Ξ)

  18. Example CTL formulae can be read as: it is possible to get to a state where “started” holds but “ready” does not 16 Suppose started and ready are atomic propositions, then: ∃ ♦ ( started ∧ ¬ ready )

  19. Example CTL formulae can be read as: it is not possible to get to a state where “started” holds but “ready” does not 17 Suppose started and ready are atomic propositions, then: ∀ � ¬ ( started ∧ ¬ ready )

  20. Example CTL formulae can be read as: the system will always progress to a state where it is henceforth permanently “deadlocked” 18 Suppose deadlock is an atomic proposition, then: ∀ ♦ ∀ � deadlock

  21. Example CTL formulae atomic propositions, then: can be read as: A lift on the second fmoor travelling upwards will always continue to travel upwards until reaching level 5 whenever it contains passengers wishing to reach that fmoor 19 Suppose floor2 , floor5 , direction _ up , and button _ pressed _ 5 are ∀ � ( floor2 ∧ direction _ up ∧ button _ pressed _ 5 ⇒ ∀ ( direction _ up UNTIL floor5 ))

  22. Semantics of CTL

  23. Making intuition precise Previous examples: • Showed examples of properties expressible in CTL, • Provided intuition for meaning of CTL formulae Time to make that intuition precise... 20

  24. Models for CTL 21 Recall M = � S, S 0 , → , L� , where: • S set of states • S 0 ⊆ S set of initial states • → ⊆ S × S (right-serial) transition relation on S • L : S → P ( AP ) labelling function “Right serial” means ∀ s ∈ S. ∃ s ′ ∈ S.s → s ′

  25. Infjnite paths of states 22 Fix a CTL model M = � S, S 0 , → , L� Write Paths ( s ) for set of infjnite paths of S starting at s Write π [ i ] for i th state of π (“indexing”) Write π i for suffjx of π starting position i

  26. Satisfaction at a state always never 23 Suppose M is a model, s is a state in M , and Φ is a state formula Defjne the satisfaction relation s | = Φ recursively by: s | = ⊤ s | = ⊥ s | = p iff p ∈ L ( s ) s | = ¬ Φ iff not s | = Φ

  27. Satisfaction at a state 24 s | = Φ ∨ Ψ iff s | = Φ or s | = Ψ s | = Φ ∧ Ψ iff s | = Φ and s | = Ψ s | = Φ ⇒ Ψ iff not s | = Φ or if s | = Φ and s | = Ψ

  28. Satisfaction at a state 25 s | = ∀ φ iff π | = φ for every π ∈ Paths ( s ) s | = ∃ φ iff π | = φ for some π ∈ Paths ( s ) π | = φ is the evaluation of path formula φ relative to a path π

  29. Satisfaction along a path 26 Suppose M is a model, π is a path in M , and φ is a path formula Defjne the satisfaction relation π | = φ by: π | = � Φ iff π [1] | = Φ π | = � Φ iff π [ i ] | = Φ for all i π | = ♦ Φ iff π [ i ] | = Φ for some i π | = Φ UNTIL Ψ iff π [ i ] | = Ψ for some i and π [ j ] | = Φ for all j < i

  30. Notes on satisfaction relations Two relations are mutually recursive—mutually recursive grammar Satisfaction relation for path formulae similar to LTL relation BUT: • Similar for other modalities 27 • In LTL modality � φ uses all suffjxes of path π • In CTL modality � Φ uses all indexes of path π Tip: imagine types of π i , π [ i ] and satisfaction relations

  31. Examples CTL model as a picture: 28 s 1 : { b } s 2 : { c } s 0 : { a , b , c } s 3 : { c }

  32. Examples 29 s 1 : { b } s 2 : { c } s 0 : { a , b , c } s 3 : { c } We have s 0 | = a ∧ b ∧ c

  33. Examples 30 s 1 : { b } s 2 : { c } s 0 : { a , b , c } s 3 : { c } We have s 0 | = ∀ ( b UNTIL c )

  34. Examples 31 s 1 : { b } s 2 : { c } s 0 : { a , b , c } s 3 : { c } We have s 1 | = ∀� c

  35. Examples 32 s 1 : { b } s 2 : { c } s 0 : { a , b , c } s 3 : { c } We have s 1 | = ∀�∀� c

  36. Examples 33 s 1 : { b } s 2 : { c } s 0 : { a , b , c } s 3 : { c } We have s 1 | = ∃ ♦ a

  37. Examples 34 s 1 : { b } s 2 : { c } s 0 : { a , b , c } s 3 : { c } We have s 2 | = ∃ � c

  38. Semantic equivalence

  39. Satisfaction in model 35 Write M | = Φ when s | = Φ for all states s in M Read M | = Φ as “model M satisfjes Φ ” Holds whenever all states of M satisfy Φ

  40. Semantic equivalence 36 Say Φ and Ψ are semantically equivalent ( Φ ≡ Ψ ) when: M | = Φ if and only if M | = Ψ for all models M Intuitively Φ ≡ Ψ asserts that: • Φ and Ψ have same “semantic content” • Safe to replace Φ with Ψ (and vice versa) in any context • Quantifying over M means can’t distinguish models

Recommend


More recommend