Ticket #1163 (assigned defect)

Opened 1 year ago

Last modified 9 months ago

assume seems to have some undesired side-effects

Reported by: zimmerma Assigned to: gfurnish (accepted)
Priority: major Milestone: sage-3.2.2
Component: calculus Keywords:
Cc:

Description

sage: assume(x > 0)
sage: sqrt(x^2)
x
sage: assume(x < 0)
sage: sqrt(x^2)
x

Maybe it is not allowed to make two assumptions on the same variable, without any forget inbetween, anyway the documentation should be clear about this, or a warning should be issued. Also, is there a way to know which assumptions were made on a given variable (like about in Maple)?

Change History

11/13/2007 12:41:41 PM changed by jason

A couple of notes:

The "assumptions()" command lists assumptions. See assumptions? for documentation.

It seems that the order in which the assumptions are made matters (only the first assumption is used below).

Should assume complain if we say that x>0 and x<0?

sage: assumptions()
[]
sage: assume(x<0)
sage: sqrt(x^2)
-x
sage: assume(x>0)
sage: sqrt(x^2)
-x
sage: assumptions()
[x < 0, x > 0]
sage: forget()
sage: assumptions()
[]
sage: assume(x>0)
sage: assume(x<0)
sage: assumptions()
[x > 0, x < 0]
sage: sqrt(x^2)
x

11/13/2007 02:51:26 PM changed by zimmerma

Sorry I did not know about the assumptions() command. Maybe assume? should point to it. Is a SEE ALSO section possible in the documentation? Also consider (from Wester's test suite):

sage: assume(x>=y, y>=z,z>=x)
sage: assumptions()
[x >= y, y >= z, z >= x]
sage: print bool(x==z)
False

Yes assume should complain if we say that x>0 and x<0 (at least if it can lead to wrong results).

11/13/2007 02:53:44 PM changed by zimmerma

More strange results:

sage: assume(x > 0)
sage: bool (x <> 1)
True

and:

sage: assume(x <= 1, x >= 1)
sage: bool(x==1)
False

11/13/2007 04:12:04 PM changed by jason

Those are some unsettling results. I don't know if this is the easiest route, but it seems like QEPCAD could handle some of these if it were integrated into SAGE. For example, we can ask QEPCAD the following questions. In these, (Ex) means "there exists an x" and (Ax) means "For all x" and "/=" means "not equal".

  • (Ex)(Ey)(Ez) [ x>=y /\ y>=z /\ z>=x /\ x/=z] (returns False)
  • (Ex) [ x>0 /\ x/= 1] (returns True)
  • (Ex) [ x>0 /\ x=1] (returns True)
  • (Ex) [ x<=1 /\ x>=1 /\ x /= 1] (returns False)

Here's another example:

  • (Ax)(Ay) [x^2+y^2>=0] (returns True).

We could ask much more general questions too.

I've been (very slowly) working on interfacing QEPCAD to SAGE, but lack of time and the learning process of making an interface is slowing me down. Also, we need to follow up on the license issue. For progress in this interface, see #772 )

11/13/2007 04:33:36 PM changed by jason

Apparently Maxima complains (behind the scenes?):

Maxima 5.12.0 http://maxima.sourceforge.net
Using Lisp GNU Common Lisp (GCL) GCL 2.6.7 (aka GCL)
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
This is a development version of Maxima. The function bug_report()
provides bug reporting information.
(%i1) assume(x<0);
(%o1)                               [x < 0]
(%i2) assume(x>0);
(%o2)                           [inconsistent]

11/13/2007 04:43:11 PM changed by jason

More results from Maxima:

Maxima 5.12.0 http://maxima.sourceforge.net
Using Lisp GNU Common Lisp (GCL) GCL 2.6.7 (aka GCL)
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
This is a development version of Maxima. The function bug_report()
provides bug reporting information.
(%i1) assume(x>=y,y>=z,z>=x);
(%o1)                      [x >= y, y >= z, z >= x]
(%i2) is(x=z);
(%o2)                                false
Maxima 5.12.0 http://maxima.sourceforge.net
Using Lisp GNU Common Lisp (GCL) GCL 2.6.7 (aka GCL)
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
This is a development version of Maxima. The function bug_report()
provides bug reporting information.
(%i1) assume(x>0);
(%o1)                               [x > 0]
(%i2) is(x#1);
(%o2)                                true

and

Maxima 5.12.0 http://maxima.sourceforge.net
Using Lisp GNU Common Lisp (GCL) GCL 2.6.7 (aka GCL)
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
This is a development version of Maxima. The function bug_report()
provides bug reporting information.
(%i1) assume(x<=1);
(%o1)                              [x <= 1]
(%i2) assume(x>=1);
(%o2)                              [x >= 1]
(%i3) is(x=1);
(%o3)                                false

So it seems like the problem is the Maxima assumptions engine. According to the documentation at http://maxima.sourceforge.net/docs/manual/en/maxima_11.html

Maxima's deduction mechanism is not very strong; there are many obvious consequences which cannot be determined by is. This is a known weakness.

11/13/2007 05:21:11 PM changed by jason

One more note:

QEPCAD also simplifies the expression [x>=y /\ y>=z /\ z>= x] to [y-x=0 /\ z-y = 0].

03/16/2008 01:11:30 PM changed by gfurnish

  • owner changed from was to gfurnish.
  • status changed from new to assigned.