Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Relational operators on intervals: bug?

48 views
Skip to first unread message

bertiiiiiiiiiii...@gmail.com

unread,
Nov 11, 2012, 3:59:15 PM11/11/12
to
Hi there,
I would like to know if someone understands the behavior of relational operators on intervals reported below. I, personally, consider items 1 and 2 below bugs, and 3, a conceptual flaw.

1. Comparision of any Interval[___] to the empty interval Interval[]:

>From the Interval-documentation (Version 8):
"Relational operators such as Equal and Less yield explicit True or False results whenever they are given disjoint intervals."

This implies that the operator Less should always yield True if the empty interval, Interval[], is compared to any other Interval[___].
However, Interval[] < Interval[] does not evaluate to either True or False.
Same for Interval[] < Interval[0].

2. Behavior of Equal on Interval[___]:

What they also mean to imply by the above quote from the documentation is, I think, that
interval1 R interval2,
where R is any relational operator (Less,LessEqual,Equal,...), should NOT yield explicit True or False results if there exist x1, x3 in interval1 and x2, x4 in interval2 such that
(x1 R x2 and Not[x3 R x4]).

Indeed, Interval[{0, 2}] <= Interval[{0, 2}] comes back unevaluated, which is fine, but Interval[{0, 2}] == Interval[{0, 2}] evaluates to True, which is not.
In fact, the documentation for Equal contradicts what is said in the above quote from the documentation of Interval.

3. IntervalIntersection[]:

