"""Independent rational arithmetic audit, transcribed from manuscript PDF. Uses only Python standard-library Fraction; all data are transcribed from the displayed manuscript formulas, without the original electronic supplement. No floating-point arithmetic or probabilistic tests. """ from fractions import Fraction as Q from collections import defaultdict from itertools import combinations import json, platform class P: def __init__(self, n, terms=None): self.n=n self.t={m:Q(c) for m,c in (terms or {}).items() if c} @classmethod def constant(cls,n,c): return cls(n,{(0,)*n:Q(c)}) def coerce(self,o): return o if isinstance(o,P) else P.constant(self.n,o) def __add__(self,o): o=self.coerce(o); t=defaultdict(Q,self.t) for m,c in o.t.items(): t[m]+=c return P(self.n,t) __radd__=__add__ def __neg__(self): return P(self.n,{m:-c for m,c in self.t.items()}) def __sub__(self,o): return self+-self.coerce(o) def __rsub__(self,o): return self.coerce(o)+-self def __mul__(self,o): o=self.coerce(o); t=defaultdict(Q) for m,c in self.t.items(): for a,b in o.t.items():t[tuple(x+y for x,y in zip(m,a))]+=c*b return P(self.n,t) __rmul__=__mul__ def __truediv__(self,o): return self*Q(1,o) def __pow__(self,k): p=P.constant(self.n,1); b=self while k: if k&1:p=p*b b=b*b;k>>=1 return p def __bool__(self):return bool(self.t) def diff(self,i): t={} for m,c in self.t.items(): if m[i]: a=list(m);a[i]-=1;t[tuple(a)]=m[i]*c return P(self.n,t) def subs(self,x): n=next(v.n for v in x if isinstance(v,P)) ans=P(n) for m,c in self.t.items(): term=P.constant(n,c) for v,d in zip(x,m):term=term*(v**d) ans=ans+term return ans def leading(self): m=max(self.t,key=lambda a:(sum(a),tuple(-e for e in a[::-1]))) return m,self.t[m] def reduce(self,gs): p=self;r=P(self.n) heads=[g.leading() for g in gs] while p: m,c=p.leading() for g,(a,b) in zip(gs,heads): if all(x>=y for x,y in zip(m,a)): p=p-P(self.n,{tuple(x-y for x,y in zip(m,a)):c/b})*g break else: term=P(self.n,{m:c});r=r+term;p=p-term return r def serial(self):return {','.join(map(str,m)):str(c) for m,c in sorted(self.t.items())} def variables(n):return [P(n,{tuple(int(i==j) for j in range(n)):1}) for i in range(n)] def monic(p):return p/p.leading()[1] def s_poly(p,q): a,c=p.leading();b,d=q.leading();m=tuple(max(x,y) for x,y in zip(a,b)) return P(p.n,{tuple(x-y for x,y in zip(m,a)):1/c})*p-P(p.n,{tuple(x-y for x,y in zip(m,b)):1/d})*q def buchberger(gs): gs=[monic(g) for g in gs];pairs=list(combinations(range(len(gs)),2)) while pairs: i,j=pairs.pop(0) r=s_poly(gs[i],gs[j]).reduce(gs) if r: n=len(gs);pairs.extend((i,n) for i in range(n));gs.append(monic(r)) return gs results={} def check(name,p): ok=not bool(p) results[name]={'pass':ok,'remainder':p.serial() if isinstance(p,P) else str(p)} print(name, 'PASS' if ok else 'FAIL',flush=True) U,V=variables(2) r0=U**4-6*U**3*V**2+5*U**2*V**4-U*V**6-1 r1=4*U**3*V-10*U**2*V**3+6*U*V**5-V**7-1 gs=[ U**7-3*U**3*V-U**3+4*U**2*V**3+6*U**2*V**2-U*V**5-5*U*V**4+V**6, U**6*V-U**3+3*U**2*V**2+3*U**2*V-U*V**4-4*U*V**3+V**5, U**5*V**2-U**6+2*U**2*V+U**2-U*V**3-3*U*V**2+V**4, U**4*V**3-2*U**5*V+U**2-U*V**2-2*U*V+V**3, U**3*V**4+U**5-3*U**4*V**2-U*V-U+V**2, U**2*V**5+3*U**4*V-4*U**3*V**3-U+V, U*V**6-U**4+6*U**3*V**2-5*U**2*V**4+1, V**7-4*U**3*V+10*U**2*V**3-6*U*V**5+1] check('A.2 r0 reduction',r0.reduce(gs));check('A.2 r1 reduction',r1.reduce(gs)) for i,j in combinations(range(8),2):check(f'A.2 Buchberger S({i},{j})',s_poly(gs[i],gs[j]).reduce(gs)) computed=buchberger([r0,r1]) for i,g in enumerate(gs):check(f'A.2 g{i} in original ideal',g.reduce(computed)) results['A.2 standard monomials']={'pass':all(g.leading()[0]==(7-i,i) for i,g in enumerate(gs)),'dimension':28} x0,x1,x2,x3,x4,x5=variables(6) xx=[x0,x1,x2,x3,x4,x5] D=x0*x3*x5-x0*x4**2-x1**2*x5+2*x1*x2*x4-x2**2*x3 W=x0**4+x0**3*x1-x0**3*x2-2*x0**2*x3**2+16*x0*x1*x3*x5-7*x0*x2*x3**2+14*x0*x3*x4*x5-20*x0*x3*x5**2+8*x1*x5**3-7*x2*x3*x5**2+x3**4+x4*x5**3-x5**4 ell=[P.constant(2,1),U,V,U**2,U*V,V**2] a=4*U**6-14*U**2*V-4*U**2+14*U*V**3+16*U*V**2-7*V**5-20*V**4 b=14*U**2*V**2+V**6 c=14*U**3*V+16*U**3-14*U**2*V**3-40*U**2*V**2+3*U*V**5+24*U*V**4-4*V**6 V0=-231*U**6+Q(1169,2)*U**2*V+215*U**2-Q(833,2)*U*V**3-988*U*V**2+Q(1,4)*V**5+411*V**4 check('3.4 a',W.diff(3).subs(ell)-a) check('3.4 b',W.diff(4).subs(ell)-b) check('3.4 c',W.diff(5).subs(ell)-c) check('3.5 V0 - K',(V0-a*c+b*b/4).reduce(gs)) Vs=-231*x3**3+Q(1169,2)*x0*x2*x3+215*x0**2*x3-Q(833,2)*x0*x4*x5-988*x0*x1*x5+Q(1,4)*x2*x5**2+411*x0*x5**2 check('4.1 restriction',Vs.subs(ell)-V0) qs=[x0*x3-x1**2,x0*x4-x1*x2,x0*x5-x2**2,x1*x4-x2*x3,x1*x5-x2*x4,x3*x5-x4**2] Cs=[ 16*x0*x1*x3+14*x0*x3*x4-40*x0*x3*x5+24*x1*x5**2-14*x2*x3*x5+3*x4*x5**2-4*x5**3, -7*x0*x3*x5-Q(1,2)*x5**3, -4*x0**2*x3+16*x0*x1*x5-14*x0*x2*x3+14*x0*x4*x5-20*x0*x5**2-7*x2*x5**2+4*x3**3, -Q(1,2)*x0**3-Q(7,2)*x0*x3**2-Q(7,2)*x3*x5**2, -Q(1,2)*x0**3-8*x0*x3*x5-4*x5**3, 4*x0**3+3*x0**2*x1-3*x0**2*x2-4*x0*x3**2+16*x1*x3*x5-7*x2*x3**2+14*x3*x4*x5-20*x3*x5**2] targets=[c,-b/2,a,-U*b/2-V*c,U*a+V*b/2,U**2*a+U*V*b+V**2*c] for i,(C,tar) in enumerate(zip(Cs,targets),1):check(f'6.5 C{i} restriction',(C.subs(ell)-tar).reduce(gs)) L3={ (0,0,0,2,1):Q(-5632,49),(0,0,0,3,0):Q(-10240,343), (0,1,0,1,1):-12,(0,1,0,2,0):-32,(0,1,1,0,1):Q(-192,7),(0,1,1,1,0):Q(-1536,49), (0,2,0,1,0):Q(-3,2),(0,2,1,0,0):-8,(1,0,0,2,0):Q(-1280,49), (1,1,0,0,1):Q(-3,2),(1,1,0,1,0):-4,(1,1,1,0,0):Q(-192,49), (2,0,0,0,1):-4,(2,0,0,1,0):Q(32,49),(2,0,1,0,0):Q(1536,343),(3,0,0,0,0):Q(24,7)} L4={ (0,0,0,0,4):3,(0,0,0,1,3):8,(0,0,0,2,2):Q(384,49),(0,0,0,3,1):Q(512,343), (0,0,1,0,3):Q(384,49),(0,0,1,1,2):Q(512,343),(0,0,3,1,0):Q(-3,8), (0,1,0,2,1):Q(8,7),(0,1,0,3,0):Q(64,49),(0,1,1,0,2):Q(8,7),(0,1,1,1,1):Q(64,49), (1,0,0,1,2):Q(8,7),(1,0,0,2,1):Q(64,49),(1,0,1,0,2):Q(64,49)} lam={**L3,**L4} def functional(p):return sum(c*lam.get(m[1:],0) for m,c in p.t.items() if m[0]==0) for i,(q,C) in enumerate(zip(qs,Cs),1): for j in range(1,6):check(f'6.7 lambda x{j}(q{i}+C{i})',functional(xx[j]*(q+C))) for j in range(1,6): for k in range(6):check(f'6.8 lambda x{j}x{k}q{i}',functional(xx[j]*xx[k]*q)) check('6.2 lambda D equals 4',functional(D)-4) check('6.2 lambda W equals -3',functional(W)+3) # Finite-field arithmetic as coefficient lists in increasing powers. def trim(a,p): a=[c%p for c in a] while a and not a[-1]:a.pop() return a def fadd(a,b,p):return trim([(a[i] if i=len(m): q=a[-1]*pow(m[-1],-1,p)%p;k=len(a)-len(m) for i,b in enumerate(m):a[i+k]-=q*b a=trim(a,p) return a def fpow(a,n,m,p): r=[1] while n: if n&1:r=frem(fmul(r,a,p),m,p) a=frem(fmul(a,a,p),m,p);n>>=1 return r h=[-1,-1,0,0,0,0,0,0,1] a7=[0,0,2,-3,1,2,-3,1];A7=[0,1,2,-1,3,3,0,3];B7=[-1,1,-1,3,-2,2,-3] check('A.1 7^(8) Frobenius',fadd(fpow([0,1],7**8,h,7),[0,-1],7)) check('A.1 7^(4) remainder',fadd(fadd(fpow([0,1],7**4,h,7),[0,-1],7),[-c for c in a7],7)) check('A.1 Bezout mod 7',fadd(fadd(fmul(A7,a7,7),fmul(B7,h,7),7),[-1],7)) q19=[5,-8,-2,9,7,-3,4,1] a19=[0,-1,0,1,2,1];A19=[9,-4,5,4,-7,2,4];B19=[4,-7,1,6,-4] check('A.1 h factorization mod 19',fadd(fmul([-4,1],q19,19),[-c for c in h],19)) check('A.1 19^(7) Frobenius',fadd(fpow([0,1],19**7,q19,19),[0,-1],19)) check('A.1 19 remainder',fadd(fadd(fpow([0,1],19,q19,19),[0,-1],19),[-c for c in a19],19)) check('A.1 Bezout mod 19',fadd(fadd(fmul(A19,a19,19),fmul(B19,q19,19),19),[-1],19)) check('A.1 q19(4) equals 9',(sum(c*4**i for i,c in enumerate(q19))-9)%19) def exponents(n,d): if n==1:yield (d,);return for i in range(d+1): for tail in exponents(n-1,d-i):yield (i,)+tail def rank(rows): if not rows:return 0 rows=[list(map(Q,row)) for row in rows] r=0 for j in range(len(rows[0])): pivot=next((i for i in range(r,len(rows)) if rows[i][j]),None) if pivot is None:continue rows[r],rows[pivot]=rows[pivot],rows[r] c=rows[r][j];rows[r]=[a/c for a in rows[r]] for i in range(r+1,len(rows)): c=rows[i][j] if c:rows[i]=[a-c*b for a,b in zip(rows[i],rows[r])] r+=1 return r for d,relations,expected in [(2,qs,6),(3,[x*q for x in xx for q in qs],28)]: mons=list(exponents(6,d)) images=[P(6,{m:1}).subs(ell) for m in mons] support=sorted(set().union(*(p.t.keys() for p in images))) image_rank=rank([[p.t.get(m,0) for p in images] for m in support]) relation_rank=rank([[p.t.get(m,0) for m in mons] for p in relations]) check(f'6.1 Veronese degree {d} image rank',{2:15,3:28}[d]-image_rank) check(f'6.1 Veronese degree {d} relation rank',expected-relation_rank) for i,p in enumerate(relations):check(f'6.1 degree {d} relation {i} vanishes',p.subs(ell)) u_,v_,p_,q_=variables(4) av=a.subs([u_,v_]);bv=b.subs([u_,v_]);cv=c.subs([u_,v_]) ell4=[P.constant(4,1),u_,v_,u_**2,u_*v_,v_**2] w4=[P.constant(4,0),p_,q_,2*u_*p_-cv,v_*p_+u_*q_+bv/2,2*v_*q_-av] for i,(quadr,tar) in enumerate(zip(qs,targets),1): negcoef=-sum((quadr.diff(j).subs(ell4)*w4[j] for j in range(6)),P(4)) check(f'6.5 negative t^3 coefficient q{i}',negcoef-tar.subs([u_,v_])) print('TOTAL',len(results),'FAILURES',sum(not r['pass'] for r in results.values()),flush=True) with open(__file__.replace('.py','_results.json'),'w') as f:json.dump({'python':platform.python_version(),'results':results},f,indent=2) if any(not r['pass'] for r in results.values()): raise SystemExit(1)