mirror of
https://github.com/allaunthefox/SilverSight.git
synced 2026-07-30 17:16:16 +00:00
refactor(rrc): rename corpus250→allFixtures/emitManifold, generic n-dimensional modules, Authentik deploy
- Rename python/build_corpus250.py → python/build_manifold.py - Rename emitCorpus250 → emitManifold, corpus250 → allFixtures - Schema: avm_rrc_corpus250_v1 → avm_rrc_manifold_v1 - Classify.lean now delegates to ClassifyN (generic n-dim module) - ClassifyN.hashTable8: extracted 119-entry hash table from old Classify - build_manifold.py now emits ClassifyN.classifyProxy hashTable8 + classifyExact 8 - build_pist_matrices_250.py: added pistMatrixDim constant - SilverSight docs/AGENTS.md updated for renames - Research Stack AGENTS.md updated for toolchain references - Authentik deployed on neon-64gb (port 30001, working) - cross_domain_significance.py: statistical significance test (all phases <6σ with n=3) - setup_authentik.sh: fixed image, password, port, key sharing Build: 3307 jobs, 0 errors (lake build)
This commit is contained in:
parent
df60316925
commit
670e7617c3
19 changed files with 6097 additions and 215 deletions
189
AGENTS.md
189
AGENTS.md
|
|
@ -135,6 +135,10 @@ Target: `formal/SilverSight/HachimojiN8.lean` — provable by `native_decide` on
|
|||
| AVMIsa/TypeCheck.lean | Complete | 0 |
|
||||
| AVMIsa/TypeSafety.lean | Complete | 0 |
|
||||
| AVMIsa/Run.lean | Complete | 0 |
|
||||
| RRC/Emit.lean | Complete (Q16_16 ncDerived, alignment gate, 6 fixtures) | 0 |
|
||||
| RRC/Q16_16Manifold.lean | Complete (278 rows, Q16_16 manifold fields) | 0 |
|
||||
| RRC/ReceiptDensity.lean | Complete | 0 |
|
||||
| RRCLogogramProjection.lean | Complete | 0 |
|
||||
|
||||
† Layer 3 sorries are geometric conjectures (Kähler on ℂℙ⁷, Cartan connection,
|
||||
holonomy SO⁰(1,6)) deferred pending Mathlib infrastructure. Layer 1 (4
|
||||
|
|
@ -248,3 +252,188 @@ The VCN-FAMM-Sidon system is a Baker-style transcendental framework where:
|
|||
- Collapse functional Λ = ∑ wᵢⱼₖₗ log(aᵢ + aⱼ)
|
||||
- Scar energy Ω = ∑ scar.pressure
|
||||
- Theorem: |Λ| ≥ ε(X) ∨ Ω > 0 (rigidity OR scar emission)
|
||||
|
||||
## ncDerived Architecture (2026-06-29)
|
||||
|
||||
### Negative Control Witness
|
||||
```
|
||||
CSV axioms (ncObserved, residualRisk, scaleBandDeclared, weakAxesNames)
|
||||
│
|
||||
▼
|
||||
ncDerived = Q16_16.mul residualRisk scaleBandDeclared
|
||||
│
|
||||
├── ncDerived_mul (simp)
|
||||
├── ncDerived_independence_justification (CRT product principle link)
|
||||
└── Output: nc_derived in JSON (via .toFloat at I/O boundary)
|
||||
```
|
||||
|
||||
### Q16_16 Values (Fixture Corpus)
|
||||
| Row | residualRisk | scaleBandDeclared | ncDerived (raw) | ncDerived (float) |
|
||||
|-----|-------------|-------------------|-----------------|-------------------|
|
||||
| Clf/Ssrc | 47/100 | 2/5 | 12320 | 0.187988 |
|
||||
| Stamp_Code | 11/25 | 1/5 | 5766 | 0.087982 |
|
||||
| Weak control | 27/50 | 1/5 | 7077 | 0.107986 |
|
||||
|
||||
### FFS Physical Analog (Pending Validation)
|
||||
- arXiv:2602.17656 fractional Fermi sea occupancy ϑ(λ) ≤ 1/(2W+1)
|
||||
- Maps to ncDerived scale-band: scaleBandDeclared(W) = 1/(2W+1)
|
||||
- If validated: modulus 128 must change (no odd divisors; see `docs/math/arxiv_2602_17656_model_notes.md`)
|
||||
- Validation: KS test of ncDerived vs 1/(2W+1) quantization (Step 5, Milestone 7b)
|
||||
|
||||
### Files Ported (Research Stack → SilverSight)
|
||||
| File | Status | Notes |
|
||||
|------|--------|-------|
|
||||
| `formal/SilverSight/RRC/Emit.lean` | ✅ Q16_16 ncDerived | Float-free compute path |
|
||||
| `formal/SilverSight/RRC/Q16_16Manifold.lean` | ✅ 278 rows | Q16_16 manifold fields |
|
||||
| `python/build_manifold.py` | ✅ Q16_16 emission | `lean_q16_16()` helper |
|
||||
|
||||
## Beyond Rigorous — Anti-Smuggle Protocol
|
||||
|
||||
LLMs produce coherent-looking outputs that are subtly wrong in non-obvious ways. Every step must be assumed flawed until independently verified by a non-LLM mechanism. This section defines the 5-layer anti-smuggle protocol that enforces dual-sided proof structure across the entire SilverSight pipeline.
|
||||
|
||||
### Layer 0: Deterministic Reproducibility Chain
|
||||
|
||||
Every artifact must be independently reproducible from source. Non-determinism is the primary vector for smuggled assumptions [5].
|
||||
|
||||
```
|
||||
Source inputs (equations, QUBO params, seeds)
|
||||
→ SHA-256 hash
|
||||
→ Python shim (deterministic, seed-locked)
|
||||
→ Lean build (deterministic)
|
||||
→ Output JSON
|
||||
→ SHA-256 receipt (pinned in CITATION.cff)
|
||||
|
||||
Independent re-run on different hardware must produce identical hash chain.
|
||||
If not → non-determinism detected → assumption smuggling possible.
|
||||
```
|
||||
|
||||
**Enforcement:**
|
||||
- All Python shims must accept `--seed` parameter (default 0)
|
||||
- All random number generators must be seeded explicitly
|
||||
- Lean `#eval` outputs must be cached and hashed
|
||||
- Receipt JSON includes `content_sha256` field for all generated artifacts
|
||||
|
||||
### Layer 1: Multi-Model Cross-Validation
|
||||
|
||||
No single LLM output stream is trusted. Every formal claim must be independently generated by at least two models and checked for formal equivalence [2][12].
|
||||
|
||||
```
|
||||
LLM A → generates Lean theorem
|
||||
LLM B → generates Lean theorem (same problem, blind)
|
||||
↓
|
||||
Lean compiler verifies both independently
|
||||
↓
|
||||
Formal equivalence checker confirms both prove same statement
|
||||
↓
|
||||
If one passes and the other fails → BOTH are suspect
|
||||
```
|
||||
|
||||
**Enforcement:**
|
||||
- Critical theorems (Chentsov, FSR, ncDerived) must have dual provenance
|
||||
- Cross-validation receipt records both source models + Lean build hash
|
||||
- Surface-form similarity is NOT equivalence — Lean proofs can be cosmetically identical while logically different
|
||||
|
||||
### Layer 2: Adversarial Mutation Testing
|
||||
|
||||
The verifier itself must be tested. For every theorem, deliberately introduce errors and verify the system catches them [8].
|
||||
|
||||
```bash
|
||||
# Mutation suite for every theorem in the build surface
|
||||
mutations/
|
||||
Emit.lean/
|
||||
001_flip_ncDerived_mul.lean # expected: FAIL
|
||||
002_swap_residual_scale.lean # expected: FAIL
|
||||
003_zero_ncObserved.lean # expected: FAIL
|
||||
004_float_instead_of_q16.lean # expected: FAIL
|
||||
```
|
||||
|
||||
**Enforcement:**
|
||||
- `python3 scripts/qc-flag/` must pass on clean build AND fail on each mutation
|
||||
- Mutation coverage = `#mutations_that_cause_build_failure / #total_mutations`
|
||||
- If a mutation passes the build → the theorem is not specific enough
|
||||
|
||||
### Layer 3: Symbolic Oracle Grounding (CAS/SMT)
|
||||
|
||||
Lean proofs can be vacuously true or circular. Every numeric claim must be independently verified by a non-LLM symbolic engine [15][17].
|
||||
|
||||
```
|
||||
Lean computes:
|
||||
ncDerived = Q16_16.mul (Q16_16.ofRatio 47 100) (Q16_16.ofRatio 2 5)
|
||||
↓
|
||||
SymPy computes:
|
||||
ncDerived = Rational(47,100) * Rational(2,5) = 47/250 = 0.188
|
||||
↓
|
||||
Z3 checks:
|
||||
Assert(lean_output == sympy_output ± epsilon)
|
||||
```
|
||||
|
||||
**Enforcement:**
|
||||
- All `Q16_16.ofRatio` values must have a corresponding SymPy `Rational` verification
|
||||
- All `native_decide` blocks must have a Z3 SMT-LIB2 equivalent
|
||||
- CAS verification receipt stored alongside Lean receipt
|
||||
|
||||
### Layer 4: Dual-Sided Proof Structure (Domain-Specific)
|
||||
|
||||
For the Hachimoji/QUBO pipeline, the quantum encoding must be verified against a classical ground truth. This is the "clear-box middleware" architecture.
|
||||
|
||||
```
|
||||
Classical Path (ground truth):
|
||||
DNA sequence → Biopython → expected state vector → SHA-256
|
||||
|
||||
Quantum Path (execution):
|
||||
DNA sequence → Qiskit/PennyLane circuit → measured state → SHA-256
|
||||
|
||||
Assertion Layer (every gate):
|
||||
├── Unitarity preserved? (‖U†U - I‖ < ε)
|
||||
├── Probability distribution consistent with DNA input?
|
||||
└── State vector fidelity ≥ threshold?
|
||||
|
||||
Cross-Validation:
|
||||
├── Classical expected == Quantum measured (within noise)
|
||||
├── If mismatch → LogicViolation exception → data quarantined
|
||||
└── Log: every state transformation serialized to JSONL for audit
|
||||
```
|
||||
|
||||
**Enforcement:**
|
||||
- Every circuit gate has an assertion wrapper checking unitarity
|
||||
- Every measurement logs: `{timestamp, gate, input_state, output_state, fidelity}`
|
||||
- Third-party observer can reconstruct exact state at any time t from logs alone
|
||||
- Full audit trail = "traceable proof"
|
||||
|
||||
### Layer 5: Claim-State Ladder with Non-LLM Gate
|
||||
|
||||
Every claim in the system must occupy one of these states. Promotion requires non-LLM evidence at every rung.
|
||||
|
||||
| State | Requirement | LLM Role | Non-LLM Gate |
|
||||
|-------|------------|----------|-------------|
|
||||
| **BEAUTIFUL_PROVISIONAL** | Coherent hypothesis | Primary author | None |
|
||||
| **CALIBRATED_ENGINEERING_DELTA** | CAS/SMT verification | Provide code | SymPy/Z3 check |
|
||||
| **REVIEWED** | Multi-model cross-validation | Dual provenance | Lean compiler |
|
||||
| **VERIFIED** | Full reproducibility + adversarial tests | Audited | Mutation suite + hash chain |
|
||||
|
||||
**Rule:** No claim may promote from PROVISIONAL to DELTA without a non-LLM symbolic verification. No claim may promote to VERIFIED without a passing mutation suite.
|
||||
|
||||
### Entry Gate for Every Commit
|
||||
|
||||
Before any formal work is accepted:
|
||||
|
||||
```bash
|
||||
1. Deterministic check: python3 scripts/check_determinism.py # seed-locked, hash-verified
|
||||
2. Cross-validation: python3 scripts/cross_validate.py # dual LLM provenance check
|
||||
3. Mutation suite: python3 scripts/qc-flag/ # verify verifier catches errors
|
||||
4. CAS grounding: python3 scripts/verify_with_sympy.py # numeric ground truth
|
||||
5. Build gate: lake build SilverSight # Lean compiler
|
||||
```
|
||||
|
||||
All five must pass. If any fails, the commit is quarantined and flagged for human review.
|
||||
|
||||
### Summary Table
|
||||
|
||||
| Layer | What It Prevents | Tool | Current Status |
|
||||
|-------|-----------------|------|----------------|
|
||||
| 0: Determinism | Non-reproducible artifacts | SHA-256, seed-lock | ⚠️ Partial (corpus hashes exist) |
|
||||
| 1: Cross-validation | Single-LLM blind spots | Multi-model Lean | ❌ Missing |
|
||||
| 2: Mutation testing | Verifier that passes bad proofs | `scripts/qc-flag/` | ❌ Missing |
|
||||
| 3: CAS/SMT grounding | Vacuous/tautological proofs | SymPy, Z3 | ❌ Missing |
|
||||
| 4: Dual-sided proof | Smuggled quantum assumptions | PennyLane, Biopython | ⚠️ Partial (QUBO exists) |
|
||||
| 5: Claim-state ladder | Unvalidated promotion | Review protocol | ⚠️ Partial (AGENTS.md framework)
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ The source tree is large (~9,600 objects, ~1,300 Lean files). Most of it is expl
|
|||
|
||||
| Area | What matters |
|
||||
|------|--------------|
|
||||
| `0-Core-Formalism/lean/Semantics/Semantics/` | Proven Lean modules: FixedPoint, SidonSets, SieveLemmas, InteractionGraphSidon, BraidEigensolid, BraidSpherionBridge, AVMIsa.*, RRC.Emit/Corpus250, TransportQUBOBridge, ChentsovBridge. |
|
||||
| `0-Core-Formalism/lean/Semantics/Semantics/` | Proven Lean modules: FixedPoint, SidonSets, SieveLemmas, InteractionGraphSidon, BraidEigensolid, BraidSpherionBridge, AVMIsa.*, RRC.Emit/Q16_16Manifold, TransportQUBOBridge, ChentsovBridge. |
|
||||
| `4-Infrastructure/shim/` | Python shims: qaoa_adapter.py, qubo_highs.py, benchmark_finsler_qap.py, chaos_game_16d.py, sidon_generation_kernel.py, geometric_entropy_explorer.py, candidate_certification_bridge.py, stack_solidification_audit.py. |
|
||||
| `6-Documentation/docs/` | AGENTS.md strict rules, architecture specs, distilled notes, specs (DP-RRC, Virtio-Net compute, etc.). |
|
||||
| `5-Applications/text-to-cad/` | CAD/URDF harness and skills. |
|
||||
|
|
@ -143,7 +143,7 @@ The source tree is large (~9,600 objects, ~1,300 Lean files). Most of it is expl
|
|||
| `4-Infrastructure/shim/qaoa_adapter.py` | `qubo/qaoa_circuit.py` / `qubo/qubo_builder.py` | 🟠 ADAPT | Split: QUBO builder stays in QUBOLib; Finsler metric moves to MetricLib. |
|
||||
| `4-Infrastructure/shim/qubo_highs.py` | `qubo/classical_solver.py` | 🟠 ADAPT | HiGHS MIP bridge and TSP assignment relaxation. Merge into `classical_solver.py`. |
|
||||
| `4-Infrastructure/shim/pist_matrix_builder.py` | `python/` | 🟡 PORT | 250-equation PIST matrix builder; produces deterministic 8×8 strand adjacency. |
|
||||
| `4-Infrastructure/shim/build_corpus250.py` | `python/` | 🟠 ADAPT | Generates RRC corpus rows. Refactor to emit SilverSight `LexLib` inputs. |
|
||||
| `4-Infrastructure/shim/build_corpus250.py` | `python/build_manifold.py` | 🟠 ADAPT | Generates RRC manifold rows. Refactored from `build_corpus250.py`; emits `allFixtures`. |
|
||||
|
||||
---
|
||||
|
||||
|
|
@ -181,13 +181,16 @@ The source tree is large (~9,600 objects, ~1,300 Lean files). Most of it is expl
|
|||
|
||||
| Research-Stack | SilverSight Target | Status | Notes |
|
||||
|----------------|-------------------|--------|-------|
|
||||
| `Semantics.RRC.Emit.lean` | `RRCLib/` | 🟡 PORT | Alignment classifier; emits RRC verdicts. |
|
||||
| `Semantics.RRC.Corpus250.lean` | `RRCLib/` | 🟡 PORT | 250-equation raw-feature corpus. |
|
||||
| `Semantics.RRC.Emit.lean` (ncDerived) | `formal/SilverSight/RRC/Emit.lean` | ✅ PORTED | Q16_16 ncDerived with alignment gate; Float-free compute path (2026-06-29) |
|
||||
| `Semantics.RRC.Q16_16Manifold.lean` (Q16_16) | `formal/SilverSight/RRC/Q16_16Manifold.lean` | ✅ PORTED | 278 rows with Q16_16 manifold fields; regenerated by `python/build_manifold.py` |
|
||||
| `Semantics.AVMIsa.Emit.lean` | `RRCLib/` | 🟡 PORT | **Sole output boundary** for top-level receipt JSON. |
|
||||
| `Semantics.AVMIsa.Run.lean` | `Core/SilverSightCore.lean` | 🟠 ADAPT | AVM transition/run semantics; SilverSight Core defines its own `δ` transition function. |
|
||||
| `Semantics.RRC.ReceiptDensity.lean` | `RRCLib/` | 🟡 PORT | Receipt density scoring. |
|
||||
| `Semantics.RRCLogogramProjection.lean` | `RRCLib/` | 🟡 PORT | Logogram receipt types + admission gates. |
|
||||
| `4-Infrastructure/shim/validate_rrc_predictions.py` | `python/` | 🟠 ADAPT | Validation harness; refactor to SilverSight receipt format. |
|
||||
| `Semantics.RRC.ReceiptDensity.lean` | `formal/SilverSight/RRC/ReceiptDensity.lean` | ✅ PORTED | Receipt density scoring (already existed) |
|
||||
| `Semantics.RRCLogogramProjection.lean` | `formal/SilverSight/RRCLogogramProjection.lean` | ✅ PORTED | Logogram receipt types + admission gates |
|
||||
| `4-Infrastructure/shim/validate_rrc_predictions.py` | `python/` | 🟠 ADAPT | Validation harness; refactor to SilverSight receipt format |
|
||||
| — | `formal/SilverSight/FFS/Validation.lean` | 🔴 NEW | FFS validation protocol (KS test in Lean) — future SilverSight |
|
||||
| — | `formal/SilverSight/FFS/ManifoldWitness.lean` | 🔴 NEW | FFS equivalence theorem — future SilverSight |
|
||||
| — | `formal/SilverSight/FeasibleSet/Theorem.lean` | 🔴 NEW | Feasible-Set Relaxation Theorem (Set.sInter, IsMinimizer) — future SilverSight |
|
||||
| — | `formal/SilverSight/FeasibleSet/QUBORelaxation.lean` | 🔴 NEW | k-hot QUBO instantiation — future SilverSight |
|
||||
|
||||
---
|
||||
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@
|
|||
|
||||
| File | Module | Build Target | Status | Receipt Boundary | Research-Stack Source | Role |
|
||||
|------|--------|--------------|--------|------------------|----------------------|------|
|
||||
| `python/build_corpus250.py` | — | — | active | — | — | — |
|
||||
| `python/build_manifold.py` | — | — | active | — | — | — |
|
||||
| `python/build_pist_matrices_250.py` | — | — | active | — | — | — |
|
||||
| `python/chaos_game.py` | — | — | active | — | `4-Infrastructure/shim/chaos_game_16d.py` | 16D chaos-game basin sampler. |
|
||||
| `python/expr_tree.py` | — | — | active | — | — | — |
|
||||
|
|
|
|||
|
|
@ -89,8 +89,8 @@ python3 python/validate_rrc_predictions.py /tmp/rrc_fixture_emitted.json
|
|||
|
||||
## Out of scope (future work)
|
||||
|
||||
- Full 250-equation `Corpus250` (requires `PIST.Classify`, `PIST.Matrices250`, source JSON).
|
||||
- `python/build_corpus250.py` generator for the full corpus.
|
||||
- Full 250-equation `Q16_16Manifold` (requires `PIST.Classify`, `PIST.Matrices250`, source JSON).
|
||||
- `python/build_manifold.py` generator for the full corpus.
|
||||
- PIST classifier surface to populate `pistProxyLabel` / `pistExactLabel` from real matrices.
|
||||
- Concrete `WireFormat`/`LayoutBridge` instances for multi-field Core types such as `BraidState`.
|
||||
|
||||
|
|
|
|||
|
|
@ -264,7 +264,7 @@ r = {"sha256": "TBD", ...}
|
|||
- Fork loops without termination: NOT FOUND
|
||||
- Quine structures: NOT FOUND
|
||||
|
||||
## 4.2 Finding: Code Generation in build_corpus250.py [LOW]
|
||||
## 4.2 Finding: Code Generation in build_manifold.py [LOW]
|
||||
|
||||
**Description:** The script generates Lean source code from JSON data using string interpolation:
|
||||
```python
|
||||
|
|
@ -619,7 +619,7 @@ U&'\0041' -- Unicode escape
|
|||
| # | Finding | File | Exploitability |
|
||||
|---|---------|------|----------------|
|
||||
| L1 | WebGPU fingerprinting for tracking | dna_webgpu.js | Trivial |
|
||||
| L2 | Code generation uses string interpolation | build_corpus250.py | Low |
|
||||
| L2 | Code generation uses string interpolation | build_manifold.py | Low |
|
||||
| L3 | No self-replication bounds needed (none found) | N/A | N/A |
|
||||
| L4 | phi_corkscrew roundtrip may fail due to Q16_16 quantization | pist_braid_bridge.py | Moderate |
|
||||
| L5 | Formal proofs limited to 8 canonical states | HachimojiLUT.lean | Theoretical |
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ MATH_KINDS = {
|
|||
"fixedpoint": ["fix16","q16","fixedpoint","saturate","phasemodulus"],
|
||||
"routing": ["route","cfd","navier","burgers","canal","flow","pressure"],
|
||||
"avm": ["avmisa","avm","instruction","receipt","emit"],
|
||||
"rrc": ["rrc","corpus250","pist","classif","receipt"],
|
||||
"rrc": ["rrc","manifold","pist","classif","receipt"],
|
||||
}
|
||||
|
||||
def dominant_kind(text: str) -> str:
|
||||
|
|
|
|||
|
|
@ -211,8 +211,8 @@ Modules with 0 sorries that are imported by at least 3 other modules:
|
|||
- `braid_mutation_optimizer.py` → `ene`
|
||||
- `braid_search.py` → `ene`
|
||||
- `braid_vcn_encoder.py` → `ene`
|
||||
- `build_corpus250.py` → `arxiv`
|
||||
- `build_corpus250.py` → `ene`
|
||||
- `build_manifold.py` → `arxiv`
|
||||
- `build_manifold.py` → `ene`
|
||||
- `build_math_symbols_db.py` → `ene`
|
||||
- `build_pist_matrices_250.py` → `ene`
|
||||
- `burgers_0d_braid_exact.py` → `ene`
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import SilverSight.AVMIsa.Emit
|
||||
|
||||
def main : IO UInt32 := do
|
||||
IO.println SilverSight.AVMIsa.Emit.emitCorpus250
|
||||
IO.println SilverSight.AVMIsa.Emit.emitManifold
|
||||
return 0
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import SilverSight.AVMIsa.Run
|
|||
import SilverSight.ReceiptCore
|
||||
import SilverSight.RRCLogogramProjection
|
||||
import SilverSight.RRC.Emit
|
||||
import SilverSight.RRC.Corpus250
|
||||
import SilverSight.RRC.Q16_16Manifold
|
||||
|
||||
namespace SilverSight.AVMIsa.Emit
|
||||
|
||||
|
|
@ -226,23 +226,23 @@ def emitFixtureCorpus : String :=
|
|||
s!"\"summary\":{summaryStr}," ++
|
||||
s!"\"rows\":{classified.rowsJson}}"
|
||||
|
||||
open SilverSight.RRC.Corpus250 in
|
||||
/-- Stamp the full 250-equation corpus: run the alignment gate (RRC.Emit), then
|
||||
open SilverSight.RRC.Q16_16Manifold in
|
||||
/-- Stamp the full manifold: run the alignment gate (RRC.Emit), then
|
||||
mint an AVM-authority receipt for the whole bundle, and emit JSON.
|
||||
|
||||
The AVM canary suite must pass for the bundle receipt to be valid.
|
||||
Individual row receipts reflect alignment-gate pass/fail independently. -/
|
||||
def emitCorpus250 : String :=
|
||||
let classified := SilverSight.RRC.Emit.emitCorpus "rrc_emit_corpus250_v1" corpus250
|
||||
def emitManifold : String :=
|
||||
let classified := SilverSight.RRC.Emit.emitCorpus "rrc_emit_manifold_v1" allFixtures
|
||||
let avmOk := canaryReceipts.all (·.valid)
|
||||
let bundleReceipt := leanBuildReceipt "avm.rrc_corpus250.bundle" avmOk
|
||||
let bundleReceipt := leanBuildReceipt "avm.rrc.manifold.bundle" avmOk
|
||||
let total := classified.totalRows
|
||||
let passed := classified.candidateRows
|
||||
let held := total - passed
|
||||
let summaryStr :=
|
||||
s!"\{\"total\":{total},\"passed_alignment\":{passed},\"held\":{held}," ++
|
||||
s!"\"not_promoted\":{total}}"
|
||||
s!"\{\"schema\":\"avm_rrc_corpus250_v1\"," ++
|
||||
s!"\{\"schema\":\"avm_rrc_manifold_v1\"," ++
|
||||
s!"\"claim_boundary\":\"admissibility-and-routing-pass-only;not-promoted\"," ++
|
||||
s!"\"avm_canaries_passed\":{jsonBool avmOk}," ++
|
||||
s!"\"bundle_receipt_valid\":{jsonBool bundleReceipt.valid}," ++
|
||||
|
|
|
|||
|
|
@ -1,70 +1,21 @@
|
|||
-- SilverSight.PIST.Classify — minimal RRC shape classifier over 8×8 matrices
|
||||
-- SilverSight.PIST.Classify — backward-compat shim for 8×8 matrices.
|
||||
--
|
||||
-- Ports only the classifier surface needed for Corpus250:
|
||||
-- • 8×8 braid adjacency matrix type
|
||||
-- • spectral-radius → RGB color → shape-name gate
|
||||
-- • matrix-hash lookup table (proxy classifier)
|
||||
-- • spectral-radius exact classifier
|
||||
-- • deterministic blending rules for shared equation_ids
|
||||
-- All classification logic now lives in SilverSight.PIST.ClassifyN.
|
||||
-- This module re-exports the old API surface under the same names.
|
||||
--
|
||||
-- Photonic/Kubelka-Munk/Quandela extensions from Research Stack are omitted.
|
||||
-- Blending rules (§4) remain here since they are not yet generalized.
|
||||
|
||||
import SilverSight.PIST.Spectral
|
||||
import SilverSight.FixedPoint
|
||||
import SilverSight.PIST.ClassifyN
|
||||
|
||||
namespace SilverSight.PIST.Classify
|
||||
|
||||
open SilverSight.FixedPoint
|
||||
open SilverSight.FixedPoint.Q16_16
|
||||
open SilverSight.PIST.Spectral
|
||||
open SilverSight.PIST.ClassifyN
|
||||
|
||||
-- ─────────────────────────────────────────────────────────────────────────────
|
||||
-- §1 Matrix type
|
||||
-- ─────────────────────────────────────────────────────────────────────────────
|
||||
-- ── §1 Matrix type ────────────────────────────────────────────────────
|
||||
|
||||
abbrev Matrix8 : Type := Array (Array Int)
|
||||
|
||||
-- ─────────────────────────────────────────────────────────────────────────────
|
||||
-- §2 Spectral-radius thresholds
|
||||
-- ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
/-- High amplification threshold: λ ≥ 4.0 (Q16.16 raw). -/
|
||||
def oberthHighThreshold : Int := 262144
|
||||
|
||||
/-- Moderate amplification threshold: λ ≥ 2.0 (Q16.16 raw). -/
|
||||
def signalThreshold : Int := 131072
|
||||
|
||||
-- ─────────────────────────────────────────────────────────────────────────────
|
||||
-- §3 Spectral color gate
|
||||
-- ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
structure SpectralColor where
|
||||
red : Q16_16
|
||||
green : Q16_16
|
||||
blue : Q16_16
|
||||
deriving Repr
|
||||
|
||||
/-- Convert a raw spectral radius (Int) to an RGB SpectralColor. -/
|
||||
def spectralRadiusToColor (lam : Int) : SpectralColor :=
|
||||
let max_raw := oberthHighThreshold
|
||||
let r := if lam ≥ max_raw then one else zero
|
||||
let g := if lam ≥ signalThreshold then
|
||||
ofRawInt ((lam - signalThreshold) * 65536 / (max_raw - signalThreshold))
|
||||
else zero
|
||||
let b := if lam < signalThreshold then
|
||||
ofRawInt (lam * 65536 / signalThreshold)
|
||||
else zero
|
||||
{ red := r, green := g, blue := b }
|
||||
|
||||
/-- Extract the shape-name string from a SpectralColor. -/
|
||||
def colorToShapeName (c : SpectralColor) : Option String :=
|
||||
if c.red.toInt > 0 then some "CognitiveLoadField"
|
||||
else if c.green.toInt > 0 then some "SignalShapedRouteCompiler"
|
||||
else none
|
||||
|
||||
-- ─────────────────────────────────────────────────────────────────────────────
|
||||
-- §4 Blending rules for shared equation_ids
|
||||
-- ─────────────────────────────────────────────────────────────────────────────
|
||||
-- ── §2 Blending rules (not yet generalized) ───────────────────────────
|
||||
|
||||
inductive BlendType where
|
||||
| additive
|
||||
|
|
@ -72,8 +23,7 @@ inductive BlendType where
|
|||
| vortex
|
||||
deriving Repr
|
||||
|
||||
def blend_additive (lam1 lam2 : Int) : Int :=
|
||||
max lam1 lam2
|
||||
def blend_additive (lam1 lam2 : Int) : Int := max lam1 lam2
|
||||
|
||||
def blend_rms (lam1 lam2 : Int) : Int :=
|
||||
Int.ofNat (Nat.sqrt (((lam1 * lam1 + lam2 * lam2) / 2).toNat))
|
||||
|
|
@ -81,7 +31,6 @@ def blend_rms (lam1 lam2 : Int) : Int :=
|
|||
def blend_vortex (lam1 lam2 : Int) : Int :=
|
||||
(lam1 * lam2) / (lam1 + lam2 + 1)
|
||||
|
||||
/-- Blend a list of spectral radii under a given topology. -/
|
||||
def blendRadii (blendType : BlendType) (lams : List Int) : Int :=
|
||||
match lams with
|
||||
| [] => 0
|
||||
|
|
@ -93,137 +42,12 @@ def blendRadii (blendType : BlendType) (lams : List Int) : Int :=
|
|||
| .vortex => (acc * lam2) / (acc + lam2 + 1)
|
||||
) lam
|
||||
|
||||
-- ─────────────────────────────────────────────────────────────────────────────
|
||||
-- §5 Classifier surface
|
||||
-- ─────────────────────────────────────────────────────────────────────────────
|
||||
-- ── §3 Classifier surface (delegates to ClassifyN) ────────────────────
|
||||
|
||||
def hashMatrix (m : Matrix8) : Int :=
|
||||
let rec loop (i j : Nat) (pow_5 : Int) (acc : Int) : Int :=
|
||||
if i ≥ 8 then acc
|
||||
else if j ≥ 8 then loop (i + 1) 0 pow_5 acc
|
||||
else
|
||||
let val := m.getD i #[] |>.getD j 0
|
||||
loop i (j + 1) (pow_5 * 5) (acc + val * pow_5)
|
||||
loop 0 0 1 0
|
||||
|
||||
/-- Advisory shape proxy via matrix-hash lookup. -/
|
||||
def classifyProxy (m : Matrix8) : Option String :=
|
||||
match hashMatrix m with
|
||||
| 0 => some "CognitiveLoadField"
|
||||
| 25 => some "CognitiveLoadField"
|
||||
| 125 => some "CognitiveLoadField"
|
||||
| 625 => some "CognitiveLoadField"
|
||||
| 78125 => some "SignalShapedRouteCompiler"
|
||||
| 390625 => some "CognitiveLoadField"
|
||||
| 1953125 => some "SignalShapedRouteCompiler"
|
||||
| 9765625 => some "ProjectableGeometryTopology"
|
||||
| 48828125 => some "ProjectableGeometryTopology"
|
||||
| 244140625 => some "SignalShapedRouteCompiler"
|
||||
| 30517578125 => some "ProjectableGeometryTopology"
|
||||
| 152587890625 => some "ProjectableGeometryTopology"
|
||||
| 152587968750 => some "ProjectableGeometryTopology"
|
||||
| 3814697265625 => some "SignalShapedRouteCompiler"
|
||||
| 19073496093750 => some "CognitiveLoadField"
|
||||
| 476837158203150 => some "CadForceProbeReceipt"
|
||||
| 2384185791015625 => some "ProjectableGeometryTopology"
|
||||
| 11920928955078125 => some "ProjectableGeometryTopology"
|
||||
| 59604644775390626 => some "ProjectableGeometryTopology"
|
||||
| 59604644824218750 => some "CognitiveLoadField"
|
||||
| 298023223876953125 => some "ProjectableGeometryTopology"
|
||||
| 1490116119384765625 => some "ProjectableGeometryTopology"
|
||||
| 1490211486816406250 => some "ProjectableGeometryTopology"
|
||||
| 1502037048339843750 => some "CognitiveLoadField"
|
||||
| 7450580596923828125 => some "ProjectableGeometryTopology"
|
||||
| 7510185241699218875 => some "ProjectableGeometryTopology"
|
||||
| 37252902984619140625 => some "HoldForUnlawfulOrUnderspecifiedShape"
|
||||
| 186264514923095703125 => some "ProjectableGeometryTopology"
|
||||
| 931322574615478515625 => some "ProjectableGeometryTopology"
|
||||
| 4656612873077392578125 => some "CognitiveLoadField"
|
||||
| 4656612873077441406250 => some "CognitiveLoadField"
|
||||
| 23283064365386962890625 => some "ProjectableGeometryTopology"
|
||||
| 23283064365386962890626 => some "ProjectableGeometryTopology"
|
||||
| 23283064365386962890630 => some "CognitiveLoadField"
|
||||
| 23283064365386962890750 => some "SignalShapedRouteCompiler"
|
||||
| 23320317268371582031250 => some "SignalShapedRouteCompiler"
|
||||
| 116415321826934814453125 => some "SignalShapedRouteCompiler"
|
||||
| 116415321826965576171875 => some "SignalShapedRouteCompiler"
|
||||
| 582076609135443115234375 => some "CognitiveLoadField"
|
||||
| 582076621055603027343750 => some "CognitiveLoadField"
|
||||
| 2910383343696594482421875 => some "CognitiveLoadField"
|
||||
| 2910420298576354980468750 => some "CognitiveLoadField"
|
||||
| 14575198292732238769531250 => some "SignalShapedRouteCompiler"
|
||||
| 17462298274040222167968750 => some "SignalShapedRouteCompiler"
|
||||
| 72759576141929626464843750 => some "CognitiveLoadField"
|
||||
| 363797917962074279785156250 => some "CognitiveLoadField"
|
||||
| 9094947017729282379150390625 => some "CognitiveLoadField"
|
||||
| 9094947017729759216308593750 => some "ProjectableGeometryTopology"
|
||||
| 9094947203993797302246093750 => some "SignalShapedRouteCompiler"
|
||||
| 45474735088646411895751953125 => some "ProjectableGeometryTopology"
|
||||
| 45474735088646412048339846876 => some "CognitiveLoadField"
|
||||
| 45547494664788246155029687500 => some "CognitiveLoadField"
|
||||
| 227373675443232059478759765625 => some "SignalShapedRouteCompiler"
|
||||
| 227373675443232060241699609375 => some "ProjectableGeometryTopology"
|
||||
| 227373675443232063293457031250 => some "ProjectableGeometryTopology"
|
||||
| 227373675443234443664550781250 => some "CognitiveLoadField"
|
||||
| 227446435019376277923828125000 => some "CognitiveLoadField"
|
||||
| 5684341886080801486968994140625 => some "ProjectableGeometryTopology"
|
||||
| 5684414668940007686615234375000 => some "CognitiveLoadField"
|
||||
| 28421709430404007911682128906250 => some "CognitiveLoadField"
|
||||
| 28421709430405498027801513671875 => some "CognitiveLoadField"
|
||||
| 56843418860808014869689941406250 => some "CognitiveLoadField"
|
||||
| 56843491620384156703949218750000 => some "CognitiveLoadField"
|
||||
| 142108547152020037174226074218750 => some "ProjectableGeometryTopology"
|
||||
| 142108547152021527767181396484375 => some "CognitiveLoadField"
|
||||
| 170530256582424044609069824218750 => some "CognitiveLoadField"
|
||||
| 710542735760100185871124267578125 => some "ProjectableGeometryTopology"
|
||||
| 3552713678800500929355621337890750 => some "CognitiveLoadField"
|
||||
| 3552713678800500929355621337893750 => some "HoldForUnlawfulOrUnderspecifiedShape"
|
||||
| 3694822225952520966529846191409375 => some "HoldForUnlawfulOrUnderspecifiedShape"
|
||||
| 17763568394002504646778106689453125 => some "ProjectableGeometryTopology"
|
||||
| 17763568394002504646778106689468750 => some "ProjectableGeometryTopology"
|
||||
| 17763568394002504646778106933593750 => some "ProjectableGeometryTopology"
|
||||
| 17763568394002504646778107910156250 => some "ProjectableGeometryTopology"
|
||||
| 17905676941154524683952331542971875 => some "HoldForUnlawfulOrUnderspecifiedShape"
|
||||
| 17905677013914100825786590820312500 => some "SignalShapedRouteCompiler"
|
||||
| 88817841970012523233890533447265625 => some "ProjectableGeometryTopology"
|
||||
| 88817841970594599845409393554687500 => some "SignalShapedRouteCompiler"
|
||||
| 88817842333810441195964813232421875 => some "SignalShapedRouteCompiler"
|
||||
| 88959950517164543271064758300784375 => some "HoldForUnlawfulOrUnderspecifiedShape"
|
||||
| 444089209850062616169452667236328125 => some "CognitiveLoadField"
|
||||
| 444231318397214636206626892089846875 => some "HoldForUnlawfulOrUnderspecifiedShape"
|
||||
| 2220446049250313080847263336181640625 => some "ProjectableGeometryTopology"
|
||||
| 2220446049250313080849647521972656250 => some "SignalShapedRouteCompiler"
|
||||
| 2220588157797465100884437561035159375 => some "HoldForUnlawfulOrUnderspecifiedShape"
|
||||
| 11102372354798717424273490905761721875 => some "HoldForUnlawfulOrUnderspecifiedShape"
|
||||
| 55511151231257827021183967590341796875 => some "CognitiveLoadField"
|
||||
| 55511293339804979041218757629394534375 => some "HoldForUnlawfulOrUnderspecifiedShape"
|
||||
| 277555756156289135105907917022705078125 => some "CognitiveLoadField"
|
||||
| 277555898264836287125945091247558596875 => some "HoldForUnlawfulOrUnderspecifiedShape"
|
||||
| 1387778780781445675529539585113525391250 => some "HoldForUnlawfulOrUnderspecifiedShape"
|
||||
| 1387778780781445680186152458190917968750 => some "CognitiveLoadField"
|
||||
| 1387778780781446257606160640716552734375 => some "CognitiveLoadField"
|
||||
| 1387778780783264664933085441589355468750 => some "CognitiveLoadField"
|
||||
| 1387779491324181435629725456237792968750 => some "CognitiveLoadField"
|
||||
| 6938893903907228377647697925567628906250 => some "SignalShapedRouteCompiler"
|
||||
| 173472347597680709441192448139190673828125 => some "ProjectableGeometryTopology"
|
||||
| 173472347597680709441229701042175292968750 => some "ProjectableGeometryTopology"
|
||||
| 867361737988403547205963742733001708984375 => some "CognitiveLoadField"
|
||||
| 867361737988405366195403039455413818359375 => some "CognitiveLoadField"
|
||||
| 867361738698946282966062426567077636718750 => some "CognitiveLoadField"
|
||||
| 4336808689947702077915892004966735839843750 => some "SignalShapedRouteCompiler"
|
||||
| 4337086245698174025164917111396789550781250 => some "ProjectableGeometryTopology"
|
||||
| 4337086245698174025164917113780975341796875 => some "ProjectableGeometryTopology"
|
||||
| 8673617380594578207819722592830657958984375 => some "ProjectableGeometryTopology"
|
||||
| 21684321005466244969284161925315856933593750 => some "SignalShapedRouteCompiler"
|
||||
| 108420217248550443400745280086994171142578125 => some "ProjectableGeometryTopology"
|
||||
| 108420217248550443400745280086994201660156250 => some "CognitiveLoadField"
|
||||
| 108420217248550443400745280098915100097656250 => some "CognitiveLoadField"
|
||||
| _ => none
|
||||
ClassifyN.classifyProxy ClassifyN.hashTable8 m
|
||||
|
||||
/-- Attested shape exact match via spectral-radius color gate. -/
|
||||
def classifyExact (m : Matrix8) : Option String :=
|
||||
let profile := computeSpectral m
|
||||
let lam := profile.adjacency_eigenvalue_max.toInt
|
||||
colorToShapeName (spectralRadiusToColor lam)
|
||||
ClassifyN.classifyExact 8 m
|
||||
|
||||
end SilverSight.PIST.Classify
|
||||
|
|
|
|||
224
formal/SilverSight/PIST/ClassifyN.lean
Normal file
224
formal/SilverSight/PIST/ClassifyN.lean
Normal file
|
|
@ -0,0 +1,224 @@
|
|||
/-
|
||||
Copyright (c) 2026 SilverSight Contributors. All rights reserved.
|
||||
Released under Apache 2.0 license.
|
||||
|
||||
Generic n-dimensional RRC shape classifier.
|
||||
Unlike Classify.lean (which fixes n=8), this version is parameterized
|
||||
by matrix dimension (n : Nat).
|
||||
|
||||
The proxy classifier uses an externally-provided hash table, since
|
||||
matrix hashes are dimension-dependent.
|
||||
-/
|
||||
|
||||
import SilverSight.FixedPoint
|
||||
import SilverSight.PIST.MatrixN
|
||||
import SilverSight.PIST.SpectralN
|
||||
|
||||
namespace SilverSight.PIST.ClassifyN
|
||||
|
||||
open SilverSight.FixedPoint
|
||||
open SilverSight.FixedPoint.Q16_16
|
||||
open SilverSight.PIST.MatrixN
|
||||
open SilverSight.PIST.SpectralN
|
||||
|
||||
-- ── Spectral-radius thresholds (dimension-independent) ───────────────────
|
||||
|
||||
/-- High amplification: λ ≥ 4.0 (Q16.16 raw 262144). -/
|
||||
def oberthHighThreshold : Int := 262144
|
||||
|
||||
/-- Moderate amplification: λ ≥ 2.0 (Q16.16 raw 131072). -/
|
||||
def signalThreshold : Int := 131072
|
||||
|
||||
-- ── Spectral color gate (dimension-independent) ─────────────────────────
|
||||
|
||||
structure SpectralColor where
|
||||
red : Q16_16
|
||||
green : Q16_16
|
||||
blue : Q16_16
|
||||
deriving Repr
|
||||
|
||||
def spectralRadiusToColor (lam : Int) : SpectralColor :=
|
||||
let max_raw := oberthHighThreshold
|
||||
let r := if lam ≥ max_raw then one else zero
|
||||
let g := if lam ≥ signalThreshold then
|
||||
ofRawInt ((lam - signalThreshold) * 65536 / (max_raw - signalThreshold))
|
||||
else zero
|
||||
let b := if lam < signalThreshold then
|
||||
ofRawInt (lam * 65536 / signalThreshold)
|
||||
else zero
|
||||
{ red := r, green := g, blue := b }
|
||||
|
||||
def colorToShapeName (c : SpectralColor) : Option String :=
|
||||
if c.red.toInt > 0 then some "CognitiveLoadField"
|
||||
else if c.green.toInt > 0 then some "SignalShapedRouteCompiler"
|
||||
else none
|
||||
|
||||
-- ── Blending rules (dimension-independent) ──────────────────────────────
|
||||
|
||||
inductive BlendType where
|
||||
| additive
|
||||
| rms
|
||||
| vortex
|
||||
deriving Repr
|
||||
|
||||
def blend_additive (lam1 lam2 : Int) : Int := max lam1 lam2
|
||||
|
||||
def blend_rms (lam1 lam2 : Int) : Int :=
|
||||
Int.ofNat (Nat.sqrt (((lam1 * lam1 + lam2 * lam2) / 2).toNat))
|
||||
|
||||
def blend_vortex (lam1 lam2 : Int) : Int :=
|
||||
(lam1 * lam2) / (lam1 + lam2 + 1)
|
||||
|
||||
def blendRadii (blendType : BlendType) (lams : List Int) : Int :=
|
||||
match lams with
|
||||
| [] => 0
|
||||
| lam :: rest =>
|
||||
rest.foldl (fun acc lam2 =>
|
||||
match blendType with
|
||||
| .additive => if acc ≥ lam2 then acc else lam2
|
||||
| .rms => isqrt ((acc * acc + lam2 * lam2) / 2)
|
||||
| .vortex => (acc * lam2) / (acc + lam2 + 1)
|
||||
) lam
|
||||
|
||||
-- ── Generic hash for n×n matrices ───────────────────────────────────────
|
||||
|
||||
def hashMatrix (n : Nat) (mat : Array (Array Int)) : Int :=
|
||||
let rec loop (i j : Nat) (pow_5 : Int) (acc : Int) : Int :=
|
||||
if i ≥ n then acc
|
||||
else if j ≥ n then loop (i + 1) 0 pow_5 acc
|
||||
else
|
||||
let val := mat.getD i #[] |>.getD j 0
|
||||
loop i (j + 1) (pow_5 * 5) (acc + val * pow_5)
|
||||
loop 0 0 1 0
|
||||
|
||||
-- ── Proxy classifier (external hash table) ──────────────────────────────
|
||||
|
||||
/-- Proxy classify using an externally-provided hash-to-shape table.
|
||||
The table must be generated per-dimension (the Python rebuild script
|
||||
handles this for n=8 via rrc_pist_predictions_250_v1.json). -/
|
||||
def classifyProxy (hashTable : Int → Option String) (mat : Array (Array Int)) : Option String :=
|
||||
hashTable (hashMatrix 8 mat)
|
||||
|
||||
/- Exact classifier via spectral radius. Dimension-independent. -/
|
||||
def classifyExact (n : Nat) (mat : Array (Array Int)) : Option String :=
|
||||
let profile := computeSpectral n mat
|
||||
let lam := profile.adjacency_eigenvalue_max.toInt
|
||||
colorToShapeName (spectralRadiusToColor lam)
|
||||
|
||||
/-- Canonical 8×8 hash-to-shape table.
|
||||
Generated from the hardcoded lookup table in SilverSight.PIST.Classify.
|
||||
Maps `hashMatrix 8` values to PIST shape names. -/
|
||||
def hashTable8 : Int → Option String :=
|
||||
fun h => match h with
|
||||
| 0 => some "CognitiveLoadField"
|
||||
| 25 => some "CognitiveLoadField"
|
||||
| 125 => some "CognitiveLoadField"
|
||||
| 625 => some "CognitiveLoadField"
|
||||
| 78125 => some "SignalShapedRouteCompiler"
|
||||
| 390625 => some "CognitiveLoadField"
|
||||
| 1953125 => some "SignalShapedRouteCompiler"
|
||||
| 9765625 => some "ProjectableGeometryTopology"
|
||||
| 48828125 => some "ProjectableGeometryTopology"
|
||||
| 244140625 => some "SignalShapedRouteCompiler"
|
||||
| 30517578125 => some "ProjectableGeometryTopology"
|
||||
| 152587890625 => some "ProjectableGeometryTopology"
|
||||
| 152587968750 => some "ProjectableGeometryTopology"
|
||||
| 3814697265625 => some "SignalShapedRouteCompiler"
|
||||
| 19073496093750 => some "CognitiveLoadField"
|
||||
| 476837158203150 => some "CadForceProbeReceipt"
|
||||
| 2384185791015625 => some "ProjectableGeometryTopology"
|
||||
| 11920928955078125 => some "ProjectableGeometryTopology"
|
||||
| 59604644775390626 => some "ProjectableGeometryTopology"
|
||||
| 59604644824218750 => some "CognitiveLoadField"
|
||||
| 298023223876953125 => some "ProjectableGeometryTopology"
|
||||
| 1490116119384765625 => some "ProjectableGeometryTopology"
|
||||
| 1490211486816406250 => some "ProjectableGeometryTopology"
|
||||
| 1502037048339843750 => some "CognitiveLoadField"
|
||||
| 7450580596923828125 => some "ProjectableGeometryTopology"
|
||||
| 7510185241699218875 => some "ProjectableGeometryTopology"
|
||||
| 37252902984619140625 => some "HoldForUnlawfulOrUnderspecifiedShape"
|
||||
| 186264514923095703125 => some "ProjectableGeometryTopology"
|
||||
| 931322574615478515625 => some "ProjectableGeometryTopology"
|
||||
| 4656612873077392578125 => some "CognitiveLoadField"
|
||||
| 4656612873077441406250 => some "CognitiveLoadField"
|
||||
| 23283064365386962890625 => some "ProjectableGeometryTopology"
|
||||
| 23283064365386962890626 => some "ProjectableGeometryTopology"
|
||||
| 23283064365386962890630 => some "CognitiveLoadField"
|
||||
| 23283064365386962890750 => some "SignalShapedRouteCompiler"
|
||||
| 23320317268371582031250 => some "SignalShapedRouteCompiler"
|
||||
| 116415321826934814453125 => some "SignalShapedRouteCompiler"
|
||||
| 116415321826965576171875 => some "SignalShapedRouteCompiler"
|
||||
| 582076609135443115234375 => some "CognitiveLoadField"
|
||||
| 582076621055603027343750 => some "CognitiveLoadField"
|
||||
| 2910383343696594482421875 => some "CognitiveLoadField"
|
||||
| 2910420298576354980468750 => some "CognitiveLoadField"
|
||||
| 14575198292732238769531250 => some "SignalShapedRouteCompiler"
|
||||
| 17462298274040222167968750 => some "SignalShapedRouteCompiler"
|
||||
| 72759576141929626464843750 => some "CognitiveLoadField"
|
||||
| 363797917962074279785156250 => some "CognitiveLoadField"
|
||||
| 9094947017729282379150390625 => some "CognitiveLoadField"
|
||||
| 9094947017729759216308593750 => some "ProjectableGeometryTopology"
|
||||
| 9094947203993797302246093750 => some "SignalShapedRouteCompiler"
|
||||
| 45474735088646411895751953125 => some "ProjectableGeometryTopology"
|
||||
| 45474735088646412048339846876 => some "CognitiveLoadField"
|
||||
| 45547494664788246155029687500 => some "CognitiveLoadField"
|
||||
| 227373675443232059478759765625 => some "SignalShapedRouteCompiler"
|
||||
| 227373675443232060241699609375 => some "ProjectableGeometryTopology"
|
||||
| 227373675443232063293457031250 => some "ProjectableGeometryTopology"
|
||||
| 227373675443234443664550781250 => some "CognitiveLoadField"
|
||||
| 227446435019376277923828125000 => some "CognitiveLoadField"
|
||||
| 5684341886080801486968994140625 => some "ProjectableGeometryTopology"
|
||||
| 5684414668940007686615234375000 => some "CognitiveLoadField"
|
||||
| 28421709430404007911682128906250 => some "CognitiveLoadField"
|
||||
| 28421709430405498027801513671875 => some "CognitiveLoadField"
|
||||
| 56843418860808014869689941406250 => some "CognitiveLoadField"
|
||||
| 56843491620384156703949218750000 => some "CognitiveLoadField"
|
||||
| 142108547152020037174226074218750 => some "ProjectableGeometryTopology"
|
||||
| 142108547152021527767181396484375 => some "CognitiveLoadField"
|
||||
| 170530256582424044609069824218750 => some "CognitiveLoadField"
|
||||
| 710542735760100185871124267578125 => some "ProjectableGeometryTopology"
|
||||
| 3552713678800500929355621337890750 => some "CognitiveLoadField"
|
||||
| 3552713678800500929355621337893750 => some "HoldForUnlawfulOrUnderspecifiedShape"
|
||||
| 3694822225952520966529846191409375 => some "HoldForUnlawfulOrUnderspecifiedShape"
|
||||
| 17763568394002504646778106689453125 => some "ProjectableGeometryTopology"
|
||||
| 17763568394002504646778106689468750 => some "ProjectableGeometryTopology"
|
||||
| 17763568394002504646778106933593750 => some "ProjectableGeometryTopology"
|
||||
| 17763568394002504646778107910156250 => some "ProjectableGeometryTopology"
|
||||
| 17905676941154524683952331542971875 => some "HoldForUnlawfulOrUnderspecifiedShape"
|
||||
| 17905677013914100825786590820312500 => some "SignalShapedRouteCompiler"
|
||||
| 88817841970012523233890533447265625 => some "ProjectableGeometryTopology"
|
||||
| 88817841970594599845409393554687500 => some "SignalShapedRouteCompiler"
|
||||
| 88817842333810441195964813232421875 => some "SignalShapedRouteCompiler"
|
||||
| 88959950517164543271064758300784375 => some "HoldForUnlawfulOrUnderspecifiedShape"
|
||||
| 444089209850062616169452667236328125 => some "CognitiveLoadField"
|
||||
| 444231318397214636206626892089846875 => some "HoldForUnlawfulOrUnderspecifiedShape"
|
||||
| 2220446049250313080847263336181640625 => some "ProjectableGeometryTopology"
|
||||
| 2220446049250313080849647521972656250 => some "SignalShapedRouteCompiler"
|
||||
| 2220588157797465100884437561035159375 => some "HoldForUnlawfulOrUnderspecifiedShape"
|
||||
| 11102372354798717424273490905761721875 => some "HoldForUnlawfulOrUnderspecifiedShape"
|
||||
| 55511151231257827021183967590341796875 => some "CognitiveLoadField"
|
||||
| 55511293339804979041218757629394534375 => some "HoldForUnlawfulOrUnderspecifiedShape"
|
||||
| 277555756156289135105907917022705078125 => some "CognitiveLoadField"
|
||||
| 277555898264836287125945091247558596875 => some "HoldForUnlawfulOrUnderspecifiedShape"
|
||||
| 1387778780781445675529539585113525391250 => some "HoldForUnlawfulOrUnderspecifiedShape"
|
||||
| 1387778780781445680186152458190917968750 => some "CognitiveLoadField"
|
||||
| 1387778780781446257606160640716552734375 => some "CognitiveLoadField"
|
||||
| 1387778780783264664933085441589355468750 => some "CognitiveLoadField"
|
||||
| 1387779491324181435629725456237792968750 => some "CognitiveLoadField"
|
||||
| 6938893903907228377647697925567628906250 => some "SignalShapedRouteCompiler"
|
||||
| 173472347597680709441192448139190673828125 => some "ProjectableGeometryTopology"
|
||||
| 173472347597680709441229701042175292968750 => some "ProjectableGeometryTopology"
|
||||
| 867361737988403547205963742733001708984375 => some "CognitiveLoadField"
|
||||
| 867361737988405366195403039455413818359375 => some "CognitiveLoadField"
|
||||
| 867361738698946282966062426567077636718750 => some "CognitiveLoadField"
|
||||
| 4336808689947702077915892004966735839843750 => some "SignalShapedRouteCompiler"
|
||||
| 4337086245698174025164917111396789550781250 => some "ProjectableGeometryTopology"
|
||||
| 4337086245698174025164917113780975341796875 => some "ProjectableGeometryTopology"
|
||||
| 8673617380594578207819722592830657958984375 => some "ProjectableGeometryTopology"
|
||||
| 21684321005466244969284161925315856933593750 => some "SignalShapedRouteCompiler"
|
||||
| 108420217248550443400745280086994171142578125 => some "ProjectableGeometryTopology"
|
||||
| 108420217248550443400745280086994201660156250 => some "CognitiveLoadField"
|
||||
| 108420217248550443400745280098915100097656250 => some "CognitiveLoadField"
|
||||
| _ => none
|
||||
|
||||
end SilverSight.PIST.ClassifyN
|
||||
5040
formal/SilverSight/RRC/Q16_16Manifold.lean
Normal file
5040
formal/SilverSight/RRC/Q16_16Manifold.lean
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -19,6 +19,7 @@ lean_lib «SilverSightFormal» where
|
|||
srcDir := "formal"
|
||||
roots := #[
|
||||
`CoreFormalism.FixedPoint,
|
||||
`SilverSight.FixedPointBridge,
|
||||
`CoreFormalism.Tactics,
|
||||
`CoreFormalism.Q16_16Numerics,
|
||||
`CoreFormalism.DynamicCanal,
|
||||
|
|
@ -27,6 +28,7 @@ lean_lib «SilverSightFormal» where
|
|||
`CoreFormalism.BraidStrand,
|
||||
`CoreFormalism.BraidCross,
|
||||
`CoreFormalism.BraidField,
|
||||
`CoreFormalism.BraidStateN,
|
||||
`CoreFormalism.SidonSets,
|
||||
`CoreFormalism.SieveLemmas,
|
||||
`CoreFormalism.InteractionGraphSidon,
|
||||
|
|
@ -59,8 +61,12 @@ lean_lib «SilverSightRRC» where
|
|||
`SilverSight.PhiConsistency,
|
||||
`SilverSight.PhiPipelineReceipt,
|
||||
`SilverSight.PIST.Spectral,
|
||||
`SilverSight.PIST.SpectralN,
|
||||
`SilverSight.PIST.MatrixN,
|
||||
`SilverSight.PIST.FisherRigidity,
|
||||
`SilverSight.PIST.FisherRigidityN,
|
||||
`SilverSight.PIST.Classify,
|
||||
`SilverSight.PIST.ClassifyN,
|
||||
`SilverSight.PIST.Matrices250,
|
||||
`SilverSight.PIST.UnifiedCovariant,
|
||||
`SilverSight.PIST.CartanConnection,
|
||||
|
|
@ -74,7 +80,7 @@ lean_lib «SilverSightRRC» where
|
|||
`SilverSight.RRC.ReceiptDensity,
|
||||
`SilverSight.RRC.PolyFactorIdentity,
|
||||
`SilverSight.RRC.EntropyCandidates,
|
||||
`SilverSight.RRC.Corpus250,
|
||||
`SilverSight.RRC.Q16_16Manifold,
|
||||
`SilverSight.AVMIsa.Types,
|
||||
`SilverSight.AVMIsa.Value,
|
||||
`SilverSight.AVMIsa.Instr,
|
||||
|
|
@ -87,6 +93,9 @@ lean_lib «SilverSightRRC» where
|
|||
`SilverSight.AdjugateMatrix,
|
||||
`SilverSight.ColdReviewer,
|
||||
`SilverSight.Rollup,
|
||||
`SilverSight.FeasibleSet.Theorem,
|
||||
`SilverSight.FeasibleSet.QUBORelaxation,
|
||||
`SilverSight.CollectiveIntelligence.CostTransparency,
|
||||
`RRCLib.RRCEmit
|
||||
]
|
||||
|
||||
|
|
|
|||
258
python/build_manifold.py
Normal file
258
python/build_manifold.py
Normal file
|
|
@ -0,0 +1,258 @@
|
|||
#!/usr/bin/env python3
|
||||
# /// script
|
||||
# requires-python = ">=3.10"
|
||||
# dependencies = []
|
||||
# ///
|
||||
"""
|
||||
Build formal/SilverSight/RRC/Q16_16Manifold.lean from
|
||||
archive/experimental-shim-probes/rrc_equation_classifier_receipt.json,
|
||||
merged with 8×8 braid adjacency matrices from
|
||||
shared-data/rrc_pist_predictions_250_v1.json.
|
||||
|
||||
Python's role:
|
||||
- read raw features from the classifier receipt
|
||||
- merge matrices by invariant_receipt.object_id
|
||||
- emit deterministic Lean source
|
||||
|
||||
Lean's role:
|
||||
- PIST classification (classifyProxy/classifyExact) from the matrix
|
||||
- alignment gate via determineAlignment
|
||||
- receipt stamping and all admissibility/promotion decisions
|
||||
|
||||
Usage:
|
||||
python3 python/build_manifold.py
|
||||
python3 python/build_manifold.py \
|
||||
--receipt /path/to/rrc_equation_classifier_receipt.json \
|
||||
--predictions /path/to/rrc_pist_predictions_250_v1.json \
|
||||
--out-lean formal/SilverSight/RRC/Q16_16Manifold.lean
|
||||
"""
|
||||
from __future__ import annotations
|
||||
import argparse, hashlib, json, sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
# classifier JSON shape name → SilverSight.RRCLogogramProjection.RRCShape constructor
|
||||
SHAPE_MAP = {
|
||||
"CognitiveLoadField": ".cognitiveLoadField",
|
||||
"SignalShapedRouteCompiler": ".signalShapedRouteCompiler",
|
||||
"ProjectableGeometryTopology": ".projectableGeometryTopology",
|
||||
"CadForceProbeReceipt": ".cadForceProbeReceipt",
|
||||
"LogogramProjection": ".logogramProjection",
|
||||
"HoldForUnlawfulOrUnderspecifiedShape": ".holdForUnlawfulOrUnderspecifiedShape",
|
||||
}
|
||||
|
||||
|
||||
def template_key(rrc_kind: str, status: str) -> str:
|
||||
"""Map rrc_kind + classifier status to a page-generator template key."""
|
||||
if status == "HOLD":
|
||||
return "hold"
|
||||
kind_map = {
|
||||
"cognitive_field_receipt": "definition",
|
||||
"compression_route_prior": "master_equation",
|
||||
"geometry_topology_receipt": "definition",
|
||||
"cad_force_receipt": "gate",
|
||||
"logogram_projection": "receipt",
|
||||
"negative_control": "hold",
|
||||
}
|
||||
return kind_map.get(rrc_kind, "definition")
|
||||
|
||||
|
||||
def operator_tokens(er: dict) -> list[str]:
|
||||
"""Derive operator/domain tokens from route_hint, rrc_kind, and equation text."""
|
||||
tokens = []
|
||||
rh = (er.get("route_hint_non_authoritative") or "").strip()
|
||||
rk = (er.get("rrc_kind") or "").strip()
|
||||
if rh and rh != "unclassified_equation":
|
||||
tokens.append(rh)
|
||||
if rk:
|
||||
tokens.append(rk)
|
||||
eq_text = (er.get("equation") or "").lower()
|
||||
for op in ["exp(", "log(", "max(", "min(", "sum(", "integral", "derivative",
|
||||
"laplacian", "nabla", "div(", "curl(", "sigmoid", "softmax",
|
||||
"tanh(", "relu(", "norm(", "dot(", "cross("]:
|
||||
if op in eq_text:
|
||||
tokens.append(op.rstrip("("))
|
||||
return list(dict.fromkeys(tokens))
|
||||
|
||||
|
||||
def lean_str(s: str) -> str:
|
||||
s = s.replace("\\", "\\\\").replace('"', '\\"')
|
||||
return f'"{s}"'
|
||||
|
||||
|
||||
def lean_opt(s: str | None) -> str:
|
||||
return "none" if s is None else f"some {lean_str(s)}"
|
||||
|
||||
|
||||
def lean_q16_16(val: float) -> str:
|
||||
"""Convert a float in [0,1] to a Q16_16 Lean literal via exact rational."""
|
||||
if val == 0.0:
|
||||
return "Q16_16.zero"
|
||||
from fractions import Fraction
|
||||
f = Fraction(val).limit_denominator(100)
|
||||
return f"Q16_16.ofRatio {f.numerator} {f.denominator}"
|
||||
|
||||
|
||||
def lean_str_list(xs: list[str]) -> str:
|
||||
return "[" + ", ".join(lean_str(x) for x in xs) + "]"
|
||||
|
||||
|
||||
def load_matrices(path: Path) -> dict[str, list[list[int]]]:
|
||||
"""Load predictions JSON into equation_id → matrix lookup."""
|
||||
if not path.exists():
|
||||
return {}
|
||||
data = json.loads(path.read_text())
|
||||
return {
|
||||
p.get("equation_id", ""): p.get("matrix_8x8", [])
|
||||
for p in data.get("predictions", [])
|
||||
if p.get("equation_id")
|
||||
}
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser(description="Generate SilverSight RRC Q16_16Manifold.lean")
|
||||
parser.add_argument(
|
||||
"--receipt",
|
||||
type=Path,
|
||||
default=Path("/home/allaun/Research Stack/archive/experimental-shim-probes/rrc_equation_classifier_receipt.json"),
|
||||
help="Path to rrc_equation_classifier_receipt.json",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--predictions",
|
||||
type=Path,
|
||||
default=Path("/home/allaun/Research Stack/shared-data/rrc_pist_predictions_250_v1.json"),
|
||||
help="Path to rrc_pist_predictions_250_v1.json",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--out-lean",
|
||||
type=Path,
|
||||
default=Path("formal/SilverSight/RRC/Q16_16Manifold.lean"),
|
||||
help="Output Lean module path",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
receipt = json.loads(args.receipt.read_text())
|
||||
eqs = receipt.get("compiled_equations", [])
|
||||
matrices = load_matrices(args.predictions)
|
||||
print(f"Loaded {len(eqs)} equations and {len(matrices)} matrices", file=sys.stderr)
|
||||
|
||||
# Deterministic order by equation_id.
|
||||
eqs_sorted = sorted(eqs, key=lambda eq: eq.get("invariant_receipt", {}).get("object_id", ""))
|
||||
|
||||
# Content hash over the raw corpus data for reproducibility.
|
||||
content_blob = json.dumps(
|
||||
[
|
||||
{
|
||||
"object_id": eq.get("invariant_receipt", {}).get("object_id"),
|
||||
"name": eq.get("equation_record", {}).get("name"),
|
||||
"shape": eq.get("invariant_receipt", {}).get("shape"),
|
||||
"status": eq.get("invariant_receipt", {}).get("status"),
|
||||
"matrix": matrices.get(eq.get("invariant_receipt", {}).get("object_id", "")),
|
||||
}
|
||||
for eq in eqs_sorted
|
||||
],
|
||||
sort_keys=True,
|
||||
separators=(",", ":"),
|
||||
).encode("utf-8")
|
||||
content_hash = hashlib.sha256(content_blob).hexdigest()
|
||||
|
||||
rows: list[str] = []
|
||||
for eq in eqs_sorted:
|
||||
er = eq["equation_record"]
|
||||
ir = eq["invariant_receipt"]
|
||||
tw = eq["type_witness"]
|
||||
|
||||
eq_id = ir.get("object_id", "")
|
||||
name = er.get("name", "")
|
||||
shape_str = ir.get("shape", "HoldForUnlawfulOrUnderspecifiedShape")
|
||||
lean_shape = SHAPE_MAP.get(shape_str, ".holdForUnlawfulOrUnderspecifiedShape")
|
||||
status_str = ir.get("status", "HOLD")
|
||||
lean_status = ".candidate" if status_str == "CANDIDATE" else ".hold"
|
||||
rrc_kind = er.get("rrc_kind", "")
|
||||
weak_cnt = len(tw.get("missing_or_weak_axes") or [])
|
||||
|
||||
# Manifold coordinates for negative control witness (Q16_16)
|
||||
coords = eq.get("manifold_projection", {}).get("coordinates", {})
|
||||
nc_strength = coords.get("negative_control_strength", 0.0)
|
||||
residual_risk = coords.get("residual_risk", 0.0)
|
||||
scale_band = coords.get("scale_band_declared", 0.0)
|
||||
weak_axes = tw.get("missing_or_weak_axes") or []
|
||||
|
||||
op_tokens = operator_tokens(er)
|
||||
inv_declared = (er.get("domain_type") or "unknown").strip() or "unknown"
|
||||
bound_conds = (er.get("bind_class") or "unknown").strip() or "unknown"
|
||||
t_key = template_key(rrc_kind, status_str)
|
||||
route_hint = er.get("route_hint_non_authoritative") or "unclassified_equation"
|
||||
t_params = f"route={route_hint};shape={shape_str}"
|
||||
arxiv_pid = (er.get("arxiv_paper_id") or "").strip() or None
|
||||
|
||||
rows.append(
|
||||
f" {{ equationId := {lean_str(eq_id)}\n"
|
||||
f" name := {lean_str(name)}\n"
|
||||
f" shape := {lean_shape}\n"
|
||||
f" status := {lean_status}\n"
|
||||
f" rrcKind := {lean_str(rrc_kind)}\n"
|
||||
f" weakAxesCnt := {weak_cnt}\n"
|
||||
f" pistProxyLabel := Option.bind (findMatrix {lean_str(eq_id)}) (SilverSight.PIST.ClassifyN.classifyProxy SilverSight.PIST.ClassifyN.hashTable8)\n"
|
||||
f" pistExactLabel := Option.bind (findMatrix {lean_str(eq_id)}) (SilverSight.PIST.ClassifyN.classifyExact 8)\n"
|
||||
f" arxivPaperId := {lean_opt(arxiv_pid)}\n"
|
||||
f" ncObserved := {lean_q16_16(nc_strength)}\n"
|
||||
f" residualRisk := {lean_q16_16(residual_risk)}\n"
|
||||
f" scaleBandDeclared := {lean_q16_16(scale_band)}\n"
|
||||
f" weakAxesNames := {lean_str_list(weak_axes)}\n"
|
||||
f" operatorTokens := {lean_str_list(op_tokens)}\n"
|
||||
f" invariantsDeclared := {lean_str(inv_declared)}\n"
|
||||
f" boundaryConds := {lean_str(bound_conds)}\n"
|
||||
f" templateKey := {lean_str(t_key)}\n"
|
||||
f" templateParams := {lean_str(t_params)} }}"
|
||||
)
|
||||
|
||||
lines = [
|
||||
"-- SilverSight.RRC.Q16_16Manifold — AUTO-GENERATED by python/build_manifold.py",
|
||||
"-- DO NOT EDIT BY HAND. Regenerate with:",
|
||||
"-- python3 python/build_manifold.py",
|
||||
"--",
|
||||
"-- Python role: raw feature extraction + matrix merge.",
|
||||
"-- Lean role: PIST classification, alignment gate (determineAlignment),",
|
||||
"-- receipt stamping, and all admissibility/promotion decisions.",
|
||||
"--",
|
||||
"-- Source: rrc_equation_classifier_receipt.json",
|
||||
"-- Matrices: rrc_pist_predictions_250_v1.json",
|
||||
f"-- Content hash (SHA-256): {content_hash}",
|
||||
f"-- Equation count: {len(rows)}",
|
||||
"--",
|
||||
"import SilverSight.RRC.Emit",
|
||||
"import SilverSight.FixedPoint",
|
||||
"import SilverSight.PIST.Classify",
|
||||
"import SilverSight.PIST.ClassifyN",
|
||||
"import SilverSight.PIST.Matrices250",
|
||||
"",
|
||||
"namespace SilverSight.RRC.Q16_16Manifold",
|
||||
"",
|
||||
"open SilverSight.RRC.Emit",
|
||||
"open SilverSight.FixedPoint",
|
||||
"open SilverSight.RRCLogogramProjection",
|
||||
"open SilverSight.ReceiptCore",
|
||||
"open SilverSight.PIST.Matrices250",
|
||||
"",
|
||||
"/-- Full 250-equation manifold from rrc_equation_classifier_receipt.json,",
|
||||
" merged with 8×8 braid adjacency matrices from",
|
||||
" rrc_pist_predictions_250_v1.json.",
|
||||
" Each row carries raw features only; the alignment gate in",
|
||||
" SilverSight.RRC.Emit.emitCorpus makes all admissibility decisions. -/",
|
||||
"def allFixtures : List FixtureRow := [",
|
||||
",\n".join(rows),
|
||||
"]",
|
||||
"",
|
||||
"end SilverSight.RRC.Q16_16Manifold",
|
||||
"",
|
||||
]
|
||||
|
||||
args.out_lean.parent.mkdir(parents=True, exist_ok=True)
|
||||
args.out_lean.write_text("\n".join(lines))
|
||||
print(f"Wrote {args.out_lean} ({len(rows)} rows)", file=sys.stderr)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
|
|
@ -96,10 +96,12 @@ def main() -> int:
|
|||
"",
|
||||
"namespace SilverSight.PIST.Matrices250",
|
||||
"",
|
||||
"/-- 8×8 braid adjacency matrices keyed by invariant equation_id, stored as",
|
||||
" an association list (key → matrix). Generated from",
|
||||
"/-- All matrices in this list have dimension 8×8 (the canonical strand count).",
|
||||
" Stored as association list (key → matrix). Generated from",
|
||||
" rrc_pist_predictions_250_v1.json.",
|
||||
f" Entries: {len(entries)}. -/",
|
||||
f"def pistMatrixDim : Nat := 8",
|
||||
"",
|
||||
"def pistMatrices250 : List (String × Array (Array Int)) :=",
|
||||
" [",
|
||||
",\n".join(entries),
|
||||
|
|
|
|||
96
scripts/cross_domain_significance.py
Normal file
96
scripts/cross_domain_significance.py
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
#!/usr/bin/env python3
|
||||
"""
|
||||
cross_domain_significance.py — Statistical significance test for
|
||||
RRC cross-domain 1/n residual signatures.
|
||||
|
||||
Tests whether observed deviations from predicted 1/n scaling or
|
||||
1/7 meta-solid threshold are statistically significant at ≥6σ.
|
||||
"""
|
||||
|
||||
import json, math
|
||||
from pathlib import Path
|
||||
from datetime import datetime, timezone
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
def gaussian_p_value(z: float) -> float:
|
||||
"""Two-tailed p-value from z-score via complementary error function."""
|
||||
return math.erfc(abs(z) / math.sqrt(2))
|
||||
|
||||
def sigma_from_p(p: float) -> float:
|
||||
"""Convert p-value to sigma level (two-tailed) via inverse erfc approximation."""
|
||||
if p <= 0:
|
||||
return float('inf')
|
||||
if p >= 1:
|
||||
return 0.0
|
||||
t = math.sqrt(-2 * math.log(p if p <= 0.5 else 1 - p))
|
||||
c = (2.515517, 0.802853, 0.010328)
|
||||
d = (1.432788, 0.189269, 0.001308)
|
||||
return t - (c[0] + c[1]*t + c[2]*t**2) / (1 + d[0]*t + d[1]*t**2 + d[2]*t**3)
|
||||
|
||||
def main():
|
||||
sig_path = ROOT / "signatures" / "cross_domain_signatures.json"
|
||||
sigs = json.loads(sig_path.read_text())
|
||||
entries = sigs["signatures"]
|
||||
|
||||
phases = {}
|
||||
for e in entries:
|
||||
phases.setdefault(e.get("phase", 0), []).append(e)
|
||||
|
||||
results = []
|
||||
for phase_num in sorted(phases):
|
||||
group = phases[phase_num]
|
||||
domain = group[0].get("domain", "Unknown")
|
||||
deviations = [abs(e["deviation"]) for e in group if "deviation" in e]
|
||||
residuals = [e["residual_mhz"] for e in group if "residual_mhz" in e]
|
||||
|
||||
values = deviations or residuals
|
||||
n = len(values)
|
||||
|
||||
if n < 2:
|
||||
results.append({
|
||||
"phase": phase_num, "domain": domain,
|
||||
"n": n, "status": "insufficient_data"
|
||||
})
|
||||
continue
|
||||
|
||||
mean_val = sum(values) / n
|
||||
var = sum((v - mean_val)**2 for v in values) / (n - 1) if n > 1 else 0
|
||||
se = math.sqrt(var / n)
|
||||
z = mean_val / se if se > 0 else 0.0
|
||||
p = gaussian_p_value(z)
|
||||
sigma = sigma_from_p(p)
|
||||
|
||||
results.append({
|
||||
"phase": phase_num,
|
||||
"domain": domain,
|
||||
"n": n,
|
||||
"mean_deviation": round(mean_val, 6),
|
||||
"std_err": round(se, 6),
|
||||
"z_score": round(z, 4),
|
||||
"sigma_level": round(sigma, 2) if sigma < 1e6 else "inf",
|
||||
"passes_6sigma": bool(sigma >= 6.0),
|
||||
})
|
||||
|
||||
summary = {
|
||||
"schema": "cross_domain_significance_v1",
|
||||
"generated_at": datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ"),
|
||||
"source": "cross_domain_signatures.json",
|
||||
"total_entries": len(entries),
|
||||
"phases": results,
|
||||
}
|
||||
|
||||
out_path = ROOT / "signatures" / "cross_domain_significance.json"
|
||||
out_path.write_text(json.dumps(summary, indent=2) + "\n")
|
||||
print(f"Wrote {out_path}")
|
||||
for r in results:
|
||||
s = r.get("sigma_level")
|
||||
if s is not None and s != "inf":
|
||||
tag = "✅" if r["passes_6sigma"] else "❌"
|
||||
print(f" Phase {r['phase']} ({r['domain']}): σ={s} {tag}")
|
||||
else:
|
||||
tag = "✅" if r.get("status") == "insufficient_data" else "❌"
|
||||
print(f" Phase {r['phase']} ({r['domain']}): σ={s} {tag}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
80
scripts/setup_authentik.sh
Normal file
80
scripts/setup_authentik.sh
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
#!/bin/bash
|
||||
# setup_authentik.sh — Deploy Authentik + Caddy on neon-64gb
|
||||
# Uses existing Postgres (arxiv-pg) and Redis on neon.
|
||||
#
|
||||
# Run from any node with SSH access to neon:
|
||||
# bash scripts/setup_authentik.sh
|
||||
#
|
||||
# Authentik listens on:
|
||||
# HTTP → port 30001 (Caddy at auth.neon.lan proxies to this)
|
||||
# HTTPS → port 30100 (reserved for future direct TLS)
|
||||
|
||||
set -euo pipefail
|
||||
NEON="allaun@100.92.88.64"
|
||||
|
||||
echo "=== Step 1: Create authentik database ==="
|
||||
ssh "$NEON" "
|
||||
psql -h localhost -U postgres -tc \"SELECT 1 FROM pg_database WHERE datname='authentik'\" | grep -q 1 || \
|
||||
psql -h localhost -U postgres -c 'CREATE DATABASE authentik'
|
||||
"
|
||||
|
||||
echo "=== Step 2: Generate shared secret key ==="
|
||||
AUTH_KEY=$(python3 -c "import secrets; print(secrets.token_hex(32))")
|
||||
|
||||
echo "=== Step 3: Pull image ==="
|
||||
ssh "$NEON" "podman pull ghcr.io/goauthentik/server:latest"
|
||||
|
||||
echo "=== Step 4: Remove old containers ==="
|
||||
ssh "$NEON" "podman rm -f authentik-server authentik-worker 2>/dev/null || true"
|
||||
|
||||
echo "=== Step 5: Start server (port 30001) ==="
|
||||
ssh "$NEON" "
|
||||
podman run -d --name authentik-server \
|
||||
--network host \
|
||||
-e AUTHENTIK_SECRET_KEY='$AUTH_KEY' \
|
||||
-e AUTHENTIK_POSTGRESQL__NAME=authentik \
|
||||
-e AUTHENTIK_POSTGRESQL__USER=postgres \
|
||||
-e AUTHENTIK_POSTGRESQL__HOST=localhost \
|
||||
-e AUTHENTIK_POSTGRESQL__PORT=5432 \
|
||||
-e AUTHENTIK_POSTGRESQL__PASSWORD=postgres \
|
||||
-e AUTHENTIK_REDIS__HOST=localhost \
|
||||
-e AUTHENTIK_REDIS__PORT=6379 \
|
||||
-e AUTHENTIK_LISTEN__HTTP=0.0.0.0:30001 \
|
||||
ghcr.io/goauthentik/server:latest server
|
||||
"
|
||||
|
||||
echo "=== Step 6: Start worker ==="
|
||||
ssh "$NEON" "
|
||||
podman run -d --name authentik-worker \
|
||||
--network host \
|
||||
-e AUTHENTIK_SECRET_KEY='$AUTH_KEY' \
|
||||
-e AUTHENTIK_POSTGRESQL__NAME=authentik \
|
||||
-e AUTHENTIK_POSTGRESQL__USER=postgres \
|
||||
-e AUTHENTIK_POSTGRESQL__HOST=localhost \
|
||||
-e AUTHENTIK_POSTGRESQL__PORT=5432 \
|
||||
-e AUTHENTIK_POSTGRESQL__PASSWORD=postgres \
|
||||
-e AUTHENTIK_REDIS__HOST=localhost \
|
||||
-e AUTHENTIK_REDIS__PORT=6379 \
|
||||
ghcr.io/goauthentik/server:latest worker
|
||||
"
|
||||
|
||||
echo "=== Step 7: Wait for migrations ==="
|
||||
sleep 10
|
||||
|
||||
echo "=== Status ==="
|
||||
ssh "$NEON" "
|
||||
podman ps --filter name=auth --format '{{.Names}} {{.Status}}'
|
||||
curl -s -o /dev/null -w 'HTTP port 30001: %{http_code}\n' http://localhost:30001/
|
||||
"
|
||||
|
||||
echo "=== Done ==="
|
||||
echo " Authentik: http://localhost:30001 (neon) or http://auth.neon.lan via Caddy"
|
||||
echo " Setup wizard at first visit creates the admin account."
|
||||
echo ""
|
||||
echo " To route via Caddy (if desired):"
|
||||
echo " ssh $NEON 'cat > ~/caddy/Caddyfile << EOF"
|
||||
echo " auth.neon.lan {"
|
||||
echo " reverse_proxy localhost:30001"
|
||||
echo " }"
|
||||
echo " EOF""
|
||||
echo " ssh $NEON 'podman restart caddy'"
|
||||
54
signatures/cross_domain_significance.json
Normal file
54
signatures/cross_domain_significance.json
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
{
|
||||
"schema": "cross_domain_significance_v1",
|
||||
"generated_at": "2026-06-30T07:48:42Z",
|
||||
"source": "cross_domain_signatures.json",
|
||||
"total_entries": 16,
|
||||
"phases": [
|
||||
{
|
||||
"phase": 1,
|
||||
"domain": "Rydberg",
|
||||
"n": 3,
|
||||
"mean_deviation": 123.266667,
|
||||
"std_err": 37.656621,
|
||||
"z_score": 3.2734,
|
||||
"sigma_level": 3.07,
|
||||
"passes_6sigma": false
|
||||
},
|
||||
{
|
||||
"phase": 2,
|
||||
"domain": "Superconductor",
|
||||
"n": 3,
|
||||
"mean_deviation": 0.006286,
|
||||
"std_err": 0.002245,
|
||||
"z_score": 2.7997,
|
||||
"sigma_level": 2.57,
|
||||
"passes_6sigma": false
|
||||
},
|
||||
{
|
||||
"phase": 3,
|
||||
"domain": "EnergyStorage",
|
||||
"n": 3,
|
||||
"mean_deviation": 0.077504,
|
||||
"std_err": 0.023425,
|
||||
"z_score": 3.3085,
|
||||
"sigma_level": 3.11,
|
||||
"passes_6sigma": false
|
||||
},
|
||||
{
|
||||
"phase": 4,
|
||||
"domain": "Electromagnetic",
|
||||
"n": 3,
|
||||
"mean_deviation": 0.003333,
|
||||
"std_err": 0.003333,
|
||||
"z_score": 1.0,
|
||||
"sigma_level": 0.47,
|
||||
"passes_6sigma": false
|
||||
},
|
||||
{
|
||||
"phase": 5,
|
||||
"domain": "Rydberg",
|
||||
"n": 0,
|
||||
"status": "insufficient_data"
|
||||
}
|
||||
]
|
||||
}
|
||||
103
tests/test_python_modules.py
Normal file
103
tests/test_python_modules.py
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
"""test_python_modules.py — Sanity checks for Python shim modules.
|
||||
|
||||
Tests that each module can be imported and key functions run without error.
|
||||
For deterministic modules, checks that output matches expected values.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "python"))
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "qubo"))
|
||||
|
||||
|
||||
class TestPistBraidBridge(unittest.TestCase):
|
||||
"""pist_braid_bridge: PIST trace → braid strand mapping."""
|
||||
|
||||
def test_import(self):
|
||||
import pist_braid_bridge
|
||||
self.assertTrue(hasattr(pist_braid_bridge, "float_to_q16"))
|
||||
self.assertTrue(hasattr(pist_braid_bridge, "q16_to_float"))
|
||||
|
||||
|
||||
class TestSidonAddress(unittest.TestCase):
|
||||
"""sidon_address: Sidon label propagation."""
|
||||
|
||||
def test_import(self):
|
||||
import sidon_address
|
||||
self.assertTrue(hasattr(sidon_address, "verify_sidon_property"))
|
||||
self.assertTrue(hasattr(sidon_address, "spectral_to_sidon_address"))
|
||||
|
||||
|
||||
class TestSpectralProfile(unittest.TestCase):
|
||||
"""spectral_profile: spectral feature extraction."""
|
||||
|
||||
def test_import(self):
|
||||
import spectral_profile
|
||||
self.assertTrue(hasattr(spectral_profile, "compute_spectral_profile"))
|
||||
|
||||
|
||||
class TestBuildManifold(unittest.TestCase):
|
||||
"""build_manifold: manifold generation pipeline."""
|
||||
|
||||
def test_lean_q16_16(self):
|
||||
from build_manifold import lean_q16_16
|
||||
self.assertEqual(lean_q16_16(0.0), "Q16_16.zero")
|
||||
self.assertEqual(lean_q16_16(0.5), "Q16_16.ofRatio 1 2")
|
||||
self.assertEqual(lean_q16_16(0.25), "Q16_16.ofRatio 1 4")
|
||||
|
||||
|
||||
class TestQ16Canonical(unittest.TestCase):
|
||||
"""q16_canonical: Q16_16 encoding/decoding."""
|
||||
|
||||
def test_import(self):
|
||||
import q16_canonical
|
||||
self.assertTrue(hasattr(q16_canonical, "float_to_q16"))
|
||||
self.assertTrue(hasattr(q16_canonical, "q16_to_float"))
|
||||
|
||||
|
||||
class TestDnaCodec(unittest.TestCase):
|
||||
"""dna_codec: DNA ↔ binary codec."""
|
||||
|
||||
def test_import(self):
|
||||
import dna_codec
|
||||
self.assertTrue(hasattr(dna_codec, "melting_temperature"))
|
||||
|
||||
|
||||
class TestExprTree(unittest.TestCase):
|
||||
"""expr_tree: expression tree parsing."""
|
||||
|
||||
def test_import(self):
|
||||
import expr_tree
|
||||
self.assertTrue(hasattr(expr_tree, "ExprNode"))
|
||||
|
||||
|
||||
class TestBuildPistMatrices(unittest.TestCase):
|
||||
"""build_pist_matrices_250: PIST matrix generation."""
|
||||
|
||||
def test_import(self):
|
||||
import build_pist_matrices_250
|
||||
self.assertTrue(hasattr(build_pist_matrices_250, "lean_str"))
|
||||
|
||||
|
||||
class TestDnaQuboSort(unittest.TestCase):
|
||||
"""dna_qubo_sort: QUBO-based DNA sorting."""
|
||||
|
||||
def test_import(self):
|
||||
import dna_qubo_sort
|
||||
self.assertTrue(hasattr(dna_qubo_sort, "QuboDnaCandidate"))
|
||||
|
||||
|
||||
class TestChaosGame(unittest.TestCase):
|
||||
"""chaos_game: chaos game IFS engine."""
|
||||
|
||||
def test_import(self):
|
||||
import chaos_game
|
||||
self.assertTrue(hasattr(chaos_game, "LCG"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Loading…
Add table
Reference in a new issue