I want to prove that associativity
$$ a \circ (b \circ c) = (a \circ b) \circ c $$
implies $P(a_1, \dots,a_n) = P'(a_1,\dots,a_n)$ for all $n \geq 1$ and all $a_1,\dots,a_n$. $P(a_1, \dots,a_n)$ and $P'(a_1, \dots,a_n)$ here denote arbitrary arrangements of parentheses in the string $a_1 \circ \dots \circ a_n$.
Let $L$ be the number of $\circ$s in a term. Then we can associate each term a pair $(m, L - m)$, where $m$ is the number of $\circ$s left of the outermost one.
The theorem holds trivially for $L < 2$ and by associativity for $L = 2$. Suppose now that we have terms $c$, $d$ of the form $(m, L - m)$ for $L > 2$. Then $c = c' \circ c''$ and $d = d'\circ d''$. Because $c' = d'$ and $c'' = d''$ by the induction hypothesis, $c = d$.
Lemma. For all $L$, if $t$ is of the form $(m, L - m)$, for all $-m \leq k \leq L - m - 1$ there exists an $h$ of the form $(m + k, L - (m + k))$ such that $t = h$.
For the base case, $L = 0$, this holds vacuously. For $L = 1$, $k$ must be $0$. For $L \geq 2$, we can use the induction hypothesis. Consider the term $a \circ b$. We use the induction hypothesis on $a$ and $b$. If $k < 0$, we can split $a$, using the induction hypothesis and associativity:
$$ a \circ b = (a' \circ a'') \circ b = a' \circ (a'' \circ b). $$
Here, $a$ is equal to a term of the form $(m + k, L_a - (m + k))$, so $a'$ has $m + k$ operators, so the last term satisfies our lemma. For $k = 0$, the solution is exactly $a \circ b$ already. For $k > 0$, we can split $b$ similarly.
$$ a \circ b = a \circ (b' \circ b'') = (a \circ b') \circ b''. $$
Here, $b$ is of the form $(k - 1, L_b - (k - 1))$, so that the last term satisfies the lemma. $\blacksquare$
Now we finish the inductive step. Consider any $t$ and $h$ of length $L > 2$. They are of the form $(n, L - n)$ and $(m, L - m)$, respectively. We want $k$ such that $n = m + k$, which is $k = n - m$. Now we have to prove that $-m \leq k \leq L - m - 1$. But this follows immediately from the fact that $0 \leq n \leq L - 1$. Our lemma now entails that there is such a $h'$ of the form $(n, L - n)$ that $t = h'$. But $h$ is of this form as well, and we have shown already that the induction hypothesis entails that all of the terms of the same form are equal. Hence, $h = h' = t$. $\blacksquare$
This proof took me a lot of time and seems very inelegant to me. If it is wrong, please, do correct me. I am also curious whether we can do it more elegantly.