# Shared activities, private paths and useful operating margins

Example for **Exact common-activity compatibility for autocatalytic junction–path assemblies: boundary reduction, a rational decision algorithm, and operating certificates**, manuscript entry 33, SHA-256 `c71bb73dd23e95817ca599f6a14b3fcb7ca4ec611d6549e411292a3aa23b80c0`.

Each selected core has two reversible reactions, Xu <-> Xv and Xv+F <-> 2Xu. A core is productive when both of its internal species have positive net production. Several cores can each work alone yet fail together because a shared species must have one activity in every reaction. The paper eliminates private path interiors exactly, leaving inequalities only in shared junction activities, and then reconstructs a rational common state.

This package implements that reduction, exact rational reconstruction, a nonlinear real-arithmetic decision backend, a linear sufficient construction and fixed-state operating certificates. These are **static compatibility calculations**. They do not establish that a prepared state persists, is reached, or is a steady state.

## Run

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
python example.py --input assembly.json --output custom_outputs
```

The default run takes seconds and writes exact current tables, fixture inputs/results, operating slices, representation-size diagnostics and two figure pairs. Seven scientific test groups cover polynomial identities, strict endpoints, near-boundary reconstruction, malformed decompositions, solver outcomes, nongraded constructions and operating bounds. A clean downloaded package is checked against its saved scientific JSON/CSV.

## Model and inputs

Edit the top of `example.py` for the weighted shortcut factors, prepared state, common lower activity, uncertainty widths and solver limits. All model coefficients and bounds use integers or rational strings; floating-point model inputs are rejected. The nominal factors (9,1),(9,1),(2,1) and activities (99/100,593/600,3551/3600) are the paper's exact illustration, not measured kinetic parameters.

At unit food activity, a core's currents and net production are

    p = a*(x-y),       q = b*(y-x*x)
    source production = 2*q-p
    target production = p-q.

Both factors multiply the two directions of their own reversible channel. They are barrier conductances, not separate forward and reverse equilibrium ratios. Doubling both a and b doubles currents while preserving compatibility. Every core is checked individually; productive sums over an entire assembly do not substitute for core-wise productivity.

`Core` provides literal currents and lower/upper response functions G=(a*x+2*b*x^2)/(a+2*b), F=(a*x+b*x^2)/(a+b). Productivity is exactly G(x)<y<F(x). A path composes these responses in physical order. `DirectedPath` supplies recursive evaluation, positive polynomial representation and rational reconstruction. `PolynomialResponse` keeps nonnegative integer numerator coefficients whose sum equals the positive denominator. After h edges its expanded degree is 2^h; no representation-independent complexity lower bound follows.

`Assembly` validates species, factors, boxes, oriented paths and edge coverage. The graph must have no loops, duplicate edges or antiparallel pairs. Paths have junction endpoints, no repeated vertices and private interiors used exactly once. Each selected edge belongs to exactly one path. Isolated species are allowed. Every species uses the common box [ell,1]; only junctions may have narrower closed boxes, including singletons. To give a private species its own box, promote it to a junction and split the path. Silently applying the two-response reduction with arbitrary private boxes would be incorrect.

An input file for the weighted two-junction example is:

```json
{
  "species": ["A", "B", "C"],
  "junctions": ["A", "C"],
  "ell": "9/10",
  "boxes": {},
  "edges": [
    {"u":"A", "v":"B", "a":"9", "b":"1"},
    {"u":"B", "v":"C", "a":"9", "b":"1"},
    {"u":"A", "v":"C", "a":"2", "b":"1"}
  ],
  "paths": [[0,1],[2]]
}
```

Here B is private, while A and C are shared by the two-edge path and direct shortcut. `fixture_inputs.json` groups the default cases by name; pass one contained case as a custom file. `nongraded_input.json` is already a standalone nine-species input. Invalid custom data raises a validation error rather than a compatibility verdict.

## Exact decision and reconstruction

`BoundarySolver` first asks whether the closed junction boxes and all strict composed response inequalities are feasible. It uses Z3 QF_NRA, as the manuscript's executable demonstration does. This is **not** the external one-block quantifier-elimination routine used in the paper's complexity proof, and no such runtime bound is claimed for this implementation.

For feasible data, the solver finds a positive dyadic slack, then bisects closed brackets while retaining one common real witness. It does not fix a rational coordinate prematurely. The code uses normalized response residuals y-Gpath(x) and Fpath(x)-y; their Lipschitz constant is bounded by 2^h+1. Once bracket widths are below slack/[4*(2^h+1)], their rational midpoints preserve positive residuals. Singleton boxes are preserved exactly.

For each private path, `reconstruct` blends every edge's lower and upper responses with one common parameter lambda. It bisects lambda, but keeps the prescribed last endpoint exact: only the prefix species are taken from the interpolation orbit. A rational last-edge margin supplies an explicit stopping budget. Merely approximating the endpoint independently on each incident path would give a shared species conflicting values; the merge rejects that.

The final `Assembly.check` reevaluates every activity box and every literal current/residual with fractions. `SAT` therefore carries an independently checkable rational witness. `UNSAT` is the exact backend verdict on the validated reduced formula; this package does not export an independent UNSAT proof object. `UNKNOWN` preserves timeout or query-budget exhaustion. `OUTSIDE_IMPLEMENTATION_LIMITS` reports the configured junction/path-length guard, not a mathematical obstruction. Defaults are six junctions, length eight, three seconds per query and 400 queries. No conclusion is obtained by discarding unresolved queries.

The weighted private-path case yields A=3789/4096, C=18433/20480 and reconstructed B=6746098527/7381975040. Its private reconstruction takes two bisections with lambda=1/4, within a proved budget of 21. This is a different valid state from the prepared operating point used in the figures. Treating all three species as junctions yields the paper's other rational witness. These witnesses and query counts agree with the supplied source demonstration for the pinned backend.

With every factor equal to one, the same shortcut graph is incompatible. The independent polynomial identity

    G(x)-F(F(x)) = x*(1-x)*(3*x*x+9*x+2)/24 > 0,  0<x<1

separates the shortcut lower bound from the path upper bound. A directed cycle is also incompatible because productive edges strictly decrease activity. Neither conclusion relies on a failed local optimizer.

## A sufficient construction without integer grading

`DeficitConstruction` sets xs=1-epsilon*ds with positive deficits. For each edge define

    U = (a+4*b)*du-(a+2*b)*dv
    V = (a+b)*dv-(a+2*b)*du.

The literal production identities are epsilon*U-2*b*epsilon^2*du^2 and epsilon*V+b*epsilon^2*du^2. Positive U,V and a sufficiently small epsilon give an exact certificate. `from_deficits` checks these inequalities, all boxes, and the resulting currents. `linear_program` uses exact rational linear optimization with sum(ds)=1 and a maximized common strict margin, then selects epsilon in the permitted interval. A failed sufficient certificate does **not** prove incompatibility. Junction boxes can prevent the returned deficits from furnishing a certificate even when some other deficits work.

The nine-species example has two unit-factor paths of lengths four and five between the same junctions. Exact published deficits with epsilon=1/10000 give minimum production **21/100000000**. A separate rational LP also produces a checked state. No integer rank can increase by exactly one along every edge, because it would have to increase by both four and five between the same endpoints. The construction thus extends beyond the earlier sufficient integer-grading class.

## Fixed-state operating certificates

`OperatingCertificate` starts from a checked prepared state. It provides three distinct uncertainty calculations; their maximal tolerances must not be combined as though independent.

At the paper's prepared state, the sharp radius of independent relative uncertainty in every a and b is **rho*=43/943**, approximately **4.5599%**. Every core remains strictly productive throughout the closed factor box exactly when rho<rho*. At equality a worst corner has zero production. Reoptimizing the state after a factor change is a different question. A radius of 4% leaves every residual at least **77/375000**.

`joint_rectangle` checks eight corners per core: the source-production minimum uses source activity high, target activity low and food low; the target-production minimum uses the opposite activity/food corner. Each is checked at all four factor corners. Monotonicity in activity/food and affine factor dependence make these checks necessary and sufficient for the **simultaneous** positive rectangle. At 4% factor uncertainty, activity errors +/-1e-6 and food fixed at one, the minimum of all 24 rational corner values is **847959991/4687500000000 >0**. Food intervals can also be supplied.

`food_window` intersects the exact open food intervals of the cores. With activities and factors fixed at the prepared point, the result is

    14814/14825 < food activity < 88859/88775.

At either endpoint one core has zero production. More food at this fixed state can overdrive one channel relative to the other. This is not a claim that increasing supply harms a state allowed to change. The identity x=f*z transforms food activity f into unit food with factors (a,b*f) and all activities/boxes divided by f; the junction–path theorem applies only if those transformed boxes meet its hypotheses.

`instantaneous_budget` sums incident productions at each species and reports the strict dilution threshold for the expressly specified field xdot_s=P_s-(D+ds)*xs. With no degradation at the prepared state it is **D<307/44550**, about 0.00689113 in the normalized inverse-time unit. Total internal production equals total food consumption, **2893/120000**. This is an instantaneous derivative calculation, not a positive equilibrium, invariant box or finite-time growth guarantee. Isolated species contribute zero production and therefore prevent strictly positive growth under nonnegative loss.

## Physical scope and reuse

Activities are dimensionless relative to chosen reference concentrations. A concentration scale c* and flux scale J* give time scale c*/J*. No metabolite, enzyme mechanism or calibrated rate range is assumed. For a mass-balanced interpretation of the doubling step, food and resident species must have the same elemental composition and charge, for example different isomers; equal molecular mass alone is insufficient.

Use `Core` and `DirectedPath` for other positive factors, `Assembly` for supplied decompositions, `BoundarySolver` for exact witness searches, and the operating/deficit classes for preparation margins. The code does not find an optimal decomposition, support shared physical reactions between cores, or claim general dynamics from static compatibility. Extending the model requires preserving the literal activity monomials and shared species identities.

## Provenance and license

The PDF is unchanged. The example independently implements the manuscript constructions and replays its rational operating values; no private proof workspace is required. Metadata hashes the source and outputs and records the pinned solver version. Lean and historical verification receipts are not rerun.

MIT is proposed for this original companion code, pending the owner's license decision. This README grants no license and does not alter manuscript or dependency rights.
