changed SemiGroup to SemiRing, and added identity function