symbolic model checking: the ic3 algorithmvganesh/teaching/w2013/satsmt... · 2013. 3. 14. ·...

22
Shoham Ben-David 1 Symbolic Model Checking: The IC3 Algorithm

Upload: others

Post on 21-Jul-2021

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Symbolic Model Checking: The IC3 Algorithmvganesh/TEACHING/W2013/SATSMT... · 2013. 3. 14. · IC3/PDR 2 Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011 A

Shoham Ben-David

1

Symbolic Model Checking:

The IC3 Algorithm

Page 2: Symbolic Model Checking: The IC3 Algorithmvganesh/TEACHING/W2013/SATSMT... · 2013. 3. 14. · IC3/PDR 2 Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011 A

IC3/PDR

2

Aaron R. Bradley: SAT-Based Model Checking without

Unrolling. VMCAI 2011

A paraphrase on the BMC paper

“Incremental Construction of Inductive Clauses for

Indubitable Correctness” : IC3

Known also as Property Directed Reachability

A very symbolic model checking algorithm

Uses SAT solving as a subroutine

Page 3: Symbolic Model Checking: The IC3 Algorithmvganesh/TEACHING/W2013/SATSMT... · 2013. 3. 14. · IC3/PDR 2 Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011 A

From last week:

3

A model M is described by

A set V of Boolean variables; the state space consists of 2|V|

states

The set I of initial states

The (total) transition relation T

Introducing a copy V` of V, the transition relation T can be represented

as a Boolean expression over V and V`.

The property P is a Boolean expression

The reachable state space R is the set of all states that can be

reached from I by taking any number of transitions through

T.

Page 4: Symbolic Model Checking: The IC3 Algorithmvganesh/TEACHING/W2013/SATSMT... · 2013. 3. 14. · IC3/PDR 2 Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011 A

Symbolic Representation

4

We view P as a set of states

All the states that satisfy P.

Suppose that P holds in the model (M ⊨ P).

It means that R P .

If we had a Boolean expression representing R, we could

simply check R ⇒ P

by checking satisfiability of R ∧⌝P

Page 5: Symbolic Model Checking: The IC3 Algorithmvganesh/TEACHING/W2013/SATSMT... · 2013. 3. 14. · IC3/PDR 2 Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011 A

States Satisfying P

5

111 011

010

000

101

100

001

110 P = (⌝V1 ⋁ ⌝V2 ⋁ ⌝V3)

Page 6: Symbolic Model Checking: The IC3 Algorithmvganesh/TEACHING/W2013/SATSMT... · 2013. 3. 14. · IC3/PDR 2 Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011 A

Reachable States

6

111 011

010

000

101

100

001

110 P = (⌝V1 ⋁ ⌝V2 ⋁ ⌝V3)

Page 7: Symbolic Model Checking: The IC3 Algorithmvganesh/TEACHING/W2013/SATSMT... · 2013. 3. 14. · IC3/PDR 2 Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011 A

Some Observations

7

R has a special property: R⋀T ⇒ R′

If we take a transition from any state in R, we shall reach a state

in R

R is a ‘fix point’ for the transition relation

For a set of states S, with I S, if S is a fix point, it must

include R.

If I S and S⋀T ⇒ S′ then R S

S is an over-approximation of R

If we find such a set S, and show in addition that S P, we

are done!

Page 8: Symbolic Model Checking: The IC3 Algorithmvganesh/TEACHING/W2013/SATSMT... · 2013. 3. 14. · IC3/PDR 2 Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011 A

An Over Approximation

8

I

R

P

Searching for an over approximation of R gives us flexibility.

May be easier to find.

Page 9: Symbolic Model Checking: The IC3 Algorithmvganesh/TEACHING/W2013/SATSMT... · 2013. 3. 14. · IC3/PDR 2 Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011 A

The IC3 Algorithm: Main Idea

9

Let I be the set of initial states, P the invariant formula

Build a series of sets

I, F1, F2, … , Fk

Such that

For all j, Fj is an over-approximation of the set of states reachable from I in j steps or less.

Each Fj satisfies P

If there exists a j such that Fj= Fj+1 then a fix point is found, P holds in the model.

