I would like to group expressions under associative equivalence, but only for a specific operation used in the expression (not for other operations).
Say we have two binary operations A and B applicable to positive integers and producing positive integer outcomes (for instance + and x on the positive integers). Expressions of the following type can be formed
A(3,1), B(7,9), A(B(1,2),3), B(A(2,1),A(B(1,3),5)), ...
The aim is to group such expressions according to equivalence under associative recombination of one of the operations. Say for operation A.
For instance (replacing arbitrary positive integers with an atom x for clarity):
A(B(x,x), A(x, A(x,x))) should be equivalent to A(A(A(B(x,x),x),x),x)
But no changes should be made to expressions using B in which associative recombinations could potentially be made.
B(B(A(x,x),x), B(x, B(x,x))) should not be equivalent to B(B(B(B(A(x,x),x),x),x),x)
Are there commands in Mathematica that test expressions for associative equivalence for a particular, i.e. fixed choice of operation?
I don't wish to make the expressions literally equivalent to one another and collapse them to a single representative. I just wish to group them into say lists of equivalent expressions.
ETA I found a reference to ``Flatten" and am considering to use it as in:
Flatten[A[B[u, v], A[x, y]], Infinity, A]
I will leave the post up, and wonder whether I could just check for associative equivalence this way?
For instance via:
Flatten[A(B(x,x), A(x, A(x,x))), Infinity, A] == Flatten[A(A(A(B(x,x),x),x),x), Infinity, A]