Documentation

GaudisCrypt.Lib.EC.DList

EasyCrypt's list distributions (theories/distributions/DList.ec) #

dlist d n samples n values from d, independently. The abstract theory Program's type t and operator d are section variables, so a clone is an application. Only what ported developments use is here.

noncomputable def GaudisCrypt.EC.dlist {α : Type} (d : SubProbability α) (n : ℤ) :

dlist d n: a list of n independent samples of d (the empty list for n ≤ 0).

Equations
Instances For
    noncomputable def GaudisCrypt.EC.dlist.go {α : Type} (d : SubProbability α) :

    dlist d n for n : ℕ.

    Equations
    Instances For
      theorem GaudisCrypt.EC.dlist0 {α : Type} (d : SubProbability α) (n : ℤ) (hn : n ≤ 0) :

      lemma dlist0: no samples for n <= 0.

      theorem GaudisCrypt.EC.dlist_succ {α : Type} (d : SubProbability α) (n : ℤ) (hn : 0 < n) :
      dlist d n = do let a ← d let l ← dlist d (n - 1) pure (a :: l)

      One sample, then n - 1 more (EC's dlistS, at n - 1, as a monadic bind).

      theorem GaudisCrypt.EC.dlist_go1E {α : Type} (d : SubProbability α) (xs : List α) :
      ↑(dlist.go d xs.length) {xs} = (List.map (fun (x : α) => ↑d {x}) xs).prod

      The point mass of dlist d at a list of its length: the product of the elements'.

      theorem GaudisCrypt.EC.dlist_go_supp {α : Type} (d : SubProbability α) (k : ℕ) (xs : List α) (h : xs.length ≠ k) :
      ↑(dlist.go d k) {xs} = 0

      dlist.go d k only gives lists of length k.

      theorem GaudisCrypt.EC.dlist_supp {α : Type} (d : SubProbability α) (n : ℤ) (xs : List α) (h : ↑xs.length ≠ max 0 n) :
      ↑(dlist d n) {xs} = 0

      lemma supp_dlist (one direction): dlist d n only gives lists of length max 0 n.

      theorem GaudisCrypt.EC.dlist1E {α : Type} (d : SubProbability α) (n : ℤ) (xs : List α) (h : ↑xs.length = n) :
      ↑(dlist d n) {xs} = (List.map (fun (x : α) => ↑d {x}) xs).prod

      lemma dlist1E (lists of the right size).

      theorem GaudisCrypt.EC.map_mu1_inj {α β : Type} (d : SubProbability α) {f : α → β} (hf : Function.Injective f) (x : α) :
      ↑(do let a ← d pure (f a)) {f x} = ↑d {x}

      The image of a distribution by an injective function, at an image point.

      @[simp]

      @[simp]: LoopSnoc.sample = Module.proc LoopSnoc.sample.procedure — true by definition, proc sample using no module parameter and so having no holes to fill.

      The body of proc sample of module LoopSnoc, as a procedure of its own: it calls no module parameter, so it has no holes.

      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 LoopSnoc.sample.procedure.apply_simp) rather than run. Use LoopSnoc.sample for this procedure as a module.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For
        theorem GaudisCrypt.EC.DList.Program.LoopSnoc.sample.procedure.apply_simp (t : Type) [_gaudiParam0 : Inhabited t] (d : SubProbability t) (holeArgs✝ : HoleSigs.empty.Instantiation) :
        (procedure t d).instantiate holeArgs✝ = proc (n : ℤ) : (List t) { var i : ℤ, l : List t, r : t; i <- 0; l <- []; while (decide (§i < §n)) { r <$ d; l <- §l ++ [§r]; i <- §i + 1; } return §l }

        Instantiating the holes of LoopSnoc.sample.procedure with a tuple holeArgs of procedures: the body of proc sample 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 [LoopSnoc.sample.procedure.apply_simp]).

        noncomputable def GaudisCrypt.EC.DList.Program.LoopSnoc (t : Type) [_gaudiParam0 : Inhabited t] (d : SubProbability t) :

        The module declared by module LoopSnoc: the record of its procedures LoopSnoc.sample.

        The declaration has no parameter list, so no procedure of it can call one either and the module is not a function — it is the plain record itself, and there is no LoopSnoc.apply_simp to apply it with.

        Equations
        Instances For
          noncomputable def GaudisCrypt.EC.DList.Program.LoopSnoc.sample (t : Type) [_gaudiParam0 : Inhabited t] (d : SubProbability t) :

          proc sample of module LoopSnoc as a module: Module.proc LoopSnoc.sample.procedure, of type Module.Proc (procsig …). It uses no module parameter, so it is not a function — LoopSnoc.sample.apply_simp says exactly that.

          Equations
          Instances For
            theorem GaudisCrypt.EC.DList.Program.LoopSnoc.sample_ewp (t : Type) [Inhabited t] (d : SubProbability t) (G : List t → VariableAssignment → ENNReal) (n : ℤ) (g : VariableAssignment) :
            (sample t d).procedure.ewp n G g = (dlist d n).expected fun (l : List t) => G l g

            LoopSnoc.sample n samples dlist d n (EC's Sample_LoopSnoc_eq, with Sample.sample n being r <$ dlist d n), as expectations.

            LoopSnoc.sample n's run: a sample of dlist d n, the globals kept.

            theorem GaudisCrypt.EC.DList.Program.LoopSnoc.pr_sample (t : Type) [Inhabited t] (d : SubProbability t) (n : ℤ) (m : VariableAssignment) (xs : List t) :
            ↑((sample t d).procedure.Pr n m fun (res : (procsig (ℤ) → List t).ret) (x : VariableAssignment) => res = xs) = ↑(dlist d n) {xs}

            EC's pr_Sample for LoopSnoc (Sample_LoopSnoc_eq and pr_Sample): Pr[LoopSnoc.sample(n) @ &m : res = xs] = mu1 (dlist d n) xs.