Representation

Symbolica documentation for getting started, symbolic expressions, numerical evaluation, pattern matching, and APIs in Python and Rust.

Representation

class Representation

An index space with a dimension and a rule for pairing indices.

Use representations to distinguish axes that have the same size but different mathematical meanings. A self-dual space pairs with itself; a dualizable space pairs with its dual(). Calling a representation assigns an index label. Built-in spaces include Euclidean and Minkowski vectors, Dirac spinors, and color representations; custom spaces work with the same tensor operations.

Examples

from symbolica.community.tensor import Representation, TensorName
space = Representation.euc(3)
vector = TensorName.vector("v")(space)
vector("i").rank
1

Attributes

Name Description
dimension The dimension of this index space as a Symbolica expression.
name The registered space identity and duality, without its dimension.

dimension

Representation.dimension: Expression

The dimension of this index space as a Symbolica expression.

Returns

  • Expression An integer-valued expression or a dimension symbol.

Examples

from symbolica.community.tensor import Representation
Representation.euc(3).dimension == 3
True

name

Representation.name: RepresentationName

The registered space identity and duality, without its dimension.

Returns

  • RepresentationName Metadata shared by this representation at different dimensions.

Examples

from symbolica.community.tensor import Representation
Representation.euc(3).name == Representation.euc(5).name
True

Methods

Name Description
__call__ Attach an abstract index label to this space.
__eq__
__new__ Create or reuse a named index space.
__repr__ Return a readable object description for inspection.
__str__ Return a readable text representation.
_repr_html_
_repr_latex_
bis Create the Dirac bispinor space.
casimir Construct the degree-dependent Casimir eigenvalue.
coad Create the adjoint color representation.
cof Create the fundamental color representation.
cos Create the sextet color representation.
dual Return the space that pairs with this one under contraction.
dynkin_index Construct the degree-dependent Dynkin index.
euc Create the Euclidean vector space.
flat Create the metric map used to lower or raise an index.
g Create the metric with two explicit index labels.
gram Construct a Gram invariant for two representations.
id Create the identity pairing between this space and its dual.
mink Create the Minkowski vector space.
to_expression Return the symbolic encoding of the space and its dimension.
to_html Render a compact HTML view of this tensor metadata.

__call__

Representation.__call__(aind: builtins.int | builtins.str) -> Slot
Representation.__call__(aind: Expression) -> Expression | Slot

Attach an abstract index label to this space.

Parameters

  • aind (int, str, or Expression) An index label, not a component coordinate. A string, Python integer, or single symbol creates a Slot. Other Expressions retain raw representation syntax: supported numeric, tagged named, and scoped labels can be admitted directly; other compound payloads require intern="indices" when constructing a tensor.

Returns

  • Slot or Expression A typed index, or symbolic syntax for a compound index payload.

Examples

from symbolica import S
from symbolica.community.tensor import Representation, Slot
space = Representation.euc(3)
isinstance(space(S("i")), Slot)
True

__eq__

Representation.__eq__(other: builtins.object) -> builtins.bool

__new__

Representation.__new__(
    name: builtins.str,
    dimension: builtins.int | Expression | str,
    is_self_dual: builtins.bool = True,
) -> Representation

Create or reuse a named index space.

Parameters

  • name (str) Registered name distinguishing this space from other representations.
  • dimension (int, Expression, or str) Number of components in this index space, or a symbol naming that number. An Expression must be a single symbol, not a sum or product.
  • is_self_dual (bool, default True) Whether indices pair with the same space. False creates a space with a distinct dual; use dual() to obtain it.

Returns

  • Representation The requested space, ready to use as an unresolved tensor axis.

Examples

from symbolica.community.tensor import Representation
space = Representation("Flavor", 5, is_self_dual=False)
space.dual().dual() == space
True

__repr__

Representation.__repr__() -> builtins.str

Return a readable object description for inspection.

Examples

