Skip to main content

Semiring

typeclass S: Semiring extends AddCommMonoid, Monoid {
distrib_left(a: S, b: S, c: S) {
a * (b + c) = (a * b) + (a * c)
}
distrib_right(a: S, b: S, c: S) {
(a + b) * c = (a * c) + (b * c)
}
}

A semiring is like a ring but without additive inverses. It has two operations where addition forms a commutative monoid, multiplication forms a monoid, and multiplication distributes over addition.

GitHub


add

Inherited from AddSemigroup.

add_associative

Inherited from AddSemigroup.

add_identity_left

Inherited from AddMonoid.

add_identity_right

Inherited from AddMonoid.

commutative

Inherited from AddCommSemigroup.

distrib_left

distrib_left(a: S, b: S, c: S) {
a * (b + c) = (a * b) + (a * c)
}

Multiplication distributes over addition from the left: a * (b + c) = (a * b) + (a * c).

distrib_right

distrib_right(a: S, b: S, c: S) {
(a + b) * c = (a * c) + (b * c)
}

Multiplication distributes over addition from the right: (a + b) * c = (a * c) + (b * c).

mul

Inherited from Semigroup.

mul_associative

Inherited from Semigroup.

mul_identity_left

Inherited from Monoid.

mul_identity_right

Inherited from Monoid.