Page 10: Symbolic Model Checking: The IC3 Algorithmvganesh/TEACHING/W2013/SATSMT... · 2013. 3. 14. · IC3/PDR 2 Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011 A

Main Idea, More Specificaly

10

I, F1, F2, … , Fk

∀i, Fi ⇒ Fi+1

∀i, Fi ⇒ P

∀i, Fi ∧ T ⇒ F`i+1

Page 11: Symbolic Model Checking: The IC3 Algorithmvganesh/TEACHING/W2013/SATSMT... · 2013. 3. 14. · IC3/PDR 2 Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011 A

Algorithm

11

Check I ⇒ P?

Check I ∧ T ⇒ P`?

Set: F1 := P

For every clause c clauses(I), if c clauses(F1),

check:

I ∧ T ⇒ c`?

If it does, set F1 := F1 ∧ c

Page 12: Symbolic Model Checking: The IC3 Algorithmvganesh/TEACHING/W2013/SATSMT... · 2013. 3. 14. · IC3/PDR 2 Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011 A

A step forward

12

Suppose that I, F1, F2, … , Fk exist, with the conditions mentioned above.

Check:

Is it the case that Fk ∧ T ⇒ P′ ?

If it is, then

set Fk+1 := P

for every clause c ∈ Fk , check Fk ∧ T ⇒ c′ ?

If it is, set Fk+1 := Fk+1 ∧ c

If Fk =Fk+1: done Improvement: compare clauses (syntactic check)

Page 13: Symbolic Model Checking: The IC3 Algorithmvganesh/TEACHING/W2013/SATSMT... · 2013. 3. 14. · IC3/PDR 2 Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011 A

Example 1

13

P= (-1,-2,-3)

I = (1)(2)(-3)

T=(-1,3`)(1,-3`)(2,-2`)(-1,-2,-1`)(-3,1`,1)(-3,1`,2)

Step 1: I ⇒ P?

I ∧ ⌝P = (1)(2)(-3) (1)(2)(3) -- unsatisfiable

Step 2: I ∧ T ⇒ P`?

I ∧ T ∧ ⌝P` =

(1)(2)(-3) (-1,3`)(1,-3`)(2,-2`)(-1,-2,-1`)(-3,1`,1)(-3,1`,2) (1`)(2`)(3`)

-- unsatisfiable

Page 14: Symbolic Model Checking: The IC3 Algorithmvganesh/TEACHING/W2013/SATSMT... · 2013. 3. 14. · IC3/PDR 2 Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011 A

Example 1 – Cont.

14

P= (-1,-2,-3)

I = (1)(2)(-3)

T=(-1,3`)(1,-3`)(2,-2`)(-1,-2,-1`)(-3,1`,1)(-3,1`,2)

Step 3:

Set F1 := P

For every clause c ∈ I, check: I ∧ T ⇒ c`?

I ∧ T ∧ ⌝c` = (1)(2)(-3) (-1,3`)(1,-3`)(2,-2`)(-1,-2,-1`)(-3,1`,1)(-3,1`,2) (-1`)

-- satisfiable for all c ∈ I. Nothing can be added to F1

Page 15: Symbolic Model Checking: The IC3 Algorithmvganesh/TEACHING/W2013/SATSMT... · 2013. 3. 14. · IC3/PDR 2 Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011 A

Example 1 – Cont.

15

P= (-1,-2,-3)

I = (1)(2)(-3)

T=(-1,3`)(1,-3`)(2,-2`)(-1,-2,-1`)(-3,1`,1)(-3,1`,2)

Step 4: : F1∧ T ⇒ P`?

F1 ∧ T ∧ ⌝P` =

(-1,-2,-3) (-1,3`)(1,-3`)(2,-2`)(-1,-2,-1`)(-3,1,1`)(-3,2,1`) (1`)(2`)(3`)

-- unsatisfiable

Since F1 =P we are done !

Page 16: Symbolic Model Checking: The IC3 Algorithmvganesh/TEACHING/W2013/SATSMT... · 2013. 3. 14. · IC3/PDR 2 Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011 A

Example 1

16

111 011

010

000

101

100

001

110 P = (-1,-2,-3)

