Benjamin Jones <benjaminfjo...@gmail.com> writes:
> On Mon, Jan 7, 2013 at 10:53 AM, Keshav Kini <keshav.k...@gmail.com> wrote:
>> Benjamin Jones <benjaminfjo...@gmail.com> writes:
>>> sage: y = var('y')
>>> sage: x * (y > 0)
>>> x*y > 0
>>>
>>> Just like applying the operator (x*_) over a list [ y, 0 ].
>>
>> Couldn't you apply the same logic to "*" as well? Now (a * b) * c
>> becomes (a * c) * (b * c), which is obviously not what we want.
>>
>> Certainly it's nice to be able to map over things. I would think that
>> there should be some actual syntax for this, though, rather than just
>> implicitly distributing all operations over relational operators. As far
>> as I can see, the only thing that's special here about relational
>> operators as opposed to arithmetic operators is that we don't currently
>> have a coherent way of resolving the application of other operators to
>> relational expressions. I don't think that should mean that by default
>> we just distribute.
>>
>> See also http://trac.sagemath.org/sage_trac/ticket/7660#comment:8 .
>
> I agree that an explicit syntax for mapping over relations would be
> better than having it done implicitly. But, then again, it would be
> nice to  implicitly map over equality, there would be no confusion
> there.

I disagree that there would be no confusion, or even that it would be
nice to implicitly map arithmetic operations. I reproduce below the
comment I made on the trac ticket several months ago:

It doesn't seem at all reasonable to me to distribute multiplication
over a relation. When you distribute multiplication over addition, the
addition expression (a+b) lives in the same space as a and b
individually. This is not the case with (x<y) and x and y.

There is no mathematical rationale for saying that (-1)*(x<y) is -x < -y
or -x > -y or anything other than just (-1)*(x<y). I'm sure many can
recall when they first learned basic algebra that their teacher was
careful to say "we multiply both sides of the equation by c", not "we
multiply the equation by c", just as he or she was careful to say "we
multiply both the numerator and denominator of the fraction by c",
rather than the dangerous "we multiply the fraction by c"!

If we allow multiplication to distribute over x<y as if it were a
two-coordinate vector, do we want other similarities with vector
arithmetic to come into play? Should (a+b)*(x<y) be equal to a*(x<y) +
b*(x<y)? Now we have addition and presumably subtraction of relational
expressions. What is 0*(x<y)? What is (x<y) + (z>y)? Should we attempt
to reverse inequalities to make them match up when adding them? Do we
then end up with (x+y<y+z), or (y+z>x+y)? Or, do we conclude that (z>y)
is equal to (-1)*(-z<-y), and so (x<y) + (z>y) == (x<y) - (-z<-y) ==
(x+z<2y)? Going beyond vector-like arithmetic, what happens when you add
a scalar to a relational expression? What is (x<y) + 3?

I think the most sensible answer to all the above questions is the
following: we should not perform arithmetic on relational expressions;
when asked to do so, we should return a purely formal expression.

-Keshav

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To post to this group, send email to sage-devel@googlegroups.com.
To unsubscribe from this group, send email to 
sage-devel+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel?hl=en.


Reply via email to