Can Mathematica Handle Open Intervals? Interval complements?

I'd represent the sets using inequalities and/or equalities and then apply Reduce. Here's an example:

set1 = x < -2 || -1 <= x < 1 || x == 3 || 4 < x <= Pi^2;
set2 = -3 <= x < 0 || x > 1;
Reduce[set1 && set2]

enter image description here

Here's the complement of the union of the two intervals.

Reduce[!(set1 || set2)]

(* Out: x==1 *)

We might define an interval complement function as follows:

intervalComplement[bigInt_, moreInts__] := 
  Reduce[bigInt && (! (Or @@ {moreInts}))];

For example:

intervalComplement[-10 < x <= 10, -8 < x <= -6, 
  0 <= x <= 2, x == 3]
(* Out: -10 < x <= -8 || -6 < x < 0 || 2 < x < 3 || 3 < x <= 10 *)

Here's an implementation of interval complement that is meant to be used with Interval expressions. Interval represents closed intervals according to the documentation, and this is consistent with the things the built-in functions do with intervals. However, in this implementation of the interval complement I simply ignore whether an interval is open or closed. I realize that this is not exactly what you asked for. I wrote this because I needed it, and I thought it'd be useful to post it.


intervalInverse[Interval[int___]] := 
  Interval @@ 
    Partition[
      Flatten @ {int} /.
        {{-∞, mid___, ∞} :> {    mid   },
         {-∞, mid__    } :> {    mid, ∞},
         {    mid__,  ∞} :> {-∞, mid   },
         {    mid___   } :> {-∞, mid, ∞}},
      2
    ]

intervalComplement[a_Interval, b__Interval] := 
 IntervalIntersection[a, intervalInverse @ IntervalUnion[b]]

intervalInverse[a] will compute the complement $(-\infty, \infty) \setminus a$.

intervalComplement[a,b,c,...] will compute $a \setminus (b \cup c \cup \ldots )$.


Example usage:

In[]:= intervalInverse[Interval[{1, 2}]]
Out[]= Interval[{-∞, 1}, {2, ∞}]

In[]:= intervalComplement[Interval[{0, 10}], Interval[{2, 3}]]
Out[]= Interval[{0, 2}, {3, 10}]

This is my code

{a = x > 1 && x < 5, b = x > 5 && x < 8}
{Reduce[a && b]}  

and

{a = x > 1 && x < 5, b = x >= 5 && x < 8}
{Reduce[a || b]}

Edit

Some examples

{a = x > 0 && x < 3, b = x > -1 && x < 2, c = x > -2 && x < 1} {Reduce[a && (b || c)],
Reduce[(a && b) || (a && c)], Reduce[a || (b && c)], Reduce[(a || b) && (a || c)]}