In the lecture notes for a course I'm taking, it is stated that:
Unlike multiplication however, we can't reverse order. First of all, in general it doesn't even make sense to reverse composition. For example, if we have $f:\mathbb{R} \to \mathbb{Z}$ defined by $f(x) =\left \lfloor x \right \rfloor$ and $g:\mathbb{R} \to \mathbb{R}$ defined by$g(x) = x^2$. Then $f \circ g$ makes perfect sense since the codomain of $g$ and the domain of $f$ are equal (both are $\mathbb{R}$), but we can't technically do $g \circ f$, since the codomain of $f$ is $\mathbb{Z}$ and the domain of $g$ is $\mathbb{R}$.
I'm confused by the reasoning for this. Since the implication is $(g\circ f):\mathbb{R} \to \mathbb{Z}$, and we have that $f:\mathbb{R} \to \mathbb{Z}$ is true, why is it that $(g \circ f)$ is not true as well?
We can form $g\circ f$ only by (silently) inserting a third function, namely the inclusion $\iota\colon \mathbb Z\to\mathbb R$, i.e. strictly we can only form $g\circ\iota\circ f$: $$ \mathbb R\stackrel f\longrightarrow\mathbb Z\stackrel \iota\longrightarrow \mathbb R\stackrel g\longrightarrow \mathbb R.$$ Alternatively, we can consider the restriction of $g$ to $\mathbb Z\subseteq \mathbb R$, that is $g|_{\mathbb Z}\colon\mathbb Z\to\mathbb R$, $x\mapsto x^2$. Then we can form $g|_{\mathbb Z}\circ f$: $$\mathbb R\stackrel f\longrightarrow\mathbb Z\stackrel {g|_{\mathbb Z}}\longrightarrow \mathbb R.$$ (Well, it's not really an alternative as one may define the restriction via $\iota$).
Maybe the example would have been more instructive if it used "totally different" sets instead of one subset of the other - cause in practice this silent assumption in the presence of subset inclusions (or other canonical inclusion maps/restrictions) is usually made.