Ask Your Question
0

Idea behind not evaluating symbolic equations

asked 2011-11-03 05:44:22 +0100

Daniel Krenn gravatar image

Can anyone explain me the following behavior of Sage: What is the idea behind not evaluating symbolic equations which are (obviously) true? For example:

sage: m = var('m')
sage: m == m
m == m

Evaluation works with

sage: bool(m == m)
True
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2011-11-03 09:33:56 +0100

DSM gravatar image

I can think of a few reasons:

(1) Symbolic equations and boolean values are different kinds of thing, and magical coercions like that should be avoided as a general principle. For example, if it autocoerces, it would be awkward to print out a symbolic expression that Sage decides is true. You also couldn't start from a known true equation and work toward something else.

(2) If you have a list of symbolic equations and you substitute values into them, with this autocoercion you could wind up with a list of symbolic equations and some boolean values scattered in. You can't continue to substitute into boolean values, so now you have to write every line of symbolic manipulation code with branches just in case your expression is suddenly a Python bool.

(3) How are you going to decide when to convert to boolean or not? You can't let it return False, because Sage will return False even if something is true but it can't prove it. So you could only ever coerce when Sage decides it's true, which means it'd be hard to explain the conditions under which the coercion took place, among other reasons because

(4) This means that Sage will have to either try to convert every symbolic expression to a boolean, which can sometimes be really slow, or you'll have to have a set of conditions to decide when to give up on trying to prove something, and those will be pretty arbitrary by necessity.

ISTM there would be lots of disadvantages to this autocoercion and I can't think of a significant advantage it offers. All of my objections are consequences of (1), really: an expression is a different kind of thing than a boolean, and both are useful.

edit flag offensive delete link more

Comments

One disadvantage is that `m==m` has to be put in `bool` to be `True`, which a user might not know about or might seem onerous to a user.

kcrisman gravatar imagekcrisman ( 2011-11-03 09:36:37 +0100 )edit
2

maybe adding a "is_true" procedure or similar for this kind of objects would be a good idea?

mmarco gravatar imagemmarco ( 2011-11-03 10:26:31 +0100 )edit

Open a ticket :) at least it's worth discussing on Trac.

kcrisman gravatar imagekcrisman ( 2011-11-03 11:45:03 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2011-11-03 05:44:22 +0100

Seen: 646 times

Last updated: Nov 03 '11