Documentation

GaudisCrypt.Examples.WhileSampling

Sampling until a test fails terminates (EasyCrypt examples/WhileSampling.ec) #

Draw from a lossless distribution until a test fails; if the test fails with positive probability, the loop terminates with probability 1. EC's file, line by line; its one lemma, Sample_lossless, is proven with EC's script.

Translation:

Gap list:

EC's type t. op sample: t distr. axiom sample_ll: is_lossless sample. op test: t -> bool. axiom pr_ntest: 0%r < mu sample (predC test).

Instances
    noncomputable def GaudisCrypt.Examples.WhileSampling.Sample {t : Type} [_gaudiParam0 : Inhabited t] [_gaudiParam1 : Params t] :

    The module declared by module Sample: the record of its procedures Sample.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 Sample.apply_simp to apply it with.

    Equations
    Instances For
      noncomputable def GaudisCrypt.Examples.WhileSampling.Sample.sample {t : Type} [_gaudiParam0 : Inhabited t] [_gaudiParam1 : Params t] :

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

      Equations
      Instances For
        theorem GaudisCrypt.Examples.WhileSampling.Sample.sample.procedure.apply_simp {t : Type} [_gaudiParam0 : Inhabited t] [_gaudiParam1 : Params t] (holeArgs✝ : HoleSigs.empty.Instantiation) :
        procedure.instantiate holeArgs✝ = proc () : t { var r : t; r <$ WhileSampling.sample; while (test §r) { r <$ WhileSampling.sample; } return §r }

        Instantiating the holes of Sample.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 [Sample.sample.procedure.apply_simp]).

        noncomputable def GaudisCrypt.Examples.WhileSampling.Sample.sample.procedure {t : Type} [_gaudiParam0 : Inhabited t] [_gaudiParam1 : Params t] :

        The body of proc sample of module Sample, 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 Sample.sample.procedure.apply_simp) rather than run. Use Sample.sample for this procedure as a module.

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

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