Announcements
• Office hours Model Checking: – M 1:30pm-2:30pm An Introduction – W 5:30pm-6:30pm (after class) – and by appointment – ECOT 621 Meeting 2 • Moodle problems?
Fundamentals of Programming Languages CSCI 5535, Spring 2009
2
A Double Header Who are we again?
• Two lectures • We're going to find critical bugs in important – Model checking primer bits of software – Software model checking – using PL techniques ! – SLAM and BLAST (tools) • You’ll be enthusiastic about this • Some key players: – and thus want to learn the gritty details – Model checking Ed Clarke, Ken McMillan, Amir Pnueli – SLAM Tom Ball, Sriram Rajamani – BLAST Ranjit Jhala, Rupak Majumdar, Tom Henzinger
3 4
Take-Home Message Overarching Plan
• Model checking is the exhaustive Model Checking (today) exploration of the state space of a – Transition systems (i.e., models) system, typically to see if an error state – Temporal properties – Temporal logics: LTL and CTL is reachable . It produces concrete – Explicit-state model checking counterexamples . – Symbolic model checking • The state explosion problem refers to Counterexample Guided Abstraction Refinement the large number of states in the model. – Safety properties – Predicate abstraction “c2bp” • Temporal logic allows you to specify – Software model checking “bebop” properties with concepts like – Counterexample feasibility “newton” – Abstraction refinement weakest pre, thrm prv “eventually” and “always”. 5 6
1 Spoiler
• This stuff really works!
• Symbolic model checking is a massive Model Checking success in the model-checking field • SLAM took the PL world by storm There are complete courses in model checking – Spawned multiple copycat projects (see ECEN 5139, Prof. Somenzi). – Launched Microsoft’s Static Driver Verifier Model Checking by Edmund M. Clarke, Orna (released in the Windows DDK) Grumberg, and Doron A. Peled. Symbolic Model Checking by Ken McMillan. We will skim. 7
Keywords Verification vs. Falsification
Model checking is an automated technique • What is verification? Model checking verifies transition systems Model checking verifies temporal properties Model checking falsifies by generating counterexamples • What is falsification? A model checker is a program that checks if a (transition) system satisfies a (temporal) property
9 10
Verification vs. Falsification Temporal Properties
• An automated verification tool Temporal Property – can report that the system is verified (with a proof); A property with time-related operators such as – or that the system was not verified. “invariant ” or “ eventually ” Invariant( p) • When the system was not verified, it would be helpful to explain why. is true in a state if property p is true in every – Model checkers can output an error counterexample : a state on all execution paths starting at that state concrete execution scenario that demonstrates the error. G, AG, (“globally” or “box” or “forall”) • Can view a model checker as a falsification tool Eventually( p) – The main goal is to find bugs is true in a state if property p is true at some state • So what can we verify or falsify? on every execution path starting from that state F, AF, ♦ (“future” or “diamond” or “exists”) 11 12
2 Reachable States An Example Concurrent Program of the Example Program • A simple concurrent 10: while (true) { mutual exclusion program 11: wait(turn == 0); • Two processes execute // critical section t=0 t=1 Next: formalize asynchronously 12: work(); turn = 1; 10,20 10,20 this intuition … • There is a shared variable 13: } turn t=0 t=0 t=1 t=1 10,21 11,20 10,21 11,20 • Two processes use the || // concurrently with shared variable to ensure that they are not in the 20: while (true) { t=0 t=0 t=1 t=1 critical section at the 11,21 12,20 11,21 same time 21: wait(turn == 1); 10,22 • Can be viewed as a // critical section “fundamental” program: 22: work(); turn = 0; t=0 t=1 Each state is a valuation 12,21 any bigger concurrent one 23: } 11,22 of all the variables: would include this one turn and the two program 13 counters for two processes#1414
Analyzed System is a Transition System Example Properties of the Program
• Labeled transition system Also called a • “In all the reachable states (configurations) T = (S, I, R, L) Kripke Structure of the system, the two processes are never in the critical section at the same time ” – S = Set of states // standard FSM – I ⊆ S = Set of initial states // standard FSM –“pc1=12 ”, “ pc2=22 ” are atomic properties for being in the critical section – R ⊆ S × S = Transition relation // standard FSM – L: S → 2AP = Labeling function // this is new! • AP : Set of atomic propositions (e.g., “x=5”∈AP) – Atomic propositions capture basic properties •“Eventually the first process enters the – For software, atomic props depend on variable values critical section” – The labeling function labels each state with the set of propositions true in that state
15 16
For what? Example Properties of the Program Temporal Logics For expressing properties
• “In all the reachable states (configurations) There are four basic temporal operators: of the system, the two processes are never in • X p the critical section at the same time ” Next p , p holds in the next state –“pc1=12 ”, “ pc2=22 ” are atomic properties for being • G p in the critical section Globally p , p holds in every state, p is an invariant Invariant (¬¬¬(pc1=12 ∧∧∧ pc2=22 )) • F p Future p , p will hold in a future state, p holds eventually •“Eventually the first process enters the • p U q critical section” p Until q , assertion p will hold until q holds Eventually (pc1=12 ) • Precise meaning of these temporal operators are defined on execution paths 17 18
3 Execution Paths Paths and Predicates
• A path in a transition system is an infinite • We write sequence of states x p (s 0, s 1, s 2, ...), such that ∀i≥0. (si, s i+1) ∈ R • A path (s 0,s 1,s 2,...) is an execution path if s0 ∈ I “the path x makes the predicate p true” • Given a path x = (s 0, s 1, s 2, ...) – x is a path in a transition system th – xi denotes the i state: si i th – p is a temporal logic predicate – x denotes the i suffix: (si, s i+1, s i+2, ...) • In some temporal logics one can quantify paths starting from a state using path quantifiers • Example: – A : for all paths A x. x G(¬¬¬(pc1=12 ∧∧∧ pc2=22)) – E : there exists a path
19 20
Linear Time Logic (LTL) Linear Time Logic (LTL)
• LTL properties are constructed from atomic • LTL properties are constructed from atomic propositions in AP; logical operators ∧, ∨, ¬; propositions in AP; logical operators ∧, ∨, ¬; and temporal operators X, G, F, U. and temporal operators X, G, F, U. • The semantics of LTL is defined on paths: • The semantics of LTL is defined on paths: Given a path x: Given a path x: x p iff L(x 0, p) atomic prop x p iff L(x 0, p) atomic prop x X p iff x1 p next x X p iff x1 p next x F p iff x F p iff ∃i≥0. x i p future x G p iff x G p iff ∀i≥0. x i p globally x p U q iff x p U q iff ∃i≥0. x i q and ∀j