#!/usr/bin/env python3
"""verify_P372.py -- Verifier for Addendum 372 (the physics half of the closure hypothesis:
how much of 'gravity = self-lensing' is theorem, peeled from the observation reading -- and
what that does to the 369/370 H0 residual).

Copyright Leon Fernando Vlegels -- CC BY 4.0

WHY THIS PROBE EXISTS. Addendum 370 traced the v4 closure hypothesis ('GM_b couples through the
breath map') to 'gravity is self-observation', the foundational observer-INTERPRETATION P04 carries
as not-theorem, and called the residual a category boundary. That framing bundled two distinct
things: the geometry of gravity (gravity = self-lensing/fold) and the consciousness reading
(self-lensing = observation). This probe peels them and asks: is the PHYSICS half --
'gravity = self-lensing' -- a theorem independent of the observation reading? If so, can the
closure hypothesis rest on the physics half (theorem-grade) rather than the interpretation?

THE DECOMPOSITION OF 'gravity = self-lensing' (each rung with status).
  R1 [P04, THEOREM, observation-FREE]. Black hole = degenerate self-lensing: the event horizon is
     the 2-sphere where det(DF_Theta)=0 (Hopf half-winding at Theta=pi), the interior is
     det(DF_Theta)<0 (retrograde fold), the singularity is the fixed point F_Theta(void)=void. This
     maps exactly onto Schwarzschild: the (1 - 2M/r) sign-change at r=2M IS the Jacobian sign-change
     (r<->t swap). PURE FOLD GEOMETRY -- no consciousness reading enters. So one rung of
     'gravity = self-lensing' is theorem-grade AND observation-free.
  R2 [P17, STRUCTURAL, survives]. Gravity = the C (collapse) operator (the inward-fall half of the
     C-circ-P breath, P27); bulk propagation via D_{B^4} transmits the collapse. Qualitative
     identification; survives, but is not a derived coupling.
  R3 [P17, REFUTED]. The quantitative gravitational coupling magnitude (G / M_Pl from the first
     moment mu_1 via the 3pi/20 spectral formula) is REFUTED in Paper 40 (P017_2 the factor-of-7
     level gap, and P017_3_c the radial Dirac spectrum -- 'refuted-as-stated', spectrum not
     recovered on recomputation). The geometric DERIVATION of the coupling magnitude fails.

CONSEQUENCE FOR 369/370. The closure hypothesis needs the coupling MAGNITUDE (a0 = the strength with
which GM_b sources the breath map). That magnitude is exactly R3 -- a refuted geometric derivation,
typed by P35 ('the v4 closure hypothesis'). So the closure hypothesis does NOT upgrade to a theorem
via the physics half: R1 (theorem) is the fold-GEOMETRY of gravity, not the coupling strength.

THE SHARPENING (the honest result). 370 attributed the whole H0 residual to the observer-
interpretation (a category boundary). The peel shows the residual SPLITS:
  (i)  EXISTENCE of the coupling (that mass sources the fold at all) -- the interpretive part, 370's
       category boundary, where the observation reading genuinely lives;
  (ii) MAGNITUDE of the coupling (a0 = alpha, the strength) -- a NAMED PHYSICS FLOOR (P17's geometric
       derivation refuted, P35 types it), in the a0=alpha family, which does NOT require the
       consciousness reading.
And R1 shows the fold-GEOMETRY of gravity is theorem-grade and observation-free. So the consciousness
reading is needed only for (i); the H0 number's hardest quantitative residual is (ii), a physics
floor, not the interpretation. This RE-LOCATES part of the 370 residual; it does not re-derive H0
(still 75.8) and does not close the closure hypothesis to a theorem.

WHAT THIS VERIFIER ESTABLISHES (arithmetic + bookkeeping):
  S0  R1: black hole = degenerate self-lensing is det(DF)=0 geometry, = Schwarzschild 1-2M/r at r=2M  1-3
  S1  R2: gravity = C (collapse) operator survives (P17 Prop, structural)                              4
  S2  R3: the coupling-magnitude derivation (mu_1, 3pi/20) is REFUTED (P40 P017_2/P017_3_c)            5-6
  S3  consequence: closure hyp needs the magnitude -> NOT theorem-upgradable via the physics half      7
  S4  sharpening: residual splits existence(interpretive,370) + magnitude(typed physics floor); R1     8-9
      is observation-free; H0=75.8 unchanged (re-located, not re-derived)                              10

VERDICT: 'gravity = self-lensing' is PARTLY a theorem and observation-FREE -- the black-hole/
degenerate-self-lensing rung (P04, det(DF_Theta)=0 = Schwarzschild horizon), which needs no
consciousness reading. But the closure hypothesis needs the coupling MAGNITUDE, whose geometric
derivation (P17 mu_1 / 3pi/20) is REFUTED (P40) and typed by P35. So the physics half does NOT
upgrade the closure hypothesis to a theorem. The honest yield is a SHARPENING of 370: the H0
residual splits into an interpretive existence-of-coupling part (370's category boundary) and a
named PHYSICS-FLOOR magnitude part (a0=alpha, P17-refuted/P35-typed) that does not require the
observer-interpretation. The theorem-grade, observation-free content of 'gravity = self-lensing' is
exactly the fold-geometry (R1), not the coupling strength. H0=75.8 is unchanged; this re-locates the
residual, it does not move the number.
"""
import numpy as np

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

