Definition
Model checking is an automatic verification method that decides whether a model of a system, usually one with finitely many states, satisfies a property. The model is a transition system: its states, its initial states and the allowed steps between states. The property is usually written in a temporal logic, a logic for statements about how states follow one another over time, as in “every request is eventually granted”. A model checker examines every execution of the model and confirms the property or returns a counterexample that violates it.
The idea
Concurrent and reactive systems fail in executions that tests rarely produce: one particular interleaving of two threads, or a message lost at one particular moment. Two threads of 10 steps each can interleave in orders, where is the product , and a test run sees one of them. Model checking replaces sampling with exhaustive search. If the model has finitely many states, an algorithm §14.1 can visit every reachable state §3.21 and, for properties about infinite executions, every reachable cycle. Edmund Clarke and Allen Emerson, and independently Jean-Pierre Queille and Joseph Sifakis, introduced the method in the early 1980s. Clarke, Emerson and Sifakis received the 2007 Turing Award for it.
The obstacle is state explosion §3.26. A global state is a combination of one local state for every component, so the number of global states is the product of the numbers of local states. Ten processes with 4 local states each have up to global states. Model checkers therefore apply reductions, which explore a smaller model that gives the same verdict. The catch is that “the same verdict” depends on the property. Exploring only one order of two steps is safe when the property cannot see the order and wrong when it can, so each reduction comes with a theorem that names the properties it preserves.
How it works
A model checker takes three inputs.
A Kripke structure, named after the logician Saul Kripke: a transition system in which every state is labeled with the atomic propositions true in it. Atomic propositions are the basic true-or-false facts the property may mention, such as “process 1 is in its critical section §9.4” or . For a concurrent program, one step of the whole system is a step of one component, so every interleaving is a path.
A property in temporal logic. LTL (linear temporal logic) speaks about one execution at a time. With atomic propositions and , it writes for “ holds in every state from now on”, for “ holds in some later state”, for “ holds in the next state” and for “ holds until does”. A system satisfies an LTL formula when every one of its executions does. CTL (computation tree logic) adds path quantifiers: for “on every path from here” and for “on some path from here”. The CTL formula says that from every reachable state some path still leads to a reset, a statement of possibility that LTL cannot express.
Fairness assumptions, which exclude unrealistic infinite executions. Weak fairness says that an action that stays enabled forever is eventually taken. Without it, the execution in which a scheduler runs process A forever and never process B, although B is ready to run, is a counterexample to “B eventually runs”.
The search depends on the property.
An invariant , the simplest safety property §1.11, holds when no reachable state violates . The checker searches the reachable states as described in the Reachability entry; a breadth-first search §14.18 returns a shortest path to a violating state as the counterexample.
A general LTL formula, including a liveness property §1.12 such as , “every request is eventually followed by a grant”. The checker builds a Büchi automaton for the negation of the formula: a machine that reads an infinite sequence of states and accepts it when its run passes through an accepting state infinitely often. This automaton accepts exactly the executions that violate the formula. The checker combines the automaton with the model and searches for a reachable cycle through an accepting state. The counterexample is a lasso: a finite path followed by a cycle that repeats forever, for example a request after which the system loops without ever granting it.
A CTL formula. The checker computes, from the innermost subformula outward, the set of states in which each subformula holds. The set for , for example, contains the states from which some path reaches ; it is computed by repeatedly adding predecessors until nothing changes.
Explicit-state checkers store each visited state. Symbolic checkers represent sets of states by formulas, such as binary decision diagrams (compact graphs that encode a true-or-false function of many bits), or pass the question to a satisfiability solver, as bounded model checking §3.29 does. A run ends with the property confirmed for the model, with a counterexample, or out of time or memory, which proves nothing.
The main reductions are these.
Cone of influence: delete every variable that cannot affect, directly or through other variables, the variables the property mentions.
Partial-order reduction §19.2.11: two actions are independent when, in every state where both are enabled, neither disables the other and both orders lead to the same state. At each state the checker explores only a subset of the enabled actions, called an ample set, and skips orders that differ only by swapping independent actions.
Symmetry reduction: when components are identical, states that differ only by a renumbering of the components are merged into one.
Bisimulation §19.2.10 minimization: states that carry the same labels and whose possible futures match step for step are merged.
Abstraction: many concrete states §3.5 are merged into one abstract state, for example by keeping only the sign of an integer. The abstract model has a step from one abstract state to another whenever some state merged into the first has a step to some state merged into the second.
Worked example
A dependence that a reduction must respect. Threads A and B each increment a shared variable , which starts at 0, in two steps. Step A1 reads into a private register of A, and step A2 writes that register plus 1 back to ; steps B1 and B2 do the same for B. Each thread’s two steps stay in order, so there are interleavings. In A1 A2 B1 B2 and in B1 B2 A1 A2, the second thread reads the value 1 and ends at 2. In the other four, for example A1 B1 A2 B2, both threads read 0, both write 1, and ends at 1: an update is lost. The property “when both threads have finished, ” is therefore violated. A1 and B1 are independent, since both only read , so a partial-order reduction may explore just one of their two orders. A2 and B1 are dependent, since one writes and the other reads it, so both of their orders must be explored. A reduction that wrongly treated every pair as independent and explored only A1 A2 B1 B2 would report that the property holds.
An order the property can see. Thread A sets from 0 to 1, and thread B sets from 0 to 1. The two actions are independent: both orders end in the state . For the property “finally and ” one order suffices. For , “ never becomes 1 before does”, the order is everything. A then B passes through and satisfies the property, while B then A passes through and violates it. Both actions change an atomic proposition of this property, so partial-order reduction may not drop either order.
A symmetry the property must share. Three identical processes are each idle, waiting or critical, so the system has global states. Merging states that differ only by which process is which leaves one state for each way of splitting the 3 processes among the 3 conditions: states. The property “at most one process is critical” does not depend on which process is which, so the 10-state model gives the right verdict for it. The property “process 1 is never critical” does depend on it: the merged state “one process critical” does not say which one, so the reduced model cannot decide this property.
Stated precisely
A Kripke structure is . is the set of states, the set of initial states, the transition relation, in which every state has at least one successor, and the set of atomic propositions true in state . A path is an infinite sequence with and for every . For an LTL formula , ( satisfies ) means that every path of satisfies .
A reduction replaces by a smaller structure . It preserves when holds exactly when holds. It is sound in one direction when implies . The standard results are these.
Cone of influence preserves every property that mentions only kept variables, because a deleted variable never feeds a kept one.
Bisimulation minimization preserves every formula of CTL*, the logic that contains both LTL and CTL.
Symmetry reduction under a group of renumberings of the components preserves every CTL* formula whose atomic propositions are unchanged by every renumbering in .
Partial-order reduction preserves every LTL formula that does not use , provided the set of actions explored in each state meets four conditions. (C0) It is empty only when no action is enabled in . (C1) On every path of the full model that starts in , no action that depends on an action in runs before some action of has run. (C2) If leaves out some enabled action, every action in it is invisible: it changes no atomic proposition of the formula. (C3) No cycle of the reduced model contains a state in which some action is enabled but never chosen for the ample set of any state on the cycle. Formulas with are excluded because the reduced model may take fewer invisible steps between two visible ones than the full model, and only can tell such executions apart.
Abstraction as described above, with an abstract step wherever some merged concrete states have a step, is sound in one direction for universal properties: every LTL formula, and every CTL formula that uses only the quantifier and applies negation only to atomic propositions. The concrete states merged into one abstract state must agree on every atomic proposition of the formula. An abstract counterexample may be spurious, meaning that no concrete execution follows it; counterexample-guided abstraction refinement §15.13 checks it against and makes the abstraction finer when it is spurious.
Limits and common mistakes
A verdict is about the model. Whether the code behaves like the model is a separate claim, treated in the Refinement §3.32 entry. A model that leaves out a failure, such as a lost message, cannot find the bugs that failure causes.
A property can hold vacuously. holds in a model in which no request is ever made. Check that the condition that triggers the property is reachable.
Fairness assumptions cut both ways. Too strong, they hide real starvation §9.18, in which a process waits forever; too weak, they produce counterexamples in which the scheduler behaves in a way no real scheduler does.
A one-way abstraction transfers only a pass, and only for universal properties. “Some path can still reach a reset” is not preserved, because the abstract model has paths that no concrete execution follows.
Unbounded data, such as integers, queues and heaps, gives infinitely many states. A checker then works on a bounded instance, such as 3 processes and a queue of length 2, or on an abstraction, and the verdict covers only that instance or abstraction.
Running out of time or memory is not a pass. Some tools offer approximate search modes that may skip states to save memory; a clean result in such a mode is a partial search, not a proof.
Reductions can be combined only if each one still meets its conditions in the combined model, and the combined result covers only properties that every reduction involved preserves.
Questions answered
Which reductions preserve the property being checked?
A reduction preserves the property being checked only when a theorem covers both that reduction and that class of property, and the theorem’s conditions hold for the property’s own atomic propositions, the basic facts it mentions. A smaller graph, or agreement with the full model on a few examples, does not show that a reduction is correct. The standard cases are these.
Cone of influence, which deletes variables that cannot affect the property, preserves any property over the variables it keeps.
Bisimulation minimization, which merges states with identical futures, preserves every formula of LTL (linear temporal logic), CTL (computation tree logic) and CTL*, the logic that contains both.
Symmetry reduction preserves a formula only if the formula is unchanged by renumbering the identical components: “at most one process is critical” qualifies, “process 1 is never critical” does not.
Partial-order reduction, which explores only some orders of independent actions, preserves LTL formulas without the next-state operator, provided its conditions hold. Dependent actions, such as a write and a read of the same variable, must be explored in both orders, and actions that change a proposition of the formula must not be reordered away. A property about which event happens first is lost if such visible actions are treated as freely reorderable.
An abstraction that merges states preserves in one direction only. If the abstract model satisfies a universal property, such as an invariant or any LTL formula, the real model does too. An abstract counterexample must be checked against the real model, since it may be spurious.
A reduction valid for a property about final values can therefore be invalid for a property about order, about eventual progress or about one named component.
Related entries: Reachability (§3.21), State explosion (§3.26), Refinement (§3.32), Bounded model checking (§3.29), Liveness property (§1.12), Counterexample-guided abstraction refinement (CEGAR) (§15.13). Further reading: [226, 227].