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

hoare logic and model checking
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 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

slide-2
SLIDE 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

slide-3
SLIDE 3

Branching model of time

slide-4
SLIDE 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

slide-5
SLIDE 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

slide-6
SLIDE 6

CTL syntax

slide-7
SLIDE 7

Atomic propositions

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

5

slide-8
SLIDE 8

CTL state and path formulae

Defjne state formulae with the following grammar: Φ, Ψ, Ξ ::= ⊤ | ⊥ | p ::= ¬Φ ::= Φ ∧ Ψ | Φ ∨ Ψ | Φ ⇒ Ψ ::= ∀φ | ∃φ and path formulae with the following grammar: φ, ψ, ξ ::= Φ | Φ | ♦Φ | Φ UNTIL Ψ In semantics of CTL:

  • Path formulae are evaluated relative to a path
  • State formulae are evaluated relative to a state

6

slide-9
SLIDE 9

Intuitive explanation of CTL formulae

First line (of state formula grammar): ⊤ | ⊥ | 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

The last should now be familiar too!

7

slide-10
SLIDE 10

Intuitive explanation of CTL formulae

Second line (of state formula grammar): ¬Φ If Φ is a CTL state formula, then ¬Φ is a CTL state formula

  • ¬Φ is negation of φ (or “not Φ”)

8

slide-11
SLIDE 11

Intuitive explanation of CTL formulae

Third line (of state formula grammar): Φ ∧ Ψ | Φ ∨ Ψ | Φ ⇒ Ψ If Φ and Ψ are CTL state formulae, then so are Φ ∧ Ψ, Φ ∨ Ψ, Φ ⇒ Ψ

  • Φ ∧ Ψ is conjunction (or “Φ and Ψ”)
  • Φ ∨ Ψ is disjunction (or “Φ or Ψ”)
  • Φ ⇒ Ψ is implication (or “if Φ then Ψ”, or “ψ whenever φ”)

9

slide-12
SLIDE 12

Intuitive explanation of CTL formulae

Last line (of state formula grammar): ∀φ | ∃φ If φ and ψ are CTL path formulae, then ∀φ and ∃φ are CTL state formulae

  • ∀φ is “φ along every path that starts here”
  • ∃φ is “φ along at least one path that starts here”, or “there exists

a path where φ holds” Specifjc to CTL!

10

slide-13
SLIDE 13

Intuitive explanation of CTL formulae

Path formula grammar: Φ | Φ | ♦Φ | Φ UNTIL Ψ If Φ and Ψ are CTL state formulae, then Φ, Φ, ♦Φ, and Φ UNTIL Ψ are CTL path formulae

  • Φ 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 Φ”

11

slide-14
SLIDE 14

Alternative syntax for modalities

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

12

slide-15
SLIDE 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:

  • ∀ and ∃ are instructions: “go off and examine paths”
  • Path formulae evaluated relative to paths
  • State formulae relative to states
  • Grammar closer to grammar of CTL⋆

Might also see (e.g. in “Logic in Computer Science”):

  • A and E instead of ∀ and ∃
  • X, G, F, and U instead of , , ♦, and UNTIL

13

slide-16
SLIDE 16

Operator precedence

We add parentheses freely to disambiguate Assign precedence to reduce number of parentheses needed:

  • Unary ¬, ∀, ∃, , ♦, and bind most tightly
  • After that UNTIL
  • After that ∨ and ∧
  • Finally ⇒ binds least tightly

14

slide-17
SLIDE 17

Precedence examples

So: Φ ⇒ ∀ Ψ means Φ ⇒ (∀(Ψ)) Φ ⇒ Ψ ∨ ∃Ψ means Φ ⇒ (Φ ∨ (∃(Ψ))) ∀ Φ ∨ Ξ ⇒ Ψ UNTIL Ξ means ((∀(Φ)) ∨ Ξ) ⇒ (Ψ UNTIL Ξ) and so on...

15

slide-18
SLIDE 18

Example CTL formulae

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

16

slide-19
SLIDE 19

Example CTL formulae

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

17

slide-20
SLIDE 20

Example CTL formulae

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

18

slide-21
SLIDE 21

Example CTL formulae

Suppose floor2, floor5, direction_up, and button_pressed_5 are atomic propositions, then: ∀(floor2 ∧ direction_up ∧ button_pressed_5 ⇒ ∀(direction_up UNTIL floor5)) 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

slide-22
SLIDE 22

Semantics of CTL

slide-23
SLIDE 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

slide-24
SLIDE 24

Models for CTL

Recall M = S, S0, →, L, where:

  • S set of states
  • S0 ⊆ 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′

21

slide-25
SLIDE 25

Infjnite paths of states

Fix a CTL model M = S, S0, →, L Write Paths(s) for set of infjnite paths of S starting at s Write π[i] for ith state of π (“indexing”) Write πi for suffjx of π starting position i

22

slide-26
SLIDE 26

Satisfaction at a state

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

23

slide-27
SLIDE 27

Satisfaction at a state

