# Define action of noncommutative product of operators

I have objects wrapped with head fv. So they are things like

fv[{1, 2}, {3, 4}, {5, 6}]


I then defined two operators, a and ad that act on these objects and spit back new objects, also with head fv:

a[v /; Head[v] == fv] = ... object returned that looks like fv[{1,2},{3, 4} ...];
ad[v /; Head[v] == fv] = ... object returned that looks like fv[{4, 5}, {6, 7} ...];
op[a] * fv[y_]  ^:= a[fv[y]];


So now I can evaluate expressions like op[a]*fv[{1, 2}, {3, 4}].

I now want to also be able to evaluate expressions like op[a]**op[ad]*fv[{1, 2}, {3, 4}] where the ** denotes non-commutative multiplication. When I try implementing this with

op[a] ** op[ad]*fv[y_] ^:= a[ad[fv[y]]];


Mathematica tells me that NonCommutativeMultiply is protected. How should I go about doing this?

• Have a look at the answer that I gave to Non Commutative sorting in Mathematica, because it contains some tricks that might be sufficient to solve your problem. Mar 9 '15 at 13:11

The following, based on the post 'Non-Commutative Sorting in Mathematica', works well. I redefined the operator product so that it produces another object with head op and then generalized the definition of the action of these op objects.
op[x__] ** op[y__] ^:= op[x, y]