# Agent Report — Three Regimes of Modular Memory: Algebraic (mod-3), Near-Uniform (mod-5), Statistical (mod-q)

**Date**: 2026-04-30 03:30
**Piano**: 59
**Tension explored**: META (0.7) — consecutio: "Does the algebraic layer exist for mod-5, mod-7? Does M2/M1 have a closed formula?"

## Claim Under Test

> The three-layer decomposition of prime gap memory (algebraic / statistical / magnitude) predicts that the algebraic layer (mod-3 self-transition prohibition) should extend to other small primes. M2/M1 (Markov depth ratio) might be a universal invariant.

## Question

For moduli q = 3, 5, 7, 11, 13: what is the Markov structure of consecutive prime gap residues? Is mod-3 unique or the first of a family? Does M2/M1 converge to a constant?

## Experiment Design

- **Data**: 200,000 consecutive prime gaps (primes up to ~3.9M)
- **For each modulus q**: compute gap residues mod q, build order-1 and order-2 Markov transition matrices
- **Metrics**: marginal entropy H0, order-1 entropy rate H1, order-2 entropy rate H2, information gains I1 = H0-H1 and I2 = H1-H2, depth ratio M2/M1 = I2/I1
- **Null baseline**: 50 shuffles (same gap distribution, order destroyed) for z-scores
- **Self-transition**: P(r_n = r_{n+1}) for each non-zero residue class

## Results

### Entropy and Information Structure

|  q | H0 (bits) | H1 (bits) | H2 (bits) | I1 (bits) | I2 (bits) | M2/M1 | z(I1)   | z(I2)  |
|---:|----------:|----------:|----------:|----------:|----------:|------:|--------:|-------:|
|  3 |    1.5591 |    1.2375 |    1.0855 |    0.3216 |    0.1521 | 0.473 | 31436.2 | 9364.3 |
|  5 |    2.2980 |    2.2870 |    2.2625 |    0.0109 |    0.0245 | 2.241 |   602.9 |  541.1 |
|  7 |    2.7516 |    2.7340 |    2.7211 |    0.0176 |    0.0129 | 0.729 |   559.7 |  141.2 |
| 11 |    3.2939 |    3.2059 |    3.1581 |    0.0880 |    0.0478 | 0.543 |  1669.2 |  365.6 |
| 13 |    3.4734 |    3.3602 |    3.2893 |    0.1133 |    0.0708 | 0.625 |  2269.1 |  287.4 |

All z-scores are extreme — ordering memory is real at every modulus tested. But the structure varies qualitatively.

### Self-Transition Rates (non-zero residues)

**Mod-3**: Residue 1 = 0.000, Residue 2 = 0.00002. z = -169, -175. **One violation** in 200K gaps: primes (3, 5, 7), gaps (2, 2) — the small-prime edge case. For p > 5, zero self-transitions.

**Mod-5**: Residues 1-4: 0.13 to 0.22 (uniform = 0.20). z = -9 to -19. Suppressed but far from zero.

**Mod-7**: Residues 1-6: 0.07 to 0.19 (uniform = 0.14). z = -2.5 to -35. Heterogeneous suppression.

**Mod-11**: Residues 1-10: 0.016 to 0.15 (uniform = 0.09). z = -5.5 to -35. Strong suppression.

**Mod-13**: Residues 1-12: 0.010 to 0.14 (uniform = 0.077). z = -3.3 to -39. Strong suppression.

### Marginal Distribution Non-Uniformity

| q  | Min residue freq | Max residue freq | Ratio max/min |
|---:|-----------------:|-----------------:|--------------:|
|  3 |           21.2%  |           42.0%  |          1.98 |
|  5 |           15.7%  |           24.6%  |          1.57 |
|  7 |            8.1%  |           20.7%  |          2.56 |
| 11 |            3.2%  |           18.2%  |          5.63 |
| 13 |            1.8%  |           17.1%  |          9.30 |

The marginal distribution becomes increasingly non-uniform for larger q. Gaps concentrate on even multiples of small primes (2, 6, 12, 30...), which hit fewer residue classes as q grows. This drives the growth of I1 with q — **a distributional effect, not an ordering effect**.

## Key Findings

