"""
WIN-COLUMN conversion #2 — GR's classical gravity tests.
Four classic tests: (1) Mercury perihelion, (2) light deflection, (3) Shapiro delay, (4) GW speed.
Question: does DFD reproduce them, demoting GR's SOLE win to a TIE?

DFD's weak-field optical metric n=e^psi gives PPN parameters gamma=beta=1 (theorem-grade in corpus),
identical to GR at 1PN. So all four tests are matched => TIE. DFD then makes a SHARPER 2PN
light-bending prediction (coefficient 4*pi = (16/15) x GR's 15pi/4) -- a future discriminator, not
yet measurable, so honestly a TIE now with a DFD edge pending. Honesty-guard: report the real numbers.
"""
import numpy as np

ARCSEC = 206264.806        # arcsec per radian
# Sun
m_sun = 1.476625          # GM_sun/c^2 in km
R_sun = 695700.0          # km

# PPN parameters
gGR, bGR = 1.0, 1.0
gDFD, bDFD = 1.0, 1.0      # DFD: optical metric n=e^psi -> gamma=beta=1 (corpus theorem)

print("="*72)
print("WIN-COLUMN #2 — GR classical gravity tests:  does DFD reproduce all four?")
print("="*72)
print(f"\n  PPN parameters:  GR (gamma,beta)=({gGR},{bGR})   DFD (gamma,beta)=({gDFD},{bDFD})  [corpus theorem]")

# (1) Mercury perihelion advance: factor (2+2gamma-beta)/3 x 42.98''/century
base_perih = 42.98
f = lambda g, b: (2 + 2*g - b)/3
print("\n  (1) Mercury perihelion (obs 42.98 +/- 0.04 ''/cy):")
print(f"        GR  = {f(gGR,bGR)*base_perih:.3f} ''/cy   DFD = {f(gDFD,bDFD)*base_perih:.3f} ''/cy   -> MATCH")

# (2) light deflection at solar limb: 1PN = (1+gamma)/2 x 4m/b
mb = m_sun/R_sun
defl1 = lambda g: (1+g)/2 * 4*mb*ARCSEC
print("\n  (2) Light deflection at solar limb (VLBI gamma-1=(-0.8+/-1.2)e-4):")
print(f"        GR  = {defl1(gGR):.4f}''   DFD = {defl1(gDFD):.4f}''   -> MATCH (1.75'')")

# (3) Shapiro delay scales as (1+gamma)/2 (Cassini gamma-1=(2.1+/-2.3)e-5)
print("\n  (3) Shapiro time delay (Cassini gamma-1=(2.1+/-2.3)e-5):")
print(f"        GR  factor={(1+gGR)/2:.4f}   DFD factor={(1+gDFD)/2:.4f}   -> MATCH")

# (4) GW speed: DFD predicts c_T=c (GW170817 |c_T/c-1|<~1e-15)
print("\n  (4) GW speed (GW170817: |c_T/c - 1| < 1e-15):")
print(f"        GR  c_T=c   DFD c_T=c (no extra tensor d.o.f.)   -> MATCH")

# 2PN light bending: DFD coeff 4pi vs GR 15pi/4  (ratio 16/15)
print("\n" + "-"*72)
print("  2PN light bending (the DFD SHARPER prediction):")
c2_GR, c2_DFD = 15*np.pi/4, 4*np.pi
d2 = lambda c2: c2*mb**2*ARCSEC*1e6   # micro-arcsec
print(f"        GR  coeff=15pi/4={c2_GR:.3f} -> {d2(c2_GR):.2f} uas   "
      f"DFD coeff=4pi={c2_DFD:.3f} -> {d2(c2_DFD):.2f} uas")
print(f"        ratio DFD/GR = {c2_DFD/c2_GR:.4f} (=16/15), difference = {d2(c2_DFD)-d2(c2_GR):.2f} uas")
print(f"        current 2PN solar-deflection precision: NOT yet sub-uas at the coefficient -> below test")

print("\n" + "="*72)
print("VERDICT: DFD has gamma=beta=1 (theorem-grade) -> reproduces ALL FOUR classic tests")
print("identically to GR at 1PN (perihelion, deflection, Shapiro, GW speed). GR's classical-tests")
print("win is therefore SHARED. DFD adds a falsifiable +6.7% (=16/15) 2PN bending prediction")
print("(~0.7 uas at the solar limb) -- a future discriminator, not yet measurable.")
print("GRADE: TIE now (DFD = GR on all four), with a DFD edge pending future astrometry.")
print("GR's classical-gravity-tests item -> no longer SOLELY GR's.")
