CEGAR
Counterexample-Guided Abstraction Refinement. Verify a safety property by checking a cheap abstraction, and refining it whenever it gives a fake counterexample.
Why abstract
The real program has too many states to check directly. An abstraction over-approximates it, like in abstract interpretation, so every real behaviour is in the abstraction, plus some fake ones.
- If the abstraction is safe, the program is safe.
- If the abstraction has a counterexample, it might be fake.
The loop
- Abstract. Build an abstraction of the program, usually from a set of predicates like \(x > 0\).
- Check. Model check the abstraction. If it's safe, the program is safe, stop.
- Replay. Otherwise, check whether the counterexample path is feasible in the real program. If it is, it's a real bug, stop.
- Refine. If it isn't, find a predicate that rules the fake path out, add it, and go back to 1.
flowchart LR
A[Abstract] --> C[Check]
C -->|safe| S[Program safe]
C -->|counterexample| R[Replay]
R -->|feasible| B[Real bug]
R -->|infeasible| F[Refine]
F --> A
The refinement step usually gets its new predicates from Craig interpolants of the infeasible path.
Note
The loop doesn't always terminate, since safety is undecidable in general. Each round only makes the abstraction more precise.
Tools
SLAM used CEGAR to verify Windows device drivers. BLAST and CPAchecker are CEGAR-based model checkers for C.