1. **Mod-3 is unique — algebraic prohibition, not a family.** Self-transition of non-zero residues is exactly zero for p > 5. No other modulus tested shows this. The mechanism: primes > 3 are 1 or 5 mod 6, so gaps are 2 or 4 mod 6, and consecutive gaps must alternate mod-3 residue classes (gap g1 mod 3 = r implies gap g2 mod 3 must be non-r for the triplet to be all-prime). This is specific to 3 | 6.

2. **Mod-5 has a qualitatively different Markov structure: M2/M1 = 2.24 (order-2 dominates order-1).** This is the only modulus where the three-body correlation exceeds the pairwise correlation. The near-uniform marginal distribution at mod-5 (ratio 1.57) means order-1 transitions carry little information, but order-2 (gap triplets) reveals hidden structure. This anomaly appears specific to q=5 — the smallest prime not dividing 6.

3. **For q = 7, 11, 13: M2/M1 ranges from 0.54 to 0.73 (order-1 dominates).** These moduli follow the Lemke Oliver-Soundararajan pattern (2016): consecutive prime residues mod q exhibit biases explained by the Hardy-Littlewood prime k-tuples conjecture. The bias is statistical, not algebraic — it strengthens with q because the marginal distribution becomes more non-uniform (L2: the I1 growth is distributional, not ordering).

4. **M2/M1 does NOT have a simple closed formula.** The values {0.47, 2.24, 0.73, 0.54, 0.63} are non-monotonic and reflect the interplay between algebraic constraints (mod-3 only) and statistical biases (all q). The depth ratio varies with the specific arithmetic of each modulus.

5. **Literature context (L5):** The self-transition suppression at all moduli is a manifestation of the Lemke Oliver-Soundararajan bias (2016, "Unexpected biases in the distribution of consecutive primes"). The mod-3 exact prohibition is a known consequence of the Z/6Z structure of primes. **What appears new**: the M2/M1 anomaly at mod-5 (order-2 dominance) and the non-monotonic M2/M1 profile across moduli. These are not discussed in LOS, which focuses on order-1 biases. However, this may be a consequence of their framework — needs verification.

## Verdict

**CONSTRAINT on META + CONFIRMED structure + NEW observation at mod-5**

- META refined: the three-layer decomposition holds. The algebraic layer is mod-3 only (not a family). The statistical layer (Lemke Oliver-Soundararajan) operates at all moduli with varying strength.
- The M2/M1 ratio is not a universal invariant — it's a signature of each modulus's arithmetic.
- NEW: Mod-5 is anomalous. M2/M1 > 1 means the prime gap sequence at mod-5 is a second-order Markov process where pairwise statistics are near-trivial but triplet statistics carry significant structure. This distinguishes q=5 from all other tested moduli.

## Bicono della scoperta

- **Due radici** (dipolo): algebraico (mod-3, esatto, eterno) / statistico (mod-5,7,11,13, bias, decade-con-scala). Invertiti: l'uno proibisce, l'altro supprime. L'uno e un teorema, l'altro una tendenza.
- **Singolare**: il gap primo in se, prima della riduzione modulo q. Non appartiene a nessun regime — li contiene entrambi. Ogni modulus rivela un aspetto diverso dello stesso gap.
- **Invariante di passaggio**: l'ordinamento dei gap porta memoria a OGNI modulus testato (tutti i z-score >> 0). La memoria e universale — la forma della memoria (algebrica vs statistica, ordine-1 vs ordine-2) dipende dal modulus.
- **Campo di possibilita**: possibile — predire la struttura Markov di ordine-2 dei gap primi a mod-5 (triplet correlations che l'ordine-1 non cattura). Non-possibile — estendere la proibizione algebrica di mod-3 ad altri moduli (e specifica di 3|6, non generalizzabile).

## Consecutio

La domanda che si apre: **perche mod-5 e' anomalo?** Il fatto che 5 sia il primo primo che non divide 6 e' necessario o sufficiente? Predizione falsificabile: se il meccanismo e' "primo che non divide 6", allora anche mod-2 dovrebbe essere anomalo — ma mod-2 e' triviale (tutti i gap > 1 sono pari). Serve testare mod-30 (= 2 * 3 * 5) per verificare se la struttura si ricompone al livello del primoriale.

## Files

- Script: `tools/exp_modular_algebra_depth.py`
- Data: `tools/data/modular_algebra_depth.json`
- Report: `tools/data/reports/agent_20260430_0330.md`
