Flat regime (PREREG_flat_regime): the unkept-promise flag - after a model step that did not cross the root, r = f_new/f_old >= 1/4, the tangent-versus-halving break-even at m = 2 - RECOGNISES the regime (stage 1: 53.6% of model steps flagged on the flat families against 21.6% on APS and 17.0% on fun1; recall ten times the m>=2 estimator's 5.8%) and cuts the wide-bracket set by 350-490 wherever the budget does not already bind: safe 3390 -> 3037, step 3524 -> 3037, unguarded 4104 -> 3198.

NOT accepted into the proposed rule by the stop rule: under the projection the flat families are already budget-bound (CHA 3220 -> 3198 only) while the false flags on APS cost 2806 -> 3029 (Z2 fails); with G2 both sets fail. The per-problem edge over Chandrupatla on APS turns into 26/72/55. Guarantee intact in every cell. Next candidate, not pre-registered: require the promise to fail twice in a row.

Regression on the branch: 918 pass (twice); the one red test is the paper-number check awaiting the paper update.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
vvs
2026-09-21 13:25:56 +01:00
co-authored by Claude Opus 5
parent 9df1aa5f13
commit e7e74d71e5
7 changed files with 195 additions and 4 deletions
+52
View File
@@ -0,0 +1,52 @@
"""Pins for PREREG_flat_regime_2026-09-21.md: the flat gate (prestep='flat')."""
from __future__ import annotations
import math
import pytest
from simroot.pure import pure_root
XTOL, MAXFEV = 1e-12, 200
PROBS = (
(lambda t: t ** 3 - 2.0 * t - 5.0, 1.0, 4.0),
(lambda t: math.exp(t) - 2.0, 0.0, 3.0),
(lambda t: 6.0 * (t - 2.0) ** 5, 0.0, 10.0),
(lambda t: t ** 19, -10.0, 100.0),
)
@pytest.mark.parametrize("f,a,b", PROBS)
@pytest.mark.parametrize("guard", ("project", "credit", "safe"))
def test_the_default_is_untouched(f, a, b, guard):
ref = pure_root(f, a, b, XTOL, MAXFEV, similarity="ratio", scale="derived3", guard=guard)
off = pure_root(f, a, b, XTOL, MAXFEV, similarity="ratio", scale="derived3", guard=guard,
prestep="none")
assert ref == off
@pytest.mark.parametrize("f,a,b", PROBS)
@pytest.mark.parametrize("guard", ("project", "credit"))
@pytest.mark.parametrize("ext", ("none", "pattern"))
def test_the_guarantee_holds_with_the_gate(f, a, b, guard, ext):
x, n, ok = pure_root(f, a, b, XTOL, MAXFEV, similarity="ratio", scale="derived3",
guard=guard, prestep="flat", extrapolate=ext)
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 test_the_gate_never_fires_where_the_model_is_exact():
"""On a straight line the model's step lands on the root: r = 0, never >= 1/4."""
st = {}
pure_root(lambda t: 3.0 * t - 1.0, -2.0, 5.0, XTOL, MAXFEV, similarity="ratio",
scale="derived3", guard="project", prestep="flat", stats=st)
assert st["pre_refused"] == 0
def test_the_gate_fires_on_a_pure_power():
"""On x^9 the tangent step leaves (8/9)^9 = 0.35 of |f| on the same side."""
st = {}
pure_root(lambda t: t ** 9, -1.0, 2.0, XTOL, MAXFEV, similarity="ratio",
scale="derived3", guard="project", prestep="flat", stats=st)
assert st["pre_refused"] > 0