Page 17: Symbolic Model Checking: The IC3 Algorithmvganesh/TEACHING/W2013/SATSMT... · 2013. 3. 14. · IC3/PDR 2 Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011 A

A step forward – Cont.

17

Suppose that I, F1, F2, … , Fk exist, with the above conditions.

Check:

Is it the case that Fk ∧ T ⇒ P′ ?

If not then

The SAT solver produces a counterexample, which includes a state s ∈ Fk that is one step away from violating P

Consider the clause ⌝s (why clause?) Find the maximal j such that Fj ∧ ⌝s ∧ T ⇒ ⌝s′

(If none exist then P does not hold in M!)

Update: Fi :=Fi ∧ ⌝s for 0<i< = j+1

Page 18: Symbolic Model Checking: The IC3 Algorithmvganesh/TEACHING/W2013/SATSMT... · 2013. 3. 14. · IC3/PDR 2 Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011 A

IC3: Cont.

18

Check:

Is it the case that Fk ∧ T ⇒ P′ ?

If not then

Find a problematic state s and propagate ⌝s as far as possible

If ⌝s was added to Fk, try again:

Fk ∧ T ⇒ P′ ?

Otherwise

find a state t that is a predecessor of s

recur on t

Page 19: Symbolic Model Checking: The IC3 Algorithmvganesh/TEACHING/W2013/SATSMT... · 2013. 3. 14. · IC3/PDR 2 Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011 A

Example 2

19

111 011

010

000

101

100

001

110 P = (1,2,3)

Page 20: Symbolic Model Checking: The IC3 Algorithmvganesh/TEACHING/W2013/SATSMT... · 2013. 3. 14. · IC3/PDR 2 Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011 A

Example 2.

20

P= (1,2,3)

I = (1)(2)(-3)

T=(-1,3`)(1,-3`)(2,-2`)(-1,-2,-1`)(-3,1`,1)(-3,1`,2)

Step 4: : F1∧ T ⇒ P`? F1 ∧ T ∧ ⌝P` =

(1,2,3) (-1,3`)(1,-3`)(2,-2`)(-1,-2,-1`)(-3,1,1`)(-3,2,1`) (-1`)(-2`)(-3`)

-- Satisfiable: -1,2,-3,-1`,-2`,-3` is a satisfying assignment

⌝P can be reached from s=(-1)(2)(-3) Check: I ∧ ⌝s ⇒ ⌝s`? (1,-2,3)(1),(2),(3) (-1,3`)(1,-3`)(2,-2`)(-1,-2,-1`)(-3,1,1`)(-3,2,1`) (-1`),(2`),(-3`)

Unsatisfiable!

Set : F1 := F1 ∧ ⌝s = (1,2,3) (1,-2,3)

Page 21: Symbolic Model Checking: The IC3 Algorithmvganesh/TEACHING/W2013/SATSMT... · 2013. 3. 14. · IC3/PDR 2 Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011 A

Example 2: Cont.

21

Recheck: F1∧ T ⇒ P`?

F1 ∧ T ∧ ⌝P` =

(1,2,3) (1,-2,3)(-1,3`)(1,-3`)(2,-2`)(-1,-2,-1`)(-3,1,1`)(-3,2,1`) (-1`)(-2`)(-3`)

-- Unsatisfiable

Set F2 := P

Check: F1∧ ⌝s ⇒ ⌝s`?

(1,-2,3)(1,2,3) (-1,3`)(1,-3`)(2,-2`)(-1,-2,-1`)(-3,1,1`)(-3,2,1`) (-1`),(2`),(-3`)

Unsatisfiable

Set : F2 := F2 ∧ ⌝s

But F1 = F2 !

A fix point is found. P holds in the model.

Page 22: Symbolic Model Checking: The IC3 Algorithmvganesh/TEACHING/W2013/SATSMT... · 2013. 3. 14. · IC3/PDR 2 Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011 A

IC3 summary

22

A combination of induction, over-approximation and SAT

solving

Instead of a “Black Box” use of SAT: make SAT solving an

integral part of the procedure

Many small SAT problems to solve (10,000 and more)

As of today:

State-of-the-art symbolic model checking algorithm

Many (improved) implementations exist