
ClearAll["Global`*"];​​SetSystemOptions["ReduceOptions"->"MaxModularPoints"->10^7];​​​​(*runonceper(n,lambda)choice*)​​RunHopf[n_Integer,lambda_Integer:1,computeEnhanced_:True]:=Module[{J,M,vars,v1,v2,v3,v4,e1,e2,e3,e4,relations,tSolve,soln,count,residuals,chk,okQ,solList,imgSizes,tallies,phiE,tag,mStr},Print["--- Hopf#Hopf over 𝔽_",n," with M = ",lambda," J ---"];​​J={{0,1},{-1,0}};​​M=Mod[lambdaJ,n];​​Print["Modulus n = ",n,"; M =\n",MatrixForm[M]];​​(*variables:four2Darc-vectors*)vars=Array[Subscript[x,##]&,{4,2}];​​{v1,v2,v3,v4}=vars;​​(*quandlerelations(symplectic:x▷y=x+<x,y>y,<x,y>=x.M.y^T)*)e1=v1+(v1.M.v3)v3;​​e2=v3+(v3.M.v1)v1;​​e3=v2+(v2.M.v4)v4;​​e4=v4+(v4.M.v3)v3;​​relations=Thread[{v1,v2,v3,v4}=={e1,e2,e3,e4}];​​{tSolve,soln}=AbsoluteTiming[Solve[relations,Flatten[vars],Modulus->n]];​​count=Length[soln];​​Print["Solve time (s): ",NumberForm[tSolve,{6,3}]];​​Print["|Hom(Q(H), M)| = ",count];​​(*verification*)residuals={v1-e1,v2-e2,v3-e3,v4-e4};​​chk=Mod[residuals/.soln,n];​​okQ=AllTrue[Flatten@chk,#==0&];​​If[okQ,Print["OK: all relations satisfied modulo ",n,"."],With[{badIdx=Flatten@Position[Map[AllTrue[Flatten@#,#==0&]&,chk],False]},Print["WARNING: some relations are nonzero modulo ",n,". Bad solution indices: ",badIdx];]];​​If[TrueQ[computeEnhanced],solList=vars/.soln;(*solutionsas4arc-vectors*)imgSizes=CountDistinct/@solList;(*#colorspersolution*)tallies=SortBy[Tally[imgSizes],First];​​phiE=Total[(#[[2]])*q^(#[[1]])&/@tallies];​​Print["Tallies (m, a_m): ",tallies];​​Print["Φ_E(H, M) = ",phiE];];​​(*exportasmallresultsfile*)tag="Z"<>ToString[n]<>"-lam"<>ToString[lambda];​​mStr="results-HopfSum-"<>tag<>".txt";​​Export[mStr,If[TrueQ[computeEnhanced],{"n = "<>ToString[n],"lambda = "<>ToString[lambda],"|Hom| = "<>ToString[count],"Tallies (m,a_m) = "<>ToString[tallies],"Phi_E = "<>ToString[phiE]},{"n = "<>ToString[n],"lambda = "<>ToString[lambda],"|Hom| = "<>ToString[count]}]]//Quiet;​​Print["Saved: ",mStr];];​​​​(*passA:baselineformM=J*)​​RunHopf[5,1];​​​​(*passB:scaledformM=2J*)​​RunHopf[5,2];​​​​
Saved: results-HopfSum-Z5-lam2.txt
Φ_E(H, M) = 25q+360
2
q
+840
3
q
Tallies (m, a_m): {{1,25},{2,360},{3,840}}
OK: all relations satisfied modulo 5.
|Hom(Q(H), M)| = 1225
Solve time (s): 0.113
Modulus n = 5; M =
0
2
3
0

--- Hopf#Hopf over 𝔽_5 with M = 2 J ---
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
In[]:=
​
​
​
​
​
​
​
​
​
​
​
​
​
​