110 lines
7.0 KiB
Python
110 lines
7.0 KiB
Python
"""Bring the stale numbers of article/sim_numerics.md to the regenerated server sweeps
|
||
(2026-09-21: after the sign-underflow fix and the _local_order fix). Every replacement is an
|
||
exact substring that must occur EXACTLY ONCE; anything else aborts without writing.
|
||
|
||
python -u apply_article_numbers.py
|
||
"""
|
||
from __future__ import annotations
|
||
|
||
PATH = "article/sim_numerics.md"
|
||
|
||
REPL = [
|
||
# Table 3
|
||
("| 3 | ITP, per-problem oracle | yes | 40/45 | 2611 | 0 |",
|
||
"| 3 | ITP, per-problem oracle | yes | 40/45 | 2647 | 0 |"),
|
||
("| 4 | similarity, $e^{-\\lvert z\\rvert}$, bracket scale, both guards | no | 40/45 | 2733 | 0 |",
|
||
"| 4 | similarity, $e^{-\\lvert z\\rvert}$, bracket scale, both guards | no | 40/45 | 2736 | 0 |"),
|
||
("| 6 | ITP, recommended constants | yes | 40/45 | 2857 | 0 |",
|
||
"| 6 | ITP, recommended constants | yes | 40/45 | 2896 | 0 |"),
|
||
("| **47** | **proposed: tent, 3-point, projection ($c=2$)** | **no** | 40/45 | **3220** | 0 |",
|
||
"| **45** | **base rule: tent, 3-point, projection ($c=2$)** | **no** | 40/45 | **3220** | 0 |"),
|
||
("| 164 | TOMS 748 | yes | 40/45 | 4000 | 15 |", "| 159 | TOMS 748 | yes | 40/45 | 4000 | 15 |"),
|
||
("| 226 | Brent | yes | 38/45 | 4115 | 18 |", "| 227 | Brent | yes | 38/45 | 4115 | 18 |"),
|
||
("5871 for the ITP oracle, 6820 for TOMS 748", "5907 for the ITP oracle, 6820 for TOMS 748"),
|
||
# Table 4 and the rankings of 5.3
|
||
("| 3-point derived | **6809** | 22294 |", "| 3-point derived | **6893** | 22315 |"),
|
||
("| 2-point derived | 6906 | 22167 |", "| 2-point derived | 6981 | 22206 |"),
|
||
("| bracket | 10263 | 19137 |", "| bracket | 10279 | 19127 |"),
|
||
("$1-|z|$ (6496), $e^{-|z|}$ (6822), $1/(1+|z|)$ (7038), $(1+|z|)^{-2}$ (9502), "
|
||
"$1-\\sqrt{|z|}$ (10497), $1-|z|^{1/3}$ (11941), $e^{-z^2}$ (14314)",
|
||
"$1-|z|$ (6560), $e^{-|z|}$ (6895), $1/(1+|z|)$ (7118), $(1+|z|)^{-2}$ (9578), "
|
||
"$1-\\sqrt{|z|}$ (10546), $1-|z|^{1/3}$ (12002), $e^{-z^2}$ (14307)"),
|
||
("3-point (6496), 2-point (6628), bracket (9081), start (14540)",
|
||
"3-point (6560), 2-point (6702), bracket (9107), start (14540)"),
|
||
# Table 5 and its text
|
||
("| (1) trust before the step, projection | 2848 | 3074 | 5922 |",
|
||
"| (1) trust before the step, projection | 2848 | 3114 | 5962 |"),
|
||
("| (1)+(2) points chosen by shape, *safe* | **2527** | 3108 | 5635 |",
|
||
"| (1)+(2) points chosen by shape, *safe* | **2527** | 3126 | 5653 |"),
|
||
("| (1)+(3) far end by dissimilarity, projection | 2726 | **2785** | **5511** |",
|
||
"| (1)+(3) far end by dissimilarity, projection | 2726 | **2799** | **5525** |"),
|
||
("| (1)+(2)+(3), *safe* | 2884 | 2859 | 5743 |", "| (1)+(2)+(3), *safe* | 2884 | 2871 | 5755 |"),
|
||
("| ITP, per-problem oracle | 3260 | 2611 | 5871 |", "| ITP, per-problem oracle | 3260 | 2647 | 5907 |"),
|
||
("the 5511 of reading (3) passes ITP's oracle (5871)", "the 5525 of reading (3) passes ITP's oracle (5907)"),
|
||
("where Chandrupatla needs 2441 against our 2683 (reading (3) under *safe*)",
|
||
"where Chandrupatla needs 2441 against our 2695 (reading (3) under *safe*)"),
|
||
("Taken together, (2) and (3) give 2884 and 2859 — worse than either alone.",
|
||
"Taken together, (2) and (3) give 2884 and 2871 — worse than either alone on the canonical "
|
||
"set, and on the wide-bracket set worse than (3) alone."),
|
||
# Table 6 (wide-bracket columns) and its text
|
||
("| both | 4522 | **3675** | 3387 | **3216** |", "| both | 4522 | **3675** | 3406 | **3241** |"),
|
||
("| bracket | 4606 | **3542** | 3571 | **3303** |", "| bracket | 4606 | **3542** | 3602 | **3359** |"),
|
||
("| projection | 6932 | **6364** | 4794 | **4559** |", "| projection | 6932 | **6364** | 4789 | **4554** |"),
|
||
("| safe | 5987 | **5229** | 4108 | **3923** |", "| safe | 5987 | **5229** | 4134 | **3954** |"),
|
||
("| step | 6435 | **5551** | 4257 | **4022** |", "| step | 6435 | **5551** | 4287 | **4068** |"),
|
||
("is 2884, against 2683 for reading (3) above and 2423 for Chandrupatla",
|
||
"is 2884, against 2695 for reading (3) above and 2441 for Chandrupatla"),
|
||
# 7.2
|
||
("the wide-bracket set costs 3066 under the projection and 2899 under *credit*",
|
||
"the wide-bracket set costs 3059 under the projection and 2892 under *credit*"),
|
||
("it refuses 63.6% of steps", "it refuses 63.5% of steps"),
|
||
("(best 2868 on the wide-bracket set)", "(best 2897 on the wide-bracket set)"),
|
||
("Under the earned projection it gives 3545 and 2949, the best total over both sets of any "
|
||
"constant-free configuration measured (6494 against 6588). It refuses only 7.0% of steps",
|
||
"Under the earned projection it gives 3545 and 2949 (6494 against 6588), the best of the "
|
||
"readings of this section without a constant; the flat regime of §8 does better still. It "
|
||
"refuses only 6.6% of steps"),
|
||
("Over both sets it costs 5733 against the 5511 of reading (3)",
|
||
"Over both sets it costs 5733 against the 5525 of reading (3)"),
|
||
# Table 7
|
||
("| ITP | 3957 | 3767 | 2857 | 1907 |", "| ITP | 3957 | 3767 | 2896 | 1907 |"),
|
||
# 7.4
|
||
("(verified on all 428 non-degenerate states; in the other five the negative weight "
|
||
"underflowed to $-0$)",
|
||
"(verified on all 428 non-degenerate states; in the other three the negative weight "
|
||
"underflowed to $-0$)"),
|
||
("splits the 244 evaluations of the gap in two", "splits the 256 evaluations of the gap in two"),
|
||
("But 160 of the 244 — two thirds —", "But 172 of the 256 — two thirds —"),
|
||
("our step removes 0.41–0.81 halvings", "our step removes 0.41–0.75 halvings"),
|
||
("to 296, 239, 235 — against his own 297, 233, 233", "to 296, 239, 228 — against his own 297, 233, 233"),
|
||
("it reports $m\\ge2$ on only 5.8% of states of families whose order is by construction 3 to 19",
|
||
"it reports $m\\ge2$ on none of the states of families whose order is by construction 3 to 19"),
|
||
# 8
|
||
("the same similarity over the whole Chandrupatla set costs 4099 against 3220, so a switch chosen "
|
||
"per benchmark is worse than no switch at all: 6905 against 6026",
|
||
"the same similarity over the whole Chandrupatla set costs 4109 against 3220, so a switch chosen "
|
||
"per benchmark is worse than no switch at all: 6915 against 6026"),
|
||
("and 3111 on the wide-bracket set against 2683", "and 3111 on the wide-bracket set against 2695"),
|
||
("the wide-bracket set improves from 3643 to 3474", "the wide-bracket set improves from 3695 to 3541"),
|
||
("An earlier version compared the 3474 with 4516", "An earlier version compared the 3541 with 4516"),
|
||
]
|
||
|
||
|
||
def main():
|
||
with open(PATH, encoding="utf8") as fh:
|
||
text = fh.read()
|
||
bad = [(old, text.count(old)) for old, _new in REPL if text.count(old) != 1]
|
||
if bad:
|
||
for old, n in bad:
|
||
print(f"occurs {n}x: {old[:90]}")
|
||
raise SystemExit("aborted, nothing written")
|
||
for old, new in REPL:
|
||
text = text.replace(old, new)
|
||
with open(PATH, "w", encoding="utf8") as fh:
|
||
fh.write(text)
|
||
print(f"{len(REPL)} replacements applied")
|
||
|
||
|
||
if __name__ == "__main__":
|
||
main()
|