Proving f(gh) = (fg)h I am trying to prove that $f(gh)=(fg)h$ for $f,g,h \in R[\mathbb{N}^n]$. Context to the exercise:
We define the polynomial ring $R[X_1,...,X_n]$ in $n$ variables as
$$
R=[X_1,...,X_n] = R[\mathbb{N}^n] = \\\{ f:\mathbb{N}^n \to R | f(v)=0,|v| >> 0 \}
$$
where $v=(v_1,...,v_n)\in \mathbb{N}$ and $|v| = v_1+...+v_n.$
A polynomial $f \in R[X_1,...,X_n]$ is the same as a function $f:\mathbb{N}^n \to R$ that is non-zero for only finitely many $v \in \mathbb{N}^n$. We let $X^v \in R\left[\mathbb{N}^n\right]$ denote the function given by
$$
X^v(w)= \begin{cases}1 & \text { if } v=w, \\\\ 0 & \text { if } v \neq w .\end{cases}
$$
With this notation, every polynomial $f \in R\left[\mathbb{N}^n\right]$ can be written as a (finite) sum
$$
f=\sum_{v \in \mathbb{N}^n} a_v X^v,
$$
where $a_v \in R$ (an element $r \in R$ is identified with the function mapping the zero vector to $r$ and everything else to $0 \in R$ ). If $f, g \in R\left[\mathbb{N}^n\right]$ we define $f+g$ by $(f+g)(v)=f(v)+g(v)$ and $f g$ by the (finite) sum
$$
(f g)(v)=\sum_{v_1+v_2=v} f\left(v_1\right) g\left(v_2\right)
$$
where $v_1,v_2 \in \mathbb{N}^n$.
 A: One should be able to prove associativity by figuring out the coefficient of $x_1^{m_1} \cdots x_n^{m_n}$ in a general product of two polynomials, then analysing that for the product of three functions. For
$$f(x) = \sum_{v\in {\bf N}^n} a_{v} x^v,$$
where if $v = (m_1,\ldots,m_n)$ and $x=(x_1,\ldots,x_n)$, then $x^v$ denotes ${x_1}^{m_1}\cdots{x_n}^{m_n}$. (Of course the $a_v$ are zero for cofinitely many $v$.) Let
$$g(x) = \sum_{v\in {\bf N}^n} b_{v} x^v,$$
Then $fg$ is given by
$$(fg)(x) = \sum_{v\in {\bf N}^n} \sum_{u+w =v} a_ub_w x^v.$$
So if we introduce a third polynomial
$$h(x) = \sum_{v\in {\bf N}^n} c_{v} x^v,$$
we have
$$(gh)(x) = \sum_{v\in {\bf N}^n} \sum_{u+w =v} b_uc_w x^v.$$
And from here it is easy to see that both $(fg)h$ and $f(gh)$ are equal to
$$\sum_{v\in {\bf N}^n} \sum_{t+u+w =v} a_tb_uc_w x^v,$$
by the associativity of addition of natural numbers, and the associativity of multiplication in a ring.
A: Since it seems like you are learning university level algebra, this simpler but more theoretical proof could be instructive.
Note that the map $(fg)h - f(gh)$ is an $R$-module map
$$M: R[X_1, \ldots, X_n]^{\otimes 3} \to R[X_1, \ldots, X_n]$$
since it is obtained as compositions and subtractions of the multiplication, which is a $R$-module map. The key observation is that the triple tensor product is generated by tensor products of monomials $X^{\alpha}\otimes X^{\beta}\otimes X^{\gamma}$. If we manage to show that $M$ is zero in generators, we show associativity.
Product of monomials is particularly easy: you can show that the summation $X^{\alpha}X^{\beta}(\nu)$ is zero unless $\nu=\alpha+\beta$, and in this case the result is one, since only one summand is non-zero. We deduce that $X^{\alpha}X^{\beta} = X^{\alpha+\beta}$, which yields
$$M(X^{\alpha}\otimes X^{\beta}\otimes X^{\gamma}) = (X^{\alpha}X^{\beta})X^{\gamma} - X^{\alpha}(X^{\beta}X^{\gamma} ) = X^{(\alpha+\beta)+\gamma} - X^{\alpha+(\beta+\gamma)} = 0$$
Voilà!
