Clear["Global`*"] (*Clear all variables*)
(*
下面计算一个代数,把代数定义成为一个函数,然后给函数赋予attribute.
*)
f[x1, x1] := x0 + a1 x1 + x2
f[x1, x2] := x1 + a2 x2 + x3
f[x1, x3] := x2 + a3 x3 + x4
f[x1, x4] := x3 + a4 x4
SetAttributes[f, Orderless]
f[x1, x1]
x0 + a1 x1 + x2
Set::write: Tag TensorProduct in x1\[TensorProduct]x1 is Protected.
x0 + a1 x1 + x2
x1\[TensorProduct]x1