"""v174 -- Seam Fock-space readings: the CAR cone compression, the Witten-index
origin of the quark Plucker norm 11, and the Affleck-Ludwig g-theorem rigidity.

Three exact audit bridges from the problem_b note that give already-used objects a
sharper QFT/topological reading. None is new physics; each is an exact identity
plus an honest reading.

  [I] 1. CAR CONE COMPRESSION ("the QFT cone is large, but not independent").
         The even CAR algebra of the 16 seam Majoranas has
         dim Lambda^even(R^16) = 2^15 = 32768 directions, with big
         connected-cumulant blocks C(16,4)=1820, C(16,6)=8008, C(16,8)=12870.
         But a quasi-free Bogoliubov transport is the second quantisation
         Gamma(t) of a 16-dim one-particle operator, Gamma(t)|_{Lambda^m}=Lambda^m(t),
         so the whole cone is generated by the 16-dim one-particle spectrum --
         compression 2^15/16 = 2048 = 2^11. (The explicit count behind v161.)
  [I] 2. WITTEN INDEX = THE PLUCKER NORM 11.  The mu4-corner fermions span a
         Fock space of dimension 2^{|mu4|} = 2^4 = 16 = dim S^+. Quadratic
         Boundary Locality (QBL, degree <= 2) truncates it to
         sum_{k<=2} C(4,k) = 1+4+6 = 11 = the Plucker norm ||Pl(K)||_1 (v42); the
         discarded high-degree complement is C(4,3)+C(4,4) = 5 = g_car, so
         11 = dim S^+ - g_car. Hence the quark ratio
         c_u/c_d = g_car * 11 / (N_fam^2 * Delta_Q) = 55/117 reads the dimension of
         the QBL-protected boundary state space (a topological Witten index), not a
         free integer.
  [I]/[L] 3. AFFLECK-LUDWIG g-THEOREM RIGIDITY.  The UV carrier data have central
         charge c_UV = c((D5)_1) + c((A3)_1) = 5+3 = 8, and the IR seam net is
         (E8)_1 with c_IR = 8, so Delta c = 0 along the seam boundary RG flow. By
         the c-/g-theorem a flow needs Delta c > 0 to dissipate; Delta c = 0 forces
         an exact isometry -- no relevant or marginal perturbation can turn on.
         This is the boundary-entropy form of the v157/v158 rigid-fixed-point
         statement: the seam vacuum is frozen by central-charge conservation.

Status [I]/[L] (exact integer/central-charge identities); the readings are audit.
Exact; mirrored on the Wolfram path.
"""
import math

from tfpt_constants import check, summary, reset, g_car, N_fam, dim_Splus

DELTA_Q = 13          # Delta_Q = p0 + p3 = N_fam + A_Lambda


def run():
    reset()
    print("v174 seam Fock-space readings (CAR cone, Witten index 11, g-theorem)")

    # 1. CAR cone compression
    cone = 2**15
    blocks = (math.comb(16, 4), math.comb(16, 6), math.comb(16, 8))
    comp = cone // 16
    check("CAR CONE COMPRESSION: dim Lambda^even(R^16) = 2^15 = 32768 with "
          "cumulant blocks C(16,4)=1820, C(16,6)=8008, C(16,8)=12870; quasi-free "
          "Bogoliubov Gamma(t)|_Lambda^m = Lambda^m(t) reduces the whole cone to a "
          "16-dim one-particle problem -- compression 2^15/16 = 2048 = 2^11 (the "
          "explicit form of v161)",
          cone == 32768 and blocks == (1820, 8008, 12870)
          and comp == 2048 == 2**11, exact=True)

    # 2. Witten index = Plucker norm 11
    full = 2**4
    trunc = sum(math.comb(4, k) for k in range(3))          # 1+4+6 = 11
    discarded = sum(math.comb(4, k) for k in range(3, 5))   # 4+1 = 5
    cu_cd = (g_car * trunc, N_fam**2 * DELTA_Q)              # (55, 117)
    check("WITTEN INDEX = PLUCKER NORM 11: the 4 mu4-corner fermions have a "
          "2^4 = 16 = dim S^+ Fock space; QBL (degree <= 2) keeps "
          "sum_{k<=2} C(4,k) = 1+4+6 = 11 = ||Pl(K)||_1, discards "
          "C(4,3)+C(4,4) = 5 = g_car, so 11 = dim S^+ - g_car; the quark ratio "
          "c_u/c_d = g_car*11/(N_fam^2*Delta_Q) = 55/117 reads this topological "
          "state-space dimension",
          full == 16 == dim_Splus and trunc == 11 and discarded == g_car == 5
          and trunc + discarded == dim_Splus
          and cu_cd == (55, 117), exact=True)

    # 3. Affleck-Ludwig g-theorem rigidity
    c_uv = 5 + 3
    c_ir = 8                                                # (E8)_1
    check("AFFLECK-LUDWIG g-THEOREM RIGIDITY: c_UV = c((D5)1)+c((A3)1) = 5+3 = 8 "
          "= c_IR((E8)1), so Delta c = 0 along the seam boundary RG flow; a flow "
          "needs Delta c > 0 to dissipate, so Delta c = 0 forces an exact isometry "
          "-- no relevant/marginal perturbation can turn on (the boundary-entropy "
          "form of the v157/v158 rigid fixed point)",
          c_uv == 8 and c_ir == 8 and (c_uv - c_ir) == 0, exact=True)

    return summary("v174 seam Fock-space readings")


if __name__ == "__main__":
    raise SystemExit(1 if run() else 0)
