"""Independent exact item-mask partition derivative check, plus basis checks.""" import json,math,time from pathlib import Path from flint import fmpz_poly from certify_three_level import construct,stirling def labelled(p,rows,top): c=len(rows);size=1<0,(c,cnts,x,y) assert basis_value(converted,cnts,x,y)==expected,(c,cnts) independent+=1 # First-degree coefficients in x,y after specialization match the analytic Hessian. for cnts in ([1,1,max(1,c-1)],[c,c,c]): n=sum(cnts);B=c*(c+1)//2;F0=n*math.prod(range(n-c+1,n+1)) pref_num=2*B*(n-c)*cnts[2]*F0**2 den=n**3*(n-1) expected_x=pref_num*cnts[0]//den expected_y=pref_num*(cnts[0]+cnts[1])//den assert pref_num*cnts[0]%den==0 and pref_num*(cnts[0]+cnts[1])%den==0 assert int(d.derivative(0)(0,0,*cnts))==expected_x assert int(d.derivative(1)(0,0,*cnts))==expected_y return {'C':c,'independent_exact_points':independent,'uniform_linear_coefficients':4,'certificate_sha256':rec['sha256']} if __name__=='__main__': x=fmpz_poly([0,1]);one=fmpz_poly([1]);zero=fmpz_poly([]) for e in range(23): assert x**e==sum((s*math.prod((x-j for j in range(k)),start=one) for k,s in enumerate(stirling(e))),zero) out=Path(__file__).with_name('results')/'independent_checks.json';rs=[];start=time.time() for c in range(1,10): r=verify(c);rs.append(r);print(json.dumps(r),flush=True) out.write_text(json.dumps({'stirling_polynomial_identities':23,'checks':rs,'elapsed_seconds':time.time()-start},indent=2))