from research import *
s=begin(1013,'Identities versus equal source values','Which agreements among all Esau registers follow from incidence alone?',{},['C1008','C1011','C1012'])
from algebra import Matrix
p=json.loads((ROOT/'model/structural_transfer_inputs.json').read_text())
def pref(order):return [[int(j in order[:i]) for j in range(9)] for i in range(1,len(order)+1)]
rows=pref(p['clean_order'])+pref(p['female_order'])+pref(p['unclean_order']);M=Matrix(rows);y=list(M*Matrix(p['Esau_counts']));relations=[list(v) for v in M.T.nullspace()]
a=artifact('model/esau_register_dependencies.json',json.dumps(clean({'matrix':rows,'left_relations':relations,'rank':M.rank(),'source_equalities':{'clean1_unclean1':[y[0],y[11]],'clean3_unclean2':[y[2],y[12]]}}),indent=2)+'\n')
finish(s,{'dependencies':a,'universal_dependency_dimension':len(relations),'source_equalities':[y[0]==y[11],y[2]==y[12]]},'Fourteen register measurements contain five universal linear dependencies. The additional20 and50 matches join different animals and rely on the supplied counts; incidence alone does not force them.','Test how source ritual templates alter the earlier Tishri margin ambiguity.',{'rank_nine':M.rank()==9,'five_dependencies':len(relations)==5,'different_incidence':rows[0]!=rows[11] and rows[2]!=rows[12]})
