from fractions import Fraction as Q from itertools import product def run(load,check): E=Q(25,23);P=Q(70,69);J=Q(300,299);lp=E*P;lj=E*J;rows=[];words=[];circuits=[] def aff(a,k):return(k,(1-k)*a) def comp(a,b):return(a[0]*b[0],a[0]*b[1]+a[1]) def at(f,x):return f[0]*x+f[1] hits=[h for h in load('PREVIOUS_DATA.json')['hits'] if h['P_return_source_records']] check('primitive loop multipliers',lp==Q(1750,3*529) and lj==Q(7500,13*529) and lp-1==Q(163,1587) and lj-1==Q(623,6877)) for k,h in enumerate(hits): N,x,y,A,B=[h[t] for t in ['E_Noah_pivot','E_input','E_output','J_return_pivot','unique_P_return_pivot']];f={'E':aff(N,E),'P':aff(B,P),'J':aff(A,J)} check('sourced three operator arrows '+str(k),at(f['E'],x)==y and at(f['P'],y)==at(f['J'],y)==x) ep=comp(f['E'],f['P']);pe=comp(f['P'],f['E']);ej=comp(f['E'],f['J']);je=comp(f['J'],f['E']);pj=comp(f['P'],f['J']);jp=comp(f['J'],f['P']) check('individual operators do not commute '+str(k),ep[1]-pe[1]==Q(326,1587) and ej[1]-je[1]==Q(1246,6877) and pj[1]-jp[1]==Q(20,897)) for vertex,c,loops in [('lower',y,{'P':ep,'J':ej}),('upper',x,{'P':pe,'J':je})]: check('two same-center loop generators '+str((k,vertex)),loops['P']==aff(c,lp) and loops['J']==aff(c,lj) and comp(loops['P'],loops['J'])==comp(loops['J'],loops['P'])) for name,rr in [('P',lp),('J',lj)]:circuits.append({'graph':k,'vertex':vertex,'source_fixed_point':c,'return_operator':name,'affine_coefficients':list(map(str,loops[name])),'multiplier':str(rr)}) for length in [1,2,3]: bycounts={} for word in product('PJ',repeat=length): result=(Q(1),Q(0)) for letter in word:result=comp(loops[letter],result) p=word.count('P');j=word.count('J');want=aff(c,lp**p*lj**j) check('closed word normal form '+str((k,vertex,word)),result==want and at(result,c)==c) if p in bycounts:check('same counts give equal circuit '+str((k,vertex,word)),result==bycounts[p]) else:bycounts[p]=result words.append({'graph':k,'vertex':vertex,'circuit_word':''.join(word),'P_circuits':p,'J_circuits':j,'edge_count':2*length,'affine_coefficients':list(map(str,result))}) check('different circuit counts give different maps '+str((k,vertex,length)),len(set(bycounts.values()))==length+1) rows.append({'Noah_pivot':N,'higher_Noah':x,'lower_Noah':y,'J_Flood_pivot':A,'P_Flood_pivot':B,'pivot_spans':{'N_minus_P':N-B,'N_minus_J':N-A,'P_minus_J':B-A},'source_records':h['records'],'P_pivot_records':h['P_return_source_records']}) def val(n,p): out=0 while n%p==0:n//=p;out+=1 return out vp=[val(lp.numerator,7)-val(lp.denominator,7),val(lj.numerator,7)-val(lj.denominator,7)];vj=[val(lp.numerator,13)-val(lp.denominator,13),val(lj.numerator,13)-val(lj.denominator,13)] check('multiplicative independence by7 and13',vp==[1,0] and vj==[0,-1]) check('finite verification inventory',len(rows)==2 and len(circuits)==8 and len(words)==56) return {'step':'C397','rows':rows,'circuit_generators':circuits,'word_trials':words,'counts':{'three_operator_source_graphs':2,'source_vertices':4,'loop_generators':8,'closed_word_trials':56,'commuting_generator_pairs':4},'multipliers':{'P_circuit':str(lp),'J_circuit':str(lj)},'prime_valuation_certificate':{'prime7':[1,0],'prime13':[0,-1]},'general_form':'A loop based at sourcec with p P-circuits and j J-circuits is t -> c+(1750/1587)^p(7500/6877)^j(t-c). Circuit order does not matter; different count pairs have different multipliers.','interpretation':'Each source vertex supports an exact two-generator commutative monoid of positive circuits. No nonempty positive circuit is the identity, and E/P/J are not individually commuting or inverse operators. Repeated paths use the same admitted source vertices and do not create additional Gears.'}