A self-modifying dynamical system for proto-cognitive adaptation
This project is in active beta development. Results reported here are preliminary and subject to revision as the research matures. Contributions, critiques, and collaborations are warmly welcome.
Devanik · B.Tech ECE '26, NIT Agartala Samsung Fellowship · Indian Institute of Science
NECF is an attempt to explore a question that does not yet have a satisfying answer in the literature:
Can a system's learning rules themselves be treated as dynamic state variables — evolving continuously under thermodynamic constraints — while preserving a coherent identity?
Most adaptive systems operate at two levels: a state that changes (neural activations, oscillator phases) and a rule that governs how the state changes (weights, coupling strengths). The rule is typically fixed or updated by a separate, outer-loop optimizer. NECF introduces a third level: the rule governing each node's adaptation is itself a dynamic variable, constrained by an identity curvature functional that prevents both chaotic drift and catatonic collapse.
This is not a claim about intelligence or general reasoning. It is a study of whether Level-3 meta-rule dynamics produces measurably different adaptive behavior from Level-1 (fixed rules) and Level-2 (globally adaptive coupling) baselines — and whether that difference can be characterized rigorously.
- Theoretical Framework
- The Three Levels of Dynamics
- Mathematical Specification
- Identity Curvature Functional
- Epistemic Contagion — The Core Mechanism
- External Driving and Non-Equilibrium Structure
- Seven Falsifiable Predictions
- Experimental Results (Beta)
- Relationship to Prior Work
- What NECF Is Not
- Codebase Structure
- Installation and Usage
- Daily Research Log
- Known Limitations
- Roadmap
- References
The standard picture of an adaptive system is a two-level hierarchy:
where
NECF proposes a genuine third level:
where
The system draws on three physical analogies:
Kuramoto model (Kuramoto, 1975):
Dissipative structures (Prigogine, 1977): Open thermodynamic systems driven far from equilibrium can spontaneously organize into ordered states. NECF is explicitly constructed as an open system — driven by Lorenz chaotic input, periodic signals, and Poisson spikes — to prevent equilibration and maintain perpetual self-organization.
Active inference (Friston, 2017): The Curiosity Engine monitors prediction error and drives the system toward states of minimal free energy. NECF's departure from standard active inference is that the minimization mechanism itself (the
The following taxonomy situates NECF in the landscape of adaptive systems:
| Level | What evolves | What is fixed | Representative systems |
|---|---|---|---|
| 0 | Nothing | Everything | Lookup tables, hardcoded controllers |
| 1 | State |
Rule |
Standard Kuramoto, fixed-weight neural networks |
| 2 | State |
Rule for updating |
Adaptive Kuramoto (Ha et al., 2016), gradient descent |
| 3 | State |
Identity curvature |
NECF (this work) |
| 4 | State, rule, and |
— | Hypothetical; not yet formalized |
The specific claim of this project is that Level-3 dynamics — where
- Standard Kuramoto (1975):
$K$ is a global scalar, fixed - Adaptive Kuramoto (Ha et al., SIAM 2016):
$K_{ij}$ evolves, but the rule governing$K$ 's evolution is fixed - Hopfield-Kuramoto (arXiv 2505.03648, May 2025): joint memory model, no meta-rule evolution
- MAML (Finn et al., 2017): learns an initialization for
$\mathcal{L}$ , not a continuously evolving rule field with identity constraints - Friston FEP (2005–2022): minimizes free energy via a fixed variational update rule
The gap NECF occupies is the combination of (a) per-node rule fields, (b) Boltzmann-weighted epistemic contagion between rules, (c) identity curvature constraint on rule evolution, and (d) Lyapunov-gated rollback — unified in a single dynamical system.
Each node
-
$A_i \in (0, 1]$ : amplitude — interpreted as local confidence or energy -
$\theta_i \in [0, 2\pi)$ : phase — causal alignment / temporal coordinate
The Kuramoto order parameter quantifies global synchrony:
Each node carries a rule vector:
| Parameter | Role | Initial value |
|---|---|---|
| Error sensitivity — governs amplitude decay rate | 0.30 | |
| Coupling strength — governs phase synchrony pull | 0.80 | |
| Curiosity weight — governs uncertainty-seeking | 0.10 |
Phase update (amplitude-weighted generalized Kuramoto with curiosity and external driving):
where
Curiosity potential — approximated via circular KDE with Silverman bandwidth
Nodes in dense, coherent phase regions experience a low
Amplitude update (error-driven with noise and periodic modulation):
where
Mean-field critical coupling (Kuramoto, 1975; Strogatz, 2000):
At initialization
This is a dynamical system in rule space, not gradient descent on a loss function. The contagion term
The central object distinguishing NECF from prior adaptive systems is
Properties:
-
$\mathcal{H}[\mathcal{L}] = 0$ at initialization by construction -
$\mathcal{H} \to \infty$ in both failure modes:-
Chaotic drift: each
$\mathcal{L}_i$ wanders freely → drift term grows -
Catatonic collapse: all
$\mathcal{L}_i \to \bar{\mathcal{L}}$ (identical) → variance penalty activates
-
Chaotic drift: each
- The viable regime corresponds to
$\mathcal{H}$ bounded in a system-dependent interval
The gradient used in the meta-dynamics update:
where
At each step, the system checks whether identity curvature has increased too rapidly:
If
This is not gradient descent — it is a reversion to the previous state plus a corrective step in the direction of lower identity curvature. The combined effect prevents the same spike from recurring immediately and provides a Lyapunov stability certificate for the rule field over
The contagion term
A naive inverse-error weighting:
is singular. For
implemented with the log-sum-exp trick for numerical stability:
log_w = -eps / kappa
log_w -= log_w.max() # stability
w = np.exp(log_w)
w /= w.sum() + 1e-15The weight is globally
which is bounded by
Properties of the Boltzmann weights:
| Character | Max weight | ||
|---|---|---|---|
| Winner-takes-all | |||
| Default (selective) | |||
| Diffuse | |||
| Uniform |
At
For each node
The contagion contribution to
where
Two-group mixing time (analytically derived and empirically verified):
At the default
NECF is deliberately constructed as an open thermodynamic system. Three driving mechanisms prevent the field from reaching equilibrium:
The Lorenz attractor
The spatial factor
A structured sinusoidal driver creates resonance opportunities and modulates node amplitudes globally:
At each step, each node independently spikes with probability
where NaN and the step is classified SPIKE_DOMINATED — a transient physical event, not internal chaos. The spike mask is explicitly threaded from environment.step() through field.step() to observer.record() at every timestep.
NECF makes seven quantitative predictions, each independently falsifiable:
| # | Observable | Prediction | Falsification condition |
|---|---|---|---|
| P1 | Order parameter |
Rises from |
|
| P2 | Identity curvature |
Remains bounded in |
|
| P3 | Mean prediction error |
Decreases after |
|
| P4 | Masked Lyapunov proxy |
Stays in |
|
| P5 | Rule diversity |
Bounded; neither collapses to zero nor diverges | |
| P6 | Curiosity directives | Fires within 30 steps of plateau detection | Never fires, or fires on non-plateau steps |
| P7 | Rollback rate | Decreases over the course of a run | Rate increases monotonically |
These predictions are what distinguish NECF from a philosophical proposal. A system that satisfies all seven is behaving as the theory predicts; a system that fails any one provides specific information about which component requires revision.
⚠️ All results below are preliminary.$N$ is small (16–64 nodes), run lengths are short ($T \leq 2000$ steps), and no task-level benchmark has been applied. These are substrate-characterization experiments only.
Sweep over
Empirical
The order parameter scales approximately as
Over 22 values of
Grid sweep over
-
67% of the explored
$(\lambda, \delta)$ space produces viable dynamics at$T = 400$ steps - Regime boundaries: VIABLE / CATATONIC (
$r < 0.04$ ) / DRIFTED ($\mathcal{H} > 3$ ) / ROLLBACK-HEAVY - Default values
$(\lambda = 0.10,, \delta = 0.30)$ fall in the VIABLE cell
Full spectrum via continuous QR decomposition (Benettin et al., 1980),
Kaplan–Yorke dimension:
indicating a fractal strange attractor of dimension
Two-group mixing time as a function of
| Rel. error | |||
|---|---|---|---|
Power law:
From 40 random initialisations (
| Condition | ||
|---|---|---|
|
Level-1 (frozen |
||
|
Level-2 (global |
||
| Level-3 (full NECF) |
Welch's
The difference in
Interpretation: The current experiments are substrate characterization, not performance benchmarking. The ablation will be re-run at
$T \geq 5{,}000$ once compute budget permits.
NECF is built on and departs from several bodies of literature:
The standard Kuramoto model (Kuramoto, 1975; Strogatz, 2000) uses a fixed global coupling
Friston's Free Energy Principle (2005–2022) provides the theoretical foundation for prediction-error-driven adaptation and the curiosity/active inference components. NECF's departure is that the variational update rule (what FEP holds fixed) is itself a dynamic variable — the
MAML (Finn, Abbeel & Levine, 2017) and its descendants learn a good initialization
Prigogine's theory of dissipative structures (1977) demonstrates that open thermodynamic systems far from equilibrium can spontaneously organize into ordered states through energy dissipation. NECF uses this principle architecturally: the Lorenz driving and Poisson spikes ensure the system never equilibrates, creating the conditions for persistent self-organization.
The proto-will mechanism draws on causal entropy maximization (Klyubin, Polani & Nehaniv, 2005; Salge, Glackin & Polani, 2014), where an agent selects actions that maximize the logarithm of future state-space volume accessible under its policy. NECF's attractor selection formula:
where
In the interest of accuracy, several things should be clearly stated:
NECF is not a cognitive architecture. It has no perception layer, no task representation, and no mechanism for mapping external stimuli to field states or extracting decisions from phase patterns.
NECF has not been benchmarked on any task. No classification accuracy, no ARC score, no game score. The experiments reported are purely substrate-characterization: does the field behave as the theory predicts?
NECF does not demonstrate intelligence or reasoning. It demonstrates that a coupled oscillator field with Level-3 meta-rule dynamics behaves differently from Level-1 and Level-2 baselines in specific, measurable ways. Whether that difference is relevant to cognitive function is an open question.
NECF is not a refutation of neural networks. It is an exploration of a different computational primitive — one that may complement, rather than replace, existing approaches.
The honest position is that NECF is a proto-cognitive substrate — a dynamical system with properties that may be useful building blocks for more complete architectures, but which is not itself a reasoning system.
necf/
├── app.py # Streamlit live dashboard — entry point
├── config.py # All hyperparameters (single source of truth)
├── field.py # Level-1: oscillator field state + Numba-compiled Kuramoto
├── meta_dynamics.py # Level-3: Boltzmann epistemic contagion + rule evolution
├── identity.py # H[L] curvature functional + Lyapunov-gated rollback
├── curiosity.py # CuriosityEngine: plateau detection + exploration directives
├── environment.py # External drivers: Lorenz attractor, periodic, Poisson spikes
├── observer.py # All observables: r(t), masked λ_max, entropy, regime classifier
├── experiment.py # Run loop with ablation helpers (Level-1, Level-2, Level-3)
└── requirements.txt
.github/
└── workflows/
└── daily_necf_research.yml # Automated daily research session (no LLM)
docs/
├── INDEX.md # Session index — one entry per day
└── sessions/
└── YYYY-MM-DD_<slug>.md # Technical research note per session
field.py — Numba JIT kernel: The @numba.njit(parallel=True, fastmath=True), pre-warmed during __init__ to avoid first-step latency in Streamlit. Falls back to NumPy broadcasting if Numba is unavailable.
observer.py — Masked Lyapunov: The Lyapunov proxy excludes nodes spiked at NaN with n_valid_lyapunov when coverage is insufficient, rather than a spurious value.
experiment.py — Ablation factories: NECFExperiment.level1_only() and .level2_adaptive_coupling() return pre-configured instances for controlled comparison. The ablation factories override meta.step rather than duplicating logic, ensuring identical dynamics up to the rule-update layer.
python >= 3.11
numpy >= 1.24
scipy >= 1.11
streamlit >= 1.32
matplotlib >= 3.7
numba >= 0.58 # optional but strongly recommended
git clone https://github.com/Devanik21/NECF.git
cd NECF
pip install -r requirements.txtstreamlit run app.pyNavigate to http://localhost:8501. The dashboard provides:
- Real-time phase polar plot and order parameter trace
- All 7 observable metrics updated live
- Rule field distribution histograms
- Identity curvature
$\mathcal{H}[\mathcal{L}]$ phase diagram - Curiosity Engine directive timeline
- Regime classifier (VIABLE / CHAOTIC / CATATONIC)
from config import NECFConfig
from experiment import NECFExperiment
# Full NECF (Level-3)
exp = NECFExperiment(NECFConfig(seed=42))
for snap in exp.stream():
print(f"t={snap.t:4d} r={snap.r:.4f} H={snap.H:.4f} λ={snap.lyapunov_proxy:+.4f}")
# Ablation baselines
exp_l1 = NECFExperiment.level1_only() # fixed rules
exp_l2 = NECFExperiment.level2_adaptive_coupling() # global β onlyimport numpy as np
from scipy.stats import ttest_ind
from experiment import NECFExperiment
from config import NECFConfig
N_TRIALS = 25
results = {1: [], 2: [], 3: []}
for seed in range(N_TRIALS):
cfg = NECFConfig(seed=1000 + seed)
for level, factory in [(1, NECFExperiment.level1_only),
(2, NECFExperiment.level2_adaptive_coupling),
(3, NECFExperiment)]:
exp = factory(cfg)
history = exp.run_batch()
results[level].append(history.snapshots[-1].r)
r1, r3 = np.array(results[1]), np.array(results[3])
t, p = ttest_ind(r3, r1)
print(f"L3 vs L1: t={t:.3f}, p={p:.4f}, d={( r3.mean()-r1.mean())/np.sqrt((r3.var()+r1.var())/2):.3f}")A GitHub Actions workflow (.github/workflows/daily_necf_research.yml) runs once per day at 06:00 UTC and performs a real numerical experiment on the NECF substrate, writing the results to docs/sessions/. Seven analysis types rotate by day-of-year modulo 7:
| Topic index | Analysis |
|---|---|
| T0 | Synchronization onset and critical coupling — sweep |
| T1 | Boltzmann temperature scan — optimal |
| T2 | Identity curvature stability landscape — phase diagram in |
| T3 | Lyapunov spectrum via continuous QR decomposition |
| T4 | Epistemic contagion rate constant — two-group mixing time vs |
| T5 | Free energy topology — attractor basin counting and escape rates |
| T6 | Ablation study — Level-1 vs Level-2 vs Level-3 comparison |
Each session generates a markdown file with:
- Full parameter specification and seed
- LaTeX-formatted mathematical derivation of the relevant theory
- Numerical results table
- Comparison to analytical predictions where available
- Interpretation and connection to the broader NECF framework
The workflow uses no LLM and no external API — all content is computed from first principles using NumPy and SciPy. The commit message encodes the key numerical result, e.g.:
necf(NECF-2026-077-T6): ablation level comparison [L3_r=0.0399 L1_r=0.0335 p=0.2852 d=0.3120]
See docs/INDEX.md for the full session archive.
These are not future work items — they are current, known gaps in the architecture that affect the interpretation of all results:
No task interface. The field has no mechanism for receiving structured input or producing structured output. All experiments are self-contained dynamical characterizations. Whether the field's synchrony and rule diversity are relevant to any task-level performance is currently unknown.
Short run lengths. The contagion timescale at
Small
Lyapunov proxy accuracy. The masked
Analytical gap. The Kaplan–Yorke dimension formula
No comparison to learned baselines. Level-1 and Level-2 ablations are the only baselines. A comparison to a gradient-trained RNN or a transformer-based adaptive system on the same substrate task would significantly strengthen the ablation.
The following phases are planned but have not yet begun. Timelines are estimates only.
Phase 1 — Longer runs and scaling study (next 4–6 weeks)
Run ablation at
Phase 2 — Task interface (6–12 weeks) Design a perception layer that maps discrete input patterns to structured phase perturbations, and a readout mechanism that extracts categorical decisions from the order parameter. Apply to a simple pattern classification task.
Phase 3 — Learned transformation spaces (12–20 weeks) Replace the fixed DSL primitives (from the companion LAteNT project) with embeddings learned from ARC-style input-output pairs. This connects NECF's rule-field dynamics to the program synthesis literature.
Phase 4 — Cross-domain generalization measurement (20–28 weeks)
Train on Task Domain A, validate on Domain B, test on Domain C (entirely unseen transformation types). Measure transfer rates as a function of
Phase 5 — Publication (28–32 weeks) Target: NeurIPS 2027 Workshop on Emergence in Complex Systems, or a journal submission to Physical Review E (dynamical systems track) for the mathematical results.
Benettin, G., Galgani, L., Giorgilli, A., & Strelcyn, J.-M. (1980). Lyapunov characteristic exponents for smooth dynamical systems and for Hamiltonian systems. Meccanica, 15, 9–30.
Berner, R., Gross, T., Kuehn, C., Kurths, J., & Yanchuk, S. (2023). Adaptive dynamical networks. Physics Reports, 1031, 1–59.
Finn, C., Abbeel, P., & Levine, S. (2017). Model-agnostic meta-learning for fast adaptation of deep networks. ICML 2017.
Friston, K., et al. (2017). Active inference and learning. Neuroscience & Biobehavioral Reviews, 68, 862–879.
Friston, K. (2010). The free-energy principle: a unified brain theory? Nature Reviews Neuroscience, 11(2), 127–138.
Ha, S.-Y., Kim, D., & Zhang, X. (2016). On the complete synchronization of the Kuramoto phase model. SIAM Journal on Applied Dynamical Systems, 15(1).
Kaplan, J. L., & Yorke, J. A. (1979). Chaotic behavior of multidimensional difference equations. Lecture Notes in Mathematics, 730, 204–227.
Klyubin, A. S., Polani, D., & Nehaniv, C. L. (2005). Empowerment: a universal agent-centric measure of control. IEEE Congress on Evolutionary Computation, 128–135.
Kuramoto, Y. (1975). Self-entrainment of a population of coupled non-linear oscillators. International Symposium on Mathematical Problems in Theoretical Physics.
Parr, T., Pezzulo, G., & Friston, K. J. (2022). Active Inference: The Free Energy Principle in Mind, Brain, and Behavior. MIT Press.
Pearl, J. (2009). Causality: Models, Reasoning, and Inference (2nd ed.). Cambridge University Press.
Prigogine, I. (1977). Self-Organization in Non-Equilibrium Systems. Wiley. (Nobel Lecture).
Salge, C., Glackin, C., & Polani, D. (2014). Empowerment — an introduction. Guided Self-Organization: Inception, 67–114. Springer.
Strogatz, S. H. (1994). Nonlinear Dynamics and Chaos. Addison-Wesley.
Strogatz, S. H. (2000). From Kuramoto to Crawford: exploring the onset of synchronization in populations of coupled oscillators. Physica D, 143(1–4), 1–20.
Author: Devanik · B.Tech ECE '26, NIT Agartala Samsung Fellowship · Indian Institute of Science
This is an independent research project in active development. Feedback, questions, and collaboration proposals are always welcome.
License: Apache License Version 2.0, January 2004 · Status: Beta