MathGroup Archive 2010

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

Search the Archive

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

  • To: mathgroup at smc.vnet.net
  • Subject: [mg114697] Re: LessEqual vs Inequality, was ..Re: Replacement Rule with Sqrt in denominator
  • From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Date: Mon, 13 Dec 2010 03:53:14 -0500 (EST)
  • References: <ie2971$mqh$1@smc.vnet.net> <4D050013.8050105@cs.berkeley.edu> <928BCB32-AEF9-4D13-87E0-BDDACF1BF878@mimuw.edu.pl> <4D055126.6080209@cs.berkeley.edu>

On 12 Dec 2010, at 23:48, Richard Fateman wrote:

>>>
>> Do you mean a user should not be allowed to enter Less[2,x,3] but 
always required to use the form Inequality[2,Less,x,Less,3]?
> I did not propose to tie the user's hands in this way.
>>  Or should Less[2,x,3] always evaluate to 
Inequality[2,Less,x,Less,3]?
> That would be my solution,.  Is my solution.  Indeed,  Less[x,y] is 
simplified to  Inequality[x,Less,y]
>>  (In that case you would still have the same problem if, for some 
reason, you prevented evaluation).
> If I prevented simplification/evaluation, I would presumably not 
expect much of anything to work.
> I can' t think of a reason.

First  in Mathematica, there are often functions that have attributes 
HoldAll or Hold First etc, which means that the act on unevaluated 
arguments. So if an argument was written as Less[x,y] it would not be 
converted to Inequality[x,Less,y] before pattern matching was applied to 
it (most Mathematica "functions" are just local pattern matching rules).

But much more importantly and, in my opinion, crucially (that was the 
main point of my reply, but somehow you managed to skirt around so I 
will now try to make it as explicit as I can):

 if Less[x,y] was always automatically converted to Inequality[x,Less,y] 
than clearly LogicalExpand[Inequality[x, Less, y]] would not longer 
work, and what's worse LogicalExpand[Inequality[x, Less, y, LessEqual, 
z]] etc. would not work.
But that would make it vastly harder to get expressions involving 
inequalities into a canonical form.

 As it is now, an expression involve both Inequality[x, Less, y, 
LessEqual, z] and And[Less[x,y],LessEqual[y,z]] (which is simply 
x<y&&y<=z). Both of these are equivalent and obviously you would want 
any patterns to apply to both. As things work now, all you need to do is 
to use LogicalExpand to replace all expressions with Inequality by 
canonical forms and you can do unambiguous pattern matching. If your 
approach were adopted this would not be possible. Instead you would have 
to pick out all the different x<y and y<=z in your expression, and 
"simplify" them to a canonical form involving Inequality. But this 
clearly would a great deal more complex than just applying 
LogicalExpand.  For a start, the expression could involve many 
conjunctions and disjunctions so that x<y and y<=z would not 
necessarily appear next to each other, i.e. it could be something like
x<y&&...various relations ...y<=z&&... . I think my point should now 
be clear - what you are proposing would probably greatly increase the 
complexity of working with inequalities and may well be impracticable. 
Thus implementing your idea would probably amount to introducing  a 
terrible bug into Mathematica, in  your own terminology.

Andrzej Kozlowski


  • Prev by Date: Re: multiple outputs from compiled function
  • Next by Date: Re: On the foundation of Mathematica, was Re: Foo /:
  • Previous by thread: LessEqual vs Inequality, was ..Re: Replacement Rule with Sqrt in
  • Next by thread: Re: LessEqual vs Inequality, was ..Re: Replacement Rule with Sqrt in denominator