EasyCrypt's fel (the failure event lemma), once #
EC's
fel init cntr step q bad [O₁: pre₁, …] inv
bounds the probability of a failure event bad after an abstract module's run by
∑_{i ∈ [init, q)} step i: each oracle call that may set bad (its preᵢ holds) does so with
probability at most step cntr and increases the counter cntr; the other calls leave bad and
cntr alone; inv holds throughout.
Here the same premises, for the oracles of Module.app D O with D abstract, give the bound,
by Module.ewp_app_le (the supermartingale abstract call) on one potential, felPotential, once
for all games: ⊤ off the invariant, 1 once bad holds, else the bound still to pay,
∑_{i ∈ [cntr, q)} step i. The state the premises talk about is the view L.get g of the
globals through a lens L that D does not touch (the counter, the variables of bad and
inv).
Deviation from EC: bad must persist (FelOracle.keep), where EC's conclusion is about bad
at the end however it got there; the events of the SHA-3 games are monotone. The premises are
Hoare and pHL judgments about the oracle procedures, proven with the usual tactics.
A procedure's expectation is monotone in the function on the outcomes a Hoare triple allows.
The premises of EC's fel for one oracle procedure p with precondition pre (the calls
that may set bad), over the view L.get of the globals.
a call that may set
badis one of theqthe bound pays for- step : phoareProc (fun (x : sig.ParamType) (g : VariableAssignment) => inv (L.get g) ∧ ¬bad (L.get g) ∧ pre (L.get g)) p (fun (x : sig.ret) (g' : VariableAssignment) => indicatorE (bad (L.get g'))) (fun (x1 x2 : ENNReal) => x1 ≤ x2) fun (x : sig.ParamType) (g : VariableAssignment) => step (cntr (L.get g))
… and sets it with probability at most
step cntr - incr (c : ℤ) : hoareProc (fun (x : sig.ParamType) (g : VariableAssignment) => inv (L.get g) ∧ ¬bad (L.get g) ∧ pre (L.get g) ∧ cntr (L.get g) = c) p fun (x : sig.ret) (g' : VariableAssignment) => inv (L.get g') ∧ (bad (L.get g') ∨ c < cntr (L.get g'))
… and increases the counter (unless it set
bad) - same (c : ℤ) : hoareProc (fun (x : sig.ParamType) (g : VariableAssignment) => inv (L.get g) ∧ ¬bad (L.get g) ∧ ¬pre (L.get g) ∧ cntr (L.get g) = c) p fun (x : sig.ret) (g' : VariableAssignment) => inv (L.get g') ∧ ¬bad (L.get g') ∧ c ≤ cntr (L.get g')
the other calls do not set
badnor decrease the counter - keep : hoareProc (fun (x : sig.ParamType) (g : VariableAssignment) => inv (L.get g) ∧ bad (L.get g)) p fun (x : sig.ret) (g' : VariableAssignment) => inv (L.get g') ∧ bad (L.get g')
badpersists
Instances For
The sum still to pay shrinks as the counter grows.
The step of the potential: an oracle call with fel's premises does not increase the
potential in expectation.
EC's fel, for an abstract module: if every oracle satisfies fel's premises
(FelOracle), then D applied to the oracles, started where inv holds and bad does not,
ends in bad with probability at most ∑_{i ∈ [cntr, q)} step i (Module.ewp_app_le on
felPotential).
EC's call (: inv) on an abstract module, for Hoare triples: if every oracle keeps the
invariant I of the view L.get, so does D applied to them (Module.ewp_app_le on the
indicator of ¬ I: 0 from where I holds, which the oracles keep).
A statement about every oracle of a single-oracle module type: the one oracle.
EC's fel on a statement: if s₀ establishes the invariant, ¬ bad and cntr = 0, then
after s₀; x <- call D(O) (D abstract, its oracles with fel's premises, the result x outside
the view L) bad holds with probability at most ∑_{i ∈ [0, q)} step i, and so at most any
r above it. The tactic fel (Logic/FelTactic.lean) applies it.
EC's call (: inv) on an abstract module, for a Hoare triple about a statement: if the
oracles keep inv (of the view L), then before x <- call D(O) it suffices that inv holds and
that every result and globals keeping it give B.