I can't understand a step in the proof of the associativity of matrix multiplication Matrix multiplication associativity is proven by the following reasoning:
Let there be matrices $A^{m \times n}$, $B^{n \times k}$ and $C^{k \times l}$. Then
$$
\{(AB)C\}_{ij}=\sum\limits_{p=1}^k{\{AB\}_{ip}c_{pj}
\\=\sum\limits_{p=1}^k \left(\sum\limits_{q=1}^n a_{iq}b_{qp}\right)}c_{pj}
\\=\sum\limits_{q=1}^n a_{iq} \left(\sum\limits_{p=1}^k b_{qp}c_{pj}\right) 
\\= \{A(BC)\}_{ij}.
$$
I don't understand how we get the third line from the second.

An $m\times n$ matrix $A=(a)_{ij}$ induces a function $f_A:\mathbb{R}^n\to\mathbb{R}^m$,
$$
f_A(x_1,x_2,\ldots,x_n)=\left(\sum_{j=1}^na_{1j}x_j,\ldots,\sum_{j=1}^na_{mj}x_j\right).
$$
You can check that the composition $f_A\circ f_B$ corresponds to the matrix product $AB$, i.e. $f_{AB}=f_A\circ f_B$.
Hence associativity of matrix multiplication is implied by associativity of function composition, which holds quite generally.
