PREREG_flat_stick outcome: NOT accepted. Sticky regime under the projection: CHA 3220 -> 3019 (W1 holds), flat fun3-6 1823 -> 1057 (W4, near pure bisection 1044), guarantee holds (W3), but APS 2806 -> 6781 (W2 fails): the unkept-promise flag enters on 134/154 APS problems and 20/25 non-flat CHA problems, and a false entry now sticks to the end of the run. W6 fails: the order read from the promise is m = inf in 163/174 entries (r >= 1/e; our step is not a pure tangent), so the derived split equals the midpoint on CHA (3019 both). Audit bug fixed and pinned: an infinite |f| at an end made the split nan. Server regression x2: 999 passed, 1 failed = the expected paper-number check.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -97,3 +97,64 @@ def test_the_gate_fires_on_a_pure_power():
|
||||
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
|
||||
|
||||
|
||||
# ---- PREREG_flat_stick_2026-09-21: the sticky flat regime and its midpoint ablation ----
|
||||
from simroot.pure import _order_from_promise, _order_split # noqa: E402
|
||||
|
||||
|
||||
@pytest.mark.parametrize("m", (2.0, 3.0, 5.0, 9.0, 19.0, 100.0))
|
||||
def test_the_order_is_read_back_from_its_own_promise(m):
|
||||
r = (1.0 - 1.0 / m) ** m
|
||||
assert _order_from_promise(r) == pytest.approx(m, rel=1e-9)
|
||||
|
||||
|
||||
def test_no_finite_order_at_or_above_one_over_e_gives_the_midpoint():
|
||||
assert math.isinf(_order_from_promise(math.exp(-1.0)))
|
||||
assert math.isinf(_order_from_promise(0.9))
|
||||
assert _order_split(-1.0, -3.0, 2.0, 5.0, math.inf) == 0.5
|
||||
|
||||
|
||||
@pytest.mark.parametrize("m", (1, 3, 5, 9))
|
||||
def test_the_split_lands_on_the_root_of_an_exact_power(m):
|
||||
f = lambda t: (t - 0.3) ** m # noqa: E731
|
||||
assert _order_split(-1.0, f(-1.0), 2.0, f(2.0), float(m)) == pytest.approx(0.3, abs=1e-12)
|
||||
|
||||
|
||||
def test_the_split_does_not_overflow_on_extreme_ends():
|
||||
x = _order_split(0.0, -1e-300, 1.0, 1e300, 2.0)
|
||||
assert 0.0 <= x < 1e-100
|
||||
x = _order_split(0.0, -1e300, 1.0, 1e-300, 2.0)
|
||||
assert 1.0 - x < 1e-100 and x <= 1.0
|
||||
|
||||
|
||||
@pytest.mark.parametrize("f,a,b", PROBS)
|
||||
@pytest.mark.parametrize("guard", ("project", "credit"))
|
||||
@pytest.mark.parametrize("ext", ("none", "pattern"))
|
||||
@pytest.mark.parametrize("gate", ("flatstick", "flatstickmid"))
|
||||
def test_the_guarantee_holds_with_the_sticky_regime(f, a, b, guard, ext, gate):
|
||||
x, n, ok = pure_root(f, a, b, XTOL, MAXFEV, similarity="ratio", scale="derived3",
|
||||
guard=guard, prestep=gate, 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
|
||||
|
||||
|
||||
@pytest.mark.parametrize("gate", ("flatstick", "flatstickmid"))
|
||||
def test_the_sticky_regime_is_silent_on_a_line_and_holds_on_a_power(gate):
|
||||
st = {}
|
||||
pure_root(lambda t: 3.0 * t - 1.0, -2.0, 5.0, XTOL, MAXFEV, similarity="ratio",
|
||||
scale="derived3", guard="project", prestep=gate, stats=st)
|
||||
assert st["pre_refused"] == 0
|
||||
st = {}
|
||||
_x, n, _ok = pure_root(lambda t: t ** 9, -1.0, 2.0, XTOL, MAXFEV, similarity="ratio",
|
||||
scale="derived3", guard="project", prestep=gate, stats=st)
|
||||
# once entered, every later non-forced step is a split: many, not one
|
||||
assert st["pre_refused"] >= 3, st
|
||||
|
||||
|
||||
def test_an_infinite_end_gives_the_midpoint_not_nan():
|
||||
"""Audit bug 2026-09-21: an infinite |f| made lq nan, and the nan step reached the
|
||||
safeguard before the loop checked finiteness."""
|
||||
assert _order_split(0.0, -math.inf, 2.0, 1.0, 3.0) == 1.0
|
||||
assert _order_split(0.0, -math.inf, 2.0, math.inf, 3.0) == 1.0
|
||||
|
||||
Reference in New Issue
Block a user