# Equivalent reaction networks, exact obstructions and reactor dynamics

Example for manuscript entry 39, **Complex-balanced realizations of a coupled autocatalytic assembly: exact obstructions, an explicit disguised-toric locus, and global dynamics**, SHA-256 `ef9c1c93dfe470c759488cd4ad2a5352e81cd75b04412a78501fd68b13036770`.

Different reaction graphs can generate exactly the same deterministic concentration dynamics. This example constructs an alternative graph that is complex balanced: at its reference state, total incoming and outgoing reaction flux agree at every complex. It also evaluates the paper's exact criterion for when any such graph exists. Realizability, local stability and productive operation of an autocatalytic core are separate properties.

## Run and change inputs

Python 3.11 or newer:

```sh
python -m venv .venv
# Windows: .venv\Scripts\activate
# macOS/Linux: source .venv/bin/activate
python -m pip install -r requirements.txt
python -m unittest -v test_example.py
python example.py --output outputs
```

The default run takes a few seconds. The top of `example.py` contains six rate parameters, an exact stationary reference, positive initial states, time sampling, the paper's crossing-slice values, catalytic attachments and a parameter-grid resolution. Rational strings such as `'7/16'` preserve exact boundary decisions. Inputs and time are nondimensional mathematical examples, not measured reactor specifications.

After changing parameters, either update the exact reference or set `EXACT_REFERENCE=None`. The latter uses rational bisection on the admissible stationary branch, reports the resulting enclosure, and integrates the reactor. It does **not** construct an exact realization from a rounded root. If no admissible root exists, it raises a descriptive error; this is not a claim that no positive equilibrium exists below the nonnegative-current cut. The reusable reactor can still integrate such parameters directly.

Use `Parameters.from_stationary_design(A,B,z,u,v,e)` to design exact rational examples: it solves for H, both feed rates and the output rate, rejecting nonpositive parameters. This returns both the parameter object and the exact state. It is useful for generating new witnesses without treating a numerical equilibrium as exact.

## Literal model and components

Species are A, B, z and H. The thirteen directed reactions are

```text
A <-> B+z       rates 1,1
z <-> H         rates u,1
2z <-> H        rates v,1
0 <-> A         rates a,1
0 <-> B         rates b,1
B <-> 2A        rates e,e
H -> 0          rate d
```

Here 0 represents exchange with reservoirs at unit activity. `Reaction` holds the source and target exponent vectors and a rate constant. `MassActionNetwork` builds the literal stoichiometry, monomial rates, Jacobian and exact polynomial coefficients. Its integrator evolves log concentrations with an analytic transformed Jacobian, enforcing positive coordinates without clipping. It supports independent Radau and BDF runs.

The two coupled cores use `(A,B)` and `(z,H)` as their respective members. Their shared reactions make local core production different from accumulation in the whole open reactor. The full equations are

```text
A' = a - 2A + Bz + 2e(B-A^2)
B' = b + A - (1+z)B - e(B-A^2)
z' = A - Bz - uz - 2vz^2 + 3H
H' = uz + vz^2 - (2+d)H.
```

`Parameters` owns the tied six-parameter family, stationary reduction, exact membership criterion, conservative permanence bounds and rational stationary-design constructor. These family-specific formulas must not be applied after arbitrarily breaking the tied rates. `BalancedRealization` owns the alternative graph and verifies its complete coefficient map, not just its value at equilibrium. `SupportingCertificate` handles the geometric obstructions independently. `CatalyticAttachment` composes private-species modules with either graph.

## Exact membership without searching reaction graphs

At a positive stationary state define fork current K=A-Bz and reverse-channel current J=e(B-A^2). The paper proves that an equivalent complex-balanced realization exists exactly when

```text
K >= 0,    J <= B.
```

Competing graphs may contain any finite number of auxiliary complexes of any molecularity. The obstruction is therefore stronger than failure of a search on eight selected complexes.

To eliminate the stationary state, let c=a+2b and s=a+b. The code computes

```text
B(z)=c/(z+2)
K(z)=[v(1+2d)z^2-u(1-d)z]/(2+d)
A(z)=z B(z)+K(z)
H(z)=(uz+vz^2)/(2+d)
E(z)=b-(1+e)B(z)+K(z)+e A(z)^2
z0=max(0,u(1-d)/(v(1+2d)))
t=c(e-1)/(e s^2)-2.
```

Membership is `E(z0)<=0` and at least one of `e<=1`, `t<=z0`, or `A(t)<=s`. The last expression is evaluated only when `t>z0`, avoiding invalid denominators. Both equality boundaries are included. The criterion is evaluated with exact fractions, including all 4,941 default grid points; colored cells merely visualize those points and do not certify interpolated boundaries. The safe region d>=1,e<=1 is included.

On z>=z0, E is strictly increasing. `admissible_root` uses the analytic upper bracket `z0+1+(1+e)c/b` and exact rational sign tests, returning a bracket after the requested number of bisections. A root there is not automatically realizable: its reservoir budget still matters. The code does not enumerate equilibria on z<z0 or infer uniqueness there from the admissible-branch monotonicity.

## Constructive witness and obstruction certificates

