In this module, we use the
% Record
Record declaration of Coq. The fields are u:M->M->M,
o:M, and proofs of associativity of o and
neutrality of u
.
The domain M is not a field of the Record
, but
a parameter of the declaration:
Variable M:Set. Record monoid:Set := mkmonoid { u:M; o:M->M->M; point_assoc:(a,b,c:M) (o a (o b c))=(o (o a b) c); u_neutral_l:(a:M) (o u a)=a; u_neutral_r:(a:M) (o a u)=a }.
Recursive Definition power[x:M]:nat->M:= O => u' | (S n) =>(o' x (power x n)).In this text, we use indifferently the notation
(power x n)
or (x ^ n)
.
Lemma power_eucl:(m:M)(b,q,r:nat) (power m (plus (mult q b) r))= (o' (power (power m b) q) (power m r)).which is used heavily in our algorithms.
You can see the coq source of this module .