I agree.  If anything, I think we may need to have separate classes to
represent a < b the inequality and a < b the boolean.  One problem
with Le(3, 4) not returning True is that constructs like

if a < b:
   do something

will break if a or b are sympified, because a < b returns Lt(a, b) in
that case.  But I think those should really be using the assumptions,
i.e.,

if Ask(b - a, Q.positive):
    do something

I think the main problem is that it doesn't play so nice if you want
to include an inequality in a boolean expression.  So for that case, I
think we should have a separate boolean Le, Eq, Gt, etc., which would
be shortcuts to the Ask(b - a, Q.positive/nonnegative/zero/etc.), or
would return an instance of Boolean otherwise (I'm not sure what they
should be called, though).  See issue 1887 and issue 2030.

See also the discussion over at
http://code.google.com/p/sympy/issues/detail?id=1932 (I don't know if
I still agree with myself there, but I am basically saying what smichr
said in comment 5).

Aaron Meurer

On Wed, Nov 24, 2010 at 1:40 PM, Filip Dominec <filip.domi...@gmail.com> wrote:
> If I can contribute to the discussion, I support the simpler behavior
> when Le(3,4) stays as a inequation until it has to be evaluated. Not
> only the shortcut to True/False has now proven to bring in an error in
> the solving routine, it is possible that in some situation one will
> want to extract the left and right sides back into two expressions.
>
> On Nov 24, 5:22 pm, Aaron Meurer <asmeu...@gmail.com> wrote:
>> Perhaps it has something to do with solve not taking into account that
>> Le() and friends evaluate themselves to a boolean in trivial cases:
>>
>> In [1]: Le(3,4)
>> Out[1]: True
>>
>> But the only way to really know for sure is to debug the code.
>>
>> By the way, there's been some debate before on whether or not it is a
>> good idea for Le() to be doing this, so maybe now a working
>> implementation of an inequality solve can shed some more light on the
>> matter.
>>
>> Aaron Meurer
>>
>>
>>
>>
>>
>>
>>
>> On Wed, Nov 24, 2010 at 3:12 AM, Filip Dominec <filip.domi...@gmail.com> 
>> wrote:
>> > I am working on a new solve() routine to fix the issue discussed in my
>> > previous post.
>>
>> > However, I observed a bug (?) that sticks deep in the code. I am using
>> > the "git clone https://matt...@github.com/mattpap/sympy-polys.git; cd
>> > sympy-polys ; git checkout polys11" version.
>>
>> > In [388]: solve([Le(3,0), Assume(x,Q.real)],x,relational=False)
>> > Out[388]: False
>>
>> > In [389]: solve([Le(3,4), Assume(x,Q.real)],x,relational=False)
>> > ---------------------------------------------------------------------------
>> > UnboundLocalError                         Traceback (most recent call
>> > last)
>>
>> > /home/filip/<ipython console> in <module>()
>>
>> > /home/filip/bin/sympy101118/sympy-polys/sympy/solvers/solvers.pyc in
>> > solve(f, *symbols, **flags)
>> >    153
>> >    154     if any(isinstance(fi, bool) or (fi.is_Relational and not
>> > fi.is_Equality) for fi in f):
>> > --> 155         return solve_poly_inequalities(f,
>> > relational=relational)
>> >    156
>> >    157     for i, fi in enumerate(f):
>>
>> > /home/filip/bin/sympy101118/sympy-polys/sympy/solvers/inequalities.pyc
>> > in solve_poly_inequalities(inequalities, relational)
>> >    152         results[gen] = result
>> >    153
>> > --> 154     if relational or not real:
>> >    155         solution = And(*results.values())
>> >    156     else:
>>
>> > UnboundLocalError: local variable 'real' referenced before assignment
>>
>> > --
>> > You received this message because you are subscribed to the Google Groups 
>> > "sympy" group.
>> > To post to this group, send email to sy...@googlegroups.com.
>> > To unsubscribe from this group, send email to 
>> > sympy+unsubscr...@googlegroups.com.
>> > For more options, visit this group 
>> > athttp://groups.google.com/group/sympy?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "sympy" group.
> To post to this group, send email to sy...@googlegroups.com.
> To unsubscribe from this group, send email to 
> sympy+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/sympy?hl=en.
>
>

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

Reply via email to