feynlag.pheno.contraction

Scalar-level reduction of fully contracted Dirac traces.

A spin-summed |M|² is a Dirac trace whose Lorentz indices are all contracted — with each other, with a metric, or with a momentum. This module reduces such an object straight to dot products, without building a SymPy tensor expression:

  1. _expand_chiral_string() multiplies out spin sums, propagator numerators and chiral vertices, pushing every projector to the right end;

  2. _contract_pairs() removes each contracted γ^ρ … γ_ρ pair with the four-dimensional contraction identities;

  3. _slash_trace() evaluates the remaining trace of slashed momenta.

contract_trace() adds the step in front that the external-boson processes of Tier 4 need: a trace multiplied by loose tensors — metrics and momentum vectors carrying the same index names as γ’s inside the trace (a polarization sum −g_{μμ'} + k_μk_{μ'}/m², a triple-gauge vertex g^{μν}(p₁−p₂)^ρ + …). They are eliminated by renaming (a metric identifies its two indices; a vector meeting a γ becomes a slash; two vectors become a dot product), after which every index sits on a contracted γ pair and steps 1–3 apply.

Why not SymPy’s tensor engine: gamma_trace (SymPy 1.14) returns a wrong result for a string that slashes one momentum twice (Tr[q̸γ^a p̸p̸γ^b q̸]g_ab comes out 72p²q², not 16p²q²), and kahane_simplify raises on interleaved contractions. A squared fermion-exchange diagram has both. Everything here is plain SymPy scalars.

The γ₅ coefficients are computed by step 1 and then discarded by _scalar_trace() — the caller must have proven the γ₅ part zero (for a fully contracted 2→2 trace: three independent momenta cannot fill an ε tensor, assert_epsilon_single_vanishes()).

Index conventions. Steps 1–3 take a contracted pair as two ('i', x) atoms with x and -x (a SymPy TensorIndex, or an Ix). contract_trace() takes plain hashable names (strings), each appearing exactly twice, and assigns the up/down pair itself.

Functions

contract_tensors(tensors, dot)

∏ tensors, fully contracted, as a scalar — contract_trace() without a Dirac trace (a pure-boson |M|², Tier 5 stage 5c).

contract_trace(factors, tensors, dot[, memo])

Tr[factors] × ∏ tensors, fully contracted, as a scalar (γ₅-free part — see the module docstring).

Classes

Ix(name[, up])

A Lorentz index for the scalar route: -Ix(n) is its lowered partner, which is all _contract_pairs() asks of an index.