|
| 1 | +"""Demo 67: P40 chi-twisted node-aware gauge sweep for primitive real |
| 2 | +Dirichlet L-functions. |
| 3 | +
|
| 4 | +Structural analogue of Demo 49 (P20 node-aware gauge sweep for zeta) |
| 5 | +extended to L(s, chi) via the P34 chi-twisted prime-ladder |
| 6 | +Hamiltonian, the P35 chi-twisted Weil-Guinand zero-side enumerator, |
| 7 | +and the P37 chi-twisted Weil-TNFR positivity bridge. |
| 8 | +
|
| 9 | +Whereas Demo 66 (P39) audited the canonical scalar-h gauges |
| 10 | +DEFAULT_GAUGES (P18), Demo 67 (P40) sweeps the **node-aware** gauges |
| 11 | +DEFAULT_NODEAWARE_GAUGES (P20) -- gauges of the form |
| 12 | +``(d, phi, eps) = g(h(E_n), hat nu_f(n), hat w(n))`` -- |
| 13 | +across the same three admissible Schwartz-even test families |
| 14 | +(gaussian, gaussian_mixture, hermite2_gaussian, inherited from P19). |
| 15 | +
|
| 16 | +The demo executes: |
| 17 | +
|
| 18 | +1. **Detailed (family, node_gauge) chart for chi_3 at sigma=2.0**. |
| 19 | +
|
| 20 | +2. **Aggregate sweep across chi_3, chi_4, chi_5** -- reports |
| 21 | + aggregate positivity flags and the [alpha_min, alpha_max] range |
| 22 | + for each character together with the (sigma, family, node_gauge) |
| 23 | + coordinates of the minimum. |
| 24 | +
|
| 25 | +3. **Certificate summaries and honest scope**. |
| 26 | +
|
| 27 | +Honest scope |
| 28 | +------------ |
| 29 | +This demo numerically probes alpha_chi(sigma; f, g) > 0 across three |
| 30 | +admissible Schwartz-even test families, four canonical node-aware |
| 31 | +gauges, and a finite Gaussian-width grid for three primitive real |
| 32 | +characters. Positive results strengthen the P37 / P38 / P39 |
| 33 | +numerical evidence under joint test-profile + node-aware mapping |
| 34 | +ambiguity but **do not prove** GRH for any L(s, chi). This demo |
| 35 | +also does NOT advance G4 = RH or the arithmetic obstruction of GRH. |
| 36 | +""" |
| 37 | + |
| 38 | +from __future__ import annotations |
| 39 | + |
| 40 | +import sys |
| 41 | + |
| 42 | +try: |
| 43 | + sys.stdout.reconfigure(encoding="utf-8") # type: ignore[attr-defined] |
| 44 | +except AttributeError: |
| 45 | + pass |
| 46 | + |
| 47 | +from tnfr.riemann import ( |
| 48 | + build_twisted_prime_ladder_hamiltonian, |
| 49 | + real_character_mod_3, |
| 50 | + real_character_mod_4, |
| 51 | + real_character_mod_5, |
| 52 | + sweep_twisted_nodeaware_gauge, |
| 53 | +) |
| 54 | + |
| 55 | +# -------------------------------------------------------------------- |
| 56 | +# Configuration |
| 57 | +# -------------------------------------------------------------------- |
| 58 | + |
| 59 | +SIGMAS = (1.0, 1.5, 2.0, 2.5, 3.0) |
| 60 | + |
| 61 | +N_PRIMES = 25 |
| 62 | +MAX_POWER = 6 |
| 63 | +COUPLING = 0.0 |
| 64 | + |
| 65 | +CHARACTERS = ( |
| 66 | + ("chi_3", real_character_mod_3), |
| 67 | + ("chi_4", real_character_mod_4), |
| 68 | + ("chi_5", real_character_mod_5), |
| 69 | +) |
| 70 | + |
| 71 | + |
| 72 | +def banner(title: str, char: str = "=") -> None: |
| 73 | + print(char * 72) |
| 74 | + print(title) |
| 75 | + print(char * 72) |
| 76 | + |
| 77 | + |
| 78 | +def fmt_signed(x: float, width: int = 12, prec: int = 4) -> str: |
| 79 | + if x != x: # NaN |
| 80 | + return f"{'nan':>{width}}" |
| 81 | + if x == float("inf"): |
| 82 | + return f"{'+inf':>{width}}" |
| 83 | + if x == float("-inf"): |
| 84 | + return f"{'-inf':>{width}}" |
| 85 | + return f"{x:+{width}.{prec}e}" |
| 86 | + |
| 87 | + |
| 88 | +# -------------------------------------------------------------------- |
| 89 | +# Block 1: detailed chart for chi_3 |
| 90 | +# -------------------------------------------------------------------- |
| 91 | + |
| 92 | + |
| 93 | +def block_detailed_chi3() -> None: |
| 94 | + banner( |
| 95 | + "BLOCK 1: detailed (family, node_gauge) chart for chi_3 " |
| 96 | + "across sigma grid" |
| 97 | + ) |
| 98 | + chi = real_character_mod_3() |
| 99 | + bundle = build_twisted_prime_ladder_hamiltonian( |
| 100 | + chi, |
| 101 | + n_primes=N_PRIMES, |
| 102 | + max_power=MAX_POWER, |
| 103 | + coupling=COUPLING, |
| 104 | + ) |
| 105 | + cert = sweep_twisted_nodeaware_gauge(chi, bundle, SIGMAS) |
| 106 | + |
| 107 | + print(f" character : {cert.character_name} " |
| 108 | + f"(q={cert.character_modulus})") |
| 109 | + print(f" n_sigma : {len(cert.sigmas)}") |
| 110 | + print(f" families : {cert.families}") |
| 111 | + print(f" node_gauges : {cert.node_gauges}") |
| 112 | + print() |
| 113 | + |
| 114 | + print(" W_chi[sigma; family] (gauge-independent):") |
| 115 | + header = " " + f"{'family':<22}" + " ".join( |
| 116 | + f"sigma={s:>5.2f}" for s in cert.sigmas |
| 117 | + ) |
| 118 | + print(header) |
| 119 | + for i, fname in enumerate(cert.families): |
| 120 | + row = " " + f"{fname:<22}" + " ".join( |
| 121 | + fmt_signed(float(cert.weil_table[i, j]), width=11, prec=3) |
| 122 | + for j in range(len(cert.sigmas)) |
| 123 | + ) |
| 124 | + print(row) |
| 125 | + print() |
| 126 | + |
| 127 | + j_target = len(cert.sigmas) // 2 |
| 128 | + sigma_target = float(cert.sigmas[j_target]) |
| 129 | + print(f" alpha_chi(sigma={sigma_target:.3f}; family, node_gauge):") |
| 130 | + header = " " + f"{'family\\node_gauge':<22}" + " ".join( |
| 131 | + f"{gn[:13]:>14}" for gn in cert.node_gauges |
| 132 | + ) |
| 133 | + print(header) |
| 134 | + for i, fname in enumerate(cert.families): |
| 135 | + row = " " + f"{fname:<22}" + " ".join( |
| 136 | + fmt_signed(float(cert.alpha_table[i, k, j_target]), |
| 137 | + width=14, prec=4) |
| 138 | + for k in range(len(cert.node_gauges)) |
| 139 | + ) |
| 140 | + print(row) |
| 141 | + print() |
| 142 | + |
| 143 | + |
| 144 | +# -------------------------------------------------------------------- |
| 145 | +# Block 2: aggregate sweep |
| 146 | +# -------------------------------------------------------------------- |
| 147 | + |
| 148 | + |
| 149 | +def block_aggregate_sweep() -> list: |
| 150 | + banner("BLOCK 2: aggregate sweep across chi_3, chi_4, chi_5") |
| 151 | + certs = [] |
| 152 | + print( |
| 153 | + f" {'character':<12} {'q':>3} {'W>=0':>6} {'a>0':>6} " |
| 154 | + f"{'alpha_min':>14} {'@(sigma,fam,node_gauge)':<48} " |
| 155 | + f"{'alpha_max':>14}" |
| 156 | + ) |
| 157 | + print(" " + "-" * 116) |
| 158 | + for name, factory in CHARACTERS: |
| 159 | + chi = factory() |
| 160 | + bundle = build_twisted_prime_ladder_hamiltonian( |
| 161 | + chi, |
| 162 | + n_primes=N_PRIMES, |
| 163 | + max_power=MAX_POWER, |
| 164 | + coupling=COUPLING, |
| 165 | + ) |
| 166 | + cert = sweep_twisted_nodeaware_gauge(chi, bundle, SIGMAS) |
| 167 | + certs.append(cert) |
| 168 | + loc = ( |
| 169 | + f"({cert.alpha_min_sigma:.3f}, " |
| 170 | + f"{cert.alpha_min_family}, " |
| 171 | + f"{cert.alpha_min_node_gauge})" |
| 172 | + ) |
| 173 | + print( |
| 174 | + f" {cert.character_name:<12} " |
| 175 | + f"{cert.character_modulus:>3} " |
| 176 | + f"{str(cert.weil_all_positive):>6} " |
| 177 | + f"{str(cert.alpha_all_positive):>6} " |
| 178 | + f"{fmt_signed(cert.alpha_min, width=14, prec=4)} " |
| 179 | + f"{loc:<48} " |
| 180 | + f"{fmt_signed(cert.alpha_max, width=14, prec=4)}" |
| 181 | + ) |
| 182 | + print() |
| 183 | + return certs |
| 184 | + |
| 185 | + |
| 186 | +# -------------------------------------------------------------------- |
| 187 | +# Block 3: summaries + scope |
| 188 | +# -------------------------------------------------------------------- |
| 189 | + |
| 190 | + |
| 191 | +def block_summaries(certs: list) -> None: |
| 192 | + banner("BLOCK 3: certificate summaries") |
| 193 | + for cert in certs: |
| 194 | + print(" " + cert.summary()) |
| 195 | + print() |
| 196 | + banner("HONEST SCOPE", char="-") |
| 197 | + print( |
| 198 | + " P40 numerically verifies alpha_chi(sigma; f, g) > 0\n" |
| 199 | + " across a finite Gaussian-width grid, three admissible\n" |
| 200 | + " Schwartz-even test families (P19) and four canonical\n" |
| 201 | + " node-aware gauges DEFAULT_NODEAWARE_GAUGES (P20) for three\n" |
| 202 | + " primitive real Dirichlet characters (chi_3, chi_4, chi_5).\n" |
| 203 | + " Positive results strengthen the P37 / P38 / P39 numerical\n" |
| 204 | + " evidence under joint test-profile + node-aware mapping\n" |
| 205 | + " ambiguity but do NOT prove GRH for any L(s, chi) and do\n" |
| 206 | + " NOT advance G4 = RH. Like P20 / P39, this is an\n" |
| 207 | + " RH-equivalent robustness audit on a finite grid, not a\n" |
| 208 | + " theorem on family-uniform positivity." |
| 209 | + ) |
| 210 | + |
| 211 | + |
| 212 | +def main() -> None: |
| 213 | + block_detailed_chi3() |
| 214 | + certs = block_aggregate_sweep() |
| 215 | + block_summaries(certs) |
| 216 | + |
| 217 | + |
| 218 | +if __name__ == "__main__": |
| 219 | + main() |
0 commit comments