Lecture 3: Model-checker NuSMV
- B. Srivathsan
Chennai Mathematical Institute
NPTEL-course July - November 2015
1/31
Lecture 3: Model-checker NuSMV B. Srivathsan Chennai Mathematical - - PowerPoint PPT Presentation
Lecture 3: Model-checker NuSMV B. Srivathsan Chennai Mathematical Institute NPTEL-course July - November 2015 1 / 31 Model-checker Specify the model of the system Specify the requirements Model-checker will automatically check if system
NPTEL-course July - November 2015
1/31
◮ Specify the model of the system ◮ Specify the requirements
2/31
3/31
3/31
◮ Declare the variables
3/31
◮ Declare the variables ◮ Define the initial values of the variables
3/31
◮ Declare the variables ◮ Define the initial values of the variables ◮ Define the next-state relation
3/31
◮ Declare the variables ◮ Define the initial values of the variables ◮ Define the next-state relation
3/31
4/31
y = NOT ( XOR (x,r) ) rnext = XOR (x,r)
XOR NOT
x
y
r register
x = 0,r = 0,y = 1 x = 1,r = 0,y = 0 x = 0,r = 1,y = 0 x = 1,r = 1,y = 1 5/31
y = NOT ( XOR (x,r) ) rnext = XOR (x,r)
XOR NOT
x
y
r register
x = 0,r = 0,y = 1 x = 1,r = 0,y = 0 x = 0,r = 1,y = 0 x = 1,r = 1,y = 1
5/31
y = NOT ( XOR (x,r) ) rnext = XOR (x,r)
XOR NOT
x
y
r register
x = 0,r = 0,y = 1 x = 1,r = 0,y = 0 x = 0,r = 1,y = 0 x = 1,r = 1,y = 1
5/31
y = NOT ( XOR (x,r) ) rnext = XOR (x,r)
XOR NOT
x
y
r register
x = 0,r = 0,y = 1 x = 1,r = 0,y = 0 x = 0,r = 1,y = 0 x = 1,r = 1,y = 1
5/31
y = NOT ( XOR (x,r) ) rnext = XOR (x,r)
XOR NOT
x
y
r register
x = 0,r = 0,y = 1 x = 1,r = 0,y = 0 x = 0,r = 1,y = 0 x = 1,r = 1,y = 1
5/31
y = NOT ( XOR (x,r) ) rnext = XOR (x,r)
XOR NOT
x
y
r register
x = 0,r = 0,y = 1 x = 1,r = 0,y = 0 x = 0,r = 1,y = 0 x = 1,r = 1,y = 1
5/31
y = NOT ( XOR (x,r) ) rnext = XOR (x,r)
XOR NOT
x
y
r register
x = 0,r = 0,y = 1 x = 1,r = 0,y = 0 x = 0,r = 1,y = 0 x = 1,r = 1,y = 1
5/31
l1 l2 x < 10 x := x+1
6/31
l1 l2 x < 10 x := x+1 MODULE main VAR ASSIGN
6/31
l1 l2 x < 10 x := x+1 MODULE main VAR ASSIGN location: {l1,l2}; x: 0 .. 100;
6/31
l1 l2 x < 10 x := x+1 MODULE main VAR ASSIGN location: {l1,l2}; x: 0 .. 100; init(location) := l1; init(x) := 0;
6/31
l1 l2 x < 10 x := x+1 MODULE main VAR ASSIGN location: {l1,l2}; x: 0 .. 100; init(location) := l1; init(x) := 0; next(location) := case esac;
6/31
l1 l2 x < 10 x := x+1 MODULE main VAR ASSIGN location: {l1,l2}; x: 0 .. 100; init(location) := l1; init(x) := 0; next(location) := case (location = l1) & (x<10): l2; esac;
6/31
l1 l2 x < 10 x := x+1 MODULE main VAR ASSIGN location: {l1,l2}; x: 0 .. 100; init(location) := l1; init(x) := 0; next(location) := case (location = l1) & (x<10): l2; (location = l2) : l1; esac;
6/31
l1 l2 x < 10 x := x+1 MODULE main VAR ASSIGN location: {l1,l2}; x: 0 .. 100; init(location) := l1; init(x) := 0; next(location) := case (location = l1) & (x<10): l2; (location = l2) : l1; TRUE: location; esac;
6/31
l1 l2 x < 10 x := x+1 MODULE main VAR ASSIGN location: {l1,l2}; x: 0 .. 100; init(location) := l1; init(x) := 0; next(location) := case (location = l1) & (x<10): l2; (location = l2) : l1; TRUE: location; esac; next(x) := case esac;
6/31
l1 l2 x < 10 x := x+1 MODULE main VAR ASSIGN location: {l1,l2}; x: 0 .. 100; init(location) := l1; init(x) := 0; next(location) := case (location = l1) & (x<10): l2; (location = l2) : l1; TRUE: location; esac; next(x) := case (location = l2) & x < 100: x+1; esac;
6/31
l1 l2 x < 10 x := x+1 MODULE main VAR ASSIGN location: {l1,l2}; x: 0 .. 100; init(location) := l1; init(x) := 0; next(location) := case (location = l1) & (x<10): l2; (location = l2) : l1; TRUE: location; esac; next(x) := case (location = l2) & x < 100: x+1; TRUE: x; esac;
6/31
l1 l2 x < 10 x := x+1 MODULE main VAR ASSIGN location: {l1,l2}; x: 0 .. 100; init(location) := l1; init(x) := 0; next(location) := case (location = l1) & (x<10): l2; (location = l2) : l1; TRUE: location; esac; next(x) := case (location = l2) & x < 100: x+1; TRUE: x; esac; NuSMV file: pg-demo.smv
6/31
MODULE main VAR request: boolean; status: {ready, busy}
7/31
request=1 ready request=1 busy request=0 ready request=0 busy MODULE main VAR request: boolean; status: {ready, busy}
7/31
request=1 ready request=1 busy request=0 ready request=0 busy MODULE main VAR request: boolean; status: {ready, busy} ASSIGN init(status) := ready;
7/31
request=1 ready request=1 busy request=0 ready request=0 busy MODULE main VAR request: boolean; status: {ready, busy} ASSIGN init(status) := ready; next(status) := case request : busy; TRUE : {ready,busy}; esac;
7/31
request=1 ready request=1 busy request=0 ready request=0 busy MODULE main VAR request: boolean; status: {ready, busy} ASSIGN init(status) := ready; next(status) := case request : busy; TRUE : {ready,busy}; esac;
7/31
request=1 ready request=1 busy request=0 ready request=0 busy MODULE main VAR request: boolean; status: {ready, busy} ASSIGN init(status) := ready; next(status) := case request : busy; TRUE : {ready,busy}; esac;
7/31
8/31
l1 l2 x < 10 x := x+1
l1, x=0 l2, x=0 l1, x=1 l2, x=1 l1, x=9 l2, x=9 l1, x=10
9/31
request=1 ready request=1 busy request=0 ready request=0 busy
request=0 ready request=0 busy request=0 ready request=1 busy request=1 busy
request=1 ready request=1 busy request=0 busy request=1 busy request=0 busy
request=0 ready request=0 ready request=0 ready request=0 ready request=0 ready
10/31
11/31
12/31
l1 l2 x < 10 x := x+1 l1, x=0 l2, x=0 l1, x=1 l2, x=1 l1, x=9 l2, x=9 l1, x=10
12/31
l1 l2 x < 10 x := x+1 l1, x=0 l2, x=0 l1, x=1 l2, x=1 l1, x=9 l2, x=9 l1, x=10
12/31
request=1 ready request=1 busy request=0 ready request=0 busy
request=0 ready request=0 busy request=0 ready request=1 busy request=1 busy
request=1 ready request=1 busy request=0 ready request=1 busy request=0 ready
request=0 ready request=0 ready request=0 ready request=0 ready request=0 ready
13/31
request=1 ready request=1 busy request=0 ready request=0 busy
request=0 ready request=0 busy request=0 ready request=1 busy request=1 busy
request=1 ready request=1 busy request=0 ready request=1 busy request=0 ready
request=0 ready request=0 ready request=0 ready request=0 ready request=0 ready
13/31
request=1 ready request=1 busy request=0 ready request=0 busy
request=0 ready request=0 busy request=0 ready request=1 busy request=1 busy
request=1 ready request=1 busy request=0 ready request=1 busy request=0 ready
request=0 ready request=0 ready request=0 ready request=0 ready request=0 ready
13/31
request=1 ready request=1 busy request=0 ready request=0 busy
ready request=0 busy request=0 ready request=1 busy request=1 busy
request=1 ready request=1 busy request=0 ready request=1 busy request=0 ready
request=0 ready request=0 ready request=0 ready request=0 ready request=0 ready
13/31
request=1 ready request=1 busy request=0 ready request=0 busy
request=0 ready request=0 busy request=0 ready request=1 busy request=1 busy
request=1 ready request=1 busy request=0 ready request=1 busy request=0 ready
request=0 ready request=0 ready request=0 ready request=0 ready request=0 ready
13/31
T T T T T T
14/31
T T T T T T
14/31
15/31
16/31
l1 l2 x < 10 x := x+1 l1, x=0 l2, x=0 l1, x=1 l2, x=1 l1, x=9 l2, x=9 l1, x=10
16/31
l1 l2 x < 10 x := x+1 l1, x=0 l2, x=0 l1, x=1 l2, x=1 l1, x=9 l2, x=9 l1, x=10
16/31
request=1 ready request=1 busy request=0 ready request=0 busy
request=0 ready request=0 busy request=0 ready request=1 busy request=1 busy
request=1 ready request=1 busy request=0 ready request=1 busy request=0 ready
request=0 ready request=0 ready request=0 ready request=0 ready request=0 ready
17/31
request=1 ready request=1 busy request=0 ready request=0 busy
ready request=0 busy request=0 ready request=1 busy request=1 busy
request=1 ready request=1 busy request=0 ready request=1 busy request=0 ready
request=0 ready request=0 ready request=0 ready request=0 ready request=0 ready
17/31
request=1 ready request=1 busy request=0 ready request=0 busy
ready request=0 busy request=0 ready request=1 busy request=1 busy
request=1 ready request=1 busy request=0 ready request=1 busy request=0 ready
request=0 ready request=0 ready request=0 ready request=0 ready request=0 ready
17/31
request=1 ready request=1 busy request=0 ready request=0 busy
request=0 ready request=0 busy request=0 ready request=1 busy request=1 busy
request=1 ready request=1 busy request=0 ready request=1 busy request=0 ready
request=0 ready request=0 ready request=0 ready request=0 ready request=0 ready
17/31
request=1 ready request=1 busy request=0 ready request=0 busy
request=0 ready request=0 busy request=0 ready request=1 busy request=1 busy
request=1 ready request=1 busy request=0 ready request=1 busy request=0 ready
request=0 ready request=0 ready request=0 ready request=0 ready request=0 ready
17/31
T
18/31
T
18/31
19/31
20/31
request=1 ready request=1 busy request=0 ready request=0 busy
request=0 ready request=0 busy request=0 ready request=1 busy request=1 busy
request=1 ready request=1 busy request=0 ready request=1 busy request=0 ready
request=0 ready request=0 ready request=0 ready request=0 ready request=0 ready
21/31
request=1 ready request=1 busy request=0 ready request=0 busy
ready request=0 busy request=0 ready request=1 busy request=1 busy
request=1 ready request=1 busy request=0 ready request=1 busy request=0 ready
request=0 ready request=0 ready request=0 ready request=0 ready request=0 ready
21/31
request=1 ready request=1 busy request=0 ready request=0 busy
ready request=0 busy request=0 ready request=1 busy request=1 busy
request=1 ready request=1 busy request=0 ready request=1 busy request=0 ready
request=0 ready request=0 ready request=0 ready request=0 ready request=0 ready
21/31
request=1 ready request=1 busy request=0 ready request=0 busy
ready request=0 busy request=0 ready request=1 busy request=1 busy
request=1 ready request=1 busy request=0 ready request=1 busy request=0 ready
request=0 ready request=0 ready request=0 ready request=0 ready request=0 ready
21/31
request=1 ready request=1 busy request=0 ready request=0 busy
request=0 ready request=0 busy request=0 ready request=1 busy request=1 busy
request=1 ready request=1 busy request=0 ready request=1 busy request=0 ready
request=0 ready request=0 ready request=0 ready request=0 ready request=0 ready
21/31
22/31
22/31
in1 in2
23/31
in1 in2
23/31
in1 in2
1 1 1 1 1 1 1
23/31
in1 in2
1 1 1 1 1 1 1
23/31
in1 in2
1 1 1 1 1 1 1
23/31
in1 in2
24/31
in1 in2
1 1 1 1 1 1 1 1 1 1 1 1
24/31
in1 in2
1 1 1 1 1 1 1 1 1 1 1 1
24/31
in1 in2
1 1 1 1 1 1 1 1 1 1 1 1
24/31
in1 in2
1 1 1 1 1 1 1 1 1 1 1 1
24/31
in1 in2
1 1 1 1 1 1 1 1 1 1 1 1
24/31
in1 in2
1 1 1 1 1 1 1 1 1 1 1 1
25/31
x1 x2
y1 y2
26/31
x
y
27/31
28/31
MODULE counter_cell(carry_in) VAR value:boolean; ASSIGN init(value):=FALSE; next(value):= value xor carry_in; DEFINE carry_out := carry_in & value; MODULE main VAR bit0:counter_cell(TRUE); bit1:counter_cell(bit0.carry_out); bit2:counter_cell(bit1.carry_out);
29/31
bit0 bit1 bit2 carry_in value carry_out 1 MODULE counter_cell(carry_in) VAR value:boolean; ASSIGN init(value):=FALSE; next(value):= value xor carry_in; DEFINE carry_out := carry_in & value; MODULE main VAR bit0:counter_cell(TRUE); bit1:counter_cell(bit0.carry_out); bit2:counter_cell(bit1.carry_out);
29/31
bit0 bit1 bit2 carry_in value carry_out 1 1 MODULE counter_cell(carry_in) VAR value:boolean; ASSIGN init(value):=FALSE; next(value):= value xor carry_in; DEFINE carry_out := carry_in & value; MODULE main VAR bit0:counter_cell(TRUE); bit1:counter_cell(bit0.carry_out); bit2:counter_cell(bit1.carry_out);
29/31
bit0 bit1 bit2 carry_in value carry_out 1 1 1 MODULE counter_cell(carry_in) VAR value:boolean; ASSIGN init(value):=FALSE; next(value):= value xor carry_in; DEFINE carry_out := carry_in & value; MODULE main VAR bit0:counter_cell(TRUE); bit1:counter_cell(bit0.carry_out); bit2:counter_cell(bit1.carry_out);
29/31
bit0 bit1 bit2 carry_in value carry_out 1 1 1 1 MODULE counter_cell(carry_in) VAR value:boolean; ASSIGN init(value):=FALSE; next(value):= value xor carry_in; DEFINE carry_out := carry_in & value; MODULE main VAR bit0:counter_cell(TRUE); bit1:counter_cell(bit0.carry_out); bit2:counter_cell(bit1.carry_out);
29/31
bit0 bit1 bit2 carry_in value carry_out 1 1 1 1 MODULE counter_cell(carry_in) VAR value:boolean; ASSIGN init(value):=FALSE; next(value):= value xor carry_in; DEFINE carry_out := carry_in & value; MODULE main VAR bit0:counter_cell(TRUE); bit1:counter_cell(bit0.carry_out); bit2:counter_cell(bit1.carry_out);
29/31
bit0 bit1 bit2 carry_in value carry_out 1 1 1 1 1 MODULE counter_cell(carry_in) VAR value:boolean; ASSIGN init(value):=FALSE; next(value):= value xor carry_in; DEFINE carry_out := carry_in & value; MODULE main VAR bit0:counter_cell(TRUE); bit1:counter_cell(bit0.carry_out); bit2:counter_cell(bit1.carry_out);
29/31
bit0 bit1 bit2 carry_in value carry_out 1 1 1 1 1 MODULE counter_cell(carry_in) VAR value:boolean; ASSIGN init(value):=FALSE; next(value):= value xor carry_in; DEFINE carry_out := carry_in & value; MODULE main VAR bit0:counter_cell(TRUE); bit1:counter_cell(bit0.carry_out); bit2:counter_cell(bit1.carry_out);
29/31
bit0 bit1 bit2 carry_in value carry_out 1 1 1 1 1 MODULE counter_cell(carry_in) VAR value:boolean; ASSIGN init(value):=FALSE; next(value):= value xor carry_in; DEFINE carry_out := carry_in & value; MODULE main VAR bit0:counter_cell(TRUE); bit1:counter_cell(bit0.carry_out); bit2:counter_cell(bit1.carry_out);
29/31
bit0 bit1 bit2 carry_in value carry_out 1 1 1 1 1 MODULE counter_cell(carry_in) VAR value:boolean; ASSIGN init(value):=FALSE; next(value):= value xor carry_in; DEFINE carry_out := carry_in & value; MODULE main VAR bit0:counter_cell(TRUE); bit1:counter_cell(bit0.carry_out); bit2:counter_cell(bit1.carry_out);
29/31
bit0 bit1 bit2 carry_in value carry_out 1 1 1 1 1 1 MODULE counter_cell(carry_in) VAR value:boolean; ASSIGN init(value):=FALSE; next(value):= value xor carry_in; DEFINE carry_out := carry_in & value; MODULE main VAR bit0:counter_cell(TRUE); bit1:counter_cell(bit0.carry_out); bit2:counter_cell(bit1.carry_out);
29/31
bit0 bit1 bit2 carry_in value carry_out 1 1 1 1 1 1 MODULE counter_cell(carry_in) VAR value:boolean; ASSIGN init(value):=FALSE; next(value):= value xor carry_in; DEFINE carry_out := carry_in & value; MODULE main VAR bit0:counter_cell(TRUE); bit1:counter_cell(bit0.carry_out); bit2:counter_cell(bit1.carry_out);
29/31
bit0 bit1 bit2 carry_in value carry_out 1 1 1 1 1 1 1 MODULE counter_cell(carry_in) VAR value:boolean; ASSIGN init(value):=FALSE; next(value):= value xor carry_in; DEFINE carry_out := carry_in & value; MODULE main VAR bit0:counter_cell(TRUE); bit1:counter_cell(bit0.carry_out); bit2:counter_cell(bit1.carry_out);
29/31
bit0 bit1 bit2 carry_in value carry_out 1 1 1 1 1 1 1 MODULE counter_cell(carry_in) VAR value:boolean; ASSIGN init(value):=FALSE; next(value):= value xor carry_in; DEFINE carry_out := carry_in & value; MODULE main VAR bit0:counter_cell(TRUE); bit1:counter_cell(bit0.carry_out); bit2:counter_cell(bit1.carry_out);
29/31
bit0 bit1 bit2 carry_in value carry_out 1 1 1 1 1 1 1 MODULE counter_cell(carry_in) VAR value:boolean; ASSIGN init(value):=FALSE; next(value):= value xor carry_in; DEFINE carry_out := carry_in & value; MODULE main VAR bit0:counter_cell(TRUE); bit1:counter_cell(bit0.carry_out); bit2:counter_cell(bit1.carry_out);
29/31
bit0 bit1 bit2 carry_in value carry_out 1 1 1 1 1 1 1 MODULE counter_cell(carry_in) VAR value:boolean; ASSIGN init(value):=FALSE; next(value):= value xor carry_in; DEFINE carry_out := carry_in & value; MODULE main VAR bit0:counter_cell(TRUE); bit1:counter_cell(bit0.carry_out); bit2:counter_cell(bit1.carry_out);
29/31
bit0 bit1 bit2 carry_in value carry_out 1 1 1 1 1 1 1 1 1 1 1 1 1 1 MODULE counter_cell(carry_in) VAR value:boolean; ASSIGN init(value):=FALSE; next(value):= value xor carry_in; DEFINE carry_out := carry_in & value; MODULE main VAR bit0:counter_cell(TRUE); bit1:counter_cell(bit0.carry_out); bit2:counter_cell(bit1.carry_out);
29/31
bit0 bit1 bit2 carry_in value carry_out 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 MODULE counter_cell(carry_in) VAR value:boolean; ASSIGN init(value):=FALSE; next(value):= value xor carry_in; DEFINE carry_out := carry_in & value; MODULE main VAR bit0:counter_cell(TRUE); bit1:counter_cell(bit0.carry_out); bit2:counter_cell(bit1.carry_out);
29/31
bit0 bit1 bit2 carry_in value carry_out 1
30/31
bit0 bit1 bit2 carry_in value carry_out 1 1 1 1 1
30/31
bit0 bit1 bit2 carry_in value carry_out 1 1 1 1 1 1 1
30/31
bit0 bit1 bit2 carry_in value carry_out 1 1 1 1 1 1 1 1 1 1 1 1 1 1
30/31
bit0 bit1 bit2 carry_in value carry_out 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
30/31
bit0 bit1 bit2 carry_in value carry_out 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
30/31
bit0 bit1 bit2 carry_in value carry_out 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
30/31
bit0 bit1 bit2 carry_in value carry_out 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
30/31
bit0 bit1 bit2 carry_in value carry_out 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
(more about this later)
30/31
31/31
◮ Computation as a sequence of states ◮ Specify initial values for variables ◮ Specify next-state relation: how the variables change given the
◮ NuSMV models of simple systems ◮ Requirements G and F
32/31