Back to Program Verification Index | Previous: (y-16) Abstractions and ARG | Next: (y-18) Trace Abstraction and Floyd-Hoare Automata

Mental Model for CEGAR

  • Automated Refinement: We don’t know the best predicates for a program. CEGAR (CounterExample-Guided Abstraction Refinement) starts with nothing and learns the predicates it needs automatically.
  • Trace Analysis: If our simplified (abstract) model finds an “error,” we check whether it is a real bug or a False Counterexample.
  • Infeasibility Proofs: If the error is a false alarm, we find an Infeasibility Proof (a sequence of formulas that prove the trace is impossible).
  • Learning: We add the formulas from that proof to our set , making our model more precise so it won’t make that same mistake again.

Traces and Feasibility

A Trace () is a sequence of statements .

  • Feasible: There is at least one execution that follows the trace.
  • Infeasible: No execution can ever follow this trace.

Infeasibility Proof

A sequence of formulas is a Proof of Infeasibility for if:

  1. Each step follows the logic:
  2. The final result is

The CEGAR Approach (Step-by-Step)

  1. Step 1: Start Simple. Set the predicates (or some initial set).
  2. Step 2: Build ARG. Construct the Abstract Reachability Graph based on .
  3. Step 3: Check for Errors.
    • If no error location is reachable in the ARG, the Program is Safe.
    • If an error location is reachable, find the Abstract Error Trace that led to it.
  4. Step 4: Check Trace Feasibility.
    • If is Feasible (satisfiable in concrete semantics), the Program is Incorrect. Return “Bug” + the concrete counterexample.
    • If is Infeasible (unsatisfiable in concrete semantics), our abstraction is too coarse.
  5. Step 5: Refine.
    • Find an Infeasibility Proof sequence for such that , and .
    • Add these new formulas to our set of predicates .
    • Go back to Step 2.

💡 Intuition: Progressive Learning

Imagine trying to find a path in a dark room.

  • Iteration 1: You assume the room is empty. You walk forward and hit a chair (the chair is your error trace).
  • Refinement: You now know “There is a chair at coordinate X.” You add this to your mental map (your set ).
  • Iteration 2: You build a new plan that avoids that chair. If you hit a table, you repeat the process.
  • End: Eventually, you either reach the exit (Safety Proof) or prove there is no way out (Real Bug).

Summary

  1. CEGAR automates the discovery of program properties (Predicates).
  2. Traces are paths through the program.
  3. Infeasibility Proofs are the source of new knowledge for the verifier.
  4. Progress Property: Once an error trace is proven infeasible, the verifier will never encounter it again in future iterations.
  5. Abstraction: CEGAR verifies complex programs without anyone guessing invariants by hand.

Self-Check

  1. When is a trace called feasible, and when is it infeasible?
  1. State the three conditions that make an infeasibility proof for .
  1. Outline the five steps of the CEGAR loop.
  1. Why does CEGAR refine its abstraction using the formulas from the infeasibility proof, rather than arbitrary predicates?
  1. Why is the abstraction necessarily coarsened back when CEGAR starts, and what does each refinement step do to it?

Back to Program Verification Index | Previous: (y-16) Abstractions and ARG | Next: (y-18) Trace Abstraction and Floyd-Hoare Automata | (y) Return to Notes | (y) Return to Home