IntervalIntersection[] evaluates to Interval[], which represents the empty set. This might be considered a legal definition, but is in fact nonsensical, for the same reason for which Min[ Interval[] ] should evaluate to Infinity, and not -Infinity (which is in fact what Mathematica's Min does).

Thank you for your comments.

Richard Fateman

unread,
Nov 12, 2012, 3:12:04 AM11/12/12
to
On 11/11/2012 12:59 PM, bertiiiiiiiiiii...@gmail.com wrote:

> 1. Comparision of any Interval[___] to the empty interval Interval[]:
>

What makes you think that this is a notation for an empty Interval,
whatever that is?



Murray Eisenberg

unread,
Nov 13, 2012, 12:13:06 AM11/13/12
to

On Nov 12, 2012, at 3:07 AM, Richard Fateman <fat...@cs.berkeley.edu> wrote:

> On 11/11/2012 12:59 PM, bertiiiiiiiiiii...@gmail.com wrote:
>
>> 1. Comparision of any Interval[___] to the empty interval Interval[]:
>>
>
> What makes you think that this is a notation for an empty Interval,
> whatever that is?

One way to define "interval" J mathematically in a (linearly) ordered set X such as the set of reals is to say J is a subset of X having the property that, for all a, b and c in X, if a and b are elements of J and if a < c < b, then also c is an element of J.

Using that definition, evidently the empty set _is_ an interval, as are rays in the real line. Which is fortunate, for otherwise the theorem that a subset of the reals is connected if and only if it is an interval would have to be restated with awkward restrictions.

Of course the OP's notation for the empty interval is spurious.

Here is the empty interval in Mathematica:

Interval[{1, 0}]

Indeed:

Resolve[Exists[x, IntervalMemberQ[Interval[{1, 0}], x]]]
False

---
Murray Eisenberg mur...@math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 549-1020 (H)
University of Massachusetts 413 545-2838 (W)
710 North Pleasant Street fax 413 545-1801
Amherst, MA 01003-9305






Bob Hanlon

unread,
Nov 13, 2012, 12:13:16 AM11/13/12
to
$Version

"8.0 for Mac OS X x86 (64-bit) (October 5, 2011)"

IntervalIntersection[Interval[{0, 2}], Interval[{6, 8}]]

Interval[]


Min[Interval[]]

Infinity


Max[Interval[]]

-Infinity


IntervalMemberQ[
Interval[], #] & /@
{-Infinity, -$MaxNumber, -1, -$MinNumber,
0, $MinNumber, 1, $MaxNumber, Infinity}

{False, False, False, False, False, False, False, False, False}

So Interval[] is the range of all values Greater than Infinity and
less than -Infinity, appears to be "empty."


Bob Hanlon


On Mon, Nov 12, 2012 at 3:07 AM, Richard Fateman
<fat...@cs.berkeley.edu> wrote:
> On 11/11/2012 12:59 PM, bertiiiiiiiiiii...@gmail.com wrote:
>
>> 1. Comparision of any Interval[___] to the empty interval Interval[]:
>>
>

Richard Fateman

unread,
Nov 13, 2012, 12:13:26 AM11/13/12
to
see
http://demonstrations.wolfram.com/IntervalNotation/
which says

"There is no interval notation for the empty set"

The internets never lie :)

Richard Fateman

unread,
Nov 14, 2012, 1:33:01 AM11/14/12
to
On 11/12/2012 9:13 PM, Murray Eisenberg wrote:

>
> Here is the empty interval in Mathematica:
>
> Interval[{1, 0}]
>
> Indeed:
>
> Resolve[Exists[x, IntervalMemberQ[Interval[{1, 0}], x]]]
> False
>
Apparently this doesn't mean what you think it does. It gives the same
answer for Interval[{0,1}].

Note that

IntervalMemberQ[ Interval[{1, 0}], 1/2] is TRUE.

IntervalIntersection[Interval[{0, 1}], Interval[{1, 0}]]

is Interval[{0,1}].

That is, the endpoints, in Mathematica, are re-ordered. This is, in
my opinion, a bug.

Using your reasoning, there are an infinite number of ways of writing
an Interval with no "insides" -- why choose {1,0}? A rather complete
calculus of interval including EXTERIOR intervals has been defined,
one in which {1,0} is the equivalent of the union of the (open)
intervals {-Infinity,0} and {1,Infinity}. A canonical representative
for an empty set would be useful in such a scheme.

The Mathematica implementation of Intervals seems to have a number
of design issues. I've commented on some of them, previously.

Andrzej Kozlowski

unread,
Nov 15, 2012, 4:04:20 AM11/15/12
to

On 14 Nov 2012, at 07:28, Richard Fateman <fat...@cs.berkeley.edu> wrote:

> On 11/12/2012 9:13 PM, Murray Eisenberg wrote:
>
>>
>> Here is the empty interval in Mathematica:
>>
>> Interval[{1, 0}]
>>
>> Indeed:
>>
>> Resolve[Exists[x, IntervalMemberQ[Interval[{1, 0}], x]]]
>> False
>>
> Apparently this doesn't mean what you think it does. It gives the same
> answer for Interval[{0,1}].

Of course that is because

IntervalMemberQ[Interval[{0, 1}], x]

False

Andrzej Kozlowski

Murray Eisenberg

unread,
Nov 15, 2012, 4:07:10 AM11/15/12
to

On Nov 14, 2012, at 1:28 AM, Richard Fateman <fat...@cs.berkeley.edu> wrote:

> On 11/12/2012 9:13 PM, Murray Eisenberg wrote:
>
>>
>> Here is the empty interval in Mathematica:
>>
>> Interval[{1, 0}]
>>
>> Indeed:
>>
>> Resolve[Exists[x, IntervalMemberQ[Interval[{1, 0}], x]]]
>> False
>>
> Apparently this doesn't mean what you think it does. It gives the same
> answer for Interval[{0,1}].
>
> Note that
>
> IntervalMemberQ[ Interval[{1, 0}], 1/2] is TRUE.
>
> IntervalIntersection[Interval[{0, 1}], Interval[{1, 0}]]
>
> is Interval[{0,1}].
>
> That is, the endpoints, in Mathematica, are re-ordered. This is, in
> my opinion, a bug.
>
> Using your reasoning, there are an infinite number of ways of writing
> an Interval with no "insides" -- why choose {1,0}? A rather complete
> calculus of interval including EXTERIOR intervals has been defined,
> one in which {1,0} is the equivalent of the union of the (open)
> intervals {-Infinity,0} and {1,Infinity}. A canonical representative
> for an empty set would be useful in such a scheme.


The result True from IntervalMemberQ[ Interval[{1, 0}], 1/2] is, if not a bug, then a result of the underlying bug/feature that, apparently, Interval[{b, a}] gives Interval[{a, b}] when b > a.

Of course the documentation for Interval describes the usage as Interval[{min, max}], which could reasonably be interpreted as requiring min <= max. And then it's the user's own fault -- mine there -- if he violates that condition.

On the other hand, there's nothing wrong whatsoever in having an infinite number of ways of writing the empty interval. Just as there are an infinite number of ways of describing the empty set.

Murray Eisenberg

unread,
Nov 15, 2012, 4:07:20 AM11/15/12
to
On Nov 14, 2012, at 5:39 AM, Andrzej Kozlowski <akozl...@gmail.com> wrote:

>
> On 14 Nov 2012, at 07:28, Richard Fateman <fat...@cs.berkeley.edu> wrote:
>
>> On 11/12/2012 9:13 PM, Murray Eisenberg wrote:
>>
>>>
>>> Here is the empty interval in Mathematica:
>>>
>>> Interval[{1, 0}]
>>>
>>> Indeed:
>>>
>>> Resolve[Exists[x, IntervalMemberQ[Interval[{1, 0}], x]]]
>>> False
>>>
>> Apparently this doesn't mean what you think it does. It gives the same
>> answer for Interval[{0,1}].
>
> Of course that is because
>
> IntervalMemberQ[Interval[{0, 1}], x]
>
> False

What remains surprising to me is:

Resolve[Exists[x, x \[Element] Reals, IntervalMemberQ[Interval[{0, 1}], x]]]

Andrzej Kozlowski

unread,
Nov 15, 2012, 4:07:31 AM11/15/12
to

On 14 Nov 2012, at 22:01, Murray Eisenberg <mur...@math.umass.edu> wrote:

> On Nov 14, 2012, at 5:39 AM, Andrzej Kozlowski <akozl...@gmail.com> wrote:
>
>>
>> On 14 Nov 2012, at 07:28, Richard Fateman <fat...@cs.berkeley.edu> wrote:
>>
>>> On 11/12/2012 9:13 PM, Murray Eisenberg wrote:
>>>
>>>>
>>>> Here is the empty interval in Mathematica:
>>>>
>>>> Interval[{1, 0}]
>>>>
>>>> Indeed:
>>>>
>>>> Resolve[Exists[x, IntervalMemberQ[Interval[{1, 0}], x]]]
>>>> False
>>>>
>>> Apparently this doesn't mean what you think it does. It gives the same
>>> answer for Interval[{0,1}].
>>
>> Of course that is because
>>
>> IntervalMemberQ[Interval[{0, 1}], x]
>>
>> False
>
> What remains surprising to me is:
>
> Resolve[Exists[x, x \[Element] Reals, IntervalMemberQ[Interval[{0, 1}], x]]]
> False
>


I don't find it surprising.
All you are doing is, evaluating Exists[x,Element[x,Reals],False] which is False and then Resolve[False] which is also False.The fact that IntervalMemberQ[Interval[{0, 1}], x] immediately evaluates to False (unlike, for example, 0<x<1, which evaluates to itself) is responsible for this and shows that IntervalMemberQ is not intended to be used in symbolic expressions. Compare this with

Resolve[Exists[x, x \[Element] Reals, 0 < x < 1]]

True

Andrzej Kozlowski


Andrzej Kozlowski

unread,
Nov 16, 2012, 2:14:07 AM11/16/12
to

On 15 Nov 2012, at 09:57, Andrzej Kozlowski <akozl...@gmail.com> wrote:

>
> On 14 Nov 2012, at 22:01, Murray Eisenberg <mur...@math.umass.edu> wrote:
>
>> On Nov 14, 2012, at 5:39 AM, Andrzej Kozlowski <akozl...@gmail.com> wrote:
>>
>>>
>>> On 14 Nov 2012, at 07:28, Richard Fateman <fat...@cs.berkeley.edu> wrote:
>>>
>>>> On 11/12/2012 9:13 PM, Murray Eisenberg wrote:
>>>>
>>>>>
>>>>> Here is the empty interval in Mathematica:
>>>>>
>>>>> Interval[{1, 0}]
>>>>>
>>>>> Indeed:
>>>>>
>>>>> Resolve[Exists[x, IntervalMemberQ[Interval[{1, 0}], x]]]
>>>>> False
>>>>>
>>>> Apparently this doesn't mean what you think it does. It gives the same
>>>> answer for Interval[{0,1}].
>>>
>>> Of course that is because
>>>
>>> IntervalMemberQ[Interval[{0, 1}], x]
>>>
>>> False
>>
>> What remains surprising to me is:
>>
>> Resolve[Exists[x, x \[Element] Reals, IntervalMemberQ[Interval[{0, 1}], x]]]
>> False
>>
>
>
> I don't find it surprising.
> All you are doing is, evaluating Exists[x,Element[x,Reals],False] which is False and then Resolve[False] which is also False.The fact that IntervalMemberQ[Interval[{0, 1}], x] immediately evaluates to False (unlike, for example, 0<x<1, which evaluates to itself) is responsible for this and shows that IntervalMemberQ is not intended to be used in symbolic expressions. Compare this with
>
> Resolve[Exists[x, x \[Element] Reals, 0 < x < 1]]
>
> True
>
> Andrzej Kozlowski
>
>
Maybe the following example will make my point clearer.

Compare:

Resolve[Exists[x, Element[x, Primes]]]

True

with

Resolve[Exists[x, PrimeQ[x]]]

False

Mathematica `predicates (functions ending with Q) always evaluate immediately to True or False and thus are generally unsuitable for use in symbolic expressions of the above kind.

Andrzej Kozlowski

Murray Eisenberg

unread,
Nov 16, 2012, 2:14:27 AM11/16/12
to
On Nov 15, 2012, at 4:45 AM, Andrzej Kozlowski <akozl...@gmail.com> wrote:
>
> On 15 Nov 2012, at 09:57, Andrzej Kozlowski <akozl...@gmail.com> wrote:
>>
>> On 14 Nov 2012, at 22:01, Murray Eisenberg <mur...@math.umass.edu> wrote:
>>
>>> On Nov 14, 2012, at 5:39 AM, Andrzej Kozlowski <akozl...@gmail.com> wrote:
>>>
>>>>
>>>> On 14 Nov 2012, at 07:28, Richard Fateman <fat...@cs.berkeley.edu> wrote:
>>>>
>>>>> On 11/12/2012 9:13 PM, Murray Eisenberg wrote:
>>>>>
>>>>>>
>>>>>> Here is the empty interval in Mathematica:
>>>>>>
>>>>>> Interval[{1, 0}]
>>>>>>
>>>>>> Indeed:
>>>>>>
>>>>>> Resolve[Exists[x, IntervalMemberQ[Interval[{1, 0}], x]]]
>>>>>> False
>>>>>>
>>>>> Apparently this doesn't mean what you think it does. It gives the same
>>>>> answer for Interval[{0,1}].
>>>>
>>>> Of course that is because
>>>>
>>>> IntervalMemberQ[Interval[{0, 1}], x]
>>>>
>>>> False
>>>
>>> What remains surprising to me is:
>>>
>>> Resolve[Exists[x, x \[Element] Reals, IntervalMemberQ[Interval[{0, 1}], x]]]
>>> False
>>>
>>
>> I don't find it surprising.
>> All you are doing is, evaluating Exists[x,Element[x,Reals],False] which is False and then Resolve[False] which is also False.The fact that IntervalMemberQ[Interval[{0, 1}], x] immediately evaluates to False (unlike, for example, 0<x<1, which evaluates to itself) is responsible for this and shows that IntervalMemberQ is not intended to be used in symbolic expressions. Compare this with
>>
>> Resolve[Exists[x, x \[Element] Reals, 0 < x < 1]]
>>
>> True
>>
> Maybe the following example will make my point clearer.
>
> Compare:
>
> Resolve[Exists[x, Element[x, Primes]]]
>
> True
>
> with
>
> Resolve[Exists[x, PrimeQ[x]]]
>
> False
>
> Mathematica `predicates (functions ending with Q) always evaluate immediately to True or False and thus are generally unsuitable for use in symbolic expressions of the above kind.

OK, that provides an explanation of sorts. In fact, the documentation of PrimeQ makes the distinction in saying, "Simplify[expr\[Element]Primes] can be used to try to determine whether a symbolic expression is mathematically a prime."

But the documentation for IntervalMemberQ does not say any such thing. Moreover, one might be misled into thinking

Simplify[0.5 \[Element] Interval[{0, 1}]]

should return True, but it returns 0.5 \[Element] Interval[{0, 1}] instead.

Is the general rule about functions whose names end with Q documented somewhere?

Andrzej Kozlowski

unread,
Nov 16, 2012, 2:14:47 AM11/16/12
to

On 15 Nov 2012, at 17:14, Murray Eisenberg <mur...@math.umass.edu> wrote:

> On Nov 15, 2012, at 4:45 AM, Andrzej Kozlowski <akozl...@gmail.com> wrote:
>>
>> On 15 Nov 2012, at 09:57, Andrzej Kozlowski <akozl...@gmail.com> wrote:
>>>
>>> On 14 Nov 2012, at 22:01, Murray Eisenberg <mur...@math.umass.edu> wrote:
>>>
>>>> On Nov 14, 2012, at 5:39 AM, Andrzej Kozlowski <akozl...@gmail.com> wrote:
>>>>
>>>>>
>>>>> On 14 Nov 2012, at 07:28, Richard Fateman <fat...@cs.berkeley.edu> wrote:
>>>>>
>>>>>> On 11/12/2012 9:13 PM, Murray Eisenberg wrote:
>>>>>>
>>>>>>>
>>>>>>> Here is the empty interval in Mathematica:
>>>>>>>
>>>>>>> Interval[{1, 0}]
>>>>>>>
>>>>>>> Indeed:
>>>>>>>
>>>>>>> Resolve[Exists[x, IntervalMemberQ[Interval[{1, 0}], x]]]
>>>>>>> False
>>>>>>>
> ---
> Murray Eisenberg mur...@math.umass.edu
> Mathematics & Statistics Dept.
> Lederle Graduate Research Tower phone 413 549-1020 (H)
> University of Massachusetts 413 545-2838 (W)
> 710 North Pleasant Street fax 413 545-1801
> Amherst, MA 01003-9305
>

I don't know if this principle is stated in the documentation in full generality but note that all the predicates (functions whose names end in Q) are defined by using the expression:

=85 gives True if =85. and False otherwise.

Also, there is no reason at all to try to use ELement to test for interval membership. The language of Mathematica is a formal language and however intuitive it may seem (it does seem so to me) the basic principle of such a language is "everything is forbidden unless explicitly allowed" rather than the opposite. There is nothing in the documentation for Element stating that you can use it with anything but domains and Interval[=85] is certainly not a domain.

Andrzej Kozlowski








Andrzej Kozlowski

unread,
Nov 17, 2012, 3:49:14 AM11/17/12
to

On 16 Nov 2012, at 15:57, Andrzej Kozlowski <akozl...@gmail.com> wrote:

> The intent of Mathematica developers is certainly that everything that one can do should be documented, which does, of course, exclude the possibility that some undocumented features may work - but when you use them "you are on your own".

Before certain tedious nitpickers jump at this opportunity I hasten to point out that a "not" disappeared form the above statement, which should have read:

"which does not, of course, exclude the possibility that some undocumented features may work=85"

Andrzej Kozlowski


Richard Fateman

unread,
Nov 17, 2012, 3:51:15 AM11/17/12
to
On 11/15/2012 11:14 PM, Andrzej Kozlowski wrote:

The language of Mathematica is a formal language and however intuitive
it may seem

(it does seem so to me) the basic principle of such a language is
"everything is forbidden

unless explicitly allowed" rather than the opposite.


Nonsense.

The semantics of Mathematica is not formally defined, and its apparent
intent is to do as much mathematics as can be automated. The exclusion
of certain operations on certain operands may change without notice in
the documentation.

If your statement is meant to be read as "unless explicitly allowed
[by the proprietary and secret source code]", then it is vacuous.
Of course the programs do only what the program do;
this is true of any programs whatsoever.

Actually, the syntax of Mathematica is not formally defined either,
but at least that doesn't change so often.

RJF


0 new messages