PREREG_flat_analogy_mem outcome (decided on the smoke, all 199 problems): NOT accepted. Remembering the analogy until the next flag: CHA 2635 -> 2552 (G2: 2625 -> 2548; flat fun3-6 1234 -> 1151, M4 holds) but APS 2806 -> 2814 (G2: 2782 -> 2787 = Chandrupatla, M2 fails) - the extra false entries. Server regression x2: 1069 passed, 1 failed = the expected paper-number check.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
vvs
2026-09-21 15:06:37 +01:00
co-authored by Claude Opus 5
parent 4bf8634757
commit 441373800b
4 changed files with 60 additions and 8 deletions
+20 -5
View File
@@ -746,7 +746,7 @@ def pure_root(f, a, b, xtol, maxfev, similarity="ratio", scale="derived",
raise ValueError(f"unknown space {space!r}")
if prestep not in ("none", "progress", "slope", "band", "defect", "simpair", "flat",
"flat2", "flatcreep", "flatstick", "flatstickmid", "flatstickexit",
"flatjudge", "flatanalog"):
"flatjudge", "flatanalog", "flatanalogmem"):
raise ValueError(f"unknown prestep {prestep!r}")
if prestep in ("band", "defect", "simpair") and scale not in (
"derived3", "derived3_cap", "derived3_m", "bracket", "far"):
@@ -804,6 +804,7 @@ def pure_root(f, a, b, xtol, maxfev, similarity="ratio", scale="derived",
sticky_m = None # order read at entry to the sticky flat regime (flatstick*)
judged = 0 # flatjudge: +1 the last point looked flat, -1 linear, 0 tie
configs = [] # flatanalog: the run's memory of (xi, phi, |dx|, |df|)
analogy_seen = False # flatanalogmem: the run has been judged analogous to its past
if stats is not None:
stats['forced'] = 0
stats['pre_refused'] = 0
@@ -1018,16 +1019,27 @@ def pure_root(f, a, b, xtol, maxfev, similarity="ratio", scale="derived",
else:
step = 0.5 * (A + B) - x
pre_refused += 1
if step is None and prestep == "flatanalog":
if step is None and prestep in ("flatanalog", "flatanalogmem"):
# PREREG_flat_analogy 2026-09-21. A pure power is similar to itself
# under zoom: its configuration RECURS, while a simple root's tends
# to the line. Enter on the unkept promise only when the current
# configuration is nearer to its own past than to the line AND the
# analogous pair scales as a power of order >= 2. Every state the
# gate sees joins the memory after it has been judged.
# PREREG_flat_analogy_mem 2026-09-21 (flatanalogmem): the flag rises
# in the cycle's non-recurring phases, the analogy shows in the
# others - so the analogy is judged at EVERY state and remembered as
# a property of the run; the regime is entered at the next flag.
cur = _config3(x, fx, x_prev, f_prev, x_prev2, f_prev2)
if (sticky_m is None and last_model and f_prev != 0.0
and fx / f_prev >= 0.25 and _analogous_and_steep(cur, configs)):
flag = (sticky_m is None and last_model and f_prev != 0.0
and fx / f_prev >= 0.25)
if prestep == "flatanalogmem":
if _analogous_and_steep(cur, configs):
analogy_seen = True
enter = flag and analogy_seen
else:
enter = flag and _analogous_and_steep(cur, configs)
if enter:
sticky_m = math.inf
if stats is not None:
stats['stick_entries'] = stats.get('stick_entries', 0) + 1
@@ -1156,7 +1168,7 @@ def pure_root(f, a, b, xtol, maxfev, similarity="ratio", scale="derived",
w_before = abs(B - A)
mid_now, lin_mid = 0.5 * (A + B), 0.5 * (FA + FB) # before the bracket moves
fnew = g(x_new)
if (prestep in ("flatstickexit", "flatanalog") and sticky_m is not None
if (prestep in ("flatstickexit", "flatanalog", "flatanalogmem") and sticky_m is not None
and x_new == mid_now
and abs(fnew - lin_mid) < abs(fnew)):
# PREREG_flat_exit 2026-09-21. A midpoint evaluated in the regime is judged
@@ -1165,6 +1177,9 @@ def pure_root(f, a, b, xtol, maxfev, similarity="ratio", scale="derived",
# like the linear one - the regime is left and the model steps again.
# Ordinal: two distances compared, no threshold; a tie stays.
sticky_m = None
# flatanalogmem: "linear" refutes "flat" - the remembered analogy is
# cleared and must be established anew (PREREG_flat_analogy_mem)
analogy_seen = False
if stats is not None:
stats['stick_exits'] = stats.get('stick_exits', 0) + 1
if prestep == "flatjudge":
File diff suppressed because one or more lines are too long
+6 -3
View File
@@ -422,10 +422,12 @@ def main():
exitmode = "--flatexit" in sys.argv # the sticky regime with an exit by similarity
judgemode = "--flatjudge" in sys.argv # one similarity judgment at entry and exit
analogmode = "--flatanalog" in sys.argv # entry by analogy with the run's own past
memmode = "--flatanalogmem" in sys.argv # the analogy remembered as a property of the run
combomode = "--combo" in sys.argv # modes A and B together
pointsmode = "--points" in sys.argv # mode A: triple by shape
dirmode = "--direction" in sys.argv # mode B: far end by dissimilarity
specs = (build_grid_flat(smoke, ("flatanalog", "flatstickexit")) if analogmode else
specs = (build_grid_flat(smoke, ("flatanalogmem", "flatanalog")) if memmode else
build_grid_flat(smoke, ("flatanalog", "flatstickexit")) if analogmode else
build_grid_flat(smoke, ("flatjudge", "flatstickexit")) if judgemode else
build_grid_flat(smoke, ("flatstickexit", "flatstickmid")) if exitmode else
build_grid_flat(smoke, ("flatstick", "flatstickmid")) if stickmode else
@@ -458,8 +460,9 @@ def main():
# the published sweep_full.json is what verify_article.py checks the paper
# against, so the log grid never writes into it
if analogmode or judgemode or exitmode or stickmode or creepmode or flat2mode or flatmode or ext2mode or extmode or decmode or ordermode or capmode or combomode or pointsmode or dirmode:
base = ("sweep_flatanalog" if analogmode else
if memmode or analogmode or judgemode or exitmode or stickmode or creepmode or flat2mode or flatmode or ext2mode or extmode or decmode or ordermode or capmode or combomode or pointsmode or dirmode:
base = ("sweep_flatanalogmem" if memmode else
"sweep_flatanalog" if analogmode else
"sweep_flatjudge" if judgemode else
"sweep_flatexit" if exitmode else
"sweep_flatstick" if stickmode else
+33
View File
@@ -267,3 +267,36 @@ def test_a_line_is_never_analogous_and_an_exact_power_repeats_with_its_order():
new = _config3(0.1, p(0.1), 0.2, p(0.2), 0.4, p(0.4)) # the same shape, zoomed by 4
assert new[0] == pytest.approx(old[0]) and new[1] == pytest.approx(old[1])
assert _analogous_and_steep(new, [old])
# ---- PREREG_flat_analogy_mem_2026-09-21: the analogy remembered as a property of the run ----
@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_remembered_analogy(f, a, b, guard, ext):
x, n, ok = pure_root(f, a, b, XTOL, MAXFEV, similarity="ratio", scale="derived3",
guard=guard, prestep="flatanalogmem", 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_remembered_analogy_spares_simple_roots_and_enters_no_later():
"""Measured before pinning: simple roots cost exactly the rule without the regime;
on powers the entry is never later than the same-state analogy (x^19: 67 -> 57)."""
for f, a, b in ((lambda t: 3.0 * t - 1.0, -2.0, 5.0),
(lambda t: t ** 3 - 2.0 * t - 5.0, 1.0, 4.0),
(lambda t: math.exp(t) - 2.0, 0.0, 3.0)):
st = {}
_x, n1, _ = pure_root(f, a, b, XTOL, MAXFEV, similarity="ratio", scale="derived3",
guard="project", prestep="flatanalogmem", stats=st)
_x, n0, _ = pure_root(f, a, b, XTOL, MAXFEV, similarity="ratio", scale="derived3",
guard="project")
assert st.get("stick_entries", 0) == 0 and n1 == n0
for f, a, b in ((lambda t: t ** 9, -1.0, 2.0), (lambda t: t ** 19, -10.0, 100.0),
(lambda t: 6.0 * (t - 2.0) ** 5, 0.0, 10.0)):
_x, nm, _ = pure_root(f, a, b, XTOL, MAXFEV, similarity="ratio", scale="derived3",
guard="project", prestep="flatanalogmem")
_x, na, _ = pure_root(f, a, b, XTOL, MAXFEV, similarity="ratio", scale="derived3",
guard="project", prestep="flatanalog")
assert nm <= na, (nm, na)