from pathlib import Path from fractions import Fraction import re def run(load,check): root=Path(__file__).resolve().parent.parent prior=load('PREVIOUS_DATA.json') cases=[r for r in prior['six_comparisons'] if r['LXX_OFF_pair_admitted']] check('five retained SP target indices only',len(cases)==5 and [r['LXX_OFF_required_index'] for r in cases]==[3,4,5,6,7]) register=load('C286_DATA.json')['target_register'] def find(role,gear=None,rail=None,center=None): hits=[r for r in register if r['tradition']=='SP' and (r['Cainan'],r['Terah60'],r['full430'])==(0,0,1) and r['role']==role and (gear is None or r['gear']==gear) and (rail is None or r.get('rail')==rail) and (center is None or r['center']==center)] assert len(hits)==1,(role,gear,rail,center) return hits[0] f18=(root/'sources/File_18.md').read_text();f09=(root/'sources/File_09.md').read_text() native={} for line in f18.splitlines(): m=re.fullmatch(r'\| G([123]) \| (\d+)/(\d+) \| (\d+)/(\d+) \| (\d+)/(\d+) \| (\d+)/(\d+) \|',line.strip()) if m: g,*v=map(int,m.groups()) if v[4] in [2991,2993,2995]:native[g]=v check('variant normalization binds source155 statement','The `+155` gap occurs because `215 − 60 = 155`' in f18 and 215-60==155) check('matched500 and600 are source-supported','matched Noah/Shem births preserve `500`' in f18 and 'Shem `600`' in f18 and len(native)==3) check('phase convention binds quarter-year source formulas','A(AD y, t) = y − 1/4' in f09 and 'A(y BC, n) = −y + 1/4' in f09) phase_actions=load('C307_DATA.json')['phase_actions'] epsilons=[Fraction(-1,4),Fraction(1,4)] check('inherited paths have opposite phase slopes',len(phase_actions)==2 and all(Fraction(p['n_and_r_offset'])==Fraction(p['source_offset']) and Fraction(p['b_and_p_offset'])==-Fraction(p['source_offset']) for p in phase_actions)) phase_register=load('C271_REGISTER.json') complete_rows={r['i']:r for r in load('C287_DATA.json')['rows'] if r['complete']} K=529;shift=215-60;offset=prior['comparison_offset'] check('held17K and cross-bridge constants',17*K==8993 and offset==2832) rows=[] for case in cases: j=case['LXX_OFF_required_index'];g=case['gear'];rail=case['rail'];r=case['rail_index'] C=case['LXX_OFF_required_pair'][1];q=-C old=case['SP_regular_pair'];s,d=[x+shift for x in old] sb=find('Shem birth',g,rail,s);sd=find('Shem death',g,rail,d) own_noah=find('Noah birth',g,rail) check(f'j{j} normalized Shem pair matches source table',old==[native[g][4+r]+60,native[g][6+r]+60] and [s,d]==[native[g][4+r]+215,native[g][6+r]+215]) check(f'j{j} source biography preserves500 and600',own_noah['center']-s==500 and s-d==600 and own_noah['center']-d==1100) n=q+17*K;noah=find('Noah birth',center=n) check(f'j{j} direct17K selects admitted Noah',C+n==8993 and n==3703+j) center_gap=n-s;labels=(noah['gear']==g and noah['rail']==rail) check(f'j{j} same-index center equations',s==-q-2077==3213-j and d==s-600 and center_gap==490+2*j) phase_record=[p for p in phase_register if p['source_event']['role']=='Noah birth' and p['source_event']['gear']==noah['gear'] and p['source_event']['rail']==noah['rail']] assert len(phase_record)==1;phase_record=phase_record[0] actual_phase_map={Fraction(p['cumulative_coordinate']):Fraction(p['reflected_coordinate']) for p in phase_record['phases']} check(f'j{j} Noah phases bind existing exact register',all(actual_phase_map.get(q+e)==n+e for e in epsilons)) paths=[] for e in epsilons: n_component=actual_phase_map[q+e] s_component=-(q+e)-2077 d_component=-(q+e)-2677 paths.append({'cumulative_phase_offset':str(e),'cumulative_coordinate':str(q+e),'Noah_component':str(n_component),'Shem_birth_component':str(s_component),'Shem_death_component':str(d_component),'Noah_to_Shem_difference':str(n_component-s_component),'Noah_to_Shem_death_difference':str(n_component-d_component),'Shem_life':str(s_component-d_component)}) check(f'j{j} correlated phase gaps follow orientation',all(Fraction(p['Noah_to_Shem_difference'])==center_gap+2*Fraction(p['cumulative_phase_offset']) and Fraction(p['Shem_life'])==600 for p in paths)) noah_set=sorted(n+e for e in epsilons);shem_set=sorted(s+e for e in epsilons) set_match=sorted(x-500 for x in noah_set)==shem_set source_like_phase_gaps=[(n+e)-(s+e) for e in epsilons] allK=j in complete_rows and any(x['tradition']=='SP' and x['gear']==noah['gear'] and x['rail']==noah['rail'] and x['center']==n for x in complete_rows[j]['Noah_records']) rows.append({'index':j,'cumulative_LXX_OFF_Flood_BC':C,'q':q,'original_SP_pair':old,'normalization_BC':shift,'normalized_Shem_birth':sb,'normalized_Shem_death':sd,'source_matched_Noah':own_noah,'same_index_17K_Noah':noah,'Noah_Shem_center_difference':center_gap,'source_binding_residual':n-own_noah['center'],'same_Gear_and_rail':labels,'center500':center_gap==500,'typed_center_success':center_gap==500 and labels,'complete_Shem_life600':s-d==600,'direct17K_source_admitted':True,'retained_C287_complete_row':allK,'unordered_phase_pair500':set_match,'like_output_phase_differences':[str(x) for x in source_like_phase_gaps],'same_cumulative_component_paths':paths,'same_ancestry500':all(Fraction(p['Noah_to_Shem_difference'])==500 for p in paths)}) winners=[r for r in rows if r['typed_center_success']] check('exactly one typed center success atj5G2primary',len(winners)==1 and (winners[0]['index'],winners[0]['normalized_Shem_birth']['gear'],winners[0]['normalized_Shem_birth']['rail'])==(5,2,'primary')) check('five center differences are496 through504', [r['Noah_Shem_center_difference'] for r in rows]==[496,498,500,502,504]) check('all five direct Noah endpoints and Shem lives are valid',all(r['direct17K_source_admitted'] and r['complete_Shem_life600'] for r in rows)) check('stronger C287 membership stays distinct',[r['index'] for r in rows if r['retained_C287_complete_row']]==[3,4,5]) check('one unordered500 phase-set match',[r['index'] for r in rows if r['unordered_phase_pair500']]==[5]) check('no same-cumulative-component500 binding',not any(r['same_ancestry500'] for r in rows)) winner=winners[0] check('winning source pair preserves exact physical500',winner['like_output_phase_differences']==['500','500'] and winner['same_index_17K_Noah']['center']==3708 and winner['normalized_Shem_birth']['center']==3208 and winner['normalized_Shem_death']['center']==2608) check('winning inherited component differences are499half500half',[Fraction(p['Noah_to_Shem_difference']) for p in winner['same_cumulative_component_paths']]==[Fraction(999,2),Fraction(1001,2)]) return {'parameters':{'K':K,'17K':17*K,'normalization_BC':shift,'comparison_offset':offset,'annual_indices':[3,4,5,6,7]},'formulas':{'q':'-5290+j','n_reflected_Noah':'q+8993=3703+j','s_reflected_normalized_Shem_birth':'-q-2077=3213-j','d_reflected_normalized_Shem_death':'s-600','center_difference':'n-s=490+2j','correlated_component_difference':'490+2j+2epsilon','necessary_cross_index_condition_only':'i+j=10; reversed-index map not tested in C313'},'rows':rows,'counts':{'cases':5,'valid_normalized_Shem_pairs':5,'valid_direct17K_Noah_endpoints':5,'typed_center500_successes':1,'unordered_phase_pair500_successes':1,'same_ancestry500_successes':0,'retained_C287_complete_rows':3},'winning_index':5,'winning_source_biography_BC':[3708,3208,2608],'source_prescribed_selector_established':False,'new_source_nodes_created':False,'new_endpoint_census_performed':False,'C314_executed':False}