On Mon, Jan 7, 2013 at 10:53 AM, Keshav Kini <keshav.k...@gmail.com> wrote: > 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. > >
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. So, what should x*(y > 0) do, raise a NotImplementedError? And x*(y == 0)? I guess we just special case inequalities. -- 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.