Maps to: Stanford CS 257 Introduction to Automated Reasoning (Winter 2026), Lecture 9 · Tue 02/03/2026 · Applications: model checking (Caroline Trippel). Homework 3 covers it. Reading: none listed on the course page. Basis: The Stanford slides are on Canvas, and the public Iowa decks have no model-checking lecture. These notes are therefore written from the original papers:
- bounded model checking: Biere, Cimatti, Clarke and Zhu (1999);
- k-induction: Sheeran, Singh and Stålmarck (2000), Eén and Sörensson (2003);
- interpolation: McMillan (2003);
- IC3 / PDR: Bradley (2011), Eén, Mishchenko and Brayton (2011);
- the textbook view: Clarke, Grumberg and Peled, Model Checking; Biere’s chapter in the Handbook of Satisfiability.
These notes add:
- a small model checker,
mc.py, built on Lecture 5’s CDCL solver: explicit-state search, BMC, k-induction, IC3 and interpolation;- ten case studies (counters, a shift register, Peterson’s protocol and a broken one, a priority arbiter with a deep bug);
- an independent check of every answer: counterexamples by simulation, invariants by three SAT queries;
- experiments that show where each engine wins and where it fails.
The experiments and their code were designed for these notes and do not reflect what was said in class. Code:
code/lecture09/(5 scripts + 1 module; Python standard library only; 5 to 30 seconds each) Reading time: 3–4 hours including running the code
0. How to read this lecture
0.1 Learning goals
After this lecture you should be able to:
- Model a hardware design or a protocol as a transition system (initial states, transition relation) and state a safety property.
- Explain explicit-state search, its shortest counterexamples, and the state explosion.
- Write down the bounded model checking formula , explain why its counterexamples are shortest, and say why BMC alone proves nothing.
- Distinguish an invariant from an inductive invariant; read a counterexample to induction.
- Explain k-induction, why it needs the simple-path constraint to be complete, and why can be exponential.
- Describe IC3/PDR: frames, proof obligations, relative induction, generalization, propagation, and its termination test.
- Compute a Craig interpolant from a resolution proof, and explain interpolation-based model checking.
- Check a model checker’s answers independently: traces by simulation, invariants by three SAT queries.
0.2 Prerequisites and scope
| Assumed | Introduced here | Developed later |
|---|---|---|
| propositional logic, Tseitin (Lectures 1–2) | transition systems, safety, invariants | — |
| CDCL, resolution proofs, DRUP (Lecture 5) | BMC, k-induction, IC3, interpolation | — |
| induction as a proof principle | inductive invariants, CTIs, strengthening | invariants of programs (Lecture 14) |
| — | — | word-level model checking with SMT (Lectures 10–16) |
Scope: safety properties (“nothing bad ever happens”) of finite-state systems with Boolean state. Liveness (“something good eventually happens”), temporal logics (LTL, CTL) and BDD-based symbolic model checking appear only in §7 and §11 as pointers.
0.3 Map
§1 systems that run forever: transition systems, runs, safety ← code 01
§2 explicit-state search and the state explosion ← code 01
§3 bounded model checking: unrolling into SAT ← code 02
§4 induction, k-induction, the simple-path constraint, strengthening ← code 01, 03
§5 IC3 / PDR ← code 04
§6 Craig interpolation and interpolation-based model checking ← code 05
§7 model checking in practice ← code 05
§8 summary §9 common pitfalls §10 exercises §11 further reading §12 next lecture
0.4 Notation
| Symbol | Meaning |
|---|---|
| , | the current state and the next state (vectors of Boolean latches) |
| the initial states | |
| the transition relation (: the inputs of the step); often written | |
| the safety property; a state with is bad | |
| , __ | the copy of the state (of latch ) at time |
| the set of states reachable from | |
| IC3’s frames (sets of clauses) | |
| , , | the two halves of an unsatisfiable formula, and a Craig interpolant |
0.5 The code of this lecture
One module, mc.py, built on Lecture 5’s cdcl.py and Lecture 1’s formulas. It contains:
- building blocks: formula constructors that fold constants, and bit-vectors as lists of formulas;
TransitionSystem: latches, inputs, initial values, next-state functions and a property, compiled into one Python function for fast simulation;explicit_reach: breadth-first search, withall_statesandcan_reach_badfor brute-force analysis of small systems;Encoder: Tseitin’s transformation (Lecture 2) done incrementally into one clause set, plus a SAT call through CDCL;- the engines
bmc,recurrence_diameter,k_induction,ic3anditp(withcraig_interpolant); - the checkers
check_traceandcheck_invariant; - the case studies
counter,even_counter,shift_parity,peterson,naive_mutexandarbiter.
Every engine counts its work in SAT calls, depths or conflicts, never in seconds. Results are therefore the same on every machine.
1. Systems that run forever
1.1 Intuition
Every question so far was about one formula. A chip, a cache-coherence protocol or a traffic-light controller is different: it runs. It is in some state, reads its inputs, moves to a next state, and does so forever. We want to know whether it can ever get into a state it must never be in:
- two processes in the critical section;
- two clients granted the bus at once;
- a counter overflowing.
Model checking answers this kind of question automatically. Clarke and Emerson, and Queille and Sifakis, introduced it in the early 1980s, and Clarke, Emerson and Sifakis received the 2007 Turing Award for it. This lecture is about the SAT-based form that dominates hardware verification today.
1.2 Transition systems
A hardware design has latches (state bits, also called registers or flip-flops) and inputs. At every clock tick each latch takes a new value, computed by a Boolean next-state function of the current latches and inputs. In mc.py:
TransitionSystem(name, latches, inputs, init, next_state, prop)
# init : dict latch -> initial value (latches left out start with any value)
# next_state : dict latch -> Formula over latches and inputs
# prop : Formula over latches -- the safety property P
Logically, the system is two formulas:
A run is a sequence with and for every . A state is reachable if some run passes through it.
A safety property is a formula over the state. is an invariant of the system if every reachable state satisfies it, . A state violating is bad. Model checking asks whether some bad state is reachable.
Why safety properties are special. If a safety property fails, a finite witness shows it: a run from an initial state to a bad state. Liveness properties (“every request is eventually granted”) fail only on infinite runs, which need lasso-shaped witnesses. Safety is the core case, and liveness can be reduced to it (Biere, Artho and Schuppan 2002), so this lecture treats safety only.
The 3-bit counter (script 01, Part 1) counts , and its property is . mc.py builds its next-state functions with an incrementer and a multiplexer, folding constants:
c0' = ¬(c0 ∧ ¬c1 ∧ c2) ∧ ¬c0
c1' = ¬(c0 ∧ ¬c1 ∧ c2) ∧ ¬(c1 ⇔ c0)
c2' = ¬(c0 ∧ ¬c1 ∧ c2) ∧ ¬(c2 ⇔ c1 ∧ c0)
property P: ¬(c0 ∧ c1 ∧ c2)
means "", where the counter wraps to 0. Its whole state graph:
| state | successor | reachable | P |
|---|---|---|---|
| c=0 … c=4 | c+1 | yes | ok |
| c=5 | c=0 | yes | ok |
| c=6 | c=7 | no | ok |
| c=7 | c=0 | no | BAD |
The edge exists in like any other edge. It is simply outside the reachable part. Telling reachable apart from merely existing is the whole difficulty of this lecture.
1.3 Where nondeterminism comes from
The counter is deterministic. Real systems are not, and inputs model every source of choice:
- the environment: the requests of an arbiter’s clients may arrive in any pattern;
- the scheduler: in a concurrent protocol, the input picks which process takes the next step. Every interleaving is then a run.
Peterson’s protocol, for example, is two processes, each with a 2-bit program counter (idle, trying, waiting, critical), plus two flags and a turn bit: 7 latches in all. Process , with other process :
idle: flag_i := 1 -> trying
trying: turn := j -> waiting
waiting: if ¬flag_j ∨ turn = i -> critical (else keep waiting)
critical: flag_i := 0 -> idle
property: not (pc_0 = critical ∧ pc_1 = critical)
The broken “check-then-set” protocol waits for before raising its own flag.
2. Explicit-state search and the state explosion
2.1 Breadth-first search
The obvious algorithm: start from the initial states, repeatedly compute the successors of the newest states (for every input combination), and stop at the first bad state or when no new state appears. explicit_reach does this with a hash set of visited states.
Breadth-first order gives two things for free:
- the counterexample is a shortest one;
- the number of BFS layers minus one is the system’s diameter: the largest distance from the initial states to a reachable state.
Script 01, Part 2:
| protocol | latches | states | reachable | diameter | result | counterexample |
|---|---|---|---|---|---|---|
| Peterson | 7 | 128 | 20 | 6 | SAFE | – |
| check-then-set | 6 | 64 | 16 | – | UNSAFE | 6 steps |
The broken protocol’s counterexample is the classic interleaving bug:
step state scheduler
0 P0:idle P1:idle flags=00 s=0
1 P0:trying P1:idle flags=00 s=0 P0 sees flag1 = 0
2 P0:waiting P1:idle flags=00 s=1
3 P0:waiting P1:trying flags=00 s=1 P1 sees flag0 = 0 too
4 P0:waiting P1:waiting flags=00 s=0
5 P0:critical P1:waiting flags=10 s=1
6 P0:critical P1:critical flags=11 BAD
check_trace replays it by simulation and confirms that it is a real run. Every counterexample in this lecture is checked that way.
2.2 The state explosion
Explicit search does work proportional to the number of reachable states, which is exponential in the number of latches. Script 01, Part 3 uses a shift register of bits with an input and a bit that tracks the parity of the register (, property ). Every register content is reachable:
| n | reachable states | explicit search |
|---|---|---|
| 12 | 4,096 | 0.01 s |
| 16 | 65,536 | 0.17 s |
| 18 | 262,144 | 0.72 s |
Each two more bits multiply the work by four, and ten more bits by a thousand. A processor has hundreds of thousands of latches.
History. Explicit-state tools such as SPIN and Murφ fight the explosion with partial-order reduction, symmetry reduction and hashing tricks, and they remain the tools of choice for protocols. In 1990 Burch, Clarke, McMillan, Dill and Hwang made model checking symbolic: they represented sets of states as formulas (binary decision diagrams, BDDs) and reached ” states and beyond”. BDDs themselves blow up on many designs. Since Biere et al. (1999), SAT solvers have been the engine of choice, and they are the subject of the rest of this lecture.
The same parity property, checked by one SAT query (§4: is unsatisfiable?):
| n | reachable states | variables | clauses | conflicts | time |
|---|---|---|---|---|---|
| 16 | 119 | 340 | 440 | 0.04 s | |
| 64 | 455 | 1,300 | 2,579 | 0.34 s | |
| 256 | 1,799 | 5,140 | 22,439 | 4.10 s |
The query grows by about 20 clauses per bit, whatever the number of states. That is the promise of SAT-based model checking. The catch, explored in §4, is that this property happens to be inductive.
Run it:
python3 01_transition_systems.py(about 10 s). It prints the counter’s state graph, the protocols’ search results and trace, the state explosion table withfigures/01_state_explosion.png, and Part 4’s brute-force analysis of invariants (§4.1).

