from pathlib import Path from fractions import Fraction as Q import re def run(load,check): text=(Path(__file__).resolve().parent.parent/'sources/BILATERAL.md').read_text() parsed=re.findall(r'\| G([1-3]) (close|start) \| (\d+) \| (\d+) \| (\d+) \| (\d+) \|',text) check('six documented bilateral rows',len(parsed)==6) reg=load('C271_REGISTER.json');rows=[] for gear,kind,C,R,ON,MT in parsed: C,R,ON,MT=map(int,[C,R,ON,MT]);j=R-3103;S=-5890+j;A=-C match=[r for r in reg if r['branch']=='Flood' and r['source_event']['gear']==int(gear) and r['selector']==kind] check(f'bound endpoint j{j}',len(match)==1 and match[0]['source_event']['BC_Nisan']==R) check(f'triangle widths j{j}',A-S==598 and R-A==8395 and R-S==8993) for e in [Q(-1,4),Q(1,4)]:check(f'path component j{j} {e}',S+e+598+8395==S+e+8993==R+e) rows.append({'index_j':j,'Shem_signed':S,'Flood_partner_signed':A,'regular_id':match[0]['id'],'regular_reflected':R,'triangle':[598,8395,8993],'bilateral_ON_C':ON,'bilateral_MT_R':MT}) check('all six endpoints retained',[r['index_j'] for r in rows]==list(range(2,8))) check('K and23 decomposition',8993==17*529 and 8395==23*365 and 8993-8395==598) return {'triangles':rows,'shared_endpoint_count':6,'composition':'T8395 after T598 equals T8993','no_regular_Noah_required_for_triangle':True,'source_path_status':'derived triangle of admitted endpoint comparisons; not six new stored C127 paths'}