from pathlib import Path
import json,hashlib,re
ROOT=Path('/workspace/scratch/1b40da62dcbd')
SOURCE=ROOT/'upload/File_52c.Rounded_Whole_Span_Inverse_Detailed_Study_Draft (2)(1).md'
OUT=ROOT/'c832_c931/prep'
text=SOURCE.read_text(); lines=text.splitlines()
assert hashlib.sha256(SOURCE.read_bytes()).hexdigest()=='a5ea84562101158b60d0cf296765d6eff38e7a2abda4e74ad1b353dfd13b9530'
def table_after(title):
start=next(i for i,x in enumerate(lines) if x==title)
first=next(i for i in range(start+1,len(lines)) if lines[i].startswith('|'))
end=first
while end<len(lines) and lines[end].startswith('|'):end+=1
rows=[]
for i in range(first+2,end):
cells=[x.strip() for x in lines[i].strip('|').split('|')]
rows.append({'cells':cells,'line':i+1,'raw':lines[i]})
return rows
manifest=table_after('### 2.1 The 32 admitted dates')
nativity=table_after('### A.2 Nativity-family inverses: 6 BC, 1406 BC, and 1446 BC')
conquest=table_after('### A.3 Conquest-family inverses: 6 BC, 1406 BC, and 1446 BC')
assert len(manifest)==len(nativity)==len(conquest)==32
rows=[]
for m,n,c in zip(manifest,nativity,conquest):
assert int(m['cells'][0])==int(n['cells'][0])==int(c['cells'][0])
rows.append({'number':int(m['cells'][0]),'source_name':m['cells'][1],'source_BC':int(m['cells'][2]),'node_class':m['cells'][3],'source_basis':m['cells'][4],
'Nativity':{'anchor_BC':int(n['cells'][1]),'endpoint_BC':int(n['cells'][2]),'literal_line':n['line']},
'Conquest':{'anchor_BC':int(c['cells'][1]),'endpoint_BC':int(c['cells'][2]),'literal_line':c['line']},
'manifest_line':m['line'],'manifest_raw':m['raw']})
def I(n):
# Exactly one call on each original source-to-anchor duration.
if n==0:return 0
p=1
while n%10==0:n//=10;p*=10
return p*int(str(n)[::-1])
def digits(n):
k=0
while n%10==0:n//=10;k+=1
ds=[int(x) for x in str(n)]
return {'placeholder_count':k,'core_digits':ds,'core_length':len(ds)}
def paired_formula(n):
a,b,c=n//100,(n//10)%10,n%10
if c==0:
assert n in [200,410]
return ('retained_zero_200' if n==200 else 'retained_zero_410'),(0 if n==200 else 7200)
if n>=240:
return ('three_digits_no_borrow',990) if b>=4 else ('three_digits_borrow',1980)
if n>=150:return 'two_digit_Conquest_core',1260+90*a-90*b-900*c
assert 144<=n<150
return 'one_digit_Conquest_core',990-990*c
diagnostics=[]
for row in rows:
d=row['source_BC']; a0=row['Nativity']['anchor_BC']; n=(d-a0)//10
assert a0==(6 if d%10==6 else 1)
assert row['Conquest']['anchor_BC']==a0+1400
routes=[]
for role in ['Nativity','Conquest']:
a=row[role]['anchor_BC']; span=d-a; encoded=digits(span)
ds=encoded['core_digits']; p=10**encoded['placeholder_count']
digit_output=p*sum(x*10**i for i,x in enumerate(ds))
endpoint=a+I(span)
assert endpoint==row[role]['endpoint_BC']==a+digit_output
routes.append({'role':role,'source_span':span,**encoded,'single_pass_value':digit_output,'reconstructed_BC':endpoint})
stratum,delta=paired_formula(n)
actual=row['Conquest']['endpoint_BC']-row['Nativity']['endpoint_BC']
assert delta==actual
diagnostics.append({'number':row['number'],'source_name':row['source_name'],'source_BC':d,'n':n,'source_digits':[n//100,n//10%10,n%10], 'stratum':stratum,'predicted_endpoint_difference':delta,'literal_endpoint_difference':actual,'routes':routes})
# Structural path tables are copied literally and stay outside the paired-map field.
paths={heading:table_after(heading) for heading in ['### 3.1 Whole-span trunk inversions','### 3.3 The segmented 12026 BC convergence']}
packet={'purpose':'Frozen existing File52c source and endpoint literals for a complete paired-anchor structural field; target widths and hit outcomes deliberately not extracted.',
'source':{'path':str(SOURCE),'sha256':hashlib.sha256(SOURCE.read_bytes()).hexdigest(),'bytes':SOURCE.stat().st_size},
'source_rows':rows,'source_path_tables':paths,
'rules':{'source_anchor':'6 for 6-ending source; 1 for 1-ending source','Conquest_anchor':'Nativity anchor +1400','route':'A+I(D-A)','one_pass':'Each I input is an original source-to-anchor duration; no inverse endpoint is input to I.',
'encoding':'s=10^k sum(d_j 10^(m-1-j)); I(s)=10^k sum(d_j 10^j), where d_0 and d_(m-1) are nonzero.',
'paired_difference':'1400+I(10(n-140))-I(10n); each I is applied once to its own original span.'},
'guards':['No target-frequency tally','No target-residue census','No source manifest changes','No second decimal inversion','No canonical file edit','No source-date gear transport','No new raw-chronology dates generated by digit-stratum formulas']}
(OUT/'inverse_inputs.json').write_text(json.dumps(packet,indent=2)+'\n')
(OUT/'inverse_paired_diagnostics.json').write_text(json.dumps({'rows':diagnostics,'verification':{'all_source_rows':32,'all_original_endpoint_reconstructions':64,'paired_formula_matches':32,'no_target_columns':True,'no_second_pass':True}},indent=2)+'\n')
print(json.dumps({'source_rows':len(rows),'existing_endpoint_reconstructions':2*len(rows),'all_paired_differences_exact':True,'packet_sha256':hashlib.sha256((OUT/'inverse_inputs.json').read_bytes()).hexdigest()}))
Evidence
prepare inverse inputs.py
Linked sources and evidence
Edition and provenance
prepare_inverse_inputs.py
SHA-256 2dbfa7824676282f7601fdc2b1b2cf1f739c7928ffcb4969dddebd59014a2afe
C480–C1634/Research_Cycles/C0832_C0931/prep/prepare_inverse_inputs.py