3. Bounded model checking
3.1 The idea
Biere, Cimatti, Clarke and Zhu (1999) asked the SAT solver a bounded question: is a bad state reachable in exactly steps? A run of length is copies of the state variables, , linked by copies of :
The models of are exactly the runs of length that end in a bad state. Ask for :
- the first satisfiable contains a counterexample, and it is a shortest one, because every shorter depth was unsatisfiable;
- the formula grows linearly in : one more copy of per step.
In mc.py the copy of latch at time is the variable x__k. Script 02 prints for the counter with property :
I(s_0): ¬c0__0 ∧ ¬c1__0 ∧ ¬c2__0
T(s_0, s_1): c0__1 ⇔ ¬(c0__0 ∧ ¬c1__0 ∧ c2__0) ∧ ¬c0__0
c1__1 ⇔ ...
T(s_1, s_2): c0__2 ⇔ ¬(c0__1 ∧ ¬c1__1 ∧ c2__1) ∧ ¬c0__1
...
¬P(s_2): c0__2 ∧ ¬c1__2 ∧ c2__2
| k | variables | clauses | BMC_k |
|---|---|---|---|
| 0 | 5 | 10 | UNSAT |
| 1 | 19 | 51 | UNSAT |
| 2 | 33 | 92 | UNSAT |
| 4 | 61 | 174 | UNSAT |
| 5 | 75 | 215 | SAT: |
The clause set grows by 41 clauses per step.
3.2 Why it is done this way
- Why Tseitin and not a direct CNF? is a circuit, and copies of it share nothing. Distributing it into CNF would blow up exponentially (Lecture 2). Tseitin’s names keep each copy linear.
- Why an incremental encoder? Each depth adds one copy of to the previous formula.
Encoderkeeps one growing clause set and asserts only in the query for depth . The Tseitin definitions of earlier stay in the set, which is harmless: a definition never restricts the original variables (Lecture 2, §4). Real tools go further and keep one incremental SAT solver that remembers its learned clauses across depths (Eén and Sörensson 2003). Our CDCL solver has no such interface, so each depth is a fresh solver run. - Why exactly depth , not “within ”? Both are used. “Exactly ” with increasing finds shortest counterexamples, and it is what
bmcdoes.
3.3 Deep bugs
The arbiter of script 02 serves three clients with fixed priorities, client 0 highest. A starvation timer of bits counts the cycles in which client 2 requests without being served. When the timer is full, an urgent grant goes to client 2 and must suppress all others. The buggy version forgets to suppress client 0, and the property “at most one grant” fails only after the timer fills up, at depth :
| timer bits | BMC depth | explicit depth | variables | clauses | conflicts (all depths) | time |
|---|---|---|---|---|---|---|
| 2 | 4 | 4 | 126 | 317 | 13 | 0.00 s |
| 4 | 16 | 16 | 668 | 1,783 | 59 | 0.03 s |
| 6 | 64 | 64 | 3,406 | 9,369 | 249 | 1.12 s |
| 7 | 128 | 128 | 7,567 | 21,018 | 504 | 5.31 s |
The trace for explains the bug:
step state requests
0 grants=000 timer=0 r0=0 r1=1 r2=1
1 grants=010 timer=1 r0=0 r1=1 r2=1 client 1 wins, client 2 waits
2 grants=010 timer=2 r0=0 r1=1 r2=1
3 grants=010 timer=3 r0=1 r1=1 r2=1 timer full: urgent grant to 2 ...
4 grants=101 timer=0 ... and the normal grant to 0: BAD
BMC’s counterexamples are concrete, short and easy to read, which makes BMC the industrial bug-hunting workhorse. Its weakness is depth: the counter of script 02 that must count to 200 needs 200 copies of the design (21,430 clauses).
3.4 What BMC cannot do
On a correct design every is unsatisfiable, and BMC says only “no bug up to depth ”. On Peterson’s protocol (script 02, Part 3):
| k | clauses | conflicts | BMC_k |
|---|---|---|---|
| 4 | 685 | 5 | UNSAT |
| 12 | 2,021 | 382 | UNSAT |
| 20 | 3,357 | 961 | UNSAT |
The formulas grow linearly, but each one is harder to refute: more interleavings of the two processes.
Completeness thresholds. If BMC passes the diameter , every reachable state has been covered (each is reachable within steps), and the property is proved. Peterson’s diameter is only 6, but computing a diameter required the explicit search we wanted to avoid. The recurrence diameter is the longest loop-free path from an initial state. It is also a valid threshold, since every reachable state is reachable along a loop-free path, and it is computable by SAT: is satisfiable exactly up to it.
| system | reachable | diameter | recurrence diameter |
|---|---|---|---|
| counter mod 6, | 6 | 5 | 5 |
| even counter, 4 bits | 8 | 7 | 7 |
| Peterson | 20 | 6 | 17 |
| arbiter (correct) | 18 | 7 | 17 |
The arbiter’s 18 reachable states all lie on one loop-free path. In real designs loop-free paths are astronomically long, so BMC finds bugs and other methods prove their absence.
Run it:
python3 02_bounded_model_checking.py(about 30 s): the unrolling, the arbiter family, other bugs, Peterson and the thresholds, withfigures/02_bmc_cost.png.

