I'm looking for an C ++ open source library (or just an open source Unix tool): Equality checking on equations .
Equations can be built at runtime as AST Trees, string, or other format.
The equations will be mostly simple algebras with some assumptions about unknown functions. The domain will be integer arithmetic (no floating point problems, since the problems associated with this are well known) Thanks @hardmath for this, I assumed it was known).
Example: Input may contain a phi function, with assumptions about this (in most cases) phi(x,y)=phi(y,x) and try to solve:
equality_test( phi( (a+1)*(a+1) , a+b ) = phi( b+a, a*a + 2a + 1 )
It can be fuzzy or any equality test - I mean that it does not always have to succeed (it can return “false” even if the equations are equal).
If there is a problem with the supporting assumptions described above about the phi function, I can handle this, so simple linear equality algebra testers are welcome.
- Could you recommend some C / C ++ programming libraries or Unix tools? (Open source)
- If possible, can you attach an example of how such an equality test might look in a given library / tool?
PS If such equality_test could (if successful) return an isomorphism - (what I mean, a kind of "mapping") between two given equations, it would be very desirable. But tools without such features are also welcome.
PS By “fuzzy tester” I mean that in internal solutions the equation will be “fuzzy” from the point of view of searching for the “isomorphism” of two functions, and not from the point of view of testing for random inputs - I could implement this, of course, but I try to find something with better accuracy.
PPS There is another problem why I need a better solution to improve performance than "testing all inputs." The above equation is a simple form of my internal problem , where I have no comparison between the variables in the equations . That is, I have eq1=phi( (a+1)*(a+1) , a+b ) and eq2=phi( l+k, k*k + 2k + 1 ) , and I should find out that a==k and b==l . But this subproblem, with which I can cope with the “brute force” approach (even the asymptotic complexity of this approach), there are only a few variables, let it be 8. Therefore, I will need to make this test equation for every possible mapping. If there is a tool that does all this work, I would be very grateful and could contribute to such a project. But I do not require such functionality, just the system_test () equation will be enough, I can easily cope with the rest.
Summarizing:
- equal_test () is just one of many sub-tasks that I have to solve, so computational complexity matters.
- it should not be 100% reliable, but a higher probability than just testing equations with several random inputs and variable mapping is welcome :).
- conclusion "yes" or "no" (all additional information may be useful, but in the future at this stage I need "Yes" / "No")