s | = Φ ∨ Ψ iff s | = Φ or s | = Ψ s | = Φ ∧ Ψ iff s | = Φ and s | = Ψ s | = Φ ⇒ Ψ iff not s | = Φ or if s | = Φ and s | = Ψ

24

slide-28
SLIDE 28

Satisfaction at a state

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

25

slide-29
SLIDE 29

Satisfaction along a path

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

26

slide-30
SLIDE 30

Notes on satisfaction relations

Two relations are mutually recursive—mutually recursive grammar Satisfaction relation for path formulae similar to LTL relation BUT:

  • In LTL modality φ uses all suffjxes of path π
  • In CTL modality Φ uses all indexes of path π
  • Similar for other modalities

Tip: imagine types of πi, π[i] and satisfaction relations

27

slide-31
SLIDE 31

Examples

CTL model as a picture: s0 : {a, b, c} s1 : {b} s2 : {c} s3 : {c}

28

slide-32
SLIDE 32

Examples

s0 : {a, b, c} s1 : {b} s2 : {c} s3 : {c} We have s0 | = a ∧ b ∧ c

29

slide-33
SLIDE 33

Examples

s0 : {a, b, c} s1 : {b} s2 : {c} s3 : {c} We have s0 | = ∀(b UNTIL c)

30

slide-34
SLIDE 34

Examples

s0 : {a, b, c} s1 : {b} s2 : {c} s3 : {c} We have s1 | = ∀c

31

slide-35
SLIDE 35

Examples

s0 : {a, b, c} s1 : {b} s2 : {c} s3 : {c} We have s1 | = ∀∀c

32

slide-36
SLIDE 36

Examples

s0 : {a, b, c} s1 : {b} s2 : {c} s3 : {c} We have s1 | = ∃♦a

33

slide-37
SLIDE 37

Examples

s0 : {a, b, c} s1 : {b} s2 : {c} s3 : {c} We have s2 | = ∃c

34

slide-38
SLIDE 38

Semantic equivalence

slide-39
SLIDE 39

Satisfaction in model

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

35

slide-40
SLIDE 40

Semantic equivalence

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

36

slide-41
SLIDE 41

Properties of semantic equivalence

Semantic equivalence:

  • Is refmexive (φ ≡ φ)
  • Is symmetric (φ ≡ ψ implies ψ ≡ φ)
  • Is transitive (φ ≡ ψ and ψ ≡ ξ implies φ ≡ ξ)

Also is congruent with structure of formulae Example: φ1 ≡ φ2 implies ¬φ1 ≡ ¬φ2 and ∃ φ1 ≡ ∃ φ2

37

slide-42
SLIDE 42

Important semantic equivalences

⊤ ≡ ¬⊥ Φ ⇒ Ψ ≡ ¬Φ ∨ Ψ Φ ∨ Ψ ≡ ¬(¬Φ ∧ ¬Ψ)

38

slide-43
SLIDE 43

Important semantic equivalences

∀ Φ ≡ ¬∃ ¬Φ ∀Φ ≡ ¬∃(⊤ UNTIL ¬Φ) ∀♦Φ ≡ ∀(⊤ UNTIL Φ) ∀(Φ UNTIL Ψ) ≡ ¬∃(¬Ψ UNTIL (¬Φ ∧ ¬Ψ)) ∧ ¬∃¬Ψ ∃♦Φ ≡ ∃(⊤ UNTIL Φ)

39

slide-44
SLIDE 44

Example proof

Task: show Φ ∨ Ψ ≡ ¬(¬Φ ∧ ¬Ψ) Fix arbitrary model M and state s in M Need to show s | = Φ ∨ Ψ if and only if s | = ¬(¬Φ ∧ ¬Ψ)

40

slide-45
SLIDE 45

One direction

Assume s | = Φ ∨ Ψ Then s | = Φ or s | = Ψ Assume without loss of generality s | = Φ Then not s | = ¬Φ Hence not s | = ¬Φ ∧ ¬Ψ Therefore s | = ¬(¬Φ ∧ ¬Ψ), as required

41

slide-46
SLIDE 46

T’other

Assume s | = ¬(¬Φ ∧ ¬Ψ) Then not s | = ¬Φ and s | = ¬Ψ Then not (not s | = Φ and not s | = Ψ) Hence either s | = Φ or s | = Ψ Without loss of generality, assume s | = Φ Then s | = Φ ∨ Ψ, as required Therefore Φ ∨ Ψ ≡ ¬(¬Φ ∧ ¬Ψ)

42

slide-47
SLIDE 47

Existential Normal Form

Defjne formulae in Existential Normal Form (ENF) by: Φ, Ψ ::= ⊤ | p ::= Φ ∧ Ψ | ¬Φ ::= ∃ Φ | ∃(Φ UNTIL Ψ) | ∃Φ Theorem: Every state formula has an equivalent ENF formula Proof: by structural induction, using previous semantic equivalences and congruences Note proof is constructive: describes an algorithm

43

slide-48
SLIDE 48

Summary

  • CTL uses a branching model of time
  • CTL state formulae express “state properties” of systems
  • CTL semantics with respect to states in model
  • Equivalence when formulae have same “semantic content”
  • Can use equivalences to rewrite a formula into ENF

44