# Reaction identity changes the probability law

Example for **Critical-window emergence of autocatalytic sets under reaction-channel quotienting**, manuscript entry 36, SHA-256 `99c0aaf9ca053f4e56a901b84a96ce0c67bba99106b4616f3b5bc17474fd6b1b`.

The descriptions A+AA <-> AAA and AA+A <-> AAA describe one reversible channel. A+B <-> AB and B+A <-> BA do not, because AB and BA are different words. Merging the first pair preserves closure and RAF witnesses, but independent catalytic marks must be merged by OR. Giving the merged channel a fresh mark with the original probability defines a different random experiment.

The paper proves that the quotient model has a nontrivial critical window: when mean catalysed channels per molecule f_n satisfies f_n/n -> lambda>0, RAF probability tends to S_qt(1-exp(-lambda)). S_qt(a) is the probability that ordinary reversible food closure is unbounded in an infinite independent channel field of openness a. It is not identified numerically by the theorem. This package supplies exact finite demonstrations and reusable network tools, without presenting a finite simulation as that unknown profile.

## Run and 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
```

Edit the top of `example.py`: catalytic cap, intensity values, trial count, random seed, census caps, toy probabilities, finite escape cutoffs and openness. Model probabilities use integers or rational strings; invalid probabilities are rejected rather than clamped. The default takes about ten seconds and writes exact probability tables, counts, peeling-history polynomials, finite simulation results and two figure pairs. NumPy and Matplotlib versions are pinned.

Explicit binary catalogues are capped at word length 12. Exact catalytic enumeration is capped at 16 molecule-channel bits. These guards prevent accidental exponential work; they do not limit the paper's theorem. Counts beyond the explicit catalogue use the paper's closed formula. The supplied-seed cutoff calculation uses integer powers without constructing the enormous seed.

## Components and literal model

`Description` stores two nonempty factors and their ordered concatenation. Canonicalization swaps factors only when they commute and the right factor is shorter. `ChannelQuotient` groups descriptions in linear time after sorting, projects catalyst masks by OR, computes each channel's independent projected parameter, and lifts a quotient RAF using a catalytically marked representative. A fixed representative can fail to carry the witness. Duplicate copies of the identical description are rejected: repeated observations require a separate dependence model.

`ReversibleNetwork` stores molecular identities, food and channels. Closure applies both ligation and cleavage, disregarding catalysis. Availability is set-valued: A+A requires A to be available, not two counted copies. A reversible RAF must have all channel endpoints in its own food closure and a catalyst for each channel in that closure. One catalyst mark serves both directions. Food molecules can catalyse reactions, and food-only RAFs count.

`CatalyticPeeler` starts with channels catalysed by any molecule, computes their closure, and removes channels lacking catalysts in that closure. It repeats to stability, then retains only channels whose endpoints are available. A catalysed but unusable channel is not a RAF. The object returns the entire decreasing history, terminal closure and usable RAF witness. Every successful ordinary run independently checks the witness against literal RAF semantics.

`IndependentCatalysis` samples the paper's independent molecule-channel law using a binomial catalyst count per channel followed by a uniform subset of that size. This avoids a dense Boolean matrix while preserving the product distribution. It is not a fixed-degree or correlated sampler. Arbitrary catalyst masks can instead be supplied directly to the peeler for deterministic studies.

`ExactCatalyticLaw` enumerates every catalytic configuration of a small network, including heterogeneous channel probabilities. It also records counts by peeling history and number of present marks, and evaluates the paper's exact column-deletion history formula. `ChannelCensus` separates exact catalogue counts from floating evaluation of openness. Plotting and file output are separate from these components.

Example of a reusable finite study:

```python
import numpy as np
from fractions import Fraction
from example import ChannelQuotient, IndependentCatalysis, CatalyticPeeler

