Ask Your Question

Equivalence operator

asked 2012-10-26 04:08:10 -0500

sage_learner gravatar image

Hi ! Here I have a small sage code.

x = var('x'); assume(x>0); print([x>0] == [1==1])

Sage prints it as "False".

In the above piece of code "[x>0] == [1==1]" is logically true as there is already an assumption, though it gives False.

I wish to know How does comparison operator "==" works ? Specially when comparing two predicates ? Does there any other function exist for such comparison ?

Best regards

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2012-10-26 07:14:07 -0500

ndomes gravatar image

First: [x>0] is a list



In your equation

[x>0] == [1==1]

you actually compare two different lists.

(x>0) == (1==1)

doesn't help

x>0 is a symbolic expression

1==1 gives the logical value True

What you can do is:

print(bool(x>0) == bool(1==1))
edit flag offensive delete link more


Thank you very much !

sage_learner gravatar imagesage_learner ( 2012-10-26 10:10:36 -0500 )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


Asked: 2012-10-26 04:08:10 -0500

Seen: 160 times

Last updated: Oct 26 '12