# Intersection (and union) of 2 intervals with variables

I have 4 variables of integer a, b, c, d which could define 2 intervals:

[min(a, b), max(a, b)] and [min(c, d), max(c, d)]

Could anyone tell me if it is possible by only using the functions mix and max and [] to represent the intersection of these 2 intervals? The definition of these functions are as following:

min(x, y) = x if x < y, y otherwise
max(x, y) = x if x > y, y otherwise
[x, y] = {i is integer | x <= i <= y}. so when x > y, [x, y] = empty


Going forward, is it possible by only using the functions mix and max to represent the union of these 2 intervals?

Thank you very much!

Edit1: as the comments suggest, the intersection may be empty under some condition. So I just added a function [].

-
The interval is nonempty if and only if either $\max(a,b)\ge\min(c,d)$ or $\min(a,b)\le\max(c,d)$. – anon Jul 25 '11 at 14:12
Perhaps others will understand the question better, but could you give an example of what you mean. For example if we have (a,b,c,d)=(1,2,3,4) then your intersection is non-existent, but your union is (1,2) U (3,4). So what kind of min(...) or max(...) argument do you want? – picakhu Jul 25 '11 at 14:14

If you define $[u,v] = \emptyset$ when $u > v$, then
$$\begin{array}{c}[\min(a,b),\max(a,b)] \cap [\min(c,d), \max(c,d)] \\ = [\max(\min(a,b),\min(c,d)), \min(\max(a,b),\max(c,d))].\end{array}$$
$$[\min(a,b),\max(a,b)] \cup [\min(c,d), \max(c,d)] = [\min(a,b,c,d), \max(a,b,c,d)].$$