+ All Categories
Home > Documents > Explicit State Model Checking - MIT OpenCourseWare...Computer Science and Artificial Intelligence...

Explicit State Model Checking - MIT OpenCourseWare...Computer Science and Artificial Intelligence...

Date post: 22-Jan-2021
Category:
Upload: others
View: 3 times
Download: 0 times
Share this document with a friend
20
Computer Science and Artificial Intelligence Laboratory MIT Armando Solar-Lezama Dec 01, 2011 December 01, 2011 Explicit State Model Checking 1
Transcript
Page 1: Explicit State Model Checking - MIT OpenCourseWare...Computer Science and Artificial Intelligence Laboratory . MIT . Armando Solar-Lezama . Dec 01, 2011 . December 01, 2011 Explicit

Computer Science and Artificial Intelligence Laboratory

MIT Armando Solar-Lezama

Dec 01, 2011

December 01, 2011

Explicit State Model Checking

1

Page 2: Explicit State Model Checking - MIT OpenCourseWare...Computer Science and Artificial Intelligence Laboratory . MIT . Armando Solar-Lezama . Dec 01, 2011 . December 01, 2011 Explicit

Explicit State Model checking

o The basic Strategy

Temporal Logic Formula

Kripke structure

Buchi Automata

Product Automata Model

checker

OK

Counterexample

trace

System Description

2

Page 3: Explicit State Model Checking - MIT OpenCourseWare...Computer Science and Artificial Intelligence Laboratory . MIT . Armando Solar-Lezama . Dec 01, 2011 . December 01, 2011 Explicit

Buchi Automata

o A Buchi Automaton is a 5-tuple Σ, 𝑆, 𝐼, 𝛿, 𝐹

- Σ is an alphabet

- S is a finite set of states

- 𝐼 ⊆ 𝑆 is a set of initial states

- 𝛿 ⊆ 𝑆 × Σ × 𝑆 is a transition relation

- 𝐹 ⊆ 𝑆 is a set of accepting states

o Non-deterministic Buchi Automata are not

equivalent to deterministic ones

3

Page 4: Explicit State Model Checking - MIT OpenCourseWare...Computer Science and Artificial Intelligence Laboratory . MIT . Armando Solar-Lezama . Dec 01, 2011 . December 01, 2011 Explicit

Buchi Automaton from Kripke Structure

o Given a Kripke structure:

- M = (S, S0, R, L)

o Construct a Buchi Automaton

- (𝜮 , S U {Init}, {Init}, T, S U {Init} )

- T is defined s.t.

• T(s, 𝜎, s’) iff R(s, s’) and 𝜎ϵ L(s’) • T(Init, 𝜎,s) iff s ϵ S0 and 𝜎ϵ L(s)

s1

s4

s3

s2

start

close start cooking

close

open door

close door

close door

start

start finish

cooking

4

Page 5: Explicit State Model Checking - MIT OpenCourseWare...Computer Science and Artificial Intelligence Laboratory . MIT . Armando Solar-Lezama . Dec 01, 2011 . December 01, 2011 Explicit

Buchi Automaton from Kripke Structure

- (𝜮 , S U {Init}, {Init}, T, S U {Init} )

- T is defined s.t.

• T(s, 𝜎, s’) iff R(s, s’) and 𝜎ϵ L(s’) • T(Init, 𝜎,s) iff s ϵ S0 and 𝜎ϵ L(s)

s1

s4

s3

s2

start

close start cooking

close

Init

s1

s4

s3

s2

start -cooking -close

close start cooking

close -start -cooking

close -start -cooking

close start cooking

close -start -cooking

-start -cooking -close

-start -cooking -close

5

Page 6: Explicit State Model Checking - MIT OpenCourseWare...Computer Science and Artificial Intelligence Laboratory . MIT . Armando Solar-Lezama . Dec 01, 2011 . December 01, 2011 Explicit

Buchi Automaton from Kripke Structure

o Given a Kripke structure:

- M = (S, S0, R, L)

o Construct a Buchi Automaton

