Over 3 years after asking the question I found the solution. I have included it as an answer.
I have an expression with modulus in it that needs to
yep. you're screwed.
example:
5 mod 3 = 2
8 mod 3 = 2
so inverse mod 2 is what? 8 or 5? or 11? or an infinitude of other numbers?
Inverse mod is a relation, you start to get to more tricky mathematics if you try to pursue this. If you're in haskell you could easilyish model it with non-determinism (an infinite list of possible answers)
Also, this isn't really a programming question. check out math exchange.