"""Exact finite classification of C267 markers. No historical search or uploads. python evidence/check_c267.py [--output DIR] """ from pathlib import Path from fractions import Fraction as F import argparse, json, hashlib, csv ROOT=Path(__file__).resolve().parents[1] parser=argparse.ArgumentParser();parser.add_argument('--output',type=Path,default=ROOT/'evidence') OUT=parser.parse_args().output;OUT.mkdir(parents=True,exist_ok=True) checks=[] def check(name,ok): if not ok: raise AssertionError(name) checks.append(name) def sha(p): return hashlib.sha256(p.read_bytes()).hexdigest() def dump(name,obj): (OUT/name).write_text(json.dumps(obj,indent=2,ensure_ascii=False,default=str)+'\n') manifest=json.loads((ROOT/'SOURCE_MANIFEST.json').read_text()) for name,row in manifest.items(): p=ROOT/'sources'/name check('frozen '+name,sha(p)==row['sha256'] and p.stat().st_size==row['bytes']) prev=json.loads((ROOT/'sources/C266_CERTIFICATE.json').read_text()) check('C266 report certificate',sha(ROOT/'sources/C266_REPORT.md')==prev['report_sha256']) check('C266 results certificate',sha(ROOT/'sources/C266_RESULTS.json')==prev['results_sha256']) check('controlling File18',sha(ROOT/'sources/FILE_18.md')=='68301ab760bfbe2e874aedc5c8d943ced7a6219d34bc2859332a70713f9630d5') check('controlling File09',sha(ROOT/'sources/FILE_09.md')=='45851004c5864229ebf6a896f9099819a08d8926715d3e97e4bc3985c4a3876e') records=json.loads((ROOT/'sources/C266_ENDPOINTS.json').read_text()) core=[r for r in records if r['source_role']=='Flood' or r['reflection_after_translation']] aux=[r for r in records if r not in core] check('fixed48core24auxiliary records',len(core)==48 and len(aux)==24) check('no regular Gears used',all(r['regular_Gear'] is None for r in records)) eta=lambda x:1000*(x-1) inverse=lambda y:1+F(y,1000) J=lambda x:2-x def pair(x): return (F(x)-F(1,4),F(x)+F(1,4)) def phase_label(x): x=F(x);frac=x%1 check('actual quarterphase '+str(x),frac in (F(1,4),F(3,4))) season='n' if frac==F(1,4) else 't' if x>0: year=x+(F(3,4) if season=='n' else F(1,4));era='AD' else: year=(F(1,4) if season=='n' else F(3,4))-x;era='BC' check('civil year nonzero '+str(x),year.denominator==1 and year>0) return f'AD {year}{season}' if era=='AD' else f'{year}{season} BC' fields={} for r in core: key=r['profile']+('_RH' if r['reflection_after_translation'] else '_F') fields.setdefault(key,[]).append(r) for k,rs in fields.items(): rs.sort(key=lambda r:r['pair_center']) centers=[F(r['pair_center']) for r in rs] check('full field '+k,len(rs)==8 and centers==list(range(int(centers[0]),int(centers[-1])+1))) for r in rs: check('inherited exact pair '+k+' '+str(r['source_index']),tuple(map(F,r['exact_components']))==pair(r['pair_center'])) def tags(r): return {k:r[k] for k in ['profile','source_role','source_index','source_BC_base','source_pair','translation','reflection_after_translation','pair_center','phase_pair']} phase_rows=[] for r in core: for i,point in enumerate(pair(r['pair_center'])): v=tags(r);v.update(exact_phase_coordinate=point,phase=('t','n')[i],source_phase=('n','t')[i] if r['reflection_after_translation'] else ('t','n')[i],eta=eta(point)) phase_rows.append(v) centers=set(F(r['pair_center']) for r in core) phases=set(p['exact_phase_coordinate'] for p in phase_rows) field_midpoints={k:F(rs[0]['pair_center']+rs[-1]['pair_center'],2) for k,rs in fields.items()} lo,hi=min(phases),max(phases) check('core phase hull',lo==F(-25,4) and hi==F(33,4)) check('center residue certificate',all(eta(x)%1000==0 for x in centers)) check('phase residue certificate',all(eta(x)%1000 in (250,750) for x in phases)) check('J1 core center symmetry',set(map(J,centers))==centers) check('J1 core phase symmetry',set(map(J,phases))==phases) classified=[] for marker in (2500,5750,6250,7500): for sign in (-1,1): y=sign*marker;x=inverse(y) center_matches=[tags(r) for r in core if r['pair_center']==x] phase_matches=[p for p in phase_rows if p['exact_phase_coordinate']==x] midpoint_matches=[k for k,m in field_midpoints.items() if m==x] row={'marker':y,'preimage':x,'center_matches':center_matches,'phase_matches':phase_matches,'whole_field_midpoint_matches':midpoint_matches,'inside_core_phase_hull':lo<=x<=hi} if phase_matches: row['civil_phase_label']=phase_label(x) classified.append(row) check('no marker is core integer center '+str(y),len(center_matches)==0) if marker==2500: check('2500 generated wholefield midpoint '+str(sign),not phase_matches and len(midpoint_matches)==1 and 'LXX_OFF' in midpoint_matches[0]) if marker in (5750,6250): check('phase marker source support '+str(y),len(phase_matches)==2 and not midpoint_matches) if marker==7500: check('7500 outsidecore '+str(sign),not phase_matches and not midpoint_matches and not row['inside_core_phase_hull']) # Identify the LXX source closing members behind the seasonal bracket. def select(profile,role,i,reflection): rs=[r for r in core if (r['profile'],r['source_role'],r['source_index'],r['reflection_after_translation'])==(profile,role,i,reflection)] check('unique selected source '+str((profile,role,i,reflection)),len(rs)==1) return rs[0] lxx_f=select('LXX_OFF','Flood',7,False) lxx_rh=select('LXX_OFF','Shem',7,True) check('LXX closing provenance',lxx_f['source_BC_base']==5283 and lxx_f['translation']==5290 and lxx_rh['source_BC_base']==5883 and lxx_rh['translation']==5888) check('LXX phases surround6000',list(map(eta,pair(7)))==[5750,6250] and list(map(eta,pair(-5)))==[-6250,-5750]) check('exact physical phase labels',list(map(phase_label,pair(7)))==['AD 7t','AD 8n'] and list(map(phase_label,pair(-5)))==['6t BC','5n BC']) check('25/23 as outerinner radius ratio',F(6250,5750)==F(25,23) and F(25,4)/F(23,4)==F(25,23)) check('529 origin ladder arithmetic',5290*F(25,23)==5750 and 5750*F(25,23)==6250) check('phase bracket has center6000 width500',F(5750+6250,2)==6000 and 6250-5750==500) # Whole-field and radius-arm midpoint constructions are generated roles. midpoint_rows=[] for key,target in [('LXX_OFF_F',F(7,2)),('LXX_OFF_RH',F(-3,2))]: rs=fields[key];a=F(rs[0]['pair_center']);b=F(rs[-1]['pair_center']) mids=tuple((p+q)/2 for p,q in zip(pair(a),pair(b))) check('wholefield midpoint '+key,(a+b)/2==target) labels=list(map(phase_label,mids)) check('midpoint physical seasons flip '+key,labels==(['AD 4n','AD 4t'] if target>0 else ['2n BC','2t BC'])) check('midpoint components already occur '+key,all(x in phases for x in mids)) check('generated midpoint center not sourcephase '+key,target not in centers and target not in phases) midpoint_rows.append({'field':key,'source_endpoint_tags':[tags(rs[0]),tags(rs[-1])],'generated_center':target,'eta':eta(target),'phasewise_midpoint_coordinates':mids,'physical_labels':labels,'status':'generated center; component co-locations do not make a new source event'}) check('same2500 halfSP radiusarm',F(1+6,2)==F(7,2) and F(-4+1,2)==F(-3,2)) # Whole 7.5-year envelopes remain lengths, not radii about c=1. arm1=(F(-25,4),F(5,4));arm2=(F(3,4),F(33,4)) check('two seasonal lengths7500',1000*(arm1[1]-arm1[0])==1000*(arm2[1]-arm2[0])==7500) check('union and overlap',(arm2[1]-arm1[0])*1000==14500 and (arm1[1]-arm2[0])*1000==500) check('hull radius7250',max(abs(eta(lo)),abs(eta(hi)))==7250) check('7500 miss is250eachside',lo-inverse(-7500)==inverse(7500)-hi==F(1,4)) aux_centers={F(r['pair_center']) for r in aux} aux_midpoints={F(a+b,2) for a,b in zip(sorted(aux_centers),sorted(aux_centers)[1:]) if b-a==1} check('auxiliary one-sided midpoint cannot closebilateral',inverse(-7500) in aux_midpoints and inverse(7500) not in aux_midpoints) # A matching two-component ratio is not an invariant field action. E=F(25,23);g=lambda x:1+E*(x-1) check('radialE sends innerphase toouterphase',g(F(27,4))==F(29,4)) check('radialE wholepair doesnotpreservephasewidth',g(F(29,4))-g(F(27,4))==F(25,46) and F(25,46)!=F(1,2)) check('radialE nextpoint losesquarterphase',g(F(29,4))%1 not in (F(1,4),F(3,4)) and g(F(29,4)) not in phases) dump('CLASSIFICATION.json',classified) dump('SOURCE_PHASE_LEDGER.json',phase_rows) dump('MIDPOINTS.json',midpoint_rows) dump('ENVELOPE_LENGTHS.json',{'core_phase_hull':[lo,hi],'core_eta_hull':[eta(lo),eta(hi)],'central_seasonal_arms':[arm1,arm2],'arm_lengths_at1000':[7500,7500],'sum':15000,'overlap':500,'union':14500,'auxiliary_status':'negative7500 can be a generatedH_MT midpoint, but no bilateral sourcepoint support follows'}) dump('RESULTS.json',{'step':'C267','status':'passed','check_count':len(checks),'checks':checks,'scientific_result':'2500 generatedLXX midpoint;5750/6250 sourcedphase bracket;7500 wholeenvelope length, not a sourcecenter orphase radius','canonical_sources_modified':False,'prior_graph_modified':False}) with (OUT/'CLASSIFICATION.csv').open('w',newline='') as f: w=csv.writer(f);w.writerow(['signed_marker','preimage','source_center_matches','phase_matches','whole_field_midpoint_matches','inside_core_hull','civil_phase_label']) for r in classified:w.writerow([r['marker'],str(r['preimage']),len(r['center_matches']),len(r['phase_matches']),';'.join(r['whole_field_midpoint_matches']),r['inside_core_phase_hull'],r.get('civil_phase_label','')]) print(json.dumps({'step':'C267','status':'passed','checks':len(checks),'output_files':6}))