Documentation

GaudisCrypt.Syntax.ModuleSubtypeTest

Tests for module_subtype #

@[simp]
theorem GaudisCrypt.ModuleSubtypeTest.Coin.neg.mk_simp (theRecord✝ : Structure) :
(mk theRecord✝).neg = theRecord✝.neg

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

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

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

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

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

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

It takes no parameters (recorded in @[gaudiProcParamNames]).

Equations
Instances For

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

    Coin is by definition Module Coin.typeRep.

    Equations
    Instances For
      @[reducible]

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

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

      Equations
      Instances For

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

        • Coin.neg.utilities.accessorModule : Coin →ₘ … — the accessor as a module, a projection being a module morphism;
        • Coin.neg.utilities.apply_simp — Module.app Coin.neg.utilities.accessorModule m = Coin.neg m: applying that module is the accessor;
        • Coin.neg.utilities.expression_eq — the same at the level of expressions: (Coin.neg m).expression = (Coin.neg.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 Coin, with fields flip, neg: the type Module Coin.typeRep of modules that are a right-nested tuple of the field types.

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

          Equations
          Instances For

            The record of a module's fields: Coin.structure m is Coin.Structure.mk applied to Coin.flip, Coin.neg of m.

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

            Equations
            Instances For
              @[implicit_reducible]

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

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

              Equations

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

              Coin.neg.mk_simp reads this field back off a module built by Coin.mk; Coin.neg.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
              Instances For

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

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

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

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

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

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

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

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

                  Instances For
                    @[implicit_reducible]

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

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

                    Equations
                    @[simp]
                    theorem GaudisCrypt.ModuleSubtypeTest.Flip.destruct_mk (theModule✝ : Flip) :
                    mk theModule✝.structure = theModule✝

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

                    @[reducible]

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

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

                    Equations
                    Instances For
                      @[simp]
                      theorem GaudisCrypt.ModuleSubtypeTest.Flip.flip.mk_simp (theRecord✝ : Structure) :
                      (mk theRecord✝).flip = theRecord✝.flip

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

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

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

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

                      Equations
                      Instances For

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

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

                        It takes no parameters (recorded in @[gaudiProcParamNames]).

                        Equations
                        • theModule✝.flip = theModule✝
                        Instances For

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

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

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

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

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

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

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

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

                              Instances For

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

                                Flip is by definition Module Flip.typeRep.

                                Equations
                                Instances For

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

                                  Equations
                                  Instances For
                                    @[simp]

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

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

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

                                    @[simp]

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

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

                                    Equations
                                    Instances For

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

                                      Equations
                                      Instances For

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

                                        Equations
                                        Instances For

                                          The module declared by module FairCoin: the record of its procedures FairCoin.flip, FairCoin.neg.

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

                                          Equations
                                          Instances For
                                            @[simp]

                                            @[simp]: applying UseFlip.main to the parameters proc main uses (F) is Module.proc (UseFlip.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.ModuleSubtypeTest.UseFlip.main.procedure.apply_simp (holeArgs✝ : (HoleSigs.cons (procsig () → Bool) HoleSigs.empty).Instantiation) :
                                            procedure.instantiate holeArgs✝ = proc () : Bool { var b : Bool; b <- call (holeArgs✝.lookup HoleIndex.zero) (); return §b }

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

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

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

                                              proc main of module UseFlip as a module, abstracted over the module parameters it uses (F, in declaration order): Module.Arr … (Module.Proc (procsig …)).

                                              Apply it with the @[simp] lemma UseFlip.main.apply_simp, which fills the holes of UseFlip.main.procedure with the callees the body called.

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

                                                The body of proc main of module UseFlip, as a procedure of its own: the one call it makes to a module parameter (F) 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 UseFlip.main.procedure.apply_simp) rather than run. Use UseFlip.main for this procedure as a module.

                                                Equations
                                                Instances For
                                                  @[simp]

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

                                                  @[simp]

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

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

                                                  Equations
                                                  Instances For

                                                    proc main of module Twice as a module, abstracted over the module parameters it uses (C, in declaration order): Module.Arr … (Module.Proc (procsig …)).

                                                    Apply it with the @[simp] lemma Twice.main.apply_simp, which fills the holes of Twice.main.procedure with the callees the body called.

                                                    Equations
                                                    • One or more equations did not get rendered due to their size.
                                                    Instances For
                                                      theorem GaudisCrypt.ModuleSubtypeTest.Twice.main.procedure.apply_simp (holeArgs✝ : (HoleSigs.cons (procsig () → Bool) HoleSigs.empty).Instantiation) :
                                                      procedure.instantiate holeArgs✝ = proc () : Bool { var b : Bool; b <- call (holeArgs✝.lookup HoleIndex.zero) (); return §b }

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

                                                      The body of proc main of module Twice, as a procedure of its own: the one call it makes to a module parameter (C) 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.main.procedure.apply_simp) rather than run. Use Twice.main for this procedure as a module.

                                                      Equations
                                                      Instances For
                                                        @[simp]

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