Welcome to Cadabra Q&A, where you can ask questions and receive answers from other members of the community.
+1 vote

Hi,

When preparing sample code for my prior question, I noticed that substitute() was affected by the definition of an additional expression that was not passed in as input. In particular, when the code below

ex := (\Gamma^{a b})_{\alpha \beta} (\Psi_{b a})_{\gamma \eta};
substitute(ex, $_{a} -> _{b}, ^{a} -> ^{b}, _{b} -> _{a}, ^{b} -> ^{a}$);

is placed in a file test.cnb and run by entering cadabra2 test.cnb in the terminal, the output is

\indexbracket(Γ^{a b})_{α β} \indexbracket(Ψ_{b a})_{γ η}
\indexbracket(Γ^{b a})_{α β} \indexbracket(Ψ_{a b})_{γ η}

as expected. However, when the code in test.cnb is

ex := (\Gamma^{a b})_{\alpha \beta} (\Psi_{b a})_{\gamma \eta};
ex2 := (\Gamma^{a})_{\alpha \beta} (\Psi_{b})_{\gamma \eta};
substitute(ex, $_{a} -> _{b}, ^{a} -> ^{b}, _{b} -> _{a}, ^{b} -> ^{a}$);

the output is

\indexbracket(Γ^{a b})_{α β} \indexbracket(Ψ_{b a})_{γ η}
\indexbracket(Γ^{a})_{α β} \indexbracket(Ψ_{b})_{γ η}
\indexbracket(Γ^{a})_{α β} \indexbracket(Ψ_{b})_{γ η}

That is, substitute() seems to be returning ex2. This bug does not appear when entering the code line-by-line into the cadabra2 CLI.

The full code of test.cnb giving the latter result is shown below.

{a,b,c,d,e}::Indices(vector)
{a,b,c,d,e}::Integer(0..10)
{\alpha,\beta,\gamma,\eta}::Indices(spinor)
\Gamma_{#}::GammaMatrix(metric=\delta)
\delta{#}::KroneckerDelta

ex := (\Gamma^{a b})_{\alpha \beta} (\Psi_{b a})_{\gamma \eta};
ex2 := (\Gamma^{a})_{\alpha \beta} (\Psi_{b})_{\gamma \eta};
substitute(ex, $_{a} -> _{b}, ^{a} -> ^{b}, _{b} -> _{a}, ^{b} -> ^{a}$);

-Simon

in Bug reports by (250 points)

1 Answer

0 votes

Hi Simon,

I'm not getting the behaviour you describe. Am I doing something wrong?

enter image description here

by (13.2k points)
...