Short and sharp:
Given two Boolean statements, what is the easiest way to calculate the equation of their intersection in a language like Lua?

(Red = Filter 1, Blue = Filter 2, Purple = Area of intersection)
Long and lamenting:
-
Filter A:
object.ID < 300 -
Filter B:
object.ID < 600
Filter A is a subset of Filter B, that is: Filter B will contain everything matched by Filter A, plus 0 or more objects.
On a Venn diagram, Filter A would be inside Filter B.
How can I calculate the equation of the area of intersection?
A more complicated 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 intersects with Filter B.
On a Venn Diagram, they would overlap.
The equation for the overlapping area would be:
object.Col == 'GREEN' and (object.ID == 64 or object.ID > 9001)
How would this equation be calculated in a language such as Python or Haskell?
I wish to eventually make this in Lua, but if Python, Haskell or another language provided the functionality, I would be able to look at the source code and convert it over.
Here is how I am representing filters in Lua:
filter = DataFilter(
{"and",
{"or",
{"==", "Col", "RED"},
{"==", "Col", "GREEN"},
},
{"or",
{"==", "ID", 3},
{">" , "ID", 22},
},
}
)
Please point me in the right direction.
Wild guess: Bring the “Filters” into disjunctive normal form and reduce using appropriate methods (x == 8 contained in x > 5).