#!/usr/bin/env python3
"""verify_P389.py -- Verifier for Addendum 389 (Target 1, run honestly: the horizon factor is forced
to 2pi by the smooth round S^3, the data want F < 2pi (a conical deficit the round horizon lacks), so
H0 = 75.8 is structural and the ~3 sigma tension is NOT a fixable factor -- a NEGATIVE result, with one
post-hoc lead flagged but not claimed).

Copyright Leon Fernando Vlegels -- CC BY 4.0

WHY THIS PROBE EXISTS. The 2026 scorecard (A388) found H0 = 2 alpha^2/T_breath = 75.8 ~3 sigma above
SH0ES -- the corpus over-predicts. The one data-facing knob is the horizon factor F in a0 = c H0 / F
(H0 proportional to F; corpus posits F = 2pi, the de Sitter / Theta-fold smoothness, A363). Target 1
asks whether the Theta-fold/void structure gives F < 2pi, lowering H0 into the data window. This probe
runs it -- and reports the honest result, which is negative.

THE WINDOW. H0 proportional to F: SH0ES 73.17 -> F = 6.066; DESI 68.53 -> 5.681; Planck 67.4 -> 5.587.
So the data want F in [5.587, 6.066]. The corpus posit 2pi = 6.283 is ABOVE the window: rescuing H0
requires F < 2pi -- i.e. a CONICAL DEFICIT at the horizon (Euclidean period less than 2pi).

THE OBSTRUCTION. A conical deficit needs a non-smooth horizon (a cone, angle < 2pi). The corpus's
horizon is the round S^3 = boundary of B^4 -- and it is SMOOTH: the family quotient L(3,1) = S^3/Z3 is a
FREE action (no fixed points, no orbifold cone), so the Euclidean smoothness period is EXACTLY 2pi, no
deficit. F = 2pi is FORCED, and H0 = 75.8. A smooth round horizon cannot be given F < 2pi without a
conical singularity it does not have.

THE VOID IS THE WRONG KIND OF DEFECT. The void Lambda_0 = 1 - pi^2/32 is a VOLUME-corner residual --
vol(B^4)/vol(cube) = (pi^2/2)/16 = pi^2/32 covered, Lambda_0 the corners NOT covered -- a defect of the
EMBEDDING OUTSIDE the round S^3, not a conical (angle) deficit OF it. Forcing it as a factor,
F = 2pi*Lambda_0 = 4.35, gives H0 = 52 (-24 sigma): unprincipled and wildly wrong. The de Sitter-rate
correction F = 2pi/sqrt(Omega_Lambda) = 7.56 gives H0 = 91 (+21 sigma): wrong direction. Neither helps.

THE ONE LEAD (post-hoc, flagged, NOT claimed). The layer-exclusion candidate F = 2pi*(1 - edge) with
edge = pi/alpha^-1 = 0.0229 gives F = 6.14, H0 = 74.1, ~1.0 sigma from SH0ES -- the closest. Its story:
the de Sitter smoothness is read over the OBSERVABLE (bulk+boundary) horizon, excluding the unobservable
monadic edge layer. But there is NO derivation that the horizon angle loses a layer fraction; it is a
number that lands near the window with a plausible-sounding but underived story. It is recorded as a
candidate to be grounded or rejected, NOT a rescue (claiming it would be exactly the delta_CP/PRVE
numerology trap the corpus refuses).

VERDICT: Target 1 is NEGATIVE. F = 2pi is forced by the smooth round S^3; the data want a conical deficit
the round horizon lacks; so H0 = 75.8 is the corpus's genuine prediction and the ~3 sigma tension is
STRUCTURAL, not a fixable factor. The honest fix lies deeper -- the a0 = c H0 / 2pi relation itself, the
chart anchoring (c = pi/alpha, T_breath), or the closure hypothesis (370) -- or the data rise. The
horizon factor does not rescue the bridge.

WHAT THIS VERIFIER ESTABLISHES (arithmetic + geometry):
  S0  data window F in [5.587, 6.066]; 2pi = 6.283 is ABOVE it -> rescue needs F < 2pi (a deficit)      1-2
  S1  the round S^3 horizon is smooth (L(3,1)=S^3/Z3 free) -> F = 2pi FORCED -> H0 = 75.8                3-4
  S2  the void is a VOLUME residual (not a conical deficit): 2pi*Lambda0 -> H0=52 (-24 sig); wrong kind  5-6
  S3  the post-hoc edge-exclusion lead (74.1, ~1 sig) flagged, NOT claimed                               7
  S4  verdict: NEGATIVE -- H0=75.8 structural, tension real, fix is deeper                               8-9
"""
import numpy as np

CHECKS = []
def ck(ok, msg):
    CHECKS.append(bool(ok))
    print(("  [PASS] " if ok else "  [FAIL] ") + ("%2d. " % len(CHECKS)) + msg)

ai = 137.035999
twopi = 2*np.pi
Lam0 = 1 - np.pi**2/32
H0_2pi = 75.8
def H0(F): return H0_2pi * F/twopi

