EasyCrypt's iteration of a procedure over a list (theories/looping/IterProc.eca) #
The abstract type t is a section variable, so a clone is an application. Only what ported
developments use is here.
Iter(O).iter l is denotationally the calls of O.f on the elements of l, in order
(Iter.iter_denotation, through iterDen). From that:
iter_llanditer_invare EC's, as stated there;iter_cat,iter_permanditer1_permare EC'sequivs with={glob O}as denotational equalities (exception E9): stronger, valid for anyO, and used by rewriting. EC'sIter(O).iters(l₁, l₂)andIter(O).iter_1s(x, l)are spelled as the composite denotations they stand for, and EC'siter2_eq(iter_12 ~ iter_21) is the commutation of two calls ofO.f.
The record of a module's fields: Orcl.structure m is Orcl.Structure.mk applied to Orcl.f of m.
Inverse of Orcl.mk (Orcl.mk_destruct, Orcl.destruct_mk).
Equations
- GaudisCrypt.EC.IterProc.Orcl.structure t theModule✝ = { f := GaudisCrypt.EC.IterProc.Orcl.f t theModule✝ }
Instances For
The ModuleTypeRep underlying Orcl, the module type declared by moduletype Orcl: the right-nested product of its 1 field types, in declaration order.
Orcl is by definition Module Orcl.typeRep.
Equations
Instances For
Builds a module of type Orcl from the record Orcl.Structure of its fields, as a right-nested Module.pair'. @[reducible].
Inverse of Orcl.structure (Orcl.mk_destruct, Orcl.destruct_mk); a single field of a module built this way is read back by the @[simp] lemmas Orcl.f.mk_simp.
Equations
- GaudisCrypt.EC.IterProc.Orcl.mk t theRecord✝ = theRecord✝.f
Instances For
The IsModule Orcl instance: Orcl is a module type, with representation Orcl.typeRep.
It is what lets the name Orcl stand where a module type is expected — in Module.Arr/Module.Prod (→ₘ/×ₘ), say — which the underlying Module Orcl.typeRep would do on its own but Orcl, a plain (non-reducible) def, would not.
Equations
- GaudisCrypt.EC.IterProc.instIsModuleOrcl t = { moduleTypeRep := GaudisCrypt.EC.IterProc.Orcl.typeRep t, isModule := ⋯ }
The module type declared by moduletype Orcl, with fields f: the type Module Orcl.typeRep of modules that are a right-nested tuple of the field types.
Build one from a record of its fields with Orcl.mk, read a single field off one with the accessors Orcl.f, and get the whole record back with Orcl.structure.
Equations
Instances For
@[simp]: Orcl.structure (Orcl.mk r) = r — destructing a module built from a record gives that record back.
What is derivable about the accessor Orcl.f, bundled into one ModuleTypeUtilities (one name per field in the namespace, rather than one per fact):
Orcl.f.utilities.accessorModule : Orcl →ₘ …— the accessor as a module, a projection being a module morphism;Orcl.f.utilities.apply_simp—Module.app Orcl.f.utilities.accessorModule m = Orcl.f m: applying that module is the accessor;Orcl.f.utilities.expression_eq— the same at the level of expressions:(Orcl.f m).expression = (Orcl.f.utilities.proj m.expression).reduce.
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[simp]: reading the field f back off a module built from a record — Orcl.f (Orcl.mk r) = r.f.
It is what carries the right-hand side of an X.apply_simp (which is an Orcl.mk) on to the field the caller actually asked for, so that simp chains X.apply_simp into X.f.apply_simp.
The field f of a module of type Orcl: the projection onto component 0 of the right-nested tuple Orcl.typeRep, as a chain of Module.fst'/Module.snd'. Tagged @[module_accessor].
Orcl.f.mk_simp reads this field back off a module built by Orcl.mk; Orcl.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.IterProc.Orcl.f t theModule✝ = theModule✝
Instances For
@[simp]: applying Iter to a tuple of its single parameter O — the record of its procedures Iter.iter, 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 Iter.iter.apply_simp to fill that procedure's holes.
Instantiating the holes of Iter.iter.procedure with a tuple holeArgs of procedures: the body of proc iter 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 [Iter.iter.procedure.apply_simp]).
@[simp]: applying Iter.iter to the parameters proc iter uses (O) is Module.proc (Iter.iter.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 body of proc iter of module Iter, 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 Iter.iter.procedure.apply_simp) rather than run. Use Iter.iter for this procedure as a module.
Equations
- One or more equations did not get rendered due to their size.
Instances For
proc iter of module Iter 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 Iter.iter.apply_simp, which fills the holes of Iter.iter.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 Iter, 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 Iter.iter, each applied to the parameters that procedure itself uses — which is what the @[simp] lemma Iter.apply_simp says.
Equations
Instances For
The lemmas #
The calls of f on the elements of a list, in order: what Iter(O).iter computes.
Equations
- GaudisCrypt.EC.IterProc.iterDen f [] = pure ()
- GaudisCrypt.EC.IterProc.iterDen f (x_1 :: xs) = do f x_1 GaudisCrypt.EC.IterProc.iterDen f xs
Instances For
A loop calling f on the head of the list in slot lv and dropping it, from a state whose
slot holds xs: the calls of f on xs, the slot emptied.
Calls of f that commute can be iterated in any order.
EC's iter_ll.
EC's iter_inv.
EC's iter_cat, denotationally: iterating over l₁ ++ l₂ is iterating over l₁, then
l₂ (EC's Iter(O).iters).
EC's iter_perm, denotationally, under EC's iter2_eq (two calls of O.f commute): the
iteration does not depend on the order of the list.
EC's iter1_perm, denotationally (EC's Iter(O).iter_1s(t, l) is O.f(t); iter(l)).