Using Idenso from Python
The spynso3 bindings expose Spenso and Idenso through one Symbolica community module. This example contracts one four-dimensional Minkowski metric with a vector and verifies the exact remaining expression.
Install and verify the modules
python -m venv .venv
. .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install symbolica
python -c "import symbolica.community.tensor"There is no standalone idenso Python wheel. Import the community module before constructing expressions, and follow Symbolica’s installation and license terms.
Simplify one metric contraction
Save this as idenso_quickstart.py:
from symbolica.community.tensor import Representation, TensorExpression, TensorName
rep = Representation.mink(4)
mu, nu = rep("mu"), rep("nu")
g = TensorExpression.g(rep)
q = TensorName.vector("q")
expression = g(mu, nu) * q(mu)
reduced = expression.contract()
assert reduced == q(nu)
assert len(reduced.list_dangling()) == 1
print(reduced)Typed composition represents the contraction with a bracket shorthand. contract() uses the shared symbolic contractor for bracketed and ordinary indexed products. It returns a TensorExpression, retaining scalar factorization. to_expression() explicitly returns its ordinary Symbolica expression. The algebra guide explains dummy scopes.
Run python idenso_quickstart.py. Success means the explicit metric disappears and q(nu) remains. The structural equality check is stronger than comparing printed text, whose formatting may change between Symbolica releases.
Check dangling indices before and after each pass. When multiplying expressions built with independent dummy-index namespaces, wrap those namespaces before simplification so equal printed names do not create an accidental contraction.
Continue with the controlled identity tutorial for a verification workflow, then use the algebra guide to compose metric, Dirac, color, and cooking stages deliberately.