|
| 1 | +"""Demo 69: P42 chi-twisted uniform-coercivity certificate for |
| 2 | +primitive real Dirichlet L-functions. |
| 3 | +
|
| 4 | +Structural extension of the zeta-track P22 / P23 / P24 milestones |
| 5 | +(empirical interval-level coercivity certificate with adaptive |
| 6 | +refinement) to L(s, chi) via the P34 chi-twisted prime-ladder |
| 7 | +Hamiltonian, the P35 chi-twisted Weil-Guinand zero-side enumerator, |
| 8 | +and the P37 chi-twisted Weil-TNFR positivity bridge. |
| 9 | +
|
| 10 | +Whereas Demos 66 / 67 / 68 (P39 / P40 / P41) verify pointwise |
| 11 | +positivity of alpha_chi(sigma; f, g) on a finite (sigma, family, |
| 12 | +gauge) grid, Demo 69 (P42) lifts pointwise positivity to *interval* |
| 13 | +positivity on a dense log-spaced sigma window by combining: |
| 14 | +
|
| 15 | +* a finite-difference Lipschitz proxy L_proxy, and |
| 16 | +* three interval lower bounds (global, stratified, segment-local), |
| 17 | +* plus optional adaptive bisection of the worst segments. |
| 18 | +
|
| 19 | +The demo executes: |
| 20 | +
|
| 21 | +1. **Sigma-window certificate for chi_3, chi_4, chi_5** without |
| 22 | + refinement (pure P22-style). |
| 23 | +
|
| 24 | +2. **Adaptive refinement** for the worst character with two rounds |
| 25 | + of bisection on the two worst segments per round (P24-style). |
| 26 | +
|
| 27 | +3. **Certificate summaries and honest scope**. |
| 28 | +
|
| 29 | +Honest scope |
| 30 | +------------ |
| 31 | +This demo numerically probes alpha_chi > 0 across an interval-level |
| 32 | +empirical certificate (sampled minima + Lipschitz envelope + segment |
| 33 | +linear envelope) on three primitive real characters. Positive |
| 34 | +results strengthen the P37 / P38 / P39 / P40 / P41 numerical |
| 35 | +evidence by promoting pointwise positivity to interval-level |
| 36 | +positivity with explicit Lipschitz control, but **do not prove** |
| 37 | +GRH for any L(s, chi) and do NOT advance G4 = RH. Like P22 / P23 |
| 38 | +/ P24 on the zeta side, this is an empirical interval-level |
| 39 | +diagnostic on a finite grid, not a theorem on family-uniform |
| 40 | +positivity over the full admissible Schwartz-even space. |
| 41 | +""" |
| 42 | + |
| 43 | +from __future__ import annotations |
| 44 | + |
| 45 | +import sys |
| 46 | + |
| 47 | +try: |
| 48 | + sys.stdout.reconfigure(encoding="utf-8") # type: ignore[attr-defined] |
| 49 | +except AttributeError: |
| 50 | + pass |
| 51 | + |
| 52 | +from tnfr.riemann import ( |
| 53 | + build_twisted_prime_ladder_hamiltonian, |
| 54 | + real_character_mod_3, |
| 55 | + real_character_mod_4, |
| 56 | + real_character_mod_5, |
| 57 | + verify_twisted_uniform_coercivity_empirical, |
| 58 | +) |
| 59 | + |
| 60 | +# -------------------------------------------------------------------- |
| 61 | +# Configuration |
| 62 | +# -------------------------------------------------------------------- |
| 63 | + |
| 64 | +SIGMA_MIN = 1.0 |
| 65 | +SIGMA_MAX = 3.0 |
| 66 | +N_SIGMA = 5 |
| 67 | + |
| 68 | +N_PRIMES = 15 |
| 69 | +MAX_POWER = 4 |
| 70 | +COUPLING = 0.0 |
| 71 | + |
| 72 | +CHARACTERS = ( |
| 73 | + ("chi_3", real_character_mod_3), |
| 74 | + ("chi_4", real_character_mod_4), |
| 75 | + ("chi_5", real_character_mod_5), |
| 76 | +) |
| 77 | + |
| 78 | + |
| 79 | +def banner(title: str, char: str = "=") -> None: |
| 80 | + print(char * 72) |
| 81 | + print(title) |
| 82 | + print(char * 72) |
| 83 | + |
| 84 | + |
| 85 | +def fmt_signed(x: float, width: int = 12, prec: int = 4) -> str: |
| 86 | + if x != x: # NaN |
| 87 | + return f"{'nan':>{width}}" |
| 88 | + if x == float("inf"): |
| 89 | + return f"{'+inf':>{width}}" |
| 90 | + if x == float("-inf"): |
| 91 | + return f"{'-inf':>{width}}" |
| 92 | + return f"{x:+{width}.{prec}e}" |
| 93 | + |
| 94 | + |
| 95 | +# -------------------------------------------------------------------- |
| 96 | +# Block 1: sigma-window certificate (no refinement) |
| 97 | +# -------------------------------------------------------------------- |
| 98 | + |
| 99 | + |
| 100 | +def block_sigma_window() -> list: |
| 101 | + banner( |
| 102 | + "BLOCK 1: chi-twisted uniform-coercivity certificate " |
| 103 | + "(no refinement)" |
| 104 | + ) |
| 105 | + print( |
| 106 | + f" sigma window : [{SIGMA_MIN:.3f}, {SIGMA_MAX:.3f}] " |
| 107 | + f"n_sigma = {N_SIGMA} (log-spaced)" |
| 108 | + ) |
| 109 | + print() |
| 110 | + print( |
| 111 | + f" {'chi':<14} {'q':>3} {'a_min':>14} {'a_max':>14} " |
| 112 | + f"{'L_proxy':>12} {'lb_global':>14} {'lb_strat':>14} " |
| 113 | + f"{'lb_local':>14} {'all+':>6}" |
| 114 | + ) |
| 115 | + print(" " + "-" * 130) |
| 116 | + certs = [] |
| 117 | + for name, factory in CHARACTERS: |
| 118 | + chi = factory() |
| 119 | + bundle = build_twisted_prime_ladder_hamiltonian( |
| 120 | + chi, |
| 121 | + n_primes=N_PRIMES, |
| 122 | + max_power=MAX_POWER, |
| 123 | + coupling=COUPLING, |
| 124 | + ) |
| 125 | + cert = verify_twisted_uniform_coercivity_empirical( |
| 126 | + chi, |
| 127 | + bundle, |
| 128 | + sigma_min=SIGMA_MIN, |
| 129 | + sigma_max=SIGMA_MAX, |
| 130 | + n_sigma=N_SIGMA, |
| 131 | + ) |
| 132 | + certs.append((name, cert)) |
| 133 | + all_pos = bool( |
| 134 | + cert.sampled_all_positive |
| 135 | + and cert.interval_lower_global_positive |
| 136 | + and cert.interval_lower_stratified_positive |
| 137 | + and cert.interval_lower_local_positive |
| 138 | + ) |
| 139 | + print( |
| 140 | + f" {cert.character_name:<14} " |
| 141 | + f"{cert.character_modulus:>3} " |
| 142 | + f"{fmt_signed(cert.sampled_alpha_min, width=14, prec=4)} " |
| 143 | + f"{fmt_signed(cert.sampled_alpha_max, width=14, prec=4)} " |
| 144 | + f"{cert.lipschitz_proxy_max:>12.4e} " |
| 145 | + f"{fmt_signed(cert.interval_lower_bound_global, 14, 4)} " |
| 146 | + f"{fmt_signed(cert.interval_lower_bound_stratified, 14, 4)} " |
| 147 | + f"{fmt_signed(cert.interval_lower_bound_local, 14, 4)} " |
| 148 | + f"{str(all_pos):>6}" |
| 149 | + ) |
| 150 | + print() |
| 151 | + return certs |
| 152 | + |
| 153 | + |
| 154 | +# -------------------------------------------------------------------- |
| 155 | +# Block 2: adaptive refinement on the worst character |
| 156 | +# -------------------------------------------------------------------- |
| 157 | + |
| 158 | + |
| 159 | +def block_adaptive_refinement(certs: list) -> None: |
| 160 | + banner( |
| 161 | + "BLOCK 2: adaptive refinement on worst-margin character " |
| 162 | + "(P24-style)" |
| 163 | + ) |
| 164 | + name, worst_cert = min( |
| 165 | + certs, key=lambda nc: nc[1].interval_lower_bound_local |
| 166 | + ) |
| 167 | + print( |
| 168 | + f" worst character : {worst_cert.character_name} " |
| 169 | + f"(q={worst_cert.character_modulus})" |
| 170 | + ) |
| 171 | + print( |
| 172 | + f" pre-refinement lb : " |
| 173 | + f"{worst_cert.interval_lower_bound_local:+.4e}" |
| 174 | + ) |
| 175 | + print(f" pre-refinement n_sigma : {worst_cert.n_sigma}") |
| 176 | + print() |
| 177 | + |
| 178 | + factory = dict(CHARACTERS)[name] |
| 179 | + chi = factory() |
| 180 | + bundle = build_twisted_prime_ladder_hamiltonian( |
| 181 | + chi, |
| 182 | + n_primes=N_PRIMES, |
| 183 | + max_power=MAX_POWER, |
| 184 | + coupling=COUPLING, |
| 185 | + ) |
| 186 | + refined = verify_twisted_uniform_coercivity_empirical( |
| 187 | + chi, |
| 188 | + bundle, |
| 189 | + sigma_min=SIGMA_MIN, |
| 190 | + sigma_max=SIGMA_MAX, |
| 191 | + n_sigma=N_SIGMA, |
| 192 | + refinement_rounds=1, |
| 193 | + refinement_per_round=2, |
| 194 | + ) |
| 195 | + print( |
| 196 | + f" refinement_rounds : {refined.n_refinement_rounds}" |
| 197 | + ) |
| 198 | + print( |
| 199 | + f" refined n_sigma : {refined.n_sigma_refined}" |
| 200 | + ) |
| 201 | + print( |
| 202 | + f" pre-refinement lb : " |
| 203 | + f"{refined.interval_lower_bound_local:+.4e}" |
| 204 | + ) |
| 205 | + print( |
| 206 | + f" refined lb (local) : " |
| 207 | + f"{refined.interval_lower_bound_local_refined:+.4e}" |
| 208 | + ) |
| 209 | + print( |
| 210 | + f" refined lb positive : " |
| 211 | + f"{refined.interval_lower_local_refined_positive}" |
| 212 | + ) |
| 213 | + print() |
| 214 | + |
| 215 | + |
| 216 | +# -------------------------------------------------------------------- |
| 217 | +# Block 3: summaries + scope |
| 218 | +# -------------------------------------------------------------------- |
| 219 | + |
| 220 | + |
| 221 | +def block_summaries(certs: list) -> None: |
| 222 | + banner("BLOCK 3: certificate summaries") |
| 223 | + for _, cert in certs: |
| 224 | + print(" " + cert.summary()) |
| 225 | + print() |
| 226 | + banner("HONEST SCOPE", char="-") |
| 227 | + print( |
| 228 | + " P42 numerically verifies alpha_chi > 0 at the interval\n" |
| 229 | + " level via a sampled minimum plus a finite-difference\n" |
| 230 | + " Lipschitz envelope on a finite log-spaced Gaussian-width\n" |
| 231 | + " window for three primitive real Dirichlet characters\n" |
| 232 | + " (chi_3, chi_4, chi_5). Positive lower bounds strengthen\n" |
| 233 | + " the P37 / P38 / P39 / P40 / P41 numerical evidence by\n" |
| 234 | + " promoting pointwise positivity to interval-level\n" |
| 235 | + " positivity with explicit Lipschitz control, but do NOT\n" |
| 236 | + " prove GRH for any L(s, chi) and do NOT advance G4 = RH.\n" |
| 237 | + " Like P22 / P23 / P24 on the zeta side, this is an\n" |
| 238 | + " empirical interval-level diagnostic on a finite grid,\n" |
| 239 | + " not a theorem on family-uniform positivity over the full\n" |
| 240 | + " admissible Schwartz-even space." |
| 241 | + ) |
| 242 | + |
| 243 | + |
| 244 | +def main() -> None: |
| 245 | + certs = block_sigma_window() |
| 246 | + block_adaptive_refinement(certs) |
| 247 | + block_summaries(certs) |
| 248 | + |
| 249 | + |
| 250 | +if __name__ == "__main__": |
| 251 | + main() |
0 commit comments