TensorPattern
symbolica.community.tensor Class
TensorPattern(head: TensorName, *, args: Sequence[_ScalarInput] = [], ports: Sequence[Slot | Representation | _ScalarInput] = []) Representation-aware Symbolica patterns for matching tensor expressions.
Scalar arguments and structural ports are specified separately. Either section can contain Symbolica wildcards, including sequence wildcards. Unlike TensorExpression, a pattern does not require a concrete rank or compatible external tensor axes. Use patterns with TensorRule for checked whole-tensor replacements, or with ordinary Expression matching.
Examples
from symbolica import S
from symbolica.community.tensor import TensorPattern, PortPattern, Representation, TensorName
D_, i_, j_, mu_, nu_, a_, b_, c_ = S("D_", "i_", "j_", "mu_", "nu_", "a_", "b_", "c_")
pattern = TensorPattern.dirac_gamma(D_, i_, j_, mu_)Constructor
#Match a fixed tensor function with separately specified arguments and ports.
Returns
TensorPattern
Pattern expression with args before ports.
Examples
from symbolica import S
from symbolica.community.tensor import TensorPattern, PortPattern, Representation, TensorName
D_, i_, j_, mu_, nu_, a_, b_, c_ = S("D_", "i_", "j_", "mu_", "nu_", "a_", "b_", "c_")
pattern = TensorPattern(TensorName("B"), ports=[PortPattern.exact(Representation.euc(3), i_)])Parameters
| Name | Type | Default | Description |
|---|---|---|---|
head | TensorName | — | Exact tensor function head to match. |
args | Sequence[ | [] | Non-index tensor arguments, including ordinary or sequence wildcards. |
ports | Sequence[ | [] | Structural port patterns, placed after args. PortPattern and sequence wildcards can describe representations, indices, or variable arity. |
Member details
any
Static method#any(name: str, *, args: Sequence[_ScalarInput] = [], ports: Sequence[Slot | Representation | _ScalarInput] = []) -> TensorPattern Match any tensor-tagged function.
Returns
TensorPattern
Tagged pattern. Concrete arity is not imposed, so sequence wildcards can match the argument and port lists.
Examples
from symbolica import S
from symbolica.community.tensor import TensorPattern, PortPattern, Representation, TensorName
D_, i_, j_, mu_, nu_, a_, b_, c_ = S("D_", "i_", "j_", "mu_", "nu_", "a_", "b_", "c_")
rest = S("ports___")
pattern = TensorPattern.any("T_", ports=[rest])Parameters
| Name | Type | Default | Description |
|---|---|---|---|
name | str | — | Wildcard function name ending in exactly one underscore. |
args | Sequence[ | [] | Non-index tensor arguments, including ordinary or sequence wildcards. |
ports | Sequence[ | [] | Structural port patterns, placed after args. PortPattern and sequence wildcards can describe representations, indices, or variable arity. |
vector
Static method#vector(name: str, *, args: Sequence[_ScalarInput] = [], ports: Sequence[Slot | Representation | _ScalarInput] = []) -> TensorPattern Match a function tagged as a rank-one tensor.
Returns
TensorPattern
Tagged pattern. Concrete arity is not imposed, so sequence wildcards can match the argument and port lists.
Examples
from symbolica import S
from symbolica.community.tensor import TensorPattern, PortPattern, Representation, TensorName
D_, i_, j_, mu_, nu_, a_, b_, c_ = S("D_", "i_", "j_", "mu_", "nu_", "a_", "b_", "c_")
rest = S("ports___")
pattern = TensorPattern.vector("V_", ports=[rest])Parameters
| Name | Type | Default | Description |
|---|---|---|---|
name | str | — | Wildcard function name ending in exactly one underscore. |
args | Sequence[ | [] | Non-index tensor arguments, including ordinary or sequence wildcards. |
ports | Sequence[ | [] | Structural port patterns, placed after args. PortPattern and sequence wildcards can describe representations, indices, or variable arity. |
dot
Static method#dot(left: _ScalarInput, right: _ScalarInput) -> TensorPattern Match a compact tensor dot product.
Returns
TensorPattern
Pattern for the compact dot notation, not explicit indexed products.
Examples
from symbolica import S
from symbolica.community.tensor import TensorPattern, PortPattern, Representation, TensorName
D_, i_, j_, mu_, nu_, a_, b_, c_ = S("D_", "i_", "j_", "mu_", "nu_", "a_", "b_", "c_")
pattern = TensorPattern.dot(S("left_"), S("right_"))Parameters
| Name | Type | Default | Description |
|---|---|---|---|
left | _ScalarInput | — | Operand patterns, including unrestricted wildcards. |
right | _ScalarInput | — | Operand patterns, including unrestricted wildcards. |
chain
Static method#chain(start: Slot | Representation | _ScalarInput, end: Slot | Representation | _ScalarInput, *factors: _ScalarInput) -> TensorPattern Match an ordered tensor chain with endpoints and factor patterns.
Returns
TensorPattern
A chain pattern that does not infer a concrete matrix interface.
Examples
from symbolica import S
from symbolica.community.tensor import TensorPattern, PortPattern, Representation, TensorName
D_, i_, j_, mu_, nu_, a_, b_, c_ = S("D_", "i_", "j_", "mu_", "nu_", "a_", "b_", "c_")
pattern = TensorPattern.chain(i_, j_, S("factors___"))Parameters
| Name | Type | Default | Description |
|---|---|---|---|
start | Slot | Representation | _ScalarInput | — | Endpoint patterns. |
end | Slot | Representation | _ScalarInput | — | Endpoint patterns. |
factors | _ScalarInput | — | — |
trace
Static method#trace(representation: Representation | Expression, *factors: _ScalarInput) -> TensorPattern Match a compact cyclic trace.
Returns
TensorPattern
Trace pattern with the cyclic factor wrapper used by tensor notation.
Examples
from symbolica import S
from symbolica.community.tensor import TensorPattern, PortPattern, Representation, TensorName
D_, i_, j_, mu_, nu_, a_, b_, c_ = S("D_", "i_", "j_", "mu_", "nu_", "a_", "b_", "c_")
pattern = TensorPattern.trace(Representation.euc(3), S("factors___"))Parameters
| Name | Type | Default | Description |
|---|---|---|---|
representation | Representation | Expression | — | Exact traced space, representation pattern, or wildcard. |
factors | _ScalarInput | — | — |
casimir
Static method#casimir(degree: _ScalarInput, representation: Representation | Expression) -> TensorPattern Match a symbolic Casimir invariant.
Returns
TensorPattern
Pattern for a scalar representation invariant.
Examples
from symbolica import S
from symbolica.community.tensor import TensorPattern, PortPattern, Representation, TensorName
D_, i_, j_, mu_, nu_, a_, b_, c_ = S("D_", "i_", "j_", "mu_", "nu_", "a_", "b_", "c_")
pattern = TensorPattern.casimir(S("degree_"), S("rep_"))Parameters
| Name | Type | Default | Description |
|---|---|---|---|
degree | _ScalarInput | — | Invariant degree or wildcard. |
representation | Representation | Expression | — | Exact representation, representation pattern, or wildcard. |
dynkin_index
Static method#dynkin_index(degree: _ScalarInput, representation: Representation | Expression) -> TensorPattern Match a symbolic Dynkin index.
Returns
TensorPattern
Pattern for a scalar representation invariant.
Examples
from symbolica import S
from symbolica.community.tensor import TensorPattern, PortPattern, Representation, TensorName
D_, i_, j_, mu_, nu_, a_, b_, c_ = S("D_", "i_", "j_", "mu_", "nu_", "a_", "b_", "c_")
pattern = TensorPattern.dynkin_index(S("degree_"), S("rep_"))Parameters
| Name | Type | Default | Description |
|---|---|---|---|
degree | _ScalarInput | — | Invariant degree or wildcard. |
representation | Representation | Expression | — | Exact representation, representation pattern, or wildcard. |
symmetric
Static method#symmetric(*factors: _ScalarInput) -> TensorPatternMatch a normalized symmetric group of matrix factors.
Returns
TensorPattern
Pattern for the compact FactorProjector syntax inside a chain or trace.
Examples
from symbolica import S
from symbolica.community.tensor import TensorPattern, PortPattern, Representation, TensorName
D_, i_, j_, mu_, nu_, a_, b_, c_ = S("D_", "i_", "j_", "mu_", "nu_", "a_", "b_", "c_")
pattern = TensorPattern.symmetric(S("factors___"))Parameters
| Name | Type | Default | Description |
|---|---|---|---|
factors | _ScalarInput | — | — |
antisymmetric
Static method#antisymmetric(*factors: _ScalarInput) -> TensorPatternMatch a normalized antisymmetric group of matrix factors.
Returns
TensorPattern
Pattern for the compact FactorProjector syntax inside a chain or trace.
Examples
from symbolica import S
from symbolica.community.tensor import TensorPattern, PortPattern, Representation, TensorName
D_, i_, j_, mu_, nu_, a_, b_, c_ = S("D_", "i_", "j_", "mu_", "nu_", "a_", "b_", "c_")
pattern = TensorPattern.antisymmetric(S("factors___"))Parameters
| Name | Type | Default | Description |
|---|---|---|---|
factors | _ScalarInput | — | — |
cyclic
Static method#cyclic(*factors: _ScalarInput) -> TensorPatternMatch a normalized cyclic group of matrix factors.
Returns
TensorPattern
Pattern for the compact FactorProjector syntax inside a chain or trace.
Examples
from symbolica import S
from symbolica.community.tensor import TensorPattern, PortPattern, Representation, TensorName
D_, i_, j_, mu_, nu_, a_, b_, c_ = S("D_", "i_", "j_", "mu_", "nu_", "a_", "b_", "c_")
pattern = TensorPattern.cyclic(S("factors___"))Parameters
| Name | Type | Default | Description |
|---|---|---|---|
factors | _ScalarInput | — | — |
gamma0
Static method#gamma0(spinor_dimension: _ScalarInput, i: _ScalarInput, j: _ScalarInput) -> TensorPattern Match the time-component Dirac matrix gamma^0.
Returns
TensorPattern
Registered tensor syntax with representation-aware port patterns. Wildcards are retained rather than checked as a concrete tensor.
Examples
from symbolica import S
from symbolica.community.tensor import TensorPattern, PortPattern, Representation, TensorName
D_, i_, j_, mu_, nu_, a_, b_, c_ = S("D_", "i_", "j_", "mu_", "nu_", "a_", "b_", "c_")
pattern = TensorPattern.gamma0(D_, i_, j_)Parameters
charge_conjugation
Static method#charge_conjugation(spinor_dimension: _ScalarInput, i: _ScalarInput, j: _ScalarInput) -> TensorPattern Match the Dirac charge-conjugation matrix.
Returns
TensorPattern
Registered tensor syntax with representation-aware port patterns. Wildcards are retained rather than checked as a concrete tensor.
Examples
from symbolica import S
from symbolica.community.tensor import TensorPattern, PortPattern, Representation, TensorName
D_, i_, j_, mu_, nu_, a_, b_, c_ = S("D_", "i_", "j_", "mu_", "nu_", "a_", "b_", "c_")
pattern = TensorPattern.charge_conjugation(D_, i_, j_)Parameters
levi_civita
Static method#levi_civita(rep_pattern: Representation | Expression, *indices: _ScalarInput) -> TensorPattern Match the totally antisymmetric Levi-Civita tensor.
Returns
TensorPattern
Registered tensor syntax with representation-aware port patterns. Wildcards are retained rather than checked as a concrete tensor.
Notes
For an unrestricted number of epsilon axes, use TensorPattern(TensorName.levi_civita(), ports=[ports___]).
Examples
from symbolica import S
from symbolica.community.tensor import TensorPattern, PortPattern, Representation, TensorName
D_, i_, j_, mu_, nu_, a_, b_, c_ = S("D_", "i_", "j_", "mu_", "nu_", "a_", "b_", "c_")
pattern = TensorPattern.levi_civita(Representation.euc(D_), i_, j_, a_)Parameters
| Name | Type | Default | Description |
|---|---|---|---|
rep_pattern | Representation | Expression | — | Exact space or a representation-only PortPattern. |
indices | _ScalarInput | — | — |
g
Static method#g(rep_pattern: Representation | Expression, i: _ScalarInput, j: _ScalarInput) -> TensorPattern Match the metric pairing.
Returns
TensorPattern
Registered tensor syntax with representation-aware port patterns. Wildcards are retained rather than checked as a concrete tensor.
Examples
from symbolica import S
from symbolica.community.tensor import TensorPattern, PortPattern, Representation, TensorName
D_, i_, j_, mu_, nu_, a_, b_, c_ = S("D_", "i_", "j_", "mu_", "nu_", "a_", "b_", "c_")
pattern = TensorPattern.g(Representation.euc(D_), i_, j_)Parameters
| Name | Type | Default | Description |
|---|---|---|---|
rep_pattern | Representation | Expression | — | Exact space or a representation-only PortPattern. |
i | _ScalarInput | — | Index values, wildcards, or contextual chain endpoints. |
j | _ScalarInput | — | Index values, wildcards, or contextual chain endpoints. |
flat
Static method#flat(rep_pattern: Representation | Expression, i: _ScalarInput, j: _ScalarInput) -> TensorPattern Match the metric map for raising or lowering an index.
Returns
TensorPattern
Registered tensor syntax with representation-aware port patterns. Wildcards are retained rather than checked as a concrete tensor.
Examples
from symbolica import S
from symbolica.community.tensor import TensorPattern, PortPattern, Representation, TensorName
D_, i_, j_, mu_, nu_, a_, b_, c_ = S("D_", "i_", "j_", "mu_", "nu_", "a_", "b_", "c_")
pattern = TensorPattern.flat(Representation.euc(D_), i_, j_)Parameters
| Name | Type | Default | Description |
|---|---|---|---|
rep_pattern | Representation | Expression | — | Exact space or a representation-only PortPattern. |
i | _ScalarInput | — | Index values, wildcards, or contextual chain endpoints. |
j | _ScalarInput | — | Index values, wildcards, or contextual chain endpoints. |
dirac_gamma
Static method#dirac_gamma(minkowski_dimension: _ScalarInput, i: _ScalarInput, j: _ScalarInput, mu: _ScalarInput) -> TensorPattern Match the Dirac gamma matrices for Clifford algebra.
Returns
TensorPattern
Registered tensor syntax with representation-aware port patterns. Wildcards are retained rather than checked as a concrete tensor.
Examples
from symbolica import S
from symbolica.community.tensor import TensorPattern, PortPattern, Representation, TensorName
D_, i_, j_, mu_, nu_, a_, b_, c_ = S("D_", "i_", "j_", "mu_", "nu_", "a_", "b_", "c_")
pattern = TensorPattern.dirac_gamma(D_, i_, j_, mu_)Parameters
gamma5
Static method#gamma5(spinor_dimension: _ScalarInput, i: _ScalarInput, j: _ScalarInput) -> TensorPattern Match the Dirac chirality matrix gamma^5.
Returns
TensorPattern
Registered tensor syntax with representation-aware port patterns. Wildcards are retained rather than checked as a concrete tensor.
Examples
from symbolica import S
from symbolica.community.tensor import TensorPattern, PortPattern, Representation, TensorName
D_, i_, j_, mu_, nu_, a_, b_, c_ = S("D_", "i_", "j_", "mu_", "nu_", "a_", "b_", "c_")
pattern = TensorPattern.gamma5(D_, i_, j_)Parameters
projm
Static method#projm(spinor_dimension: _ScalarInput, i: _ScalarInput, j: _ScalarInput) -> TensorPattern Match the left-chiral Dirac projector (I - gamma^5)/2.
Returns
TensorPattern
Registered tensor syntax with representation-aware port patterns. Wildcards are retained rather than checked as a concrete tensor.
Examples
from symbolica import S
from symbolica.community.tensor import TensorPattern, PortPattern, Representation, TensorName
D_, i_, j_, mu_, nu_, a_, b_, c_ = S("D_", "i_", "j_", "mu_", "nu_", "a_", "b_", "c_")
pattern = TensorPattern.projm(D_, i_, j_)Parameters
projp
Static method#projp(spinor_dimension: _ScalarInput, i: _ScalarInput, j: _ScalarInput) -> TensorPattern Match the right-chiral Dirac projector (I + gamma^5)/2.
Returns
TensorPattern
Registered tensor syntax with representation-aware port patterns. Wildcards are retained rather than checked as a concrete tensor.
Examples
from symbolica import S
from symbolica.community.tensor import TensorPattern, PortPattern, Representation, TensorName
D_, i_, j_, mu_, nu_, a_, b_, c_ = S("D_", "i_", "j_", "mu_", "nu_", "a_", "b_", "c_")
pattern = TensorPattern.projp(D_, i_, j_)Parameters
sigma
Static method#sigma(minkowski_dimension: _ScalarInput, mu: _ScalarInput, nu: _ScalarInput, i: _ScalarInput, j: _ScalarInput) -> TensorPattern Match the antisymmetric Dirac sigma tensor.
Returns
TensorPattern
Registered tensor syntax with representation-aware port patterns. Wildcards are retained rather than checked as a concrete tensor.
Examples
from symbolica import S
from symbolica.community.tensor import TensorPattern, PortPattern, Representation, TensorName
D_, i_, j_, mu_, nu_, a_, b_, c_ = S("D_", "i_", "j_", "mu_", "nu_", "a_", "b_", "c_")
pattern = TensorPattern.sigma(D_, mu_, nu_, i_, j_)Parameters
| Name | Type | Default | Description |
|---|---|---|---|
minkowski_dimension | _ScalarInput | — | Minkowski dimension or wildcard. Spinor dimensions are fixed at four. |
mu | _ScalarInput | — | Lorentz-index patterns. |
nu | _ScalarInput | — | Lorentz-index patterns. |
i | _ScalarInput | — | Spinor-index patterns or contextual chain endpoints. |
j | _ScalarInput | — | Spinor-index patterns or contextual chain endpoints. |
color_f
Static method#color_f(adjoint_dimension: _ScalarInput, a: _ScalarInput, b: _ScalarInput, c: _ScalarInput) -> TensorPattern Match the antisymmetric color structure constants f^{abc}.
Returns
TensorPattern
Registered tensor syntax with representation-aware port patterns. Wildcards are retained rather than checked as a concrete tensor.
Examples
from symbolica import S
from symbolica.community.tensor import TensorPattern, PortPattern, Representation, TensorName
D_, i_, j_, mu_, nu_, a_, b_, c_ = S("D_", "i_", "j_", "mu_", "nu_", "a_", "b_", "c_")
pattern = TensorPattern.color_f(D_, a_, b_, c_)Parameters
| Name | Type | Default | Description |
|---|---|---|---|
adjoint_dimension | _ScalarInput | — | Adjoint dimension or wildcard, e.g. 8 for SU(3). |
a | _ScalarInput | — | Patterns for the three adjoint indices. |
b | _ScalarInput | — | Patterns for the three adjoint indices. |
c | _ScalarInput | — | Patterns for the three adjoint indices. |
color_t
Static method#color_t(adjoint_dimension: _ScalarInput, fundamental_dimension: _ScalarInput, a: _ScalarInput, i: _ScalarInput, j: _ScalarInput) -> TensorPattern Match the fundamental color generators T^a.
Returns
TensorPattern
Registered tensor syntax with representation-aware port patterns. Wildcards are retained rather than checked as a concrete tensor.
Examples
from symbolica import S
from symbolica.community.tensor import TensorPattern, PortPattern, Representation, TensorName
D_, i_, j_, mu_, nu_, a_, b_, c_ = S("D_", "i_", "j_", "mu_", "nu_", "a_", "b_", "c_")
pattern = TensorPattern.color_t(D_, S("N_"), a_, i_, j_)Parameters
| Name | Type | Default | Description |
|---|---|---|---|
adjoint_dimension | _ScalarInput | — | Adjoint dimension or wildcard, e.g. 8 for SU(3). |
fundamental_dimension | _ScalarInput | — | Fundamental dimension or wildcard, e.g. 3 for SU(3). |
a | _ScalarInput | — | Adjoint-index pattern. |
i | _ScalarInput | — | Fundamental and antifundamental index patterns, or contextual endpoints. |
j | _ScalarInput | — | Fundamental and antifundamental index patterns, or contextual endpoints. |
View generated signature source: docs/api/python/spynso3.pyi:9730