Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive

MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

LessEqual vs Inequality, was ..Re: Replacement Rule with Sqrt in

  • To: mathgroup at
  • Subject: [mg114707] LessEqual vs Inequality, was ..Re: Replacement Rule with Sqrt in
  • From: Richard Fateman <fateman at>
  • Date: Mon, 13 Dec 2010 03:55:04 -0500 (EST)
  • References: <ie2971$mqh$>

On 12/12/2010 2:46 AM, Andrzej Kozlowski wrote:
> On 11 Dec 2010, at 07:52, Jack L Goldberg 1 wrote:
>> a)  Input as typed:  2<==x<==4.  Look at its fullform.  On my Mac
>> running ver. 7 of Mathematica, I get returned,
>>                     LessEqual[2,x,4].
>> b)  Now type in Reduce[2<==x<==4].  You will get
>> Inequality[2,LessEqual,x,LessEqual,4].
>> These are are different expressions!  How can one program replacement
>> rules when one can not be sure of the FullForm?  These structures are
>> entirely different.  Which fullform can one assume is the one Mathematica sees
>> in some complicated module wherein one step is a replacement rule?
>> Jack Goldberg
>> Mathematics
>> University of Michigan
> O.K. but I don't see anything here that in any way contradicts anything that

>has been said about the need for
> for looking at FullForm before trying pattern matching. Actually, it is als
> o an argument against using Copy and Paste. To see that, evaluate

> Reduce[2<==x<==4]. Now, copy the output and paste it into another cell

>and wrap FullForm around it, then evaluate. You will get  LessEqual[2,x,4].
> I don't see this as a problem, do you? You can certainly match both forms

> with a single pattern:
>   {2<== x<== 4, Reduce[2<== x<== 4]} /.
>     (a_)<== x<== (b_) |  Inequality[a_, LessEqual, x, LessEqual, b_] :>  {a, b}
> {{2, 4}, {2, 4}}

I find it remarkable that you can claim this is a solution.  First of 
all, the original poster said that he was taken by surprise that there
are two rather simple expressions where both are simplified, and which 
print the same, and both have the same meaning, but don't
match.  Your response is to write a pattern that matches them both by 
including each as a separate pattern.

This is a bug, in my opinion. And there is a way around it, which is to
always parse an inequality or equality of more than 2 arguments as
inequality. e.g.  a==b==c  is Inequality(a,Equal,b,Equal,c).  I recall 
doing this when I implemented my parser in Mockmma.

Note that one can
construct such things in Mathematica, e.g.
a<b<=c  /. LessEqual-> Less
which has FullForm Inequality[a,Less,b,Less,c].

But if you type it in as a<b<c, it is Less[a,b,c].
So you have two items whose 'difference' does not simplify to zero,
and which is not simplified by FullSimplify[] to zero.

(parenthetically,  (3<4) - (5<6) DOES simplify to zero.  )

I would be surprised to find other people so accepting of this "solution".


  • Prev by Date: Re: Puzzled by IntegerPart
  • Next by Date: Re: Replacement Rule with Sqrt in denominator. Also Bug in Series
  • Previous by thread: Re: How to create a notebook outside of Mathematica?
  • Next by thread: Re: LessEqual vs Inequality, was ..Re: Replacement Rule with Sqrt in denominator