catalogue = ChannelQuotient.binary(6)
network = catalogue.quotient
intensity = Fraction(1, 10)
p = intensity * 6 / len(network.channels)
sampler = IndependentCatalysis(np.random.default_rng(1234))
marks = sampler.sample(network, p)
result = CatalyticPeeler(network).run(marks)
print(result["has_raf"], network.generated_words(result["closure"]))
```

To compare identity conventions on the same realized configuration, sample on `catalogue.split`, project with `catalogue.project_marks`, and run both peelers. Their RAF existence agrees. A new homogeneous sample on `catalogue.quotient` is a different law. This binary-word equivalence rule is not a general rule for merging biochemical database records.

## Exact four-molecule experiment

The fixture has molecules A, AA, AAA, AAAA; food A, AA; and split descriptions (A,AA), (AA,A), (A,AAA). Its quotient has two channels, one with a double fibre. For each molecule, a double-fibre mark has probability 1-(1-p)^2=2p-p^2 under independent split marks. Different projected molecule-channel coordinates remain independent because their source coordinates are disjoint.

At p=1/2 the split RAF probability is 4077/4096, reproduced exactly by the heterogeneous OR law. The homogeneous quotient probability is 239/256. At p=1/3 the values are 505585/531441 and 5137/6561. All 4096 split configurations are checked for equivalent RAF existence; all 4077 successful configurations have a witness lifted back to the split network. These are exhaustive rational computations, not estimates.

If two records are duplicate observations of the same event, their marks coincide and OR retains probability p. The independent formula must not be applied to that correlated case. Tests include this distinction and a case where only the noncanonical representative is catalysed.

The paper's reduced-openness coupling is an inequality: at split openness a/2, a double fibre has OR probability a-a^2/4 <= a. The sharper choice 1-sqrt(1-a) makes that probability exactly a. At equal openness, selecting only canonical split marks gives the homogeneous quotient as a subset of the split field. These yield comparisons between survival profiles, not equality of them; strict inequality between the infinite profiles is not established here.

## Adaptive peeling and its history law

The current catalyst pool is determined by previous marks. Treating that random pool as an independent fixed pool would be incorrect. The paper instead compares entire histories with a process that replaces each pool by the first equally many molecules in a fixed ordering.

For prescribed nested pools of sizes k0,...,kT and s=1-p, a channel disappears initially with probability s^k0, first disappears at step d>=1 with probability s^kd-s^k(d-1), or survives all pools with probability 1-s^kT. Multiplying independent column weights gives the history probability. The implementation includes the final stability check. On the 256 quotient configurations, all six possible histories have identical mark-count polynomials in the original and prefix processes, so the equality holds for every p in this fixture. Exact column weights are checked against enumeration at the supplied probabilities; tests also cover p=0 and 1. The prefix process is a law-comparison device, not a claim that its witness uses the original catalyst identities.

## Normalization, gateways and finite estimates

There are M_n=2^(n+1)-2 molecules and R_n=(n-2)*2^(n+1)+4 split descriptions. The quotient count J_n subtracts the commuting unequal-factor duplicates. Enumeration through n=12 agrees with the primitive-word closed formula, including J_12=81828 and D_12=96. At f_n=lambda*n, p_n=lambda*n/J_n. Full-pool channel openness is exactly 1-(1-p_n)^M_n, evaluated stably with log1p/expm1; it is not RAF probability. At n=12 and lambda=1 it is about 0.699150, versus limiting openness 0.632121. Dotted lines in the first figure show this limiting openness only.

For n>=4 there are 34 food gateways: four length-two, fourteen length-three and sixteen length-four channels. A finite RAF needs one of these to be catalysed from the full molecule pool, giving upper bound 1-(1-p)^(34*M_n). Only 30 gateways produce nonfood words. Their openness bounds infinite survival by 1-(1-a)^30; it is not a replacement finite RAF bound, because finite food-only RAFs remain possible.

The default catalytic experiment uses n=6 and 256 independent trials per intensity. At lambda=0.05 and 0.1 it finds respectively 37 and 59 RAFs; 3 and 6 have food-only terminal closure. The table includes the observed gateway-conditioned proportion, with its actual conditional sample size. At larger intensities all trials may succeed; this does not establish probability one. Plotted intervals are pointwise approximate 95% Wilson intervals, not simultaneous or rigorous bounds.

The separate static-field experiment estimates e_K(a), the probability of generating a word longer than K. It uses **cap 2K**: the first escape must ligate two words of length at most K. Reaching the cap in an arbitrary smaller simulation would not compute this event. Each true e_K is an upper bound on infinite survival and decreases with K; independently sampled estimates need not decrease. For K=2, e_2(a)=1-(1-a)^30 is available exactly and is saved beside the estimate. Sampling intervals can miss the true probability; they are not certified bounds on S_qt. No numerical lower survival bound is claimed.

The contour-based sufficient seed cutoffs are verified by integer arithmetic: at a0=0.1,m=10, L=536670; at a0=0.5,m=10, L=20820. They explain why a practical finite certified survival bracket is not supplied. They are sufficient cutoffs for that theorem, not minimum physical sizes or convergence rates.

## Evidence and limits

Seven test groups check canonical identities, counts and gateways, all toy closures and catalytic configurations against literal subset RAF testing, witness lifting, exact probability laws, complete histories and column weights, cleavage/food-only/unusable controls, normalization, integer seed cutoffs, sampling reproducibility and computation guards. Clean-package replay compares saved scientific JSON/CSV. The theorem and its Lean formalization are described by the paper; Lean is not rerun. These structural networks have no concentrations, reaction rates, energy budget, inhibition or degradation, and RAF existence does not establish productive operation.

Licensing: MIT is proposed for this example, pending owner confirmation; this statement does not grant a license. The manuscript retains its own terms.
