Solving system of Linear Equatin over finite fields.

173 views
Skip to first unread message

Ha

unread,
May 10, 2022, 3:40:48 AM5/10/22
to sage-support
Hi,
I need to solve a system of linear equations [over finite fields] which are obtained from system of polynomials by l substitution   of some variables.  
For example:   If we start with F[x1,x2,x3] = x1*x2+x3+1 and let x1 = 1 then we get
L[x2,x3] = F(1,x2,x3) = x2+x3+1 --> a linear equation.
Need to solve L == constant over a finite field Fp.

I tried the following method. But no luck.

##--------------------------------------------------------
n=10
F = GF(7)
Rx=PolynomialRing(F,n,'x')
X=Rx.gens()
f = x2+ x1 * x5 - 1
print(f)
v=list(X)
v[1]=1
v[2]=5
print(f(v))
eqns = [f(v) == 1]
sol = solve_mod(eqns, 7)
print(sol)
##------------------------------------------------------
Getting error:
  • AttributeError: 'bool' object has no attribute 'lhs'

Emmanuel Charpentier

unread,
May 11, 2022, 4:43:23 AM5/11/22
to sage-support

Your example has several problems :

1) You don’t define your polynomial indeterminates ; you should Rx.inject_variables().

2) The syntax you use to substitute values in f is questionable…

3) f(v) is a polynomial in x0..x9 over GF(7), not a symbolic expression. Therefore f(v)==1 is not a symbolic equation ; it just tests if f(v) is equal to 1, which isFalse`. Hence the “error” you get.

4) solve_modis a function working on symbolic equations systems. Passing a (list of) polynomial(s) as its first argument will fail. If you want to use this function, us it on symbolic equation systems.

5) “Solving” polynomial systems use other methods. Perusing the documentation and the source the latter points to is highly recommended.

HTH,

xiaoy...@gmail.com

unread,
May 11, 2022, 4:54:13 AM5/11/22
to sage-support

sage: R.<x,y,z> = PolynomialRing(GF(7),3)

sage: I = R.ideal(x*y+z+1-1, x-1, y-5)

sage: I

Ideal (x*y + z, x - 1, y + 2) of Multivariate Polynomial Ring in x, y, z over Finite Field of size 7

sage: I.variety()

[{z: 2, y: 5, x: 1}]

Reply all
Reply to author
Forward
0 new messages