The unary invariant rule for bounded loop approximants #
A predicate I on heaps that the body preserves whenever the guard holds is an
invariant of every approximant whileApprox guard body n: from a heap satisfying
I, each outcome of the approximant satisfies I and falsifies the guard.
The rule needs no termination hypothesis. A run that exhausts its budget fails, and failure carries no value mass, so the postcondition holds vacuously on it; the judgment is partial correctness. Termination enters separately, through losslessness: at a budget where the approximant has mass one, the postcondition has probability one.
Main results #
pHoare_whileApprox— the invariant rule at every budgetpHoare_whileApprox_conseq— the same with the postcondition weakenedprEvent_whileApprox_eq_one— probability one under conditional losslessnessprEvent_whileApprox_eq_one_of_isLossless— the unconditional variant
Base case #
The zero-budget approximant is SPComp.fail, which satisfies every judgment:
its support contains no outcome.
The invariant rule #
Invariant rule for the bounded approximants. If body restores I from any
heap satisfying I on which the guard holds, then from a heap satisfying I the
approximant whileApprox guard body n ends in a heap satisfying I on which the
guard is false, for every budget n.
The invariant rule with the postcondition weakened: any Q implied by the
invariant together with the guard being false.
Termination-gated probability #
At a budget where the approximant is lossless on heaps satisfying the invariant, the invariant together with the guard being false has probability one.
prEvent_whileApprox_eq_one under unconditional losslessness of the
approximant.
The weakened form at probability one: a postcondition implied by the invariant and the guard being false holds with probability one at a budget where the approximant is lossless.