The type for a result that has a semi-ring structure
An associative and commutative binary operation over the type t
. The
following should hold:
sum a (sum b c)
= sum (sum a b) c
.sum a b
= sum b a
.An associative binary operation over the type t
. The following should
hold:
prod a (prod b c)
= prod (prod a b) c
.prod a (sum b c)
= sum (prod a b) (prod a c)
.val one : t
The identity for the prod
operation. The following should hold:
prod one t
= t
.prod t one
= t
.As an example, if t
where the type bool
and prod
and sum
were &&
and ||
, respectively, then one
should be the value true
.
val zero : t
The identity for the sum
operation. The following should hold:
sum zero t
= t
.sum t zero
= t
.prod zero t
= zero
.prod t zero
= zero
.As an example, if t
where the type bool
and prod
and sum
were &&
and ||
, respectively, then zero
should be the value false
.