I am lost in the sea of different kinds of constraint solvers available. I am writing a database query program.
Given an equation where terms are sets of non-consecutive integers, my goal is to simplify the equation as the influence of some terms might completely overlap or be completely disjoint in/from the resulting set, therefore making them discardable.
({1, 2} ∪ {3, 4}) - {4, 6}
as a first step can be simplified to:
({1, 2} ∪ {3, 4}) - {4}
since {6} ⊄ ({1, 2} ∪ {3, 4}), etc.
What kind of solver can one use for such a problem? I found library(fd_sets) which seems appropriate. However, ECLiPSE is not an easy platform to work with. Are there other solutions?
({1, 2} ∪ {3, 4}) - {4, 6}
is not an equation (or constraint), so there is nothing to solve. So you don't need a solver. It is a (constant) expression. We can easily evaluate this expression and print the result. E.g. in straightforward Python:
print({1,2}.union({3,4}).difference({4,6}))
will give
{1, 2, 3}
Python knows about sets, so that makes it easy. To automatically go from ({1, 2} ∪ {3, 4}) - {4, 6}
to {1,2}.union({3,4}).difference({4,6})
, you would need to build a parser. This is not very difficult to do (for a skilled programmer). If your favorite programming language does not know about sets, it is not too difficult to create data structures and functions to handle sets. Many languages have some support for sets (e.g. the standard C++ library has sets).
PS. To be complete: Python also allows infix set operators. E.g.:
print({1,2} | {3,4} - {4,6})