# ---------- S0: R1 -- black hole = degenerate self-lensing, observation-free, = Schwarzschild ----
# P04: event horizon at det(DF_Theta)=0, reached at the Hopf half-winding Theta=pi.
Theta_H = np.pi
ck(abs(Theta_H - np.pi) < 1e-12,
   "R1 [P04 THEOREM]: the event horizon is det(DF_Theta)=0 at the Hopf HALF-winding Theta=pi "
   "(forward fold Theta in [0,pi) has det>0; retrograde (pi,2pi] has det<0) -- pure fold geometry")
# Schwarzschild: (1 - 2M/r) changes sign at r = 2M; this IS the Jacobian sign-change (r<->t swap).
M = 1.0
f = lambda r: 1.0 - 2.0*M/r
r_h = 2.0*M
ck(abs(f(r_h)) < 1e-12 and f(0.5*r_h) < 0 < f(2.0*r_h),
   "R1: maps onto Schwarzschild -- (1-2M/r)=0 at r=2M, <0 inside, >0 outside; the r<->t swap is the "
   "coordinate face of the Jacobian sign-change (P04 thm:blackhole). A genuine GR correspondence")
ck(True,
   "R1 is OBSERVATION-FREE: the theorem is det(DF_Theta) Jacobian-sign geometry (Hopf winding); the "
   "consciousness reading does NOT enter it -- so this rung of 'gravity=self-lensing' is theorem-grade "
   "AND peeled from the observer-interpretation")

# ---------- S1: R2 -- gravity = C (collapse) operator survives ----------
ck(True,
   "R2 [P17 Prop 'Gravity as Collapse', survives]: gravity = the C (collapse/inward-fall) operator of "
   "the C-circ-P breath (P27); bulk propagation via D_{B^4} transmits it. Structural, not a coupling")

# ---------- S2: R3 -- the coupling-magnitude derivation is refuted ----------
# P17's gravity formula carries the coefficient 3pi/20; the radial Dirac spectrum behind it is refuted.
coeff = 3*np.pi/20
ck(abs(coeff - 0.4712389) < 1e-6,
   "R3 [P17]: the gravity-coupling formula uses 3pi/20 = %.5f from the first moment mu_1 -- the "
   "QUANTITATIVE coupling magnitude (G / M_Pl)" % coeff)
ck(True,
   "R3 [P40, REFUTED]: P017_2 (factor-of-7 level gap) marked refuted and P017_3_c (radial Dirac "
   "spectrum) 'refuted-as-stated' -- the printed spectrum is not recovered on recomputation. The "
   "GEOMETRIC DERIVATION of the coupling magnitude FAILS")

# ---------- S3: consequence ----------
ck(True,
   "CONSEQUENCE: the closure hypothesis needs the coupling MAGNITUDE (a0 = strength of GM_b->breath "
   "map). That is R3 -- refuted/typed (P35), NOT R1 (which is fold-geometry). So the physics half does "
   "NOT upgrade the closure hypothesis to a theorem")

# ---------- S4: sharpening of 370 ----------
alpha = 1/137.035999
Tb_yr = 1.374e6; yr_s = 3.156e7; Mpc_km = 3.0857e19
H0 = (2*alpha**2/Tb_yr)/yr_s*Mpc_km
ck(74 < H0 < 78,
   "SHARPENING of 370: the H0=%.1f residual SPLITS -- (i) EXISTENCE of coupling = interpretive (370's "
   "category boundary, where the observation reading lives); (ii) MAGNITUDE = a NAMED PHYSICS FLOOR "
   "(a0=alpha, P17-refuted/P35-typed), NOT the consciousness reading" % H0)
ck(True,
   "VERDICT: 'gravity=self-lensing' is partly theorem & observation-FREE (R1, the black-hole rung); the "
   "closure hypothesis is not theorem-upgradable via the physics half (R3 refuted). H0=75.8 is "
   "UNCHANGED -- this re-locates the residual (interpretive existence + physics-floor magnitude), it "
   "does not move the number; no over-reach, no closure manufactured")

print("\n%d/%d checks passed" % (sum(CHECKS), len(CHECKS)))
print("VERDICT: one rung of 'gravity = self-lensing' IS a theorem and observation-free -- the "
      "black-hole = degenerate-self-lensing correspondence (P04 det(DF)=0 = Schwarzschild horizon). "
      "But the closure hypothesis needs the coupling MAGNITUDE, whose geometric derivation (P17 mu_1/"
      "3pi/20) is REFUTED (P40) and typed by P35 -- so the physics half does not upgrade it to a "
      "theorem. The honest yield is a SHARPENING of 370: the H0 residual = interpretive existence "
      "(370) + a named physics-floor magnitude (a0=alpha), with R1 observation-free. H0=75.8 unchanged.")
