Documentation

GaudisCrypt.Logic.ECCallTrueTest

Golden tests of equiv_call (_ : True), of byequiv on ≤, and of stmt_inline (M(A).f) #

through a module type

EC's call (_ : true) on the adversary; the events' implication of byequiv on Pr[…] ≤ Pr[…], closed as EC's => //; a procedure named by its module, called through the module type of an experiment's parameter (see Logic/ECAutoTest.lean for the format; scripts/update_golden.py refreshes the expected text).

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

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

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

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

Equations
Instances For
    @[simp]
    theorem GaudisCrypt.ECCallTrueTest.Guesser.guess.mk_simp (theRecord✝ : Structure) :
    (mk theRecord✝).guess = theRecord✝.guess

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

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

    @[implicit_reducible]

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

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

    Equations

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

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

    Equations
    Instances For

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

      • Guesser.guess.utilities.accessorModule : Guesser →ₘ … — the accessor as a module, a projection being a module morphism;
      • Guesser.guess.utilities.apply_simp — Module.app Guesser.guess.utilities.accessorModule m = Guesser.guess m: applying that module is the accessor;
      • Guesser.guess.utilities.expression_eq — the same at the level of expressions: (Guesser.guess m).expression = (Guesser.guess.utilities.proj m.expression).reduce.
      Equations
      • One or more equations did not get rendered due to their size.
      Instances For

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

        Guesser is by definition Module Guesser.typeRep.

        Equations
        Instances For

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

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

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

          Equations
          • theModule✝.guess = theModule✝
          Instances For

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

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

            Instances For
              @[simp]
              theorem GaudisCrypt.ECCallTrueTest.Guesser.destruct_mk (theModule✝ : Guesser) :
              mk theModule✝.structure = theModule✝

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

              @[reducible]

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

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

              Equations
              Instances For

                proc main of module Game 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 Game.main.apply_simp, which fills the holes of Game.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 Game.main to the parameters proc main uses (A) is Module.proc (Game.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.ECCallTrueTest.Game.main.procedure.apply_simp (holeArgs✝ : (HoleSigs.cons (procsig (ℕ) → Bool) HoleSigs.empty).Instantiation) :
                  procedure.instantiate holeArgs✝ = proc () : Bool { var k : ℕ, b : Bool; k <- 1; b <- call (holeArgs✝.lookup HoleIndex.zero) (§k); return §b }

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

                  The module declared by module Game, 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 Game.main, each applied to the parameters that procedure itself uses — which is what the @[simp] lemma Game.apply_simp says.

                  Equations
                  Instances For
                    @[simp]

                    @[simp]: applying Game to a tuple of its single parameter A — the record of its procedures Game.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 Game.main.apply_simp to fill that procedure's holes.

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

                    Equations
                    Instances For

                      proc guess of module Twice 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 Twice.guess.apply_simp, which fills the holes of Twice.guess.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 Twice to a tuple of its single parameter A — the record of its procedures Twice.guess, 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 Twice.guess.apply_simp to fill that procedure's holes.

                        The module declared by module Twice, 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 Twice.guess, each applied to the parameters that procedure itself uses — which is what the @[simp] lemma Twice.apply_simp says.

                        Equations
                        Instances For
                          theorem GaudisCrypt.ECCallTrueTest.Twice.guess.procedure.apply_simp (holeArgs✝ : (HoleSigs.cons (procsig (ℕ) → Bool) HoleSigs.empty).Instantiation) :
                          procedure.instantiate holeArgs✝ = proc (n : ℕ) : Bool { var b : Bool; b <- call (holeArgs✝.lookup HoleIndex.zero) (§n + §n); return §b }

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

                          @[simp]

                          @[simp]: applying Twice.guess to the parameters proc guess uses (A) is Module.proc (Twice.guess.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.

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

                          Equations
                          Instances For