from research import *
s=begin(1277,'Compare row-rounded blocks with once-rounded block totals','Can theMosesblockdiagram preserve thesourceRoundedpath withoutlosingresidualinformation?',{},['C1234','C1236','C1218','prep/common_representation_architecture.md'])
def Qz(x):return 5*((x+2)//5)
rows=json.loads((ROOT/'model/Moses_MT_complete_path.json').read_text())['rows'];names=[r['name'] for r in rows];cuts=['Adam','Seth','Enoch','Arphaxad','Reu','Moses'];out=[]
for a,b in zip(cuts,cuts[1:]):
 part=rows[names.index(a):names.index(b)];exact=sum(x['actual'] for x in part);rounded=sum(x['rounded'] for x in part);out.append({'from':a,'to':b,'exact':exact,'row_rounded':rounded,'aggregate_residual':exact-rounded,'once_rounded':Qz(exact)})
a=artifact('model/Moses_block_rounding_order.json',json.dumps({'blocks':out,'exact_total':sum(x['exact'] for x in out),'row_rounded_total':sum(x['row_rounded'] for x in out),'once_rounded_whole':Qz(sum(x['exact'] for x in out)),'rule':'Aggregate residuals are sums ofrowresiduals andneednot liein[-2,2]. Renormalizingthem changesthepublishedRoundedpath.'},indent=2)+'\n')
finish(s,{'block_rounding_order':a,'block_residuals':[x['aggregate_residual'] for x in out]},'The fiveblocks retain residuals0,2,4,−1,1. Enoch-to-Arphaxad is1030 afterrowrounding but1035 iftheexactblock isroundedonce; thewholepath is2580 ratherthanQ(2586)=2585. Thediagrammustretain thedeclaredoperationorder.','Verify thecomplete25-nodeexactfield isrecoveredby accumulatedrowresiduals.',{'exact_blocks':[x['exact'] for x in out]==[130,492,1034,129,801],'residuals':[x['aggregate_residual'] for x in out]==[0,2,4,-1,1],'distinction':out[2]['row_rounded']==1030 and out[2]['once_rounded']==1035,'whole':Qz(sum(x['exact'] for x in out))==2585})
