2

I am trying to construct polynomials over a two-valued finite field {0, 1}, and I want them to automatically simplify using some identities that exist in this setting.

I have tried the following:

    from sympy import *
    from sympy.polys.domains.finitefield import FiniteField
    x, y, z, t = symbols('x y z t')

    k = Poly(x+y * z*z + (x + y) + y + 1, domain=FiniteField(2))

This already simplifies to:

Poly(y*z**2 + 1, x, y, z, modulus=2)

However, the z**2 is actually the same as z in the field that I want to use. It does seem to automatically recognize that y + y = 0. How can I implement the other identity, z * z = z (idempotency)?

1 Answers1

0

What you want doesn't seem to implemented for poly but maybe you can simulate the effect:

In [54]: normalise = lambda p: Poly(ratsimpmodprime(p, [n**2-n for n in p.free_symbols]), modulus=2)                                                                                                               

In [55]: e = x+y * z*z + (x + y) + y + 1                                                                                                                                                                           

In [56]: normalise(e)                                                                                                                                                                                              
Out[56]: Poly(y*z + 1, x, y, z, modulus=2)
Oscar Benjamin
  • 12,649
  • 1
  • 12
  • 14