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, soNCMis not expanded during the definition of the pattern andNonCommutativeMultiply(which you have with**) does not matchNCM. – eyorble Dec 19 '20 at 22:29Evaluate[NCM[...]], or just avoid using the abbreviation in the first place.... /: id ** x_and... /: y_ ** idshould also work. – eyorble Dec 19 '20 at 22:43