4. Induction and k-induction
4.1 Invariants and inductive invariants
To prove for runs of any length, use induction on the length of the run:
- base: , so every initial state is good;
- step: , so every good state has only good successors.
Each is one SAT query: and must be unsatisfiable. If both are, is an inductive invariant, and the proof is done regardless of the number of states. That is what proved the 256-bit parity register in §2.2.
Usually the step fails. Its model is a counterexample to induction (CTI): a good state with a bad successor. Script 01, Part 4 analyses small systems by brute force over all their states:
| system | states | P inductive? | |||
|---|---|---|---|---|---|
| counter mod 6, | 8 | 7 | 6 | 6 | no |
| even counter, 4 bits | 16 | 15 | 8 | 8 | no |
| saturating counter with enable | 16 | 15 | 6 | 6 | no |
| arbiter (correct) | 64 | 32 | 18 | 32 | yes |
| Peterson | 128 | 120 | 20 | 46 | no |
Here is the set of states from which no bad state can be reached. The three sets are nested:
- is an invariant iff .
- and are both inductive (closed under transitions), and so is any union of with a closed subset of .
- itself is inductive only when no unreachable good state steps into a bad one. That happens only for the arbiter, whose grants are recomputed from scratch every cycle.
The CTIs found by brute force are all unreachable:
counter mod 6 c=6 -> c=7
even counter x=15 -> x=1
saturating counter c=14 [en=1] -> c=15
Peterson P0:waiting P1:critical flags=00 turn=0 [s=0] -> both critical
The Peterson CTI has both flags down although neither process is idle, which no run can produce. Induction looks one step back from the bad state and cannot know that.
Proving means finding an inductive invariant between and , without enumerating states. The rest of the lecture gives three ways.
4.2 k-induction
Sheeran, Singh and Stålmarck (2000): if one step of history is not enough, assume .
If and are all unsatisfiable, holds:
- by the base cases, every run of length below is good;
- every longer run ends with good states in a row (by induction), which the step case says are followed by a good state.
is just , so k-induction also finds shortest counterexamples.
How large must be? One more than the longest loop-free chain of good states leading into a bad state. Every state on such a chain is unreachable, otherwise the bad state would be reachable. Script 03:
| system | k | step-case clauses | conflicts | time |
|---|---|---|---|---|
| counter mod 6 | 2 | 160 | 3 | 0.00 s |
| even counter, 4 bits | 8 | 1,274 | 9 | 0.01 s |
| saturating counter with enable | 10 | 2,730 | 456 | 0.16 s |
| shift register, 8 bits | 1 | 180 | 142 | 0.01 s |
| arbiter | 1 | 148 | 4 | 0.00 s |
| Peterson | 17 | 10,057 | 6,139 | 4.13 s |
can be exponential. On the even counter ( from 0, property ), the odd values form a cycle of good states, minus , that feeds into the bad state:
| n | states | k | step clauses | time |
|---|---|---|---|---|
| 4 | 16 | 8 | 1,274 | 0.02 s |
| 6 | 64 | 32 | 23,408 | 0.81 s |
| 7 | 128 | 64 | 103,283 | 8.33 s |
The reason for safety is a single clause, (” is even”). k-induction reasons about paths and never invents a new invariant.

