Make symbols atomic, without losing their type

You could use my TensorSimplify package help with this. Install the paclet with:

PacletInstall[
    "TensorSimplify", 
    "Site" -> "http://raw.githubusercontent.com/carlwoll/TensorSimplify/master"
]

Once installed, you can load the package with:

<<TensorSimplify`

This package defines the helper functions ToTensor and FromTensor. ToTensor converts expressions containing Tr and Dot into the equivalent version using TensorContract, and FromTensor does the opposite. So, your Tr expression can be simplified with:

$Assumptions = M \[Element] Matrices[{3, 3}] && a \[Element] Complexes;

FromTensor @ ToTensor @ Tr[a M]

a Tr[M]

An alternative is to just use the package's TensorSimplify function:

TensorSimplify @ Tr[a M]

a Tr[M]

TensorSimplify will work for more complicated arguments to Tr:

TensorSimplify @ Tr[a M + a^2 M.M]

a Tr[M] + a^2 Tr[M.M]


Perhaps what you want is symbolic tensors: http://reference.wolfram.com/language/tutorial/SymbolicTensors.html

$Assumptions = M ∈ Arrays[{3, 3}] && a ∈ Complexes;

TensorContract[a*M, {{1, 2}}]
(* a TensorContract[M, {{1, 2}}] *)