nat
, the unity O
, and
the addition plus
.
Since the module Plus
is required, we get a very simple
construction:
Lemma trivial: (monoid nat). Realizer (mkmonoid nat O plus). Program_all. Qed.This monoid was very useful before the author learned to use Coq, since in this monoid, the n-th power of 1 is equal to n. Then it allowed us to check our algorithms, as proved by the lemma:
Lemma obsolete_debug:(n:nat)(power nat trivial n (S O))=n. Simpl;Auto. Qed.Now, we know that our algorithms are correct, and debugging is useless.
#load "Demo.ml";; ##open "Demo";; #trivial;; - : int monoid = mkmonoid (0, <fun>) #addchains (dicho log2_impl) 107885 trivial 1;; - : int = 107885 #let my_mult x = function y -> addchains (dicho log2_impl) x trivial y;; my_mult : int -> int -> int = <fun> #my_mult 564 321;; - : int = 181044