from research import *
from algebra import Matrix
s=begin(1154,'Construct the shared-amplitude post-Flood dictionary','Can the located operations be generated by one century, one sixty and one early-life increment?',{'amplitudes':['u=100','t=60','a=27']},['C1153','prep/postflood_source_packets.json'])
names=['Shem','Arphaxad','Shelah','Eber','Peleg','Reu','Serug','Nahor','Terah']
rb=[[0,0,0]]+[[1,0,0]]*6+[[F(1,2),0,0],[0,0,0]]
spL=[[0,0,0],[0,0,0],[0,0,0],[0,-1,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,-1,0]]
lxL=[[0,0,0],[0,0,1],[0,0,1],[1,-1,0],[1,0,0],[1,0,0],[1,0,0],[0,1,0],[0,0,0]]
rows=[];labels=[]
for t,life in [('SP',spL),('LXX_OFF',lxL)]:
 for n,r,l in zip(names,rb,life):rows.extend([r,l]);labels.extend([t+':'+n+':R',t+':'+n+':A'])
M=Matrix(rows);out=list(M*Matrix([100,60,27]));old=json.loads((ROOT/'model/postflood_row_operations.json').read_text());want=[v for r in old for v in [r['R'],r['A']]]
a=artifact('model/postflood_amplitude_dictionary.json',json.dumps(clean({'parameters':['u','t','a'],'source_values':[100,60,27],'labels':labels,'matrix':rows,'rank':M.rank(),'names':names,'R_mask':rb,'SP_A_mask':spL,'LXX_A_mask':lxL,'scope':'fitted complete-family representation; named supports count as premises'}),indent=2)+'\n')
finish(s,{'amplitude_dictionary':a,'rank':M.rank(),'outputs':len(out)},'The whole36-coordinate change packet lies in a rank3 source-labelled model with amplitudes100,60,27. Repeated changes share parameters, but their named supports remain part of the description.','Determine which observations actually recover the three amplitudes.',{'all36_match':out==want,'rank3':M.rank()==3,'fixed_labels':len(labels)==36})
