#!/usr/bin/env python3
"""
SCOPE NOTE, 2026-10-13 (comp 201).  Where this file lists "the coherence length d_0 <~
2.3 nm" among the theory's lengths and evaluates the area-law ratio there (5e-53), that
is the Casimir bound of its day, kept as found.  comp 201 derived d_0 = sqrt(2) hbar c /
m_h = 2.2 am; (l_P / l)^2 grows as l shrinks, so the shortfall at that length is
thirty-four orders instead of fifty-two, and the negative answer below (neither resource
fixes the magnitude of Lambda) stands.

PROVENANCE: NUMERICAL

Computation 188 -- Can PST's own area law or its finiteness fix the magnitude of Lambda?
No, and here is by how much
=========================================================================================
THE QUESTION, as the register posed it on 2026-07-13 and the backlog carried it as B.3.
PST declines to derive the static valley depth Delta F, the energy quantum each
threshold crossing releases, and with it the magnitude of the cosmological constant
(\\S sec:cosmo-sign; comp 82 reclassified the magnitude as T(C)-contingent).  Two
resources of the theory's own had never been pointed at it:

  (i)  an "area-law property" of Pi, boundary data scaling with area rather than
       volume, which the first edition stated in its holography comparison; and
  (ii) the finiteness of the internal structure: Lambda_UV = sqrt|D|, the grain
       l_* = hbar c / M_*, the coherence length d_0 <~ 2.3 nm.

Does either constrain Delta F?  The stated prior was negative.  Three hard constraints
on any attempt, carried over unchanged: no fourth postulate; nothing that revives
sub-threshold-substrate-gravitates (three independent killers, comp 82's era); and
PST-internal only, so no imported holographic bound (Reed's in particular).

WHAT THIS COMPUTATION DOES
--------------------------
  1.  RESOURCE (i) NO LONGER EXISTS IN THE SECOND EDITION, and the book says so.  The
      Appendix D row on holography now reads "The bound is not derived: Pi's kernel is
      supported on the bulk, and no area law follows from it", and \\S sec:open-horizon
      gives the three structural obstructions.  So the first leg of the question is moot:
      there is no derived area law to use.  Recorded, not computed.

  2.  AN AREA LAW IN PST'S OWN LENGTHS WOULD BE WRONG, QUANTIFIED.  If an area law were
      written with the quantum of area set by a length the theory owns, its entropy
      would miss A / 4 l_P^2 by (l_P / l)^2: about 1e-32 for the grain and 5e-53 for the
      coherence length.  The book says "tens of orders"; these are the numbers.

  3.  THE ENERGY BOUND SUCH A LAW WOULD IMPLY IS VIOLATED BY THE OBSERVED LAMBDA.  The
      only way an area law constrains an energy density is through the argument that a
      region of size L must not hold more vacuum energy than a black hole of that size,
      rho <= 3 c^4 / (8 pi G L^2) (Cohen, Kaplan and Nelson's form), which at L = c/H_0 is
      the critical density.  That argument uses G.  Replacing G by the "G" an l-quantised
      area law would imply, G_l = l^2 c^3 / hbar, scales the bound by (l_P / l)^2: the
      grain-quantised bound is 1e-32 rho_crit and the coherence-length one 5e-53 rho_crit,
      against an observed rho_Lambda of 0.7 rho_crit.  So an area law in PST's own lengths
      is not a weak resource but a false statement, which is the right thing for a theory
      that does not derive one.

  4.  THE BOUND THAT LANDS USES l_P, WHICH PST REACHES ONLY THROUGH ITS EMERGENT G.
      eq:G-from-seeley fixes G from the projected Einstein--Hilbert term, so the CKN bound
      with the true G is available to PST exactly as it is to general relativity: it says
      rho_Lambda <= rho_crit, observed at 0.7, and it is an inequality on a total vacuum
      energy, not an equation for Delta F.  Delta F enters only through the product
      j_tau Delta F (eq:rho-inst-cosmo), so any bound on rho constrains the product and
      leaves the factors free; comp 82 already placed j_tau at ~1e-37 per configuration
      for Delta F ~ M_*.

  5.  RESOURCE (ii) GIVES THE WRONG SCALE BY FIFTY-NINE ORDERS.  The finiteness fixes an
      ultraviolet scale, M_* = 1.285 TeV; the zero-point density an effective theory cut
      off there would carry is M_*^4, about 1e59 rho_Lambda.  That is Mechanism A of
      \\S sec:cosmo-sign, whose sign the book already records as regulator-dependent and
      whose magnitude it inherits from the Standard Model rather than fixing.  Finiteness
      makes the integral converge; it does not make it small.

VERDICT.  Negative on both legs, as the prior said, and now with numbers: the area law
does not exist in the theory, would be falsified if it did, and the finiteness sets a
scale fifty-nine orders too large.  Nothing here touches the three structural results
(sign, w = -1, non-dilution), and nothing here needs a fourth postulate or an import.
Backlog item B.3 closes on this file.

A "pass": the two entropy ratios and the two bound ratios below 1e-30 and 1e-50
respectively; the l_P bound above the observed density; the M_* zero-point above 1e58
times the observed density; and j_tau Delta F reproducing rho_Lambda at comp 82's values.
"""
import math

