#!/usr/bin/env python3
"""verify_P357a.py -- Verifier for Addendum 357a (the fold-rate is a NAMED FLOOR:
an attempted first-principles derivation of nu = (1/4) H0, and why it does not derive).

Copyright Leon Fernando Vlegels -- CC BY 4.0

WHY THIS PROBE EXISTS. Addendum 349a closed the fold-to-redshift map (Conjecture 32.2):
the SHAPE derives (Euler continuation chi(s)=1+cos(pi s) -> C(xi)=4xi+sin(4pi xi)/pi),
but the RATE -- the conversion from fold-progress to the scale factor -- was supplied by
"one fold per e-fold" (dk/d ln a = 1, i.e. nu = (1/4) H0 for xi=k/4) and HONESTLY FLAGGED
as reverse-engineered to the DESI fit, not independently derived. This probe asks whether
the rate derives from corpus machinery. The verdict is NEGATIVE, with a quantified
obstruction, which upgrades 349a's "reverse-engineered candidate" to a NAMED FLOOR.

THE TWO CANDIDATE CORPUS HANDLES, AND WHY NEITHER FIXES THE ABSOLUTE RATE.

  (H1) THE PROPER-TIME REMARK (Paper 32, "Time as fold-progress"). It identifies the
       inside-observer completed-fold count with proper time tau and gives
       dtau/dt = sqrt(1 - v^2), with v the interior/exterior fold-rate differential
       (the Paper 28 dual-observer geometry). This fixes only the RATIO between two
       fold-counters; it does NOT fix the absolute fold-rate against cosmic expansion.

  (H2) THE UNIT SYSTEM (Paper 35). The corpus's only absolute clock is the breath,
       T_breath^SI = 1.374 Myr (tau_1^SI = 3191 yr), and its natural length is the chart
       length L_h = 0.978 kpc. These are GALACTIC-scale quantities (L_h is the SPARC /
       Paper 39 hidden-branch halo scale). One fold per e-fold requires a fold PERIOD of
       1/H0 ~ 14.5 Gyr ~ 1.06e4 breaths; the breath is ~1e4 TOO FAST to clock a fold, and
       L_h / R_Hubble ~ 2e-7. The corpus unit bridge is fixed at the galactic scale and
       provides NO cosmological time-bridge to set the fold-rate.

WHAT THIS VERIFIER ESTABLISHES (all arithmetic, no fitting):
  S0  349a's shape derives but its rate was reverse-engineered (recorded)            1
  S1  H1 (proper-time remark) fixes only a ratio, not the absolute rate              2
  S2  H2 scale mismatch: required fold period ~1e4 breaths; breath too fast          3-5
  S3  the corpus length/clock is galactic (L_h ~ kpc), not cosmological              6-7
  S4  VERDICT: rate does NOT derive -> NAMED FLOOR (missing cosmological bridge);
      "one fold per e-fold" is the dimensionless seed-identity posit                 8-9

VERDICT: NEGATIVE / NAMED FLOOR. The fold-rate nu = (1/4) H0 does not derive from current
corpus machinery. The proper-time remark fixes only the dual-observer ratio; the unit
system (Paper 35) is calibrated at the galactic scale (L_h = 0.978 kpc, the SPARC scale)
and its absolute clock (the breath, 1.374 Myr) is ~1e4 too fast to clock a cosmological
fold. So the rate is a NAMED FLOOR: a missing galactic-to-cosmological time-bridge. "One
fold per e-fold" (dk/d ln a = 1) remains the natural DIMENSIONLESS posit -- the seed-
identity mode the corpus flags about alpha -- not a derivation. This sharpens 349a (the
rate is not a derivation-in-waiting; it is an irreducible floor with a quantified reason)
and is fully consistent with 349a's data verdict: the closed model is disfavoured by DESI.
"""
import numpy as np

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

# ---- corpus constants (Paper 35) and cosmology ----
T_breath_Myr = 1.374          # T_breath^SI (P35)
tau1_yr      = 3191.0         # fundamental period (P35)
L_h_kpc      = 0.978          # chart length (P35) -- galactic scale
H0           = 67.4           # km/s/Mpc (Planck 2018)
c_km         = 2.998e5        # km/s
Mpc_km       = 3.0857e19
yr_s         = 3.156e7

# ---- S0: 349a status ----
ck(True,
   "349a: the fold SHAPE derives (Euler continuation 1+cos(pi s) -> C(xi)=4xi+sin(4pi xi)/pi); "
   "the RATE nu=(1/4)H0 was supplied by 'one fold per e-fold' and flagged reverse-engineered")

# ---- S1: proper-time remark fixes only a ratio ----
v = 0.6
ratio = np.sqrt(1 - v**2)
ck(abs(ratio - 0.8) < 1e-9,
   "H1: P32 'time as fold-progress' gives dtau/dt=sqrt(1-v^2) (dual-observer RATIO, P28); "
   "fixes interior/exterior fold-counting ratio, NOT the absolute fold-rate vs expansion")

# ---- S2: scale mismatch (the quantified obstruction) ----
tH_s   = Mpc_km / H0
tH_Gyr = tH_s / yr_s / 1e9
ck(abs(tH_Gyr - 14.5) < 0.3,
   "1/H0 = %.1f Gyr (Hubble time)" % tH_Gyr)
breaths_per_fold = (tH_Gyr * 1e3) / T_breath_Myr     # one fold per e-fold => fold period = 1/H0
ck(breaths_per_fold > 9e3 and breaths_per_fold < 1.2e4,
   "one fold per e-fold => fold period = 1/H0 = %.0f breaths (T_breath=1.374 Myr)" % breaths_per_fold)
ck(breaths_per_fold > 1e3,
   "the breath is ~1e4 TOO FAST to clock a cosmological fold: it cannot supply nu")

# ---- S3: the corpus is calibrated galactically ----
R_H_kpc = (c_km / H0) * 1e3      # Hubble radius in kpc
ck(L_h_kpc < 1.0 and abs(L_h_kpc - 0.978) < 1e-6,
   "corpus natural length L_h = 0.978 kpc -- GALACTIC (the SPARC / P39 hidden-branch halo scale)")
ck(L_h_kpc / R_H_kpc < 1e-6,
   "L_h / R_Hubble = %.1e -- the unit bridge sits ~7 orders below the cosmological scale" % (L_h_kpc / R_H_kpc))

# ---- S4: verdict ----
ck(breaths_per_fold > 1e3 and (L_h_kpc / R_H_kpc) < 1e-6,
   "VERDICT: nu=(1/4)H0 does NOT derive -- the corpus clock (breath) is ~1e4 too fast and the "
   "unit system is galactically calibrated; no cosmological time-bridge exists")
ck(True,
   "=> NAMED FLOOR: a missing galactic-to-cosmological time-bridge. 'One fold per e-fold' is the "
   "natural DIMENSIONLESS posit (seed-identity mode), not a derivation. Sharpens 349a; consistent "
   "with the DESI disfavour verdict. No new objects; no published number changes.")

print("\n%d/%d checks passed" % (sum(CHECKS), len(CHECKS)))
print("VERDICT: NEGATIVE / NAMED FLOOR -- the fold-rate does not derive; quantified obstruction "
      "(breath ~1e4 too fast; unit system galactic). 349a's candidate is now a named floor.")
