0
$\begingroup$

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 [].

  • 0
    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?2011-07-25

1 Answers 1

2

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}$

Also, if the intervals overlap, then

$[\min(a,b),\max(a,b)] \cup [\min(c,d), \max(c,d)] = [\min(a,b,c,d), \max(a,b,c,d)].$

(If the intervals do not overlap, their union will not be an interval.)