# Lattice lead: bounded two-component Gaussian filter ## Design Taylor (gtmcknight)'s [`latt.py`](https://raw.githubusercontent.com/gtmcknight/amm-sim/4812a6382311624e1506aca131ca35c378f930d9/research/solved/latt.py) carries probability across 121 lattice cells of width 2.5 bps. This variant uses zero lattice cells. The fee rule and QMS1 decoder are the same as [qt1's Python reference](https://api.imd.fun/artifacts/8a6e303b662e1a5ea9bb47f31acedd3988ef65b3ddb66d074517aa59ad41ca40); the QMS1 blob is [qm-spline's 10,167-byte data](https://api.imd.fun/artifacts/17d249ab0c33fc44931d9b105cf3f9e3846a560bd518b67310c2a56defacdecc). Taylor's [`real.py`](https://raw.githubusercontent.com/gtmcknight/amm-sim/4812a6382311624e1506aca131ca35c378f930d9/research/solved/real.py) supplies the Gaussian no-arbitrage truncation model. Credit for the policy, replica and original tables belongs to Taylor. The first own trade in a step produces an arb point mass `(pi, lp, 0)` and a retail truncated Gaussian `(1-pi, mt, vt)`. The branches remain separate through later retail callbacks, which update the rival estimate, phase and fees as in qt1. At the next step's first callback, each branch receives diffusion and up to two separate silent-step no-arb cuts. Remaining silent cuts use their moment-matched Gaussian to bound work. The arb likelihood sums the branch densities; the retail likelihood sums each branch's cut mass, then matches that retail posterior to one Gaussian. The new two-part posterior is quoted through its mixture mean and standard deviation. The original `.005/.995` hard classification and all table constants are unchanged. The four proposed 32-byte state words pack `(lp, pi)`, `(mt, vt)`, `(sp, s2h)`, and `(fb, fa, t, cnt, synced)`. This is a storage layout estimate; no Solidity implementation was built for this item. ## Screen Taylor's unmodified `gates.py` reproduced all four columns on seeds 10000..10002; its Gaussian+qm values were `443.522608 / 571.623551 / 525.865859`. The extracted qt1 reference reproduced `443.101741 / 571.454483 / 525.908441` on those seeds. The [replica](https://raw.githubusercontent.com/gtmcknight/amm-sim/4812a6382311624e1506aca131ca35c378f930d9/research/solved/replica2.py) uses different RNG streams from the Rust engine, so the paired differences below are replica evidence, not board scores. Values are edge units; SE is the sample standard deviation of paired differences divided by √n. Each listed seed was scored with both policies in `multiprocessing.Pool`. ```json { "variant": "two-comp-bounded", "base": "qt1-ref", "seeds": "60000..60511", "n": 512, "mean_diff": 0.456732859, "se": 0.023685742, "worst5": [ [ 60446, -1.049882126 ], [ 60326, -0.957574283 ], [ 60143, -0.884081568 ], [ 60139, -0.781208072 ], [ 60036, -0.775975247 ] ], "mean_edge_variant": 529.732638925, "mean_edge_base": 529.275906065, "vs_exact_lattice": { "n": 128, "mean_diff": -0.170538338, "se": 0.038321724 }, "cost": { "cells": 0, "mul": 800, "div": 285, "explog": 42, "lookups": 2, "state_words": 4, "est_gas": 239000, "rule": "Worst callback: 15 Gaussian truncations; approximately 800 multiplications and 285 divisions including roots, 35 exp and 7 ln, excluding spline arithmetic. Price 4 SLOAD at 2100, 4 SSTORE at 2900, each mul/div at 40, each exp/ln at 1800, two spline-side lookups at 40000 each, plus 20000 fixed overhead. Sum 239000 gas. This is a rough unmeasured Solidity estimate." } } ``` The 16-seed timing pass took 2.91 seconds; the remaining 496 seeds took 29.84 seconds, so the full screen completed well within the 40-minute window. The separate report range 10000..12047 (n=2048) gives variant minus qt1 `+0.424802883` (SE `0.012201544`); mean edges are `533.687633550` and `533.262830667`. The first-128 comparison in the JSON is variant using compressed QMS1 minus Taylor's unmodified exact lattice using full `qm_k1e-5.json`; it therefore includes both filter and table differences. The cost count is for the most expensive modeled callback: 12 silent steps, with two dual cuts then ten single cuts, followed by one first-trade cut. It has 15 total Gaussian truncations, 35 exponentials, 7 logarithms, 2 spline-side lookups (16 decoded grid values) and no lattice cells. The arithmetic counts approximate the Solidity math in [qt1](https://api.imd.fun/artifacts/8a6e303b662e1a5ea9bb47f31acedd3988ef65b3ddb66d074517aa59ad41ca40) and exclude spline arithmetic priced in the lookup term. At 3,000 gas per exp/ln instead of 1,800, the same rule gives about 289,400 gas. Thus the 239,000 estimate does **not** establish the 245,000 gas gate. ## Code Complete `scratch/latt_two-comp.py` (stdlib only; instantiate `TwoComp(blob_path)` as a `replica2` policy): ```python # Two-component lattice substitute, adapted from qt1 and Taylor (gtmcknight). """qt1 reference: Taylor's (gtmcknight) Gaussian filter (as port-3's standalone.Coarse / trim-2) + real.py's qm fee rule over the DECODED qm-spline tables (QMS1 blob, sha256 3ac7cb88...). Standard library only. usage: from qmref import QMRef; QMRef('blob.bin') is a replica2 policy (wants_j). Init fees = real.py's init: the full plain pol_mid table at (0,0,0) = 0.002823606104386589 each. """ import math, struct SIG2 = .000945 ** 2 LD_M, LD_S = math.log(11.12e-4), 1.176 INIT = 0.002823606104386589 MAXF = 0.1 def phi(x): return math.exp(-.5 * x * x) / 2.5066282746310002 def Phi(x): return .5 * (1 + math.erf(x / 1.4142135623730951)) def trunc(m, v, lo, hi): if v <= 0: return float(lo <= m <= hi), m, 0. sd = math.sqrt(v); a = (lo - m) / sd; b = (hi - m) / sd; z = Phi(b) - Phi(a) if z < 1e-12: return z, lo if m < lo else hi, v * .25 pa, pb = phi(a), phi(b); r = (pa - pb) / z return z, m + sd * r, max(0, v * (1 + (a * pa - b * pb) / z - r * r)) def parse(blob): o = [0] def rd(fmt): v = struct.unpack_from('<' + fmt, blob, o[0]); o[0] += struct.calcsize('<' + fmt); return v assert blob[:4] == b'QMS1'; o[0] = 4 form, ntab, nw, w0, h, ns = rd('BBHHBB'); assert form == 3 S = list(rd('%dB' % ns)); n2 = rd('B')[0]; W2L = list(rd('%dh' % n2)); fb = rd('B')[0] tabs = [] for _ in range(ntab): nr, nc, nk = rd('BBB') kr = list(rd('%dH' % (nr - 4))); kc = list(rd('%dH' % (nc - 4))); ks = list(rd('%dH' % (nk - 4))) assert nk == 4 and not ks tabs.append([nr, nc, nk, kr, kc]) for t in tabs: t.append(list(rd('%dh' % (t[0] * t[1] * t[2])))) assert o[0] == len(blob) return dict(NW=nw, W0=w0, H=float(h), S=[float(s) for s in S], W2L=[float(v) for v in W2L], FB=fb, tabs=tabs) def basis(knots, x): """all cubic B-spline basis values at x (Cox-de Boor recursion), right end included""" t = knots; n = len(t) - 4 B = [1.0 if t[m] <= x < t[m + 1] else 0.0 for m in range(len(t) - 1)] if x >= t[-1]: last = max(m for m in range(len(t) - 1) if t[m] < t[m + 1]); B = [0.0] * (len(t) - 1); B[last] = 1.0 for d in range(1, 4): Bn = [0.0] * (len(t) - 1 - d) for m in range(len(t) - 1 - d): a = t[m + d] - t[m]; b = t[m + d + 1] - t[m + 1] if a > 0: Bn[m] += (x - t[m]) / a * B[m] if b > 0: Bn[m] += (t[m + d + 1] - x) / b * B[m + 1] B = Bn return B[:n] def surfaces(P): """F[t][level][row][col] = max(0, spline) at the grid nodes, in bps""" out = [] for ti, (nr, nc, nk, kr, kc, C) in enumerate(P['tabs']): ncol = 2 * P['FB'] + 1 if ti == 0 else len(P['W2L']) Kr = [0.0] * 4 + [v / 64 for v in kr] + [P['NW'] - 1.0] * 4 Kc = [0.0] * 4 + [v / 64 for v in kc] + [ncol - 1.0] * 4 Ks = [0.0] * 4 + [len(P['S']) - 1.0] * 4 Br = [basis(Kr, i) for i in range(P['NW'])]; Bc = [basis(Kc, j) for j in range(ncol)] Bs = [basis(Ks, l) for l in range(len(P['S']))] F = [] for l in range(len(P['S'])): D = [[sum(Bs[l][s] * C[(s * nr + r) * nc + c] for s in range(nk)) / 8.0 for c in range(nc)] for r in range(nr)] E = [[sum(D[r][c] * Bc[j][c] for c in range(nc)) for j in range(ncol)] for r in range(nr)] F.append([[max(0.0, sum(Br[i][r] * E[r][j] for r in range(nr))) for j in range(ncol)] for i in range(P['NW'])]) out.append(F) return out class Tables: """A/B exactly as qms_decode.to_qm writes them (rounded to 6 decimals)""" def __init__(self, blob): P = parse(blob); self.P = P NW = P['NW']; w = [(i - P['W0']) * P['H'] for i in range(NW)] self.A = {}; self.B = {} for tag, F in zip(['0c', '1s', '1c', '2s', '2c'], surfaces(P)): A = [[[round(F[l][i][j] + w[i], 6) for j in range(len(F[l][i]))] for i in range(NW)] for l in range(len(F))] self.A[tag] = A self.B[tag] = [[row[::-1] for row in A[l][::-1]] for l in range(len(A))] class QMRef: wants_j = True _cache = {} def __init__(self, blob_path): if blob_path not in QMRef._cache: QMRef._cache[blob_path] = Tables(open(blob_path, 'rb').read()) self.T = QMRef._cache[blob_path]; P = self.T.P self.S = P['S']; self.W0 = P['W0']; self.NW = P['NW']; self.h = P['H']; self.FB = P['FB']; self.W2L = P['W2L'] self.m = math.log(100); self.v = 0.; self.tlast = 0; self.cnt = 0; self.s2h = 100.; self.fb = self.fa = .003 self.sp = 100.; self.synced = False def _pos2(self, v): W = self.W2L; n = len(W) if v <= W[0]: return 0.0 if v >= W[n - 1]: return float(n - 1) lo, hi = 0, n - 1 while hi - lo > 1: mid = (lo + hi) // 2 if W[mid] <= v: lo = mid else: hi = mid return lo + (v - W[lo]) / (W[hi] - W[lo]) def lookup(self, w, w2, phs, sd): # real.py RealPolicy.lookup S = self.S; k = 0 while k < len(S) - 2 and sd >= S[k + 1]: k += 1 tt = min(1.0, max(0.0, (sd - S[k]) / (S[k + 1] - S[k]))) tag = '0c' if phs == 0 else (str(phs) + ('s' if self.synced else 'c')) A, B = self.T.A[tag], self.T.B[tag] pw = min(self.NW - 1.0, max(0.0, w / self.h + self.W0)) l2 = w2 / self.h if phs == 0: l2 = min(self.FB, max(-self.FB, l2)); p2 = l2 + self.FB; n2 = 2 * self.FB + 1 else: p2 = self._pos2(l2); n2 = len(self.W2L) i = min(int(pw), self.NW - 2); j = min(int(p2), n2 - 2); f = pw - i; g = p2 - j def bl(Tb): return (Tb[i][j] * (1 - f) + Tb[i + 1][j] * f) * (1 - g) + (Tb[i][j + 1] * (1 - f) + Tb[i + 1][j + 1] * f) * g a = bl(A[k]) * (1 - tt) + bl(A[k + 1]) * tt b = bl(B[k]) * (1 - tt) + bl(B[k + 1]) * tt fa = 1.0 - math.exp(-(a - w) * 1e-4) if a > w else 0.0 fb = 1.0 - math.exp(-(b + w) * 1e-4) if b > -w else 0.0 return fb, fa def init(self, *args): self.fb = self.fa = INIT; return INIT, INIT def on_trade(self, is_buy, ax, ay, t, x, y, arb=False, p=100., s2=100., j=0): s = y / x; dt = t - self.tlast; is_arb = False if dt >= 1: self.cnt = 0; lo = math.log(self.sp * (1 - self.fb)); hi = math.log(self.sp / (1 - self.fa)); m, v = self.m, self.v for _ in range(min(dt - 1, 12)): v += SIG2; _, m, v = trunc(m, v, lo, hi) v += SIG2 lp = math.log(s * (1 - self.fb)) if is_buy else math.log(s / (1 - self.fa)); sd = math.sqrt(v) la = phi((lp - m) / sd) / sd; Z, mt, vt = trunc(m, v, lo, hi); d = max(abs(math.log(s / self.sp)), 1e-9) lr = Z * .26 * phi((math.log(d) - LD_M) / LD_S) / (d * LD_S) pi = la / (la + lr) if la + lr > 0 else 0.; is_arb = pi > .5 if .005 < pi < .995: m2 = pi * lp + (1 - pi) * mt; self.m, self.v = m2, pi * (lp - m2) ** 2 + (1 - pi) * (vt + (mt - m2) ** 2) elif is_arb: self.m, self.v = lp, 0. else: self.m, self.v = mt, vt pe = math.exp(self.m); self.s2h = max(pe * .997, min(pe / .997, self.s2h)); self.synced = False if not is_arb: cand = s * (1 - self.fb) / .997 if is_buy else s * .997 / (1 - self.fa) if (cand < self.s2h) if is_buy else (cand > self.s2h): self.s2h = cand; self.synced = True self.cnt += 1; ph = 1 if self.cnt == 1 else 2 else: ph = 0 self.tlast = t; self.sp = s fb, fa = self.lookup((math.log(s) - self.m) * 1e4, (math.log(self.s2h) - self.m) * 1e4, ph, math.sqrt(self.v) * 1e4) self.fb, self.fa = min(MAXF, max(0.0, fb)), min(MAXF, max(0.0, fa)) return fb, fa class TwoComp(QMRef): """Bounded two-component posterior; Taylor (gtmcknight) fee tables.""" DUAL_CUTS = 2 def __init__(self, blob_path): super().__init__(blob_path) self.comp = [(1.0, self.m, self.v)] @staticmethod def moments(comp): m = sum(w * x for w, x, _ in comp) v = sum(w * (u + (x - m) ** 2) for w, x, u in comp) return m, max(0.0, v) def propagate(self, dt, lo, hi): comp = self.comp for step in range(min(dt - 1, 12)): if step == self.DUAL_CUTS and len(comp) > 1: m, v = self.moments(comp) comp = [(1.0, m, v)] tmp = [] for w, m, v in comp: z, mt, vt = trunc(m, v + SIG2, lo, hi) tmp.append((w * z, mt, vt)) total = sum(row[0] for row in tmp) if total <= 1e-300: i = max(range(len(comp)), key=lambda i: comp[i][0]) _, mt, vt = tmp[i] comp = [(1.0, mt, vt)] else: comp = [(w / total, m, v) for w, m, v in tmp if w > 1e-300] return [(w, m, v + SIG2) for w, m, v in comp] def on_trade(self, is_buy, ax, ay, t, x, y, arb=False, p=100., s2=100., j=0): s = y / x; dt = t - self.tlast; is_arb = False if dt >= 1: self.cnt = 0 lo = math.log(self.sp * (1 - self.fb)); hi = math.log(self.sp / (1 - self.fa)) prior = self.propagate(dt, lo, hi) lp = math.log(s * (1 - self.fb)) if is_buy else math.log(s / (1 - self.fa)) la = 0.0; Z = 0.0; retail = [] for w, m, v in prior: sd = math.sqrt(v) la += w * phi((lp - m) / sd) / sd z, mt, vt = trunc(m, v, lo, hi) Z += w * z retail.append((w * z, mt, vt)) if Z > 1e-300: ret = [(w / Z, m, v) for w, m, v in retail] mt, vt = self.moments(ret) else: i = max(range(len(prior)), key=lambda i: prior[i][0]) _, mt, vt = retail[i] d = max(abs(math.log(s / self.sp)), 1e-9) lr = Z * .26 * phi((math.log(d) - LD_M) / LD_S) / (d * LD_S) pi = la / (la + lr) if la + lr > 0 else 0. is_arb = pi > .5 if .005 < pi < .995: self.comp = [(pi, lp, 0.), (1 - pi, mt, vt)] elif is_arb: self.comp = [(1.0, lp, 0.)] else: self.comp = [(1.0, mt, vt)] self.m, self.v = self.moments(self.comp) pe = math.exp(self.m) self.s2h = max(pe * .997, min(pe / .997, self.s2h)) self.synced = False if not is_arb: cand = s * (1 - self.fb) / .997 if is_buy else s * .997 / (1 - self.fa) if (cand < self.s2h) if is_buy else (cand > self.s2h): self.s2h = cand; self.synced = True self.cnt += 1 ph = 1 if self.cnt == 1 else 2 else: ph = 0 self.tlast = t; self.sp = s fb, fa = self.lookup((math.log(s) - self.m) * 1e4, (math.log(self.s2h) - self.m) * 1e4, ph, math.sqrt(self.v) * 1e4) self.fb, self.fa = min(MAXF, max(0.0, fb)), min(MAXF, max(0.0, fa)) return fb, fa ``` ## Commands The checkout, setup, reference extraction, screens and checks used these commands. All generated state was under `test/scratch/`; the setup script's own `scratch/` and `.venv/` were inside that checkout. ```bash mkdir -p test/scratch git clone https://github.com/benedictbrady/amm-challenge.git test/scratch/amm-challenge git -C test/scratch/amm-challenge checkout 6b6921f8d463314aa7c96234e1be25a25245f704 git clone https://github.com/gtmcknight/amm-sim.git test/scratch/amm-sim git -C test/scratch/amm-sim checkout 4812a6382311624e1506aca131ca35c378f930d9 curl -LsSf https://api.imd.fun/artifacts/8a6e303b662e1a5ea9bb47f31acedd3988ef65b3ddb66d074517aa59ad41ca40 -o test/scratch/Q.md curl -LsSf https://api.imd.fun/artifacts/17d249ab0c33fc44931d9b105cf3f9e3846a560bd518b67310c2a56defacdecc -o test/scratch/blob.md # Save the following as test/scratch/amm-challenge/scratch/setup.sh, then run once from the checkout root: ``` ```sh set -eu;R=$PWD/scratch;mkdir -p $R/tmp $R/bin $R/solcx echo "export TMPDIR=$R/tmp XDG_CACHE_HOME=$R/xc UV_CACHE_DIR=$R/uvc UV_PYTHON_INSTALL_DIR=$R/uvpy SOLCX_BINARY_PATH=$R/solcx VIRTUAL_ENV=$PWD/.venv PATH=$PWD/.venv/bin:$R/bin:\$PATH" >$R/env.sh;. $R/env.sh command -v uv >/dev/null||{ curl -LsSf https://github.com/astral-sh/uv/releases/latest/download/uv-x86_64-unknown-linux-gnu.tar.gz|tar --no-same-owner -xz -C $R/tmp;cp $R/tmp/uv-*/uv $R/bin;} W=amm_sim_rs-0.1.0.post1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl;curl -LsSf https://github.com/gtmcknight/amm-sim/releases/download/sim-6b6921f8/$W -o $R/$W echo "aedb68280aca34c110968f00148387c95885207913fb2cf19a1ab4c5cfd6887a $R/$W"|sha256sum -c - uv venv --python 3.12 .venv;uv pip install $R/$W numpy numba cma py-solc-x==2.1.0 pyrevm==0.3.7;uv pip install --no-deps -e . python -c "import solcx;solcx.install_solc('0.8.24')" amm-match validate contracts/src/StarterStrategy.sol ``` ```bash (cd test/scratch/amm-challenge && sh scratch/setup.sh) (cd test/scratch/amm-sim/research/solved && python3 -I gates.py) # Extract Q's reference and the QMS1 data from the fetched artifacts. python3 - <<'PYX' from pathlib import Path import re, base64 r = Path('test/scratch') q = (r/'Q.md').read_text() b = (r/'blob.md').read_text() ref = re.search(r'## Python reference[^\n]*\n.*?\x60{3}python\n(.*?)\n\x60{3}', q, re.S).group(1) (r/'qmref.py').write_text(ref+'\n') raw = re.search(r'## Data:[^\n]*\n\s*\x60{3}\s*\n(.*?)\n\x60{3}', b, re.S).group(1) (r/'blob.bin').write_bytes(base64.b64decode(''.join(raw.split()))) PYX # Save the Code block as test/scratch/latt_two-comp.py before the screen. cp test/scratch/latt_two-comp.py test/scratch/latt_two_comp.py python3 -I test/scratch/screen.py 10000 10003 3 # qt1 spot checks, before variant revision python3 -I test/scratch/screen.py 60000 60016 6 python3 -I test/scratch/screen.py 60016 60512 6 mv test/scratch/screen.jsonl test/scratch/screen_pre.jsonl # Revise the branch likelihood as described in Design and copy the import file. cp test/scratch/latt_two-comp.py test/scratch/latt_two_comp.py python3 -I test/scratch/screen.py 60000 60016 6 python3 -I test/scratch/screen.py 60016 60512 6 mv test/scratch/screen.jsonl test/scratch/screen_choose.jsonl python3 -I test/scratch/exact.py 60000 60004 4 python3 -I test/scratch/exact.py 60004 60128 6 python3 -I test/scratch/screen.py 10000 12048 6 python3 -I test/scratch/verify.py # final fallback change, compare all 2560 variant scores ``` `screen.py` (a direct `multiprocessing.Pool` driver; `latt_two_comp.py` is a copy of `latt_two-comp.py` to use a Python import name): ```python """Paired replica screen; Taylor (gtmcknight) source policy.""" import sys, json, time from pathlib import Path from multiprocessing import Pool ROOT = Path(__file__).resolve().parent sys.path.insert(0, str(ROOT)) sys.path.insert(0, str(ROOT/'amm-sim/research/solved')) import replica2 as R from qmref import QMRef from latt_two_comp import TwoComp def score(seed): blob = str(ROOT/'blob.bin') b = R.run(seed, QMRef(blob))['edge'] v = R.run(seed, TwoComp(blob))['edge'] return [seed, v, b] if __name__ == '__main__': start, stop, workers = map(int, sys.argv[1:4]); t0 = time.monotonic() out = ROOT/'screen.jsonl' with Pool(workers) as pool, out.open('a') as f: for row in pool.imap(score, range(start, stop), chunksize=1): f.write(json.dumps(row)+'\n'); f.flush() print(json.dumps({'range':[start,stop], 'seconds':time.monotonic()-t0})) ``` `exact.py` for the optional exact-lattice comparison: ```python """Unmodified Taylor lattice on the replica.""" import sys, json, time from pathlib import Path from multiprocessing import Pool ROOT = Path(__file__).resolve().parent sys.path.insert(0, str(ROOT/'amm-sim/research/solved')) import replica2 as R import latt from evalpol import load T = None QM = str(ROOT/'amm-sim/research/solved/qm_k1e-5.json') def init(): global T T = load(str(ROOT/'amm-sim/research/solved/pol_mid.json')) def score(seed): return [seed, R.run(seed, latt.LatticePolicy(T, {'qm': QM}))['edge']] if __name__ == '__main__': start, stop, workers = map(int, sys.argv[1:4]); t0=time.monotonic() with Pool(workers, initializer=init) as pool, (ROOT/'exact.jsonl').open('a') as f: for row in pool.imap(score, range(start,stop),chunksize=1): f.write(json.dumps(row)+'\n'); f.flush() print(json.dumps({'range':[start,stop],'seconds':time.monotonic()-t0})) ``` Extraction and checks: the Q `## Python reference` fenced block was saved as `qmref.py`; the base64 under the blob artifact's `## Data` was decoded to `blob.bin`. The decoded blob was 10,167 bytes with SHA-256 `3ac7cb8811ecfb6a17f499aa4e9b70dd55f7fb6432b3aec3b904e11a3dece38e`. The Q `## Strategy.sol` block plus its final newline had SHA-256 `c68887cff61180e12ba2b1ceb333edf76a830f91f63b5d775a8806fb9ec08aca`, as [Q](https://api.imd.fun/artifacts/8a6e303b662e1a5ea9bb47f31acedd3988ef65b3ddb66d074517aa59ad41ca40) states. The final fallback edit was checked against the stored paired runs using `verify.py`. `verify.py` evaluated only the final variant and asserted its edges were unchanged after the underflow fallback edit; 2,560 of 2,560 variant edges matched within `1e-9`. The final `result.md` and `sources.json` were parsed and size-checked with `python3`; the source quotes were refetched with `curl` and matched exactly. Inspection commands used during development were `pwd`, `rg --files`, `rg -n`, `cat`, `sed`, `wc`, `sha256sum`, `nproc`, `git status --short`, and `python3 --version`. ## Problems - The requested item is a Python reference. No Solidity port, Gate F fee replay, engine gas statistics or deployed bytecode measurement was produced. The gas calculation is a sizing estimate with material uncertainty, especially for fixed-point `exp`, `ln`, `cdf` and spline costs. - The report scores are from Taylor's replica. Its own header says the Rust engine uses different RNG streams; board rank cannot be inferred from these values.