Expressions¶
Chacana parses tensor calculus expressions using a PEG grammar. This page covers the supported syntax.
Tensor expressions¶
A tensor with indices uses curly braces:
R{^a _b _c _d} # Riemann tensor: 1 contra, 3 covariant
T{^a _b} # Mixed rank-2 tensor
g{_a _b} # Metric tensor (covariant)
^marks a contravariant (upper) index_marks a covariant (lower) index
Bare identifiers without braces are also valid:
Arithmetic¶
A{^a} + B{^a} # Sum (free indices must match)
A{^a} - B{^a} # Subtraction
A{_a} * B{^a} # Product with contraction
3 * T{^a _b} # Scalar multiplication
3.14 # Scalar literal
(A + B) * C # Parenthesized sub-expression
Wedge product¶
Index derivatives¶
T{^a _b ;c} # Covariant derivative (semicolon)
T{^a _b ,c} # Partial derivative (comma)
T{;a ;b} # Double covariant derivative
Symmetrization¶
T{_( a b _)} # Symmetrize over a, b
T{_[ a b _]} # Anti-symmetrize over a, b
T{^( a b ^)} # Contravariant symmetrization
Nested symmetrization
Nested symmetrization like T{_( _( a b _) _)} is rejected by the
parser as it is not supported in the Chacana micro-syntax.
Functional operators¶
d(omega) # Exterior derivative
L(X, T{^a _b}) # Lie derivative
Tr(T{^a _b}) # Trace
det(g{_a _b}) # Determinant
inv(M) # Inverse
star(omega) # Hodge star (requires active_metric)
i(X, omega) # Interior product
Perturbations and commutators¶
Greek indices¶
Greek letters are supported and automatically detected as IndexType.GREEK:
Unicode normalization¶
All input is NFC-normalized before parsing. Decomposed characters (e.g.,
α + combining acute) are composed to their precomposed form.
Characters from non-Latin/Greek Unicode blocks (Cyrillic, Arabic, CJK, etc.) are rejected to prevent visual spoofing.