Top Banner
The IC3 Algorithm Shoham Ben-David
28

The IC3 Algorithm - University of Waterloovganesh/TEACHING/F2013/SATSMT/lectures... · The IC3/PDR Algorithm Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011

Sep 22, 2018

Download

Documents

ngonhu
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: The IC3 Algorithm - University of Waterloovganesh/TEACHING/F2013/SATSMT/lectures... · The IC3/PDR Algorithm Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011

The IC3 Algorithm

Shoham Ben-David

Page 2: The IC3 Algorithm - University of Waterloovganesh/TEACHING/F2013/SATSMT/lectures... · The IC3/PDR Algorithm Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011

The IC3/PDR Algorithm

Aaron R. Bradley: SAT-Based Model Checking withoutUnrolling. VMCAI 2011

Incremental Construction of Inductive Clauses for IndubitableCorrectness : IC3

Known also as Property Directed Reachability

As of today: the state-of-art symbolic model checkingalgorithm.

Page 3: The IC3 Algorithm - University of Waterloovganesh/TEACHING/F2013/SATSMT/lectures... · The IC3/PDR Algorithm Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011

Symbolic Model Checking

The main problem in model checking: the size problem

For |V | = 100 we have 2100 states to explore

Symbolic model checking deals with it by never referring tosingle states

Rather: always refer to sets of states

A Boolean formula F over the variables V represents a set ofstates in M:

All the states that satisfy F .

Page 4: The IC3 Algorithm - University of Waterloovganesh/TEACHING/F2013/SATSMT/lectures... · The IC3/PDR Algorithm Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011

Symbolic Model Checking

The main problem in model checking: the size problem

For |V | = 100 we have 2100 states to explore

Symbolic model checking deals with it by never referring tosingle states

Rather: always refer to sets of states

A Boolean formula F over the variables V represents a set ofstates in M:

All the states that satisfy F .

Page 5: The IC3 Algorithm - University of Waterloovganesh/TEACHING/F2013/SATSMT/lectures... · The IC3/PDR Algorithm Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011

Symbolic Model Checking

The main problem in model checking: the size problem

For |V | = 100 we have 2100 states to explore

Symbolic model checking deals with it by never referring tosingle states

Rather: always refer to sets of states

A Boolean formula F over the variables V represents a set ofstates in M:

All the states that satisfy F .

Page 6: The IC3 Algorithm - University of Waterloovganesh/TEACHING/F2013/SATSMT/lectures... · The IC3/PDR Algorithm Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011

Some Definition

A cube is a conjunction of literals

For a clause c , ¬c is a cube

S , I ,T ,P,V ,V ′ as before

Primed formulas (e.g. s ′) are defined on V ′

Page 7: The IC3 Algorithm - University of Waterloovganesh/TEACHING/F2013/SATSMT/lectures... · The IC3/PDR Algorithm Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011

Some Definition

A cube is a conjunction of literals

For a clause c , ¬c is a cube

S , I ,T ,P,V ,V ′ as before

Primed formulas (e.g. s ′) are defined on V ′

Page 8: The IC3 Algorithm - University of Waterloovganesh/TEACHING/F2013/SATSMT/lectures... · The IC3/PDR Algorithm Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011

Some Definition

A cube is a conjunction of literals

For a clause c , ¬c is a cube

S , I ,T ,P,V ,V ′ as before

Primed formulas (e.g. s ′) are defined on V ′

Page 9: The IC3 Algorithm - University of Waterloovganesh/TEACHING/F2013/SATSMT/lectures... · The IC3/PDR Algorithm Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011

PDR: Frames

The PDR algorithm is based on maintaining a sequence of“frames”

R0,R1, ...,RN .

1 Each frame is a CNF formula over the variables V ,representing a set of states in the model (Rj ⊆ S).

2 Each frame Rj is an over-approximations of the statesreachable from the initial states I in j steps or less.

Page 10: The IC3 Algorithm - University of Waterloovganesh/TEACHING/F2013/SATSMT/lectures... · The IC3/PDR Algorithm Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011

Properties of Frames

The frames Rj fulfill the following conditions:

1 R0 = I .2 1 Rj ⊆ Rj+1.

2 CL(Rj+1) ⊆ CL(Rj), for j > 0.

3 T (Rj) ⊆ Rj+1.

4 Rj ⊆ P, for j < N.

Note that RN is different from the other frames, as it does notnecessarily satisfy P.

Page 11: The IC3 Algorithm - University of Waterloovganesh/TEACHING/F2013/SATSMT/lectures... · The IC3/PDR Algorithm Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011

Termination of Algorithm

The PDR algorithm proceeds by refining the frames, adding moreclauses when possible, while maintaining the conditions discussedabove.The algorithm terminates in one of two cases:

1 For some j , Rj = Rj+1. In this case a fix point of reachablestates have been found, and thus M |= P.

2 An error state sI ∈ I is found, from which a path to ¬P exists.In this case M 6|= P.

Page 12: The IC3 Algorithm - University of Waterloovganesh/TEACHING/F2013/SATSMT/lectures... · The IC3/PDR Algorithm Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011

Taking a Step Forward

Set a query to the SAT solver:

SAT?[RN ∧ ¬P] (1)

If not, then RN ⊆ P.

Open a new empty frame RN+1

For every 0 < j , try to “push” clauses from Rj to Rj+1.

A clause c ∈ Rj can be pushed forward if

SAT?[Rj ∧ T ∧ ¬c′] (2)

is not satisfiable.

If two frames are found to be equal, terminate.Otherwise – continue with Query 1 on RN+1.

Page 13: The IC3 Algorithm - University of Waterloovganesh/TEACHING/F2013/SATSMT/lectures... · The IC3/PDR Algorithm Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011

Taking a Step Forward

Set a query to the SAT solver:

SAT?[RN ∧ ¬P] (1)

If not, then RN ⊆ P.

Open a new empty frame RN+1

For every 0 < j , try to “push” clauses from Rj to Rj+1.

A clause c ∈ Rj can be pushed forward if

SAT?[Rj ∧ T ∧ ¬c′] (2)

is not satisfiable.

If two frames are found to be equal, terminate.Otherwise – continue with Query 1 on RN+1.

Page 14: The IC3 Algorithm - University of Waterloovganesh/TEACHING/F2013/SATSMT/lectures... · The IC3/PDR Algorithm Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011

Taking a Step Forward

Set a query to the SAT solver:

SAT?[RN ∧ ¬P] (1)

If not, then RN ⊆ P.

Open a new empty frame RN+1

For every 0 < j , try to “push” clauses from Rj to Rj+1.

A clause c ∈ Rj can be pushed forward if

SAT?[Rj ∧ T ∧ ¬c′] (2)

is not satisfiable.

If two frames are found to be equal, terminate.Otherwise – continue with Query 1 on RN+1.

Page 15: The IC3 Algorithm - University of Waterloovganesh/TEACHING/F2013/SATSMT/lectures... · The IC3/PDR Algorithm Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011

Taking a Step Forward

Set a query to the SAT solver:

SAT?[RN ∧ ¬P] (1)

If not, then RN ⊆ P.

Open a new empty frame RN+1

For every 0 < j , try to “push” clauses from Rj to Rj+1.

A clause c ∈ Rj can be pushed forward if

SAT?[Rj ∧ T ∧ ¬c′] (2)

is not satisfiable.

If two frames are found to be equal, terminate.Otherwise – continue with Query 1 on RN+1.

Page 16: The IC3 Algorithm - University of Waterloovganesh/TEACHING/F2013/SATSMT/lectures... · The IC3/PDR Algorithm Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011

Taking a Step Forward

Set a query to the SAT solver:

SAT?[RN ∧ ¬P] (1)

If not, then RN ⊆ P.

Open a new empty frame RN+1

For every 0 < j , try to “push” clauses from Rj to Rj+1.

A clause c ∈ Rj can be pushed forward if

