# Certified one-bit chemical computation

This standalone model connects chemical correction, productive readout and inheritance on the same trajectory. Making product consumes the same food as replication; correcting a minority consumes fuel and creates waste that enables reverse correction. Both daughters must remain usable after harvesting and one complementary partition.

## Run and explore

Use Python 3.11+ in a virtual environment:

```sh
python -m pip install -r requirements.txt
python -m unittest -v
python example.py --output outputs
```

The constants at the top of `example.py` specify rates, inventories, initial majority/minority counts, deadline, recovery, partition, continued-lineage length and random seed. Defaults reproduce the wide WO regime at its adverse kinetic/operation endpoints. They are abstract count-model placeholders, not experimentally calibrated inputs. For regime F use fuel 64, minority allowance 2, initial minority 2, reverse correction `5/10**11`, prefix duration `1/10**7`, and `REGIME_NAME='F'`.

Edits drive the literal model. `literal_source.json` lists every reference-certificate premise and reports no applicable reference lower bound when one fails. The core certificates, four one-minority bounds and all 216 finite-fuel restart checks are fixed reference calculations, clearly separate from edited-source trajectories. A parameter outside the paper box is not automatically a failed device; it is outside this certificate. The pure-core class supports other inventories and thresholds, but transferring its result to a new full-source contract requires rechecking the repair and departure bounds.

## Reusable components

* `chemistry.py`: immutable reaction/rate objects, all seven reversible pairs, exact count propensities and a Gillespie simulator with an explicit incomplete result at its event budget. No trajectory is scored as completed when that budget is exhausted.
* `BatchOperations`: product removal and independent recovery, one molecule-wise complementary partition, then food/fuel refill and waste removal. It never reads the encoded bit. The scoring method uses a label only to evaluate the requested joint event.
* `ProductRetention`: retain both daughters above a selected-product gate, otherwise retain each by an independent coin. It reads product counts, not resident labels.
* `core.py`: exact pure-core enumeration, complementary partition/collection payoff, bounded-integer uniformization, and weighted-cluster partition polynomials.
* `correction.py`: the embedded majority walk, unlimited-fuel consensus law, finite-fuel first-absorption/spent-fuel table, fixed-clock budgets and external selection bounds.

There is no required shared framework or external repository import. The integer algorithm is adapted from the manuscript checker; `provenance.json` records its origin and hash. The new implementation saves the complete lower vector and all newborn coordinates for inspection.

## Literal chemistry and operations

State order is `X,Y,F,PX,PY,H,W`. Replication `S+F -> 2S` and production `S+F -> S+PS` each have propensity `s*f`; their reverses have propensities `s*(s-1)/100` and `s*pS/100`. Leakage is first order. Correction `2X+Y+H -> 3X+W` has propensity `gamma*h*x*(x-1)*y`, with the label-swapped channel included. Reverse correction uses `beta*w*x*(x-1)*(x-2)`. Falling factorials have no extra factorial divisor.

Every channel preserves core mass `x+y+f+pX+pY` and fuel mass `h+w`. Reverse replication cannot consume the last resident. The simulator keeps every channel active for the entire batch; the proof's repair/core split is a comparison argument at a fixed time, not a switched physical protocol. Positive equilibrium activities are checked independently using deterministic mass-action powers, not the count factorials. Formal thermodynamic consistency does not constitute a full operating-energy account.

Harvest removes **terminal product stock**, not the count of forward production reactions. Reverse production may consume product. Recovery credits each removed molecule with the declared probability and discards the remainder. Each remaining molecule goes to daughter A or B in one draw, so the daughters are complementary. Refill adds only food, removes waste, restores fuel and assumes restored reference operating volume; residents are never supplied, selected or relabelled. Both daughter cores together require exactly `80 + harvested_product` food units in the reference system. Refill costs are charged before any retention discards a daughter.

The saved lineage always continues daughter A, chosen in advance. Both daughters are scored each round. Failures and out-of-region states are retained in the simulation rather than reset to a good preparation. The selection illustration starts ten mothers of each program and uses actual products/daughters and independent retention coins. These are seeded illustrations, not Monte Carlo estimates of the rare failure probabilities.

## Exact certificates

