Short and sharp:
Given the two Boolean operators, what is the easiest way to compute the equation of their intersection in a language such as Lua?

(Red = Filter 1, Blue = Filter 2, Purple = Intersection Area)
Long and crying:
Filter A is a subset of Filter B , that is: Filter B will contain everything that matches Filter A. strong>, plus 0 or more objects. In the Venn diagram, Filter A will be inside Filter B.
How can I calculate the equation of the intersection region?
More complex example:
- Filter X :
object.Col == 'GREEN' and (object.ID == 2 or object.ID == 64 or object.ID > 9001) - Filter Y :
(object.Col == 'RED' or object.Col == 'GREEN') and (object.ID == 3 or object.ID > 22)
Filter A crosses Filter B. On the Venn diagram, they will overlap. The equation for the overlapping region will be:
object.Col == 'GREEN' and (object.ID == 64 or object.ID > 9001)
How to calculate this equation in a language such as Python or Haskell?
I want to end up doing this in Lua, but if Python, Haskell, or another language provided functionality, I could look at the source code and convert it.
This is how I present filters in Lua:
filter = DataFilter( {"and", {"or", {"==", "Col", "RED"}, {"==", "Col", "GREEN"}, }, {"or", {"==", "ID", 3}, {">" , "ID", 22}, }, } )
Please point me in the right direction.