Skip to content

Trusty Neurocoder

Neuro-Symbolic Agents for Verified Scientific Code Generation.

Overview

Trusty Neurocoder combines LLM-based agentic workflows with Neuro-Symbolic Abstract Machines (NSAMs) to enable verified scientific code generation, optimization, and surrogate construction.

NSAMs are neural networks structurally equivalent to programming language interpreters. They enable principled compilation of symbolic programs into neural architectures and decompilation back to interpretable code. LLM agents bridge the gap between real-world scientific codebases and the declarative representations NSAMs require.

Notebooks

Foundations

Notebook Description
01 - Cajal Intro Boolean functions compile to matrices; iteration as recurrent neuron
02 - Exponential Decay Learn scalar ODE rate constant from data

Earth & Environment

Notebook Description
03 - Unknown Function MLP learns unknown moisture response; symbolic regression recovers Hill equation
04 - CENTURY-Lite 3-pool model, 2 unknown functions learned simultaneously, mass conservation verified

DOE Science Domains

Notebook Description
05 - Decay Chain 4-isotope radioactive decay chain; learns unknown branching ratios exactly
06 - Battery Degradation SEI growth + capacity fade; recovers parabolic growth law via symbolic regression
07 - Chemical Kinetics Reversible reaction A⇌B; recovers Arrhenius rate k=2.0·exp(-5.0/T) from equilibrium data
08 - EcoSIM Kernel Case Study Soil-carbon decomposition kernel extracted from EcoSIM Fortran
09 - PFLOTRAN Relative Permeability Subsurface-flow constitutive relation as a structured surrogate
10 - Methionine Cycle Regulated metabolic cycle (DTU Biosustain model); keeps stoichiometry exact, recovers SAM→CBS allosteric Hill activation, conservation to 1e-7
11 - Regulated Steady State Amortizes the regulated steady-state solve; exact moiety reduction (left null space of S), scales to 128 metabolites, ~95x surrogate speedup with conservation guaranteed
12 - Methionine Steady-State Fit Real methionine+folate network; finds the folate moiety from S's null space; differentiates through the steady state (implicit function theorem) to fit SAM→CBS / SAM→MTHFR allosteric constants from steady-state data
13 - Methionine Bayesian UQ Bayesian calibration with uncertainty, priors anchored to the real Maud methionine model; Gauss–Newton Laplace posterior surfaces the amp/Ka identifiability ridge (corr 0.99) that the point fit hid
14 - CBS MWC: Laplace vs HMC Faithful single-enzyme port (real Maud MWC rate law + priors, mM units); Laplace matches exact grid and HMC on informative data, and visibly misses the skewed L tail on data-poor designs
15 - Alzheimer's Aβ–Tau Core Compiles an SBML/Antimony-style AD reaction model (Aβ aggregation + tau phosphorylation) to a Cajal program; recovers the hidden amyloid→tau hyperphosphorylation coupling as Michaelis–Menten with both conservation laws (total Aβ, total tau) exact by construction

Quick Start

# Install
uv pip install -e ".[notebooks,docs]"

# Run all notebooks
just notebooks

# Serve docs locally
just docs

Architecture

┌──────────────────────────────────────┐
│  Layer 1: LLM Agent                  │
│  - Parses real scientific code       │
│  - Extracts algorithmic kernels      │
│  - Translates to Cajal programs      │
├──────────────────────────────────────┤
│  Layer 2: NSAM Compilation           │
│  - Cajal program → PyTorch RNN       │
│  - Learnable sub-expressions (MLPs)  │
│  - Backprop through compiled program │
├──────────────────────────────────────┤
│  Layer 3: Verification               │
│  - Structural invariants by design   │
│  - Symbolic regression (decompile)   │
│  - Mass conservation, positivity     │
└──────────────────────────────────────┘