On Mon, Dec 17, 2012 at 9:32 PM, P Purkayastha <ppu...@gmail.com> wrote:

> On 12/18/2012 10:10 AM, Benjamin Jones wrote:
>
>> if y > 0 is true,
>> is x*(y > 0) true or false?
>>
>
> Why is this kind of operation (+,-,*, etc) distributive over comparison
> operators? Is this distributive operation well defined in general, maybe
> according to some theory?
>
>
If you think about the comparison operators as type constructors (for the
SR type), it's useful for them to be functors. In other words, it's useful
to be able to map over them, e.g. map the function that is multiplication
by a constant element of SR over a comparison:

sage: y = var('y')
sage: x * (y > 0)
x*y > 0

Just like applying the operator (x*_) over a list [ y, 0 ].

Another example:

sage: f(x) = x + 1
sage: y = var('y')
sage: expr = y > 0
sage: f(expr)
(y > 0) + 1

If > was a functor, you would expect to get f(y) > f(0), which is y + 1 >
1. And indeed,

sage: (y > 0) + 1
y + 1 > 1

So things look consistent. This even works for non-linear functions:

sage: f(x) = x^2+1
sage: f(y > 0)
(y > 0)^2 + 1
sage: (y > 0)^2 + 1
y^2 + 1 > 1

--
Benjamin Jones

-- 
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