In mathematics, a given operation $\circ$ is said to be associative if there is equality $$(f\circ g)\circ h=f\circ(g\circ h)$$ for any $f$, $g$ and $h$. Intuitively, this means that parentheses don't matter when one is dealing with the given operation.
I'm wondering if Mathematica's
/. is associative. Explicitly, suppose that
expr1 is an expression, and
expr3 are replacement rules. Will the Mathematica kernel distinguish between the inputs
(expr1 /. expr2 ) /. expr3 and
expr1 /. (expr2 /. expr3 )?
Here is an example, which evaluates to
(x /. x -> y) /. y -> z == x /. (x -> y /. y -> z)
Is there a nice example of
ReplaceAll behaving in a non-associative manner? Can I expect associativity under reasonable conditions? What if we consider the
//. instead of