Every time a developer writes a loop, they are implicitly claiming something: no matter how many times this runs, such-and-such property always holds. That hidden claim is called a loop invariant, and finding one that is both true and strong enough to prove the program correct is the crux of automated verification.
One of the most elegant approaches encodes the whole problem as a set of constrained Horn clauses (CHCs) — logical implications of the form , where each is a constraint and is either another predicate or false. The program becomes a handful of such clauses, and a CHC solver finds — or proves the non-existence of — a model: an assignment of predicates that makes every clause true.
If a model exists it hands you the invariants for free. If it does not, the solver produces a counterexample trace that shows exactly how the program breaks its specification. Either way, you get a definitive answer without guessing.
Comments
Loading comments...