"""Replay separable two-ear comparison signs in arbitrary-precision integer arithmetic.""" import json,sys,time from fractions import Fraction as Q from functools import reduce from itertools import product from math import comb,gcd,lcm from pathlib import Path import numpy as np from affine_cut_data import basis_factors from twoear_data import ear_data,metric_sieve,monomials DEG=4;P=517;QDEN=50 def split(t,axis): v=np.moveaxis(t,axis,0);n=v.shape[0]-1 l,r=np.empty_like(v),np.empty_like(v) for k in range(n+1): l[k],r[n-k]=v[0]*(1<<(n-k)),v[-1]*(1<<(n-k)) if k0 mean=max(abs(B[1]+T[:,:,1].min()+U[:,:,1].min()),abs(B[1]+T[:,:,1].max()+U[:,:,1].max())) ac=mid[0] for z,w in product(*metrics): fs=basis_factors(z,w);denom=lcm(*(v.denominator for v in fs));p,a,b,c=[int(denom*v) for v in fs] weight=np.array([-a,-b,-c],dtype=object);v=P*p*D;ec=mid[3:]@weight eb=B[3:]@weight;et=T[:,:,3:]@weight;eu=U[:,:,3:]@weight emin=eb+et.min()+eu.min();emax=eb+et.max()+eu.max() loss=max((K*A-ac)*(K*e-ec) for A,e in product((Amin,Amax),(emin,emax))) def linear(A,M,en):return K*K*v*M-QDEN*K*(ac*en+ec*A) low=(linear(B[0],B[2],eb)+linear(T[:,:,0],T[:,:,2],et).min()+linear(U[:,:,0],U[:,:,2],eu).min() +QDEN*ac*ec-QDEN*loss) assert low*Amin>K*K*v*mean**2,(family,node,metrics,depth) leaves+=1 if leaves%10000==0:print('verified',family,leaves,depth,round(time.monotonic()-started),flush=True) fname=Path(__file__).with_name(f'twoear_{family}.json');tree=json.loads(fname.read_text(encoding='ascii')) walk(tree,ear,mirror,g1,0,[(-Q(2,5),Q(2,5))]*2,0) print('PASS',family,'leaves',leaves,'depth',depth_max,'seconds',round(time.monotonic()-started,3),flush=True) if __name__=='__main__':check(sys.argv[1])