Ask Your Question
1

Equivalence operator

asked 2012-10-26 11:08:10 +0100

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
3

answered 2012-10-26 14:14:07 +0100

ndomes gravatar image

First: [x>0] is a list

see:

type([x>0])

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:

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

Comments

Thank you very much !

sage_learner gravatar imagesage_learner ( 2012-10-26 17:10:36 +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: 2012-10-26 11:08:10 +0100

Seen: 714 times

Last updated: Oct 26 '12