Implementation in Python of Semiring related concepts.