# Extract equalities from a list of assumptions

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

thanks,

Extract equalities from a list of assumptions

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

thanks,

add a comment

3

Let

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

Then

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

versus

```
sage: eq2.operator() == operator.lt
True
```

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).

3

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.lt, operator.le, operator.gt, operator.ge]]
sage: equalities
[y == 2]
sage: inequalities
[x > 0, x <= 1]
```

You might want to put `operator.ne`

somewhere.

Asked: **
2016-01-03 07:49:04 -0600
**

Seen: **48 times**

Last updated: **Jan 03 '16**

Solving an inequality symbolically under constraints

How to do operations that change a relation?

Solving a simple system of inequalities

(Unexpanded) symbolic inequalities yield erroneous results

Checking if two inequalities are equivalent

Problem with assumption (in RR)

solving a set of equations involving both inequalities and equalities

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.