I am writing my own Mathematica code for simplifying tensor index manipulations with a metric. Here is what I wrote:
SetAttributes[metric, Orderless]
SetAttributes[metricInv, Orderless]
Format[Tensor[{a___}, {b___}]] := Subscript[Superscript["T", {a}], {b}]
metric/:Tensor[{x___, μ_, y___}, {a___}]· metric[μ_, ν_] :=
Tensor[{x, ν, y}, {a}]
metricInv/:Tensor[{a___}, {x___, μ_, y___}]· metricInv[μ_, ν_] :=
Tensor[{a}, {x, ν, y}]
Is there any way to say that other functions that I am defining, under other names, should follow the same rules for tensors as I have described above? In other words, if I have other functions that are NOT named Tensor, how can I say that they should behave as tensors, while keeping their different names intact?