SilverSight/scripts/heatmap_gen.py
allaun 3362d554d1 feat(braid/dag): land untracked research WIP + register 4 formal libs; ignore build artifacts
- lakefile.lean: register SilverSight.{AngrySphinx,CollatzBraid,GoldenSpiral,GCCL}
- docs/research/: braid group action, iteration DAG/regime, Sidon
  preservation/creation, unified CRT-torus DAG notes
- docs/diagrams/: DAG + heatmap + 8-strand search JSON/dot outputs
- formal/CoreFormalism/StrandCapacityBound.lean: capacity bound (passes
  hardened anti-smuggle --ci)
- scripts/, python/: braid word solver, collapse/DAG search + tuning,
  heatmap gen, YB search/verification, wrapping verifier
- .gitignore: exclude rust/**/target and coq compiled artifacts
  (*.vo/*.vok/*.vos/*.glob/*.aux) that were polluting the tree

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-03 15:11:37 -05:00

44 lines
1.7 KiB
Python

#!/usr/bin/env python3
"""Generate modulus heatmap visualization data (JSON)."""
import sys, math, json
sys.path.insert(0, '/home/allaun/SilverSight/scripts')
from verify_wrapping import f_k, is_sidon, certify_sidon_creation
def generate_heatmap_data(A, S, max_mod=16):
"""Generate heatmap of all coprime pairs in [2,max_mod]."""
maxA = max(A)
data = {'A': A, 'S': S, 'maxA': maxA, 'cells': []}
for L1 in range(2, max_mod + 1):
for L2 in range(2, max_mod + 1):
if L1 == L2: continue
if math.gcd(L1, L2) != 1: continue
M = L1 * L2
if not (maxA < M <= 2 * maxA):
# Still record but mark as out-of-range
status = "out_of_range"
else:
FA = [f_k(a, S, [L1, L2]) for a in A]
sidon = is_sidon(FA)
_, _, reason = certify_sidon_creation(A, S, [L1, L2])
status = "sidon" if sidon else "fail"
data['cells'].append({
'L1': L1, 'L2': L2, 'M': M,
'status': status
})
return data
# Known examples
examples = [
([1,2,5,6], 7, "Sidon example"),
([0,1,3,8,13], 27, "Complex set"),
]
for A, S, name in examples:
data = generate_heatmap_data(A, S)
with open(f'/home/allaun/SilverSight/docs/diagrams/heatmap_{name.replace(" ","_")}.json', 'w') as f:
json.dump(data, f, indent=2)
sidon_count = sum(1 for c in data['cells'] if c['status'] == 'sidon')
fail_count = sum(1 for c in data['cells'] if c['status'] == 'fail')
out_count = sum(1 for c in data['cells'] if c['status'] == 'out_of_range')
print(f"{name}: {sidon_count} sidon, {fail_count} fail, {out_count} out-of-range")