from fractions import Fraction as F from math import prod def run(load,read,check): reg=load('C286_DATA.json')['target_register'];by={} for i,r in enumerate(reg):by.setdefault(r['center'],[]).append(i) E=lambda h,x:F(25*x-2*h,23) rat=lambda x:{'numerator':x.numerator,'denominator':x.denominator} trials=[];families=[];complete=[] for c in load('C434_DATA.json')['cases']: v=c['coordinates'];p,q,h=v['P'],v['Q'],v['H'];rows=[] for x in sorted(by): mid=E(p,x);out=E(q,mid) check(f'whole-map identity {h}/{x}',out==F(625*x-96*h,529)) indices={'input':by[x],'intermediate':by.get(mid,[]),'output':by.get(out,[]),'first_pivot':by[p],'second_pivot':by[q]} hit=bool(indices['intermediate'] and indices['output']) row={'gear':c['gear'],'Terah60':c['Terah60'],'H':h,'p':p,'q':q,'input':x,'intermediate':rat(mid),'output':rat(out), 'record_indices':indices,'integer_output':out.denominator==1,'complete':hit,'effective_gap_K':rat(F(h-x,529)), 'signed_pivot_gaps':[rat(p-x),rat(q-mid)],'coordinate_changes':[rat(x-mid),rat(mid-out)], 'labelled_assignments':prod(len(z) for z in indices.values())} rows.append(row);trials.append(row) if hit:complete.append(row) families.append({'gear':c['gear'],'Terah60':c['Terah60'],'H':h,'p':p,'q':q,'trials':len(rows), 'sourced_intermediates':sum(bool(r['record_indices']['intermediate']) for r in rows), 'integer_outputs':sum(r['integer_output'] for r in rows), 'sourced_outputs':sum(bool(r['record_indices']['output']) for r in rows), 'complete_paths':sum(r['complete'] for r in rows)}) check('2238 fixed input/map trials',len(trials)==6*373==2238) check('family membership counts',[(f['sourced_intermediates'],f['integer_outputs'],f['sourced_outputs'],f['complete_paths']) for f in families]==[(8,2,2,2),(3,2,2,0),(2,1,1,0),(4,2,1,0),(3,2,1,0),(3,1,1,0)]) check('exactly old2K path plus zero-net loop',[(r['H'],r['input'],r['intermediate']['numerator'],r['output']['numerator']) for r in complete]==[(3206,2148,2020,1956),(3206,3206,3170,3206)]) check('two and sixteen Cartesian source-label assignments',[r['labelled_assignments'] for r in complete]==[2,16]) check('loop has opposite signed second gap',complete[1]['signed_pivot_gaps']==[rat(F(414)),rat(F(-414))] and complete[1]['coordinate_changes']==[rat(F(36)),rat(F(-36))]) check('no other2K input has complete path',sum(r['complete'] and r['effective_gap_K']==rat(F(2)) for r in trials)==1) return {'step':'C435','domain':{'labelled_records':len(reg),'coordinates':len(by)},'families':families,'all_trials':trials,'complete_paths':complete, 'integer_output_cases':[r for r in trials if r['integer_output']], 'counts':{'trials':len(trials),'sourced_first_leg_outputs':23,'integer_composed_outputs':10,'sourced_composed_outputs':8,'complete_coordinate_paths':2}, 'interpretation':'One prior forward2K path and one additional mixed-direction zero-net coordinate loop; no single chronological traversal or global action is inferred.'}