Ask Your Question
1

Equivalence operator

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

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 07:14:07 -0600

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 10:10:36 -0600 )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 04:08:10 -0600

Seen: 100 times

Last updated: Oct 26 '12