Controls K1/K2: code and two PREREG amendments, committed before the full run.
simroot/pure.py: flatlagmempt / flatbandmempt / flatflagmempt - A' with only the flat detector swapped (Lagouanelle without declining outside (0,1), with memory; Chandrupatla's band; none). A' itself is untouched: bit-identical to the compiled simbracket on all 868 problems (x2). sweep_controls.py: K2 through sweep_fourth's harness, K1 with the oracle order m*. Amendment 1: m* <= 0 is undefined (aps.15.22-30, C0.04 crashed the first full attempt). Amendment 2 (after the smokes; only corpus-level K1 sums and corpus-4 K2 sums were seen): each side's slope rounded to 0.01, m* defined only when both sides show a zero (jumps C0.03, aps.15.21), group 'multiple/fractional' = m* >= 2 or m* <= 2/3, the branches of section 8.1 (simple roots measured at 0.99999 fell under the registered 'm* < 1'). tests/test_article_numbers.py: the verifier test runs on Linux only (the paper's numbers are a Linux run; libm's last digit differs elsewhere, e.g. 4461 vs 4462). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
+61
-8
@@ -634,6 +634,31 @@ def _analogy_order(cur, past, translation=False):
|
||||
return math.log(lf) / math.log(lx)
|
||||
|
||||
|
||||
def _lagouanelle_raw(x2, f2, x1, f1, x0, f0):
|
||||
"""PREREG_controls_2026-09-22 (control K2): Lagouanelle's order from the parabola through the
|
||||
last three points WITHOUT declining outside (0, 1): theta = f f''/f'^2, m = 1/(1 - theta) for
|
||||
theta < 1 (so 0 < m < 1 when theta < 0, the fractional branch), m = inf for theta >= 1. None
|
||||
when f' is zero, not finite, or its square underflows. A control, not part of A'."""
|
||||
if x0 is None or len({x0, x1, x2}) < 3:
|
||||
return None
|
||||
d01 = (f1 - f0) / (x1 - x0)
|
||||
d12 = (f2 - f1) / (x2 - x1)
|
||||
d012 = (d12 - d01) / (x2 - x0)
|
||||
fp = d12 + d012 * (x2 - x1)
|
||||
fpp = 2.0 * d012
|
||||
if fp == 0.0 or not math.isfinite(fp) or not math.isfinite(fpp):
|
||||
return None
|
||||
den = fp * fp
|
||||
if den == 0.0:
|
||||
return None
|
||||
theta = f2 * fpp / den
|
||||
if not math.isfinite(theta):
|
||||
return None
|
||||
if theta >= 1.0:
|
||||
return math.inf
|
||||
return 1.0 / (1.0 - theta)
|
||||
|
||||
|
||||
def _analogous_and_steep(cur, past):
|
||||
"""Is the configuration nearer to its own past than to the line phi = xi, and does the
|
||||
analogous pair scale like a power of order m >= 2? Two ordinal judgments and the
|
||||
@@ -772,15 +797,18 @@ def pure_root(f, a, b, xtol, maxfev, similarity="ratio", scale="derived",
|
||||
parts = prestep.split("+")
|
||||
cats = ({"defect"}, {"contra"}, {"exp"}, {"half"}, {"close"}, {"sub"},
|
||||
{"flatanalog", "flatanalogmem", "flatanalogpt",
|
||||
"flatanalogmempt"})
|
||||
"flatanalogmempt", "flatlagmempt", "flatbandmempt",
|
||||
"flatflagmempt"})
|
||||
if (len(parts) != len(set(parts)) or any(not any(p in c for c in cats) for p in parts)
|
||||
or any(sum(p in c for p in parts) > 1 for c in cats)):
|
||||
raise ValueError(f"unknown composite prestep {prestep!r}")
|
||||
if (("exp" in parts or "sub" in parts)
|
||||
and not any(p.startswith("flatanalog") for p in parts)):
|
||||
if "exp" in parts and not any(p.startswith("flatanalog") for p in parts):
|
||||
# the translation limit changes how the analogy reads its order; without the
|
||||
# flat regime there is no analogy to read (PREREG_flat_exp_limit)
|
||||
raise ValueError("prestep component 'exp' needs a flatanalog* component")
|
||||
if "sub" in parts and not any(p.startswith("flat") for p in parts):
|
||||
# the overshoot branch enters the flat regime; it needs one (PREREG_close_sub)
|
||||
raise ValueError("prestep component 'sub' needs a flat* regime component")
|
||||
elif prestep not in ("none", "progress", "slope", "band", "defect", "simpair", "flat",
|
||||
"flat2", "flatcreep", "flatstick", "flatstickmid", "flatstickexit",
|
||||
"flatjudge", "flatanalog", "flatanalogmem", "contra",
|
||||
@@ -789,10 +817,17 @@ def pure_root(f, a, b, xtol, maxfev, similarity="ratio", scale="derived",
|
||||
parts = prestep.split("+")
|
||||
pre_dec = next((p for p in parts if p in ("band", "defect", "simpair")), "none")
|
||||
pre_flat = next((p for p in parts if p in ("flatanalog", "flatanalogmem", "flatanalogpt",
|
||||
"flatanalogmempt")), "none")
|
||||
"flatanalogmempt", "flatlagmempt",
|
||||
"flatbandmempt", "flatflagmempt")), "none")
|
||||
# PREREG_flat_order_point: the "pt" twins split at the point from the pair's order
|
||||
flat_mem = pre_flat in ("flatanalogmem", "flatanalogmempt")
|
||||
flat_pt = pre_flat in ("flatanalogpt", "flatanalogmempt")
|
||||
# PREREG_controls_2026-09-22: flatlag/flatband/flatflag are A' with ONLY the detector swapped
|
||||
# (Lagouanelle with memory, Chandrupatla's band, no detector); memory, split, exit unchanged
|
||||
detector = {"flatlagmempt": "lag", "flatbandmempt": "band",
|
||||
"flatflagmempt": "flag"}.get(pre_flat, "analogy")
|
||||
flat_mem = pre_flat in ("flatanalogmem", "flatanalogmempt", "flatlagmempt", "flatbandmempt",
|
||||
"flatflagmempt")
|
||||
flat_pt = pre_flat in ("flatanalogpt", "flatanalogmempt", "flatlagmempt", "flatbandmempt",
|
||||
"flatflagmempt")
|
||||
pre_contra = "contra" in parts
|
||||
pre_exp = "exp" in parts # PREREG_flat_exp_limit: translation similarity, m = inf
|
||||
pre_half = "half" in parts # PREREG_half_contra: the half promised vs the bracket
|
||||
@@ -1089,7 +1124,11 @@ def pure_root(f, a, b, xtol, maxfev, similarity="ratio", scale="derived",
|
||||
cur = _config3(x, fx, x_prev, f_prev, x_prev2, f_prev2)
|
||||
flag = (sticky_m is None and last_model and f_prev != 0.0
|
||||
and fx / f_prev >= 0.25)
|
||||
m_pair = _analogy_order(cur, configs, translation=pre_exp)
|
||||
m_now = None # controls band/flag: the split reads the current m_L
|
||||
if detector == "analogy":
|
||||
m_pair = _analogy_order(cur, configs, translation=pre_exp)
|
||||
else:
|
||||
m_pair = _lagouanelle_raw(x, fx, x_prev, f_prev, x_prev2, f_prev2)
|
||||
steep = m_pair is not None and m_pair >= 2.0
|
||||
# PREREG_close_sub 2026-09-21 (sub): the tangent step loses to a halving
|
||||
# when |1 - 1/m| > 1/2 - for m > 2 (undershoot, the branch above) AND
|
||||
@@ -1097,6 +1136,19 @@ def pure_root(f, a, b, xtol, maxfev, similarity="ratio", scale="derived",
|
||||
# a sign change; the pair's order says which branch it is.
|
||||
shallow = (pre_sub and m_pair is not None
|
||||
and 0.0 < m_pair <= 2.0 / 3.0)
|
||||
if detector in ("band", "flag"):
|
||||
# PREREG_controls K2-P / K2-F: the regime is recognised by
|
||||
# Chandrupatla's band (band rejects the triple) or not at all;
|
||||
# the split uses m_L of the current state, inf if undefined
|
||||
m_now = math.inf if m_pair is None else m_pair
|
||||
if detector == "band":
|
||||
rej = _decide_refuse("band", S, z_now, x, fx, x_prev, f_prev,
|
||||
x_prev2, f_prev2)
|
||||
else:
|
||||
rej = True
|
||||
steep = rej
|
||||
shallow = pre_sub and rej
|
||||
m_pair = m_now
|
||||
flag_over = (pre_sub and sticky_m is None and last_model
|
||||
and f_prev != 0.0 and fx / f_prev <= -0.25)
|
||||
if flat_mem:
|
||||
@@ -1129,7 +1181,8 @@ def pure_root(f, a, b, xtol, maxfev, similarity="ratio", scale="derived",
|
||||
if flat_pt:
|
||||
# PREREG_flat_order_point 2026-09-21: split where |f| ~
|
||||
# |x - r|^m puts the root, m read from the analogous pair
|
||||
regime_target = _order_split(A, FA, B, FB, analogy_m)
|
||||
regime_target = _order_split(
|
||||
A, FA, B, FB, analogy_m if m_now is None else m_now)
|
||||
step = regime_target - x
|
||||
else:
|
||||
step = 0.5 * (A + B) - x
|
||||
|
||||
Reference in New Issue
Block a user