Golden tests of proc, inline, call and sim #
Each test pins the goals a rule leaves on small modules: a concrete oracle (two spellings of it),
a game calling an abstract adversary with the oracle, and a declared adversary (see
Logic/ECAutoTest.lean for the format; scripts/update_golden.py refreshes the expected text).
Equations
- GaudisCrypt.ECCallsTest.cCount = GaudisCrypt.varLens (GaudisCrypt.VariableName.mk "GaudisCrypt.ECCallsTest.cCount" ℤ)
Instances For
Equations
- GaudisCrypt.ECCallsTest.cFlag = GaudisCrypt.varLens (GaudisCrypt.VariableName.mk "GaudisCrypt.ECCallsTest.cFlag" Bool)
Instances For
The ModuleTypeRep underlying Orc, the module type declared by moduletype Orc: the right-nested product of its 1 field types, in declaration order.
Orc is by definition Module Orc.typeRep.
Instances For
What is derivable about the accessor Orc.get, bundled into one ModuleTypeUtilities (one name per field in the namespace, rather than one per fact):
Orc.get.utilities.accessorModule : Orc →ₘ …— the accessor as a module, a projection being a module morphism;Orc.get.utilities.apply_simp—Module.app Orc.get.utilities.accessorModule m = Orc.get m: applying that module is the accessor;Orc.get.utilities.expression_eq— the same at the level of expressions:(Orc.get m).expression = (Orc.get.utilities.proj m.expression).reduce.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The IsModule Orc instance: Orc is a module type, with representation Orc.typeRep.
It is what lets the name Orc stand where a module type is expected — in Module.Arr/Module.Prod (→ₘ/×ₘ), say — which the underlying Module Orc.typeRep would do on its own but Orc, a plain (non-reducible) def, would not.
Equations
- GaudisCrypt.ECCallsTest.instIsModuleOrc = { moduleTypeRep := GaudisCrypt.ECCallsTest.Orc.typeRep, isModule := ⋯ }
The record of a module's fields: Orc.structure m is Orc.Structure.mk applied to Orc.get of m.
Inverse of Orc.mk (Orc.mk_destruct, Orc.destruct_mk).
Instances For
Builds a module of type Orc from the record Orc.Structure of its fields, as a right-nested Module.pair'. @[reducible].
Inverse of Orc.structure (Orc.mk_destruct, Orc.destruct_mk); a single field of a module built this way is read back by the @[simp] lemmas Orc.get.mk_simp.
Equations
- GaudisCrypt.ECCallsTest.Orc.mk theRecord✝ = theRecord✝.get
Instances For
@[simp]: Orc.structure (Orc.mk r) = r — destructing a module built from a record gives that record back.
The field get of a module of type Orc: the projection onto component 0 of the right-nested tuple Orc.typeRep, as a chain of Module.fst'/Module.snd'. Tagged @[module_accessor].
Orc.get.mk_simp reads this field back off a module built by Orc.mk; Orc.get.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).
Instances For
The module type declared by moduletype Orc, with fields get: the type Module Orc.typeRep of modules that are a right-nested tuple of the field types.
Build one from a record of its fields with Orc.mk, read a single field off one with the accessors Orc.get, and get the whole record back with Orc.structure.
Instances For
@[simp]: reading the field get back off a module built from a record — Orc.get (Orc.mk r) = r.get.
It is what carries the right-hand side of an X.apply_simp (which is an Orc.mk) on to the field the caller actually asked for, so that simp chains X.apply_simp into X.get.apply_simp.
An adversary with oracle access.
Equations
Instances For
The body of proc get of module Inc, 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 Inc.get.procedure.apply_simp) rather than run. Use Inc.get for this procedure as a module.
Equations
- GaudisCrypt.ECCallsTest.Inc.get.procedure = proc (x : ℤ) : ℤ { GaudisCrypt.ECCallsTest.cCount <- §GaudisCrypt.ECCallsTest.cCount + 1; return §x + §GaudisCrypt.ECCallsTest.cCount }
Instances For
proc get of module Inc as a module: Module.proc Inc.get.procedure, of type Module.Proc (procsig …). It uses no module parameter, so it is not a function — Inc.get.apply_simp says exactly that.
Equations
Instances For
@[simp]: Inc.get = Module.proc Inc.get.procedure — true by definition, proc get using no module parameter and so having no holes to fill.
The module declared by module Inc: the record of its procedures Inc.get.
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 Inc.apply_simp to apply it with.
Equations
Instances For
Instantiating the holes of Inc.get.procedure with a tuple holeArgs of procedures: the body of proc get 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 [Inc.get.procedure.apply_simp]).
proc get of module Inc2 as a module: Module.proc Inc2.get.procedure, of type Module.Proc (procsig …). It uses no module parameter, so it is not a function — Inc2.get.apply_simp says exactly that.
Equations
Instances For
@[simp]: Inc2.get = Module.proc Inc2.get.procedure — true by definition, proc get using no module parameter and so having no holes to fill.
The module declared by module Inc2: the record of its procedures Inc2.get.
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 Inc2.apply_simp to apply it with.
Equations
Instances For
Instantiating the holes of Inc2.get.procedure with a tuple holeArgs of procedures: the body of proc get 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 [Inc2.get.procedure.apply_simp]).
The body of proc get of module Inc2, 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 Inc2.get.procedure.apply_simp) rather than run. Use Inc2.get 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 Game, abstracted over its 2 parameters O, 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
- One or more equations did not get rendered due to their size.
Instances For
The body of proc main of module Game, as a procedure of its own: the one call it makes to a module parameter (O, 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
- GaudisCrypt.ECCallsTest.Game.main.procedure = proc () uses (_hole0 : () → ℤ) : ℤ { var r : ℤ; GaudisCrypt.ECCallsTest.cFlag <- true; r <- call _hole0 (); return §r }
Instances For
proc main of module Game as a module, abstracted over the module parameters it uses (O, 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
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]).
@[simp]: applying Game.main to the parameters proc main uses (O, 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.
@[simp]: applying Game to a tuple of its 2 parameters O, 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.
proc main of module Twice as a module, abstracted over the module parameters it uses (O, 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
The module declared by module Twice, abstracted over its single parameter O, 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
@[simp]: applying Twice to a tuple of its single parameter O — 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.
@[simp]: applying Twice.main to the parameters proc main uses (O) 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.
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 (O) 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
call on concrete callees #
The module declared by module Fw, abstracted over its single parameter O, 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 Fw.get, each applied to the parameters that procedure itself uses — which is what the @[simp] lemma Fw.apply_simp says.
Equations
Instances For
@[simp]: applying Fw to a tuple of its single parameter O — the record of its procedures Fw.get, 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 Fw.get.apply_simp to fill that procedure's holes.
@[simp]: the alias Fw.get, applied to the parameters its callee uses (O), is its callee, as written in the declaration.
proc get = …; of module Fw: an alias, EasyCrypt's proc get = M.g — the callee itself, as a module abstracted over the module parameters it uses (O, in declaration order). It has no Fw.get.procedure: applied with the @[simp] lemma Fw.get.apply_simp, it is the callee.
Equations
Instances For
@[simp]: applying FwT to a tuple of its single parameter O — the record of its procedures FwT.get, 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 FwT.get.apply_simp to fill that procedure's holes.
proc get = …; of module FwT: an alias, EasyCrypt's proc get = M.g — the callee itself, as a module abstracted over the module parameters it uses (O, in declaration order). It has no FwT.get.procedure: applied with the @[simp] lemma FwT.get.apply_simp, it is the callee.
Equations
Instances For
The module declared by module FwT, abstracted over its single parameter O, which it takes as one right-nested tuple: Module.Arr (T₁ ×ₘ (… ×ₘ Tₙ)) M, with M the module type it was declared with.
Applied to such a tuple it is the record of its procedures FwT.get, each applied to the parameters that procedure itself uses — which is what the @[simp] lemma FwT.apply_simp says.
Equations
Instances For
@[simp]: the alias FwT.get, applied to the parameters its callee uses (O), is its callee, as written in the declaration.
call on a declared adversary #
sim #
A declared adversary with a region for its glob (declare module … with glob R) #
The lemma's hypothesis restricts the oracles against the region R ({-R}), so that it applies
to an adversary built from a declared one (Logic/DeclareModule.lean).
EC's frame by writes: a callee that reads a variable without writing it keeps it #
Instantiating the holes of Peek.get.procedure with a tuple holeArgs of procedures: the body of proc get 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 [Peek.get.procedure.apply_simp]).
The body of proc get of module Peek, 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 Peek.get.procedure.apply_simp) rather than run. Use Peek.get 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 Peek: the record of its procedures Peek.get.
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 Peek.apply_simp to apply it with.
Equations
Instances For
@[simp]: Peek.get = Module.proc Peek.get.procedure — true by definition, proc get using no module parameter and so having no holes to fill.
proc get of module Peek as a module: Module.proc Peek.get.procedure, of type Module.Proc (procsig …). It uses no module parameter, so it is not a function — Peek.get.apply_simp says exactly that.
Equations
Instances For
Instantiating the holes of Once.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 [Once.main.procedure.apply_simp]).
@[simp]: applying Once.main to the parameters proc main uses (O) is Module.proc (Once.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 Once, abstracted over its single parameter O, 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 Once.main, each applied to the parameters that procedure itself uses — which is what the @[simp] lemma Once.apply_simp says.
Equations
Instances For
proc main of module Once as a module, abstracted over the module parameters it uses (O, in declaration order): Module.Arr … (Module.Proc (procsig …)).
Apply it with the @[simp] lemma Once.main.apply_simp, which fills the holes of Once.main.procedure with the callees the body called.
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[simp]: applying Once to a tuple of its single parameter O — the record of its procedures Once.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 Once.main.apply_simp to fill that procedure's holes.
The body of proc main of module Once, as a procedure of its own: the one call it makes to a module parameter (O) 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 Once.main.procedure.apply_simp) rather than run. Use Once.main for this procedure as a module.
Equations
Instances For
proc main of module Run as a module, abstracted over the module parameters it uses (O, A, in declaration order): Module.Arr … (Module.Proc (procsig …)).
Apply it with the @[simp] lemma Run.main.apply_simp, which fills the holes of Run.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 Run, as a procedure of its own: the one call it makes to a module parameter (O, 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 Run.main.procedure.apply_simp) rather than run. Use Run.main for this procedure as a module.
Equations
- GaudisCrypt.ECCallsTest.Run.main.procedure = proc () uses (_hole0 : () → ℤ) : ℤ { var r : ℤ; r <- call _hole0 (); return §r }
Instances For
The module declared by module Run, abstracted over its 2 parameters O, 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 Run.main, each applied to the parameters that procedure itself uses — which is what the @[simp] lemma Run.apply_simp says.
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[simp]: applying Run.main to the parameters proc main uses (O, A) is Module.proc (Run.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.
@[simp]: applying Run to a tuple of its 2 parameters O, A — the record of its procedures Run.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 Run.main.apply_simp to fill that procedure's holes.
Instantiating the holes of Run.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 [Run.main.procedure.apply_simp]).
A reducible alias of Inc.get (as a later port names an earlier port's procedure).