from research import *
from algebra import Matrix
s=begin(1139,'Complete the age reconstruction with a stated source basis','Which retained source coordinates close the unconstrained linear age model?',{},['C1133–C1134','File18 §3.1'])
d=json.loads((ROOT/'model/SP_age_constraints.json').read_text())
extra=[[int(i==j) for i in range(9)] for j in [4,1,3]];A=Matrix(d['matrix']+extra);rhs=d['rhs']+[65,105,70]
v=list(A.inv()*Matrix(rhs))
a=artifact('model/SP_age_basis_completion.json',json.dumps({'retained_source_ages':{'Mahalalel':65,'Seth':105,'Kenan':70},'matrix':d['matrix']+extra,'rhs':rhs,'rank':A.rank(),'determinant':clean(A.det()),'reconstructed':clean(v),'scope':'conditional coordinate recovery, cap lives and600 already supplied'},indent=2)+'\n')
finish(s,{'age_basis':a,'rank':A.rank(),'reconstructed':v},'The shared65 age and two interior ages provide an exact full-rank reconstruction after the six stated relations are retained. The distinction between a rational model and a bounded grid explains their different identification costs.','Audit the full input cost so reverse cap recovery is not counted as a new independent source explanation.',{'full_rank':A.rank()==9,'actual_recovered':v==d['source_ages']})