- (𝜮 , S U {Init}, {Init}, T, S U {Init} )

- T is defined s.t.

• T(s, 𝜎, s’) iff R(s, s’) and 𝜎ϵ L(s’) • T(Init, 𝜎,s) iff s ϵ S0 and 𝜎ϵ L(s)

o What about missing transitions? - Need to add a dummy “error state”

s1

s4

s3

s2

start

close start cooking

close

open door

close door

close door

start

start finish

cooking

6

Page 7: Explicit State Model Checking - MIT OpenCourseWare...Computer Science and Artificial Intelligence Laboratory . MIT . Armando Solar-Lezama . Dec 01, 2011 . December 01, 2011 Explicit

Explicit State Model checking

o The basic Strategy

Temporal Logic Formula

Kripke structure

Buchi Automata

Product Automata Model

checker

OK

Counterexample

trace

System Description

7

Page 8: Explicit State Model Checking - MIT OpenCourseWare...Computer Science and Artificial Intelligence Laboratory . MIT . Armando Solar-Lezama . Dec 01, 2011 . December 01, 2011 Explicit

Negated Properties

o Given a good property P, you can define a bad property P’

- If the system has a trace that satisfies P’, then it is buggy.

o Example

- Good property: G( req F ack)

- Bad property: F (req & ( G !ack))

o We are going to ask whether M satisfies P’

- If it does, then we found a bug

o Why are we doing the negation?

8

Page 9: Explicit State Model Checking - MIT OpenCourseWare...Computer Science and Artificial Intelligence Laboratory . MIT . Armando Solar-Lezama . Dec 01, 2011 . December 01, 2011 Explicit

Computing the Product Automata

o Given Buchi automata A and B’

- A = (𝜮 , SA, TA, {InitA}, SA)

- B’ = (𝜮 , SB, TB, {InitB}, F’)

- A x B’ = (𝜮 , SA x SB, T, {(InitA, InitB)}, F)

o Where

- T((s1,s2), 𝜎, (s1’, s2’)) iff TA(s1, 𝜎, s1’) and TB(s2, 𝜎, s2’)

- (s1,s2) ϵ F iff s2 ϵ F’

9

Page 10: Explicit State Model Checking - MIT OpenCourseWare...Computer Science and Artificial Intelligence Laboratory . MIT . Armando Solar-Lezama . Dec 01, 2011 . December 01, 2011 Explicit

Check if a state is visited infinitely often

o Check for a cycle with an accepting state

o Cycle must be reachable from the initial state

o Simple algorithm

- Do DFS to find an accepting state

- Do a DFS from that accepting state to see if it can reach itself

10

Page 11: Explicit State Model Checking - MIT OpenCourseWare...Computer Science and Artificial Intelligence Laboratory . MIT . Armando Solar-Lezama . Dec 01, 2011 . December 01, 2011 Explicit

Explicit State Model checking

o The basic Strategy

Temporal Logic Formula

Kripke structure

Buchi Automata

Product Automata Model

checker

OK

Counterexample

trace

System Description

DFS on state machine!

11

Page 12: Explicit State Model Checking - MIT OpenCourseWare...Computer Science and Artificial Intelligence Laboratory . MIT . Armando Solar-Lezama . Dec 01, 2011 . December 01, 2011 Explicit

Example

ok

rec

ack 𝜮-rec

𝜮-ack

G rec F ack

rec

rec ack

12

Page 13: Explicit State Model Checking - MIT OpenCourseWare...Computer Science and Artificial Intelligence Laboratory . MIT . Armando Solar-Lezama . Dec 01, 2011 . December 01, 2011 Explicit

Optimizations: Partial Order Reduction

o Example

H

V

while(*){ if(p=0){ p:=1; } if(p=1){ if(g=free){ g:=id; p:=2; } } if(p=2){ p:=3; g:=free } if(p=3){ p:=0; } }

pc=0 pc=1 pc=2 pc=3 pc=4 pc=5 pc=6 pc=7 pc=8 pc=9

