Documentation

GaudisCrypt.Lib.EC.AdvAbsVal

Absolute values of advantages (EasyCrypt theories/crypto/AdvAbsVal.ec) #

EC's module type Adv (one procedure main : unit -> bool) is a procedure module, procmod () → Bool; Neg_main(A) negates its answer. Neg_A_Pr_minus is how EC turns a bound on Pr[A.main() : res] into one on Pr[A.main() : !res] for a lossless A, and abs_val how a bound on the signed advantage gives one on its absolute value. EC's Pr[mu_not] is Pr_mu_not.

@[reducible, inline]

EC's module type Adv = { proc main () : bool }: one procedure, a procedure module.

Equations
Instances For

    The body of proc main of module Neg_main, as a procedure of its own: the one call it makes to a module parameter (A) is its single hole.

    A hole stands for a call whose callee is not known here — a module parameter is supplied only when the module is applied — so the body is a ProcedureWithHoles, to be instantiated (see Neg_main.main.procedure.apply_simp) rather than run. Use Neg_main.main for this procedure as a module.

    Equations
    Instances For

      proc main of module Neg_main as a module, abstracted over the module parameters it uses (A, in declaration order): Module.Arr … (Module.Proc (procsig …)).

      Apply it with the @[simp] lemma Neg_main.main.apply_simp, which fills the holes of Neg_main.main.procedure with the callees the body called.

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

        @[simp]: applying Neg_main.main to the parameters proc main uses (A) is Module.proc (Neg_main.main.procedure.instantiate …) — the procedure with its holes filled by the callees they were made from, each written as it was in the body (with the arguments in place of the module parameters) and turned into a Procedure by Module.Proc.procedure.

        theorem GaudisCrypt.EC.AdvAbsVal.Neg_main.main.procedure.apply_simp (holeArgs✝ : (HoleSigs.cons (procsig () → Bool) HoleSigs.empty).Instantiation) :
        procedure.instantiate holeArgs✝ = proc () : Bool { var b : Bool; b <- call (holeArgs✝.lookup HoleIndex.zero) (); return !§b }

        Instantiating the holes of Neg_main.main.procedure with a tuple holeArgs of procedures: the body of proc main as written, with each hole call replaced by the matching holeArgs.lookup (HoleIndex.zero being the first hole the body declared). True by rfl.

        Deliberately not @[simp], unlike the other apply_simp lemmas: its right-hand side is the whole body written out, so letting it fire on its own would turn any goal mentioning an instantiated procedure into that body. Inlining a procedure is a step to ask for by name (simp [Neg_main.main.procedure.apply_simp]).

        @[simp]

        @[simp]: applying Neg_main to a tuple of its single parameter A — the record of its procedures Neg_main.main, each applied to the parameters it uses.

        This is the lemma that unfolds a module use: simp rewrites with it, then with the field lemmas of the module type (N.f.mk_simp) to get at the one procedure the goal is about, and then with Neg_main.main.apply_simp to fill that procedure's holes.

        The module declared by module Neg_main, abstracted over its single parameter A, which it takes as one right-nested tuple: Module.Arr (T₁ ×ₘ (… ×ₘ Tₙ)) M, with M the anonymous product of the procedures' own types, the declaration naming no module type.

        Applied to such a tuple it is the record of its procedures Neg_main.main, each applied to the parameters that procedure itself uses — which is what the @[simp] lemma Neg_main.apply_simp says.

        Equations
        Instances For
          theorem GaudisCrypt.EC.AdvAbsVal.Pr_mu_not {sig : ProcedureSignature} (p : Procedure sig) (args : sig.ParamType) (σ : VariableAssignment) (E : sig.ret → VariableAssignment → Prop) :
          ↑(p.Pr args σ fun (r : sig.ret) (g : VariableAssignment) => ¬E r g) = ↑(p.Pr args σ fun (x : sig.ret) (x_1 : VariableAssignment) => True) - ↑(p.Pr args σ E)

          EC's Pr[mu_not]: the probability of !E is that of true minus that of E.

          theorem GaudisCrypt.EC.AdvAbsVal.Neg_A (A : Adv) [Module.Declared A ⊥] :
          equiv[ Neg_main(A).main ~ A : ={(FVP.fvP A).touched_getter} ==> §res{1} = !§res{2} ]

          EC's equiv Neg_A (A<:Adv) : Neg_main(A).main ~ A.main : ={glob A} ==> res{1} = !res{2}.

          theorem GaudisCrypt.EC.AdvAbsVal.Neg_A_Pr (A : Adv) [Module.Declared A ⊥] (m : VariableAssignment) :
          Pr[ Neg_main(A).main () @ &m : §res = true ] = Pr[ A () @ &m : ¬§res = true ]

          EC's lemma Neg_A_Pr (A<:Adv) &m: Pr[Neg_main(A).main() @ &m : res] = Pr[A.main() @ &m : !res].

          theorem GaudisCrypt.EC.AdvAbsVal.Neg_A_Pr_minus (A : Adv) [Module.Declared A ⊥] (m : VariableAssignment) (Hl : (Module.Proc.procedure A).IsLossless) :
          Pr[ Neg_main(A).main () @ &m : §res = true ] = 1 - Pr[ A () @ &m : §res = true ]

          EC's lemma Neg_A_Pr_minus (A<:Adv) &m: islossless A.main => Pr[Neg_main(A).main() @ &m : res] = 1%r - Pr[A.main() @ &m : res].

          theorem GaudisCrypt.EC.AdvAbsVal.abs_val (P : ℝ → Prop) (HP : ∀ (m : VariableAssignment) (A : Adv) [Module.Declared A ⊥], P (Pr[ A () @ &m : §res = true ] - 1 / 2)) (m : VariableAssignment) (A : Adv) [Module.Declared A ⊥] (Hl : (Module.Proc.procedure A).IsLossless) :
          P |Pr[ A () @ &m : §res = true ] - 1 / 2|

          EC's lemma abs_val (P:real -> bool): (forall &m (A <: Adv), P (Pr[A.main() @ &m : res] - 1%r/2%r)) => forall &m (A <: Adv), islossless A.main => P (|Pr[A.main() @ &m : res] - 1%r/2%r|)`.