from fractions import Fraction as Q def rat(x):return {'numerator':x.numerator,'denominator':x.denominator} def val(x,p): n,d=x.numerator,x.denominator;v=0 while n%p==0:n//=p;v+=1 while d%p==0:d//=p;v-=1 return v def run(load,check): reg=load('C286_DATA.json')['target_register'];cs=sorted({r['center'] for r in reg});hit=load('PREVIOUS_DATA.json')['sourced_endpoint_hits'][0];h,x,y=hit['held_upper'],hit['input_lower'],Q(hit['output']['numerator'],hit['output']['denominator']);lam=Q(25,23);rows=[];matches=[] for p in cs: q=Q(48*h-25*p,23);mid=Q(p)+lam*(x-p);out=q+lam*(mid-q);ok=q in cs;check('whole-map equality from pivot equation '+str(p),Q(25*p+23*q,48)==h and out==y) row={'first_pivot':p,'required_second_pivot':rat(q),'second_pivot_sourced':ok,'intermediate':rat(mid),'intermediate_sourced':mid in cs,'same_map_source_path':bool(ok and mid in cs)};rows.append(row) if ok:matches.append(row) check('only repeated held pivot sourced',len(matches)==1 and matches[0]['first_pivot']==h and matches[0]['required_second_pivot']==rat(Q(h))) check('upper-bound proof applies',max(cs)==3900 and h==3899 and 0<=max(cs)-h<23 and 0<=max(cs)-h<25) slopes={'E':Q(25,23),'P':Q(70,69),'J':Q(300,299),'target':Q(625,529)};vs={str(p):{n:val(z,p) for n,z in slopes.items()} for p in [7,13,5]} check('prime7 isolates P',vs['7']=={'E':0,'P':1,'J':0,'target':0}) check('prime13 isolates J',vs['13']=={'E':0,'P':0,'J':-1,'target':0}) check('prime5 fixes two E after P,J exclusion',vs['5']=={'E':2,'P':1,'J':2,'target':4}) return {'step':'C421','target_map':{'held_pivot':h,'input':x,'output':rat(y),'slope':rat(lam*lam)},'pivot_trials':rows,'sourced_pivot_solutions':matches,'prime_valuation_certificate':vs,'integer_solution_form':'p=3899+23t, q=3899−25t, t integer. Both pivots≤3900 force t=0.','positive_word_count_solution':{'E':2,'P':0,'J':0},'counts':{'first_pivot_coordinates':len(cs),'sourced_two_pivot_solutions':len(matches),'complete_source_paths':sum(r['same_map_source_path'] for r in rows)},'interpretation':'Every finite positive E/P/J word equal as a whole affine map has exactly two E steps, by slope valuations. The only possible pair of pivots from even the entire regular coordinate menu is3899,3899, requiring absent2749. This excludes same-map source paths in that grammar. It does not exclude different slopes coinciding at one endpoint, inverse operators, or a future expanded source menu.'}