1// [email protected]
2SetColumns(50);
3//SetRows(20);
4
5Q := Rationals();
6
7P<r,s,t,u,v,w,
8  x01,x02,x03,x04,x05,x06,x07,x08,
9  x09,x10,x11,x12,x13,x14,x15,x16> := PolynomialRing(Q,22);
10eqn := [];
11for outer := 0 to 15 do
12  ul := outer mod 2;
13  ur := (outer div 2) mod 2;
14  ll := (outer div 4) mod 2;
15  lr := (outer div 8) mod 2;
16  outereqn := 0;
17  for inner := 0 to 3 do
18    innereqn := 1;
19    il := inner mod 2;
20    ir := (inner div 2) mod 2;
21    if ul eq il then
22      innereqn *:= 1-r;
23    else
24      innereqn *:= r;
25    end if;
26    if ll eq il then
27      innereqn *:= 1-s;
28    else
29      innereqn *:= s;
30    end if;
31    if il eq ir then
32      innereqn *:= 1-t;
33    else
34      innereqn *:= t;
35    end if;
36    if ur eq ir then
37      innereqn *:= 1-u;
38    else
39      innereqn *:= u;
40    end if;
41    if lr eq ir then
42      innereqn *:= 1-v;
43    else
44      innereqn *:= v;
45    end if;
46    outereqn +:= innereqn;
47  end for;
48  Append(~eqn,outereqn);
49
50end for;
51
52neweqn := [];
53
54temp := x01 - w*eqn[1]; Append(~neweqn, temp);
55temp := x02 - w*eqn[2]; Append(~neweqn, temp);
56temp := x03 - w*eqn[3]; Append(~neweqn, temp);
57temp := x04 - w*eqn[4]; Append(~neweqn, temp);
58temp := x05 - w*eqn[5]; Append(~neweqn, temp);
59temp := x06 - w*eqn[6]; Append(~neweqn, temp);
60temp := x07 - w*eqn[7]; Append(~neweqn, temp);
61temp := x08 - w*eqn[8]; Append(~neweqn, temp);
62temp := x09 - (1-w)*eqn[9]; Append(~neweqn, temp);
63temp := x10 - (1-w)*eqn[10]; Append(~neweqn, temp);
64temp := x11 - (1-w)*eqn[11]; Append(~neweqn, temp);
65temp := x12 - (1-w)*eqn[12]; Append(~neweqn, temp);
66temp := x13 - (1-w)*eqn[13]; Append(~neweqn, temp);
67temp := x14 - (1-w)*eqn[14]; Append(~neweqn, temp);
68temp := x15 - (1-w)*eqn[15]; Append(~neweqn, temp);
69temp := x16 - (1-w)*eqn[16]; Append(~neweqn, temp);
70
71I := ideal<P|neweqn>;
72I;
73SetVerbose("Groebner",true);
74B := GroebnerBasis(I);
75B;
76