# cocycle.py -- from the centrally regular subgroups R (usage: cocycle.py matrix.txt R.npy out.json, with R.npy written # by cocyclic16.py or cocyclicodd.py), extract for each of them an explicit # cocycle psi : G x G -> {-1,1} with H equivalent to (psi(g,h)), check the cocycle identity, build the extension group # E = {-1,1} x G, with (e,g)(f,h) = (e f psi(g,h), gh), and decide whether psi is a coboundary over T, that is, # whether z = (-1,1) is outside [E,E]. Writes the labelings, the group table of G and psi to cocycle.json (or to the file given as 3rd argument). import numpy as np, sys, json, itertools H=np.loadtxt(sys.argv[1] if len(sys.argv)>1 else 'had163.txt').astype(int); N=len(H) Rs=np.load(sys.argv[2] if len(sys.argv)>2 else 'cocyclic16_R.npy') Rs=[R for R in Rs] def pmul(a,b): return tuple(a[x] for x in b) def pinv(a): r=[0]*len(a) for i,x in enumerate(a): r[x]=i return tuple(r) def qmat(g): Q=np.zeros((N,N),int) for j in range(N): c=int(g[j]); Q[c%N,j]=1 if c (perm, signs) with M e_j = s_j e_perm(j) p=[int(np.nonzero(M[:,j])[0][0]) for j in range(N)]; return tuple(p),tuple(int(M[p[j],j]) for j in range(N)) out=[] for R in Rs: R=[tuple(int(v) for v in g) for g in R] # the quotient G = R/ acting on columns (unsigned), each element with one lift lift={} for g in R: k=tuple(x%N for x in g[:N]) lift.setdefault(k,g) G=sorted(lift); e=tuple(range(N)); assert len(G)==N and e in G ix={g:k for k,g in enumerate(G)} mult=[[ix[pmul(a,b)] for b in G] for a in G] # row action: P H Q = H with P = H Q^T H^T / N; unsigned row permutation rowp={g:sperm(np.rint(H@qmat(lift[g]).T@H.T/N).astype(int))[0] for g in G} colp={g:g for g in G} found=None for ri,ci in itertools.product((False,True),repeat=2): rl=[ (rowp[pinv(g)] if ri else rowp[g])[0] for g in G] # row label of g: image of row 0 cl=[ (colp[pinv(g)] if ci else colp[g])[0] for g in G] if len(set(rl))3 else 'cocycle.json','w')) from collections import Counter print("summary:",dict(Counter((o["group"],o["z_in_commutator"]) for o in out))) print("cocyclic matrix (psi(g,h)) of the first one, + and - for 1 and -1:") for row in out[0]["psi"]: print(" "+"".join('+' if v>0 else '-' for v in row))