Skip to content
This repository was archived by the owner on May 22, 2026. It is now read-only.

SuperInstance/spectral-conservation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

spectral-conservation

Track spectral conservation in coupled nonlinear dynamics — know instantly when your system is drifting.

Tests License crates.io

Why?

In coupled nonlinear dynamics, the spectral invariant I(x) = γ(x) + H(x) stays remarkably stable along trajectories. This crate lets you monitor that conservation in real time — if I(x) drifts, your system is entering a pathological regime. Zero counterexamples found across 20 cycles of adversarial falsification.

Use this when you need to verify stability guarantees in neural coupling, attention mechanisms, or any system with state-dependent coupling matrices.

Install

[dependencies]
spectral-conservation = "0.1"

Or: cargo add spectral-conservation

The Discovery

In coupled nonlinear dynamics of the form x_{t+1} = σ(C(x_t) · x_t), the quantity

In coupled nonlinear dynamics of the form x_{t+1} = σ(C(x_t) · x_t), the quantity

I(x) = γ(x) + H(x)
     = spectral_gap(C) + participation_entropy(C)

is approximately conserved along trajectories, with CV < 0.03 across thousands of configurations, 20 cycles of automated adversarial falsification, and zero counterexamples found.

Nobody predicted this. It's not Hamiltonian conservation, not a Lyapunov function, not Noether's theorem. It's a spectral shape stability property that emerges from the algebra of contractive coupling.

Quick Start

use spectral_conservation::*;
use nalgebra::{DMatrix, DVector};

// Create a coupling matrix
let C = random_coupling(10, 42);

// Compute spectral state
let state = spectral_state(&C).unwrap();
println!("γ = {}, H = {}, I = {}", state.gamma, state.entropy, state.invariant);
println!("PR = {}, effective_rank = {}", state.participation_ratio, state.effective_rank);

// Track conservation over a trajectory
let mut monitor = ConservationMonitor::default_threshold();
for step in 0..100 {
    let C_t = coupling_fn(&x); // your coupling function
    let state = spectral_state(&C_t).unwrap();
    let status = monitor.step(&state);
    println!("Step {}: I = {:.6}, CV = {:.6}, Alert = {:?}", step, state.invariant, status.cv, status.alert);
}

Three Regimes

Regime Coupling CV(I) Mechanism
Structural Rank-1 (star topology) 0.0000 Algebraic identity
Dynamical Full-rank, stable shape < 0.015 Spectral shape stability
Transitional Near rank-1 0.03–0.05 Shape conflict

Key Results (20 Cycles of Automated Falsification)

  • Conservation quality: CV(I) < 0.03 across all tested configurations
  • Best predictor: Commutator ||[D,C]|| with r = 0.965 (p = 0.0004)
  • Substrate-invariant: FP64 to binary quantization (10¹⁵:1 range)
  • Dimensional scaling: CV ∝ N^{-0.28}
  • Asymmetry tolerance: CV stays < 0.03 even at 10× antisymmetric perturbation
  • Noise immune: Additive Gaussian noise doesn't affect conservation for static coupling
  • Zero counterexamples in 6 dedicated stress tests

Features

  • Spectral state computation: Eigenvalues, spectral gap, participation entropy, participation ratio
  • Conservation monitor: Track I(x) over trajectories with automatic CV computation and alert levels
  • Commutator diagnostic: Compute ||[D,C]||_F for conservation quality prediction
  • Built-in coupling functions: Random, Hebbian, Attention
  • Trajectory runner: Full dynamics simulation with conservation tracking
  • Regime classification: Automatic Structural / Dynamical / Transitional / Degraded

API

Core Functions

  • spectral_state(C) → Spectral decomposition with I, γ, H, PR, effective rank
  • commutator_norm(diag, C) → ||[D,C]||_F diagnostic
  • saturation_diagonal(z) → D = diag(sech²(z)) for tanh dynamics

Monitor

  • ConservationMonitor::new(threshold) → Track conservation over trajectories
  • monitor.step(&state) → ConservationStatus with CV, alert, regime
  • monitor.step_with_commutator(&state, &diag, &C) → Status with commutator diagnostic

Dynamics

  • run_trajectory(x0, coupling_fn, activation_fn, steps) → Full trajectory with CV
  • random_coupling(n, seed) → Symmetric random matrix
  • hebbian_coupling(x, n) → State-dependent Hebbian
  • attention_coupling(x, temperature) → Softmax attention

Related

Reference

Forgemaster & Digennaro (2026). "Spectral Near-Conservation in Coupled Nonlinear Dynamics: An Empirical Discovery with 18 Cycles of Automated Falsification." Draft v4, 5130 words. NeurIPS/ICML 2026 submission.

License

Apache-2.0

About

Spectral first integral I(x) = γ(x) + H(x) conservation tracker for coupled nonlinear dynamics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages