09. Unbounded Model Checking
09. Unbounded Model Checking
系統晶片驗證
SoC Verification
2021.05.07
1
Limitation of Formal Engine
u Still bounded by exponential complexity
l When design gets big, or property becomes
complex, it is very often that the formal engine
cannot conclude the proof result
è We have “coverage metric” for simulation, what
about formal method?
u However, property checking by formal engine is
somewhat analogous to reversely reasoning on
designer’s intent
l Designer’s intent should not be too complicated for
one local module
l It’s the interaction on the modules that make the
problem difficult
2
Localization abstraction
u Property: G (c ⇒ X c)
a g C'= {
b p c g = a ∧ b,
p = g ∨ c,
c' = p
}
Constraint granularity
Most authors use constraints at "latch" granularity...
a g Model:
b p c
C={
c' = (a ∧ b) ∨ c
}
3
Localization, cont
u C' may refer to fewer state variables than C
l reduction in the state explosion problem
4
Counter-example based Abstraction
Creating Initial C’
u e.g. Cut at FF boundary
¬p ¬p
PIs POs
Combinational
elements
t=0 PIs FFs FFs
PPIs
seq elm
PIs POs
PPIs C’
t=2
seq elm
10
5
Counter-example based Abstraction
11
Counterexample extension
u Abstract counterexample A' satisfies:
I0 ∧ U'k ∧ Fk where U'k = C'0 ∧ C'1 ∧ ... ∧ C'k-1
12
6
Abstraction refinement
u Refinement = adding constraints to C' to
eliminate false counterexamples.
u Many heuristsics used for this.
13
14
7
Refutation Refinement for Counter-example
Based Abstraction
I A’ C’ A’ C’ A’ C’ F
C’’ refutation
C
15
In other words...
The refutation of the formula:
A' ∧ I0 ∧ Uk ∧ Fk
16
8
Counter-example based Abstraction
17
18
9
Proof-based abstraction MA,TACAS03
Cex?
BMC done
at depth k
No Cex?
Use refutation to
Increase k
choose abstraction
True?
MC abstraction done
False?
19
BMC phase
u Unfold the model k times:
Uk = C0 ∧ C1 ∧ ... ∧ Ck
• If unsatisfiable:
• property has no Cex of length k
• produce a refutation proof R
20
10
Abstraction phase
u Let C' be set of constraints used in proof R:
C' = { c ∈ C | some ci occurs in R }
u C' admits no counterexample of length k
l Let U' = C'0 ∧ C'1 ∧ ... ∧ C'k
l R is a refutation of I0 ∧ U' ∧ Fk
21
True?
Model check C' done
22
11
Termination
u Depth k increases at each iteration
u Eventually k > d, diameter of C'
u If k > d, no counterexample is possible
23
24
12
Inference
u SAT solver seems to be very effective at
narrowing down the proof to relevant facts.
In most cases,
it did better than manual abstraction.
25
u Apples-apples comparison
l same SAT solver
l same model checker
l only differences are:
§ For CBA previous A' is kept as a constraint for BMC,
C' is cumulative.
§ For PBA previous A' and C' are thrown away each
iteration.
26
13
Run time comparison
27
Abstraction comparison
28
14
Possible explanation
u Internally, SAT solver is really doing CBA
a=0
b=1 decision stack
c=0 = abstract Cex A'
d=1
refutation of A'
decision heuristic
moves proof variables
up, into A'
SoC Verification Prof. Chung-Yang (Ric) Huang 29
29
30
15
Flashback
Cex-based Proof-based
true cex
BDD on C’ T BMC(k) F
cex unsat / abstract
cex true
BMC F BDD on C’ T
refine increase k
31
32
16
Fixed point characterization by SAT
u Recall: Fixed point characterizaion of CTL:
EFp = µ. Q (p ∨ EX Q)
u Reverse image: (what are the states that lead to p?)
state variable
input variables
transition function
33
34
17
In other words, to compute pre-image
35
Limitations
u Syntactic quantifier elimination is
exponential
l Method limited to circuits with very few
inputs
l E.g., sequential arithmetic circuits
36
18
Direct image computation
u Adapt SAT methods for image computation
in symbolic model checking
l Recall: this is essentially quantifier
elimination
u Idea: reduce formula to CNF or DNF
l Make quantifier elimination easy
l Essentially, enumerate all satisfying
assignments, but in an efficient way (i.e., by
covering them with clauses or cubes).
37
CNF Characterization
38
19
CNF characterization algorithm
A = ∅, c = ∅
empty y return
clause? c
n
y
Deduce conflict?
Infer blocking
clause c’ from p.
is A y Add c’ to f, c.
Branch
total?
39
40
20
CTL Model Checking with SAT
AXp p
state variable
input variables
transition function
41
42
21
" - elimination algorithm
A = ∅, c = ∅
empty y return
clause? c
n
y
Deduce conflict?
Infer blocking
clause c’ from p.
is A y Add "W.c’ to f, c.
Branch
total?
43
44
22
SAT-based image
u May provide a good alternative when
BDD's fail.
u Does not take advantage of SAT solver's
ability to filter out irrelevant facts, since
exact image is computed.
45
Over-approximated reachability
u Define an over-approximated image op. Img' s.t.
for all S, Img(S,C) implies Img'(S,C)
Img’(S,C)
u Over-approximated reachability:
R'0 = I S Img(S,C)
R'i+1 = R'i ∨ Img'(R'i,C)
R' = È R'i
u Img' is adequate w.r.t. F, when
l if S cannot reach F, Img’(S,C) cannot reach F
u If Img' is adequate, then
l F is reachable iff R' ∧ F ≠ false
46
23
Adequate image
overapprox. img
Img(S,C)
S Img’(S,C) F
47
48
24
Image over-approximation
u BMC and Craig interpolation allow us to
compute image over-approximation relative
to property.
l Avoid computing exact image.
l Maintain SAT solver's advantage of filtering
out irrelevant facts.
49
(Craig,57)
Interpolation
u If A ∧ B = false, there exists an interpolant I for
(A,B) such that:
A⇒I A I B
I ∧ B = false
I refers only to common variables of A,B
u Example:
l A = p ∧ q, B = ¬q ∧ r, A' = q
u New result
l given a resolution refutation of A ∧ B,
A' can be derived in linear time.
(Pudlak,Krajicek,97)
SoC Verification Prof. Chung-Yang (Ric) Huang 50
50
25
Another Example of Interpolation
SAT target: A ∧ B
A: (¬x∧z) ∨ (x∧ ¬y∧ ¬z )
B: (x∧y) ∨ (¬x∧ ¬z) A B
g1 g4
A B
z
g2 g3 g5 g6
A
y B B
B A x x y z
51
A B
z
A
y B B
B A x z x y
52
26
Some Definitions for Unsatisfiability Proof
u Let (A,B) be a pair of clause sets and let Π be a proof of
unsatisfiability of A ∪ B
l Π is a DAG (VΠ, EΠ)
l Each vertex c ∈ Π in the graph corresponds to a clause
and has exactly 2 predecessors, say c1, c2
§ c is called the “resolvent” of c1 and c2
§ The resolved variable v is called the “pivot” variable
l Π has exactly 1 leaf vertex which is a False (null clause)
l The roots are original clauses in A ∪ B
A B
c1 c2 Π
c
Null clause
SoC Verification Prof. Chung-Yang (Ric) Huang 53
53
54
27
Again, Implication graph, resolution, and learning
Decision level
a=1 a=1 a1 = 0 a2 = 1 a3 = 1 1
b=0 b=0 b1 = 0 b2 = 1 b3 = 0 b4 = 1 2
(1): (c2’ + g)
(2): (b4’ + c4 + g’) (b4’ + c2’ + c4)
(3): (a2’ + c3’ + c4’) (a2’ + b4’ + c2’ + c3’)
(4): (c1 + c3) (a2’ + b4’ + c1 + c2’)
(5): (b1 + c1 + c2) (a2’ + b1 + b4’ + c1)
SoC Verification Prof. Chung-Yang (Ric) Huang 55
55
u A conflict is encountered
in decision level 0
l Problem is proven
UNSAT
Proof core
56
28
Interpolants from Proofs (McMillan)
u Deriving interpolant from Π
è Calling itp(leaf vertex)
u itp(c) { // c ∈ VΠ let p(c) be a
if c is a root, then
if c ∈ A then
itp(c) = the disjunction of the
global literals in c
else itp(c) = constant True
else, let c1, c2 be the predecessors of c
and let v be their pivot variable
if v is local to A
then itp(c) = itp(c1) ∨ itp(c2)
else itp(c) = itp(c1) ∧ itp(c2)
}
SoC Verification Prof. Chung-Yang (Ric) Huang 57
57
(p) (¬p ∨ q) (¬q ∨ r)(¬r) (p) is root and ∈ A (¬p ∨ q) is root and ∈ A
but global literals = ∅ global literals = {q}
(q) False (q)
}
else itp(c) = itp(c1) ∧ itp(c2)
q èA’
SoC Verification Prof. Chung-Yang (Ric) Huang 58
58
29
How can interpolation help SAT-based
unbounded model checking?
u Remember:
SAT doesn’t compute nor record exact
image, and it is not a good idea to use SAT
for exact image computation
u In BMC:
A = S 0 ∧ C0 B = C1 ∧ C2 ∧... ∧ Ck ∧ Fk
S0 C0 C1 C2 Ck-1 Ck Fk
UNSAT
t=0 t=k
What does A mean?
What’s the image(S0) here? What does B means?
What does their interpolant I mean?
SoC Verification Prof. Chung-Yang (Ric) Huang 59
59
S0 C0 Y C1 C2 Ck-1 Ck Fk
UNSAT
t=0 t=k
u A = S0 ∧ C0
l Characterize S1 (not computed), the image of S0, on the variables Y
u B = C1 ∧ C2 ∧... ∧ Ck ∧ Fk
l Characterize the set of states on variables Y that can witness (reach)
Fk in k timeframes
u I = interpolation of A and B
l AèI
l I∧B=∅
l I refers to A’s and B’s common variables (Who are they???)
è I is an over-approximated image of S1 on Y
è The states in I cannot reach Fk in k timeframes
60
30
Interpolation-based image
u Idea -- use unfolding to enforce k-adequacy
A = S 0 ∧ C0 B = C1 ∧ C2 ∧... ∧ Ck ∧ Fk
S0 C0 Y C1 C2 Ck-1 Ck Fk
UNSAT
t=0 t=k
Let I = Img'(S0),
where I is an interpolant for (A,B)...
- remember: I contains the
Img' is k-adequate!
common variables of (A, B)
61
Intuition
A = S 0 ∧ C0
I B = C1 ∧ C2 ∧... ∧ Ck ∧ Fk
S0 C0 Y C1 C2 Ck-1 Ck Fk
UNSAT
t=0 t=k
62
31
Interpolation-based UBMC
let k = 0
repeat_1
if BMCk(S0, F) = SAT, answer reachable
R = S0
let i = 0
repeat_2
Si+1 = Img’(Si,C)
if (BMCk(Si+1, F) = SAT) break repeat_2
R' = R ∨ Si+1
if R' = R answer unreachable
R = R‘
increase i
end repeat_2
increase k
end repeat_1
63
Interpolation-based UBMC
S0 C0 F0 A = S1’ ∧ C0 B = C1 ∧ F1
SAT
F@0 NO S1’ C0 C 1 F1
t=0 SAT
K++
UNSAT t=0 S2’ t=1
S0 C0 C 1 F1 UNSAT
SAT
F@1
R2 = R1 ∨ S2’ YES Fixed
t=0 t=1 R2 == R1 ? point
R0 = S0 UNSAT NO
A = S 0 ∧ C0 B = C 1 ∧ F1
Fixed point A = S2’ ∧ C0 B = C1 ∧ F1
YES S2’ C0 C 1 F1
S0 C0 C 1 F1 SAT
R1 = R0 ∨ S1’ K++
R1 == R0 ? t=0 S3’ t=1
t=0 S1’ t=1
SoC Verification Prof. Chung-Yang (Ric) Huang
UNSAT 64
64
32
Termination
u Since k increases at every iteration,
eventually k > d, the diameter, in which
case Img' is adequate, and hence we
terminate.
Notes:
l don't need to know when k > d in order to
terminate
l often termination occurs with k << d
l depth bound for earlier method (Sheeran et
al '00) is "longest simple path", which can
be exponentially longer than diameter
65
Interpolation-based UBMC
u Fully SAT-based.
u Inherits SAT solvers ability to concentrate
on facts relevant to a property.
u Like CBA, PBA, most effective when
l Very large set of facts is available
l Only a small subset are relevant to property
u For true properties, appears to converge for
smaller k values.
66
33
Is the above intp-UBMC complete?
u Given the diameter d unknown, does interpolation-
UBMC always terminate for certain k?
l No, similar to induction SAT, if there exists a state
that (1) is unreachable from init state, (2) can go
to !p, (3) is involved in a loop, and (4) is reachable
by the img’ operator, then the interpolation-UBMC
may not converge for any k.
l How to resolve this??
S0 Img’(S0,C) P ¬P
unreachable
from I, but can
reach ¬P
SoC Verification Prof. Chung-Yang (Ric) Huang 67
67
68
34