Documentation

GaudisCrypt.Logic.PRHLWpTest

Tests of the relational tactics (Logic/PRHLWp.lean).

What is derivable about the accessor Adv.guess, bundled into one ModuleTypeUtilities (one name per field in the namespace, rather than one per fact):

  • Adv.guess.utilities.accessorModule : Adv →ₘ … — the accessor as a module, a projection being a module morphism;
  • Adv.guess.utilities.apply_simp — Module.app Adv.guess.utilities.accessorModule m = Adv.guess m: applying that module is the accessor;
  • Adv.guess.utilities.expression_eq — the same at the level of expressions: (Adv.guess m).expression = (Adv.guess.utilities.proj m.expression).reduce.
Equations
  • One or more equations did not get rendered due to their size.
Instances For
    @[simp]
    theorem GaudisCrypt.PRHLWpTest.Adv.guess.mk_simp (theRecord✝ : Structure) :
    (mk theRecord✝).guess = theRecord✝.guess

    @[simp]: reading the field guess back off a module built from a record — Adv.guess (Adv.mk r) = r.guess.

    It is what carries the right-hand side of an X.apply_simp (which is an Adv.mk) on to the field the caller actually asked for, so that simp chains X.apply_simp into X.guess.apply_simp.

    @[simp]
    theorem GaudisCrypt.PRHLWpTest.Adv.destruct_mk (theModule✝ : Adv) :
    mk theModule✝.structure = theModule✝

    @[simp]: Adv.mk (Adv.structure m) = m — rebuilding a module from its own fields gives that module back.

    @[simp]
    theorem GaudisCrypt.PRHLWpTest.Adv.mk_destruct (theRecord✝ : Structure) :
    (mk theRecord✝).structure = theRecord✝

    @[simp]: Adv.structure (Adv.mk r) = r — destructing a module built from a record gives that record back.

    @[reducible]

    Builds a module of type Adv from the record Adv.Structure of its fields, as a right-nested Module.pair'. @[reducible].

    Inverse of Adv.structure (Adv.mk_destruct, Adv.destruct_mk); a single field of a module built this way is read back by the @[simp] lemmas Adv.guess.mk_simp.

    Equations
    Instances For

      The field guess of a module of type Adv: the projection onto component 0 of the right-nested tuple Adv.typeRep, as a chain of Module.fst'/Module.snd'. Tagged @[module_accessor].

      Adv.guess.mk_simp reads this field back off a module built by Adv.mk; Adv.guess.utilities has the accessor as a module, and the lemmas about it.

      Its parameters are named x, in that order (recorded in @[gaudiProcParamNames], a ProcedureSignature holding only their types).

      Equations
      • theModule✝.guess = theModule✝
      Instances For

        The record of a module's fields: Adv.structure m is Adv.Structure.mk applied to Adv.guess of m.

        Inverse of Adv.mk (Adv.mk_destruct, Adv.destruct_mk).

        Equations
        Instances For

          The module type declared by moduletype Adv, with fields guess: the type Module Adv.typeRep of modules that are a right-nested tuple of the field types.

          Build one from a record of its fields with Adv.mk, read a single field off one with the accessors Adv.guess, and get the whole record back with Adv.structure.

          Equations
          Instances For

            The ModuleTypeRep underlying Adv, the module type declared by moduletype Adv: the right-nested product of its 1 field types, in declaration order.

            Adv is by definition Module Adv.typeRep.

            Equations
            Instances For
              @[implicit_reducible]

              The IsModule Adv instance: Adv is a module type, with representation Adv.typeRep.

              It is what lets the name Adv stand where a module type is expected — in Module.Arr/Module.Prod (→ₘ/×ₘ), say — which the underlying Module Adv.typeRep would do on its own but Adv, a plain (non-reducible) def, would not.

              Equations

              The record of the fields of a module of type Adv: the fields guess, one per moduletype field, each of that field's own module type.

              Adv.mk turns such a record into a Adv, Adv.structure turns a Adv back into one.

              Instances For

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

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

                  The module declared by module CondFlip: the record of its procedures CondFlip.run.

                  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 CondFlip.apply_simp to apply it with.

                  Equations
                  Instances For
                    @[simp]

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

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

                    Equations
                    Instances For
                      theorem GaudisCrypt.PRHLWpTest.CondFlip.run.procedure.apply_simp (holeArgs✝ : HoleSigs.empty.Instantiation) :
                      procedure.instantiate holeArgs✝ = proc () : Bool { var b : Bool, c : Bool; b <$ SubProbability.uniform; c <- false; if (§b) { c <$ SubProbability.uniform; } return §c }

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