The eight source complexes are `(0,A,B+z,z,H,2z,B,2A)`. `BalancedRealization` computes the paper's nineteen flux entries, keeps only positive edges, and divides each flux by its source monomial at the exact reference state. It verifies nonnegative fluxes, incoming/outgoing balance at every complex, and exact equality of all polynomial coefficient vectors with the literal reactor. This proves equality of vector fields at every state, with the same concentrations and time scale. Zero-flux edges are legitimately absent on equality boundaries.

At the default rational example the reconstructed graph has 16 active edges. K=3/16 and B-J=3/8. Both AB production margins `(-K+2J,K-J)` equal 1/16. The zH margins at stationarity are `(-K,dH)`, so that core cannot be strictly productive on the realizability locus.

The two supporting certificates assign a slope h_i and potential pi_i to each source exponent y_i. All 64 ordered-pair inequalities `h_i dot (y_j-y_i)+pi_j-pi_i>=0` are checked for each certificate. Their stationary pairings equal K and 2(B-J). `extension` evaluates the maximum of the prescribed affine pieces at additional exponents and selects an active piece. The supporting inequality follows from that maximum construction for any finite added set; the demonstration checks three additional complexes and the tests check 25 more. Those finite checks illustrate the general argument rather than proving an infinite claim by sampling. Auxiliary complexes have zero polynomial drift and cannot repair a negative certificate budget.

`realization.csv` includes all nineteen entries, exact rational rates, exact reference fluxes and presence flags. The JSON includes all source-pair slacks. An exact witness constructor rejects even a slightly rounded nonstationary reference, instead of silently accepting it.

## Stability, permanence and the crossing slice

The paper proves permanence for every positive parameter vector, independently of realizability. The code returns its explicit conservative constants. With

```text
L=(e+3/2)A+(2e+1)B+z+3H/2
C=(e+3/2)a+(2e+1)b+(u+2)^2/(8v)
rho=min(1/(e+3/2),1/(2e+1),1,d),
```

the bound is `L'<=C-rho L`. Consequently all coordinates eventually stay below M=2C/rho. Sequential positive lower bounds from the two feeds and production chain give an explicit eventual floor. These are eventual bounds, with initial-state-dependent entry times; they are not necessarily tight operating ranges.

On the realizability locus, the Horn–Jackson entropy `G=sum[x_i log(x_i/xstar_i)-x_i+xstar_i]` decreases strictly away from the balancing state. Full stoichiometric rank and permanence give the paper's conventional global-attraction conclusion for every positive initial state. The entropy is not a barrier that diverges when a coordinate tends to zero; permanence supplies the needed boundary control. Numerical traces illustrate the theorem rather than establish global attraction by sampling. Entropy values below 1e-16 use a display floor in the plot only; raw numerical values remain in the CSV.

The exact slice is

```text
p_eta=((19-2eta)/25,(eta-4)/25,1,5,eta,3),  4<eta<19/2
xstar=(2/5,1/5,1/5,2/25).
```

It is realizable exactly when eta<=5, strictly AB-productive exactly when 9/2<eta<9, and locally asymptotically stable throughout the whole slice. The script derives the Jacobian from the literal symbolic field and verifies positive coefficients of all required quartic Hurwitz expressions. At eta=5, an exact quadratic entropy certificate has positive leading minors `(25,2199/16,55245/16,31001025/256)`.

The paper additionally proves an open globally attracting nontoric neighborhood, but supplies no explicit radius. This example does not label eta=11/2, eta=8 or every off-locus parameter globally stable on that basis. The boundary is not a local-stability or productivity boundary.

## Composable private attachments

An attachment `Y <-> Y+W` has base-only catalyst exponent Y, forward rate alpha and reverse rate beta. It leaves the base field unchanged and adds `W'=x^Y(alpha-beta W)`. Its equilibrium is Wstar=alpha/beta, and

```text
W(t)-Wstar = (W(0)-Wstar) exp[-beta integral_0^t x(s)^Y ds].
```

`CatalyticAttachment.compose` accepts any finite list, appends private species, and builds ordinary mass-action reactions. Coincident contributions are combined by the coefficient and balance calculations. Composing with the realizing graph preserves exact field equality and complex balance. The code verifies these identities and exports an augmented trajectory. The paper's invariance theorem allows arbitrary competing mixed complexes; it relies on zero base drift of the attachments. Feedback modules that change base concentrations do not satisfy this hypothesis.

## Evidence and reuse scope

Seven test groups cover literal equations, exact membership boundaries and brackets, supporting planes, positive/negative-current realization construction, permanence comparisons and slice stability, entropy/independent integration, and catalytic attachments. Default Radau/BDF trajectories agree within about 1.6e-9 in concentration. The source and realization have exact polynomial equality; solver agreement is a separate numerical check.

The supplied PDF and `Disguised_Toric_CAC_Assemblies_arxiv/check_paper.py` informed the constants and identities. This package does not rerun Lean. Trajectory theorems, arbitrary-auxiliary-complex reasoning and attachment closure use the stated mathematical arguments in the paper, not a new formal proof. Deterministic field equality does not identify stochastic jump processes or confer a product-form stationary distribution on the original graph.

MIT is proposed for the example code, pending owner approval; this README grants no license and does not alter manuscript rights.
