# Reference-Preserving Martingale Layer

- ID: 2563
- Canonical URL: https://synthcore.org/idea/2563/reference-preserving-martingale-layer
- API JSON: https://synthcore.org/api/idea/2563.json
- API Markdown: https://synthcore.org/api/idea/2563.md
- Verification status: mechanism_failed
- Source: [arXiv:2608.19391](https://arxiv.org/abs/2608.19391)
- Category: architecture
- Solves: stability, generalization, accuracy
- ML areas: vae, diffusion, regularization, training-dynamics
- Math tags: probability, statistics, optimal-transport, convex-analysis, stochastic-processes
- Ratings: usefulness 8/10; difficulty 6/10; novelty 7/10

## Idea description

Replace an unconstrained stochastic transition between categorical or discretized latent distributions by a transition matrix that preserves a prescribed reference distribution while mapping relative populations through a martingale. This prevents the layer from inventing arbitrarily sharp deviations from the reference and imposes a convex-order monotonicity condition on uncertainty across layers or diffusion time steps.

## Mathematical statement

Let g1 and g2 be strictly positive reference distributions, k1 and k2 be state distributions, and T be a nonnegative column-stochastic transition matrix. Reference-preserving convertibility requires T g1 = g2 and T k1 = k2. Define relative populations kappa1_j = k1_j / g1_j and kappa2_i = k2_i / g2_i. The associated laws are mu1 = sum_j g1_j delta_{kappa1_j} and mu2 = sum_i g2_i delta_{kappa2_i}. Convertibility is equivalent to the existence of a coupling Q whose columns have masses g1, whose rows have masses g2, and whose conditional expectation of the output relative population equals the input relative population. Specifically, sum_i Q_ij kappa2_i = kappa1_j g1_j. Setting T_ij = Q_ij / g1_j gives both state-transition constraints. Equivalently, mu1 dominates mu2 in convex order: the expectation of every convex function is no smaller under mu1 than under mu2, while both laws have mean one.

## Key formulas

- $$Tg^{(1)}=g^{(2)},\qquad Tk^{(1)}=k^{(2)},\qquad T_{ij}\ge 0,\quad \sum_i T_{ij}=1.$$
- $$\kappa^{(a)}_j=\frac{k^{(a)}_j}{g^{(a)}_j},\qquad \mu_a=\sum_j g^{(a)}_j\,\delta_{\kappa^{(a)}_j}.$$
- $$\sum_i Q_{ij}=g^{(1)}_j,\quad \sum_j Q_{ij}=g^{(2)}_i,\quad \sum_i \kappa^{(2)}_i Q_{ij}=\kappa^{(1)}_j g^{(1)}_j,\quad T_{ij}=\frac{Q_{ij}}{g^{(1)}_j}.$$
- $$\mathbb{E}_{\mu_1}[\phi(\kappa)]\ge \mathbb{E}_{\mu_2}[\phi(\kappa)]\quad\text{for every convex }\phi,\qquad \mathbb{E}_{\mu_1}[\kappa]=\mathbb{E}_{\mu_2}[\kappa]=1.$$

## Implementation notes

Use this mechanism as a stochastic latent transition in a VAE, categorical world model, discretized diffusion model, or any network whose intermediate representation is a probability vector. At each transition, let k1 and g1 be the previous state and reference, and let k2 and g2 be the desired next state and reference. Instead of directly predicting T, predict unconstrained logits R for a nonnegative coupling Q = softplus(R). Optimize the task loss plus penalties for column marginals, row marginals, and the martingale condition. In pseudocode: compute kappa1 = k1 / (g1 + epsilon) and kappa2 = k2 / (g2 + epsilon); construct Q = softplus(R); minimize Ltask + lambda_c times the squared norm of Q-transpose times one minus g1, plus lambda_r times the squared norm of Q times one minus g2, plus lambda_m times the squared norm of Q times kappa2 minus g1 elementwise-multiplied by kappa1. Then define T_ij = Q_ij / (g1_j + epsilon) and propagate T k1. The paper supplies the coupling and convex-order criterion; penalty weights, epsilon, and differentiable projection are empirical approximations. Monitor convex-order violation V = max_a [E_mu2[(kappa-a)_+] - E_mu1[(kappa-a)_+]]_+ over a grid. First experiment: train a 20-state categorical VAE on MNIST and compare an unconstrained stochastic layer, KL regularization, and this layer. Generate synthetic convertible pairs from a known Q and non-convertible pairs by violating the martingale constraint. The prediction is V approaching zero for convertible transitions, with recovered marginal and martingale residuals below 10^-3; for non-convertible targets, task loss should plateau when V remains bounded away from zero.

## Verification

- Status: mechanism_failed
- Mechanism evidence: yes
- Mechanism confirmed: no
- Verdict: Built an LP-based reference-preserving coupling MVP and numerically tested the claimed convex-order relationship. The convex-order/Strassen orientation works for the convertible contraction (V=0, marginal and martingale residuals below 6e-17), but the authoritative displayed constraint uses the reverse conditional expectation: it rejects the convertible pair and accepts the non-convertible pair. Therefore the proposed mechanism does not work as written; only a corrected orientation appears mathematically viable.

### Mechanism check

- Verdict: Built an LP-based reference-preserving coupling MVP and numerically tested the claimed convex-order relationship. The convex-order/Strassen orientation works for the convertible contraction (V=0, marginal and martingale residuals below 6e-17), but the authoritative displayed constraint uses the reverse conditional expectation: it rejects the convertible pair and accepts the non-convertible pair. Therefore the proposed mechanism does not work as written; only a corrected orientation appears mathematically viable.
- Confidence: 10/10
- Limitations: No MNIST VAE or neural training experiment was run because the authoritative coupling equation fails the required toy mathematical verification. The MVP uses exact linear programming and tests equal-size discrete distributions with uniform references; differentiable softplus penalties and unequal/reference-learned settings were not evaluated.

## Artifacts

- [mvp.py](https://synthcore.org/code/902/mvp.py)
- [report.md](https://synthcore.org/code/902/report.md)
- [verify.py](https://synthcore.org/code/902/verify.py)
- [Download all files as ZIP](https://synthcore.org/download/902)

## Disclaimer

AI-generated research hypothesis, automatically tested. Not peer-reviewed.