The pure core has 3,240 states `(n,p)` with `1 <= n <= 80` and `n+p <= 80`. Its payoff is the product of the probability of collecting at least four terminal product molecules and the probability that **one** binomial partition gives at least eight residents to each daughter. This product uses conditional independence of recovery and partition given the mother; it does not multiply unrelated trajectory guarantees.

The sparse row generator is uniformized at lambda 3216, with integer denominator 321600. An alternating-series lower bound on `exp(-1)` provides downward-rounded Poisson weights; each matrix iterate and block is rounded downward on scale `2**31`. The example checks nonnegative entries, row sums and both signed-64-bit accumulator bounds before 3,216 blocks. The recomputed minima are exactly `2147232289/2**31` for ideal operations and `2147153442/2**31` at partition 0.48/recovery 0.9, attained at `(8,0)`. The full vector is included. No floating-point matrix exponential or confidence interval supports this certificate.

Recovery monotonicity and the symmetric unimodal complementary-partition payoff reduce the operation continuum `[0.48,0.52] × [0.9,1]` to that endpoint. A parameter grid is not the proof. Fixed-time clock comparisons then subtract repair delay, suppressed prefix clocks and later leakage/reverse correction. The WO joint lower bound is about 0.999766315849, exceeding the advertised 0.9997. The Original regime also saves the paper's conservative loss allowance separately from the tighter directly evaluated budget.

The embedded correction direction depends on resident counts, not gamma or remaining fuel. Exact harmonic probabilities give wrong consensus `2**(-(r-3))` from two minorities. Finite-fuel propagation retains both absorbed and transient mass and records the jump on which each endpoint is first hit. Spent-fuel moments are **unnormalized**, so downstream reverse-correction loss is weighted by the actual successful paths.

Every one of the 216 admitted two-minority restart states is checked. The minimum is at resident total 10, minority 2, giving 0.9916452580485533… with imperfect operations. Correct absorption spends about 2.37 fuel units on average conditional on success, rather than all 64 available. The 127/128 ceiling is for the correction-only route at the worst state; it must not be read as a proved ceiling for every possible full-source trajectory.

A mixed `(8,2,70,0,0,64,0)` preparation has productive opposite-pair probability at least 0.0074873613014…, whereas a pure newborn's probability is at most 0.0000080000008. Before any minority appears in a pure newborn, correction is disabled and no waste exists to enable reverse correction; leakage is the only initiating channel. The sharper bounds give a ratio above 935. The rounded statement `0.0074 / 0.0000081` alone does not imply that ratio. These are bounds of opposite sense, not comparable sample frequencies or a universal two-label mutation kernel.

The exact external-selection result uses a union bound over the twenty chemical failures plus a binomial tail for independent retention coins. It does not assume chemical failures are independent. A preselected lineage has the conditional bound `q**rounds`; a complete binary tree requires accounting for its actual number of divisions, not substituting depth. The information display is the numerical Fano reading `1-h2(1-q)`, not a measured bit rate.

## Mechanistic and practical limits

Equal material count does not guarantee equal division safety. The exact cluster polynomial shows different risks for 32 monomers, 16 intact dimers and 8 tetramers. The tested elementary mechanism's first-association bound is only `56/(4e8)` at the stated short deadline. These checks demonstrate why matching an effective reaction rate does not transfer the monomer certificate; the example does not claim that all elementary mechanisms are impossible, or rerun the paper's separate 1,000-trajectory occupancy pilot.

The illustrative volume/time conversion exposes the extreme fourth-order kinetic demand. It is not a physical implementation. The counted material omits solvent, containment, compartment construction, separation apparatus, measurement reagents and volume-reset work. The finite-count one-minority mechanism is not invariant under arbitrary concentration-preserving volume scaling.

Seven tests cover reaction invariants and disabled channels, fresh core numerators, consensus harmonicity and fuel conservation, clock budgets and selection, complementary operations, literal trajectory ledgers, cluster partition and invalid inputs. Stochastic comparison/semigroup theorems are used from the paper. This package reruns the finite arithmetic, not Lean and not an end-to-end formal probability proof. JSON/CSV outputs, source/manuscript hashes and regenerated figures are included.

MIT is proposed for newly authored code, pending owner confirmation; no license grant is asserted here. Preserve provenance for the adapted certificate algorithm.
