import math, json def figure(id,title,xlabel,ylabel,x,series,caption): return dict(id=id,title=title,kind='analytical_curve',x_label=xlabel,y_label=ylabel,x=dict(name=xlabel,values=x),series=[dict(name=n,values=v)for n,v in series],caption=caption) def close(a,b,tol=1e-10): assert abs(a-b)<=tol*max(1,abs(a),abs(b)),(a,b) def dot(a,b):return sum(x*y for x,y in zip(a,b)) def cross(a,b):return [a[1]*b[2]-a[2]*b[1],a[2]*b[0]-a[0]*b[2],a[0]*b[1]-a[1]*b[0]] def vol(a,b,c):return dot(a,cross(b,c)) a=[1,0,0];b=[0,1,0];zs=[-1,-.75,-.5,-.25,0,.25,.5,.75,1] for z in zs: c=[0,0,z];pts=[[0,0,0],a,b,c];reflect=lambda p:[p[0],p[1],-p[2]] close(vol(a,b,c),z);close(vol(reflect(a),reflect(b),reflect(c)),-z) for p in pts: for q in pts:close(sum((p[i]-q[i])**2 for i in range(3)),sum((reflect(p)[i]-reflect(q)[i])**2 for i in range(3))) for angle in [.2,1,2]: rot=lambda p:[math.cos(angle)*p[0]-math.sin(angle)*p[1],math.sin(angle)*p[0]+math.cos(angle)*p[1],p[2]] close(vol(rot(a),rot(b),rot(c)),z) close(vol(b,a,c),-z) close(vol([2*t for t in a],[2*t for t in b],[2*t for t in c]),8*z) for q in [.01,.1,.3,.5,.7,.9,.99]: assert -.5*math.log(q)-.5*math.log(1-q)>=math.log(2)-1e-12 p=[j/10 for j in range(11)] figs=[ figure('signed-volume','Reflection preserves distances and reverses orientation','Third-vector coordinate z','Volume (constructed length units cubed)',zs,[('Signed volume',zs),('Unsigned volume',[abs(z)for z in zs])],'Labeled vectors a=(1,0,0), b=(0,1,0), c=(0,0,z). Distances agree under z→-z. This geometric construction is not a chemical measurement; z=0 is degenerate.'), figure('mirror-pair-accuracy','Class imbalance can hide orientation loss','Positive-orientation prevalence p','Optimal accuracy',p,[('Reflection-invariant representation',[max(v,1-v)for v in p]),('Noiseless sign-aware representation',[1]*len(p))],'Constructed mirror-pair classification. Invariant inputs identify both labels and can only exploit class prevalence; signed-volume inputs identify the noiseless nondegenerate orientation. No trained architecture.')] print(json.dumps(dict(status='PASS',checks=['mirror distances','signed reflection','proper rotation','permutation sign','cubic scale','balanced cross-entropy bound'],figures=figs)))