pub trait Semiring: Clone + PartialEq + Debug + Default + Add + AddAssign + Mul + MulAssign + Display {
type Type: Display;
fn plus(&self, rhs: &Self) -> Self;
fn times(&self, rhs: &Self) -> Self;
fn zero() -> Self;
fn one() -> Self;
fn value(&self) -> Self::Type;
fn set_value(&mut self, _: Self::Type);
}
Expand description
For some operations, the weight set associated to a wFST must have the structure of a semiring.
(S, +, *, 0, 1)
is a semiring if (S, +, 0)
is a commutative monoid with identity element 0,
(S, *, 1)
is a monoid with identity element 1
, *
distributes over +
,
0
is an annihilator for *
.
Thus, a semiring is a ring that may lack negation.
For more information : https://cs.nyu.edu/~mohri/pub/hwa.pdf