SERAPH5-SAELYRA-v6 / code /check_orbits.py
PureOne's picture
Release SERAPH-5 / SAELYRA v6.0.0
5fe5e69 verified
Raw History Blame Contribute Delete
1.58 kB
#!/usr/bin/env python3
"""Exhaust the five-coordinate covering antichains and check the supplied orbits."""
import itertools,json,time
from pathlib import Path
ROOT=Path(__file__).resolve().parents[1]
def run():
start=time.perf_counter();families=set()
def extend(next_mask,chosen,used):
if used==31:families.add(tuple(chosen))
for m in range(next_mask,32):
if all((m&h)!=m and (m&h)!=h for h in chosen):
extend(m+1,chosen+[m],used|m)
extend(1,[],0)
data=json.loads((ROOT/'data/legacy_catalogue.json').read_text());seen=set()
for rec in data['representatives']:
fam=tuple(rec['facets']);orb=set()
for p in itertools.permutations(range(5)):
orb.add(tuple(sorted(sum(1<<p[i] for i in range(5) if m&(1<<i)) for m in fam)))
assert min(orb)==fam and len(orb)==rec['orbit_size']
assert not seen.intersection(orb);seen.update(orb)
assert seen==families and len(families)==6894
keys={(c['index'],c['body']) for c in data['certificates']}
assert keys==set(itertools.product(range(180),['P','Q']))
report={'status':'PASS','covering_antichains':len(families),'coordinate_permutation_orbits':len(data['representatives']),
'primal_polar_records':len(keys),'model_presentations':2*len(families),
'elapsed_seconds':round(time.perf_counter()-start,3),'unrestricted_5d_theorem_proved':False}
(ROOT/'verification/orbit_report.json').write_text(json.dumps(report,indent=2)+'\n');print(json.dumps(report,indent=2))
if __name__=='__main__':run()