Lower bounds through compound statements #
phoare_wp handles a conditional only when the expectations of both branches can be computed
(no loop inside). These two rules let a lower-bound proof go through such statements. Losslessness
proofs (phoare[ True ==> 1 ] ≥ 1) of procedures whose loops are guarded by a conditional need
them.
phoareStmt_if_ge: a conditional, one judgment per branch (EC'sifinphoare).phoareStmt_seq_ge_one:p; q, whereqgets expectation at least1from everywhere, soponly needs a bound for the expectation1(EC'sseqwith a lossless suffix).
theorem
GaudisCrypt.phoareStmt_if_ge
{A : ProgramState → Prop}
{c : Getter Bool ProgramState}
{t e : Stmt}
{g r : ProgramState → ENNReal}
(ht : phoareStmt (fun (σ : ProgramState) => A σ ∧ c.get σ = true) t g GE.ge r)
(he : phoareStmt (fun (σ : ProgramState) => A σ ∧ c.get σ = false) e g GE.ge r)
:
phoareStmt A
(GaudiProg[
if (§c) {
stmt t;
} else {
stmt e;
}
])
g GE.ge r
Conditional, lower bound: one judgment per branch, each with the test's value in its precondition.
theorem
GaudisCrypt.phoareStmt_seq_ge_one
{A : ProgramState → Prop}
{p q : Stmt}
{g r : ProgramState → ENNReal}
(hq : phoareStmt (fun (x : ProgramState) => True) q g GE.ge fun (x : ProgramState) => 1)
(hp : phoareStmt A p (fun (x : ProgramState) => 1) GE.ge r)
:
phoareStmt A
(GaudiProg[
stmt p;
stmt q;
])
g GE.ge r
Sequence through a lossless suffix: if q reaches g with expectation at least 1 from
every state, then a lower bound on p for the expectation 1 is one on p; q for g.