pRHL rules for bounded loop approximants #
rHoare Φ c₁ c₂ Ψ holds when the output sub-distributions of c₁ and c₂,
run from any Φ-related pair of heaps, admit a coupling supported in Ψ. This
file gives the rules relating whileApprox guard₁ body₁ n to
whileApprox guard₂ body₂ n at a fixed budget n.
A relational invariant I that forces the two guards to agree, together with
bodies that preserve I while the guards hold, relates the two approximants at
every budget. The two sides run in lockstep: the same n on both sides. A
Coupling matches its two marginals exactly, so the failure mass carried by a
joint sub-distribution is shared by both sides; at equal budgets the two
approximants do lose the same mass, which is what makes the lockstep statement
couplable.
Main results #
rHoare_fail_fail— a coupling of two failed computations, on any pre- and postconditionrHoare_whileApprox_zero— the budget-0case, where both approximants areSPComp.failrHoare_whileApprox_step— one synchronous iteration at budgetn + 1, given the judgment for the bodies and the judgment at budgetnrHoare_whileApprox— the synchronous invariant rule at every budgetrHoare_whileApprox_same— the specialization to one guard and one body
Failure against failure #
Two failed computations are related by any postcondition: the zero
sub-distribution is a coupling of SPComp.fail with itself, and its support is
empty.
The approximants at a fixed budget #
At budget 0 both approximants are SPComp.fail, so any pre- and
postcondition relate them.
One synchronous iteration. From a pair of heaps satisfying I with both
guards true, a judgment for the two bodies and a judgment for the two
approximants at budget n give the judgment at budget n + 1.
The synchronous invariant rule for the bounded approximants.
If the relational invariant I forces the two guards to agree, and the two
bodies preserve I from any I-related pair of heaps at which the guards hold,
then at every budget n the two approximants are related by I together with
both guards being false.
The synchronous rule with one guard and one body on both sides: the invariant only has to make the guard agree on the two heaps.