from fractions import Fraction as Q from itertools import product def run(load,check): E=Q(25,23);ratios={'P':Q(70,69),'J':Q(300,299)} rows=[r for r in load('C340_DATA.json')['rows'] if r['rail']=='primary' and r['binding']=='same-Gear MT Shem'] check('two retained primary rows',[r['i'] for r in rows]==[3,5]) 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] def show(f):return list(map(str,f)) reg=load('C286_DATA.json')['target_register'];coords={x['center'] for x in reg};items=[] for row in rows: rec=row['records'];N,R,H,F,M=[rec[k]['center'] for k in ['N','R','H','F','M']];f=aff(N,E);B=R+460 check('ladder i'+str(row['i']),at(f,R)==H and at(f,H)==F and N-R==1058) check('source common repair i'+str(row['i']),any(x['coordinate_tuple']==[R,B,M,M+2,N] for x in load('C379_DATA.json')['qualified_regular_hits'])) images={k:str(at(f,x)) for k,x in [('M',M),('M_plus2',M+2),('J_pivot',R),('P_pivot',B)]} check('sourced Shem image i'+str(row['i']),any(x['tradition']=='SP' and x['gear']==rec['N']['gear'] and x['role']=='Shem birth' and x['rail']=='primary' and x['Cainan']==0 and x['Terah60']==0 and x['full430']==1 and x['center']==at(f,M) for x in reg)) check('fixed E output noninteger i'+str(row['i']),at(f,M+2).denominator==23 and at(f,M+2) not in coords) for op,k in ratios.items(): a=R if op=='J' else B check('static affine conjugacy '+str((row['i'],op)),comp(f,aff(a,k))==comp(aff(at(f,a),k),f)) items.append({'i':row['i'],'source_records':rec,'P_pivot':B,'E_images':images,'static_E_output_source_member':False}) a,z=rows;d={k:z['records'][k]['center']-a['records'][k]['center'] for k in a['records']} check('all six recorded endpoints translate',set(d.values())=={2}) N=a['records']['N']['center'];R=a['records']['R']['center'];M=a['records']['M']['center'];B=R+460;h=2;f=aff(N,E);g=aff(N+h,E);T=(Q(1),Q(h)) check('translation E intertwiner',comp(g,T)==comp(T,f)) mixed=[] for op,k in ratios.items(): pivot=R if op=='J' else B;left=comp(g,aff(pivot,k));right=comp(aff(pivot+h,k),f);defect=left[1]-right[1] check('moving mixed defect '+op,left[0]==right[0] and defect==Q(42,69 if op=='P' else 299) and defect!=0) check('first route existing endpoints '+op,at(aff(pivot,k),M)==M+h and at(left,M)==3208) check('second route non-source '+op,at(f,M)==3206 and at(right,M).denominator>1 and at(right,M) not in coords) mixed.append({'operator':op,'pivot':pivot,'next_pivot':pivot+h,'E_after_operator':show(left),'operator_after_E':show(right),'constant_order_defect':str(defect),'source_input':M,'left_source_output':str(at(left,M)),'right_generated_output':str(at(right,M))}) phases=[] for phase in [Q(-1,4),Q(1,4)]: fp=aff(N+phase,E);gp=aff(N+h+phase,E) check('same component translation '+str(phase),comp(gp,T)==comp(T,fp) and at(fp,R+phase)==a['records']['H']['center']+phase) phases.append({'offset':str(phase),'component_translation_square':True}) return {'step':'C384','primary_rows':items,'translation_endpoint_shifts':d,'source_translation_square':{'input_R':R,'E_image_H':a['records']['H']['center'],'next_R':R+h,'next_H':z['records']['H']['center'],'shift':h,'whole_affine_intertwiner':True},'mixed_tests':mixed,'component_tests':phases,'counts':{'primary_ladders':2,'adjacent_source_translation_squares':1,'direct_E_PJ_mixed_squares':2,'commuting_direct_E_PJ_squares':0,'matched_phase_translation_squares':2},'interpretation':'Source translation intertwines the two E ladders. P/J realizes that translation only on its selected MT Noah source input; applying it to the E image does not realize the same source shift. Static E conjugacy is exact but sends the repaired endpoint to a noninteger coordinate. No generated point is admitted.'}