feynlag.pheno.lorentz

Covariant Dirac-trace engine for squared amplitudes.

The computation path is manifestly covariant: traces are evaluated with SymPy’s own Clifford-algebra engine (sympy.physics.hep.gamma_matrices, which ships with SymPy — no new dependency), producing Lorentz-invariant contractions that are reduced to on-shell dot products p_i·p_j at the very end. Explicit 4×4 Dirac matrices are deliberately not on this path; they appear only as the independent test oracle (tests/test_pheno.py).

SymPy’s engine does not cover three things this module needs, all handled here:

  1. Mass terms. gamma_trace chokes on p̸ + m: the sum is a TensAdd whose scalar argument has no .sorted_components(). dirac_trace() splits the scalar (identity) pieces off and applies Tr[c·I₄] = 4c to them directly.

  2. γ₅ / chiral projectors. SymPy has no G5, so P_L/P_R cannot be represented at all. reduce_projectors() implements the projector algebra and reduces any chain to a γ₅-free trace times a factor — see that function for the derivation and the precondition it enforces. Which projector a vertex carries is decided upstream by classify_gamma().

  3. Reduction to scalars. TensExpr.replace_with_arrays raises ValueError on contracted dummy indices (SymPy 1.14), so contract_to_dots() walks the tensor structure directly.

Functions

contract_to_dots(expr, dot)

Reduce a fully contracted tensor expression to a plain scalar.

dirac_trace(expr)

Trace of a Dirac chain, tolerating scalar (identity) pieces.

index(name)

A (cached) Lorentz TensorIndex called name.

momentum(name)

The (cached) rank-1 TensorHead for a momentum called name.

reduce_projectors(expr, chirality[, ...])

Reduce a chiral chain to a γ₅-free trace times a scalar factor.

slashed(p, dummy)

p̸ = p_μ γ^μ for the momentum head p, summed over dummy.