Finishes the Layer 1 analytical core. All six experiments run with honest, publication-quality figures; 71 tests green. - E3 region-matched grounding: `grounding.exercised` knob + per-region tail survival. Matched holds the exercised region's tail (0.49) where uniform spreads thin and lets it collapse (0.07). - E4 multi-teacher recombination: `run_coverage` runner. Union coverage matches U(K_T,rho,q) exactly. Finding: mean-mixture distillation shows NO surviving benefit (a conservation law — 1/K_T dilution cancels the union gain); a union-preserving max-merge (M2N2-style) does. E4 reports both operators. - E5 QD vs greedy: greedy drives fixation (H~0.01); QD holds H at 0.48-0.88, rising with the novelty exponent. - E6 re-mint gate: `arm` multi-override sweep. Re-minting a collapsed lineage locks in divergence of KL-to-original; gating on diversity prevents it. - E2 analysis add-ons (from the companion work order, numbers verified): new analysis.py (reduce_to_stationary, critical_grounding with bootstrap CI -> g*=0.048, 95% CI [0.047,0.050]); tail_band_metrics + per-band logging; the E2 figure rebuilt as a 2x2 (defined g*+CI, g=0 flagged as a finite-time artifact, tail item-vs-mass, per-rarity-band panel). Uses truth-mass-weighted tail coverage rather than the raw (martingale) tail_mass. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
76 lines
3 KiB
Python
76 lines
3 KiB
Python
"""E6 figure: the re-minting gate and irreversibility.
|
|
|
|
Re-minting freezes the current distribution as the new grounding reference and discards
|
|
the original truth. Re-minting a collapsed lineage locks in the collapse: KL to the
|
|
original truth diverges, because the lost original tails can no longer be grounded.
|
|
Gating re-mint on diversity refuses to re-mint while collapsed and keeps KL bounded;
|
|
re-minting a healthy lineage is harmless. Usage: python figures/plot_E6.py [results/E6]
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import matplotlib.pyplot as plt
|
|
import numpy as np
|
|
|
|
sys.path.insert(0, str(Path(__file__).parent))
|
|
from _figlib import load_bundle, savefig # noqa: E402
|
|
|
|
STYLE = {
|
|
"healthy_remint": ("#2ca02c", "re-mint while healthy (H high)"),
|
|
"collapsed_remint": ("#d62728", "re-mint while collapsed (ungated)"),
|
|
"collapsed_gated": ("#1f77b4", "collapsed + diversity gate"),
|
|
"collapsed_noremint": ("#7f7f7f", "collapsed, no re-mint (baseline)"),
|
|
}
|
|
|
|
|
|
def main(results_dir: str = "results/E6") -> None:
|
|
df, cfg = load_bundle(results_dir)
|
|
period = cfg["dynamics"]["remint"]["period"]
|
|
G = cfg["generations"]
|
|
remint_gens = list(range(period, G + 1, period))
|
|
|
|
fig, axes = plt.subplots(1, 2, figsize=(13, 4.6))
|
|
|
|
# Panel 1: forward KL to the ORIGINAL truth
|
|
ax = axes[0]
|
|
for arm, (c, lab) in STYLE.items():
|
|
s = df[df["arm"] == arm].groupby("generation")["forward_kl"]
|
|
mean, sem = s.mean(), s.sem()
|
|
ax.plot(mean.index, mean.values, color=c, label=lab)
|
|
ax.fill_between(mean.index, mean - 1.96 * sem, mean + 1.96 * sem,
|
|
color=c, alpha=0.15)
|
|
for g in remint_gens:
|
|
ax.axvline(g, ls=":", color="k", lw=0.8, alpha=0.5)
|
|
ax.set(xlabel="generation", ylabel=r"forward KL to ORIGINAL truth",
|
|
title="Re-minting while collapsed locks in divergence")
|
|
ax.legend(frameon=False, fontsize=8)
|
|
|
|
# Panel 2: heterozygosity (which arms are collapsed; gate reads this)
|
|
ax = axes[1]
|
|
gate = None
|
|
for arm, (c, lab) in STYLE.items():
|
|
s = df[df["arm"] == arm].groupby("generation")["heterozygosity"].mean()
|
|
ax.plot(s.index, s.values, color=c, label=lab)
|
|
# draw the gate threshold used by the gated arm
|
|
for v in cfg["sweep"][0]["values"]:
|
|
if v["name"] == "collapsed_gated":
|
|
gate = v["set"].get("dynamics.remint.H_gate")
|
|
if gate is not None:
|
|
ax.axhline(gate, ls="--", color="k", lw=1)
|
|
ax.annotate(f"gate H={gate}", (G * 0.02, gate + 0.02), fontsize=8)
|
|
for g in remint_gens:
|
|
ax.axvline(g, ls=":", color="k", lw=0.8, alpha=0.5)
|
|
ax.set(xlabel="generation", ylabel="heterozygosity $H$",
|
|
title="Diversity at re-mint time (the gate reads this)")
|
|
ax.legend(frameon=False, fontsize=8)
|
|
|
|
fig.suptitle("E6 — re-minting is irreversible; gate it on diversity", y=1.02)
|
|
fig.tight_layout()
|
|
savefig(fig, results_dir, "E6")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main(*sys.argv[1:])
|