pHL loops that terminate with probability 1: EC's while I V k ε #
EC's rule for phoare[ while b c : P ==> Q ] = r (ecPhlWhile.ml, t_bdhoare_while_rev_geq):
an invariant I, an integer variant V bounded by k on I and positive where the test
passes, and a probability ε > 0 with which one round decreases the variant. Then the loop
terminates with probability 1 from I (Stmt.ewp_while_one_of_variant), and its expectation
is the one solution of the loop's equation (phoareStmt_while_rev_eq).
The zero-one argument of Stmt.ewp_while_one (Logic/PHoare.lean) is the case I = True,
k = 1: there, one round leaves the loop with probability ε.
An event of probability 1 may be assumed under an expectation at most 1.
A statement that reaches an event with probability 1 is lossless.
Almost-sure termination from a variant (EC's while I V k ε): from the invariant I,
with a variant V that is at most k on I and positive where the test passes, if one round
keeps I with probability 1 and decreases V with probability at least ε > 0, the loop
terminates with probability 1.
A statement with a prescribed expectation of g: go to the state τ₁ with probability
J σ, fail otherwise. (The stand-in for EC's abstract statement in the loop rule below.)
Equations
- One or more equations did not get rendered due to their size.
Instances For
EC's while I V k ε on phoare[ while b c : P ==> g ] = bd (ecPhlWhile.ml,
t_bdhoare_while_rev_geq), EC's six conditions in its order:
hpre: the precondition gives the invariant;hbound: where the loop is not entered, the bound is the postcondition;hterm: on the invariant the variant is at mostk, and positive where the test passes;hbody: one round followed by any statementwthat meets the judgment meets it (EC's abstract statement standing for the loop);hinv: one round keeps the invariant, with probability1;hε0,hvar: one round decreases the variant with probability at leastε > 0.
Beyond EC's: g ≤ 1 and bd ≤ 1 (an event and a probability), and some state satisfies the
postcondition (hsat). The last is needed here because w is a quantified statement, not
EC's abstract one: if no state satisfies the postcondition, no w meets the judgment with a
bound other than 0, and hbody holds for want of one — while (b) b <- false from b with
the postcondition false would pass the six conditions for any bound. (In EC the judgment
about w is a hypothesis that can only be used, not refuted.)
phoareStmt_while_rev_eq with the rate a real, as EC writes it.
EC's while I V k ε on phoareStmt P (while c body) g = bd (phoareStmt_while_rev_eq):
EC's goals in its order — pre_inv, pre_bound, term, body, inv, rate (0 < ε),
variant — then post_le_one, bound_le_one, sat. The goals that are not judgments are
closed when trivial (EC's => //).
Equations
- One or more equations did not get rendered due to their size.
Instances For
EC's while I V k ε on phoare[ while b c : P ==> Q ] = r (the loop alone): the
invariant I and the integer variant V written like the judgment's conditions, k an
integer and ε a real. See phoareStmt_while_rev_eq for the goals.
Equations
- One or more equations did not get rendered due to their size.