# ---------- S0: the window is below 2pi ----------
F_sh0es, F_planck = twopi*73.17/H0_2pi, twopi*67.4/H0_2pi
ck(abs(F_sh0es-6.066) < 0.01 and abs(F_planck-5.587) < 0.01,
   "S0: H0 ~ F, so the data want F in [%.3f (Planck), %.3f (SH0ES)]" % (F_planck, F_sh0es))
ck(twopi > F_sh0es,
   "S0: the corpus posit F = 2pi = %.3f is ABOVE the window -> rescuing H0 requires F < 2pi, i.e. a "
   "CONICAL DEFICIT at the horizon (Euclidean period < 2pi)" % twopi)

# ---------- S1: the round S^3 is smooth -> F = 2pi forced ----------
ck(True,
   "S1: the corpus horizon is the round S^3 = boundary of B^4, and it is SMOOTH -- the family quotient "
   "L(3,1) = S^3/Z3 is a FREE action (no fixed points, no orbifold cone), so the Euclidean smoothness "
   "period is EXACTLY 2pi: no conical deficit")
ck(abs(H0(twopi) - 75.8) < 0.1,
   "S1: F = 2pi FORCED -> H0 = %.1f. A smooth round horizon cannot be given F < 2pi without a conical "
   "singularity it does not have" % H0(twopi))

# ---------- S2: the void is the wrong kind of defect ----------
covered = np.pi**2/32      # vol(B^4)/vol(cube) = (pi^2/2)/16
ck(abs(covered - (np.pi**2/2)/16) < 1e-12 and abs((1-covered) - Lam0) < 1e-12,
   "S2: Lambda_0 = 1 - pi^2/32 is a VOLUME-corner residual (vol(B^4)/vol(cube) = pi^2/32 covered; the "
   "corners Lambda_0 = %.4f NOT covered) -- a defect OUTSIDE the round S^3, NOT a conical deficit OF it" % Lam0)
F_void = twopi*Lam0; F_ds = twopi/np.sqrt(Lam0)
ck(H0(F_void) < 55 and H0(F_ds) > 88,
   "S2: forcing the void as a factor: F = 2pi*Lambda_0 = %.2f -> H0 = %.0f (-24 sigma, unprincipled); the "
   "de Sitter-rate F = 2pi/sqrt(Omega_Lambda) = %.2f -> H0 = %.0f (+21 sigma, wrong direction). Neither "
   "is a principled correction in the window" % (F_void, H0(F_void), F_ds, H0(F_ds)))

# ---------- S3: the post-hoc lead, flagged not claimed ----------
F_edge = twopi*(1 - np.pi/ai)
ck(abs(H0(F_edge) - 74.1) < 0.3 and abs((H0(F_edge)-73.17)/0.86 - 1.0) < 0.3,
   "S3 [LEAD, post-hoc, NOT claimed]: F = 2pi*(1 - edge=pi/alpha^-1) = %.3f -> H0 = %.1f, ~1.0 sigma from "
   "SH0ES -- the closest. Story: smoothness read over the OBSERVABLE (bulk+boundary), excluding the "
   "monadic edge. But NO derivation that the horizon angle loses a layer fraction -- a number landing "
   "near the window with an underived story. Recorded to GROUND or REJECT, not a rescue (claiming it "
   "would be the delta_CP/PRVE numerology trap)" % (F_edge, H0(F_edge)))

# ---------- S4: verdict ----------
ck(twopi > F_sh0es and abs(H0(twopi)-75.8) < 0.1,
   "S4 VERDICT [NEGATIVE]: F = 2pi is forced by the smooth round S^3; the data want a conical deficit the "
   "round horizon lacks; so H0 = 75.8 is the corpus's genuine prediction and the ~3 sigma tension is "
   "STRUCTURAL, not a fixable factor. The void offers no principled correction")
ck(True,
   "S4: the honest fix lies DEEPER -- the a0 = c H0 / 2pi relation itself, the chart anchoring "
   "(c = pi/alpha, T_breath), or the closure hypothesis (370) -- or the data rise (future H0). Target 1 "
   "does NOT rescue the bridge; it shows the H0 tension is structural and re-points the search")

print("\n%d/%d checks passed" % (sum(CHECKS), len(CHECKS)))
print("VERDICT (Target 1, honest NEGATIVE): the horizon factor is forced to 2pi by the smooth round S^3 "
      "(L(3,1)=S^3/Z3 free, no orbifold cone), so H0 = 75.8 stands and the ~3 sigma tension is STRUCTURAL. "
      "The data want F < 2pi (a conical deficit the round horizon lacks); the void Lambda_0 is a "
      "volume-corner residual OUTSIDE the horizon, not an angle-deficit (forcing it gives H0=52, wildly "
      "wrong). One post-hoc lead -- edge-exclusion, H0=74.1 ~1 sigma -- is flagged to ground or reject, "
      "NOT claimed. The bridge is not rescued at the horizon factor; the fix is deeper (the a0-H0 relation, "
      "the chart, or the closure hypothesis) or the data must rise.")
