Ask Your Question

Extract equalities from a list of assumptions

asked 2016-01-03 14:49:04 +0200

daniele gravatar image

Hi, how can I recognize an equality from an inequality, in a list of assumptions?


edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2016-01-03 17:03:53 +0200

vdelecroix gravatar image


sage: var('a,b')
sage: eq1 = a == b
sage: eq2 = a < b


sage: eq1.operator() == operator.eq


sage: eq2.operator() ==

operator is a python module and the comparison operators are lt (less than), le (lesser or equal), eq (equal), ne (different), gt (greater than) and ge (greater or equal).

edit flag offensive delete link more

answered 2016-01-03 17:13:52 +0200

tmonteil gravatar image

To complement @vdelecroix answer, the assumptions is a list of symbolic expressions which you can filter as follows:

sage: var('x,y')
(x, y)
sage: assume(x>0)
sage: assume(x<=1)
sage: assume(y==2)
sage: equalities = [ass for ass in assumptions() if ass.operator() == operator.eq]
sage: inequalities = [ass for ass in assumptions() if ass.operator() in [, operator.le,,]]
sage: equalities
[y == 2]
sage: inequalities
[x > 0, x <= 1]

You might want to put somewhere.

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

1 follower


Asked: 2016-01-03 14:49:04 +0200

Seen: 368 times

Last updated: Jan 03 '16