from fractions import Fraction as Q from itertools import product def run(load,check): P=Q(70,69);J=Q(300,299);d=load('C380_DATA.json');squares=[];words=[];frames=[] def f(a,r):return (r,(1-r)*a) def comp(a,b):return(a[0]*b[0],a[0]*b[1]+a[1]) def show(a):return list(map(str,a)) check('mixed defect symbolic coefficients',(-(P-1)*(J-1),(P-1)*(J-1),J-P)==(-Q(1,20631),Q(1,20631),-Q(230,20631))) for k,pair in enumerate(d['consecutive_edge_pairs']): e=pair['first_edge'];n=pair['second_edge'];A=e['J_pivot'];B=e['P_pivot'];h=pair['common_gain'];D=B-A jp=comp(f(B+h,P),f(A,J));pj=comp(f(A+h,J),f(B,P));staticjp=comp(f(B,P),f(A,J));staticpj=comp(f(A,J),f(B,P)) check('source moving mixed square '+str(k),jp==pj and jp[0]*e['input']+jp[1]==n['output']) check('exact shift condition '+str(k),D==230*h and jp[1]-pj[1]==Q(D-230*h,20631)) check('fixed pivot order defect '+str(k),staticjp[0]==staticpj[0] and staticjp[1]-staticpj[1]==Q(D,20631)!=0) squares.append({'field':pair['field'],'full430':pair['full430'],'input':e['input'],'intermediate':e['output'],'output':n['output'],'J_pivot':A,'P_pivot':B,'pivot_shift':h,'P_after_J_coefficients':show(jp),'J_after_P_coefficients':show(pj),'fixed_pivot_order_defect':str(Q(D,20631))}) for k,path in enumerate(d['paths']): es=path['edges'];h=path['signed_step'];x0=path['source_vertices'][0];xn=path['source_vertices'][-1];classes={} for t,e in enumerate(es): for name,ratio,piv in [('J',J,e['J_pivot']),('P',P,e['P_pivot'])]: physical=f(piv,ratio);co=(ratio,physical[1]+ratio*t*h-(t+1)*h);want=f(x0,ratio) check('common center in translated frame '+str((k,t,name)),co==want and co[0]*x0+co[1]==x0) frames.append({'path':k,'step':t,'operator':name,'moving_frame_center_existing_source':x0,'coefficients':show(co),'frame_displacement':t*h}) for ww in product('PJ',repeat=len(es)): transform=(Q(1),Q(0)) for op,e in zip(ww,es):transform=comp(f(e['P_pivot'] if op=='P' else e['J_pivot'],P if op=='P' else J),transform) word=''.join(ww);pcount=ww.count('P');expected=P**pcount*J**(len(es)-pcount) check('finite word endpoint and slope '+str((k,word)),transform[0]*x0+transform[1]==xn and transform[0]==expected and transform[1]==xn-expected*x0) if pcount in classes:check('operator order independence within counts '+str((k,word)),classes[pcount]==transform) else:classes[pcount]=transform words.append({'path':k,'word_in_execution_order':word,'P_count':pcount,'input':x0,'output':xn,'affine_coefficients':show(transform)}) check('different operator counts remain different '+str(k),len({v[0] for v in classes.values()})==len(es)+1) check('finite source inventory',len(squares)==6 and len(words)==24 and len(frames)==20) return {'step':'C382','mixed_squares':squares,'moving_frame_maps':frames,'finite_word_routes':words,'counts':{'source_mixed_squares':6,'finite_word_routes':24,'translated_frame_maps':20,'all_mixed_squares_commute':True},'general_order_defect':'F_(B+h)^P o F_A^J minus F_(A+h)^J o F_B^P has zero slope difference and constant(B-A-230h)/20631.','commutation_condition':'B-A=230h, exactly the equal-gain pivot condition. At fixed pivots h0 the defect isD/20631, hence±20/897 on these source pairs.','reduced_frame':'Subtract t*h before step t and(t+1)*h after it. Both maps become dilations centered at the same existing initial source x0=A+299h=B+69h; their ratios remain J and P.','word_formula':'For a source path of lengthn, any word with p P-steps has affine form x -> x_n + P^p J^(n-p)(x-x_0). Order changes with fixed counts do not change this map; different counts remain different maps even though the one source input has the same output.','limits':'This is an exact moving-frame comparison on finite admitted source paths, not fixed-pivot commutation, universal source closure, a single physical-time phase action or preservation of17K under paired iteration.'}