lec13_SMV
lec13_SMV
2/18/2005
2
© 2011 Carnegie Mellon University 2
Overview of SMV
SMV Input
Language Backend
Finite
State
Kripke OBDD based Yes
Structure Symbolic Model
Checking
Specification –
CTL Formula
No
CounterExample
2/18/2005
3
© 2011 Carnegie Mellon University 3
SMV Variants
Cadence
SMV
NuSMV
l Strong abstraction functions
CMU l GUI
SMV
l New language
Two versions
l 2.x: Open Source, many
l Oldest Version new features, BDD and SAT
l No GUI based backends
l 1.x: Original version, had a
GUI
Parallel-assignment syntax
Non-determinism
MODULE
main
VAR
request:
boolean;
state:
{ready,
busy};
ASSIGN
init(state)
:=
ready;
next(state)
:=
case
state=ready
&
request:
busy;
TRUE
:
{ready,
busy};
esac;
SPEC
AG(request
-‐>
AF
(state
=
busy))
2/18/2005
7
© 2011 Carnegie Mellon University 7
Kripke structure Computation tree
ready
request
ready busy
!request !request
busy busy
!request request
2/18/2005
9
© 2011 Carnegie Mellon University 9
AG(request
-‐>
AX
(state
=
busy))
is false
ready busy
!request !request
ready busy
request request
Expr
::
atom
-‐-‐
symbolic
constant
|
number
-‐-‐
numeric
constant
|
id
-‐-‐
variable
identifier
|
“!”
Expr
-‐-‐
logical
not
|
Expr
&
Expr
-‐-‐
logical
and
|
Expr
|
Expr
-‐-‐
logical
or
|
Expr
-‐>
Expr
-‐-‐
logical
implication
|
Expr
<-‐>
Expr
-‐-‐
logical
equivalence
|
“next”
“(“
id
“)”
-‐-‐
next
value
|
Case_expr
|
Set_expr
Scoping
• Variables declared outside a module can be passed as
parameters
DEFINE
a
:=
0;
VAR
DEFINE
b
:
bar(a);
a
:=
0;
…
b.y
:=
0;
MODULE
bar(x)
b.a
:=
1;
DEFINE
a
:=
1;
y
:=
x;
20
© 2011 Carnegie Mellon University 20
Pass by reference
VAR
a
:
boolean;
VAR
b
:
foo(a);
a
:
boolean;
…
b.y
:
boolean;
MODULE
foo(x)
ASSIGN
VAR
a
:=
TRUE;
y
:
boolean;
b.y
:=
FALSE;
ASSIGN
x
:=
TRUE;
y
:=
FALSE;
21
© 2011 Carnegie Mellon University 21
A Three-Bit Counter
MODULE
main
VAR
bit0
:
counter_cell(TRUE);
bit1
:
counter_cell(bit0.carry_out);
bit2
:
counter_cell(bit1.carry_out);
SPEC
AG
AF
bit2.carry_out
MODULE
counter_cell(carry_in)
VAR
value
:
boolean;
ASSIGN
init(value)
:=
FALSE;
value
+
carry_in
mod
2
next(value)
:=
value
xor
carry_in;
DEFINE
carry_out
:=
value
&
carry_in;
val
in out
bit0
module declaration
val val
in out in out
bit1
val
in out
bit2
in 1 1 1 1 1 1 1 1 1
bit0 val 0 1 0 1 0 1 0 1 0
out 0 1 0 1 0 1 0 1 0
in 0 1 0 1 0 1 0 1 0
bit1 val 0 0 1 1 0 0 1 1 0
out 0 0 0 1 0 0 0 1 0
in 0 0 0 1 0 0 0 1 0
bit2 val 0 0 0 0 1 1 1 1 0
out 0 0 0 0 0 0 0 1 0
bit2.carry_out is ture
in 1 1 1 1 1 1 1 1 1
bit0 val 0 1 0 1 0 1 0 1 0
out 0 1 0 1 0 1 0 1 0
in 0 1 0 1 0 1 0 1 0
bit1 val 0 0 1 1 0 0 1 1 0
out 0 0 0 1 0 0 0 1 0
in 0 0 0 1 0 0 0 1 0
bit2 val 0 0 0 0 1 1 1 1 0
out 0 0 0 0 0 0 0 1 0
bit2.carry_out is ture
Synchronous composition
• All assignments are executed in parallel and synchronously.
• A single step of the resulting model corresponds to a step in each
of the components.
Asynchronous composition
• A step of the composition is a step by exactly one process.
• Variables, not assigned in that process, are left unchanged.
in 0 0 0 1 1 1 0 0 0 1
gate0 out 0 1 1 0 0 0 1 1 1 0
in 0 1 1 1 0 0 0 1 1 1
gate1
out 0 0 0 0 1 1 1 0 0 0
in 0 0 0 0 0 1 1 1 0 0
gate2
out 0 0 1 1 1 0 0 0 1 1
FAIRNESS Ctlform
FAIRNESS running
INIT Expr
INVAR Expr
TRANS Expr
Advantages
• Group assignments to different variables
• Good for modeling guarded commands
– IF guard THEN new state
Disadvantages
• Logical absurdities can lead to unimplementable
descriptions
M ⊧ AG (x ⇒ AF x) Always vacuous!!!
M ⊧ AG TRUE
M ⊧ AG (x ⇒ AX x) Can be vacuous!!!
can’t reduce
Basic Usage
• go
– prepare model for verification
• check_ctlspec
– verify properties
Simulation
• pick_state
[-‐i]
[-‐r]
– pick initial state for simulation [interactively] or [randomly]
• simulate
[-‐i]
[r]
s
– simulate the model for ‘s’ steps [interactively] or [randomly]
• show_traces
– show active traces