|
| 1 | +# Apply all 12 final fixes to paper/main.tex |
| 2 | + |
| 3 | +with open(r'paper\main.tex', 'r', encoding='utf-8') as f: |
| 4 | + text = f.read() |
| 5 | + |
| 6 | +original_len = len(text) |
| 7 | +changes = [] |
| 8 | + |
| 9 | +# ================================================================ |
| 10 | +# FIX 1: Remove CvS paragraph from abstract (Issues 5 & 6) |
| 11 | +# ================================================================ |
| 12 | +# The CvS paragraph is lines 44-45, starts with "We also provide" |
| 13 | +# and ends with the closing of the Sliwinski citation. |
| 14 | +CVS_START = 'We also provide new independent numerical evidence for the CvS spectral framework.' |
| 15 | +if CVS_START in text: |
| 16 | + # Find the paragraph and remove it |
| 17 | + idx = text.find(CVS_START) |
| 18 | + # Find end of paragraph (next \n\n or \medskip) |
| 19 | + end_markers = ['\n\n\\medskip', '\n\n\\textbf{DOI}'] |
| 20 | + end_idx = len(text) |
| 21 | + for marker in end_markers: |
| 22 | + m = text.find(marker, idx) |
| 23 | + if m != -1 and m < end_idx: |
| 24 | + end_idx = m |
| 25 | + # Remove from idx to end_idx (the paragraph and its preceding blank line) |
| 26 | + para = text[idx:end_idx] |
| 27 | + text = text[:idx] + text[end_idx:] |
| 28 | + changes.append('CvS paragraph removed from abstract') |
| 29 | +else: |
| 30 | + print('WARNING: CvS paragraph not found') |
| 31 | + |
| 32 | +# ================================================================ |
| 33 | +# FIX 2: Fix abstract component (3) — update min margin from 93.1 to 91.3 |
| 34 | +# ================================================================ |
| 35 | +OLD_MARGIN_ABS = r'(minimum margin~93.1; see Theorem~\ref{thm:extended} in Section~\ref{sec:extended})' |
| 36 | +NEW_MARGIN_ABS = r'(minimum margin~91.3; see Theorem~\ref{thm:extended})' |
| 37 | +if OLD_MARGIN_ABS in text: |
| 38 | + text = text.replace(OLD_MARGIN_ABS, NEW_MARGIN_ABS, 1) |
| 39 | + changes.append('Abstract min_margin updated to 91.3') |
| 40 | + |
| 41 | +# ================================================================ |
| 42 | +# FIX 3: Trim falsification detail from abstract |
| 43 | +# (Find by landmarks: the paragraph starts with 'We subject' and ends with 're-verified.') |
| 44 | +# ================================================================ |
| 45 | +import re |
| 46 | +# Remove the 3-sentence falsification paragraph from abstract only |
| 47 | +pattern = (r'We subject every link in the proof chain to 36~systematic falsification attacks ' |
| 48 | + r'.*?re-verified\.') |
| 49 | +match = re.search(pattern, text[:text.find(r'\end{abstract}')], re.DOTALL) |
| 50 | +if match: |
| 51 | + text = text[:match.start()] + r'All 36~systematic tests organized in 7~categories detected no inconsistency.' + text[match.end():] |
| 52 | + changes.append('Abstract falsification detail trimmed') |
| 53 | +else: |
| 54 | + # Already trimmed or not matching |
| 55 | + pass |
| 56 | + |
| 57 | +# ================================================================ |
| 58 | +# FIX 4: Replace Lemma W with full G'(u) < 0 proof |
| 59 | +# ================================================================ |
| 60 | +OLD_LEMMA = r"""\begin{lemma}[Uniform tail bound]\label{lem:wtail} |
| 61 | +For all $u \geq 1$, |
| 62 | +\[ |
| 63 | +|W_{\mathrm{tail}}(u)| \leq \lambda(1)\cdot|W_1(u)| \leq 1.82\times 10^{-25}, |
| 64 | +\] |
| 65 | +where $\lambda(u) := |\Delta Q(u)|/|Q_{\varphi_1}(u)|$ is the perturbation ratio. |
| 66 | +The bound follows from: (1)~$\lambda(u)$ is strictly decreasing for $u\geq 1$ (since |
| 67 | +$d\log\lambda/du \leq 2 - 6\pi e^{2u} < 0$); (2)~$\lambda(u)\cdot|W_1(u)|$ is maximised |
| 68 | +at $u=1$ with value $1.95\times 10^{-27}\times 93.15 \approx 1.82\times 10^{-25}$. |
| 69 | +\end{lemma}""" |
| 70 | +NEW_LEMMA = r"""\begin{lemma}[Uniform tail bound]\label{lem:wtail} |
| 71 | +For all $u \geq 1$, |
| 72 | +\[ |
| 73 | +|W_{\mathrm{tail}}(u)| \leq G(u) := \lambda(u)\cdot|W_1(u)| \leq G(1) = 1.82\times 10^{-25}, |
| 74 | +\] |
| 75 | +where $\lambda(u) := |\Delta Q(u)|/|Q_{\varphi_1}(u)|$. |
| 76 | +\end{lemma} |
| 77 | +\begin{proof} |
| 78 | +We prove $G'(u) < 0$ for all $u \geq 0$, so $G$ is strictly decreasing and $G(u)\leq G(1)$ for $u\geq 1$. |
| 79 | +
|
| 80 | +$\frac{d}{du}\log G = \frac{d}{du}\log\lambda + \frac{d}{du}\log|W_1|.$ |
| 81 | +
|
| 82 | +\emph{Step 1.} From~\cite[Theorem~4.1]{TailBound}: $\frac{d}{du}\log\lambda \leq 2 - 6\pi e^{2u}$ |
| 83 | +(the dominant $n=2$ term of $\varepsilon^*$ decays as $e^{-6\pi e^{2u}}$, while $C(u) = O(e^{2u})$). |
| 84 | +
|
| 85 | +\emph{Step 2.} $\frac{d}{du}\log|W_1| \leq 2$. |
| 86 | +Indeed, $|W_1(u)| = 24\pi e^{2u}/h^2 + 4\pi e^{2u} \geq 4\pi e^{2u}$, and |
| 87 | +$\frac{d}{du}|W_1| = \frac{48\pi e^{2u}(-2\pi e^{2u}-3)}{h^3} + 8\pi e^{2u} \leq 8\pi e^{2u}$ |
| 88 | +(first term is negative). Hence $\frac{d}{du}\log|W_1| \leq 8\pi e^{2u}/(4\pi e^{2u}) = 2$. |
| 89 | +
|
| 90 | +\emph{Step 3.} $\frac{d}{du}\log G \leq (2 - 6\pi e^{2u}) + 2 = 4 - 6\pi e^{2u} \leq 4 - 6\pi < 0$ |
| 91 | +for all $u \geq 0$ (since $6\pi > 4$). |
| 92 | +
|
| 93 | +Therefore $G(u) \leq G(1) = \lambda(1)\cdot|W_1(1)| = 1.95\times 10^{-27}\times 93.15 \approx 1.82\times 10^{-25}$. |
| 94 | +\end{proof}""" |
| 95 | +if OLD_LEMMA in text: |
| 96 | + text = text.replace(OLD_LEMMA, NEW_LEMMA, 1) |
| 97 | + changes.append('Lemma W completely repaired with G\'(u)<0 proof') |
| 98 | +else: |
| 99 | + print('WARNING: Lemma W text not found') |
| 100 | + |
| 101 | +# ================================================================ |
| 102 | +# FIX 5: Fix Theorem 5 proof — ε* notation and remove editorial note |
| 103 | +# ================================================================ |
| 104 | +OLD_T5_EPS = (r'|W_{\mathrm{tail}}(u)| \leq C\,\varepsilon(u),' |
| 105 | + '\n' |
| 106 | + r'\quad' |
| 107 | + '\n' |
| 108 | + r'\varepsilon^*(u) := 2\sum_{n=2}^{\infty} n^4\,e^{-\pi(n^2-1)e^{2u}}\quad\text{[corrected: }B_n(u)/n^4 < 2\text{]},') |
| 109 | +NEW_T5_EPS = r'|W_{\mathrm{tail}}(u)| \leq C\,\varepsilon^*(u), \quad \varepsilon^*(u) := 2\sum_{n=2}^{\infty} n^4\,e^{-\pi(n^2-1)e^{2u}},' |
| 110 | +if OLD_T5_EPS in text: |
| 111 | + text = text.replace(OLD_T5_EPS, NEW_T5_EPS, 1) |
| 112 | + changes.append('Theorem 5: editorial note removed from math, ε* used') |
| 113 | + |
| 114 | +# Also fix the C definition to use ε* |
| 115 | +OLD_C_DEF = (r'where $C = 204$ is the explicitly computed proportionality constant at $u = 1$:\n' |
| 116 | + r'\[\n' |
| 117 | + r'C := \frac{|\Delta Q|}{\varepsilon \cdot |Q_{\varphi_1}|}\bigg|_{u=1} = 204,\n' |
| 118 | + r'\quad\n' |
| 119 | + r'\varepsilon(1) = 9.59\times 10^{-30},\n' |
| 120 | + r'\quad |\Delta Q|/|Q_{\varphi_1}| = 1.95\times 10^{-27}.\n' |
| 121 | + r'\]') |
| 122 | +NEW_C_DEF = (r'where $C = 204$ is a conservative constant: using $\varepsilon^*(1) \approx 1.82\times 10^{-29}$,\n' |
| 123 | + r'\[\n' |
| 124 | + r'C^* := \frac{|\Delta Q|}{\varepsilon^* \cdot |Q_{\varphi_1}|}\bigg|_{u=1} \approx 102 \leq 204,\n' |
| 125 | + r'\quad |\Delta Q|/|Q_{\varphi_1}| = 1.95\times 10^{-27}.\n' |
| 126 | + r'\]' |
| 127 | + '\n' |
| 128 | + r'Hence $C=204$ with $\varepsilon^*$ is conservative ($204\,\varepsilon^*(1) \approx 3.7\times 10^{-27}$).') |
| 129 | +if OLD_C_DEF in text: |
| 130 | + text = text.replace(OLD_C_DEF, NEW_C_DEF, 1) |
| 131 | + changes.append('Theorem 5: C definition updated to use ε*, note C*≤204') |
| 132 | + |
| 133 | +# Fix stale SHA256 in Theorem 5 proof |
| 134 | +text = text.replace( |
| 135 | + r'(SHA256 of output: \texttt{7D65253C...})', |
| 136 | + r'(SHA256: \texttt{1BB9E9DECF13580C...})', |
| 137 | + 1 |
| 138 | +) |
| 139 | +changes.append('Theorem 5: SHA256 hash updated to 1BB9E9DE') |
| 140 | + |
| 141 | +# Fix the margin reference (93.1 → 91.3) in Theorem 5 proof result line |
| 142 | +text = text.replace( |
| 143 | + r'while $|W_1(u)| \geq 93.1$.', |
| 144 | + r'while the certified minimum margin is $91.3$.', |
| 145 | + 1 |
| 146 | +) |
| 147 | +changes.append('Theorem 5: corrected |W1| bound to certified margin 91.3') |
| 148 | + |
| 149 | +# ================================================================ |
| 150 | +# FIX 6: Fix Theorem 6 proof — consistent ε* notation |
| 151 | +# ================================================================ |
| 152 | +# Fix the decomposition line |
| 153 | +text = text.replace( |
| 154 | + r'bound $|W_{\mathrm{tail}}| \leq C\,\varepsilon$ with $C = 204$, it suffices to show' |
| 155 | + '\n' |
| 156 | + r'$W_1(u) + 204\,\varepsilon(u) < 0$ for $u \geq 3$.', |
| 157 | + r'bound $|W_{\mathrm{tail}}| \leq C\,\varepsilon^*$ with $C = 204$, it suffices to show' |
| 158 | + '\n' |
| 159 | + r'$W_1(u) + 204\,\varepsilon^*(u) < 0$ for $u \geq 3$.', |
| 160 | + 1 |
| 161 | +) |
| 162 | +changes.append('Theorem 6: ε→ε* in decomposition line') |
| 163 | + |
| 164 | +# Fix the numeric consistency (10^{-1637} → 10^{-1636}) |
| 165 | +text = text.replace( |
| 166 | + r'Hence $W_1(3) + 204\,\varepsilon(3) < -1000 + 204\cdot 10^{-1637} < 0$.', |
| 167 | + r'Hence $W_1(3) + 204\,\varepsilon^*(3) < -1000 + 204\cdot 10^{-1636} < 0$.', |
| 168 | + 1 |
| 169 | +) |
| 170 | +changes.append('Theorem 6: ε(3) → ε*(3) and 10^{-1637} → 10^{-1636}') |
| 171 | + |
| 172 | +# Fix "both W_1 and 204ε" lines |
| 173 | +text = text.replace( |
| 174 | + r'Since both $W_1$ and $204\varepsilon$ are strictly decreasing for $u \geq 3$,' |
| 175 | + '\n' |
| 176 | + r'$W_1(u) + 204\,\varepsilon(u) \leq W_1(3) + 204\,\varepsilon(3) < 0$ for all $u \geq 3$.', |
| 177 | + r'Since both $W_1$ and $204\varepsilon^*$ are strictly decreasing for $u \geq 3$,' |
| 178 | + '\n' |
| 179 | + r'$W_1(u) + 204\,\varepsilon^*(u) \leq W_1(3) + 204\,\varepsilon^*(3) < 0$ for all $u \geq 3$.', |
| 180 | + 1 |
| 181 | +) |
| 182 | +changes.append('Theorem 6: 204ε → 204ε* in monotonicity conclusion') |
| 183 | + |
| 184 | +# Update tail ratios to ε* notation and corrected values |
| 185 | +OLD_TAIL = (r'\textbf{Tail ratios:} $\varepsilon(1.0) = 9.59\times 10^{-30}$,' |
| 186 | + '\n' |
| 187 | + r'$\varepsilon(1.5) = 9.98\times 10^{-82}$, $\varepsilon(2.0) = 5.37\times 10^{-223}$,' |
| 188 | + '\n' |
| 189 | + r'$\varepsilon(3.0) < 10^{-1637}$. See \texttt{proof/verify\_algebraic\_core.py}.') |
| 190 | +NEW_TAIL = (r'\textbf{Corrected tail values $\varepsilon^*(u) = 2\varepsilon_{\mathrm{old}}(u)$:}' |
| 191 | + r' $\varepsilon^*(1.0) \approx 1.82\times 10^{-29}$,' |
| 192 | + '\n' |
| 193 | + r'$\varepsilon^*(1.5) \approx 1.96\times 10^{-81}$, $\varepsilon^*(2.0) \approx 1.07\times 10^{-222}$,' |
| 194 | + '\n' |
| 195 | + r'$\varepsilon^*(3.0) < 10^{-1636}$. See \texttt{proof/verify\_algebraic\_core.py}.') |
| 196 | +if OLD_TAIL in text: |
| 197 | + text = text.replace(OLD_TAIL, NEW_TAIL, 1) |
| 198 | + changes.append('Theorem 6: tail ratio values updated to ε* notation') |
| 199 | + |
| 200 | +# Also fix the ε*(3) exponent reference in the Proof-Critical Dependencies table |
| 201 | +text = text.replace( |
| 202 | + r'monotonicity+$\varepsilon(3)<10^{-1637}$', |
| 203 | + r'monotonicity+$\varepsilon^*(3)<10^{-1636}$', |
| 204 | + 1 |
| 205 | +) |
| 206 | +changes.append('Proof-Critical Deps table: ε(3) exponent corrected') |
| 207 | + |
| 208 | +# ================================================================ |
| 209 | +# FIX 7: Fix Appendix C table — raw math text |
| 210 | +# ================================================================ |
| 211 | +OLD_APP_C = r'$\log K$ concave ($(\\log K)''\\ leq 0$)' |
| 212 | +NEW_APP_C = r'$(\\log K)'' \\leq 0$' |
| 213 | +# Use exact string matching for the LaTeX source |
| 214 | +text = text.replace( |
| 215 | + r'$\log K$ concave ($(\log K)''\ leq 0$)', |
| 216 | + r'$(\log K)'' \leq 0$', |
| 217 | + 1 |
| 218 | +) |
| 219 | +changes.append('Appendix C: raw math text fixed to proper LaTeX') |
| 220 | + |
| 221 | +# ================================================================ |
| 222 | +# FIX 8: Fix Appendix B hash table header |
| 223 | +# ================================================================ |
| 224 | +text = text.replace( |
| 225 | + r'SHA256 (full 64 hex, see \texttt{docs/certificate\_hash\_table.md})', |
| 226 | + r'SHA256 prefix (16 chars); full hash in \texttt{docs/certificate\_hash\_table.md}', |
| 227 | + 1 |
| 228 | +) |
| 229 | +changes.append('Appendix B: hash table header corrected (prefix not full hash)') |
| 230 | + |
| 231 | +# Also add note below the table |
| 232 | +OLD_HASH_NOTE = r'To verify: run the corresponding script and compare the SHA256 of the output JSON against the table above.' |
| 233 | +NEW_HASH_NOTE = (r'Prefixes shown for readability. Full 64-character SHA256 hashes are in ' |
| 234 | + r'\texttt{docs/certificate\_hash\_table.md}. ' |
| 235 | + r'To verify: run the corresponding script and compare.') |
| 236 | +text = text.replace(OLD_HASH_NOTE, NEW_HASH_NOTE, 1) |
| 237 | +changes.append('Appendix B: hash note updated') |
| 238 | + |
| 239 | +# ================================================================ |
| 240 | +# FIX 9: Add C-17 and C-18 as explicit items to Appendix D |
| 241 | +# ================================================================ |
| 242 | +C16_ENDING = ( |
| 243 | + r'\item[C-16.] \textbf{P\'olya Satz~II source audit with verdict.}' + '\n' |
| 244 | + + r' Status: $\sim$ PARTIAL --- verdict: SOURCE MATCH VERIFIED WITH MODIFIED HYPOTHESES.' + '\n' |
| 245 | + + r' German original paywalled; primary text not directly verified.' + '\n' |
| 246 | + + r' Required before top-journal submission.' + '\n' |
| 247 | + + r'\end{enumerate}' |
| 248 | +) |
| 249 | +if C16_ENDING in text: |
| 250 | + NEW_D_ITEMS = ( |
| 251 | + r'\item[C-16.] \textbf{P\'olya Satz~II source audit with verdict.}' + '\n' |
| 252 | + + r' Status: $\sim$ PARTIAL --- verdict: SOURCE MATCH VERIFIED WITH MODIFIED HYPOTHESES.' + '\n' |
| 253 | + + r' German original paywalled; primary text not directly verified.' + '\n' |
| 254 | + + r' Required before top-journal submission.' + '\n\n' |
| 255 | + + r'\item[C-17.] \textbf{Tail prefactor bound corrected from $n^4$ to $2n^4$.}' + '\n' |
| 256 | + + r' Status: $\checkmark$ RESOLVED. $B_n(u)/n^4 \leq 1+3/(2\pi-3) < 2$;' + '\n' |
| 257 | + + r' corrected script recertifies $[1,3]$, minimum margin~91.3.' + '\n\n' |
| 258 | + + r'\item[C-18.] \textbf{Script renamed to \texttt{verify\_ia\_1\_to\_3.py}.}' + '\n' |
| 259 | + + r' Status: $\checkmark$ DONE.' + '\n' |
| 260 | + + r'\end{enumerate}' |
| 261 | + ) |
| 262 | + text = text.replace(C16_ENDING, NEW_D_ITEMS, 1) |
| 263 | + changes.append('Appendix D: C-17 and C-18 added as explicit items') |
| 264 | +else: |
| 265 | + print('WARNING: Appendix D ending not found') |
| 266 | + |
| 267 | +# ================================================================ |
| 268 | +# FIX 10: Fix typo "uncontroversal" → "uncontroversial" |
| 269 | +# ================================================================ |
| 270 | +text = text.replace('uncontroversal', 'uncontroversial') |
| 271 | +changes.append('Typo fixed: uncontroversal → uncontroversial') |
| 272 | + |
| 273 | +# ================================================================ |
| 274 | +# FIX 11: Shorten abstract — remove detailed falsification |
| 275 | +# (if the trimming above didn't catch it) |
| 276 | +# ================================================================ |
| 277 | +# The abstract might still have full falsification detail; clean it up |
| 278 | +text = text.replace( |
| 279 | + r'All 36~systematic tests organized in 7~batches. Each test attempts to detect an inconsistency or counterexample. These tests are confidence-building and do not substitute for the proof-critical certificates in Section~\ref{sec:deps}. No test detected any inconsistency. A representative selection:', |
| 280 | + r'All 36~systematic tests organized in 7~batches detected no inconsistency.', |
| 281 | + 1 |
| 282 | +) |
| 283 | +changes.append('Section 11 falsification opening simplified') |
| 284 | + |
| 285 | +# ================================================================ |
| 286 | +# FIX 12: Add prose note about ε* factor after the definition in Thm 5 |
| 287 | +# ================================================================ |
| 288 | +# Add explanation after the display in the proof |
| 289 | +PROSE_INSERT_AFTER = r'$\varepsilon^*(u) := 2\sum_{n=2}^{\infty} n^4\,e^{-\pi(n^2-1)e^{2u}},' |
| 290 | +if PROSE_INSERT_AFTER in text: |
| 291 | + idx = text.find(PROSE_INSERT_AFTER) |
| 292 | + if idx != -1: |
| 293 | + # Find end of the displayed math block (next \\]) |
| 294 | + end_math = text.find(r'\]', idx) |
| 295 | + if end_math != -1: |
| 296 | + insert_pos = end_math + len(r'\]') |
| 297 | + prose = '\nThe factor~2 comes from the corrected prefactor bound $B_n(u)/n^4 \\leq 1+3/(2\\pi-3) < 2$ (Proposition~\\ref{prop:tail_ratio}).\n' |
| 298 | + # Only add if not already there |
| 299 | + if prose.strip() not in text[insert_pos:insert_pos+200]: |
| 300 | + text = text[:insert_pos] + prose + text[insert_pos:] |
| 301 | + changes.append('Theorem 5: factor-2 prose note added after ε* display') |
| 302 | + |
| 303 | +# ================================================================ |
| 304 | +# Write result |
| 305 | +# ================================================================ |
| 306 | +with open(r'paper\main.tex', 'w', encoding='utf-8') as f: |
| 307 | + f.write(text) |
| 308 | + |
| 309 | +print(f'Original: {original_len} chars') |
| 310 | +print(f'New: {len(text)} chars') |
| 311 | +print('Changes:') |
| 312 | +for c in changes: |
| 313 | + print(f' + {c}') |
0 commit comments