Documentation

GaudisCrypt.Logic.ExpectationCall

The abstract call rule for expectations (supermartingales) #

An adversary that cannot touch an oracle's state L, run with oracles that do not increase the expectation of a potential φ of that state, does not increase it either. This is the unary, quantitative counterpart of the relational abstract call rule (Logic/AbstractCall.lean), and what EasyCrypt's failure event lemma (fel) rests on: with φ the indicator of the bad event plus the bound still to be paid for the remaining oracle calls, Pr[bad] ≤ φ(initial state).

The proof is an induction over the adversary's statement (ConfinedP, from its footprint): code without holes keeps the content of L (inFootprint_preserves_touched, L lifted is a lens region), an oracle call is the hypothesis, sequences compose by monotonicity, and loops are Stmt.ewp_while_le with φ as the invariant.

theorem GaudisCrypt.SubProbability.pure_singleton_ne_zero {α : Type u_1} (a : α) :
↑(pure a) {a} ≠ 0

A point mass charges its point.

A program confined outside L (lifted through the globals) keeps L's value.

theorem GaudisCrypt.Stmt.ewp_le_of_confined {Ω : Type} (L : Lens Ω VariableAssignment) {s : Stmt} (φ : Ω → ENNReal) (hs : (programDenotation s).inFootprint (ProgramState.globalL.chain L).footprintᶜ) (σ : ProgramState) :
s.ewp (fun (τ : ProgramState) => φ (L.get τ.globals)) σ ≤ φ (L.get σ.globals)

A statement confined outside L does not increase the expectation of a function of L.

theorem GaudisCrypt.StmtWithHoles.ewp_instantiate_le {Ω : Type} (L : Lens Ω VariableAssignment) {holes : HoleSigs} (inst : holes.Instantiation) (φ : Ω → ENNReal) (hhole : ∀ {sig' : ProcedureSignature} (n : HoleIndex holes sig') (a : sig'.ParamType) (g : VariableAssignment), (inst.lookup n).ewp a (fun (x : sig'.ret) (g' : VariableAssignment) => φ (L.get g')) g ≤ φ (L.get g)) (s : StmtWithHoles holes) :

The body induction: an adversary statement confined outside L, its holes filled with oracles that do not increase φ in expectation, does not increase it.

theorem GaudisCrypt.ProcedureWithHoles.ewp_instantiate_le {Ω : Type} (L : Lens Ω VariableAssignment) {holes : HoleSigs} {sig : ProcedureSignature} (A : ProcedureWithHoles holes sig) (hdisj : FVP.fvP_proc A ≤ L.footprintᶜ) (hc : ∀ {sig' : ProcedureSignature} (a : HoleIndex holes sig'), Countable sig'.ParamType) (inst : holes.Instantiation) (φ : Ω → ENNReal) (hhole : ∀ {sig' : ProcedureSignature} (n : HoleIndex holes sig') (a : sig'.ParamType) (g : VariableAssignment), (inst.lookup n).ewp a (fun (x : sig'.ret) (g' : VariableAssignment) => φ (L.get g')) g ≤ φ (L.get g)) (a : sig.ParamType) (g : VariableAssignment) :
(A.instantiate inst).ewp a (fun (x : sig.ret) (g' : VariableAssignment) => φ (L.get g')) g ≤ φ (L.get g)

The abstract call rule for expectations (a procedure with holes): an adversary that cannot touch L (FVP.fvP_proc A ≤ L.footprintᶜ), its holes filled with oracles that do not increase the expectation of φ ∘ L, does not increase it.

theorem GaudisCrypt.Module.ewp_app_le {Ω : Type} (L : Lens Ω VariableAssignment) {T : Type 1} [IsModule T] {sig : ProcedureSignature} {holes : HoleSigs} (D : Arr T (Proc sig)) (ext : T → holes.Instantiation) (hD : Representable D ext) (hdisj : FVP.fvP D ≤ L.footprintᶜ) (hc : ∀ {sig' : ProcedureSignature} (a : HoleIndex holes sig'), Countable sig'.ParamType) (O : T) (φ : Ω → ENNReal) (horacle : ∀ {sig' : ProcedureSignature} (n : HoleIndex holes sig') (a : sig'.ParamType) (g : VariableAssignment), ((ext O).lookup n).ewp a (fun (x : sig'.ret) (g' : VariableAssignment) => φ (L.get g')) g ≤ φ (L.get g)) (a : sig.ParamType) (g : VariableAssignment) :
(app D O).procedure.ewp a (fun (x : sig.ret) (g' : VariableAssignment) => φ (L.get g')) g ≤ φ (L.get g)

The abstract call rule for expectations, for a module (EasyCrypt's declare module D <: T {-O}): D applied to oracles that do not increase the expectation of φ ∘ L, L outside D, does not increase it (exception E2 for the representation).