from pathlib import Path
from fractions import Fraction as F
import hashlib,json
def rank(rows):
a=[[F(x) for x in row] for row in rows];r=0
for col in range(len(a[0])):
pivot=next((i for i in range(r,len(a)) if a[i][col]),None)
if pivot is None:continue
a[r],a[pivot]=a[pivot],a[r];p=a[r][col]
a[r]=[x/p for x in a[r]]
for i in range(len(a)):
if i!=r:
f=a[i][col];a[i]=[x-f*y for x,y in zip(a[i],a[r])]
r+=1
if r==len(a):break
return r
def dot(a,b):return sum(x*y for x,y in zip(a,b))
OUT=Path(__file__).resolve().parent
ROOT=OUT.parents[2]
SRC=ROOT/'c832_c931/evidence/sources/File52c_latest.md'
lines=SRC.read_text().splitlines()
sha=hashlib.sha256(SRC.read_bytes()).hexdigest()
assert sha=='a5ea84562101158b60d0cf296765d6eff38e7a2abda4e74ad1b353dfd13b9530'
assert (OUT/'QUESTIONS_BEFORE_CALCULATION.md').exists()
def excerpt(a,b):
return {'first_line':a,'last_line':b,'text':'\n'.join(lines[a-1:b])}
def I(n):
# Applied once only to an original declared or explicitly diagnostic duration.
assert n>0
f=1
while n%10==0:n//=10;f*=10
out=0
while n:n,d=divmod(n,10);out=10*out+d
return f*out
def reg(n):
k=0;m=n
while m%10==0:m//=10;k+=1
return {'zeros':k,'digits':[int(z) for z in str(m)],'length':len(str(m))}
def aggregates(parts):
rs=[reg(n) for n in parts]
assert all(r['zeros']==1 and r['length']==3 for r in rs)
return [sum(r['digits'][j] for r in rs) for j in range(3)]
packet={'source':{'path':str(SRC),'sha256':sha},
'question_register_sha256':hashlib.sha256((OUT/'QUESTIONS_BEFORE_CALCULATION.md').read_bytes()).hexdigest(),
'literal_source_coordinates':{'Conquest_BC':1406,'Nativity_BC':6,'Exodus_BC':1446,'Rounded_regular_Creation_BC':4106,'Rounded_cumulative_Creation_BC':14006,'Rounded_regular_Flood_BC':2456,'Rounded_cumulative_Flood_BC':4836,'Rounded_regular_Noah_BC':3056,'Rounded_cumulative_Shem_BC':5436,'Actual_regular_Creation_completion_BC':4114,'Actual_cumulative_Creation_completion_BC':14004,'Moses_birth_BC':1526,'Temple_BC':966},
'paths':[
{'id':'regular_primary','chronological_components':[1650,1050],'source_lines':[359,364],'status':'primary admitted'},
{'id':'regular_Noah','chronological_components':[1050,1650],'source_lines':[360,403],'status':'admitted order permutation'},
{'id':'regular_Flood_Noah','chronological_components':[1050,600,1050],'source_lines':[361,403],'status':'admitted local refinement'},
{'id':'cumulative_primary','chronological_components':[9170,3430],'source_lines':[362,364],'status':'primary admitted'}],
'tail':{'duration':1400,'source_single_pass_value':4100,'source_lines':[370,378,388]},
'expected_outputs_for_validation_only':{'conquest_stage_BC':12026,'nativity_stage_BC':14726,'common_primary_reverse_sum':10620,'nativity_reverse_sum':14720,'weighted_ratio_C_to_R':'4:1','same_side_to_Exodus':10580,'observed_529_coefficient':20,'first_E_duration':11500,'second_E_duration':12500,'Temple_inverse_BC':696,'Moses_inverse_BC':1616},
'independent_operation_choices':{'single_pass':'retained-zero reversal on each source-admitted component','calendar_E':'25/23','rounded_coordinate':'q(BC B)=1−B; q(AD Y)=Y−1','secondary_cumulative_scope':'Only File52c literal Shem5436 can be used for a derived secondary diagnostic; Noah cumulative details are not newly sourced here.'},
'locators':{'primary_paths':excerpt(351,407),'Shem_birth_and_Flood':excerpt(415,420),'weighted_bridge':excerpt(1242,1264),'529_ladder':excerpt(1632,1663),'Temple_source_inverse':excerpt(295,316),'Temple_first_junction':excerpt(594,643),'Moses_second_junction':excerpt(688,738)},
'guards':['No second decimal reversal','No new target tally','No source mutation','Diagnostic alternative partitions are mathematical controls, not new chronological nodes','Do not treat derived coefficient20 or weighted ratio4 as independent evidence after computing them from frozen dates']}
(OUT/'inputs.json').write_text(json.dumps(packet,indent=2)+'\n')
R=[1650,1050];C=[9170,3430];A=1406;N=6;X=1446;E=F(25,23)
r=aggregates(R);c=aggregates(C)
w=[[100,10,1],[1,10,100]]
rawrev={'regular':{'aggregate':r,'raw':sum(R),'reversed':sum(map(I,R))},'cumulative':{'aggregate':c,'raw':sum(C),'reversed':sum(map(I,C))}}
assert r==[2,6,10] and c==[12,5,10]
assert rank(w)==2 and all(dot(row,[10,-101,10])==0 for row in w)
# Complete aggregate possibilities, not chronology or target enumeration.
# Analytical bounds are also stated in the memo: A,C in[2,18], B in[0,18].
def possible_aggregates(total):
ans=[]
for a in range(2,19):
for b in range(19):
cc=total//10-100*a-10*b
if 2<=cc<=18:
ans.append({'aggregate':[a,b,cc],'reversed_total':10*(a+10*b+100*cc)})
return ans
regular_options=possible_aggregates(2700);cumulative_options=possible_aggregates(12600)
assert regular_options==[{'aggregate':[2,6,10],'reversed_total':10620}]
assert cumulative_options==[{'aggregate':[11,15,10],'reversed_total':11610},{'aggregate':[12,5,10],'reversed_total':10620}]
# In aggregate coordinates(AR,BR,CR,AC,BC,CC), these are convergence and
# equality of the REGULAR reversed endpoint to (4C+R)/5.
f1=[1,10,100,-1,-10,-100]
f2=[-95,40,499,-400,-40,-4]
constraints=[f1,f2]
assert rank(constraints)==2
base=r+c
assert all(dot(row,base)==0 for row in constraints)
def inspect(Rp,Cp):
pr=sum(map(I,Rp));pc=sum(map(I,Cp));Rhead=A+sum(Rp);Chead=A+sum(Cp)
weighted=F(4*Chead+Rhead,5)
return {'regular_parts':Rp,'cumulative_parts':Cp,'regular_aggregate':aggregates(Rp),'cumulative_aggregate':aggregates(Cp),'regular_reversed_sum':pr,'cumulative_reversed_sum':pc,'regular_head':Rhead,'cumulative_head':Chead,'regular_inverse_endpoint':A+pr,'cumulative_inverse_endpoint':A+pc,'weighted_point':str(weighted),'convergence':pr==pc,'regular_weighted_equality':A+pr==weighted}
controls={'preserve_convergence_break_weighted':inspect([2650,1050],[9170,4430]),'preserve_source_heads_and_weighted_break_convergence':inspect(R,[9970,2630]),'same_aggregate_different_ordered_regular_components':inspect([1550,1150],C),'same_aggregate_different_ordered_cumulative_components':inspect(R,[9270,3330])}
assert controls['preserve_convergence_break_weighted']['convergence'] and not controls['preserve_convergence_break_weighted']['regular_weighted_equality']
assert not controls['preserve_source_heads_and_weighted_break_convergence']['convergence'] and controls['preserve_source_heads_and_weighted_break_convergence']['regular_weighted_equality']
# Two exact local source instances of peeling the hundred-place component.
peels=[]
for whole,tail in [(1650,600),(9170,600)]:
remainder=whole-tail
hundred_digit=(whole//100)%10;d=tail//100
defect=I(remainder)+I(tail)-I(whole)
assert defect==(990 if hundred_digit<d else 0)
peels.append({'whole':whole,'remaining_original_piece':remainder,'tail':tail,'hundred_digit':hundred_digit,'peeled_digit':d,'borrow':hundred_digit<d,'refinement_defect':defect})
primary_values=[A+sum(map(I,p)) for p in [R,C]]
completed_values=[N+I(A-N)+sum(map(I,p)) for p in [R,C]]
assert primary_values==[12026,12026] and completed_values==[14726,14726]
g=sum(map(I,R));t=I(A-N)
modular={'regular_evaluated_sum_mod23':g%23,'tail_evaluated_mod23':t%23,'combined_mod23':(g+t)%23,'meaning':'17+6=23 is source-derived compatibility; equal path sums alone do not force it'}
assert (g%23,t%23,(g+t)%23)==(17,6,0)
K=primary_values[0];B=completed_values[0];d=K-X;k=F(d,529)
ladder=[F(d),E*d,E*E*d]
assert d==10580 and k==20 and ladder==[10580,11500,12500]
qp=K-1;q_ladder=[qp-y for y in ladder]
T=N+I(966-N);M=A+I(1526-A)
first_constraint=46+2*B+2*K-25*(T+X)
second_constraint=2*(K-X)-23*(M-T)
q_t=1-B+E*(B-T);q_m=1-B+E*(B-M)
assert first_constraint==second_constraint==0 and q_t==q_ladder[1]==525 and q_m==q_ladder[2]==-475
J=[[2,2,-25,0,-25],[2,0,23,-23,-2]] # K,B,T,M,X
assert rank(J)==2
assert 4*(-2)+8==0
result={'status':'PASS','raw_reverse_forms':{'raw_weights':[100,10,1],'reverse_weights':[1,10,100],'outside_scale':10,'data':rawrev,'combined_rank':2,'integer_kernel_generator':[10,-101,10],'bounded_integer_injectivity':'Any two feasible aggregate vectors differ by at most18 in the middle column, so no nonzero integer multiple of(10,-101,10) connects them.'},
'reverse_equality_kernel':{'regular_minus_cumulative':[-10,1,0],'reverse_dot':0,'raw_dot':-990,'raw_difference':-9900,'full_integer_basis':[[-10,1,0],[-100,0,1]],'parameterization':'delta=(-10u-100v,u,v); raw change=−9900u−99990v'},
'fixed_total_possible_aggregates':{'regular2700':regular_options,'cumulative12600':cumulative_options},
'free_aggregate_constraints':{'variable_order':['AR','BR','CR','AC','BC','CC'],'convergence_form':list(f1),'regular_weighted_form':list(f2),'rank':2,'caution':'Algebraic independence in the free aggregate register does not imply two new independent empirical witnesses when source totals and integral bounds are already fixed.'},
'diagnostic_controls_not_chronologies':controls,'source_hundred_place_refinements':peels,
'continuation':{'primary':primary_values,'completed':completed_values,'shared_output_shift':I(A-N)-(A-N),'equality_at_completed_stage':'same prior equality after common addition; no extra rank'},
'modular_compatibility':modular,
'529_dependency':{'primitive_dates':[A,N,X],'computed_K':K,'computed_B':B,'measured_D':d,'derived_k':str(k),'derived_ladder':[str(z) for z in ladder],'reflected_coordinates':[str(z) for z in q_ladder],'T_inverse':T,'M_inverse':M,'first_junction_form':'46+2B+2K−25(T+X)=0','second_gap_form':'2(K−X)−23(M−T)=0','two_junction_constraint_rank':2,'first_junction_value':first_constraint,'gap_value':second_constraint,'derived_expansion_gains':[str(ladder[1]-ladder[0]),str(ladder[2]-ladder[1])]},
'actual_rounded_weighted_kernel':{'delta_C':-2,'delta_R':8,'weighted_numerator_change':0,'status':'inherited C494/C902, dependency linkage only'},
'tests':{'fixed_total_aggregate_options':True,'free_constraint_rank2':True,'both_diagnostic_directions':True,'local_refinement_carry_rule':True,'same_tail_adds_no_equality_constraint':True,'all_inverse_inputs_original':True,'no_target_tally':True}}
(OUT/'calculations.json').write_text(json.dumps(result,indent=2)+'\n')
print(json.dumps({'status':'PASS','input_sha256':hashlib.sha256((OUT/'inputs.json').read_bytes()).hexdigest(),'aggregate_options':result['fixed_total_possible_aggregates'],'constraint_rank':rank(constraints),'529_k_is_output':str(k)}))
Evidence
prepare constraints.py
Linked sources and evidence
Edition and provenance
prepare_constraints.py
SHA-256 f02a8567a31fb24fbab1e541f4a575b2fd274f89800a7dbfbf415cc88e675466
C480–C1634/Research_Cycles/C0932_C1131/prep/inverse_constraints/prepare_constraints.py