Documentation

GaudisCrypt.Logic.PHoareLossless

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.

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.