Documentation

GaudisCrypt.Logic.ByPr

EasyCrypt's bypr, on phoare judgments #

bypr is the converse of byphoare (Logic/PrTactics.lean): a procedure judgment about an event,

phoare[ p : P ==> E ] ≤ (ENNReal.ofReal x)        (or `=`, `≥`)

its bound a real (as byphoare and phoare_call (: P ==> Q) leave it: EC's bounds are reals), becomes the statement about the probabilities of the runs that satisfy the precondition,

∀ a &m, P a m → Pr[ p (a) @ &m : E ] ≤ x

(EC's goal after bypr=> &m: the arguments and the memory are introduced by intro).

theorem GaudisCrypt.Procedure.phoareProc_le_of_toReal_Pr_le {sig : ProcedureSignature} {A : sig.ParamType → VariableAssignment → Prop} {p : Procedure sig} {E : sig.ret → VariableAssignment → Prop} {x : ℝ} (h : ∀ (a : sig.ParamType) (σ : VariableAssignment), A a σ → ↑(p.Pr a σ E) ≤ x) :
phoareProc A p (fun (v : sig.ret) (g : VariableAssignment) => indicatorE (E v g)) (fun (x1 x2 : ENNReal) => x1 ≤ x2) fun (x_1 : sig.ParamType) (x_2 : VariableAssignment) => ENNReal.ofReal x

bypr for ≤.

theorem GaudisCrypt.Procedure.phoareProc_ge_of_le_toReal_Pr {sig : ProcedureSignature} {A : sig.ParamType → VariableAssignment → Prop} {p : Procedure sig} {E : sig.ret → VariableAssignment → Prop} {x : ℝ} (h : ∀ (a : sig.ParamType) (σ : VariableAssignment), A a σ → x ≤ ↑(p.Pr a σ E)) :
phoareProc A p (fun (v : sig.ret) (g : VariableAssignment) => indicatorE (E v g)) (fun (x1 x2 : ENNReal) => x1 ≥ x2) fun (x_1 : sig.ParamType) (x_2 : VariableAssignment) => ENNReal.ofReal x

bypr for ≥.

theorem GaudisCrypt.Procedure.phoareProc_eq_of_toReal_Pr_eq {sig : ProcedureSignature} {A : sig.ParamType → VariableAssignment → Prop} {p : Procedure sig} {E : sig.ret → VariableAssignment → Prop} {x : ℝ} (h : ∀ (a : sig.ParamType) (σ : VariableAssignment), A a σ → ↑(p.Pr a σ E) = x) :
phoareProc A p (fun (v : sig.ret) (g : VariableAssignment) => indicatorE (E v g)) Eq fun (x_1 : sig.ParamType) (x_2 : VariableAssignment) => ENNReal.ofReal x

bypr for =.

The event of a postcondition in the shape phoare[ p : P ==> ev ] elaborates to, fun res σ => let res := …; GaudiExpr[ indicatorE (ev) ].get ⟨σ, init⟩, in the shape Pr[ … : ev ] elaborates to (GaudiExpr[ ev ] read the same way), so that the goal bypr leaves prints as probabilities; none for another shape.

EC's bypr on a phoare judgment about a procedure, see the module docstring: the goal phoare[ p : P ==> E ] ≤ (ENNReal.ofReal x) (=, ≥) becomes ∀ a &m, P a m → Pr[ p (a) @ &m : E ] ≤ x.

Equations
Instances For