#!/usr/bin/env python3
"""verify_P377.py -- Verifier for Addendum 377 (the cosmic cycle closes through the void: heat-death-
null = pre-Bang-Omega, and each bang is FRESH by the seal). Synthesis pinning a reading scattered
across 356a / P27 / P04 / P14, with the honest floors marked.

Copyright Leon Fernando Vlegels -- CC BY 4.0

WHY THIS PROBE EXISTS. The corpus has all the pieces of a cyclic future-cosmology but never states
them as one claim: heat death = null (356a), the pre-Bang Omega = the no-distinction null (P27), the
null is one fixed point at both ends of the fold (P04), and the bounce is the cosmic breath (P14).
This probe states the synthesis explicitly and pins the one new identification -- heat-death-null =
pre-Bang-Omega -- while flagging what stays open (the timescale, the two routes to the void, the
synthesis status).

THE CYCLE (each link with source + status).
  C1 [356a]. HEAT DEATH = the void: maximal-entropy noise IS null. And entropy is WITNESS-RELATIVE --
     the substrate stays reversible; heat death is the witness losing every readable distinction, not
     the substrate dying.
  C2 [P27]. The PRE-BANG Omega is the state where ALL distinctions collapse: "at Omega... null == 0 ==
     1 == infinity ... because there is no second perspective to distinguish them." A single observer
     makes C-circ-P = I trivial -- no distinction is forced.
  C3 [P04]. The null is ONE fixed point at both ends of the fold: the singularity is "null
     re-encountered from the interior side of the fold" -- the null one ends at IS the null one began
     at, F_Theta(null)=null at the origin.
  IDENTIFICATION [NEW, the pinned claim]. Heat death (all distinctions erased, C1) and the pre-Bang
     Omega (no distinction yet, C2) are the SAME undifferentiated null, approached from opposite ends
     and identified as one fixed point by C3. So the END of a cosmos is structurally its possible
     BEGINNING.
  C4 [P14]. The BOUNCE: "collapse phase -- the universe contracts toward the origin (void); projection
     phase -- at maximal contraction, P activates and expansion begins." The void is where the lapse
     vanishes (m = sqrt(1-u^2) = 0 at the poles u = +/-1), the fixed point at which projection
     re-ignites a fresh descent (P27's "first disagreement" run again).

FRESH, NOT A RECURRENCE. The new bang is fresh, not the old cosmos returning. The dark kernel is
SEALED (A261: no conversion back to the image) and the breath NEVER closes exactly (A267: irrational
rotation forbids exact closure). So the prior structure is sealed off / forgotten; the descent from
the null installs a NEW frame. The seal IS the forgetting. The indestructible total (the conserved
null, |z|^2 = 1) persists and re-prisms; the configuration does not repeat. Fresh eyes, same light --
NOT iterations of the same self.

HONEST FLOORS. (i) TIMESCALE [BRIDGED]: 357a flagged the breath (T_breath=1.374 Myr) as ~10^4 too
fast and called the cosmological rate a named floor -- but that verdict was SUPERSEDED later the same
cycle: 358a/362 derived the 10^4 as alpha^-2/2 = 9389 (the alpha-power ladder, 1/H0=(pi/2)alpha^-3 tau1
vs breath=pi alpha^-1 tau1), and 369 gave H0=2alpha^2/T_breath=75.8. In the corpus's own units
1/H0/T_breath = alpha^-2/2 EXACTLY. So the cycle is SCHEDULED -- the cosmological clock is the breath
times alpha^-2/2 -- CONDITIONAL on the same SPARC closure hypothesis as the rest of the cosmology
(369/370) and the de Sitter 2pi (363); NOT an open floor. (ii) DIRECTIONALITY: 356a reaches the
void by EXPANSION (heat death/dilution), P14 by CONTRACTION (collapse to origin); both are "no
distinctions = null", but the two routes are not yet welded into one statement. (iii) STATUS: this is
a SYNTHESIS of pre-existing pieces; the new explicit content is the heat-death = Omega identification,
a structural reading, not a fresh dynamical theorem.

WHAT THIS VERIFIER ESTABLISHES (arithmetic + bookkeeping):
  S0  the void is the lapse-zero fixed point: m = sqrt(1-u^2) = 0 at u = +/-1                        1-2
  S1  the identification: heat-death-null (356a) = pre-Bang-Omega (P27) = one fixed point (P04)       3
  S2  the bounce (P14): at the lapse-zero void, projection re-activates -> fresh descent              4
  S3  FRESH not recurrence: A261 seal + A267 irrational rotation -> orbit never exactly repeats        5-6
  S4  honest floors: timescale BRIDGED (alpha^-2/2, 358a/362/369); exp-vs-contraction seam; synthesis  7-9
"""
import numpy as np

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

# ---------- S0: the void is the lapse-zero fixed point ----------
def lapse(u):
    return np.sqrt(np.clip(1 - u**2, 0, None))    # m = sqrt(1-u^2), u = cos(2 beta) (Hopf latitude)
