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

*To*: mathgroup at smc.vnet.net*Subject*: [mg114717] Re: LessEqual vs Inequality, was ..Re: Replacement Rule with Sqrt in denominator*From*: Andrzej Kozlowski <akoz at mimuw.edu.pl>*Date*: Tue, 14 Dec 2010 06:54:26 -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> <ie4mt7$9a7$1@smc.vnet.net> <4D0645BE.6000205@cs.berkeley.edu>

On 13 Dec 2010, at 17:11, Richard Fateman wrote: > On 12/13/2010 12:52 AM, Andrzej Kozlowski wrote: >> 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). > > Um, I think this is irrelevant. Consider the "function" in = Mathematica > Divide. It exists in Mathematica. > > Divide[a,b] is immediately transformed to Times[a,Power[b,-1]. > > Divide[a,b] /. Times-> Foo results in Foo[a,Power[b,-1]]. > > Divide has attributes Protected, Listable, NumericFunction. > > It's not that different from Less, in some senses: > (a). Divide can always be rewritten as Times[Power ..] or as Rational. > (a') Less can always be rewritten as Inequality[ ..], at least if > Mathematica didn't insist on rewriting in the opposite direction, > namely making Inequality[a,Less,b] into Less[a,b]. > (b). Divide does not have attributes Hold, HoldFirst, etc etc > (b') Neither does Less. > > So now we have set the stage for DanL and friends. > 1. Remove Less. and always replace it with Inequality ... > 2. Same for Greater, etc etc. > 3. (suggestion) Rename Inequality with Comparison. > 4. modify the rest of the programs, like Compile, Display, as = necessary. > 5. Change the documentation. > > > There may still be work to do for dealing with the elements in > Mathematica that do not obey the "law of trichotomy", which states > that a<b, a==b, or a>b. But this is not true for objects that are > not comparable. Like Complex numbers, various undefined objects, > Indeterminate, NaN. > > Yes, this seems plausible, but of course it would require a fundamental re-write of Mathematica for a very minor gain (though I admit that there would be some gain). But I would much rather Wolfram employed its resources on developing many new functions and algorithms that I actually use and that are important to me, so I would strenuously object to any idea of diverting these resources to anything of this kind. As I have pointed out to you many times, I consider these sort of things that seem to excite you so much as essentially of very little practical interest to the "working mathematician". I would certainly not pay any money to get this sort of improvement and I doubt many users would. > > Note that LogicalExpand does not distinguish between Less[x,y,z] and Inequality[x,Less,y,Less, z]. What do you mean by note? I pointed this out to you, LogicalExpand reduces both to the same canonical form. I am curious if you really believe your own words when you write stuff like this and whether I really like to imagine you discovered it all by yourself or knew it anyway. > > FullSimplify [Less[x,y,z]-Inequality[x,Less,y,Less,z] ] > does not reduce to zero, as it should. So Mathematica, dare > I say, exhibits a bug. No, these expressions are not equal but logically equivalent. The way to show that is In[103]:= Refine[Less[x, y, z], Inequality[x, Less, y, Less, z]] Out[103]= True In[104]:= Refine[Inequality[x, Less, y, Less, z], Less[x, y, z]] Out[104]= True or by using LogicalExpand (as you noticed below) > > Oh, LogicalExpand[Inequality[x,Less,y,Less,z]] is x<y&&y<z > as is LogicalExpand[x<y<z]. > > > Actually, you appear to be wrong, since > LogicalExpand[x<y<z] and LogicalExpand[z>y>x] are different. Again, In[107]:= Refine[x < y < z, z > y > x] Out[107]= True In[108]:= Refine[z > y > x, x < y < z] Out[108]= True Actually, it would be good to have a function that checked both implications at once (Refine performs the job of ImpliesQ in older versions of Mathematica). > > You appear to be proposing some > kind of alternative to disjunctive normal form (or conjunctive normal > form), both of which are quite well studied. Re-grouping of logical > terms for logic synthesis is also quite well studied, (see circuit > minimization). The general circuit minimization problem is believed to be intractable. Apparently there are advantages to a computer science > education :) I am certainly not proposing this, as should have been quite clear from what I wrote. I had assumed, I admit mistakenly, that that was what you were proposing as it did not come to my mind that you were instead proposing a massive re-write of Mathematica that would, in effect, eliminate Greater, Less etc. Thank you for confirming that the approach I thought you had proposed is intractable, as I had expected. I agree that there are some advantages to a computer science education - I do actually teach mathematics, and Mathematica, to some excellent computer science students (among the best in the world). But I think there are even more advantages to a mathematics education. For one, one is less inclined to keep eternally circling the same basic issues rather than getting to some interesting problems. Andrzej Kozlowski