EasyCrypt's declare module #
declare module A <: AdvPreimage «from» «to» {-RO, -Preimage}
declares an abstract module A of a module type for the rest of the section, with EasyCrypt's
restriction: A touches none of the globals of RO and Preimage. It is
variable (A : AdvPreimage «from» «to») [Module.Declared A S]
with S the join of those globals' footprints. Module.Declared A S bundles the two facts EC
takes for granted about a declared module: finitely many globals, and none of them in S. As
an instance-implicit section variable it is part of exactly the lemmas that mention A — EC's
generalization over A when the section is closed — and fp_disjoint reads it like the
restriction hypothesis FVP.fvP A ≤ Sᶜ it states.
The restriction. Each -X names a module or a global variable:
- a concrete module (a definition): its globals are the
global_vars its code mentions, through the modules it uses (EC'sglob Xof a concrete module is read off its code the same way); - a global variable: itself;
- a declared module (a section variable):
glob X, EC's restriction against an abstract module.
A region for glob A (exception E14 of the SHA-3 port).
declare module D <: DISTINGUISHER {-C, -Perm} with glob R
also declares a region R above D's footprint, restricted like D
(Module.ECGlob D R, Footprint.Restricted R S), and {-R} in a restriction names it:
variable (D_ll : ∀ (F <: DFUNCTIONALITY {-R}), ∀ (P <: DPRIMITIVE {-R}), … → islossless D(F, P).distinguish)
This is for a lemma that restricts other modules against glob D (EC's {-D} on a module bound in
a hypothesis) and is applied to a module built from a declared one, A(D'). EC's glob A(D') is
glob D' and the variables of A, by definition; here the footprint of an application is bounded
from above only, so {-A(D')} does not give {-D'}. Stated against R, the lemma is applied
with the region written out, glob D' ⊔ C.c.footprint (an instance Module.ECGlob (A D') _, and
Footprint.Restricted _ _ by ⟨by fp_finite, by fp_disjoint⟩). Applied to a declared module it
is applied with R its glob (Module.ECGlob.declared, Footprint.Restricted.glob_declared).
Representability (exception E2 of the SHA-3 port) is not a hypothesis: over a first-order
module type it is a theorem (Module.representable_of_firstOrder), and
Module.Declared.ecModule A ext gives Module.ECModule A ext with its side conditions
discharged by default (ext the module type's canonical one, as Oracle.ext is).
A is an EasyCrypt declared module restricted against S: finitely many globals (EC's
glob A is a set of variables), none of them in S.
- finite : (FVP.fvP A).FinitelySupported
Instances
S is a sub-join of S₀: every joinand of S is one of S₀ (or ⊥), found by instance
search on the two joins. What lets a module declared against S₀ be used where a lemma
declares it against less (Module.Declared.weaken): a lemma of a theory, used in a clone whose
declaration restricts more (EC's exact (RO_is_collision_resistant A &m)).
Instances
A module declared against S₀ is declared against any sub-join S of it. The declaration
is found first, its S₀ unknown (a local hypothesis: declare module's, an introduced binder's),
then S checked against it: the synthesis order the check would not accept.
Concrete modules: their glob read off their code #
EC checks a restriction against a concrete module from its code (glob Perm is Perm.m,
Perm.mi). Here a concrete module carries Module.GlobBound A B: its footprint within a join
B of global_vars (proven once, by fp_module, next to the module). Instance search then
derives Module.Declared for it, and for a declared module against the glob of a concrete
one, as EC does:
Footprint.Outside B S—B ≤ Sᶜover the joins:global_vars by theirLens.Disjointinstances, theglobof a declared module (its restriction), of a concrete one (its bound);Module.Declared.ofGlobBound— a concrete module is declared against what its bound stays outside;Footprint.Covers S₀ S— what stays outsideS₀(finitely supported) stays outsideS: the joinands ofS₀, and theglobof a concrete module whose bound is withinS₀(Module.Declared.weakenCovers,weakenextended).
A concrete module's footprint lies within B, a join of global_vars (fp_module): what
EC reads off the module's code. Not an EC notion.
- finite : (FVP.fvP A).FinitelySupported
Instances
B is a join of global_vars: finitely supported, and outside a finitely supported F,
outside glob F.
- finite : B.FinitelySupported
- le_compl_glob (F : Footprint VariableAssignment) : F.FinitelySupported → F ≤ Bᶜ → B ≤ F.globᶜ
Instances
B ≤ Sᶜ, by instance search over the two joins.
Instances
A module without globals (its bound is ⊥) stays outside everything.
Two global_vars: their Lens.Disjoint instance.
The glob of a declared module N: its restriction keeps it outside B.
The glob of a declared module N on the left: its restriction keeps the global_vars S
outside it.
The glob of a concrete module N, its bound B' outside B.
A concrete module is declared against what its bound stays outside (EC's check of a restriction from the module's code).
A concrete functor applied to a declared module is declared where both stay outside
(EC's restriction of F(A) from F's code and A's declaration).
EC's syntactic glob A: R, a region containing A's footprint, within the glob of a
finitely supported footprint (a declared module's glob, joined with global_vars). Given once
for a local module built from declared ones (EC's glob D' is glob D and the variables of
D''s code), where glob (fvP A) would not do: fvP of an application is only bounded
above.
- finite : (FVP.fvP A).FinitelySupported
- base : ∃ (GF : Footprint VariableAssignment), GF.FinitelySupported ∧ R ≤ GF.glob
Instances
A module is declared against what its EC glob stays outside (EC's restriction of a local
module, {-PRPi} on D').
The glob of a finitely supported footprint is finitely supported: within the same
variables.
What stays outside S₀ (a finitely supported footprint) stays outside S.
- le (F : Footprint VariableAssignment) : F.FinitelySupported → F ≤ S₀ᶜ → F ≤ Sᶜ
Instances
The glob of a concrete module whose bound lies within S₀ (EC: a module restricted
against Perm.m, Perm.mi is restricted against glob Perm).
Module.Declared.weaken, to what a declaration's set Covers: also the glob of the
concrete modules within it.
A region for glob A (declare module … with glob R) #
Footprint.Restricted R S (Logic/FootprintSolver.lean) is weakened like a declaration, and
gives the Footprint.Outside instances of R (so a module with Module.ECGlob A R is declared,
Module.Declared.ofECGlob).
A region restricted against S₀ is restricted against any sub-join S of it
(as Module.Declared.weaken).
Footprint.Restricted.weaken, to what the restriction Covers
(as Module.Declared.weakenCovers).
A restricted region stays outside the sub-joins of its restriction.
A declared module's glob is a restricted region: the lemma stated against a region is
applied to a declared module with R its glob.
Every procedure signature of holes has nonempty parameter and result types.
Equations
- GaudisCrypt.HoleSigs.empty.AllNonempty = True
- (GaudisCrypt.HoleSigs.cons s h).AllNonempty = (((∀ U ∈ s.params, Nonempty U) ∧ Nonempty s.ret) ∧ h.AllNonempty)
Instances For
Discharge (Module.moduleTypeRep T).FirstOrder for a literal module type: the constructor
lemmas, unification unfolding the type down to its representation.
Equations
- GaudisCrypt.tacticModule_first_order = Lean.ParserDescr.node `GaudisCrypt.tacticModule_first_order 1024 (Lean.ParserDescr.nonReservedSymbol "module_first_order" false)
Instances For
Discharge HoleSigs.AllNonempty holes for literal signatures: one goal per parameter and
result type, by instance search.
Equations
- GaudisCrypt.tacticHoles_nonempty = Lean.ParserDescr.node `GaudisCrypt.tacticHoles_nonempty 1024 (Lean.ParserDescr.nonReservedSymbol "holes_nonempty" false)
Instances For
A declared module is EasyCrypt-like (Module.ECModule): its finite support is part of
the declaration, and over a first-order module type its representability is a theorem
(Module.representable_of_firstOrder). The side conditions are discharged by default for a
module type declared by moduletype and its canonical ext (each procedure in order).
The restriction as a hypothesis.
A global variable's footprint is finitely supported (one variable): what Module.Declared's
finite support combines with for the modules built from declared ones and the theory's variables.
c is a global_var or a module_var: its value is varLens … under the binders of its
implicit arguments (and module_var's haves).
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.
- GaudisCrypt.DeclareModule.isGlobalVar.body (Lean.Expr.lam binderName binderType b binderInfo) = GaudisCrypt.DeclareModule.isGlobalVar.body b
- GaudisCrypt.DeclareModule.isGlobalVar.body (Lean.Expr.letE declName type value b nondep) = GaudisCrypt.DeclareModule.isGlobalVar.body b
- GaudisCrypt.DeclareModule.isGlobalVar.body (((((Lean.Expr.const `letFun us).app arg).app arg_1).app arg_2).app f) = ((((Lean.Expr.const `letFun us).app arg).app arg_1).app arg_2).app f
- GaudisCrypt.DeclareModule.isGlobalVar.body a✝ = a✝
Instances For
Whether to look into the definition c for globals: ours (this file, the examples, the
libraries), not the framework's or mathlib's.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The global_vars the code of the definitions roots mentions, through the definitions it
uses (EC's glob of a concrete module), in the order first met. Under an alias of a clone
(Syntax/Clone.lean), a variable of the clone's theory is the clone's (SRO.RO.m for
SecureRO.RO.m), nested clones innermost first: the name that elaborates where the clone is used
(the theory's own would need the theory's instance, which a clone does not register).
Equations
- One or more equations did not get rendered due to their size.
Instances For
The restriction {-X₁, …, -Xₖ} as a footprint term, resolved in the current context, as
declare module resolves it: a declared module (a local) is glob X; a region (a local, of
declare module … with glob R) itself; a global variable itself; a concrete module (a definition)
the globals its code mentions.
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
An argument of the module type in declare module: a name or a parenthesized term (so that
the restriction {-…} that follows is not read as one more argument).
Equations
Instances For
Equations
- GaudisCrypt.declare_module_arg_ = Lean.ParserDescr.node `GaudisCrypt.declare_module_arg_ 1022 (Lean.ParserDescr.const `ident)
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
declare module A <: T a₁ … aₙ {-X₁, …, -Xₖ}: see the module docstring.
Equations
- One or more equations did not get rendered due to their size.
Instances For
declare module A <: T a₁ … aₙ {-X₁, …, -Xₖ} with glob R: declare module, and a region R
above A's footprint, restricted like A ({-R} names it in a restriction): see the module
docstring.
Equations
- One or more equations did not get rendered due to their size.
Instances For
clear_decl_hyps: clear the hypotheses that state a declared module's restrictions
(Module.Declared A S, Footprint.Restricted R S, Module.ECGlob A R: instances that
declare module puts in the context), where nothing depends on them.
For the closers, in front of simp_all: it simplifies every hypothesis, and a restriction is a
join of dozens of footprints that it can do nothing with (measured: 4 s per call under
SHA3Security.ec's adversary, in every auto; 7 s per call under SHA3OSecurity.ec's, in
sim's closer before it cleared them). Only where the goal is then closed or the step undone:
the footprint tactics need these hypotheses.
Equations
- GaudisCrypt.tacticClear_decl_hyps = Lean.ParserDescr.node `GaudisCrypt.tacticClear_decl_hyps 1024 (Lean.ParserDescr.nonReservedSymbol "clear_decl_hyps" false)