Documentation

GaudisCrypt.Examples.SHA3.SmartCounter.Gcol

The collision event of G1 (EasyCrypt proof/smart_counter/Gcol.eca) — EC-fidelity port #

Pr_G1col bounds the probability of G1.bcol by max_size · (2 max_size / 2^c), through the local game Gcol that counts the capacity samples. Over the old port's Handle declarations (as SmartCounter/Handle.lean).

Translation:

Declarations of the first port #

Definitions and plain lemmas of the first port of this file (2026-10/11) that the proofs below use; its program-logic proofs are gone.

The first port's translation notes (some mention declarations that went with its proofs):

The section PROOF #

theorem GaudisCrypt.SHA3.Gcol.card_rng_set {α β : Type} [DecidableEq α] [DecidableEq β] (m : EC.FMap α β) (x : α) (y : β) :
↑(m.set x y).frng.card ≤ ↑m.frng.card + 1

EC's Mu_mem.mu_mem for cdistr: a set of capacities has probability card S / 2^c.

The invariant of G1_col and the oracles' steps #

A variable's footprint below a join of footprints it is a joinand of (C.footprint unfolded).

Equations
Instances For

    Gap list (batch-fix later, see TRANSFER_SKILL.md §1.6):

    instance GaudisCrypt.SHA3.Pilot.Gcol.instIsGlobalVarIntCountMk :
    Gcol.count.IsGlobalVar (VariableName.mk "GaudisCrypt.SHA3.Pilot.Gcol.Gcol.count" ℤ)

    EC's Gcol.count.

    Equations
    Instances For

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

      @[simp]

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

      The body of proc sample_c of module Gcol.sample_c, 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 Gcol.sample_c.sample_c.procedure.apply_simp) rather than run. Use Gcol.sample_c.sample_c 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 Gcol.sample_c: the record of its procedures Gcol.sample_c.sample_c.

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

        Equations
        Instances For

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

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

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

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

            Equations
            Instances For

              Instantiating the holes of Gcol.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 [Gcol.M.f.procedure.apply_simp]).

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

              Equations
              Instances For
                theorem GaudisCrypt.SHA3.Pilot.Gcol.Gcol.S.f.procedure.apply_simp [SLCommon.Params] (holeArgs✝ : HoleSigs.empty.Instantiation) :
                procedure.instantiate holeArgs✝ = proc (x : SLCommon.state) : SLCommon.state { var y : SLCommon.state, hx2 : SLCommon.handle, p : List Common.block, v : Common.block, y1 : Common.block, y2 : Common.capacity, hy2 : SLCommon.handle; if (!decide (EC.FMap.dom §Handle.G1.m §x)) { y <- (Common.b0, Common.c0); if (!decide ((§Handle.FRO.m).rng ((§x).2, EC.PROM.Known))) { Handle.FRO.m <- (§Handle.FRO.m).set §Handle.G1.chandle ((§x).2, EC.PROM.Known); Handle.G1.chandle <- §Handle.G1.chandle + 1; } hx2 <- EC.oget (SLCommon.hinvK (§Handle.FRO.m) (§x).2); if (decide ((§Handle.G1.paths).dom (§x).2)) { p, v <- EC.oget ((§Handle.G1.paths).get (§x).2); y1 <- call (EC.PROM.FullRO.ROmap.get (List Common.block) Common.block SLCommon.F.RO).procedure (EC.rcons (§p) (§v +^ (§x).1)); y2 <- call sample_c.procedure (); } else { y1 <$ Common.bdistr; y2 <- call sample_c.procedure (); } y <- (§y1, §y2); if (decide (EC.FMap.dom §Handle.G1.mh ((§x).1, §hx2) ∧ (§Handle.FRO.m).in_dom_with (EC.oget (EC.FMap.get §Handle.G1.mh ((§x).1, §hx2))).2 EC.PROM.Unknown)) { hy2 <- (EC.oget (EC.FMap.get §Handle.G1.mh ((§x).1, §hx2))).2; y <- ((§y).1, (EC.oget ((§Handle.FRO.m).get §hy2)).1); Handle.FRO.m <- (§Handle.FRO.m).set §hy2 ((§y).2, EC.PROM.Known); Handle.G1.m <- EC.FMap.set §Handle.G1.m §x §y; Handle.G1.mi <- EC.FMap.set §Handle.G1.mi §y §x; } else { hy2 <- §Handle.G1.chandle; Handle.G1.chandle <- §Handle.G1.chandle + 1; Handle.FRO.m <- (§Handle.FRO.m).set §hy2 ((§y).2, EC.PROM.Known); Handle.G1.m <- EC.FMap.set §Handle.G1.m §x §y; Handle.G1.mh <- EC.FMap.set §Handle.G1.mh ((§x).1, §hx2) ((§y).1, §hy2); Handle.G1.mi <- EC.FMap.set §Handle.G1.mi §y §x; Handle.G1.mhi <- EC.FMap.set §Handle.G1.mhi ((§y).1, §hy2) ((§x).1, §hx2); } if (decide ((§Handle.G1.paths).dom (§x).2)) { p, v <- EC.oget ((§Handle.G1.paths).get (§x).2); Handle.G1.paths <- (§Handle.G1.paths).set (§y).2 (EC.rcons (§p) (§v +^ (§x).1), (§y).1); } } else { y <- EC.oget (EC.FMap.get §Handle.G1.m §x); } return §y }

                Instantiating the holes of Gcol.S.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 [Gcol.S.f.procedure.apply_simp]).

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

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

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

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

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

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

                    The module declared by module Gcol.S: the record of its procedures Gcol.S.f, Gcol.S.fi.

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

                    Equations
                    Instances For

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

                      Equations
                      Instances For
                        theorem GaudisCrypt.SHA3.Pilot.Gcol.Gcol.S.fi.procedure.apply_simp [SLCommon.Params] (holeArgs✝ : HoleSigs.empty.Instantiation) :
                        procedure.instantiate holeArgs✝ = proc (x : SLCommon.state) : SLCommon.state { var y : SLCommon.state, hx2 : SLCommon.handle, y1 : Common.block, y2 : Common.capacity, hy2 : SLCommon.handle; if (!decide (EC.FMap.dom §Handle.G1.mi §x)) { y <- (Common.b0, Common.c0); if (!decide ((§Handle.FRO.m).rng ((§x).2, EC.PROM.Known))) { Handle.FRO.m <- (§Handle.FRO.m).set §Handle.G1.chandle ((§x).2, EC.PROM.Known); Handle.G1.chandle <- §Handle.G1.chandle + 1; } hx2 <- EC.oget (SLCommon.hinvK (§Handle.FRO.m) (§x).2); y1 <$ Common.bdistr; y2 <- call sample_c.procedure (); y <- (§y1, §y2); if (decide (EC.FMap.dom §Handle.G1.mhi ((§x).1, §hx2) ∧ (§Handle.FRO.m).in_dom_with (EC.oget (EC.FMap.get §Handle.G1.mhi ((§x).1, §hx2))).2 EC.PROM.Unknown)) { y1, hy2 <- EC.oget (EC.FMap.get §Handle.G1.mhi ((§x).1, §hx2)); y <- ((§y).1, (EC.oget ((§Handle.FRO.m).get §hy2)).1); Handle.FRO.m <- (§Handle.FRO.m).set §hy2 ((§y).2, EC.PROM.Known); Handle.G1.mi <- EC.FMap.set §Handle.G1.mi §x §y; Handle.G1.m <- EC.FMap.set §Handle.G1.m §y §x; } else { hy2 <- §Handle.G1.chandle; Handle.G1.chandle <- §Handle.G1.chandle + 1; Handle.FRO.m <- (§Handle.FRO.m).set §hy2 ((§y).2, EC.PROM.Known); Handle.G1.mi <- EC.FMap.set §Handle.G1.mi §x §y; Handle.G1.mhi <- EC.FMap.set §Handle.G1.mhi ((§x).1, §hx2) ((§y).1, §hy2); Handle.G1.m <- EC.FMap.set §Handle.G1.m §y §x; Handle.G1.mh <- EC.FMap.set §Handle.G1.mh ((§y).1, §hy2) ((§x).1, §hx2); } } else { y <- EC.oget (EC.FMap.get §Handle.G1.mi §x); } return §y }

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

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

                        Equations
                        Instances For
                          @[simp]

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

                          The module declared by module Gcol: the record of its procedures Gcol.main.

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

                          Equations
                          Instances For

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

                            Equations
                            Instances For

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

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

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