Model Checking in Verification
Model Checking in Verification
Model Checking
Debdeep Mukhopadhyay
IIT Madras
2. A specification language
for describing the properties to be verified
3. A verification method
for establishing if the description of the
system satisfies the specification
Proof-based verification
The system description is a set of formula
in a suitable logic
The specification is another formula
The verification method is finding a proof
that
means deduction
Model-based verification
The system is represented by a model M
for an appropriate logic
The specification is again represented by
a formula
The verification method consist of
computing whether a model M satisfies
M satisfies : M
Degree of automation
From fully automated to fully manual
Model checking
Model checking is an automatic, modelbased, property-verification approach
It is intended to be used for concurrent
and reactive systems
The purpose of a reactive system is not
necessarily to obtain a final result, but to
maintain some interaction with its
environment
yes
Model
Checker
no
Error Trace
Branching Time
Every moment has
several successors
Infinite tree
Computation Tree
Logic (CTL)
Temporal operators
Globally:
p p
p p p p p p p...
G p...
Temporal operators...
Future:
p p
F p...
Until:
p p
p U q at t iff
p p
p p p p p q
p U q...
Next-time:
X p at t iff p at t+1
Examples
Liveness: if input, then eventually output
G (input F output)
atomic props
Model
A Model is a transition system.
A transition system M=(S,,L) is a set of
states S endowed with a transition relation
(a binary relation on S), such that every
state s from S, has some successor state
s which is also from S. Thus ss
Also associated with each state is a set of
atomic propositions which are true at that
state, described by a labeling function, L
Example
S = {s0, s1, s2}
s0
transitions = s0 s1 ,
s1 s1 , s2 s1 , s2
s0 , s0 s2
p,q
q
s1
q,r
s2
L(s0) = {p,q}
L(s1) = {q}
L(s2) = {q,r}
Example
N1,N2
turn=0
PATH
T1,N2
turn=1
C1,N2
turn=1
N1,T2
turn=2
T1,T2
turn=1
T1,T2
turn=2
C1,T2
turn=1
N1,C2
turn=2
T1,C2
turn=2
p p
p p p p p q
p U q...
p p
p p
p p p p p q
(p U q)
Explanation
p q := i[( |= q ) (j < i, |= p )]
i
( p q ) := i[( |= q ) (j < i, |= p )]
i
Operator precedence
Unary operators including negation have strongest
precedence
p U q is parsed as (p) U q rather than (p U q)
Temporal binary operators have stronger precedence
than non-temporal binary operators
p q U r is parsed as: p (q U r)
The precedence over propositional logic is as usual
First do the AND
then the ORs and XORs
finally the IMPLIES and EQUIVALENCEs.
Example
The parse tree of Fp Gq p W r
according to precedence rules
More of Until
What is not pUq?
We have seen that.
Here is another expression for that.
( p q ) = q (p q ) Gq
Intuitive Explanation
( p q ) = (q (p q )) Fq
Fq is straight-forward
Let q occur => Fq
t1
t2
q=1
p=0
t3
q=1
q=0
Let t3 be the first time interval when q is true.
Let us contradict the equation, that is pUq does not hold.
Then, there is a time instant t=t2, when p=0. Obviously q=0, as t2<t3
But by RHS, if
(q (p q ))
But, t1<t3 and hence we have a violation that t3 is the first time when q=1.
Thus, there is a contradiction and pUq does hold. The equivalence follows.
Release
Release R is dual of U; that is:
p R q ( p U q)
p must remain true up to and including the
moment when q becomes true (if there is
one); p releases q
Thus, pRq= Gq V [q U (p q)]
= [F q (q U (p q)]
=[p U q]
Weak Until
W : Weak Until is related to the Until
with the difference that it does not require
that is eventually hold
Essentially W is a short form for
writing
U G
Example
1. M, s0 X q
s0
p,q
s1
s2
q,r
3. M, s1 G q
q
s0
s2
q,r
p,q
s1
s1
s2
q,r
4. M, s0 p U q
s1
p,q
s0
s2
q,r
2. M, s0 G (p r)
Practical patterns(contd.)
An upwards travelling lift at the 2nd floor
does not change its direction when it has
passengers wishing to go to the 5th floor:
G(floor2 directionup ButtonPressed5
(directionup U floor5)
LTL weakness
The features which assert the existence of a
path are not (directly) expressible in LTL
This problem can be solved by: checking
whether all paths satisfy the negation of the
required property
A positive answer to this is a negative answer to
our original question and vice versa.
But properties which mix universal and
existential path quantifiers cannot in general be
expressed in LTL
Expected Properties
Safety: Only one process is in its critical section
at any time.
Liveness: Whenever any process requests to
enter its critical section, it will eventually be
permitted to do so.
Non-blocking: A process can always request to
enter its critical section.
No strict sequencing: Processes need not
enter their critical section in strict sequence.
Modeling mutex
Consider each process to be either:
in its non-critical state n
trying to enter the critical section t
or in critical section c
2 process mutex
The processes are asynchronous interleaved
one of the processes makes a transition while the
other remains in its current state
s0
n1 n2
t1 n2
s5
s1
n1 t2
s3
s2
t1 t2
c1 n2
s4
c1 t2
n1 c2
t1 c2
s7
s6
No Strict Sequencing
c1 and c2 need not alternate
Desired scenario:
Process 1 acquires critical section (c1)
Process 1 releases the critical section (c1)
Process 2 does not enter the critical section
(c2)
Process 1 regains access to the critical
section (c1)
No Strict Sequencing
There exists at least one path with no strict sequencing:
c1
c1
c1
c1
c2
c2 c2
c1
Time
Or, in all paths there is strict sequencing:
Anytime we have
c1 state, the condn
persists, or it ends
with a non-c1 state
and in that case there
is no further c1
unless and until
we obtain a c2 state.
c1
c1
c1
c1
c1
c1 c1
c1
Time
c1 c1
c2
Live-ness property is
violated. Follow the path
marked in red. Processor 1
tries to enter the critical
section but fails.
s0
n1 n2
t1 n2
s5
s1
n1 t2
s3
s2
t1 t2
c1 n2
s4
c1 t2
n1 c2
t1 c2
s7
s6
t1 n2
s0
n1 n2
s5
s1
n1 t2
s3
s2
t1 t2
c1 n2
s4
c1 t2
n1 c2
t1 c2
s7
s6
No-strict sequencing
Path marked in red
shows that all paths are
sequencing is false.
Thus, no strict sequencing
is maintained.
s0
n1 n2
t1 n2
s5
s1
n1 t2
s3
s2
t1 t2
c1 n2
s4
c1 t2
n1 c2
t1 c2
s7
s6
Solution
s0
n1 n2
t1 n2
s2
c1 n2
s4
All the four
properties
are
satisfied
c1 t2
s5
s1
s3
s3
t1 t2
t1 t2
n1 t2
n1 c2
t1 c2
s7
s6