Lesson 1The Graph Laplacian — Diffusion's Discrete Twin
You know $\nabla^2 f$. On a regular grid, a scaled sum of neighbor differences approximates it. The combinatorial graph Laplacian $L=D-A$ has the opposite sign: it is the negative neighbor-difference operator, corresponding to $-\nabla^2$ up to grid scaling.
Given a graph $G = (V, E)$, define:
- $A$ — the adjacency matrix: $A_{ij} = 1$ if $(i,j) \in E$
- $D$ — the degree matrix: $D_{ii} = \deg(i)$, zero off-diagonal
- $L = D - A$ — the combinatorial Laplacian
The quadratic form tells you everything: $x^T L x = \sum_{(i,j) \in E} (x_i - x_j)^2$. This measures total variation across edges. Smooth signals (constant on components) have zero energy. Spiky signals (large differences across edges) have high energy.
Play with it
Click any node to deposit heat. Watch it diffuse along edges via $dp/dt = -\alpha L p$. The sidebar shows the Laplacian matrix and the current state vector in real time.
Notice what happens: total heat is conserved under pure diffusion (no decay). The constant eigenmode $\lambda_0 = 0$ is never damped. Heat spreads but never disappears. This changes in Lesson 2.
Lesson 2The SOMA Equation — Diffusion, Decay, Stability
SOMA's Medium evolves by three forces:
The decay term $-\gamma p$ breaks conservation. Without persistent sources, all traces fade to zero — this is biologically necessary. Pheromone trails that lasted forever would make the system rigid. The source term $S(t)$ represents agents depositing traces as they work.
Equilibrium
At steady state, $dp/dt = 0$:
The equilibrium exists and is unique because $\alpha L + \gamma I$ has all eigenvalues $\alpha \lambda_i + \gamma > 0$. The system is globally attracting.
Numerical stability
The full equation has Jacobian $J = -(\alpha L + \gamma I)$, with eigenvalues $-(\alpha \lambda_i + \gamma)$. A forward Euler step for the full equation is stable when $|1 - \Delta t(\alpha\lambda_i + \gamma)| < 1$ for every mode. This demo uses a split update: it injects sources using the requested $\Delta t$, applies exact exponential decay over $\Delta t_{\rm eff}$, then applies forward Euler diffusion over $\Delta t_{\rm eff}$. Its clamp bounds diffusion with $\Delta t_{\rm eff}=\min(\Delta t,0.9/(\alpha d_{\max}))$; that bound omits $\gamma$ because decay is handled separately.
For forward Euler on the full equation, Gershgorin gives $\lambda_{\max}(L) \leq 2d_{\max}$, so a sufficient bound is:
Play with it
Click to deposit. Adjust $\alpha$, $\gamma$, and $\Delta t$. The "destabilize" button cranks $\Delta t$ past the stability bound — watch what happens. Toggle the stability clamp to see SOMA's fix.
Lesson 3Stigmergic Agents — Coordination Without Communication
Termites build cathedrals without architects. The mechanism: indirect coordination through environmental modification. An agent modifies the shared medium; other agents respond to the modification, not to each other.
In SOMA, each agent computes the pheromone gradient at its current position:
Movement follows an $\varepsilon$-greedy policy: with probability $\varepsilon$, move randomly (explore). Otherwise, select a neighbor proportional to $\max(0, \partial p(v, u))$ (exploit).
A graph-dependent baseline
On a fixed graph, random-walk discovery time depends on topology, starting positions, and bug locations. It is a hitting-time and coverage problem, not the ordinary coupon collector: that formula assumes independent, equally likely draws from the full set. We therefore compare the two policies on the same seeded graphs, bug locations, and starting positions, and report empirical outcomes rather than a universal closed-form expectation.
Play with it
Run Random Walk (no pheromone, no gradient) and Stigmergic (agents deposit pheromone on discovery, follow gradients) side by side. The counter shows steps to find all bugs. The benchmark uses 30 fixed paired seeds and a 5,000-step cap per policy. It reports completion counts, median steps among completions, and paired wins, losses, and ties. These results describe this simulation setup, not a general performance guarantee.
Lesson 4Resolution & Homeostasis — The Anti-Inflammatory
Here's a problem: stigmergic agents pile on. Once a bug is found, its pheromone attracts more agents. They arrive, confirm the finding, deposit more pheromone, attracting even more agents. In immunology, this is a cytokine storm — an inflammatory cascade that damages the host.
SOMA's fix: resolution traces. After discovery, agents deposit an anti-inflammatory signal:
Agents sense $p_{\text{eff}}$, not raw $p$. Resolved areas become invisible even if they still have pheromone. Agents move on to unexplored territory.
Play with it
Toggle resolution on and off. Without it, agents cluster at the first discovery. With it, they spread out and find everything.
Lesson 5From Scalars to Sheaves — and the Road Ahead
Everything so far used a constant sheaf: each node carries a scalar (pheromone level), and the restriction maps are the identity. The full SOMA framework assigns each node a typed stalk:
The sheaf Laplacian $L_{\mathcal{F}}$ generalizes the graph Laplacian. Where $L$ compares scalar values across edges, $L_{\mathcal{F}}$ compares stalks through restriction maps and measures disagreement via the coboundary operator. The spectral gap of $L_{\mathcal{F}}$ governs convergence speed — Hansen & Ghrist (2021) proved exponential convergence to global sections.
Think of it this way: the constant sheaf says "every node speaks the same language." The full sheaf says "every node has its own dialect, and the restriction maps are the translation dictionaries." Sheaf cohomology $H^1(K, \mathcal{F})$ describes cohomology classes of cocycles modulo coboundaries. A nonzero $H^1$ signals a global obstruction for the chosen sheaf, but does not diagnose a current SOMA state, establish local agreement, or locate a structural inconsistency. Turning it into a debugging tool would require a defined mapping from observed agent data to cochains and a validated way to interpret or localize the resulting obstruction.
The Roadmap
What follows is the mathematical territory ahead. Each item becomes a future interactive lesson.
Belief-Weighted Exploration: An Active-Inference Heuristic
The current prototype maintains a Beta belief for each node and labels this score Expected Free Energy. It combines expected bug probability, resolution damping, belief variance, and inverse-visit novelty, then samples neighboring actions with a softmax over the negative score:
This is a hand-designed proxy. Variance times novelty is not expected information gain: the implementation does not predict possible observations and average their posterior uncertainty reduction. It also does not minimize variational free energy $F$ to infer a posterior or derive an action score from expected future free energy.
For comparison, variational free energy for approximate posterior $q$ is:
Minimizing $F$ with respect to $q$ is an inference objective. Expected free energy scores candidate policies using predicted future outcomes; formulations can include both pragmatic and epistemic terms. These quantities are related in active-inference methods, but they are distinct and neither is computed by this prototype's node score.
Interactive lesson concept: Compare the current variance-and-novelty heuristic with $\varepsilon$-greedy exploration. A later model could test whether predicted information gain improves coverage of isolated nodes, with its assumptions and results shown explicitly.
Belief Markets: Truth via Price Discovery
Agents deposit belief traces with confidence stakes. Conflicting beliefs trigger a tatonnement auction:
Cole & Fleischer (2008) proved polynomial convergence for weak gross substitutes. Market prices converge to collective credence — a 10% accuracy gain over single-shot baselines (Gho et al., 2025).
Interactive lesson concept: A market simulator. Multiple agents submit beliefs with stakes. Watch the tatonnement iterate. See prices converge. Compare market consensus to individual agent accuracy.
Immune Selection: Evolving the Agent Population
Successful agents clone with mutation. Failed agents are culled. The population evolves toward problem-solving fitness:
This is CLONALG (de Castro, 2000) applied to agent configurations. Affinity maturation = accelerated mutation near solutions. Negative selection = kill agents that react to "self" (the system's normal operating state). Memory cells = dormant solution templates.
Interactive lesson concept: A population dynamics visualization. Watch agent parameter distributions shift over generations. Successful exploration rates and deposit intensities propagate. Failed configurations die out. See the population converge.
Cohomological Diagnostics
The full SOMA Medium is a cellular sheaf $(K, \mathcal{F}, L_{\mathcal{F}})$ where $K$ is a dynamic simplicial complex and $\mathcal{F}$ assigns typed stalks. The master equation becomes:
Where $L_{\mathcal{F}}$ is the sheaf Laplacian and $u(t)$ is urgency amplification from deadline-aware traces. The urgency function is exponential: $u(t) = \alpha \cdot e^{\beta(t - t_{\text{deadline}})}$.
Sheaf cohomology can describe global obstructions to gluing compatible local data. A nonzero $H^1$ means a nontrivial cohomology class exists; it does not by itself identify particular edges or prove that agents locally agree while globally contradicting one another. A diagnostic would need a specified sheaf, observed cochains, and a method that maps a computed obstruction back to interpretable evidence.
Interactive lesson concept: A graph where each node has a vector-valued stalk (not just a scalar). Restriction maps enforce consistency across edges. Visualize the cohomology: highlight edges where local agreement breaks down. Watch the sheaf Laplacian drive the system toward consistency.