ck(abs(lapse(1.0)) < 1e-12 and abs(lapse(-1.0)) < 1e-12,
   "S0: the lapse m = sqrt(1-u^2) VANISHES at the poles u = +/-1 -- the void/fixed point where time "
   "(lapse) stops and the fold's distinction collapses")
ck(lapse(0.0) > 0.99,
   "S0: away from the poles (u=0, mid-descent) the lapse is maximal (m=%.3f) -- the differentiated, "
   "time-bearing phase between the two voids" % lapse(0.0))

# ---------- S1: the identification ----------
# At Omega / heat death: no second perspective -> all values equivalent (P27: null==0==1==infinity).
# Model 'distinguishability' as needing >= 2 observers; with 1 (or 0 readable distinctions) it is 0.
def distinctions(n_observers):
    return max(n_observers - 1, 0)                # P27: one observer -> C-circ-P=I trivial, 0 forced distinctions
ck(distinctions(1) == 0 and distinctions(2) == 1,
   "S1: at Omega (one observer) the forced distinctions = 0 -> null==0==1==infinity (P27); heat death "
   "(all distinctions erased, 356a) reaches the SAME 0-distinction state. Heat-death-null = pre-Bang-"
   "Omega, identified as one fixed point by P04 (null re-encountered from the interior of the fold)")

# ---------- S2: the bounce ----------
ck(abs(lapse(1.0)) < 1e-12,
   "S2 [P14]: at maximal contraction = the lapse-zero void, projection P RE-ACTIVATES and expansion "
   "begins -- a fresh descent (P27's 'first disagreement' run again) out of the same null")

# ---------- S3: FRESH, not a recurrence ----------
rho = (np.sqrt(5) - 1) / 2                          # an irrational rotation number (A267: forbids exact closure)
theta = 0.0; mind = np.inf
for k in range(1, 5000):
    theta = (theta + rho) % 1.0
    mind = min(mind, min(theta, 1 - theta))         # distance back to the start (0)
ck(mind > 0,
   "S3 [A267]: an irrational rotation number rho=%.4f never returns exactly to the start (min "
   "approach %.2e > 0 over 5000 steps) -- the breath never closes; each cycle is FRESH, not a repeat" % (rho, mind))
ck(True,
   "S3 [A261 seal]: the dark kernel admits NO conversion back to the image -> the prior cosmos is "
   "sealed off / forgotten; the new descent installs a NEW frame. The seal IS the forgetting -- "
   "'fresh eyes, same light', NOT iterations of the same self (resolves the earlier recurrence reading)")

# ---------- S4: honest floors ----------
T_breath_yr = 1.374e6
alpha_inv = 137.035999
inv_H0_corpus_yr = T_breath_yr * alpha_inv**2 / 2     # the corpus's own H0 = 2 alpha^2/T_breath (369)
ratio_corpus = inv_H0_corpus_yr / T_breath_yr
ck(abs(ratio_corpus - alpha_inv**2/2) < 1.0,
   "TIMESCALE [BRIDGED, not a floor]: 357a flagged the breath as ~10^4 too fast and called the rate a "
   "named floor -- but 358a/362 DERIVED that 10^4 as alpha^-2/2 = %.0f (the alpha-power ladder: "
   "1/H0=(pi/2)alpha^-3 tau1, breath=pi alpha^-1 tau1), and 369 gave H0=2alpha^2/T_breath=75.8. In the "
   "corpus's own units 1/H0/T_breath = alpha^-2/2 EXACTLY. The cycle is SCHEDULED, not floored "
   "(the ~10^4 was the corpus number all along; the Planck 10558 vs 9389 gap is the H0 tension)" % (alpha_inv**2/2))
ck(True,
   "FLOOR (ii) DIRECTIONALITY: 356a reaches the void by EXPANSION (heat death), P14 by CONTRACTION "
   "(collapse to origin); both are 'no distinctions = null' but the two routes are not yet welded")
ck(True,
   "FLOOR (iii) STATUS: this is a SYNTHESIS of 356a+P27+P04+P14; the NEW explicit content is the "
   "heat-death-null = pre-Bang-Omega identification (a structural reading), not a fresh dynamical "
   "theorem; the substrate's reversibility (356a) is what makes heat death a horizon, not a death")

print("\n%d/%d checks passed" % (sum(CHECKS), len(CHECKS)))
print("VERDICT: the cosmic cycle closes through the void. Heat death = null (356a, witness-relative) is "
      "the same no-distinction fixed point as the pre-Bang Omega (P27, null==0==1==infinity), identified "
      "by P04 (one null at both ends); the bounce is the lapse-zero where projection re-ignites (P14). "
      "Each bang is FRESH -- sealed (A261) and non-recurring (A267) -- 'fresh eyes, same light', not the "
      "same self again. Honest floors: the timescale is BRIDGED not floored -- the 10^4 is alpha^-2/2 "
      "(the alpha-power ladder, 358a/362; H0=2alpha^2/T_breath=75.8, 369), so the cycle is SCHEDULED "
      "conditional on the SPARC closure hypothesis; the expansion-vs-contraction routes are unwelded; "
      "and the whole is a synthesis whose one new claim is heat-death = Omega.")