0 1 2 3

0

1

3

while(*){ if(p=0){ p:=1; } if(p=1){ if(g=free){ g:=id; p:=2; } } if(p=2){ p:=3; g:=free } if(p=3){ p:=0; } }

H train V train 13

Page 14: Explicit State Model Checking - MIT OpenCourseWare...Computer Science and Artificial Intelligence Laboratory . MIT . Armando Solar-Lezama . Dec 01, 2011 . December 01, 2011 Explicit

Optimizations: Partial Order Reduction

o Example

H

V

while(*){ if(p=0){ p:=1; } if(p=1){ if(g=free){ g:=id; p:=2; } } if(p=2){ p:=3; g:=free } if(p=3){ p:=0; } }

pc=0 pc=1 pc=2 pc=3 pc=4 pc=5 pc=6 pc=7 pc=8 pc=9

0 1 2 3

0

1

3

while(*){ if(p=0){ p:=1; } if(p=1){ if(g=free){ g:=id; p:=2; } } if(p=2){ p:=3; g:=free } if(p=3){ p:=0; } }

H train V train 14

Page 15: Explicit State Model Checking - MIT OpenCourseWare...Computer Science and Artificial Intelligence Laboratory . MIT . Armando Solar-Lezama . Dec 01, 2011 . December 01, 2011 Explicit

Partial Order Reduction

o Key idea:

- The order of independent actions on different threads does not

matter

- Note: what is considered independent depends on the property

P

P -P

-P

𝐹¬𝑝 a

b

b

a

P

P

-P

a

b

15

Page 16: Explicit State Model Checking - MIT OpenCourseWare...Computer Science and Artificial Intelligence Laboratory . MIT . Armando Solar-Lezama . Dec 01, 2011 . December 01, 2011 Explicit

Ample set

o On state s1, the transitions to s2 and s3 are both

enabled.

- enabled(s1)

o We only want to explore a subset of the enabled set

- ample(s1) ⊆ enabled(s1)

P

P -P

-P

𝐹¬𝑝 a

b

b

a

P

P

-P

a

b

s1 s1

s2

s4

s3

16

Page 17: Explicit State Model Checking - MIT OpenCourseWare...Computer Science and Artificial Intelligence Laboratory . MIT . Armando Solar-Lezama . Dec 01, 2011 . December 01, 2011 Explicit

Ample set

o We have 3 goals in computing ample(s)

- Using ample instead of enabled should give us a much smaller

graph

- Using ample instead of enabled should still allow us to find what

we are looking for

- Computing ample should be easy

P

P -P

-P

𝐹¬𝑝 a

b

b

a

P

P

-P

a

b

s1 s1

s2

s4

s3

17

Page 18: Explicit State Model Checking - MIT OpenCourseWare...Computer Science and Artificial Intelligence Laboratory . MIT . Armando Solar-Lezama . Dec 01, 2011 . December 01, 2011 Explicit

Independence and Invisibility

o Independence:

- Actions a and b are independent iff:

• a does not disable b and vice-versa

• Commutativity: a(b(s)) = b(a(s))

o Invisibility:

- a and b should not affect the values of any relevant property

18

Page 19: Explicit State Model Checking - MIT OpenCourseWare...Computer Science and Artificial Intelligence Laboratory . MIT . Armando Solar-Lezama . Dec 01, 2011 . December 01, 2011 Explicit

Ample is computed heuristically

o Computing it precisely is too hard, but we can find

actions that are definitely not in ample(s) and can

therefore be ignored.

o What we need to consider:

- Actions that share variables with the property

- If two actions share variables, they are dependent

- If two actions appear in the same thread they are dependent

19

Page 20: Explicit State Model Checking - MIT OpenCourseWare...Computer Science and Artificial Intelligence Laboratory . MIT . Armando Solar-Lezama . Dec 01, 2011 . December 01, 2011 Explicit

MIT OpenCourseWarehttp://ocw.mit.edu

6.820 Fundamentals of Program AnalysisFall 2015

For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.


Recommended