#!/usr/bin/env python3 """Independent, finite C313 arithmetic review. No C314 or expanded census. --sources DIR expects PREVIOUS_DATA.json (or C312_DATA.json), C286_DATA.json, C287_DATA.json, and C307_DATA.json. Without it, use sibling completed step evidence files. """ import argparse from fractions import Fraction import hashlib import json from pathlib import Path def main(): p = argparse.ArgumentParser() p.add_argument('--sources', type=Path) p.add_argument('--out', type=Path, default=Path(__file__).parent) a = p.parse_args() root = Path(__file__).resolve().parents[1] inputs = {} hashes = {} for step in (312, 286, 287, 307): path = (a.sources / f'C{step}_DATA.json') if a.sources else root / f'C{step}' / 'evidence' / 'DATA.json' if a.sources and step == 312 and not path.exists(): path = a.sources / 'PREVIOUS_DATA.json' raw = path.read_bytes() inputs[step] = json.loads(raw) hashes[f'C{step}_DATA.json'] = hashlib.sha256(raw).hexdigest() targets = inputs[286]['target_register'] cases = [r for r in inputs[312]['six_comparisons'] if r['LXX_OFF_pair_admitted']] assert [r['LXX_OFF_required_index'] for r in cases] == [3, 4, 5, 6, 7] assert all(r['SP_regular_pair'][0]-r['SP_regular_pair'][1] == 600 for r in cases) assert inputs[307]['phase_actions'] == [ {'source_offset': '-1/4', 'n_and_r_offset': '-1/4', 'b_and_p_offset': '1/4', 'n_minus_r_offset': '0', 'n_minus_p_offset': '-1/2'}, {'source_offset': '1/4', 'n_and_r_offset': '1/4', 'b_and_p_offset': '-1/4', 'n_minus_r_offset': '0', 'n_minus_p_offset': '1/2'}] def record(center, role, gear=None, rail=None): return [r for r in targets if r['tradition']=='SP' and r['Cainan']==0 and r['Terah60']==0 and r['full430']==1 and r['role']==role and r['center']==center and (gear is None or r['gear']==gear) and (rail is None or r.get('rail')==rail)] ledger = [] for case in cases: j = case['LXX_OFF_required_index'] gear, rail = case['gear'], case['rail'] q = -case['LXX_OFF_required_pair'][1] birth, death = [b+215-60 for b in case['SP_regular_pair']] assert q == -5290+j assert birth == -q-2077 assert death == birth-600 assert len(record(birth, 'Shem birth', gear, rail)) == 1 assert len(record(death, 'Shem death', gear, rail)) == 1 same_source_noah = record(birth+500, 'Noah birth', gear, rail) assert len(same_source_noah) == 1 noah = q+17*529 nr = record(noah, 'Noah birth') assert len(nr) == 1 nr = nr[0] assert noah-q == 8993 gap = noah-birth assert gap == 490+2*j typed_match = nr['gear']==gear and nr['rail']==rail assert typed_match == (gap==500) phases = [] for e in (Fraction(-1,4), Fraction(1,4)): # C307 establishes +epsilon for the17K transport and -epsilon # for the reflected cross-bridge endpoint. Normalization is # a fixed state translation, so it does not reverse this sign. n_e = Fraction(noah)+e s_e = Fraction(birth)-e d_e = Fraction(death)-e assert s_e-d_e == 600 assert n_e-s_e == gap+2*e source_biography_same_output = Fraction(birth+500)+e-(Fraction(birth)+e) assert source_biography_same_output == 500 phases.append({'cumulative_component_offset': str(e), 'Noah17K': str(n_e), 'Shem_birth_cross_bridge': str(s_e), 'Shem_death_cross_bridge': str(d_e), 'common_ancestor_Noah_minus_Shem': str(n_e-s_e), 'complete_Shem_life': str(s_e-d_e), 'source_biography_same_output_phase_gap': str(source_biography_same_output)}) # Confirm the phase-pair set translation separately from ancestry. ns = {Fraction(noah)+e for e in (Fraction(-1,4), Fraction(1,4))} ss500 = {Fraction(birth)+e+500 for e in (Fraction(-1,4), Fraction(1,4))} pairset_equal = ns==ss500 assert pairset_equal == (j==5) four_form = next((r for r in inputs[287]['rows'] if r['i']==j), None) complete_four = bool(four_form and four_form['complete']) assert complete_four == (j in (3,4,5)) ledger.append({'j': j, 'cumulative_Flood_q': q, 'C312_Shem_gear': gear, 'C312_Shem_rail': rail, 'normalized_Shem_pair': [birth,death], 'same_Gear_rail_biographical_Noah': birth+500, 'Noah17K': noah, 'Noah17K_gear': nr['gear'], 'Noah17K_rail': nr['rail'], 'center_gap': gap, 'source_binding_and_center_match': typed_match, 'complete_Shem_life_admitted': True, 'Noah17K_admitted': True, 'complete_C287_four_node_form_admitted': complete_four, 'cumulative_ON_Shem_index_needed_for_four_node_form': j+2, 'whole_pair_set_matches_after500': pairset_equal, 'same_cumulative_ancestry_components_both500': all(x['common_ancestor_Noah_minus_Shem']=='500' for x in phases), 'phases': phases}) assert [r['center_gap'] for r in ledger] == [496,498,500,502,504] assert [r['j'] for r in ledger if r['source_binding_and_center_match']] == [5] assert not any(r['same_cumulative_ancestry_components_both500'] for r in ledger) out = {'step': 'C313', 'review_type': 'Independent finite arithmetic check; input-state membership inherited from frozen registers', 'status': 'passed', 'input_sha256': hashes, 'normalization_BC': 155, 'center_model': {'q': '-5290+j', 'n': 'q+8993', 's': '-q-2077', 'd': 's-600', 'n_minus_s': '490+2j', 'same_cumulative_component_gap': '490+2j+2epsilon'}, 'cases': ledger, 'counts': {'fixed_domain': 5, 'normalization_and_complete_Shem_life': 5, 'admitted_Noah17K': 5, 'center_and_typed_binding_success': 1, 'center_and_typed_binding_failure': 4, 'same_cumulative_ancestry_phase_success': 0, 'whole_pair_set_translation500_success': 1}, 'caveats': ['The five17K edges exist independently of C287 four-node completeness.', 'The j5 source biography and phase-pair set translate by500, but same-cumulative-ancestor transport gives499.5/500.5.', 'No new endpoint, interpolated phase, source rule, Gear scope, or C314 computation is introduced.']} a.out.mkdir(parents=True, exist_ok=True) (a.out/'C313_Independent_Math_Results.json').write_text(json.dumps(out, indent=2)+'\n') print(json.dumps({'status': 'passed', 'cases': 5, 'center_successes': 1, 'common_ancestry_phase_successes': 0})) if __name__ == '__main__': main()