4.3 The simple-path constraint
Without extra constraints, can be satisfiable for every . Take a counter with an enable input. With it stutters, so an unreachable good state can repeat itself for as long as demands and then step towards the bad state. Script 03’s model at :
c=5 -> c=5 -> c=5 -> c=5 -> c=5 -> c=6 -> c=7 (en = 0 0 0 0 1 1)
Such a path repeats a state, so it carries no information that a shorter path did not. The simple-path constraint adds for all to the step case:
| system | with simple path | without (k ≤ 30) |
|---|---|---|
| counter, 3 bits, saturating at 2 | SAFE at k = 5 | UNKNOWN |
| counter, 4 bits, saturating at 5 | SAFE at k = 10 | UNKNOWN |
| counter, 5 bits, saturating at 9 | SAFE at k = 22 | UNKNOWN |
With it, k-induction is complete for finite systems: loop-free paths are bounded by the number of states, so the step case eventually becomes unsatisfiable. The price is disequality constraints, and may be as large as the number of states.
4.4 Strengthening
If is not inductive, find a such that is. Then 1-induction proves , and with it . Script 03, Part 4:
| system | Q | k for P | k for P ∧ Q |
|---|---|---|---|
| even counter | (” is even”) | 8 | 1 |
| saturating counter | ("") | 10 | 1 |
| Peterson | flags match program counters; critical while the other waits ⇒ turn favours the critical one | 17 | 1 |
Peterson’s was written by hand from the protocol’s logic. It has four conjuncts:
- for ;
- , and the symmetric conjunct.
This is how humans verify systems: by stating invariants. Finding automatically is what IC3 does.
Run it:
python3 03_k_induction.py(about 30 s), withfigures/03_k_induction.png.
5. IC3 / property-directed reachability
5.1 Intuition
Bradley’s IC3 (2011), reimplemented by Eén, Mishchenko and Brayton as PDR, builds the strengthening from CTIs, one clause at a time, without ever unrolling more than once. Its central idea is relative induction. A CTI cannot simply be excluded, because maybe it is reachable. But if is unreachable from some over-approximation of the states reachable in fewer steps, the clause can be added to the next over-approximation.
5.2 Frames
IC3 keeps a sequence of frames , each a set of clauses over the state variables, with four invariants:
- ;
- : each frame is weaker than the previous one (as clause sets, );
- : contains every successor of , so over-approximates the states reachable in at most steps;
- for .
It then repeats three operations.
Blocking. While some state in is bad (a SAT query ), show it unreachable in steps. Ask whether it has a predecessor in :
- Yes: the predecessor becomes a proof obligation at level and must be blocked first, recursively. If an obligation reaches an initial state, the chain of obligations is a counterexample.
- No: is unreachable from in one step. The clause holds in all successors of , so it may be added to . The in the query makes this relative induction: we may assume we are not already in .
Generalization. Before adding , drop literals from the cube as long as the query stays unsatisfiable and the cube stays disjoint from . A cube over 1 latch out of excludes states at once. This is what turns IC3 from a state enumerator into an invariant finder.
Propagation. After blocking, open and push every clause of with into . If some ends up equal to , then , and is an inductive invariant that implies . IC3 stops with a proof.
Every query involves one copy of . The queries are small and numerous, the opposite of BMC’s few large ones.
5.3 Two traced runs
Script 04, Part 1, on the even counter:
--- frame F_1: block every bad state in F_1
bad state in F_1: x0 ∧ ¬x1 ∧ ¬x2 ∧ ¬x3
blocked at level 1: learn ¬x0 in F_1 (generalized from 4 to 1 literals)
propagate ¬x0 from F_1 to F_2
F_1 = F_2: an inductive invariant -- done
Result: SAFE after 8 SAT calls. Invariant (with P): ¬x0 certificate: ok
The bad state has no predecessor in . Generalization asks whether the cube can shrink: alone still has no predecessor outside itself, since adding 2 never changes . IC3 learns , the one-clause invariant that k-induction needed to get around.
On the saturating counter, IC3 learns , then , then , in 25 SAT calls. Together these say : the strengthening written by hand in §4.4, found automatically.
5.4 Results, certificates, and Peterson’s invariant
Script 04, Part 2, on every case study:
| system | IC3 | frames | invariant / trace | SAT calls |
|---|---|---|---|---|
| counter mod 6, | SAFE | 3 | 1 clause | 15 |
| counter mod 6, | UNSAFE | 3 | trace of 5 steps | 37 |
| even counter, 4 bits | SAFE | 2 | 1 clause | 8 |
| shift register, 6 bits | SAFE | 7 | 64 clauses | 1,424 |
| Peterson | SAFE | 7 | 12 clauses | 566 |
| check-then-set | UNSAFE | 5 | trace of 6 steps | 129 |
| arbiter | SAFE | 2 | 3 clauses | 29 |
| arbiter, buggy | UNSAFE | 5 | trace of 8 steps | 200 |
Certificates. Every SAFE answer comes with an invariant , and check_invariant verifies it with three independent SAT queries. All three must be unsatisfiable:
Initiation, consecution and safety together are the induction proof. Every UNSAFE answer comes with a trace that simulation confirms. As with DRUP proofs (Lecture 5), a bug in the engine cannot produce a wrong certified answer.
Peterson’s 12 clauses begin with , , , : a process that is not idle has its flag up. This is one direction of the hand-written . The other clauses relate turn to the program counters in IC3’s own words, and one of them is itself.
IC3’s counterexamples here are as short as BMC’s (5, 6 and 8 steps), but that is not guaranteed. An obligation re-enqueued at a higher level can lengthen the trace.
5.5 Where IC3 struggles
Script 04, Part 3:
| family | n | IC3 invariant | IC3 SAT calls | k-induction |
|---|---|---|---|---|
| even counter | 4 | 8 | k = 8 | |
| even counter | 64 | 68 | k = | |
| shift register + parity | 4 | 16 clauses | 283 | k = 1 |
| shift register + parity | 7 | 128 clauses | 3,103 | k = 1 |
IC3 can only learn clauses. The parity of bits has no CNF smaller than clauses, because every clause of a parity CNF must mention all variables. So the invariant IC3 needs is exponential, while 1-induction proves the same property at once.
The even counter is the opposite case: one clause for IC3, for k-induction. No method dominates. Each is fast when the reason for safety is short in its language.

