EasyCrypt's Bigop (theories/algebra/Bigop.eca) #
The big operator of a commutative monoid over a list: big P F r is the monoid's sum of F x
over the x of r that satisfy P. The theory's type t with EC's Monoid cloned as
Support (idm, +, addmA, addmC, add0m) is the class Params t; a clone gives the
monoid (clone import GaudisCrypt.EC.Bigop as BBS with type t <- word, op idm <- zerow, op add <- xorw). Only what ported developments use is here. Names are EasyCrypt's.
def
GaudisCrypt.EC.Bigop.big
{t : Type}
[Params t]
{α : Type}
(P : α → Prop)
[DecidablePred P]
(F : α → t)
(r : List α)
:
t
op big (P : 'a -> bool) (F : 'a -> t) (r : 'a list) = foldr Support.(+) idm (map F (filter P r)).
Equations
- GaudisCrypt.EC.Bigop.big P F r = List.foldr GaudisCrypt.EC.Bigop.Params.add GaudisCrypt.EC.Bigop.idm (List.map F (List.filter (fun (x : α) => decide (P x)) r))