Documentation

GaudisCrypt.Logic.PrTactics

EasyCrypt's byequiv and byphoare, on probabilities #

A goal about probabilities, as Pr[ M (a) @ &m : E ] writes them (Syntax/PrSyntax.lean: the real (Procedure.Pr p a m E : ℝ)), is turned into a judgment:

The side conditions left are tried by rfl/trivial/simp_all; 0 ≤ x (a bound below a probability is non-negative) by positivity.

theorem GaudisCrypt.Procedure.toReal_Pr_le_of_phoareProc {sig : ProcedureSignature} {A : sig.ParamType → VariableAssignment → Prop} {p : Procedure sig} {E : sig.ret → VariableAssignment → Prop} {r : sig.ParamType → VariableAssignment → ENNReal} {a : sig.ParamType} {σ : VariableAssignment} {x : ℝ} (h : phoareProc A p (fun (v : sig.ret) (g : VariableAssignment) => indicatorE (E v g)) (fun (x1 x2 : ENNReal) => x1 ≤ x2) r) (hA : A a σ) (hr : r a σ ≤ ENNReal.ofReal x) (hx : 0 ≤ x) :
↑(p.Pr a σ E) ≤ x

byphoare for ≤.

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

byphoare for ≥.

theorem GaudisCrypt.Procedure.toReal_Pr_eq_of_phoareProc {sig : ProcedureSignature} {A : sig.ParamType → VariableAssignment → Prop} {p : Procedure sig} {E : sig.ret → VariableAssignment → Prop} {r : sig.ParamType → VariableAssignment → ENNReal} {a : sig.ParamType} {σ : VariableAssignment} {x : ℝ} (h : phoareProc A p (fun (v : sig.ret) (g : VariableAssignment) => indicatorE (E v g)) Eq r) (hA : A a σ) (hr : r a σ = ENNReal.ofReal x) (hx : 0 ≤ x) :
↑(p.Pr a σ E) = x

byphoare for =.

theorem GaudisCrypt.Procedure.toReal_Pr_eq_of_prhlProc {sig₁ sig₂ : ProcedureSignature} {A : sig₁.ParamType → VariableAssignment → sig₂.ParamType → VariableAssignment → Prop} {p₁ : Procedure sig₁} {p₂ : Procedure sig₂} {B : sig₁.ret → VariableAssignment → sig₂.ret → VariableAssignment → Prop} (h : prhlProc A p₁ p₂ B) {E₁ : sig₁.ret → VariableAssignment → Prop} {E₂ : sig₂.ret → VariableAssignment → Prop} (hE : ∀ (r₁ : sig₁.ret) (g₁ : VariableAssignment) (r₂ : sig₂.ret) (g₂ : VariableAssignment), B r₁ g₁ r₂ g₂ → (E₁ r₁ g₁ ↔ E₂ r₂ g₂)) {a₁ : sig₁.ParamType} {a₂ : sig₂.ParamType} {σ₁ σ₂ : VariableAssignment} (hA : A a₁ σ₁ a₂ σ₂) :
↑(p₁.Pr a₁ σ₁ E₁) = ↑(p₂.Pr a₂ σ₂ E₂)

byequiv for =, on real probabilities.

theorem GaudisCrypt.Procedure.toReal_Pr_le_of_prhlProc {sig₁ sig₂ : ProcedureSignature} {A : sig₁.ParamType → VariableAssignment → sig₂.ParamType → VariableAssignment → Prop} {p₁ : Procedure sig₁} {p₂ : Procedure sig₂} {B : sig₁.ret → VariableAssignment → sig₂.ret → VariableAssignment → Prop} (h : prhlProc A p₁ p₂ B) {E₁ : sig₁.ret → VariableAssignment → Prop} {E₂ : sig₂.ret → VariableAssignment → Prop} (hE : ∀ (r₁ : sig₁.ret) (g₁ : VariableAssignment) (r₂ : sig₂.ret) (g₂ : VariableAssignment), B r₁ g₁ r₂ g₂ → E₁ r₁ g₁ → E₂ r₂ g₂) {a₁ : sig₁.ParamType} {a₂ : sig₂.ParamType} {σ₁ σ₂ : VariableAssignment} (hA : A a₁ σ₁ a₂ σ₂) :
↑(p₁.Pr a₁ σ₁ E₁) ≤ ↑(p₂.Pr a₂ σ₂ E₂)

byequiv for ≤, on real probabilities.

theorem GaudisCrypt.Procedure.toReal_Pr_le_add_of_prhlProc {sig₁ sig₂ : ProcedureSignature} {A : sig₁.ParamType → VariableAssignment → sig₂.ParamType → VariableAssignment → Prop} {p₁ : Procedure sig₁} {p₂ : Procedure sig₂} {B : sig₁.ret → VariableAssignment → sig₂.ret → VariableAssignment → Prop} (h : prhlProc A p₁ p₂ B) {E₁ : sig₁.ret → VariableAssignment → Prop} {E₂ F₂ : sig₂.ret → VariableAssignment → Prop} (hE : ∀ (r₁ : sig₁.ret) (g₁ : VariableAssignment) (r₂ : sig₂.ret) (g₂ : VariableAssignment), B r₁ g₁ r₂ g₂ → E₁ r₁ g₁ → E₂ r₂ g₂ ∨ F₂ r₂ g₂) {a₁ : sig₁.ParamType} {a₂ : sig₂.ParamType} {σ₁ σ₂ : VariableAssignment} (hA : A a₁ σ₁ a₂ σ₂) :
↑(p₁.Pr a₁ σ₁ E₁) ≤ ↑(p₂.Pr a₂ σ₂ E₂) + ↑(p₂.Pr a₂ σ₂ F₂)

byequiv up to a bad event (EC's byequiv … => //# on Pr[p₁ : E₁] <= Pr[p₂ : E₂] + Pr[p₂ : F₂]): the judgment gives E₂ ∨ F₂ from E₁, then the union bound.

NNReal.toReal (Procedure.Pr p a m E): (sig, p, a, m, E).

Equations
  • One or more equations did not get rendered due to their size.
Instances For

    The goal's relation (Eq, LE.le, GE.ge at ℝ) and its two sides.

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For

      Try to close the side goals a rule leaves (each left as it is on failure).

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For

        EC's byequiv, see the module docstring.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          theorem GaudisCrypt.Procedure.toReal_Pr_eq_one_of_isLossless {sig : ProcedureSignature} {p : Procedure sig} (h : p.IsLossless) {a : sig.ParamType} {σ : VariableAssignment} {E : sig.ret → VariableAssignment → Prop} (hE : ∀ (v : sig.ret) (g : VariableAssignment), E v g) :
          ↑(p.Pr a σ E) = 1

          A lossless procedure's probability of an event that always holds is 1 (EC's byphoare Hl with Hl : islossless p on Pr[ p @ &m : true ] = 1%r).

          EC's byphoare, see the module docstring.

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For

            EC's byequiv (_ : P ==> Q): byequiv with the judgment equiv[ p₁ ~ p₂ : P ==> Q ] (P, Q relational conditions on the two procedures, res their results) as the new goal; the side conditions (P of the two runs, Q implying the events) as goals when not closed.

            Equations
            • One or more equations did not get rendered due to their size.
            Instances For