from symbolica.community import tensor as sp
r = sp.Representation.mink(4)
text = repr(r)

__str__

Representation.__str__() -> builtins.str

Return a readable text representation.

Examples

from symbolica.community import tensor as sp
r = sp.Representation.mink(4)
text = str(r)

_repr_html_

Representation._repr_html_() -> builtins.str

_repr_latex_

Representation._repr_latex_() -> builtins.str

bis

Representation.bis(dimension: builtins.int | Expression | str) -> Representation

Create the Dirac bispinor space.

Parameters

  • dimension (int, Expression, or str) Number of components in this index space, or a symbol naming that number. An Expression must be a single symbol, not a sum or product.

Returns

  • Representation The built-in index space with the supplied dimension.

Notes

This is the self-dual spinor index space used by the Dirac-matrix helpers. Its dimension counts spinor components, not space-time coordinates.

Examples

from symbolica.community.tensor import Representation
space = Representation.bis(4)
space.dimension == 4
True

casimir

Representation.casimir(degree: _ScalarInput = 2) -> Expression

Construct the degree-dependent Casimir eigenvalue.

Parameters

  • degree (scalar expression, default 2) Degree of the invariant. The default is the quadratic invariant.

Returns

  • Expression A symbolic scalar invariant; constructing it does not evaluate a group-specific formula.

Examples

from symbolica.community.tensor import Representation
invariant = Representation.cof(3).casimir()

coad

Representation.coad(dimension: builtins.int | Expression | str) -> Representation

Create the adjoint color representation.

Parameters

  • dimension (int, Expression, or str) Number of components in this index space, or a symbol naming that number. An Expression must be a single symbol, not a sum or product.

Returns

  • Representation The built-in index space with the supplied dimension.

Notes

For SU(N), pass N**2 - 1 (for example 8 for SU(3)). This space is self-dual.

Examples

from symbolica.community.tensor import Representation
space = Representation.coad(8)
space.dimension == 8
True

cof

Representation.cof(dimension: builtins.int | Expression | str) -> Representation

Create the fundamental color representation.

Parameters

  • dimension (int, Expression, or str) Number of components in this index space, or a symbol naming that number. An Expression must be a single symbol, not a sum or product.

Returns

  • Representation The built-in index space with the supplied dimension.

Notes

For SU(N), the dimension is N. This space pairs with its distinct dual, the antifundamental representation.

Examples

from symbolica.community.tensor import Representation
space = Representation.cof(3)
space.dimension == 3
True

cos

Representation.cos(dimension: builtins.int | Expression | str) -> Representation

Create the sextet color representation.

Parameters

  • dimension (int, Expression, or str) Number of components in this index space, or a symbol naming that number. An Expression must be a single symbol, not a sum or product.

Returns

  • Representation The built-in index space with the supplied dimension.

Notes

The SU(3) sextet has dimension 6 and a distinct dual representation.

Examples

from symbolica.community.tensor import Representation
space = Representation.cos(6)
space.dimension == 6
True

dual

Representation.dual() -> Representation

Return the space that pairs with this one under contraction.

Returns

  • Representation The same space for a self-dual representation; its partner otherwise.

Examples

from symbolica.community.tensor import Representation
Representation.euc(3).dual() == Representation.euc(3)
True
Representation.cof(3).dual().dual() == Representation.cof(3)
True

dynkin_index

Representation.dynkin_index(degree: _ScalarInput = 2) -> Expression

Construct the degree-dependent Dynkin index.

Parameters

  • degree (scalar expression, default 2) Degree of the invariant. The default is the quadratic invariant.

Returns

  • Expression A symbolic scalar invariant; constructing it does not evaluate a group-specific formula.

Examples

from symbolica.community.tensor import Representation
invariant = Representation.cof(3).dynkin_index()

euc

Representation.euc(dimension: builtins.int | Expression | str) -> Representation

Create the Euclidean vector space.

