Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
As pointed out in a comment above, the OP is not working in a finite field, but rather a commutative semiring. This means that additive inverses are not guaranteed to exist, so "subtracting" the expressions to check equality with zero is not a valid operation.
You're looking at determining expression equivalence in a semiring. This is related to a Kleene algebra, which, in turn, is related to regular expressions. It might be possible to reduce this problem to determining equivalence of regexes. I'm out of my depth, but that might aid search terms.