For some context: I have a function
Prod[a___,state] which represents a list a___ of quantum mechanical operators acting on a state. After manipulating the elements in a___, I end up with a sum of products of operators. For example, I get
c_1*Prod[P1,P2,state] + c_2*Prod[P2,P1,state], where P1 and P2 commute. I am looking for a way to directly obtain the coefficient
c_1+c_2. To do so:
I am trying to define a bilinear function
Dot[Prod[a___,state],Prod[b___,state]] that would return 1 if a___ is a reordering of b___ and 0 otherwise.
I know how to make my function bilinear, but I have no idea how to specify the condition of "a is a reordering of b".
Note that P1 can appear multiple times, which prevents me from simply using Complement.
Any help is appreciated, thank you.