02d LTL ModelChecking-print
02d LTL ModelChecking-print
02d LTL ModelChecking-print
KIT – University of the State of Baden-Württemberg and National Large-scale Research Center of the Helmholtz Association
Model Checking with S PIN
model correctness
name.pml properties
executable
-a verifier C
SPIN verifier
pan.c compiler
pan
e r
th
ei
or
failing
random/ interactive / guided run “errors: 0”
simulation name.pml.trail
Prof. Dr. Bernhard Beckert · Dr. Vladimir Klebanov – Applications of Formal Verification SS 2010 2/25
Stating Correctness Properties
model correctness
name.pml properties
today:
model checking of properties formulated in temporal logic
Remark:
in this course, “temporal logic” is synonymous to “linear temporal logic” (LTL)
Prof. Dr. Bernhard Beckert · Dr. Vladimir Klebanov – Applications of Formal Verification SS 2010 4/25
Beyond Assertions
Assertions only talk about the state ‘at their own location’ in the code.
Example: mutual exclusion expressed by adding assertion into each
critical section.
critical++;
assert( critical <= 1 );
critical--;
Drawbacks:
no separation of concerns (model vs. correctness property)
changing assertions is error prone (easily out of synch)
easy to forget assertions:
correctness property might be violated at unexpected locations
many interesting properties not expressible via assertions
Prof. Dr. Bernhard Beckert · Dr. Vladimir Klebanov – Applications of Formal Verification SS 2010 5/25
Temporal Correctness Properties
properties more conveniently expressed as global properties,
rather than assertions:
Mutual Exclusion
“critical <= 1 holds throughout the run”
Array Index within Bounds (given array a of length len)
“0 <= i <= len-1 holds throughout the run”
Prof. Dr. Bernhard Beckert · Dr. Vladimir Klebanov – Applications of Formal Verification SS 2010 6/25
Boolean Temporal Logic
Prof. Dr. Bernhard Beckert · Dr. Vladimir Klebanov – Applications of Formal Verification SS 2010 7/25
Boolean Temporal Logic over
P ROMELA
Prof. Dr. Bernhard Beckert · Dr. Vladimir Klebanov – Applications of Formal Verification SS 2010 8/25
Semantics of Boolean Temporal
Logic
A run σ through a P ROMELA model M is a chain of states
L 0 , I0 L1 , I1 L2 , I2 L3 , I3 L4 , I4 ···
Prof. Dr. Bernhard Beckert · Dr. Vladimir Klebanov – Applications of Formal Verification SS 2010 10/25
Safety Properties
special case:
[ ]¬ψ states that something bad, ψ, never happens
Prof. Dr. Bernhard Beckert · Dr. Vladimir Klebanov – Applications of Formal Verification SS 2010 11/25
Applying Temporal Logic to Critical
Section Problem
We want to verify ‘[](critical<=1)’ as correctness property of:
Prof. Dr. Bernhard Beckert · Dr. Vladimir Klebanov – Applications of Formal Verification SS 2010 12/25
Model Checking a Safety Property
with J S PIN
Prof. Dr. Bernhard Beckert · Dr. Vladimir Klebanov – Applications of Formal Verification SS 2010 13/25
Never Claims
Prof. Dr. Bernhard Beckert · Dr. Vladimir Klebanov – Applications of Formal Verification SS 2010 14/25
Model Checking a Safety Property
with S PIN directly
Prof. Dr. Bernhard Beckert · Dr. Vladimir Klebanov – Applications of Formal Verification SS 2010 15/25
Temporal MC Without Ghost
Variables
We want to verify mutual exclusion without using ghost variables
Prof. Dr. Bernhard Beckert · Dr. Vladimir Klebanov – Applications of Formal Verification SS 2010 16/25
Liveness Properties
example: ‘<>csp’
(with csp a variable only true in the critical section of P)
Prof. Dr. Bernhard Beckert · Dr. Vladimir Klebanov – Applications of Formal Verification SS 2010 17/25
Applying Temporal Logic to
Starvation Problem
We want to verify ‘<>csp’ as correctness property of:
Prof. Dr. Bernhard Beckert · Dr. Vladimir Klebanov – Applications of Formal Verification SS 2010 18/25
Model Checking a Liveness Property
with J S PIN
Prof. Dr. Bernhard Beckert · Dr. Vladimir Klebanov – Applications of Formal Verification SS 2010 19/25
Verification Fails
Verification fails.
Why?
Prof. Dr. Bernhard Beckert · Dr. Vladimir Klebanov – Applications of Formal Verification SS 2010 20/25
Fairness
Does the following P ROMELA model necessarily terminate?
byte n = 0;
bool flag = false;
Prof. Dr. Bernhard Beckert · Dr. Vladimir Klebanov – Applications of Formal Verification SS 2010 21/25
Model Checking Liveness with Weak
Fairness!
Prof. Dr. Bernhard Beckert · Dr. Vladimir Klebanov – Applications of Formal Verification SS 2010 22/25
Model Checking Liveness with S PIN
directly
Prof. Dr. Bernhard Beckert · Dr. Vladimir Klebanov – Applications of Formal Verification SS 2010 23/25
Verification Fails
Prof. Dr. Bernhard Beckert · Dr. Vladimir Klebanov – Applications of Formal Verification SS 2010 24/25
Literature for this Lecture
Ben-Ari Chapter 5
Prof. Dr. Bernhard Beckert · Dr. Vladimir Klebanov – Applications of Formal Verification SS 2010 25/25