mirror of
https://github.com/allaunthefox/Research-Stack.git
synced 2026-07-31 03:05:21 +00:00
Squash the four overlapping feature branches into a single change set against main, eliminating cross-PR merge conflicts and the duplicated CI-fix scripts. What this brings in (merge order #79 -> #80 -> #81 -> #89): - #79 refactor(infra): shared utilities (4-Infrastructure/lib/*: q16, hashing, jsonl, fraction_utils) + the scripts/math-first/* validators that the math-check CI requires. - #80 feat(lean): Semantics.E8Sidon (1025 lines) -- Eisenstein coefficient identity E4^2 = E8 and the Sidon framework. E4_sq_eq_E8_coeff is fully proved (all Fourier-coefficient extraction machine-checked); the single residual gap is pinned to E4_sq_eq_E8_qExpansion (Mathlib lacks the valence formula / dim M8 = 1). 4 sorries + 1 axiom (e8_additive_completeness), all TODO(lean-port). - #81 refactor(lean): Float-free FixedPoint core (integer-only sqrt/log2/expNeg). E8Sidon.lean kept at #80's final 1025-line version (the #81 intermediate 438-line copy was overridden by merge order). - #89 feat(lean): Semantics.RRC.PolyFactorIdentity -- short-sleeve polynomial detection at the zerocopy limb boundary; now imports Semantics.E8Sidon for sigma3/sigma7/convolutionLHS (single source of truth) instead of inlining them. Conflict resolution: - flake.nix -> canonical rs-surface removal (Garnix shutdown). - scripts/math-first/* -> byte-identical across branches, clean. - .cursorrules / AGENTS.md -> unified; baselines + sorry inventory refreshed. Verification: - lake build (default aggregator): 3573 jobs, 0 errors. - lake build Semantics.RRC.PolyFactorIdentity (E8Sidon + FixedPoint + PolyFactor): 3655 jobs, 0 errors. Witnesses verified (sigma7 4 = 16513, convolutionLHS 6 = 2350). - Python tests: 68/68 pass. Note: the "Workers Builds: researchstack" check is a preexisting external Cloudflare build unrelated to this change (no branch touches 4-Infrastructure/cloudflare/). Build: 3573 jobs (default), 3655 jobs (narrow), 0 errors Co-Authored-By: Allaun Silverfox <bigdataiscoming+9i37y6j2@protonmail.com>
67 lines
2.3 KiB
Python
67 lines
2.3 KiB
Python
import json
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parents[2] / "4-Infrastructure"))
|
|
from lib.q16 import to_q16
|
|
|
|
|
|
def sadd(a, b):
|
|
"""Saturating 32-bit signed addition."""
|
|
res = a + b
|
|
if res > 0x7FFFFFFF: return 0x7FFFFFFF
|
|
if res < -0x80000000: return -0x80000000
|
|
return res
|
|
class AVMReference:
|
|
def __init__(self):
|
|
self.state = {"stack": [], "pc": 0}
|
|
|
|
def compute_routing(self, genome, event_source, lawful):
|
|
# GenomeAddr = {mu, rho, c, m, ne, sigma}
|
|
# addr = {muBin, rhoBin, cBin, mBin, neBin, sigmaBin}
|
|
addr = 0
|
|
for i, val in enumerate(genome):
|
|
addr = (addr << 3) | (val & 0x7)
|
|
|
|
bucket = genome[0] # muBin
|
|
|
|
# SourceTargetClassifier
|
|
# notion=0, linear=1, ene=2, rgflow=3, swarm=4
|
|
# TGT: ene_pkgs=0, swarm_man=1, swarm_nodes=2, swarm_wq=3, mcast=4
|
|
source = event_source
|
|
if source in [0, 1, 2]: target = 0
|
|
elif source == 3: target = 1
|
|
elif source == 4 and lawful: target = 2
|
|
elif source == 4 and not lawful: target = 3
|
|
else: target = 4
|
|
|
|
return addr, bucket, target
|
|
|
|
def compute_cost(self, bind_cost, bucket):
|
|
return sadd(bind_cost, bucket)
|
|
|
|
def generate_receipts():
|
|
avm = AVMReference()
|
|
boards = [
|
|
{"name": "Board 0", "genome": [2,4,0,4,7,0], "source": 4, "lawful": True, "cost": 0x10000},
|
|
{"name": "Board 1", "genome": [7,7,7,7,7,7], "source": 4, "lawful": False, "cost": 0x20000},
|
|
{"name": "Board 2", "genome": [1,2,3,4,5,6], "source": 2, "lawful": True, "cost": 0xA000},
|
|
{"name": "Board 3", "genome": [0,0,0,0,0,0], "source": 4, "lawful": True, "cost": 0x0000},
|
|
{"name": "Board 4", "genome": [5,3,1,6,2,4], "source": 3, "lawful": True, "cost": 0x15000},
|
|
]
|
|
|
|
results = []
|
|
for b in boards:
|
|
addr, bucket, target = avm.compute_routing(b["genome"], b["source"], b["lawful"])
|
|
total_cost = avm.compute_cost(b["cost"], bucket)
|
|
results.append({
|
|
"board": b["name"],
|
|
"addr": hex(addr),
|
|
"target": target,
|
|
"cost": hex(total_cost)
|
|
})
|
|
|
|
print(json.dumps(results, indent=2))
|
|
|
|
if __name__ == "__main__":
|
|
generate_receipts()
|