The unbounded loop #
whileLoop guard body runs body while guard holds of the current heap, with
no bound on the number of iterations. It is the limit of whileApprox: the mass
it assigns to a heap is the probability of reaching that heap and leaving the loop
after any finite number of iterations, and the failure mass is the probability of
running forever.
The pHL rule transports from the approximants because pHoare constrains the
support: a heap in the support of the limit is in the support of some
approximant, and the invariant rule holds at every budget.
while guard do body, as the limit of its bounded approximants.
Equations
- CatCrypt.NonUniform.whileLoop guard body h = CatCrypt.NonUniform.mlim (fun (n : ℕ) => CatCrypt.NonUniform.whileApprox guard body n h) ⋯
Instances For
An outcome of the loop is an outcome of some approximant: a supremum over the budgets is nonzero only if one of them is.
The pHL rule for the unbounded loop. If the body preserves the invariant while the guard holds, then every outcome of the loop satisfies the invariant with the guard false.
This is partial correctness: the mass on which the loop runs forever is failure mass, which carries no outcome and so satisfies the postcondition vacuously.
The consequence form of the loop rule.