# MCC 0.1 — numerical methods and behavioral semantics

## Scope

The workbench is a simulation of a shared programming interface for a finite class of lattice dynamical systems. “General” means a program can be interpreted by the three supplied model adapters. It does not mean every material can realize the interface, or that the language is Turing complete.

Every quantity is dimensionless. The three adapters do not describe three chemically, biologically or mechanically calibrated materials. They are different mathematical models whose observables share an interface.

## Pipeline

MCC source → syntax and bound checks → structured constraint IR → graph and target construction → model adapter → integration → readout and conformance.

The source selects domain, target, initial condition, memory strength `a`, local coupling `k`, template density and amplitude, optional uniform pulse, Gaussian noise, time horizon and target-error threshold. No arbitrary source code is evaluated. Source fingerprints use FNV-1a for identification; they are not cryptographic integrity proofs.

The compiler constructs a four-neighbor lattice. Sealed boundaries omit outside neighbors (no-flux graph boundary); periodic boundaries wrap. Deleted sites have no dynamics and no links. Grid spacing is 1 in model units: increasing the number of sites changes the modeled system rather than automatically refining a fixed physical PDE domain.

## Target and input

The binary goal is `z_i ∈ {−1, +1}`. A ring, disk, bands, uniform bit or arbitrary bitmap determines the goal. Coordinates are normalized independently by each domain dimension. Bitmap values are sampled at site centers with nearest-neighbor resampling.

A seeded Bernoulli mask `m_i ∈ {0, 1}`, with probability `density`, determines persistent guide sites. The actual fraction differs slightly from the requested probability unless density is 0 or 1.

The applied local input is:

```text
b_i(n) = guideEnabled × strength × m_i × z_i
       + driveEnabled × writeStrength × 1[n < writeUntil]
```

An encoded pattern therefore consumes a known template representation. The simulation never secretly reads the target to reset or repair a site. The target enters dynamics only through the explicitly constructed `guide` array. The uniform write pulse does not consult the target at all; LOW requires a negative write pulse.

`Remove template` sets `guideEnabled = false` from that tick onward. Reset restores the compiled template. Conformance's `noDrive` ablation disables both the template and the pulse from the initial state.

## Three model adapters

For surviving neighbors `N_i`, `Lx_i = Σ_{j∈N_i}(x_j − x_i)`.

### Bistable medium

```text
dx_i/dt = a(x_i − x_i³) + k Lx_i + b_i
```

This is a nonconserved, overdamped bistable field. With fixed biases and no noise it descends the discrete potential:

```text
U = Σ_i a(x_i² − 1)²/4
  + Σ_undirected edges (k/2)(x_i − x_j)²
  − Σ_i b_i x_i
```

That potential is an abstract model function, not calibrated physical energy. It is related to Allen–Cahn dynamics, not a two-species chemical Turing system.

### Elastic lattice

```text
dx_i/dt = v_i
dv_i/dt = a(x_i − x_i³) + k Lx_i + b_i − 2.4 v_i
```

Mass is normalized to 1. Damping is fixed at 2.4. Each site has displacement and velocity, so inertia and relaxation differ from the first model. Missing sites remove springs. No physical spring geometry or stress calibration is claimed.

### Regulatory lattice

```text
dx_i/dt = tanh((1 + 1.2a)x_i + k Lx_i + b_i) − x_i
```

The linear decay constant is normalized to 1. The signed state and saturating self-activation approximate a generic rate model. They do not represent literal gene concentration, membrane voltage, or a measured transcription network. Mapping `a` to a self-activation gain preserves a useful bistability interface, not the microscopic equations of the other adapters.

## Numerical integration

The deterministic state update uses Heun's method, an explicit second-order Runge–Kutta method:

```text
k1 = f(s_n, b_n)
s_trial = s_n + dt k1
k2 = f(s_trial, b_n)
s_next = s_n + (dt/2)(k1 + k2)
```

The pulse and masked guide are constant within each tick. For the mechanical model `s = (x, v)`, and both derivatives are evaluated together.

Then apply an independent Gaussian increment `σ sqrt(dt) ξ` per surviving site, to `x` for the medium/regulatory models and to `v` for the mechanical model. This is a split deterministic RK2 plus additive Euler–Maruyama update; no second-order stochastic accuracy claim is made.

The language restricts `dt` to [0.005, 0.05], coupling and memory strength to [0, 2], and guide amplitude to [0, 3]. These are practical validated bounds for the supplied presets, not a proof of stability for every possible program. A nonfinite value or state magnitude above 100 halts integration with an error instead of silently clamping the underlying state.

The state arrays use float64. Readouts alone are bounded. PRNG streams use the same 32-bit Mulberry32 transformation with separate derived seeds for initialization, guide mask, continuous noise and intervention selection. Gaussian values use Box–Muller. Equal seed and domain yield matched initial states and masks across adapters; the response to noise need not match because the perturbation enters different state variables.

## Measurements

`y_i = clip((x_i + 1)/2, 0, 1)` and target readout `z_i' = (z_i + 1)/2`.