Parameters

  • dimension (int, Expression, or str) Number of components in this index space, or a symbol naming that number. An Expression must be a single symbol, not a sum or product.

Returns

  • Representation The built-in index space with the supplied dimension.

Notes

The space is self-dual, with positive metric signs on every component.

Examples

from symbolica.community.tensor import Representation
space = Representation.euc(3)
space.dimension == 3
True

flat

Representation.flat(
    i: builtins.int | Expression | str,
    j: builtins.int | Expression | str,
) -> TensorExpression

Create the metric map used to lower or raise an index.

Parameters

  • i, j (int, str, or Expression) Abstract index labels accepted by the shared tensor-structure parser, including numeric, symbolic, tagged named, and scoped indices.

Returns

  • TensorExpression The indexed rank-two tensor, or its contraction when the labels pair.

Notes

Both ports belong to this representation. The flat map accounts for the metric signs when identifying vectors and covectors.

Examples

from symbolica.community.tensor import Representation
tensor = Representation.euc(3).flat("i", "j")
tensor.rank
2

g

Representation.g(
    i: builtins.int | Expression | str,
    j: builtins.int | Expression | str,
) -> TensorExpression

Create the metric with two explicit index labels.

Parameters

  • i, j (int, str, or Expression) Abstract index labels accepted by the shared tensor-structure parser, including numeric, symbolic, tagged named, and scoped indices.

Returns

  • TensorExpression The indexed rank-two tensor, or its contraction when the labels pair.

Notes

Both ports belong to this representation. For a pairing between a space and its dual, use id or TensorExpression.g(rep, rep.dual()).

Examples

from symbolica.community.tensor import Representation
tensor = Representation.euc(3).g("i", "j")
tensor.rank
2

gram

Representation.gram(
    degree: _ScalarInput,
    other: typing.Optional[Representation] = None,
) -> Expression

Construct a Gram invariant for two representations.

Parameters

  • degree (scalar expression) Degree of the invariant.
  • other (Representation, optional) Second representation. Defaults to this representation.

Returns

  • Expression A symbolic Gram invariant, without evaluating a group-specific formula.

Examples

from symbolica.community.tensor import Representation
invariant = Representation.cof(3).gram(2)

id

Representation.id(
    i: builtins.int | Expression | str,
    j: builtins.int | Expression | str,
) -> TensorExpression

Create the identity pairing between this space and its dual.

Parameters

  • i, j (int, str, or Expression) Abstract index labels accepted by the shared tensor-structure parser, including numeric, symbolic, tagged named, and scoped indices.

Returns

  • TensorExpression The indexed rank-two tensor, or its contraction when the labels pair.

Notes

The first port is in self.dual() and the second in self.

Examples

from symbolica.community.tensor import Representation
tensor = Representation.euc(3).id("i", "j")
tensor.rank
2

mink

Representation.mink(dimension: builtins.int | Expression | str) -> Representation

Create the Minkowski vector space.

Parameters

  • dimension (int, Expression, or str) Number of components in this index space, or a symbol naming that number. An Expression must be a single symbol, not a sum or product.

Returns

  • Representation The built-in index space with the supplied dimension.

Notes

The space is self-dual, with metric signature (+, -, …, -). Component zero is the time coordinate.

Examples

from symbolica.community.tensor import Representation
space = Representation.mink(4)
space.dimension == 4
True

to_expression

Representation.to_expression() -> Expression

Return the symbolic encoding of the space and its dimension.

Returns

  • Expression Representation syntax without an index label. Use the Representation itself when constructing tensor axes.

Examples

from symbolica.community.tensor import Representation
encoded = Representation.euc(3).to_expression()

to_html

Representation.to_html() -> builtins.str

Render a compact HTML view of this tensor metadata.

Returns

  • str HTML fragment for display in a notebook or page.

Examples

from symbolica.community.tensor import Representation
value = Representation.euc(3)
html = value.to_html()