5.6 What matters inside IC3
Script 04, Part 4 switches components off:
| system | full IC3 | no pushing | no generalization |
|---|---|---|---|
| even counter, 8 bits | 12 calls, 1 clause | 12 calls, 1 clause | 515 calls, 128 clauses |
| arbiter | 29 calls, 3 clauses | 29 calls, 3 clauses | 98 calls, 32 clauses |
| Peterson | 566 calls, 12 clauses | 571 calls, 12 clauses | 316 calls, 82 clauses |
Without generalization IC3 excludes the 128 odd values of the 8-bit even counter one by one. On Peterson, generalization costs more SAT calls than it saves, since each literal it tries to drop is a query. It still shrinks the invariant from 82 clauses to 12.
Pushing changes little on systems this small. Real implementations add much more:
- one incremental solver per frame;
- ternary simulation to generalize predecessors;
- smarter generalization (“MIC”, “CTG”);
- careful clause propagation.
Run it:
python3 04_ic3.py(about 5 s), withfigures/04_ic3_scaling.png.
6. Craig interpolation and interpolation-based model checking
6.1 Craig’s theorem
Theorem (Craig 1957). If is unsatisfiable, there is an interpolant with:
- ;
- unsatisfiable;
- mentions only variables that occur in both and .
is “what says about the shared vocabulary that is enough to contradict ”.
McMillan’s system (2003) reads off any resolution refutation, as a partial interpolant for each line:
| proof line | partial interpolant |
|---|---|
| input clause of | the disjunction of its shared literals ( if none) |
| input clause of | |
| resolvent on a variable that occurs only in | |
| resolvent on any other variable |
The empty clause’s partial interpolant is . Lecture 5’s CDCL solver writes every learned clause as a chain of resolution steps (resolution=True), so interpolants come for free.
Script 05, Part 1, with and :
line clause how partial interpolant
1 {a, b} input clause of A ⊥
2 {¬a, c} input clause of A c
3 {¬b, c} input clause of A c
4 {¬c, d} input clause of B ⊤
5 {¬d} input clause of B ⊤
6 {a, c} resolve 1, 3 on b (A-local: ∨) c
7 {c} resolve 6, 2 on a (A-local: ∨) c
8 {d} resolve 7, 4 on c (shared: ∧) c
9 □ resolve 8, 5 on d (shared: ∧) c
: exactly the fact that passes to .
6.2 Interpolants as images
McMillan used interpolants to compute over-approximate images. Let be the current over-approximation of the reachable states, starting with :
If is unsatisfiable, no bad state is reachable within steps after one step from . The interpolant , renamed from time 1 to time 0, has three properties:
- it contains every successor of (since );
- it cannot reach a bad state within more steps;
- it mentions only state variables.
The loop then continues:
- if , is closed under : an inductive invariant;
- otherwise set and repeat.
If is satisfiable and , it is a real counterexample (a BMC run). If , it may be spurious, because the over-approximation reached too far. Then increase and restart from .
Script 05, Part 2 counts states:
| system | k | iteration | exact image of R | outcome | ||
|---|---|---|---|---|---|---|
| even counter | 1 | 1 | 1 | 1 | 8 | R := R ∨ J |
| even counter | 1 | 2 | 8 | 8 | 8 | fixpoint |
From the exact image is the single state 2. The interpolant covers all 8 even values, because the refutation only needed ” stays 0”. Two interpolants reach the fixpoint, where exact image computation would need 8 steps.
On the saturating counter, small give interpolants that overshoot into unreachable states, which can reach the bad state, so the run ends spurious. ITP increases six times and reaches a fixpoint at after 6 iterations, with every interpolant inside the reachable states.
6.3 The price: interpolant size
Interpolants are as large as the proofs they come from. In the comparison of §7, the largest interpolant on Peterson’s protocol has 1,916 distinct subformulas for a system of 7 latches. ITP runs out of its budget (3,000 conflicts) at . Production tools shrink interpolants with circuit rewriting; ours uses them as they come.
Run it:
python3 05_interpolation.py(about 25 s).
7. Model checking in practice
7.1 Five engines side by side
Script 05, Part 3, runs every engine on every case study (deterministic work measures; times vary by machine):
| system | truth | explicit | BMC (≤ 20) | k-induction | IC3 | ITP (3,000 conflicts) |
|---|---|---|---|---|---|---|
| counter mod 6, | SAFE | 6 states | none ≤ 20 | k = 2 | 15 calls | k = 2 |
| counter mod 6, | UNSAFE | 6 states | at 5 | k = 6 | 37 calls | k = 5 |
| even counter | SAFE | 8 states | none ≤ 20 | k = 8 | 8 calls | k = 1 |
| shift register | SAFE | 64 states | none ≤ 20 | k = 1 | 1,424 calls | k = 1 |
| shift register, buggy | UNSAFE | 65 states | at 7 | k = 8 | 1,432 calls | k = 7 |
| Peterson | SAFE | 20 states | none ≤ 20 | k = 17 | 566 calls | UNKNOWN |
| check-then-set | UNSAFE | 16 states | at 6 | k = 7 | 129 calls | k = 6 |
| arbiter | SAFE | 18 states | none ≤ 20 | k = 1 | 29 calls | k = 1 |
| arbiter, buggy | UNSAFE | 19 states | at 8 | k = 9 | 200 calls | k = 8 |
| saturating counter | SAFE | 6 states | none ≤ 20 | k = 10 | 25 calls | k = 7 |
All engines agree wherever they answer, and every answer is checked.
On systems this small explicit search wins every row. Its cost is the number of reachable states, while the symbolic engines’ cost is the size of a proof. On a design with thousands of latches only the symbolic engines have a chance. Industrial model checkers therefore run a portfolio of BMC, k-induction, IC3 and interpolation, often in parallel. Examples are ABC, nuXmv, AVR and Pono (and CBMC and ESBMC for software).
7.2 Where model checking is used
- Hardware. Every major chip company runs SAT-based model checkers on RTL. The Hardware Model Checking Competition (HWMCC) uses the AIGER format, which is the same “latches + next-state functions + bad states” form as
TransitionSystem. - Protocols. Cache-coherence and consensus protocols are checked with explicit-state tools (Murφ, TLC for TLA+) and with SAT/SMT-based ones.
- Memory models. Trippel’s research verifies that processors implement their memory consistency models and that hardware is free of side channels. Examples are TriCheck (ASPLOS 2017) and CheckMate (MICRO 2018), which search for bad executions with relational model finding on top of SAT. These are the same “find a run that ends in a bad state” questions.
- Software. Bounded model checkers for C (CBMC, ESBMC) unroll loops just as BMC unrolls time. k-induction and IC3 are applied to programs over integers and arrays, which needs SMT instead of SAT: the subject of Lectures 10–16.
8. Summary
- A transition system is and . A safety property is an invariant iff no bad state is reachable. A violation always has a finite witness.
- Explicit-state search finds shortest counterexamples and proves safety by exhausting the reachable states. Its cost grows exponentially with the latches (2^18 states: 0.7 s).
- BMC encodes “a bad state at depth ” as one SAT formula, linear in . It finds shortest counterexamples (the arbiter’s at depth 128 in about 5 s) and proves nothing unless passes a completeness threshold (diameter, recurrence diameter).
- Induction proves inductive properties with one SAT query (parity of 256 bits). Its counterexamples, the CTIs, are usually unreachable states, and inductive invariants lie between Reach and Safe.
- k-induction strengthens the hypothesis with steps of history. It needs the simple-path constraint for completeness, and can be exponential (even counter: ).
- IC3 builds an inductive strengthening clause by clause through relative induction, generalization and propagation. It is robust, and it fails when the invariant has no short CNF (parity).
- Interpolants from resolution proofs over-approximate images and can jump to an invariant in one step. Their size grows with the proofs.
- Every answer is certified: counterexamples by simulation, invariants by initiation, consecution and safety.
9. Common pitfalls
- “BMC found no bug up to depth 50, so the design is correct.” Only if 50 exceeds a completeness threshold. The arbiter’s bug sits at depth 128 with a 7-bit timer.
- Confusing invariant with inductive invariant. may hold in every reachable state and still fail the induction step. A CTI is not a bug.
- Forgetting the base case. alone proves nothing: satisfies it trivially, as does any property that is closed under transitions but false in an initial state.
- k-induction without the simple-path constraint, then concluding “UNKNOWN means probably buggy”. A stuttering system defeats it for every .
- Reading IC3’s frames as reachable sets. over-approximates the states reachable in at most steps. Only a fixpoint is a proof.
- Generalizing a cube into the initial states. A blocked cube must stay disjoint from , or IC3 would “prove” that initial states are unreachable.
- Treating a spurious ITP counterexample as real. Only satisfiable with is a real run.
- Mixing up time steps. In the unrolling, __ and __ are different variables. Forgetting to rename a subformula silently links two time steps.
10. Exercises
1. (modeling) Model a 2-bit Gray-code counter (00 → 01 → 11 → 10 → 00) as a TransitionSystem with next-state functions. Property: consecutive states differ in exactly one bit. Is this a safety property of single states? How do you check it with mc.py?
Answer
“Consecutive states differ in one bit” is a property of transitions, not of single states. Make it a state property by adding history latches:
- add latches with (the previous value);
- add a latch
startedwith init 0 and next 1.
The property is then started ⇒ (g ⊕ h has exactly one bit set). This “monitor” construction turns any finite-history property into a safety property of an extended system. With it, explicit search, BMC or IC3 all prove the property.
2. (BMC) Write for “a bad state within steps” instead of “at exactly ”. When would you prefer each?
Answer
.
- “Within ” answers “any bug up to ?” with one query, and suits jumping to a large directly.
- “Exactly ” with increasing gives shortest counterexamples and simpler queries.
With an incremental solver, “exactly ” plus learned clauses usually wins.
3. (diameter) Show that the recurrence diameter is always at least the diameter, and give a system where it is exponentially larger.
Answer
Why rd ≥ D. A shortest path to a state is loop-free, and the diameter is the longest of these shortest paths. So .
Example. Take latches, all initial values free (every state initial). Then . With a transition relation that allows a Hamiltonian path through all states (e.g. a counter), .
4. (induction) For the counter mod 6 with , find the weakest such that is inductive. Compare with IC3’s invariant.
Answer
The weakest Q. must exclude 6, the only good state with a bad successor. No state steps to 6 (5 wraps to 0), so excluding 6 is enough: , i.e. .
IC3’s answer. IC3 found , which excludes both 6 and 7: generalization dropped . Both are valid strengthenings, and IC3’s is shorter.
5. (k-induction) Prove that k-induction with the simple-path constraint terminates on every finite system.
Answer
Case: bad state reachable. Some base case with = the length of a shortest counterexample is satisfiable.
Case: no bad state reachable. Consider larger than the number of states . The step case asks for pairwise distinct states, which is impossible. So is unsatisfiable for at the latest, and k-induction answers SAFE.
The bound is the longest loop-free path, at most .
6. (IC3) In the even-counter trace, why may IC3 drop the literals but not ? What would happen if generalization dropped too?
Answer
What generalization tests. Dropping a literal from the cube is allowed if the smaller cube is still disjoint from and is unsatisfiable.
Why the three literals can go. With , the query asks for a state with (not in ) whose successor has . Adding 2 never changes , so this is unsatisfiable.
Why must stay. The empty cube is . It intersects , so dropping is forbidden: it would “block” every state, including the initial one.
7. (certificates) An engine claims that is an inductive invariant for Peterson. Which of the three checks of check_invariant fails, and what does the failing model look like?
Answer
Which check fails. Initiation and safety hold. Consecution fails: is satisfiable.
The failing model. A CTI, e.g. script 03’s: process 0 waiting, process 1 critical, both flags down, turn = 0. The scheduler moves process 0, which enters because .
8. (interpolation) Compute McMillan’s interpolant by hand for and . Then swap the roles of and . What do you get, and why?
Answer
; . The shared variable is .
- gets (no shared literal), gets , gets .
- Resolving on (A-local) gives with .
- Resolving on (shared) gives □ with .
So .
Swapped. Now and . A proof is: resolve with on (B-local: ∧) to get , then with on (shared: ∧).
The interpolant is , the negation of the first one. In general, the negation of any interpolant of is an interpolant of : because is unsatisfiable, and is unsatisfiable because .
9. (programming) Add incremental BMC to mc.py: keep one CDCLSolver across depths. Which changes does cdcl.py need (adding clauses after solve, solving under assumptions)? Measure the gain on the arbiter family.
Answer sketch
Changes to cdcl.py.
- Adding clauses after
solve: a method that grows the variable arrays (values, levels, watches, heap) and watches new clauses at level 0. - Assumptions:
solve(assumptions=[...])decides the assumption literals first, one per decision level. A conflict involving them means “UNSAT under these assumptions”, without learning anything that depends on them as a fact.
How to use them. Encode as an assumption literal bad_k.
What to expect. The learned clauses about carry over between depths. MiniSat-based BMC typically gains several-fold.
10. (programming) Implement ternary simulation to generalize IC3’s predecessor cubes. Drop a latch from the predecessor cube if setting it to X (unknown) still forces the successor cube under the same inputs. Measure SAT calls on Peterson.
Answer sketch
Ternary simulation. Evaluate the next-state functions over :
- , , , and so on.
The algorithm. For each latch of the predecessor, set it to X. If every latch of the successor cube still evaluates to its required value, keep it as X, which drops it from the cube.
What to expect. Fewer, larger blocked regions per obligation, and so fewer SAT calls. This is Eén et al.’s PDR trick.
11. Further reading
- E. M. Clarke, O. Grumberg, D. Peled, Model Checking, MIT Press 1999 (2nd ed. with Kroening and Veith, 2018).
- J. R. Burch, E. M. Clarke, K. L. McMillan, D. L. Dill, L. J. Hwang, “Symbolic Model Checking: 10^20 States and Beyond”, LICS 1990.
- A. Biere, A. Cimatti, E. Clarke, Y. Zhu, “Symbolic Model Checking without BDDs”, TACAS 1999 (bounded model checking).
- M. Sheeran, S. Singh, G. Stålmarck, “Checking Safety Properties Using Induction and a SAT-Solver”, FMCAD 2000.
- N. Eén, N. Sörensson, “Temporal Induction by Incremental SAT Solving”, BMC 2003.
- K. L. McMillan, “Interpolation and SAT-Based Model Checking”, CAV 2003.
- A. R. Bradley, “SAT-Based Model Checking without Unrolling”, VMCAI 2011 (IC3).
- N. Eén, A. Mishchenko, R. Brayton, “Efficient Implementation of Property Directed Reachability”, FMCAD 2011.
- A. Biere, “Bounded Model Checking”, Chapter 18 of the Handbook of Satisfiability (2nd ed. 2021).
- C. Trippel, Y. Manerkar, D. Lustig, M. Pellauer, M. Martonosi, “TriCheck: Memory Model Verification at the Trisection of Software, Hardware, and ISA”, ASPLOS 2017.
12. Next lecture
Lecture 10: first-order theories and DPLL(T). Model checking at the bit level stops where designs have 64-bit adders and memories. The next unit lets the solver reason directly about integers, arrays and uninterpreted functions: satisfiability modulo theories.
- We study the eager approach (translate everything to SAT, as we did here) and the lazy one.
- In the lazy approach a CDCL engine works on the Boolean skeleton while a theory solver checks conjunctions of literals.
- We build
smt.py: congruence closure for equality with uninterpreted functions, plugged into CDCL with conflict explanations and theory propagation.