You need to declare the \mu
index to run over the range that you want, e.g.
{\mu,\nu}::Indices(values={1,2,3,4}, position=fixed);
The fixed
is there to tell cadabra that there is a distinction between upper and lower indices; for your problem that's not relevant. Then you can do
ex:=A^{\mu} A_{\mu};
evaluate(ex);
to get what you want.
The evaluate
algorithm can do much more, all having to do with evaluating tensor expressions in components, but if you do not tell it what the components are, it will just keep them as A_{1}
, A_{2}
and so on. If instead of the above you do e.g.
ex:= A^{\mu} A_{\mu};
evaluate(ex, $A_{1} -> x, A_{2} -> x+y, A_{4}->c$);
you would get $x A^{1} + (x+y) A^{2} + c A^{4}$. And so on.