TensorReducer
symbolica.community.hepkit Class
TensorReducer(dimension: Expression, *, integrated: Sequence[symbolica.community.tensor.TensorName | symbolica.Expression | symbolica.community.tensor.TensorExpression] = (), external: Sequence[symbolica.Expression | symbolica.community.tensor.TensorExpression] = ()) Project Lorentz-tensor integrands onto Spenso invariants.
The reducer implements the symmetry-orbit form of the orthogonal Weingarten projector. Repeated loop and projector momenta are kept in compact contraction classes, making the common rank-20 vacuum projections practical without constructing the full 19!! pairing matrix. Fully contracted projectors yield scalar spenso::dot invariants. If projector indices remain free, the returned expression retains them as explicit spenso::g tensors. Keep mixed high-rank reductions symbolic in D until afterward: at fixed positive integer dimension below half the rank, dimension-specific identities make the universal metric basis singular. The all-equal isotropic fast path remains well defined. For denominators depending on external momenta, add an independent basis with the external constructor keyword. Only the transverse components are then rotationally averaged; odd total ranks need not vanish.
Examples
Average a rank-two vacuum numerator over the loop direction. The result is proportional to the metric tensor times k.k / D.
from symbolica import S, E
from symbolica.community import hepkit as hep
from symbolica.community.tensor import TensorName, Representation, PortPattern, TensorPattern
D, mu, nu = S("D", "mu", "nu")
k, p = (TensorName.vector("hep_reducer_docs::" + name).to_expression() for name in ("k", "p"))
lorentz = Representation.mink(D)
reducer = hep.TensorReducer(D, integrated=[k(PortPattern.exact(lorentz))])
numerator = k(PortPattern.exact(lorentz, mu)) * k(PortPattern.exact(lorentz, nu))
projected = reducer.reduce(numerator)Parameters
dimensionExpressionLorentz-space dimension, commonly
Dor4 - 2*eps.
Constructor
#Configure the integrated momenta and independent external basis.
Bare symbols and TensorName entries in integrated select every vector with that head. Compact vector expressions select one exact momentum, including its scalar arguments. External entries are compact vectors and take precedence over integrated-head selections.
Examples
Using the setup in the TensorReducer class example:
reducer = hep.TensorReducer(D, integrated=[k])
reducer = hep.TensorReducer(D, integrated=[k(PortPattern.exact(lorentz))], external=[p(PortPattern.exact(lorentz))])Parameters
| Name | Type | Default | Description |
|---|---|---|---|
dimension | Expression | — | Lorentz-space dimension used by every |
integrated | Sequence[ | () | Whole vector heads or exact compact vectors to integrate. |
external | Sequence[ | () | Independent compact vectors in the denominator's external basis. |
Member details
dimension
Property · read-only#dimension: ExpressionReturn the configured Lorentz-space dimension.
Examples
Using the setup in the TensorReducer class example:
assert reducer.dimension == Dfeynkit
Static method#feynkit(dimension: Expression) -> TensorReducerConstruct a reducer that selects every gammalooprs::Q tensor.
This is the convenient constructor for vacuum numerators produced by HEP native Feynman-rule generator. It selects the entire gammalooprs::Q head and is therefore intended for pure vacuum numerators, where every such momentum is integrated. If a graph still contains external gammalooprs::Q tensors, construct a reducer with exact compact vectors in integrated for its internal momenta instead.
Examples
The equivalent explicit selector shows which momentum head is integrated:
from symbolica import S, E
from symbolica.community import hepkit as hep
model = hep.Model.phi4()
vacuum_diagram = model.process([], []).generate_diagrams(loops=2, factorized_loop_topologies_count_range=None).diagrams[0]
reducer = hep.TensorReducer(E("4"), integrated=[E("gammalooprs::Q")])
reduced = reducer.reduce(vacuum_diagram.numerator_expression().to_expression())Parameters
| Name | Type | Default | Description |
|---|---|---|---|
dimension | Expression | — | Lorentz-space dimension used by every |
with_pairing_limit
Method#with_pairing_limit(limit: int) -> TensorReducerSet the labeled-pairing budget for unsymmetrized or free-index output.
Symmetric contraction-orbit paths do not consume this budget.
Examples
Using the setup in the TensorReducer class example:
reducer = reducer.with_pairing_limit(200_000)Parameters
| Name | Type | Default | Description |
|---|---|---|---|
limit | int | — | Maximum number of labeled perfect matchings to enumerate. |
with_pairing_product_limit
Method#with_pairing_product_limit(limit: int) -> TensorReducerSet the relative-pairing budget for residual free-index output.
Examples
Using the setup in the TensorReducer class example:
reducer = reducer.with_pairing_product_limit(150_000_000)Parameters
| Name | Type | Default | Description |
|---|---|---|---|
limit | int | — | Maximum Cartesian product of internal and projector matchings. |
with_output_term_limit
Method#with_output_term_limit(limit: int) -> TensorReducerSet the maximum number of distinct invariant output terms.
Examples
Using the setup in the TensorReducer class example:
reducer = reducer.with_output_term_limit(20_000)Parameters
| Name | Type | Default | Description |
|---|---|---|---|
limit | int | — | Maximum compact contraction classes to materialize. |
reduce
Method#reduce(expression: symbolica.Expression | symbolica.community.tensor.TensorExpression) -> TensorExpression Reduce a numerator to a TensorExpression with its ordered interface.
Rank-one tensors must carry a final spenso::mink(D,index) argument. Fully contracted projectors are returned as scalar spenso::dot invariants. Residual free projector pairs remain explicit spenso::g tensors; this method intentionally does not reject tensor-valued output. Compact dots between an integrated vector and a spectator are reduced directly, including nonnegative integer powers. Dots between integrated vectors or with declared external basis vectors remain scalar invariants. Negative or noninteger powers of spectator contractions are rejected. Odd-rank vacuum tensors vanish while retaining their output interface.
Examples
Using the setup in the TensorReducer class example:
A rank-two vacuum projection becomes a product of dot products divided by the dimension:
from symbolica import S
from symbolica.community import hepkit as hep
D, mu, nu = S("hep_docs::D", "hep_docs::mu", "hep_docs::nu")
from symbolica.community.tensor import TensorName, Representation, PortPattern, TensorPattern
k, p = (TensorName.vector("hep_reducer_docs::" + name).to_expression() for name in ("k", "p"))
lorentz, dot = Representation.mink(D), TensorPattern.dot
k_compact = k(PortPattern.exact(lorentz))
p_compact = p(PortPattern.exact(lorentz))
numerator = (
k(PortPattern.exact(lorentz, mu)) * k(PortPattern.exact(lorentz, nu))
* p(PortPattern.exact(lorentz, mu)) * p(PortPattern.exact(lorentz, nu))
)
reducer = hep.TensorReducer(D, integrated=[k_compact])
reduced = reducer.reduce(numerator)
expected = dot(k_compact, k_compact) * dot(p_compact, p_compact) / D
assert reduced.rank == 0 and reduced.axes == ()
assert reduced.to_expression() == expectedParameters
| Name | Type | Default | Description |
|---|---|---|---|
expression | symbolica. | — | Tensor numerator or projected tensor numerator to reduce. |
__repr__
Method#__repr__() -> strReturn a concise description of the reducer configuration.
Examples
Using the setup in the TensorReducer class example:
print(reducer)_repr_pretty_
Method#_repr_pretty_(pretty: Any, cycle: bool) -> None Write the reducer summary to an IPython pretty printer.
Examples
Using the setup in the TensorReducer class example:
from IPython.lib.pretty import pretty
text = pretty(reducer)Parameters
| Name | Type | Default | Description |
|---|---|---|---|
pretty | Any | — | The IPython pretty-printer object. |
cycle | bool | — | Whether this object is part of a recursive formatting cycle. |
View generated signature source: docs/api/python/feynkit-community.pyi:11114