#!/usr/bin/env python3 """Generate exact V3 data; no plotted or simulated physical measurements.""" import csv,json,sys from pathlib import Path from math import comb,ceil ROOT=Path(__file__).resolve().parents[1] sys.path.insert(0,str(ROOT/'src')) from noulith.third import (example_point,predicted_rank,direct_block_rank,optimal_calibration_subfamily, calibration_classes,certify_scalar,component_equations,all_components) from noulith.algebra import TwistedAlgebra def table(name,fields,rows): with (ROOT/'data'/name).open('w',newline='') as f: w=csv.DictWriter(f,fieldnames=fields);w.writeheader();w.writerows(rows) def main(): rows=[] for m in range(6,31): E=optimal_calibration_subfamily(m) rows.append(dict(m=m,edge_parameters=comb(m,2),star_components=m,triangle_components=comb(m,3), twin_components=comb(m,2),total_components=m+comb(m+1,3), minimum_calibration_constraints=len(E),remaining_scale_classes=len(calibration_classes(m,E)))) table('v3_component_and_budget_counts.csv',list(rows[0]),rows) kinds=['origin','star','triangle','twin','uniform_star','star_twin','edge','double_star','generic'] rows=[] for m in [6,7,8]: for kind in kinds: q=example_point(m,kind);r=direct_block_rank(m,q,m-3) assert r==predicted_rank(m,q) rows.append(dict(m=m,stratum=kind,state_dimension=2**m,rank=r,nullity=2**m-r)) table('v3_exact_rank_strata.csv',list(rows[0]),rows) components=[] for c in all_components(6): M=component_equations(6,c) components.append({'type':c[0],'labels_zero_based':c[1],'dimension':15-M.rank(), 'linear_equations_ascending_edges':[[int(x) for x in M.row(i)] for i in range(M.rows)]}) (ROOT/'data/v3_components_m6.json').write_text(json.dumps(components,indent=2)+'\n') certs=[] for kind in kinds: q=example_point(6,kind);c=certify_scalar(6,q) entry={'stratum':kind,'visible':c.visible,'motif':c.motif, 'normalized_response':str(c.normalized_response),'containing_components':c.components} if c.visible: alg=TwistedAlgebra(6,q);b=c.full_partition(6);raw=alg.isolated_response(b) assert raw==alg.isolated_unit(b)*c.normalized_response entry['raw_word_response']=str(raw);entry['partition_masks']=b certs.append(entry) (ROOT/'data/v3_visibility_certificates.json').write_text(json.dumps(certs,indent=2)+'\n') print('Generated component counts, exact rank strata, linear equations, and raw-word certificates.') if __name__=='__main__':main()