# Constants (SI)
hbar = 1.054571817e-34
c    = 2.99792458e8
G    = 6.67430e-11
eV   = 1.602176634e-19
GeV  = 1e9 * eV
l_P  = math.sqrt(hbar * G / c**3)                 # 1.616e-35 m
H0   = 70e3 / 3.0857e22                           # s^-1, 70 km/s/Mpc
rho_crit   = 3 * H0**2 * c**2 / (8 * math.pi * G)  # J/m^3
rho_Lambda = 5.9e-10                              # J/m^3, observed (comp 82's value)

# PST's lengths
d0   = 2.3e-9                                     # coherence-length bound, eq:d0bound
Mstar_GeV = 1285.0
l_star = hbar * c / (Mstar_GeV * GeV)             # grain, hbar c / M_*

def area_law_entropy_ratio(l):
    """S_l / S_P for an area law A/(4 l^2) against A/(4 l_P^2)."""
    return (l_P / l)**2

def ckn_bound(G_eff, L):
    """rho_max = 3 c^4 / (8 pi G_eff L^2), an energy density: no more vacuum energy in a
    region of size L than a black hole of that size holds.  At L = c/H_0 and G_eff = G
    this is the critical density 3 H_0^2 c^2 / (8 pi G)."""
    return 3 * c**4 / (8 * math.pi * G_eff * L**2)

def G_of_length(l):
    """The gravitational constant an l-quantised area law would imply, l^2 = hbar G / c^3."""
    return l**2 * c**3 / hbar

