mirror of
https://github.com/allaunthefox/Research-Stack.git
synced 2026-07-31 03:05:21 +00:00
Lean proof fixes: - N3L_Energy.lean: fully close gaussian_line_integral_unit_dir (nlinarith+hab for unit-circle quadratic, sqrt_mul+neg_div for integral_gaussian_1d match, exp_sum_of_sq order fix, add_assoc for h_gauss_shift, sq_sqrt for field_simp, sq_abs for perpDistance hd) - Add Adapters/AlphaProofNexus: 12 Erdos/graph adapter stubs (AlphaProof nexus) - Add Adapters/ErgodicAdditive.lean, SidonMatroid.lean - Add AntiDiophantine.lean, EffectiveBoundDQ.lean, PVGS_DQ_Bridge.lean - Add FormalConjectures/Util/ProblemImports.lean - Add RRC/EntropyCandidates/Candidates.lean - Add OTOM external project (lakefile.toml, lake-manifest.json, lean-toolchain) Infrastructure: - Add 4-Infrastructure/shim/: 17 Python probes (RRC manifold, Sidon kernel, Wannier, arxiv harvest, math_symbols DB, coverage density, geometric entropy) - Add 4-Infrastructure/NoDupeLabs/: Node server + package files - Add 6-Documentation/docs/specs/DP_RRC_RECEIPT_ENCODING_SPEC.md - Add fix_offloat.py Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
179 lines
6.5 KiB
Python
179 lines
6.5 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
rrc_manifold_assign.py — Assign RRC equations to manifold locations using
|
|
Anti-Diophantine slack regimes.
|
|
|
|
Each equation is placed on the 8D braid manifold based on:
|
|
1. Route hint from equation semantics (keyword matching)
|
|
2. Anti-Diophantine slack from match characteristics
|
|
3. Canonical Sidon label assignment
|
|
|
|
Output: shared-data/data/rrc_manifold_assignment_v1.json
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import re
|
|
from collections import Counter, defaultdict
|
|
from pathlib import Path
|
|
|
|
RECEIPT_PATH = Path("archive/experimental-shim-probes/rrc_equation_classifier_receipt.json")
|
|
OUT_PATH = Path("shared-data/data/rrc_manifold_assignment_v1.json")
|
|
|
|
# Manifold route hints with keyword patterns
|
|
ROUTE_PATTERNS: list[tuple[str, list[str], str]] = [
|
|
("thermodynamic_energy", [
|
|
"energy", "entropy", "heat", "carnot", "landauer", "temperature",
|
|
"thermodynamic", "thermal", "dissipation", "efficiency", "joule",
|
|
], "Anti-Diophantine: high match density, many variant forms"),
|
|
("geometry_topology", [
|
|
"geodesic", "metric", "stereographic", "euclidean", "manifold",
|
|
"curvature", "riemann", "tensor", "topology", "holonomy",
|
|
"connection", "bundle", "chart",
|
|
], "Diophantine: tight structural constraints"),
|
|
("cognitive_load", [
|
|
"cognitive", "load", "emotional", "signal", "attention",
|
|
"salience", "novelty", "surprise", "gate",
|
|
], "Transition: moderate slack, adaptive"),
|
|
("compression_route", [
|
|
"compress", "hutter", "encoding", "codec", "entropy",
|
|
"bit", "rate", "distortion", "redundancy",
|
|
], "Anti-Diophantine: many equivalent compression schemes"),
|
|
("magnetic_signal", [
|
|
"magnetic", "magneto", "field", "wave", "plasma",
|
|
"flux", "induction", "mhd", "alfven",
|
|
], "Anti-Diophantine: dense solution space"),
|
|
("control_signal", [
|
|
"control", "gate", "overflow", "gain", "tuning",
|
|
"cascade", "feedback", "regulator", "threshold",
|
|
], "Diophantine: precise constraint satisfaction"),
|
|
("chaotic_couch", [
|
|
"chaotic", "couch", "soliton", "turbulence", "vortex",
|
|
"strange", "attractor", "lyapunov",
|
|
], "Anti-Diophantine: chaotic regime, dense trajectories"),
|
|
("number_theory", [
|
|
"prime", "modulo", "congruence", "diophantine", "integer",
|
|
"arithmetic", "logarithm", "lower_bound", "bound",
|
|
], "Diophantine: Baker-style finiteness bounds"),
|
|
]
|
|
|
|
# Canonical Sidon labels (powers of 2) for address assignment
|
|
CANONICAL_LABELS = [1, 2, 4, 8, 16, 32, 64, 128]
|
|
|
|
|
|
def compute_antidiophantine_slack(match_count: int | None, stage: str | None) -> tuple[int, str]:
|
|
"""Compute Anti-Diophantine slack from match characteristics."""
|
|
mc = match_count or 0
|
|
if mc >= 100:
|
|
slack = 128 # Anti-Diophantine: many matches, dense
|
|
regime = "anti_diophantine"
|
|
elif mc >= 20:
|
|
slack = 64 # Transition: moderate
|
|
regime = "transition"
|
|
elif mc >= 5:
|
|
slack = 16 # Transition: tighter
|
|
regime = "transition_tight"
|
|
else:
|
|
slack = 4 # Diophantine: few matches, tight
|
|
regime = "diophantine"
|
|
# Adjust for kernel stage quality
|
|
if stage == "kernel_refine_v1":
|
|
slack = max(slack // 2, 2) # Keyword match is weaker
|
|
elif stage == "kernel_refine_v4":
|
|
slack = min(slack * 2, 256) # Dataset match is stronger
|
|
return slack, regime
|
|
|
|
|
|
def classify_route(name: str, eq_text: str) -> str:
|
|
"""Classify an equation into a manifold route by name + text keywords."""
|
|
combined = (name + " " + str(eq_text)).lower()
|
|
best_route = "unclassified"
|
|
best_score = 0
|
|
for route, keywords, _ in ROUTE_PATTERNS:
|
|
score = sum(3 for kw in keywords if kw in combined)
|
|
if score > best_score:
|
|
best_score = score
|
|
best_route = route
|
|
return best_route
|
|
|
|
|
|
def assign_canonical_label(route: str, index: int) -> int:
|
|
"""Assign a canonical Sidon label (power of 2) based on route and index."""
|
|
return CANONICAL_LABELS[hash(route + str(index)) % len(CANONICAL_LABELS)]
|
|
|
|
|
|
def main():
|
|
d = json.loads(RECEIPT_PATH.read_text())
|
|
eqs = d["compiled_equations"]
|
|
N = len(eqs)
|
|
|
|
manifold = {
|
|
"schema": "rrc_manifold_assignment_v1",
|
|
"description": "RRC equations assigned to 8D braid manifold locations with Anti-Diophantine slack regimes",
|
|
"strands": 8,
|
|
"canonical_labels": CANONICAL_LABELS,
|
|
"route_counts": {},
|
|
"regime_counts": Counter(),
|
|
"equations": [],
|
|
}
|
|
|
|
route_registry: dict[str, int] = Counter()
|
|
|
|
for e in eqs:
|
|
rec = e["equation_record"]
|
|
name = rec.get("name", "unknown")
|
|
eq_text = str(rec.get("equation", ""))
|
|
match_count = rec.get("arxiv_match_count")
|
|
stage = rec.get("arxiv_match_stage")
|
|
|
|
# 1. Classify route
|
|
route = rec.get("route_hint", "unclassified")
|
|
if route == "?" or route == "unclassified":
|
|
route = classify_route(name, eq_text)
|
|
if route == "unclassified" and not route:
|
|
route = "unclassified"
|
|
|
|
route_registry[route] += 1
|
|
|
|
# 2. Compute slack and regime
|
|
slack, regime = compute_antidiophantine_slack(match_count, stage)
|
|
manifold["regime_counts"][regime] += 1
|
|
|
|
# 3. Assign canonical Sidon label
|
|
label_idx = route_registry[route] - 1
|
|
sidon_label = assign_canonical_label(route, label_idx)
|
|
|
|
# 4. Compute address budget M = slack + label
|
|
M = slack + sidon_label
|
|
|
|
# 5. Compute strand position (0-7)
|
|
strand = sidon_label.bit_length() - 1
|
|
|
|
manifold["equations"].append({
|
|
"name": name,
|
|
"route": route,
|
|
"regime": regime,
|
|
"slack": slack,
|
|
"sidon_label": sidon_label,
|
|
"address_budget": M,
|
|
"strand": strand,
|
|
"match_count": match_count,
|
|
"match_stage": stage,
|
|
})
|
|
|
|
manifold["route_counts"] = dict(route_registry)
|
|
|
|
OUT_PATH.parent.mkdir(parents=True, exist_ok=True)
|
|
OUT_PATH.write_text(json.dumps(manifold, indent=2, ensure_ascii=False))
|
|
print(f"=== Manifold Assignment ({N} equations) ===")
|
|
print(f"Routes:")
|
|
for route, count in sorted(manifold["route_counts"].items(), key=lambda x: -x[1]):
|
|
print(f" {route:30s} {count:4d}")
|
|
print(f"\nRegimes:")
|
|
for regime, count in sorted(manifold["regime_counts"].items(), key=lambda x: -x[1]):
|
|
print(f" {regime:25s} {count:4d}")
|
|
print(f"\nWritten to {OUT_PATH}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|