Random oracles (EasyCrypt theories/crypto/ROM.eca) #
The module types of an oracle and the lazy random oracle Lazy.LRO, with its losslessness.
(FiniteEager, and the equivalences between the lazy and the eager oracle, are not ported:
Lib/EC/PROM.lean has EC's programmable oracles and their lazy/eager theory.)
The theory's types in_t, out_t, d_in_t, d_out_t are outParams of the class Params,
its operator dout the class's field: a clone is clone import GaudisCrypt.EC.ROM as H with type in_t <- …, op dout <- …. The module variable LRO.m is a module_var.
EC's type in_t, out_t. op dout: in_t -> out_t distr. type d_in_t, d_out_t.
- dout : in_t → SubProbability out_t
Instances
@[simp]: POracle.mk (POracle.structure m) = m — rebuilding a module from its own fields gives that module back.
The field o of a module of type POracle: the projection onto component 0 of the right-nested tuple POracle.typeRep, as a chain of Module.fst'/Module.snd'. Tagged @[module_accessor].
POracle.o.mk_simp reads this field back off a module built by POracle.mk; POracle.o.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
Builds a module of type POracle from the record POracle.Structure of its fields, as a right-nested Module.pair'. @[reducible].
Inverse of POracle.structure (POracle.mk_destruct, POracle.destruct_mk); a single field of a module built this way is read back by the @[simp] lemmas POracle.o.mk_simp.
Equations
- GaudisCrypt.EC.ROM.POracle.mk theRecord✝ = theRecord✝.o
Instances For
What is derivable about the accessor POracle.o, bundled into one ModuleTypeUtilities (one name per field in the namespace, rather than one per fact):
POracle.o.utilities.accessorModule : POracle →ₘ …— the accessor as a module, a projection being a module morphism;POracle.o.utilities.apply_simp—Module.app POracle.o.utilities.accessorModule m = POracle.o m: applying that module is the accessor;POracle.o.utilities.expression_eq— the same at the level of expressions:(POracle.o m).expression = (POracle.o.utilities.proj m.expression).reduce.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The ModuleTypeRep underlying POracle, the module type declared by moduletype POracle: the right-nested product of its 1 field types, in declaration order.
POracle is by definition Module POracle.typeRep.
Equations
Instances For
The record of the fields of a module of type POracle: the fields o, one per moduletype field, each of that field's own module type.
POracle.mk turns such a record into a POracle, POracle.structure turns a POracle back into one.
Instances For
The IsModule POracle instance: POracle is a module type, with representation POracle.typeRep.
It is what lets the name POracle stand where a module type is expected — in Module.Arr/Module.Prod (→ₘ/×ₘ), say — which the underlying Module POracle.typeRep would do on its own but POracle, a plain (non-reducible) def, would not.
Equations
- GaudisCrypt.EC.ROM.instIsModulePOracle = { moduleTypeRep := GaudisCrypt.EC.ROM.POracle.typeRep, isModule := ⋯ }
The module type declared by moduletype POracle, with fields o: the type Module POracle.typeRep of modules that are a right-nested tuple of the field types.
Build one from a record of its fields with POracle.mk, read a single field off one with the accessors POracle.o, and get the whole record back with POracle.structure.
Instances For
The record of a module's fields: POracle.structure m is POracle.Structure.mk applied to POracle.o of m.
Inverse of POracle.mk (POracle.mk_destruct, POracle.destruct_mk).
Instances For
@[simp]: POracle.structure (POracle.mk r) = r — destructing a module built from a record gives that record back.
@[simp]: reading the field o back off a module built from a record — POracle.o (POracle.mk r) = r.o.
It is what carries the right-hand side of an X.apply_simp (which is an POracle.mk) on to the field the caller actually asked for, so that simp chains X.apply_simp into X.o.apply_simp.
A Distinguisher (or distinguishing context) is a single algorithm that has access to an
oracle, and has some input/output behaviour: EC's module type Distinguisher (H : POracle) = { proc run(_ : d_in_t): d_out_t }.
Equations
Instances For
Builds a module of type Oracle from the record Oracle.Structure of its fields, as a right-nested Module.pair'. @[reducible].
Inverse of Oracle.structure (Oracle.mk_destruct, Oracle.destruct_mk); a single field of a module built this way is read back by the @[simp] lemmas Oracle.init.mk_simp, Oracle.o.mk_simp.
Equations
- GaudisCrypt.EC.ROM.Oracle.mk theRecord✝ = GaudisCrypt.Module.pair' theRecord✝.init theRecord✝.o
Instances For
@[simp]: Oracle.mk (Oracle.structure m) = m — rebuilding a module from its own fields gives that module back.
The IsModule Oracle instance: Oracle is a module type, with representation Oracle.typeRep.
It is what lets the name Oracle stand where a module type is expected — in Module.Arr/Module.Prod (→ₘ/×ₘ), say — which the underlying Module Oracle.typeRep would do on its own but Oracle, a plain (non-reducible) def, would not.
Equations
- GaudisCrypt.EC.ROM.instIsModuleOracle = { moduleTypeRep := GaudisCrypt.EC.ROM.Oracle.typeRep, isModule := ⋯ }
@[simp]: reading the field o back off a module built from a record — Oracle.o (Oracle.mk r) = r.o.
It is what carries the right-hand side of an X.apply_simp (which is an Oracle.mk) on to the field the caller actually asked for, so that simp chains X.apply_simp into X.o.apply_simp.
What is derivable about the accessor Oracle.o, bundled into one ModuleTypeUtilities (one name per field in the namespace, rather than one per fact):
Oracle.o.utilities.accessorModule : Oracle →ₘ …— the accessor as a module, a projection being a module morphism;Oracle.o.utilities.apply_simp—Module.app Oracle.o.utilities.accessorModule m = Oracle.o m: applying that module is the accessor;Oracle.o.utilities.expression_eq— the same at the level of expressions:(Oracle.o m).expression = (Oracle.o.utilities.proj m.expression).reduce.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The record of the fields of a module of type Oracle: the fields init, o, one per moduletype field, each of that field's own module type.
Oracle.mk turns such a record into a Oracle, Oracle.structure turns a Oracle back into one.
Instances For
What is derivable about the accessor Oracle.init, bundled into one ModuleTypeUtilities (one name per field in the namespace, rather than one per fact):
Oracle.init.utilities.accessorModule : Oracle →ₘ …— the accessor as a module, a projection being a module morphism;Oracle.init.utilities.apply_simp—Module.app Oracle.init.utilities.accessorModule m = Oracle.init m: applying that module is the accessor;Oracle.init.utilities.expression_eq— the same at the level of expressions:(Oracle.init m).expression = (Oracle.init.utilities.proj m.expression).reduce.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The field o of a module of type Oracle: the projection onto component 1 of the right-nested tuple Oracle.typeRep, as a chain of Module.fst'/Module.snd'. Tagged @[module_accessor].
Oracle.o.mk_simp reads this field back off a module built by Oracle.mk; Oracle.o.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).
Equations
- theModule✝.o = GaudisCrypt.Module.snd' theModule✝
Instances For
The module type declared by moduletype Oracle, with fields init, o: the type Module Oracle.typeRep of modules that are a right-nested tuple of the field types.
Build one from a record of its fields with Oracle.mk, read a single field off one with the accessors Oracle.init, Oracle.o, and get the whole record back with Oracle.structure.
Instances For
@[simp]: reading the field init back off a module built from a record — Oracle.init (Oracle.mk r) = r.init.
It is what carries the right-hand side of an X.apply_simp (which is an Oracle.mk) on to the field the caller actually asked for, so that simp chains X.apply_simp into X.init.apply_simp.
The field init of a module of type Oracle: the projection onto component 0 of the right-nested tuple Oracle.typeRep, as a chain of Module.fst'/Module.snd'. Tagged @[module_accessor].
Oracle.init.mk_simp reads this field back off a module built by Oracle.mk; Oracle.init.utilities has the accessor as a module, and the lemmas about it.
It takes no parameters (recorded in @[gaudiProcParamNames]).
Equations
- theModule✝.init = GaudisCrypt.Module.fst' theModule✝
Instances For
The ModuleTypeRep underlying Oracle, the module type declared by moduletype Oracle: the right-nested product of its 2 field types, in declaration order.
Oracle is by definition Module Oracle.typeRep.
Equations
Instances For
The record of a module's fields: Oracle.structure m is Oracle.Structure.mk applied to Oracle.init, Oracle.o of m.
Inverse of Oracle.mk (Oracle.mk_destruct, Oracle.destruct_mk).
Instances For
@[simp]: Oracle.structure (Oracle.mk r) = r — destructing a module built from a record gives that record back.
An Oracle is a POracle (its o).
Equations
- GaudisCrypt.EC.ROM.instCoeOraclePOracle = { coe := fun (s : GaudisCrypt.EC.ROM.Oracle) => GaudisCrypt.EC.ROM.POracle.mk { o := s.o } }
@[simp]: applying Exp to a tuple of its 2 parameters H, D — the record of its procedures Exp.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 Exp.main.apply_simp to fill that procedure's holes.
The module declared by module Exp, abstracted over its 2 parameters H, D, 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 Exp.main, each applied to the parameters that procedure itself uses — which is what the @[simp] lemma Exp.apply_simp says.
Equations
Instances For
@[simp]: applying Exp.main to the parameters proc main uses (H, D) is Module.proc (Exp.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 Exp.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 [Exp.main.procedure.apply_simp]).
proc main of module Exp as a module, abstracted over the module parameters it uses (H, D, in declaration order): Module.Arr … (Module.Proc (procsig …)).
Apply it with the @[simp] lemma Exp.main.apply_simp, which fills the holes of Exp.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 Exp, as a procedure of its own: the 2 calls it makes to module parameters (H, D) are its holes, in the order the body makes them.
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 Exp.main.procedure.apply_simp) rather than run. Use Exp.main for this procedure as a module.
Equations
- One or more equations did not get rendered due to their size.
Instances For
theory Lazy #
Equations
- GaudisCrypt.EC.ROM.Lazy.LRO.m = GaudisCrypt.varLens (GaudisCrypt.VariableName.mk "GaudisCrypt.EC.ROM.Lazy.LRO.m" (GaudisCrypt.EC.FMap in_t out_t))
Instances For
The body of proc o of module LRO, 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 LRO.o.procedure.apply_simp) rather than run. Use LRO.o 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 LRO.o.procedure with a tuple holeArgs of procedures: the body of proc o 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 [LRO.o.procedure.apply_simp]).
The module declared by module LRO: the record of its procedures LRO.init, LRO.o.
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 LRO.apply_simp to apply it with.
Equations
Instances For
proc o of module LRO as a module: Module.proc LRO.o.procedure, of type Module.Proc (procsig …). It uses no module parameter, so it is not a function — LRO.o.apply_simp says exactly that.
Equations
Instances For
proc init of module LRO as a module: Module.proc LRO.init.procedure, of type Module.Proc (procsig …). It uses no module parameter, so it is not a function — LRO.init.apply_simp says exactly that.
Equations
Instances For
@[simp]: LRO.o = Module.proc LRO.o.procedure — true by definition, proc o using no module parameter and so having no holes to fill.
The body of proc init of module LRO, 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 LRO.init.procedure.apply_simp) rather than run. Use LRO.init for this procedure as a module.
Equations
- GaudisCrypt.EC.ROM.Lazy.LRO.init.procedure = proc () : Unit { GaudisCrypt.EC.ROM.Lazy.LRO.m <- GaudisCrypt.EC.FMap.empty; return () }
Instances For
Instantiating the holes of LRO.init.procedure with a tuple holeArgs of procedures: the body of proc init 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 [LRO.init.procedure.apply_simp]).
@[simp]: LRO.init = Module.proc LRO.init.procedure — true by definition, proc init using no module parameter and so having no holes to fill.
glob LRO: its map LRO.m (read off the code; for the footprint tactics).
EC's lemma LRO_init_ll : islossless LRO.init.
EC's lemma LRO_o_ll : (forall x, is_lossless (dout x)) => islossless LRO.o.