- **MAE:** mean `|y_i − z_i'|` across all original sites. Each deleted site contributes error 1. Overshoot is saturated by the readout and is not a stability certificate.
- **Contract:** current MAE is strictly below the program's threshold. The live indicator is an instantaneous measurement; it is not a proof of temporal invariance.
- **State agreement:** fraction of original sites whose readout is on the correct side of 0.5. Deleted sites fail.
- **Quality:** `Q = 1 − MAE`.
- **Recovery:** after a scramble or deletion at tick `n_d`, `(Q(n) − Q_after)/(Q_before − Q_after)`. This is undefined when immediate quality loss is at most 0.0001. Values may exceed 1 if quality improves beyond the original state, or be negative if it worsens.
- **T90:** first crossing of recovery 0.9 that persists for 10 consecutive numerical ticks. The value is the start of that sustained interval in dimensionless time. Subsequent losses do not erase a previously observed T90. A new state-damage intervention replaces the recovery reference.
- **Activity:** accumulated deterministic `mean(|Δx|)`; no claim is made that this is computational work or energy.
- **Input proxy:** accumulated `dt × mean(b_i²)` over surviving sites, with the original-site count as denominator. It is neither mechanical work nor electrical energy; it does not count sensing, fabrication, computation or reset.

Plots sample every 5 ticks, plus resets and interventions. History retains up to 4,000 samples. A run can continue beyond its original finite horizon; its snapshot contains the actual tick.

## Perturbations

State scramble selects an exact floor of 20% of surviving sites without replacement and draws new states uniformly in [−1, 1], resetting their velocity. The location selection and drawn values are seeded. Scramble does not consult the target, so it can occasionally improve quality.

Deletion selects 10% of surviving sites without replacement, permanently marks them absent, and removes their neighbor links. It is not regrowth. The score remains over the original grid so deletion cannot hide failures by reducing the denominator.

The brush scrambles a small circular neighborhood at the pointer; its explicit site IDs and tick are in the intervention ledger. The brush is a state intervention, not a template editor. The separate target editor changes the program and recompiles from initial conditions.

## Conformance protocol

For each model, independently run seeds 17, 43, and 71:

1. Integrate the same source for the requested horizon.
2. Record final clean measurements.
3. Scramble 20% of surviving states.
4. Run 250 additional ticks and record error, contract result, recovery fraction and T90.
5. In a separate run with the same seed, disable all external drive from the beginning; integrate for the original horizon and record the ablation result.

Summaries use arithmetic mean and sample standard deviation (n = 3). This tiny sample is an engineering smoke test, not a statistical proof of robust generalization. All seed-level measurements are exported.

Cross-model field distance is the MAE between pairs of final bounded fields using seed 17. It is a finite common-output comparison, not a claim about matching microscopic states, full trajectory equivalence, common physical time, or equal energy use.

## Bounded inverse design

For the selected model and spatial target, enumerate:

- density: 0.35, 0.65, 1.00;
- strength: 0.65, 1.10, 1.60;
- coupling: 0.25, 0.70.

There are 18 candidates. The other program parameters remain unchanged. Evaluate every candidate on training seeds 17 and 29 for the original horizon. Rank by:

```text
objective = mean_training_MAE + 0.012 × density × strength²
```

This combines task error and a simple dimensionless drive-design proxy. A denser weaker template may win over a sparse strong one. The search is not a general-purpose optimizer, does not synthesize a material composition or arbitrary local rule, and does not optimize actual energy.

Evaluate the winner on unused seeds 43 and 71. Do not retrain after seeing those results. The interface reports test error and pass count even when the candidate fails. Use the winner only by explicitly applying its constraints to its original source.

## Persistence and reproducibility

A JSON snapshot carries source, source fingerprint, model, seed, current tick, states, velocities, alive mask, guide values, random-stream state, input flags, cost counters, history and damage reference. Import validates version, dimensions, finite state values and source identity before continuation. A snapshot is user-editable data, not a signed or adversarially tamper-proof record.

The source save in browser storage is a convenience, not a backup. Export experiments you want to keep. Numerical streams are deterministic in the supplied JavaScript engine; bitwise results across different JS engines are not guaranteed because transcendental functions may differ slightly.

## What remains unimplemented

Turing-completeness proofs; formal semantic equivalence; causal-state discovery; arbitrary substrate compilation; material synthesis; automatic discovery of new equations; hardware calibration; complete physical energy accounting; dynamic topology growth; true chemical reaction kinetics; biological or consciousness models; and any unknown-coupling or paranormal claim.

## Primary scientific context

- Allen, S. M. & Cahn, J. W. (1979). *A microscopic theory for antiphase boundary motion and its application to antiphase domain coarsening.* https://doi.org/10.1016/0001-6160(79)90196-2
- Gardner, T. S., Cantor, C. R. & Collins, J. J. (2000). *Construction of a genetic toggle switch in Escherichia coli.* https://www.nature.com/articles/35002131
- Turing, A. M. (1952). *The Chemical Basis of Morphogenesis.* https://www.dna.caltech.edu/courses/cs191/paperscs191/turing.pdf

These motivate the research; they do not validate the chosen adapter mappings as calibrated physical implementations.