def main():
    print("=" * 100)
    print("  Computation 188 -- Lambda's magnitude from PST's own area law or finiteness: no")
    print("=" * 100)
    L_H = c / H0
    print(f"\n  l_P = {l_P:.3e} m   d_0 = {d0:.1e} m   l_* = {l_star:.3e} m   L_H = c/H_0 = {L_H:.3e} m")
    print(f"  rho_crit = {rho_crit:.3e} J/m^3   rho_Lambda = {rho_Lambda:.3e} J/m^3   ratio = {rho_Lambda/rho_crit:.2f}")

    print("\n  (1) RESOURCE (i): the second edition derives no area law.  Appendix D, holography")
    print("      row: 'Pi's kernel is supported on the bulk, and no area law follows from it'.")
    print("      Recorded; nothing to compute on this leg.")

    print("\n  (2) WHAT AN AREA LAW IN PST'S OWN LENGTHS WOULD MISS, S_l / S_P = (l_P / l)^2")
    r_star = area_law_entropy_ratio(l_star)
    r_d0   = area_law_entropy_ratio(d0)
    print(f"      grain l_*            : {r_star:.2e}   ({math.log10(1/r_star):.0f} orders short of A/4 l_P^2)")
    print(f"      coherence length d_0 : {r_d0:.2e}   ({math.log10(1/r_d0):.0f} orders short)")

    print("\n  (3) THE ENERGY BOUND SUCH A LAW IMPLIES, rho <= 3 c^4 / (8 pi G_l L_H^2), AGAINST rho_Lambda")
    rows = []
    for name, l in (("l_P (emergent G, i.e. GR's bound)", l_P), ("grain l_*", l_star), ("coherence length d_0", d0)):
        b = ckn_bound(G_of_length(l), L_H)
        rows.append((name, l, b))
        verdict = "satisfied" if rho_Lambda <= b else "VIOLATED by the observed Lambda"
        print(f"      {name:36s} bound = {b:.3e} J/m^3 = {b/rho_crit:.2e} rho_crit   {verdict}")
    b_P, b_star, b_d0 = rows[0][2], rows[1][2], rows[2][2]

    print("\n  (4) THE BOUND THAT LANDS IS GR'S, THROUGH eq:G-from-seeley, AND IT IS AN INEQUALITY ON A PRODUCT")
    print(f"      rho_Lambda / bound(l_P) = {rho_Lambda/b_P:.2f}: consistent, not predicted.")
    # comp 82's values: j_tau Delta F (|D|/V) = rho_Lambda with Delta F ~ M_*, |D|/V = 1/d_0^4
    DeltaF = Mstar_GeV * GeV
    nD = 1.0 / d0**4
    j_tau = rho_Lambda / (nD * DeltaF)
    print(f"      Delta F ~ M_* = {DeltaF:.3e} J,  |D|/V = 1/d_0^4 = {nD:.3e} m^-3  ->  j_tau = {j_tau:.3e} per configuration")
    print(f"      A bound on rho constrains j_tau * Delta F; it fixes neither factor.")

    print("\n  (5) RESOURCE (ii): THE SCALE THE FINITENESS SETS, M_*^4, AGAINST rho_Lambda")
    GeV4_in_J_per_m3 = GeV * (GeV / (hbar * c))**3
    rho_Mstar = Mstar_GeV**4 * GeV4_in_J_per_m3
    print(f"      M_*^4 = {rho_Mstar:.3e} J/m^3 = {rho_Mstar/rho_Lambda:.2e} rho_Lambda   ({math.log10(rho_Mstar/rho_Lambda):.0f} orders too large)")
    print("      This is Mechanism A of sec:cosmo-sign: finite, regulator-dependent in sign, inherited.")

    checks = [
        ("entropy ratio for l_* below 1e-30", r_star < 1e-30),
        ("entropy ratio for d_0 below 1e-50", r_d0 < 1e-50),
        ("l_*-quantised bound violated by the observed Lambda", rho_Lambda > b_star),
        ("d_0-quantised bound violated by the observed Lambda", rho_Lambda > b_d0),
        ("l_P bound (GR's) satisfied by the observed Lambda", rho_Lambda <= b_P),
        ("M_*^4 exceeds rho_Lambda by more than 1e58", rho_Mstar / rho_Lambda > 1e58),
        ("comp 82's j_tau reproduces rho_Lambda at Delta F ~ M_*", abs(j_tau * nD * DeltaF / rho_Lambda - 1) < 1e-9),
    ]
    print("\n" + "=" * 100)
    for name, ok in checks:
        print(f"  {'ok  ' if ok else 'FAIL'}  {name}")
    print("=" * 100)
    print("  VERDICT: negative on both legs.  No area law exists in the theory; one written in its")
    print("  own lengths would be falsified by the observed Lambda; the finiteness sets a scale")
    print("  fifty-nine orders too large; the bound that lands is GR's and bounds a product.")
    print("  PASS" if all(ok for _, ok in checks) else "  FAIL")

if __name__ == "__main__":
    main()
