PREREG_defect_contra_flat outcome (smoke, all 199 problems). Goal (below Chandrupatla on both) NOT reached by any cell: best CHA 2537 vs 2441. Best total: defect+flatanalogmem APS 2530 / CHA 2561 = 5091 < Chandrupatla 5228 (first time), C1-C3 hold; ablation: defect earns APS +284 (costs CHA 9), remembered analogy earns CHA +649 (costs APS 7). contra earned without defect (APS 2806 -> 2785, CHA 3220 -> 3198; with the remembered analogy 2792 / 2537, the best CHA), redundant with defect (defect+contra = defect). fun9: 105 -> 81 (Chandrupatla 55). Remaining CHA gap 120: flat +88, fun1 +20, fun9 +26. Server regression x2: 1116 passed, 1 failed = the paper-number check.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
vvs
2026-09-21 15:57:15 +01:00
co-authored by Claude Opus 5
parent 3c92d610d6
commit 3d9287ec2c
6 changed files with 205 additions and 12 deletions
+38
View File
@@ -300,3 +300,41 @@ def test_the_remembered_analogy_spares_simple_roots_and_enters_no_later():
_x, na, _ = pure_root(f, a, b, XTOL, MAXFEV, similarity="ratio", scale="derived3",
guard="project", prestep="flatanalog")
assert nm <= na, (nm, na)
# ---- PREREG_defect_contra_flat_2026-09-21: composite prestep and the sign contradiction ----
@pytest.mark.parametrize("bad", ("defect+defect", "defect+band", "flatanalog+flatanalogmem",
"none+defect", "defect+flat", "contra+slope"))
def test_a_malformed_composite_is_refused(bad):
with pytest.raises(ValueError):
pure_root(lambda t: t - 1.0, 0.0, 3.0, XTOL, MAXFEV, similarity="ratio",
scale="derived3", guard="project", prestep=bad)
@pytest.mark.parametrize("f,a,b", PROBS)
@pytest.mark.parametrize("guard", ("project", "credit"))
@pytest.mark.parametrize("pre", ("contra", "defect+contra", "defect+flatanalogmem",
"defect+contra+flatanalog", "defect+contra+flatanalogmem"))
def test_the_guarantee_holds_with_composites(f, a, b, guard, pre):
x, n, ok = pure_root(f, a, b, XTOL, MAXFEV, similarity="ratio", scale="derived3",
guard=guard, prestep=pre)
assert ok and min(a, b) <= x <= max(a, b)
half = math.ceil(math.log2(abs(b - a) / XTOL))
assert n <= (2 * half + 3 if guard == "project" else half + 4), n
def _fun9(t):
return math.exp(t) - 2.0 - 0.01 / t ** 2 + 0.000002 / t ** 3
def test_contra_is_silent_on_a_line_and_breaks_the_fun9_well():
"""Measured before pinning: fun9.4 ([2e-4, 27]) costs 39 without, 21 with contra."""
st = {}
pure_root(lambda t: 3.0 * t - 1.0, -2.0, 5.0, XTOL, MAXFEV, similarity="ratio",
scale="derived3", guard="project", prestep="contra", stats=st)
assert st["pre_refused"] == 0
_x, n0, _ = pure_root(_fun9, 0.0002, 27.0, XTOL, MAXFEV, similarity="ratio",
scale="derived3", guard="project")
_x, n1, ok = pure_root(_fun9, 0.0002, 27.0, XTOL, MAXFEV, similarity="ratio",
scale="derived3", guard="project", prestep="contra")
assert ok and n1 < n0, (n0, n1)