if I define id
as:
id /: NonCommutativeMultiply[id, x_] := x
id /: NonCommutativeMultiply[y_, id] := y
then id ** a - a ** id
gives 0
. However if:
NCM[x___] := NonCommutativeMultiply[x];
id /: NCM[id, x_] := x
id /: NCM[y_, id] := y
then id ** a - a ** id
gives -a ** id + id ** a
and not 0
I am confused as to why this happens(?)
Attributes[TagSet]
includesHoldAll
, soNCM
is not expanded during the definition of the pattern andNonCommutativeMultiply
(which you have with**
) does not matchNCM
. $\endgroup$Evaluate[NCM[...]]
, or just avoid using the abbreviation in the first place.... /: id ** x_
and... /: y_ ** id
should also work. $\endgroup$