Re: How to do symbolic algebra in GF(2)={0,1}

30 views
Skip to first unread message
Message has been deleted

Pierre

unread,
Mar 11, 2014, 1:29:50 PM3/11/14
to sage-s...@googlegroups.com
You can try

sage: x= polygen(GF(2), "a")

and try a few expressions involving x. For example

sage: 2*x
0

since 2=0 in GF(2).

Pierre

On Tuesday, March 11, 2014 3:25:04 PM UTC+1, Prakash Dey wrote:
I am new to sage.

x=var('a')
print x*x*x*x+x*x*x+x*x+x

How to do this symbolic algebra in GF(2)={0,1} ?

Message has been deleted
Message has been deleted

Christian Nassau

unread,
Mar 11, 2014, 2:26:13 PM3/11/14
to sage-s...@googlegroups.com
You could work in the polynomial ring generated by the ak, modulo the
relation ak**2 = ak:

P=PolynomialRing(GF(2),["a%d" % i for i in (0,..,5)])
I=P.ideal([u*u-u for u in P.gens()])
Q=P.quotient(I)
@cached_function
def z(k):
if k < 6: return Q.gens()[k]
return z(k-6)+z(k-3)+z(k-2)*z(k-1)

for z(40) you then get

sage: Q.lift(z(40))
a0*a1*a2*a3*a4 + a0*a1*a3*a4*a5 + a1*a2*a3*a4*a5 + a0*a1*a2*a3 +
a0*a1*a2*a4 + a0*a1*a3*a4 + a0*a1*a3*a5 + a0*a2*a3*a5 + a1*a2*a3*a5 +
a0*a2*a4*a5 + a0*a3*a4*a5 + a1*a3*a4*a5 + a2*a3*a4*a5 + a0*a1*a2 +
a0*a2*a3 + a0*a3*a4 + a0*a1*a5 + a0*a2*a5 + a1*a2*a5 + a1*a3*a5 +
a1*a4*a5 + a0*a1 + a0*a2 + a1*a3 + a2*a3 + a0*a5 + a1*a5 + a4*a5 + a4

Hope this helps,
C.

On 03/11/2014 07:02 PM, Prakash Dey wrote:
> Thanks. But
>
> x= polygen(GF(2), "a")
> y= polygen(GF(2), "b")
> print x+y
> -----------------------> gives error
>
> How to do this symbolic algebra in GF(2)={0,1} ?
>
> My need is the following:
> I have a recurrence relation like z[t+6]=z[t]+z[t+3]+z[t+4]*z[t+5] in GF(2)
> taking z[0]=a0,z[1]=a1,...,z[5]=a5
> i want to find the value of z[40] in a0,a1,..,a5
>

Prakash Dey

unread,
Mar 11, 2014, 3:32:09 PM3/11/14
to sage-s...@googlegroups.com
Thanks. It solves my problem.

Nils Bruin

unread,
Mar 11, 2014, 7:31:35 PM3/11/14
to sage-s...@googlegroups.com


On Tuesday, March 11, 2014 11:26:13 AM UTC-7, Christian Nassau wrote:
You could work in the polynomial ring generated by the ak, modulo the
relation ak**2 = ak

For which sage  wraps a specially optimized library PolyBoRi:

sage: R.<a,b,c>=BooleanPolynomialRing(3)
sage: (a+b+c)*(a+b)
a*c + a + b*c + b

Reply all
Reply to author
Forward
0 new messages