'Is there a way to simplify a system of polynomial equations in sympy?

I have the following identity:

1 = a + b + c

Supose that I have the expression:

expr = x*(a + b + c)

It can be simplified as x.

Is there a way to declare it to SymPy so it can simplify them? Actually I do the job mannualy:

>>> import sympy
>>> sympy.vars("x a b c")
>>> expr = x*(a + b + c)
>>> expr.subs(a + b + c, 1)
x


Solution 1:[1]

The ratsimpmodprime function will work in your case. It simplifies a rational function with respect to some polynomials that are assumed to be equal to zero:

In [13]: a, b, c, x = symbols('a, b, c, x')

In [14]: polys = [a + b + c - 1]

In [15]: basis = groebner(polys).polys

In [16]: ratsimpmodprime(x*(a + b + c), basis)
Out[16]: x

https://docs.sympy.org/latest/modules/simplify/simplify.html#ratsimpmodprime

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Oscar Benjamin