PureOne's picture
Release HALOCHORD square-root boundary principle v3.0.0
3217b7f verified
Raw History Blame Contribute Delete
2.67 kB
#!/usr/bin/env python3
"""Derive the inspectable exact dataset from the archived rational check report."""
from fractions import Fraction
import json
from pathlib import Path
def build(root):
root = Path(root)
report = json.loads((root/"research"/"CLASSIFICATION_CHECKS.json").read_text(encoding="utf-8"))
cases = report["direct_cases"] + [report["negative_certificate"]]
rows = []
for case in cases:
m, k = case["m"], case["k"]
profile = [Fraction(value) for value in case["row_curvatures"]]
assert len(profile) == 2*k+2 and m*sum(profile) == 1
assert min(profile) == Fraction(case["minimum_curvature"])
assert case["full_grounded_inverse_matches_character_ring"]
for i, value in enumerate(profile):
rows.append({
"graph_id": f"G_{m}_{k}",
"circumference_m": m,
"length_k": k,
"vertex_count": case["vertices"],
"edge_count": case["edges"],
"row_index": i,
"vertices_in_row": m,
"is_cap": i in (0,len(profile)-1),
"curvature_fraction": str(value),
"curvature_decimal": float(value),
"curvature_sign": (value>0)-(value<0),
"unit_conductance": True,
"full_grounded_inverse_checked": True,
"source_report": "research/CLASSIFICATION_CHECKS.json",
})
assert len(cases) == 19 and len(rows) == 122
dest=root/"data"
dest.mkdir(exist_ok=True)
(dest/"unit_curvature_samples.jsonl").write_text(
"".join(json.dumps(row,ensure_ascii=False)+"\n" for row in rows),encoding="utf-8")
summary={
"research_version":"3.0.0",
"dataset_version":"1.0.0",
"records":len(rows),"distinct_graphs":len(cases),
"exact_arithmetic":"fractions.Fraction; decimals are display approximations",
"row_interpretation":"Each record gives one cyclic orbit containing m vertices",
"source_report_version":report["version"],
"source_report_retention":"The v2 exact unit report is unchanged in the v3 release",
"formal_proof_assistant_verified":False,
"external_review":False,
"positive_rows":sum(r["curvature_sign"]>0 for r in rows),
"negative_rows":sum(r["curvature_sign"]<0 for r in rows),
"zero_rows":sum(r["curvature_sign"]==0 for r in rows),
}
(dest/"DATA_SUMMARY.json").write_text(json.dumps(summary,indent=2)+"\n",encoding="utf-8")
return summary
if __name__=="__main__":
print(json.dumps(build(Path(__file__).resolve().parent),indent=2))