ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 26 Oct 2012 17:10:36 +0200Equivalence operatorhttps://ask.sagemath.org/question/9467/equivalence-operator/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 regardsFri, 26 Oct 2012 11:08:10 +0200https://ask.sagemath.org/question/9467/equivalence-operator/Answer by ndomes for <p>Hi !
Here I have a small sage code.</p>
<p>x = var('x'); assume(x>0); print([x>0] == [1==1])</p>
<p>Sage prints it as "False".</p>
<p>In the above piece of code "[x>0] == [1==1]" is logically true as there is already an assumption, though it gives False.</p>
<p>I wish to know How does comparison operator "==" works ? Specially when comparing two predicates ? Does there any other function exist for such comparison ?</p>
<p>Best regards</p>
https://ask.sagemath.org/question/9467/equivalence-operator/?answer=14187#post-id-14187First: [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))Fri, 26 Oct 2012 14:14:07 +0200https://ask.sagemath.org/question/9467/equivalence-operator/?answer=14187#post-id-14187Comment by sage_learner for <p>First: [x>0] is a list </p>
<p>see:</p>
<pre><code>type([x>0])
</code></pre>
<p>In your equation</p>
<pre><code>[x>0] == [1==1]
</code></pre>
<p>you actually compare two different lists.</p>
<p>(x>0) == (1==1)</p>
<p>doesn't help </p>
<p>x>0 is a symbolic expression</p>
<p>1==1 gives the logical value True</p>
<p>What you can do is: </p>
<pre><code>assume(x>0)
print(bool(x>0) == bool(1==1))
</code></pre>
https://ask.sagemath.org/question/9467/equivalence-operator/?comment=18810#post-id-18810Thank you very much ! Fri, 26 Oct 2012 17:10:36 +0200https://ask.sagemath.org/question/9467/equivalence-operator/?comment=18810#post-id-18810