Documentation

GaudisCrypt.Syntax.PRHLSyntaxTest

Smoke tests for equiv[ … ] (Syntax/PRHLSyntax.lean).

Equations
Instances For
    instance GaudisCrypt.PRHLSyntaxTest.instIsGlobalVarNatGMk :
    g.IsGlobalVar (VariableName.mk "GaudisCrypt.PRHLSyntaxTest.g" ℕ)

    Printing: sided reads print as §x{1}/§x{2}, each side with its own vars.

    @[implicit_reducible]

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

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

    Equations

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

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

    Instances For

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

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

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

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

        Equations
        Instances For

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

          T.f.mk_simp reads this field back off a module built by T.mk; T.f.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✝.f = theModule✝
          Instances For

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

            T is by definition Module T.typeRep.

            Equations
            Instances For
              @[reducible]

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

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

              Equations
              Instances For
                @[simp]
                theorem GaudisCrypt.PRHLSyntaxTest.T.mk_destruct (theRecord✝ : Structure) :
                (mk theRecord✝).structure = theRecord✝

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

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

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

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

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

                Equations
                Instances For
                  @[simp]
                  theorem GaudisCrypt.PRHLSyntaxTest.T.f.mk_simp (theRecord✝ : Structure) :
                  (mk theRecord✝).f = theRecord✝.f

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

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

                  theorem GaudisCrypt.PRHLSyntaxTest.M.f.procedure.apply_simp (holeArgs✝ : HoleSigs.empty.Instantiation) :
                  procedure.instantiate holeArgs✝ = proc (n : ℕ) : ℕ { g <- §n; return §n + 1 }

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

                  noncomputable def GaudisCrypt.PRHLSyntaxTest.M :

                  The module declared by module M: the record of its procedures M.f.

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

                  Equations
                  Instances For

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

                    Equations
                    Instances For

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

                      Equations
                      Instances For
                        @[simp]

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

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

                        Equations
                        Instances For

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

                          Equations
                          Instances For
                            @[simp]

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

                            The module declared by module M2: the record of its procedures M2.h.

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

                            Equations
                            Instances For
                              theorem GaudisCrypt.PRHLSyntaxTest.M2.h.procedure.apply_simp (holeArgs✝ : HoleSigs.empty.Instantiation) :
                              procedure.instantiate holeArgs✝ = proc (a : ℕ, b : ℕ) : ℕ { skip; return §a + §b }

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