Benjamin Jones <benjaminfjo...@gmail.com> writes: > 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 ].
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 . -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.