# Sage subs() function include product condition

Code:

from brial import *
katan=declare_ring([Block('x',32),Block('k',80)],globals())

r1=x(3)*x(8) + x(7) + x(10)*x(12) + x(18) + x(23) + k(1) + k(16)

r2 = r1.subs({x(3)*x(8)+x(7)+ x(10)*x(12)+ x(18) + x(23) + k(1) + k(16) : 0})
print(r2)


this is a sage code, make r1 equals a polynomial include some variables, then use the subs() function to fix some variable, in this case, let the polynomial equals 0, so the expected result of r2 is 0, but the sage gives the result is

x(7) + x(10)*x(12) + x(18) + x(23) + k(1) + k(16)

i know , some thing wrong with the x(3)*x(8), but i don't know how to make it right.

edit retag close merge delete

( 2018-12-07 12:38:38 -0500 )edit

Sort by ยป oldest newest most voted

If you want to mod out by r1, you could use a quotient ring.

One good option is to project to the quotient ring and then lift back to the original ring.

sage: from brial import *
sage: katan = declare_ring([Block('x', 32), Block('k', 80)], globals())
sage: r1 = x(3)*x(8) + x(7) + x(10)*x(12) + x(18) + x(23) + k(1) + k(16)
sage: r1
x(3)*x(8) + x(7) + x(10)*x(12) + x(18) + x(23) + k(1) + k(16)
sage: J = katan.ideal([r1])
sage: R = katan.quotient(J)
sage: r2 = R(r1).lift()
sage: r2
0

more

it's very helpful, thank you so much

( 2019-01-15 04:50:18 -0500 )edit