SAT?[Rj ∧ T ∧ ¬c′] (2)

is not satisfiable.

If two frames are found to be equal, terminate.Otherwise – continue with Query 1 on RN+1.

Page 17: The IC3 Algorithm - University of Waterloovganesh/TEACHING/F2013/SATSMT/lectures... · The IC3/PDR Algorithm Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011

Taking a Step Forward

Set a query to the SAT solver:

SAT?[RN ∧ ¬P] (1)

If not, then RN ⊆ P.

Open a new empty frame RN+1

For every 0 < j , try to “push” clauses from Rj to Rj+1.

A clause c ∈ Rj can be pushed forward if

SAT?[Rj ∧ T ∧ ¬c′] (2)

is not satisfiable.

If two frames are found to be equal, terminate.

Otherwise – continue with Query 1 on RN+1.

Page 18: The IC3 Algorithm - University of Waterloovganesh/TEACHING/F2013/SATSMT/lectures... · The IC3/PDR Algorithm Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011

Taking a Step Forward

Set a query to the SAT solver:

SAT?[RN ∧ ¬P] (1)

If not, then RN ⊆ P.

Open a new empty frame RN+1

For every 0 < j , try to “push” clauses from Rj to Rj+1.

A clause c ∈ Rj can be pushed forward if

SAT?[Rj ∧ T ∧ ¬c′] (2)

is not satisfiable.

If two frames are found to be equal, terminate.Otherwise – continue with Query 1 on RN+1.

Page 19: The IC3 Algorithm - University of Waterloovganesh/TEACHING/F2013/SATSMT/lectures... · The IC3/PDR Algorithm Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011

The IC3 Algorithm

Now suppose that SAT?[RN ∧ ¬P] is satisfiable.

The SAT solver provides a satisfying assignment to thevariables V

A cube s, such that s ⊆ RN , but s ⊆ S \ P.If P holds in M, then the states in s are not reachable in M

exist in RN only because RN is an over-approximation

We want to block s in frame RN

CheckSAT?[RN−1 ∧ T ∧ s′] (3)

If (3) is not satisfiable, s is blockedAdd ¬s to RN ; Continue with Query 1.

Page 20: The IC3 Algorithm - University of Waterloovganesh/TEACHING/F2013/SATSMT/lectures... · The IC3/PDR Algorithm Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011

The IC3 Algorithm

Now suppose that SAT?[RN ∧ ¬P] is satisfiable.

The SAT solver provides a satisfying assignment to thevariables V

A cube s, such that s ⊆ RN , but s ⊆ S \ P.If P holds in M, then the states in s are not reachable in M

exist in RN only because RN is an over-approximation

We want to block s in frame RN

CheckSAT?[RN−1 ∧ T ∧ s′] (3)

If (3) is not satisfiable, s is blockedAdd ¬s to RN ; Continue with Query 1.

Page 21: The IC3 Algorithm - University of Waterloovganesh/TEACHING/F2013/SATSMT/lectures... · The IC3/PDR Algorithm Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011

The IC3 Algorithm

Now suppose that SAT?[RN ∧ ¬P] is satisfiable.

The SAT solver provides a satisfying assignment to thevariables V

A cube s, such that s ⊆ RN , but s ⊆ S \ P.

If P holds in M, then the states in s are not reachable in M

exist in RN only because RN is an over-approximation

We want to block s in frame RN

CheckSAT?[RN−1 ∧ T ∧ s′] (3)

If (3) is not satisfiable, s is blockedAdd ¬s to RN ; Continue with Query 1.

Page 22: The IC3 Algorithm - University of Waterloovganesh/TEACHING/F2013/SATSMT/lectures... · The IC3/PDR Algorithm Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011

The IC3 Algorithm

Now suppose that SAT?[RN ∧ ¬P] is satisfiable.

The SAT solver provides a satisfying assignment to thevariables V

A cube s, such that s ⊆ RN , but s ⊆ S \ P.If P holds in M, then the states in s are not reachable in M

