From the permutation to a random function (EasyCrypt proof/smart_counter/ConcreteF.eca) — #
EC-fidelity port
The real game with the ideal permutation is close to the same game with PF, a random function
with an inverse, up to the PRP/PRF switching bound (Real_Concrete).
Translation (as SmartCounter/SLCommon.lean):
local clone import Strong_RP_RF as Switching with type D <- state, op uD <- dstate, …is the namespaceSwitching: the clone's module variables (PRPi.m,ARP.coll,DBounder.FBounder.c, …)global_vars, its modules the library's (Lib/EC/Strong_RP_RF.lean) at them, its realized axioms lemmas. (EC'slocalhas no counterpart: the clone's names stay visible.)declare module D <: DISTINGUISHER {-Perm, -C, -PF, -Redo}anddeclare axiom D_llas in EC; the local modulesGReal',D'are definitions (D'withDa Lean parameter, asDRestr).
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's
declare module D <: DISTINGUISHER {-Perm, -C, -PF, -Redo}anddeclare axiom D_llare hypotheses of the lemmas. So are the local modules' parameters. local clone import Strong_RP_RF as Switching with type D <- state, op uD <- dstate, type K <- unit, op dK <- dunit tt, op q <- max_sizeis the namespaceSwitching, and its realized axiomsge0_q,uD_uf_fuare lemmas. The clone is local, so its module variables are lens parameters of the local declarations that mention them (exception E6).- EasyCrypt checks this file only up to an anomaly at line 418 (inside the proof of
Real_Concrete); seenotes/SHA3/README.md.
EC's PF.m.
Equations
- One or more equations did not get rendered due to their size.
Instances For
EC's PF.mi.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The body of proc init of module PF, 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 PF.init.procedure.apply_simp) rather than run. Use PF.init for this procedure as a module.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The body of proc fi of module PF, 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 PF.fi.procedure.apply_simp) rather than run. Use PF.fi for this procedure as a module.
Equations
- One or more equations did not get rendered due to their size.
Instances For
proc init of module PF as a module: Module.proc PF.init.procedure, of type Module.Proc (procsig …). It uses no module parameter, so it is not a function — PF.init.apply_simp says exactly that.
Equations
Instances For
@[simp]: PF.init = Module.proc PF.init.procedure — true by definition, proc init using no module parameter and so having no holes to fill.
Instantiating the holes of PF.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 [PF.f.procedure.apply_simp]).
@[simp]: PF.f = Module.proc PF.f.procedure — true by definition, proc f using no module parameter and so having no holes to fill.
proc fi of module PF as a module: Module.proc PF.fi.procedure, of type Module.Proc (procsig …). It uses no module parameter, so it is not a function — PF.fi.apply_simp says exactly that.
Equations
Instances For
The module declared by module PF: the record of its procedures PF.init, PF.f, PF.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 PF.apply_simp to apply it with.
Equations
Instances For
The body of proc f of module PF, 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 PF.f.procedure.apply_simp) rather than run. Use PF.f 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 PF.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 [PF.init.procedure.apply_simp]).
proc f of module PF as a module: Module.proc PF.f.procedure, of type Module.Proc (procsig …). It uses no module parameter, so it is not a function — PF.f.apply_simp says exactly that.
Equations
Instances For
Instantiating the holes of PF.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 [PF.fi.procedure.apply_simp]).
@[simp]: PF.fi = Module.proc PF.fi.procedure — true by definition, proc fi using no module parameter and so having no holes to fill.
module CF(D : DISTINGUISHER) = Indif(SqueezelessSponge(PF), PF, D).
Equations
- One or more equations did not get rendered due to their size.
Instances For
local clone import Strong_RP_RF as Switching with type D <- state, op uD <- dstate, type K <- unit, op dK <- (MUnit.dunit<:unit> tt), op q <- max_size.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- GaudisCrypt.SHA3.Pilot.ConcreteF.Switching.ARP.coll = GaudisCrypt.varLens (GaudisCrypt.VariableName.mk "GaudisCrypt.SHA3.Pilot.ConcreteF.Switching.ARP.coll" Bool)
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- GaudisCrypt.SHA3.Pilot.ConcreteF.Switching.DBounder.FBounder.c = GaudisCrypt.varLens (GaudisCrypt.VariableName.mk "GaudisCrypt.SHA3.Pilot.ConcreteF.Switching.DBounder.FBounder.c" ℤ)
Instances For
The clone's PRPi.PRPi (the theory's clone import RP as PRPi).
Equations
- One or more equations did not get rendered due to their size.
Instances For
The clone's ARP.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The clone's DBounder.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Instances For
Equations
Instances For
Equations
Instances For
Equations
Instances For
realize ge0_q by smt w=max_ge0.
realize uD_uf_fu: dstate is uniform, lossless and full.
The globs of SqueezelessSponge and Perm, which EC reads off their code
(Module.GlobBound: instance search derives the restrictions against them). Not EC lemmas.
EC's smt(domE mem_set get_setE take_size cat_take_drop) in DoubleBounding's conseq,
the facts smt_close does not find: the query bs₀ added, with its block sa.
EC's smt facts in DoubleBounding's second loop that smt_close does not find: the round
adds the prefix take (i+1) p to Redo.prefixes.
EC's facts in DoubleBounding's first loop: the prefixes of bs up to its longest queried
prefix are known (prefix_exchange moves the longest prefix from the queries to the prefixes).
EC's smt(mem_set mem_empty) on the initial maps: the keys of {[] ↦ w} are [], so are
their prefixes.
EC's facts in Real_Concrete's first step (the new query bs, Redo.prefixes from P to
R: P's entries kept, the prefixes of bs added, nothing else), the conseq goals
smt_close does not find (EC's progress bullets: two by hand, three smt).
EC's facts in Real_Concrete's first step, second loop: a round past the longest queried
prefix adds take (i+1) p, which was nowhere yet (EC's prefix_exchange).
EC's facts in Real_Concrete's first step, first loop: it stops exactly at the longest
queried prefix (EC's take_get_max_prefix, prefix_exchange).
A PRPSec.SPRP_Oracles is a DPRIMITIVE (its f, fi).
local module GReal' = Indif(FC(SqueezelessSponge(Perm)), PC(Perm), D).
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[simp]: applying D' to a tuple of its single parameter P' — the record of its procedures D'.distinguish, 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 D'.distinguish.apply_simp to fill that procedure's holes.
The body of proc distinguish of module D', as a procedure of its own: the one call it makes to a module parameter (P') 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 D'.distinguish.procedure.apply_simp) rather than run. Use D'.distinguish 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 D', abstracted over its single parameter P', 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 D'.distinguish, each applied to the parameters that procedure itself uses — which is what the @[simp] lemma D'.apply_simp says.
Equations
Instances For
@[simp]: applying D'.distinguish to the parameters proc distinguish uses (P') is Module.proc (D'.distinguish.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 D'.distinguish.procedure with a tuple holeArgs of procedures: the body of proc distinguish 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 [D'.distinguish.procedure.apply_simp]).
proc distinguish of module D' as a module, abstracted over the module parameters it uses (P', in declaration order): Module.Arr … (Module.Proc (procsig …)).
Apply it with the @[simp] lemma D'.distinguish.apply_simp, which fills the holes of D'.distinguish.procedure with the callees the body called.
Equations
- One or more equations did not get rendered due to their size.
Instances For
EC's local lemma DoubleBounding (P <: PRPSec.PRP {-D, -C, -DBounder, -Redo}) &m: Pr[PRPSec.IND(P,D').main() @ &m: res] = Pr[PRPSec.IND(P,DBounder(D')).main() @ &m: res].
The first step of EC's Real_Concrete (its have ->:): Pr[RealIndif(SqueezelessSponge, PC(Perm), D).main() @ &m: res /\ C.c <= max_size] = Pr[GReal'.main() @ &m: res /\ C.c <= max_size]; a theorem of its own (EC's proof, step for step).
The globs of the concrete modules, which EC reads off their code (Module.GlobBound:
instance search derives the restrictions against them). Not EC lemmas.
D'(D) touches D's variables, C's and Redo.prefixes. Not an EC lemma.
EC's glob D': glob D (the region R given for D; a declared module's is its glob) and
the variables of D''s code.
The clone's lemma Conclusion (D <: Distinguisher {-PRPi, -ARP, -DBounder}) &m: (forall (O <: SPRP_Oracles{-D}), islossless O.f => islossless O.fi => islossless D(O).distinguish) => |Pr[IND(PRPi,DBounder(D)).main() @ &m: res] -
Pr[IND(ARP,DBounder(D)).main() @ &m: res]| <= (q^2 - q)%r / 2%r * mu uD (pred1 witness): the library's (Lib/EC/Strong_RP_RF.lean) at the clone's variables. EC's restrictions are on EC's glob D (Module.ECGlob, a local module's globfrom its code):Doutside the clone's variables, the oraclesO <: SPRP_Oracles{-D}` declared against it.
EC's lemma Real_Concrete &m : Pr[GReal(D).main()@ &m: res /\ C.c <= max_size] <= Pr[CF(DRestr(D)).main()@ &m: res] + (max_size ^ 2 - max_size)%r / 2%r * mu dstate (pred1 witness).