EasyCrypt's pseudo-random permutations (theories/crypto/PRP.eca) #
The abstract type D and the operator dD are Lean parameters, so EasyCrypt's
clone PRP with type D <- … and clone RP with op dD <- … are applications. So are the module
variables (RP.m, RP.mi): a clone declares its own global_vars and passes them. The sub-theories
StrongPRP and RP are namespaces. Only what ported developments use is here (WeakPRP is not).
The field f of a module of type PRP: the projection onto component 1 of the right-nested tuple PRP.typeRep, as a chain of Module.fst'/Module.snd'. Tagged @[module_accessor].
PRP.f.mk_simp reads this field back off a module built by PRP.mk; PRP.f.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
- GaudisCrypt.EC.PRP.StrongPRP.PRP.f D theModule✝ = (GaudisCrypt.Module.snd' theModule✝).fst'
Instances For
@[simp]: PRP.structure (PRP.mk r) = r — destructing a module built from a record gives that record back.
What is derivable about the accessor PRP.fi, bundled into one ModuleTypeUtilities (one name per field in the namespace, rather than one per fact):
PRP.fi.utilities.accessorModule : PRP →ₘ …— the accessor as a module, a projection being a module morphism;PRP.fi.utilities.apply_simp—Module.app PRP.fi.utilities.accessorModule m = PRP.fi m: applying that module is the accessor;PRP.fi.utilities.expression_eq— the same at the level of expressions:(PRP.fi m).expression = (PRP.fi.utilities.proj m.expression).reduce.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The ModuleTypeRep underlying PRP, the module type declared by moduletype PRP: the right-nested product of its 3 field types, in declaration order.
PRP is by definition Module PRP.typeRep.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The IsModule PRP instance: PRP is a module type, with representation PRP.typeRep.
It is what lets the name PRP stand where a module type is expected — in Module.Arr/Module.Prod (→ₘ/×ₘ), say — which the underlying Module PRP.typeRep would do on its own but PRP, a plain (non-reducible) def, would not.
Equations
- GaudisCrypt.EC.PRP.StrongPRP.instIsModulePRP D = { moduleTypeRep := GaudisCrypt.EC.PRP.StrongPRP.PRP.typeRep D, isModule := ⋯ }
The field init of a module of type PRP: the projection onto component 0 of the right-nested tuple PRP.typeRep, as a chain of Module.fst'/Module.snd'. Tagged @[module_accessor].
PRP.init.mk_simp reads this field back off a module built by PRP.mk; PRP.init.utilities has the accessor as a module, and the lemmas about it.
It takes no parameters (recorded in @[gaudiProcParamNames]).
Equations
- GaudisCrypt.EC.PRP.StrongPRP.PRP.init D theModule✝ = GaudisCrypt.Module.fst' theModule✝
Instances For
Builds a module of type PRP from the record PRP.Structure of its fields, as a right-nested Module.pair'. @[reducible].
Inverse of PRP.structure (PRP.mk_destruct, PRP.destruct_mk); a single field of a module built this way is read back by the @[simp] lemmas PRP.init.mk_simp, PRP.f.mk_simp, PRP.fi.mk_simp.
Equations
- GaudisCrypt.EC.PRP.StrongPRP.PRP.mk D theRecord✝ = GaudisCrypt.Module.pair' theRecord✝.init (GaudisCrypt.Module.pair' theRecord✝.f theRecord✝.fi)
Instances For
@[simp]: reading the field fi back off a module built from a record — PRP.fi (PRP.mk r) = r.fi.
It is what carries the right-hand side of an X.apply_simp (which is an PRP.mk) on to the field the caller actually asked for, so that simp chains X.apply_simp into X.fi.apply_simp.
The record of the fields of a module of type PRP: the fields init, f, fi, one per moduletype field, each of that field's own module type.
PRP.mk turns such a record into a PRP, PRP.structure turns a PRP back into one.
Instances For
What is derivable about the accessor PRP.init, bundled into one ModuleTypeUtilities (one name per field in the namespace, rather than one per fact):
PRP.init.utilities.accessorModule : PRP →ₘ …— the accessor as a module, a projection being a module morphism;PRP.init.utilities.apply_simp—Module.app PRP.init.utilities.accessorModule m = PRP.init m: applying that module is the accessor;PRP.init.utilities.expression_eq— the same at the level of expressions:(PRP.init m).expression = (PRP.init.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: PRP.structure m is PRP.Structure.mk applied to PRP.init, PRP.f, PRP.fi of m.
Inverse of PRP.mk (PRP.mk_destruct, PRP.destruct_mk).
Equations
- One or more equations did not get rendered due to their size.
Instances For
The module type declared by moduletype PRP, with fields init, f, fi: the type Module PRP.typeRep of modules that are a right-nested tuple of the field types.
Build one from a record of its fields with PRP.mk, read a single field off one with the accessors PRP.init, PRP.f, PRP.fi, and get the whole record back with PRP.structure.
Equations
Instances For
@[simp]: reading the field f back off a module built from a record — PRP.f (PRP.mk r) = r.f.
It is what carries the right-hand side of an X.apply_simp (which is an PRP.mk) on to the field the caller actually asked for, so that simp chains X.apply_simp into X.f.apply_simp.
What is derivable about the accessor PRP.f, bundled into one ModuleTypeUtilities (one name per field in the namespace, rather than one per fact):
PRP.f.utilities.accessorModule : PRP →ₘ …— the accessor as a module, a projection being a module morphism;PRP.f.utilities.apply_simp—Module.app PRP.f.utilities.accessorModule m = PRP.f m: applying that module is the accessor;PRP.f.utilities.expression_eq— the same at the level of expressions:(PRP.f m).expression = (PRP.f.utilities.proj m.expression).reduce.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The field fi of a module of type PRP: the projection onto component 2 of the right-nested tuple PRP.typeRep, as a chain of Module.fst'/Module.snd'. Tagged @[module_accessor].
PRP.fi.mk_simp reads this field back off a module built by PRP.mk; PRP.fi.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
- GaudisCrypt.EC.PRP.StrongPRP.PRP.fi D theModule✝ = (GaudisCrypt.Module.snd' theModule✝).snd'
Instances For
@[simp]: PRP.mk (PRP.structure m) = m — rebuilding a module from its own fields gives that module back.
@[simp]: reading the field init back off a module built from a record — PRP.init (PRP.mk r) = r.init.
It is what carries the right-hand side of an X.apply_simp (which is an PRP.mk) on to the field the caller actually asked for, so that simp chains X.apply_simp into X.init.apply_simp.
The record of a module's fields: SPRP_Oracles.structure m is SPRP_Oracles.Structure.mk applied to SPRP_Oracles.f, SPRP_Oracles.fi of m.
Inverse of SPRP_Oracles.mk (SPRP_Oracles.mk_destruct, SPRP_Oracles.destruct_mk).
Equations
- One or more equations did not get rendered due to their size.
Instances For
The module type declared by moduletype SPRP_Oracles, with fields f, fi: the type Module SPRP_Oracles.typeRep of modules that are a right-nested tuple of the field types.
Build one from a record of its fields with SPRP_Oracles.mk, read a single field off one with the accessors SPRP_Oracles.f, SPRP_Oracles.fi, and get the whole record back with SPRP_Oracles.structure.
Equations
Instances For
Builds a module of type SPRP_Oracles from the record SPRP_Oracles.Structure of its fields, as a right-nested Module.pair'. @[reducible].
Inverse of SPRP_Oracles.structure (SPRP_Oracles.mk_destruct, SPRP_Oracles.destruct_mk); a single field of a module built this way is read back by the @[simp] lemmas SPRP_Oracles.f.mk_simp, SPRP_Oracles.fi.mk_simp.
Equations
- GaudisCrypt.EC.PRP.StrongPRP.SPRP_Oracles.mk D theRecord✝ = GaudisCrypt.Module.pair' theRecord✝.f theRecord✝.fi
Instances For
@[simp]: reading the field fi back off a module built from a record — SPRP_Oracles.fi (SPRP_Oracles.mk r) = r.fi.
It is what carries the right-hand side of an X.apply_simp (which is an SPRP_Oracles.mk) on to the field the caller actually asked for, so that simp chains X.apply_simp into X.fi.apply_simp.
The field fi of a module of type SPRP_Oracles: the projection onto component 1 of the right-nested tuple SPRP_Oracles.typeRep, as a chain of Module.fst'/Module.snd'. Tagged @[module_accessor].
SPRP_Oracles.fi.mk_simp reads this field back off a module built by SPRP_Oracles.mk; SPRP_Oracles.fi.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
- GaudisCrypt.EC.PRP.StrongPRP.SPRP_Oracles.fi D theModule✝ = GaudisCrypt.Module.snd' theModule✝
Instances For
The field f of a module of type SPRP_Oracles: the projection onto component 0 of the right-nested tuple SPRP_Oracles.typeRep, as a chain of Module.fst'/Module.snd'. Tagged @[module_accessor].
SPRP_Oracles.f.mk_simp reads this field back off a module built by SPRP_Oracles.mk; SPRP_Oracles.f.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
- GaudisCrypt.EC.PRP.StrongPRP.SPRP_Oracles.f D theModule✝ = GaudisCrypt.Module.fst' theModule✝
Instances For
The IsModule SPRP_Oracles instance: SPRP_Oracles is a module type, with representation SPRP_Oracles.typeRep.
It is what lets the name SPRP_Oracles stand where a module type is expected — in Module.Arr/Module.Prod (→ₘ/×ₘ), say — which the underlying Module SPRP_Oracles.typeRep would do on its own but SPRP_Oracles, a plain (non-reducible) def, would not.
Equations
- GaudisCrypt.EC.PRP.StrongPRP.instIsModuleSPRP_Oracles D = { moduleTypeRep := GaudisCrypt.EC.PRP.StrongPRP.SPRP_Oracles.typeRep D, isModule := ⋯ }
What is derivable about the accessor SPRP_Oracles.f, bundled into one ModuleTypeUtilities (one name per field in the namespace, rather than one per fact):
SPRP_Oracles.f.utilities.accessorModule : SPRP_Oracles →ₘ …— the accessor as a module, a projection being a module morphism;SPRP_Oracles.f.utilities.apply_simp—Module.app SPRP_Oracles.f.utilities.accessorModule m = SPRP_Oracles.f m: applying that module is the accessor;SPRP_Oracles.f.utilities.expression_eq— the same at the level of expressions:(SPRP_Oracles.f m).expression = (SPRP_Oracles.f.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 SPRP_Oracles: the fields f, fi, one per moduletype field, each of that field's own module type.
SPRP_Oracles.mk turns such a record into a SPRP_Oracles, SPRP_Oracles.structure turns a SPRP_Oracles back into one.
Instances For
@[simp]: reading the field f back off a module built from a record — SPRP_Oracles.f (SPRP_Oracles.mk r) = r.f.
It is what carries the right-hand side of an X.apply_simp (which is an SPRP_Oracles.mk) on to the field the caller actually asked for, so that simp chains X.apply_simp into X.f.apply_simp.
The ModuleTypeRep underlying SPRP_Oracles, the module type declared by moduletype SPRP_Oracles: the right-nested product of its 2 field types, in declaration order.
SPRP_Oracles is by definition Module SPRP_Oracles.typeRep.
Equations
Instances For
What is derivable about the accessor SPRP_Oracles.fi, bundled into one ModuleTypeUtilities (one name per field in the namespace, rather than one per fact):
SPRP_Oracles.fi.utilities.accessorModule : SPRP_Oracles →ₘ …— the accessor as a module, a projection being a module morphism;SPRP_Oracles.fi.utilities.apply_simp—Module.app SPRP_Oracles.fi.utilities.accessorModule m = SPRP_Oracles.fi m: applying that module is the accessor;SPRP_Oracles.fi.utilities.expression_eq— the same at the level of expressions:(SPRP_Oracles.fi m).expression = (SPRP_Oracles.fi.utilities.proj m.expression).reduce.
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[simp]: SPRP_Oracles.mk (SPRP_Oracles.structure m) = m — rebuilding a module from its own fields gives that module back.
@[simp]: SPRP_Oracles.structure (SPRP_Oracles.mk r) = r — destructing a module built from a record gives that record back.
Instantiating the holes of IND.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 [IND.main.procedure.apply_simp]).
proc main of module IND as a module, abstracted over the module parameters it uses (P, Dist, in declaration order): Module.Arr … (Module.Proc (procsig …)).
Apply it with the @[simp] lemma IND.main.apply_simp, which fills the holes of IND.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 IND, as a procedure of its own: the 2 calls it makes to module parameters (P, Dist) 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 IND.main.procedure.apply_simp) rather than run. Use IND.main for this procedure as a module.
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[simp]: applying IND to a tuple of its 2 parameters P, Dist — the record of its procedures IND.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 IND.main.apply_simp to fill that procedure's holes.
The module declared by module IND, abstracted over its 2 parameters P, Dist, 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 IND.main, each applied to the parameters that procedure itself uses — which is what the @[simp] lemma IND.apply_simp says.
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[simp]: applying IND.main to the parameters proc main uses (P, Dist) is Module.proc (IND.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 variables RP.m, RP.mi are parameters: each clone declares its own (EasyCrypt's
clone RP as Perm has Perm.m, Perm.mi), so two clones never share them.
@[simp]: RP.f = Module.proc RP.f.procedure — true by definition, proc f using no module parameter and so having no holes to fill.
The body of proc fi of module RP, 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 RP.fi.procedure.apply_simp) rather than run. Use RP.fi for this procedure as a module.
Equations
- One or more equations did not get rendered due to their size.
Instances For
proc fi of module RP as a module: Module.proc RP.fi.procedure, of type Module.Proc (procsig …). It uses no module parameter, so it is not a function — RP.fi.apply_simp says exactly that.
Equations
- GaudisCrypt.EC.PRP.RP.RP.fi D dD m mi = GaudisCrypt.Module.proc (GaudisCrypt.EC.PRP.RP.RP.fi.procedure D dD m mi)
Instances For
Instantiating the holes of RP.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 [RP.init.procedure.apply_simp]).
@[simp]: RP.init = Module.proc RP.init.procedure — true by definition, proc init using no module parameter and so having no holes to fill.
The module declared by module RP: the record of its procedures RP.init, RP.f, RP.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 RP.apply_simp to apply it with.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Instantiating the holes of RP.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 [RP.fi.procedure.apply_simp]).
The body of proc init of module RP, 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 RP.init.procedure.apply_simp) rather than run. Use RP.init for this procedure as a module.
Equations
- GaudisCrypt.EC.PRP.RP.RP.init.procedure D dD m mi = proc () : Unit { m <- GaudisCrypt.EC.FMap.empty; mi <- GaudisCrypt.EC.FMap.empty; return () }
Instances For
proc init of module RP as a module: Module.proc RP.init.procedure, of type Module.Proc (procsig …). It uses no module parameter, so it is not a function — RP.init.apply_simp says exactly that.
Equations
- GaudisCrypt.EC.PRP.RP.RP.init D dD m mi = GaudisCrypt.Module.proc (GaudisCrypt.EC.PRP.RP.RP.init.procedure D dD m mi)
Instances For
Instantiating the holes of RP.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 [RP.f.procedure.apply_simp]).
The body of proc f of module RP, 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 RP.f.procedure.apply_simp) rather than run. Use RP.f for this procedure as a module.
Equations
- One or more equations did not get rendered due to their size.
Instances For
proc f of module RP as a module: Module.proc RP.f.procedure, of type Module.Proc (procsig …). It uses no module parameter, so it is not a function — RP.f.apply_simp says exactly that.
Equations
- GaudisCrypt.EC.PRP.RP.RP.f D dD m mi = GaudisCrypt.Module.proc (GaudisCrypt.EC.PRP.RP.RP.f.procedure D dD m mi)
Instances For
@[simp]: RP.fi = Module.proc RP.fi.procedure — true by definition, proc fi using no module parameter and so having no holes to fill.
lemma f_ll: is_full dD => islossless RP.f (with the theory's axiom dD_ll): RP.f
samples from dD \ rng RP.m, which keeps a value when RP.m misses the queried key
(endo_dom_rng).