exist in RN only because RN is an over-approximation

We want to block s in frame RN

CheckSAT?[RN−1 ∧ T ∧ s′] (3)

If (3) is not satisfiable, s is blockedAdd ¬s to RN ; Continue with Query 1.

Page 23: The IC3 Algorithm - University of Waterloovganesh/TEACHING/F2013/SATSMT/lectures... · The IC3/PDR Algorithm Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011

The IC3 Algorithm

Now suppose that SAT?[RN ∧ ¬P] is satisfiable.

The SAT solver provides a satisfying assignment to thevariables V

A cube s, such that s ⊆ RN , but s ⊆ S \ P.If P holds in M, then the states in s are not reachable in M

exist in RN only because RN is an over-approximation

We want to block s in frame RN

CheckSAT?[RN−1 ∧ T ∧ s′] (3)

If (3) is not satisfiable, s is blockedAdd ¬s to RN ; Continue with Query 1.

Page 24: The IC3 Algorithm - University of Waterloovganesh/TEACHING/F2013/SATSMT/lectures... · The IC3/PDR Algorithm Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011

The IC3 Algorithm

Now suppose that SAT?[RN ∧ ¬P] is satisfiable.

The SAT solver provides a satisfying assignment to thevariables V

A cube s, such that s ⊆ RN , but s ⊆ S \ P.If P holds in M, then the states in s are not reachable in M

exist in RN only because RN is an over-approximation

We want to block s in frame RN

CheckSAT?[RN−1 ∧ T ∧ s′] (3)

If (3) is not satisfiable, s is blockedAdd ¬s to RN ; Continue with Query 1.

Page 25: The IC3 Algorithm - University of Waterloovganesh/TEACHING/F2013/SATSMT/lectures... · The IC3/PDR Algorithm Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011

The IC3 Algorithm

Now suppose that SAT?[RN ∧ ¬P] is satisfiable.

The SAT solver provides a satisfying assignment to thevariables V

A cube s, such that s ⊆ RN , but s ⊆ S \ P.If P holds in M, then the states in s are not reachable in M

exist in RN only because RN is an over-approximation

We want to block s in frame RN

CheckSAT?[RN−1 ∧ T ∧ s′] (3)

If (3) is not satisfiable, s is blockedAdd ¬s to RN ; Continue with Query 1.

Page 26: The IC3 Algorithm - University of Waterloovganesh/TEACHING/F2013/SATSMT/lectures... · The IC3/PDR Algorithm Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011

The IC3 Algorithm

CheckSAT?[RN−1 ∧ T ∧ s′]

If (3) is satisfiable

We get a cube s1Needs to be blocked in frame RN−1

Check Query 3 with frame RN−2 and s′1...

If none of the cubes can be blocked during this process, thena query finally returns a cube sI ⊆ I

Cannot be blockedP does not hold in the model!

Page 27: The IC3 Algorithm - University of Waterloovganesh/TEACHING/F2013/SATSMT/lectures... · The IC3/PDR Algorithm Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011

The IC3 Algorithm

CheckSAT?[RN−1 ∧ T ∧ s′]

If (3) is satisfiable

We get a cube s1Needs to be blocked in frame RN−1Check Query 3 with frame RN−2 and s′1

...

If none of the cubes can be blocked during this process, thena query finally returns a cube sI ⊆ I

Cannot be blockedP does not hold in the model!

Page 28: The IC3 Algorithm - University of Waterloovganesh/TEACHING/F2013/SATSMT/lectures... · The IC3/PDR Algorithm Aaron R. Bradley: SAT-Based Model Checking without Unrolling. VMCAI 2011

The IC3 Algorithm

CheckSAT?[RN−1 ∧ T ∧ s′]

If (3) is satisfiable

We get a cube s1Needs to be blocked in frame RN−1Check Query 3 with frame RN−2 and s′1...

If none of the cubes can be blocked during this process, thena query finally returns a cube sI ⊆ I

Cannot be blockedP does not hold in the model!