Point 1. The base step's order is Muller's 1.839, not 2: the derivative of the parabola through
the last three points errs by f'''/6 (x_n - x_{n-1})(x_n - x_{n-2}) = O(e_{n-1} e_{n-2}).
order_high_precision.py (3000 digits, to 1e-2900): 1.840 on cos x - x, e^x - 2, x^3 - x - 2,
sin x - 1/2; 2.000 only on x^2 - 2; two-point 1.618. The double-precision medians (2.000, 1.94)
are removed from the text.
Point 3. Every protocol number is re-scored under the criterion of section 9 - a sign change
within 1e-6 or f(x) == 0. rescore_uniform.py re-runs all 2779 distinct configurations of the 25
protocol sweeps on APS and CHA (the runs did not keep x) -> sweep_uniform.json, same row format;
it reproduces the APS/CHA lines of Table 10 exactly (built-in check). verify_article.py,
audit_similarity_places.py and the gap diagnostics read the re-scored data; the multiplier and
endowment measurements score by the same criterion. Table 7 (two criteria side by side) is gone;
7.3 now explains why the criterion is a sign change. Consequences stated in the text: the base
rule 2634 / 2357 against Chandrupatla 2595 / 1505 (1.5% behind on APS, no longer "level"); A'
2259 / 1074 (12.9% and 28.6% below Chandrupatla); the defect reading 2351 is second to the
shape reading 2337, not the record; the remembered analogy is level with no regime (2633 vs
2634) under this criterion; Table 9a's range is 19% to 425%.
Point 8. report_sweep.head_to_head counts every problem, failures charged (it counted only the
problems both methods solved, which is why Table 8 rows summed to 153 and 40). Family-level
comparisons added (A' vs Chandrupatla 8/1/6 of 15 and 7/0/2 of 9 families, not significant), and
an independence paragraph in section 9.
Point 11. sweep_itp.py: ITP (recommended constants and per-problem oracle) on all six corpora ->
Table 10; behind A' on every corpus, 0 bound violations.
Points 7, 9, 10 and the internals: the 2x bound is ours, not the rivals' promise; the law
predicts the group order only; "outside the proven bracket" explained (narrowest bracket of all
observed signs); 7.4's fun1 paragraph corrected (five costs under safe; the unguarded numbers
belong to fun1.4, fun1.5 and to fun3.1, fun5.1 separately); Table 1's last cell; the corpus-4
composition and odd multiplicities stated, also in the abstract.
build_tex.py: pdflatex output decoded with errors="replace" (a UTF-8 character cut by TeX's log
wrap crashed the build). Table 10 column widths rebalanced.
Checks: verify_article on the server 500 OK / 0 BAD (467 existing with the new values, 33 new);
regression x2 on the server 1232 passed, 0 failed; PDF 28 pages, 0 errors, 0 undefined, 0 overfull.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
524 lines
31 KiB
Python
524 lines
31 KiB
Python
"""Revision 1: verify_article.py checks the numbers of the revised text (single criterion,
|
|
head-to-head over every problem) and the new claims (order, ITP in Table 10, families,
|
|
negative items 5 and 9, section 7.3's solved counts). Exact anchors, each found exactly
|
|
once, or nothing is written.
|
|
|
|
python -u apply_verify_revision1.py
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
PATH = "verify_article.py"
|
|
REPL = []
|
|
|
|
|
|
def R(old, new):
|
|
REPL.append((old, new))
|
|
|
|
|
|
# ---- main(): the base rule, its head-to-head, the earned variant, the replacing guards
|
|
R(''' for setname, pl, tot, sol in (("APS", 3, 2806, 153),
|
|
("CHA", 45, 3220, 40)):''',
|
|
''' for setname, pl, tot, sol in (("APS", 3, 2634, 154),
|
|
("CHA", 49, 2357, 45)):''')
|
|
R(''' + row(rows, "CHA", PROPOSED)["total"], 6026)
|
|
|
|
print("\\nHead to head of the proposed method:")''',
|
|
''' + row(rows, "CHA", PROPOSED)["total"], 4991)
|
|
|
|
print("\\nHead to head of the proposed method:")''')
|
|
R(''' ("APS", "chandrupatla", (87, 24, 42)),
|
|
("APS", "toms748", (86, 16, 51)),
|
|
("APS", "brent", (102, 11, 40)),
|
|
("APS", "itp", (132, 3, 18)),
|
|
("APS", "itp_oracle", (121, 4, 28)),
|
|
("APS", "bisection", (152, 1, 0)),
|
|
("CHA", "chandrupatla", (9, 5, 26)),
|
|
("CHA", "toms748", (31, 1, 8)),
|
|
("CHA", "brent", (30, 4, 4)),
|
|
("CHA", "itp", (17, 0, 23)),
|
|
("CHA", "itp_oracle", (16, 0, 24))]:''',
|
|
''' ("APS", "chandrupatla", (87, 24, 43)),
|
|
("APS", "toms748", (86, 16, 52)),
|
|
("APS", "brent", (102, 11, 41)),
|
|
("APS", "itp", (132, 3, 19)),
|
|
("APS", "itp_oracle", (121, 4, 29)),
|
|
("APS", "bisection", (152, 1, 1)),
|
|
("CHA", "chandrupatla", (11, 5, 29)),
|
|
("CHA", "toms748", (33, 1, 11)),
|
|
("CHA", "brent", (34, 4, 7)),
|
|
("CHA", "itp", (18, 1, 26)),
|
|
("CHA", "itp_oracle", (16, 1, 28))]:''')
|
|
R(''' check("APS vs Chandrupatla sign test p < 1e-4", sign_p(w, l) < 1e-4, True)''',
|
|
''' check("APS vs Chandrupatla sign test p (2 digits)", float(f"{sign_p(w, l):.2g}"), 0.00014)''')
|
|
R(''' for setname, pl, tot in (("APS", 29, 3568), ("CHA", 10, 3020)):''',
|
|
''' for setname, pl, tot in (("APS", 25, 3377), ("CHA", 9, 2073)):''')
|
|
R(''' + row(rows, "CHA", CREDIT)["total"], 6588)
|
|
check("credit costs 762 more on the canonical set",
|
|
row(rows, "APS", CREDIT)["total"] - row(rows, "APS", PROPOSED)["total"], 762)
|
|
for setname, opp, want in [("APS", "chandrupatla", (79, 3, 71)),
|
|
("APS", "toms748", (77, 9, 67)),
|
|
("APS", "brent", (78, 5, 70))]:''',
|
|
''' + row(rows, "CHA", CREDIT)["total"], 5450)
|
|
check("credit costs 743 more on the canonical set",
|
|
row(rows, "APS", CREDIT)["total"] - row(rows, "APS", PROPOSED)["total"], 743)
|
|
for setname, opp, want in [("APS", "chandrupatla", (79, 3, 72)),
|
|
("APS", "toms748", (78, 9, 67)),
|
|
("APS", "brent", (79, 5, 70))]:''')
|
|
R(''' check("credit APS vs Chandrupatla sign test p (rounded)", round(sign_p(w, l), 2), 0.57)''',
|
|
''' check("credit APS vs Chandrupatla sign test p (rounded)", round(sign_p(w, l), 2), 0.63)''')
|
|
R(''' check("APS unguarded", row(rows, "APS", "pure.ratio.derived3.none")["total"],
|
|
2806)
|
|
cha_none = row(rows, "CHA", "pure.ratio.derived3.none")
|
|
check("CHA unguarded total", cha_none["total"], 4104)
|
|
check("CHA unguarded solved", cha_none["solved"], 35)''',
|
|
''' check("APS unguarded", row(rows, "APS", "pure.ratio.derived3.none")["total"],
|
|
2634)
|
|
cha_none = row(rows, "CHA", "pure.ratio.derived3.none")
|
|
check("CHA unguarded total", cha_none["total"], 3391)
|
|
check("CHA unguarded solved", cha_none["solved"], 39)''')
|
|
R(''' check("APS bracket-guard", row(rows, "APS", "pure.ratio.derived3.bracket")["total"],
|
|
7260)
|
|
check("APS both-guard", row(rows, "APS", "pure.ratio.derived3.both")["total"],
|
|
7239)''',
|
|
''' check("APS bracket-guard", row(rows, "APS", "pure.ratio.derived3.bracket")["total"],
|
|
7068)
|
|
check("APS both-guard", row(rows, "APS", "pure.ratio.derived3.both")["total"],
|
|
7046)''')
|
|
# ---- the field
|
|
R(''' for lbl, pl, tot in [("chandrupatla", 1, 2787), ("toms748", 4, 2820),
|
|
("brent", 5, 2889), ("dekker", 12, 3158),
|
|
("itp_oracle", 13, 3260), ("ridders", 20, 3313),
|
|
("itp", 34, 3957), ("illinois", 73, 7045),
|
|
("bisection", 79, 7530), ("regula_falsi", 244, 10560)]:''',
|
|
''' for lbl, pl, tot in [("chandrupatla", 1, 2595), ("toms748", 4, 2636),
|
|
("brent", 5, 2707), ("dekker", 232, 3158),
|
|
("itp_oracle", 11, 3068), ("ridders", 15, 3124),
|
|
("itp", 29, 3767), ("illinois", 237, 7045),
|
|
("bisection", 73, 7338), ("regula_falsi", 244, 10560)]:''')
|
|
R(''' check("CHA rank 1 label", top["label"], "pure.sqrt.bracket.project")
|
|
check("CHA rank 1 solves one more than anyone else", top["CHA"]["solved"], 41)
|
|
for lbl, pl, tot in [("chandrupatla", 2, 2441), ("itp_oracle", 3, 2647),
|
|
("itp", 6, 2896), ("bisection", 16, 3090),
|
|
("toms748", 159, 4000), ("brent", 227, 4115)]:''',
|
|
''' check("CHA rank 1 label", top["label"], "chandrupatla")
|
|
check("CHA rank 1 solves all 45", top["CHA"]["solved"], 45)
|
|
for lbl, pl, tot in [("chandrupatla", 1, 1505), ("itp_oracle", 2, 1675),
|
|
("itp", 5, 1946), ("bisection", 15, 2136),
|
|
("toms748", 158, 3088), ("brent", 227, 3238)]:''')
|
|
R(''' check("CHA brent solved", row(rows, "CHA", "brent")["solved"], 38)''',
|
|
''' check("CHA brent solved", row(rows, "CHA", "brent")["solved"], 43)''')
|
|
R(''' check("chandrupatla, both sets", cha_both, 5228)''',
|
|
''' check("chandrupatla, both sets", cha_both, 4100)''')
|
|
R(''' row(rows, "CHA", "pure.cbrt.derived3.project")["total"], 4109)''',
|
|
''' row(rows, "CHA", "pure.cbrt.derived3.project")["total"], 3204)''')
|
|
R(''' check("single fixed choice, both sets", single, 6026)
|
|
check("switch by benchmark set, both sets", switched, 6915)''',
|
|
''' check("single fixed choice, both sets", single, 4991)
|
|
check("switch by benchmark set, both sets", switched, 5838)''')
|
|
R(''' want = {("derived3", "lin"): 6893, ("derived3", "quad"): 22315,
|
|
("derived", "lin"): 6981, ("derived", "quad"): 22206,
|
|
("bracket", "lin"): 10279, ("bracket", "quad"): 19127,
|
|
("start", "lin"): 16102, ("start", "quad"): 15345}''',
|
|
''' want = {("derived3", "lin"): 5764, ("derived3", "quad"): 21200,
|
|
("derived", "lin"): 5854, ("derived", "quad"): 21089,
|
|
("bracket", "lin"): 9149, ("bracket", "quad"): 18015,
|
|
("start", "lin"): 14983, ("start", "quad"): 14228}''')
|
|
R(''' for sim, v in [("ratio", 6560), ("exp_abs", 6895), ("rational", 7118),
|
|
("ratio_soft", 9578), ("sqrt", 10546), ("cbrt", 12002),
|
|
("exp_sq", 14307), ("rat_sq", 15102), ("cosine", 16394)]:''',
|
|
''' for sim, v in [("ratio", 5422), ("exp_abs", 5772), ("rational", 5993),
|
|
("ratio_soft", 8455), ("sqrt", 9411), ("cbrt", 10874),
|
|
("exp_sq", 13187), ("rat_sq", 13990), ("cosine", 15272)]:''')
|
|
R(''' for sc, v in [("derived3", 6560), ("derived", 6702), ("bracket", 9107),
|
|
("start", 14540)]:''',
|
|
''' for sc, v in [("derived3", 5422), ("derived", 5564), ("bracket", 7972),
|
|
("start", 13423)]:''')
|
|
R(''' verify_flat_regime_and_oos()
|
|
|
|
print()''',
|
|
''' verify_flat_regime_and_oos()
|
|
verify_revision1()
|
|
|
|
print()''')
|
|
# ---- placement modes
|
|
R(''' "sweep_slope.json": ("slope.ratio.derived3.project", 2848, 3114),
|
|
"sweep_points.json": ("pure+shape+slope.ratio.derived3.safe", 2527, 3126),
|
|
"sweep_direction.json": ("pure+dissim+slope.ratio.derived3.project", 2726, 2799),
|
|
"sweep_combo.json": ("pure+shape+dissim+slope.ratio.derived3.safe", 2884, 2871),
|
|
"sweep_gate.json": ("progress.ratio.derived.project", 4449, 3047),
|
|
"sweep_log.json": ("log.ratio_soft.derived.safe", 6940, 3541),''',
|
|
''' "sweep_slope.json": ("slope.ratio.derived3.project", 2663, 2170),
|
|
"sweep_points.json": ("pure+shape+slope.ratio.derived3.safe", 2337, 2177),
|
|
"sweep_direction.json": ("pure+dissim+slope.ratio.derived3.project", 2539, 1864),
|
|
"sweep_combo.json": ("pure+shape+dissim+slope.ratio.derived3.safe", 2695, 1928),
|
|
"sweep_gate.json": ("progress.ratio.derived.project", 4258, 2093),
|
|
"sweep_log.json": ("log.ratio_soft.derived.safe", 6749, 2598),''')
|
|
R(''' "both": (4522, 3675, 3406, 3241),
|
|
"bracket": (4606, 3542, 3602, 3359),
|
|
"credit": (5190, 4686, 3013, 2884),
|
|
"project": (6932, 6364, 4789, 4554),
|
|
"safe": (5987, 5229, 4134, 3954),
|
|
"step": (6435, 5551, 4287, 4068),
|
|
"none": (10676, 10043, 8265, 7794),''',
|
|
''' "both": (4331, 3485, 2469, 2306),
|
|
"bracket": (4418, 3352, 2671, 2428),
|
|
"credit": (4999, 4495, 2064, 1933),
|
|
"project": (6783, 6176, 4057, 3751),
|
|
"safe": (5803, 5040, 3218, 3032),
|
|
"step": (6251, 5362, 3371, 3146),
|
|
"none": (10676, 9855, 8265, 7424),''')
|
|
R(''' ("rational", "far", "none", "order"): (128, 10043)}''',
|
|
''' ("rational", "far", "none", "order"): (129, 9855)}''')
|
|
R('''ORDER_SLOPE_HARM = {("ratio", "derived3", "none", "none"): 2806,
|
|
("ratio", "derived3", "none", "order"): 2854}''',
|
|
'''ORDER_SLOPE_HARM = {("ratio", "derived3", "none", "none"): 2634,
|
|
("ratio", "derived3", "none", "order"): 2703}''')
|
|
R(''' ("ratio", "band", "project"): {"APS": 5432, "CHA": 3059},
|
|
("ratio", "band", "credit"): {"CHA": 2892},
|
|
("ratio", "none", "project"): {"APS": 2806},
|
|
("ratio", "defect", "project"): {"APS": 2523, "CHA": 3210},
|
|
("ratio_soft", "simpair", "project"): {"CHA": 2897},''',
|
|
''' ("ratio", "band", "project"): {"APS": 5242, "CHA": 2101},
|
|
("ratio", "band", "credit"): {"CHA": 1942},
|
|
("ratio", "none", "project"): {"APS": 2634},
|
|
("ratio", "defect", "project"): {"APS": 2351, "CHA": 2346},
|
|
("ratio_soft", "simpair", "project"): {"CHA": 1941},''')
|
|
R(''' check("defect APS solved", d["APS"]["solved"], 153)
|
|
check("defect both sets", d["APS"]["total"] + d["CHA"]["total"], 5733)
|
|
check("defect is the new canonical best (< 2527)", d["APS"]["total"] < 2527, True)''',
|
|
''' check("defect APS solved", d["APS"]["solved"], 154)
|
|
check("defect both sets", d["APS"]["total"] + d["CHA"]["total"], 4697)
|
|
check("defect second to the shape reading (2337 < defect)", 2337 < d["APS"]["total"], True)''')
|
|
# ---- the gap decomposition
|
|
R(''' check("problems where we lose", len(mo["lose"]), 33)''',
|
|
''' check("problems where we lose", len(mo["lose"]), 35)''')
|
|
R(''' check("non-degenerate states with one negative weight", mo["neg_ok"], 428)
|
|
check("bracketing states in total", mo["neg_all"], 431)''',
|
|
''' check("non-degenerate states with one negative weight", int(mo["neg_ok"]), 431)
|
|
check("bracketing states in total", mo["neg_all"], 434)''')
|
|
R(''' check("total gap on the losing problems", sum(gap.values()), 256)''',
|
|
''' check("total gap on the losing problems", sum(gap.values()), 262)''')
|
|
R(''' check("m>=2 on canonical states %", round(fl["APS (canonical)"][2], 1), 0.2)''',
|
|
''' check("m>=2 on canonical states %", float(round(fl["APS (canonical)"][2], 1)), 0.3)''')
|
|
R(''' check("log item: x-space control APS", xcell["APS"]["total"], 5822)
|
|
check("log item: x-space control CHA", xcell["CHA"]["total"], 3695)''',
|
|
''' check("log item: x-space control APS", xcell["APS"]["total"], 5635)
|
|
check("log item: x-space control CHA", xcell["CHA"]["total"], 2759)''')
|
|
# ---- 3.1, Tables 2-3, 5.1, section 7 under credit
|
|
R(''' for c, (aps, cha) in ((1.0, (4817, 2997)), (1.25, (2806, 2752)), (1.5, (2806, 2889)),
|
|
(2.0, (2806, 3220)), (3.0, (2806, 3756)), (4.0, (2806, 4006))):''',
|
|
''' for c, (aps, cha) in ((1.0, (4625, 2039)), (1.25, (2626, 1822)), (1.5, (2636, 1991)),
|
|
(2.0, (2634, 2357)), (3.0, (2634, 2936)), (4.0, (2634, 3229))):''')
|
|
R(''' for c0, (aps, cha) in ((0.1, (5344, 3051)), (0.5, (4656, 3002)), (1.0, (3568, 3020)),
|
|
(2.0, (3692, 2712)), (5.0, (3006, 2615))):''',
|
|
''' for c0, (aps, cha) in ((0.1, (5150, 2097)), (0.5, (4462, 2037)), (1.0, (3377, 2073)),
|
|
(2.0, (3502, 1757)), (5.0, (2819, 1666))):''')
|
|
R(''' sh = rm["shape reading (2527)"]
|
|
check("2527 at multiplier 1.25", sh[1.25][0], 2541)
|
|
check("2527 flat from 1.5 to 4", {sh[f][0] for f in (1.5, 2.0, 3.0, 4.0)}, {2527})
|
|
de = rm["defect reading (2523)"]
|
|
check("2523 flat from 1.25 to 4", {de[f][0] for f in (1.25, 1.5, 2.0, 3.0, 4.0)}, {2523})''',
|
|
''' sh = rm["shape reading (2527)"]
|
|
check("shape reading at multiplier 1.25", sh[1.25][0], 2351)
|
|
check("shape reading flat from 1.5 to 4", {sh[f][0] for f in (1.5, 2.0, 3.0, 4.0)}, {2337})
|
|
de = rm["defect reading (2523)"]
|
|
dv = [de[f][0] for f in (1.25, 1.5, 2.0, 3.0, 4.0)]
|
|
check("defect reading from 1.25 to 4: range", (min(dv), max(dv)), (2343, 2353))''')
|
|
R(''' for setname, lbl, pl in (("APS", PROJ, 3), ("APS", none_, 2), ("CHA", PROJ, 45),
|
|
("CHA", none_, 228), ("CHA", "pure.exp_abs.bracket.both", 4)):''',
|
|
''' for setname, lbl, pl in (("APS", PROJ, 3), ("APS", none_, 2), ("CHA", PROJ, 49),
|
|
("CHA", none_, 229), ("CHA", "pure.exp_abs.bracket.both", 3),
|
|
("CHA", "pure.exp_abs.bracket.bracket", 4),
|
|
("CHA", "pure.exp_abs.bracket.credit", 6),
|
|
("APS", CREDIT, 25), ("CHA", CREDIT, 9)):''')
|
|
R(''' check("CHA exp_abs.bracket.both total", by["pure.exp_abs.bracket.both"]["CHA"]["total"],
|
|
2736)''',
|
|
''' check("CHA exp_abs.bracket.both total", by["pure.exp_abs.bracket.both"]["CHA"]["total"],
|
|
1778)''')
|
|
R(''' (CREDIT, "APS", "itp_oracle", (86, 6, 61)),
|
|
(CREDIT, "CHA", "itp_oracle", (2, 2, 36)),
|
|
(CREDIT, "CHA", "bisection", (5, 0, 35)),
|
|
(PROJ, "APS", "chandrupatla", (87, 24, 42)),
|
|
(PROJ, "APS", "itp", (132, 3, 18)),
|
|
(PROJ, "APS", "itp_oracle", (121, 4, 28)),
|
|
(PROJ, "APS", "bisection", (152, 1, 0)),
|
|
(PROJ, "CHA", "toms748", (31, 1, 8)),
|
|
(PROJ, "CHA", "brent", (30, 4, 4)),
|
|
(PROJ, "CHA", "itp", (17, 0, 23)),
|
|
(PROJ, "CHA", "itp_oracle", (16, 0, 24))):''',
|
|
''' (CREDIT, "APS", "itp_oracle", (86, 6, 62)),
|
|
(CREDIT, "CHA", "itp_oracle", (2, 2, 41)),
|
|
(CREDIT, "CHA", "bisection", (5, 0, 40)),
|
|
(PROJ, "APS", "chandrupatla", (87, 24, 43)),
|
|
(PROJ, "APS", "itp", (132, 3, 19)),
|
|
(PROJ, "APS", "itp_oracle", (121, 4, 29)),
|
|
(PROJ, "APS", "bisection", (152, 1, 1)),
|
|
(PROJ, "CHA", "toms748", (33, 1, 11)),
|
|
(PROJ, "CHA", "brent", (34, 4, 7)),
|
|
(PROJ, "CHA", "itp", (18, 1, 26)),
|
|
(PROJ, "CHA", "itp_oracle", (16, 1, 28))):''')
|
|
R(''' for lbl, want in ((CREDIT, 6588), (PROJ, 6026), ("chandrupatla", 5228),
|
|
("itp_oracle", 5907), ("toms748", 6820), ("brent", 7004)):''',
|
|
''' for lbl, want in ((CREDIT, 5450), (PROJ, 4991), ("chandrupatla", 4100),
|
|
("itp_oracle", 4743), ("toms748", 5724), ("brent", 5945)):''')
|
|
R(''' for lbl, aps, cha in (("slope.ratio.derived3.credit", 3507, 2997),
|
|
("pure+shape+slope.ratio.derived3.credit", 3755, 3021),
|
|
("pure+dissim+slope.ratio.derived3.credit", 3857, 3002),
|
|
("pure+shape+dissim+slope.ratio.derived3.credit", 4354, 3037),
|
|
("defect.ratio.derived3.credit", 3545, 2949)):''',
|
|
''' for lbl, aps, cha in (("slope.ratio.derived3.credit", 3316, 2050),
|
|
("pure+shape+slope.ratio.derived3.credit", 3564, 2074),
|
|
("pure+dissim+slope.ratio.derived3.credit", 3666, 2052),
|
|
("pure+shape+dissim+slope.ratio.derived3.credit", 4163, 2087),
|
|
("defect.ratio.derived3.credit", 3354, 2002)):''')
|
|
R(''' check("its total over both sets", top["APS"]["total"] + top["CHA"]["total"], 6111)''',
|
|
''' check("its total over both sets", top["APS"]["total"] + top["CHA"]["total"], 4965)''')
|
|
R(''' d["APS"]["total"] + d["CHA"]["total"], 6494)''',
|
|
''' d["APS"]["total"] + d["CHA"]["total"], 5356)''')
|
|
R(''' "sweep_direction.json": ("CHA", "pure+dissim+slope.ratio.derived3.safe", 2695),
|
|
"sweep_gate.json": ("CHA", "progress.ratio_soft.derived.safe", 2888),''',
|
|
''' "sweep_direction.json": ("CHA", "pure+dissim+slope.ratio.derived3.safe", 1752),
|
|
"sweep_gate.json": ("CHA", "progress.ratio_soft.derived.safe", 1929),''')
|
|
R(''' check(f"{lbl} solved", d["APS"]["solved"] + d["CHA"]["solved"], 193)''',
|
|
''' check(f"{lbl} solved", d["APS"]["solved"] + d["CHA"]["solved"], 199)''')
|
|
# ---- section 8 development grids
|
|
R(''' ("sweep_flat.json", f"flat.{P}", 3029, 3198),
|
|
("sweep_flat2.json", f"flat2.{P}", 2803, 3341),
|
|
("sweep_flatcreep.json", f"flatcreep.{P}", 2878, 3354),
|
|
("sweep_flatstick.json", f"flatstickmid.{P}", 6897, 3019),
|
|
("sweep_flatexit.json", f"flatstickexit.{P}", 3125, 2503),
|
|
("sweep_flatjudge.json", f"flatjudge.{P}", 3009, 2486),
|
|
("sweep_orderpt.json", f"flatanalogmem.{P}", 2814, None),
|
|
("sweep_half.json", f"half.{P}", 2564, None)):''',
|
|
''' ("sweep_flat.json", f"flat.{P}", 2839, 2243),
|
|
("sweep_flat2.json", f"flat2.{P}", 2613, 2388),
|
|
("sweep_flatcreep.json", f"flatcreep.{P}", 2688, 2399),
|
|
("sweep_flatstick.json", f"flatstickmid.{P}", 6707, 2063),
|
|
("sweep_flatexit.json", f"flatstickexit.{P}", 2935, 1546),
|
|
("sweep_flatjudge.json", f"flatjudge.{P}", 2820, 1532),
|
|
("sweep_orderpt.json", f"flatanalogmem.{P}", 2633, None),
|
|
("sweep_half.json", f"half.{P}", 2392, None)):''')
|
|
R(''' _cell("sweep_flatstick.json", f"flatstick.{P}")["APS"]["total"], 6781)''',
|
|
''' _cell("sweep_flatstick.json", f"flatstick.{P}")["APS"]["total"], 6591)''')
|
|
R(''' op[f"pure+extP+flatanalogmempt.{P}"]["CHA"]["total"], 2117)''',
|
|
''' op[f"pure+extP+flatanalogmempt.{P}"]["CHA"]["total"], 1250)''')
|
|
R(''' op[f"pure+extP+flatanalogpt.{P}"]["CHA"]["total"], 2221)''',
|
|
''' op[f"pure+extP+flatanalogpt.{P}"]["CHA"]["total"], 1388)''')
|
|
# ---- Table 8
|
|
R(''' check("A' APS", a["APS"]["total"], 2438)
|
|
check("A' CHA", a["CHA"]["total"], 2005)
|
|
check("A' both", a["APS"]["total"] + a["CHA"]["total"], 4443)
|
|
check("A' solved", a["APS"]["solved"] + a["CHA"]["solved"], 193)
|
|
c = apr[f"{A}.credit"]
|
|
check("A' earned budget", (c["APS"]["total"], c["CHA"]["total"]), (3608, 2807))''',
|
|
''' check("A' APS", a["APS"]["total"], 2259)
|
|
check("A' CHA", a["CHA"]["total"], 1074)
|
|
check("A' both", a["APS"]["total"] + a["CHA"]["total"], 3333)
|
|
check("A' solved", a["APS"]["solved"] + a["CHA"]["solved"], 199)
|
|
c = apr[f"{A}.credit"]
|
|
check("A' earned budget", (c["APS"]["total"], c["CHA"]["total"]), (3417, 1852))''')
|
|
R(''' for setname, opp, want in (("APS", "chandrupatla", (103, 20, 30)),
|
|
("CHA", "chandrupatla", (29, 4, 7)),
|
|
("APS", "toms748", (127, 6, 20)), ("CHA", "toms748", (38, 2, 0)),
|
|
("APS", "brent", (118, 17, 18)), ("CHA", "brent", (33, 3, 2)),
|
|
("APS", "itp_oracle", (126, 7, 20)),
|
|
("CHA", "itp_oracle", (35, 1, 4))):''',
|
|
''' for setname, opp, want in (("APS", "chandrupatla", (103, 20, 31)),
|
|
("CHA", "chandrupatla", (31, 4, 10)),
|
|
("APS", "toms748", (127, 6, 21)), ("CHA", "toms748", (42, 2, 1)),
|
|
("APS", "brent", (118, 17, 19)), ("CHA", "brent", (39, 3, 3)),
|
|
("APS", "itp_oracle", (126, 7, 21)),
|
|
("CHA", "itp_oracle", (35, 1, 9))):''')
|
|
R(''' check("A' APS vs Chandrupatla p (2 digits)", float(f"{sign_p(103, 30):.2g}"), 1.5e-10)
|
|
check("A' CHA vs Chandrupatla p (1 digit)", float(f"{sign_p(29, 7):.1g}"), 3e-4)
|
|
check("A' below Chandrupatla, APS %", round(100 * (1 - 2438 / 2787), 1), 12.5)
|
|
check("A' below Chandrupatla, CHA %", round(100 * (1 - 2005 / 2441), 1), 17.9)''',
|
|
''' check("A' APS vs Chandrupatla p (1 digit)", float(f"{sign_p(103, 31):.1g}"), 3e-10)
|
|
check("A' CHA vs Chandrupatla p (1 digit)", float(f"{sign_p(31, 10):.1g}"), 0.001)
|
|
check("A' below Chandrupatla, APS %", round(100 * (1 - 2259 / 2595), 1), 12.9)
|
|
check("A' below Chandrupatla, CHA %", round(100 * (1 - 1074 / 1505), 1), 28.6)''')
|
|
R(''' check("A' level on fun7", af["fun7"] == cf["fun7"], True)''',
|
|
''' check("A' fun7 vs Chandrupatla", (af["fun7"], cf["fun7"]), (69, 64))''')
|
|
# ---- ModAB in Table 8: the same single-criterion runs as Table 10
|
|
R(''' mp = mb["protocol"]["modab"]
|
|
check("ModAB protocol APS, CHA, both", (mp["APS"]["total"], mp["CHA"]["total"],
|
|
mp["APS"]["total"] + mp["CHA"]["total"]),
|
|
(2914, 2436, 5350))
|
|
for setname, want in (("APS", (118, 11, 25)), ("CHA", (32, 9, 4))):
|
|
am = {p: v for p, v in a[setname]["per"].items()}
|
|
mm = mp[setname]["per"]
|
|
w = sum(cost(am[p]) < cost(mm[p]) for p in am)
|
|
l = sum(cost(am[p]) > cost(mm[p]) for p in am)
|
|
check(f"A' vs ModAB protocol {setname}", (w, len(am) - w - l, l), want)''',
|
|
''' ms = mb["seen"]["modab"]
|
|
check("Table 8 ModAB APS, CHA, both",
|
|
(sum(cost(v) for v in ms["APS"].values()), sum(cost(v) for v in ms["CHA"].values()),
|
|
sum(cost(v) for s_ in ("APS", "CHA") for v in ms[s_].values())), (2726, 1681, 4407))
|
|
for setname, want in (("APS", (118, 10, 26)), ("CHA", (34, 4, 7))):
|
|
am = {p: v for p, v in a[setname]["per"].items()}
|
|
mm = ms[setname]
|
|
w = sum(cost(am[p]) < cost(mm[p]) for p in am)
|
|
l = sum(cost(am[p]) > cost(mm[p]) for p in am)
|
|
check(f"Table 8 A' vs ModAB {setname}", (w, len(am) - w - l, l), want)''')
|
|
# ---- Table 9a
|
|
R(''' t9a = {"ratio": (4443, 13032), "exp_abs": (4988, 14142), "rational": (5486, 14843),
|
|
"ratio_soft": (8360, 28500), "sqrt": (12718, 45552), "cbrt": (17207, 63031),
|
|
"exp_sq": (18410, 67701), "cosine": (18412, 67854), "rat_sq": (18422, 67394)}''',
|
|
''' t9a = {"ratio": (3333, 13032), "exp_abs": (3965, 14142), "rational": (4424, 14843),
|
|
"ratio_soft": (7249, 28500), "sqrt": (11613, 45552), "cbrt": (16094, 63031),
|
|
"exp_sq": (17429, 67701), "cosine": (17487, 67854), "rat_sq": (17452, 67394)}''')
|
|
R(''' check("nearest other S costs more, protocol %", round(100 * (4988 / 4443 - 1)), 12)
|
|
check("worst S costs more, protocol %", round(100 * (18422 / 4443 - 1)), 315)''',
|
|
''' check("nearest other S costs more, two sets %", round(100 * (3965 / 3333 - 1)), 19)
|
|
check("worst S costs more, two sets %", round(100 * (17487 / 3333 - 1)), 425)''')
|
|
R(''' check("quadratic S: four to five times",
|
|
(int(18410 / 4443), int(67854 / 13032)), (4, 5))''',
|
|
''' check("quadratic S: five times",
|
|
(int(17429 / 3333), int(67854 / 13032)), (5, 5))''')
|
|
|
|
NEW_FUNC = '''
|
|
|
|
def verify_revision1():
|
|
"""Revision 1 (2026-09-22): the claims added or restated by the revision - the order
|
|
of the base step, section 7.3's solved counts, the families as the unit, ITP in Table 10,
|
|
negative items 5 and 9, and the one canonical problem the multiplier moves. Recomputed."""
|
|
import contextlib
|
|
import io
|
|
import math
|
|
import re
|
|
from collections import defaultdict
|
|
print("\\nRevision 1:")
|
|
import order_high_precision
|
|
buf = io.StringIO()
|
|
with contextlib.redirect_stdout(buf):
|
|
order_high_precision.main()
|
|
out = buf.getvalue()
|
|
check("Muller order", re.search(r"Muller order .*: ([\\d.]+)", out).group(1), "1.8393")
|
|
for name in ("cos x - x", "exp(x) - 2", "x^3 - x - 2", "sin x - 1/2"):
|
|
line = next(ln for ln in out.splitlines() if ln.startswith(name))
|
|
three = line[14:54].split()
|
|
check(f"three-point order settles, {name}", three[-2], "1.840")
|
|
line = next(ln for ln in out.splitlines() if ln.startswith("x^2 - 2"))
|
|
check("three-point order on x^2 - 2", line[14:54].split()[-1], "2.000")
|
|
check("two-point order, cos x - x", next(ln for ln in out.splitlines()
|
|
if ln.startswith("cos x - x"))[54:].split()[-1], "1.618")
|
|
|
|
rows = _load("sweep_full.json")
|
|
by = {r["label"]: r for r in rows}
|
|
solved = {k: by[k]["APS"]["solved"] + by[k]["CHA"]["solved"]
|
|
for k in ("chandrupatla", "toms748", "itp", "bisection", "brent", "dekker",
|
|
"illinois")}
|
|
check("section 7.3 solved counts", solved, {"chandrupatla": 199, "toms748": 199,
|
|
"itp": 199, "bisection": 199, "brent": 197,
|
|
"dekker": 178, "illinois": 177})
|
|
check("Chandrupatla fewer than the base rule, APS %",
|
|
round(100 * (by[PROJ]["APS"]["total"] / by["chandrupatla"]["APS"]["total"] - 1), 1), 1.5)
|
|
none_ = by["pure.ratio.derived3.none"]["CHA"]
|
|
check("guarantee on CHA: more solved, fewer evaluations",
|
|
(45 - none_["solved"], round(100 * (1 - by[PROJ]["CHA"]["total"] / none_["total"]))),
|
|
(6, 30))
|
|
check("earned costs 28% more on APS",
|
|
round(100 * (by[CREDIT]["APS"]["total"] / by[PROJ]["APS"]["total"] - 1)), 28)
|
|
|
|
def cost(v):
|
|
return v[0] if v[1] else 200
|
|
|
|
def fam_of(pid):
|
|
return ".".join(pid.split(".")[:2]) if pid.startswith("aps") else pid.split(".")[0]
|
|
|
|
def families(a, b, s):
|
|
ta, tb = defaultdict(int), defaultdict(int)
|
|
for p in a[s]["per"]:
|
|
ta[fam_of(p)] += cost(a[s]["per"][p])
|
|
tb[fam_of(p)] += cost(b[s]["per"][p])
|
|
w = sum(ta[k] < tb[k] for k in ta)
|
|
l = sum(ta[k] > tb[k] for k in ta)
|
|
return w, len(ta) - w - l, l
|
|
|
|
def sign_p(w, l):
|
|
k, n = min(w, l), w + l
|
|
return min(1.0, 2.0 * sum(math.comb(n, i) for i in range(k + 1)) / 2.0 ** n)
|
|
ap = {r["label"]: r for r in _load("sweep_aprime.json")}[
|
|
"pure+extP+contra+flatanalogmempt+exp+half+close+sub.ratio.derived3.project"]
|
|
ch = by["chandrupatla"]
|
|
check("base rule vs Chandrupatla by family, APS", families(by[PROJ], ch, "APS"), (6, 1, 8))
|
|
check("A' vs Chandrupatla by family, APS", families(ap, ch, "APS"), (8, 1, 6))
|
|
check("A' vs Chandrupatla by family, CHA", families(ap, ch, "CHA"), (7, 0, 2))
|
|
check("family-level p, APS and CHA (2 digits)",
|
|
(float(f"{sign_p(8, 6):.2g}"), float(f"{sign_p(7, 2):.2g}")), (0.79, 0.18))
|
|
|
|
order = _load("sweep_order.json")
|
|
cells = {}
|
|
for r in order:
|
|
s = r["spec"]
|
|
if s[2] == "far":
|
|
cells[(s[1], s[3], s[8] if len(s) > 8 else "none")] = r["APS"]["total"] + r["CHA"]["total"]
|
|
pairs = [(k[0], k[1]) for k in cells if k[2] == "none" and (k[0], k[1], "order") in cells]
|
|
check("far-end reading: measured order cheaper in cells",
|
|
(sum(cells[(s_, g, "order")] < cells[(s_, g, "none")] for s_, g in pairs), len(pairs)),
|
|
(33, 63))
|
|
|
|
cap, dire = _load("sweep_cap.json"), _load("sweep_direction.json")
|
|
for s, want in (("APS", (3101, 2539)), ("CHA", (1766, 1752))):
|
|
bc = min(r[s]["total"] for r in cap if r[s]["solved"] == r[s]["n"])
|
|
bd = min(r[s]["total"] for r in dire if r[s]["solved"] == r[s]["n"] and r["spec"][0] == "pure")
|
|
check(f"item 9: best capped vs best uncapped, {s}", (bc, bd), want)
|
|
|
|
itp = _load("sweep_itp.json")
|
|
t10 = {"APS": (3767, 3068), "CHA": (1946, 1675), "NEW": (5674, 4707), "RJL": (2161, 1629),
|
|
"APP": (3245, 2386), "D": (5721, 4832)}
|
|
for s, want in t10.items():
|
|
check(f"Table 10 ITP / oracle {s}", (sum(cost(v) for v in itp["itp"][s].values()),
|
|
sum(cost(v) for v in itp["itp_oracle"][s].values())), want)
|
|
check("Table 10 ITP / oracle over 855", tuple(sum(cost(v) for s in t10 for v in itp[k][s].values())
|
|
for k in ("itp", "itp_oracle")), (22514, 18297))
|
|
check("ITP bound violations over 855", sum(v[2] for k in ("itp", "itp_oracle")
|
|
for s in t10 for v in itp[k][s].values()), 0)
|
|
seen, four = _load("sweep_fourth_seen.json"), _load("sweep_fourth_fourth.json")
|
|
apx = dict(seen["Aprime"])
|
|
apx.update(four["Aprime"])
|
|
check("A' ahead of ITP and the oracle on every corpus",
|
|
all(sum(cost(v) for v in apx[s].values()) < sum(cost(v) for v in itp[k][s].values())
|
|
for s in t10 for k in ("itp", "itp_oracle")), True)
|
|
|
|
from simroot.pure import pure_root
|
|
from stage12_validation import load, per_problem
|
|
probs = load()
|
|
aps = [p for p in probs if p[0] == "APS"]
|
|
runs = {fac: per_problem(lambda f, a, b, xt, mx, _f=fac: pure_root(
|
|
f, a, b, xt, mx, similarity="ratio", scale="derived3", guard="project",
|
|
budget_factor=_f), aps, 200, criterion="sign") for fac in (1.25, 1.5, 2.0)}
|
|
moved = {p: tuple(runs[f][p][0] for f in (1.25, 1.5, 2.0)) for p in runs[2.0]
|
|
if len({runs[f][p][0] for f in (1.25, 1.5, 2.0)}) > 1}
|
|
check("Table 1a: the one canonical problem the multiplier moves", moved,
|
|
{"aps.13.00": (20, 30, 28)})
|
|
tot = {}
|
|
for sc in ("derived3", "derived3_m"):
|
|
pp = per_problem(lambda f, a, b, xt, mx, _s=sc: pure_root(
|
|
f, a, b, xt, mx, similarity="ratio", scale=_s, guard="project"), probs, 200,
|
|
criterion="sign")
|
|
tot[sc] = sum(v[0] for v in pp.values())
|
|
check("item 5: phase detector vs base rule, both sets", (tot["derived3_m"], tot["derived3"]),
|
|
(5336, 4991))
|
|
'''
|
|
|
|
|
|
def main():
|
|
src = open(PATH, encoding="utf8").read()
|
|
bad = [old[:80] for old, _ in REPL if src.count(old) != 1]
|
|
if bad:
|
|
for b in bad:
|
|
print("ANCHOR NOT FOUND EXACTLY ONCE:", repr(b))
|
|
raise SystemExit(f"{len(bad)} anchors failed; nothing written")
|
|
for old, new in REPL:
|
|
src = src.replace(old, new)
|
|
marker = '\n\nif __name__ == "__main__":\n main()\n'
|
|
assert src.count(marker) == 1
|
|
src = src.replace(marker, NEW_FUNC + marker)
|
|
open(PATH, "w", encoding="utf8").write(src)
|
|
print(f"applied {len(REPL)} replacements and added verify_revision1")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|