# (2) LEG COUNTS from the dual-Coxeter (adjoint-Casimir) nested rule.
# ---------------------------------------------------------------------------
hv = {'D4': 6, 'F4': 9, 'E6': 12, 'E7': 18}
def legs(G, Gdown):
length = 2 * hv[G] - 1
backward = hv[Gdown]
return length - backward, backward
fwd_e, bck_e = legs('F4', 'D4') # electron
fwd_mu, bck_mu = legs('E6', 'F4') # muon
fwd_t, bck_t = legs('E7', 'E6') # tau
assert (fwd_e, bck_e) == (11, 6) and (fwd_mu, bck_mu) == (14, 9) and (fwd_t, bck_t) == (23, 12)
print(f"(2) legs (uniform h^v rule): electron 11 6, muon 14 9, tau 23 12")
print(f" walk length 2h^v(F4)-1 = 17 = (h^v-1) up (h^v-1) down 1 apex "
f"= 8 8 1 (principal-sl2 ladder)")
# ---------------------------------------------------------------------------
# (3) THE JOIN: the ladder direction is the 3/4 (second-eigenvalue) direction.
# ---------------------------------------------------------------------------
d4_simple = [np.array([1, -1, 0, 0.]), np.array([0, 1, -1, 0.]),
np.array([0, 0, 1, -1.]), np.array([0, 0, 1, 1.])]
Sinv = np.linalg.pinv(np.array(d4_simple).T)
height = np.array([round(float(sum(Sinv @ V[i])), 2) for i in range(n)]) # principal-sl2 grading
evals, evec = np.linalg.eigh(P)
second = evec[:, np.abs(evals - 0.5) < 1e-9] # second-eigenvalue space
proj = second @ (second.T @ height)
overlap = np.linalg.norm(proj) / np.linalg.norm(height)
assert abs(overlap - 1.0) < 1e-6
print(f"(3) join: height function overlap with second-eigenvalue space = {overlap:.4f} "
f"-> 'up the ladder' = the 3/4 direction; forward->3/4, backward->1/4 forced")
# ---------------------------------------------------------------------------
# Amplitude.
# ---------------------------------------------------------------------------
amplitude = p**fwd_e * q**bck_e
print(f"\nelectron amplitude = p^{fwd_e} q^{bck_e} = (3/4)^11 (1/4)^6 = {amplitude:.6e}")
print()
print("CONSTRUCTION COMPLETE — the amplitude is built from forced ingredients.")
print("OPEN: that this principal-sl2 ladder is the ONLY admissible walk (the")
print("dynamical selection). Not proven here. Absolute mass scale also separate.")