Let $X,Y,Z$ be metric spaces. Let $g:X\to Y$ and $f:Y \to Z$ two applications such that $f$ is continuous and $f\circ g$ is also continuous. Do we necessary have $g$ continuous ?
Is it possible to construct an example such that $f\circ g$ is continuous while $f$ or $g$ is not ?
Let $f (a)=f (b) ;a\ne b $.
Let $\lim_{x\rightarrow z} g (x)=a $ but $g (x) = b $. Then $g$ is not continuous at $z $. Then as $f $ is continuous $\lim_{x\rightarrow z} f (g (x)) = f (\lim g (x))=f (a)=f (b)=f (g (z)) $. So $f\circ g $ is continuous at $z$.
===
Even simpler is $g $ be any discontinuous function and $f$ be any constant function. But I wanted a non trivial example.
===
If we add the restriction $f $ is injective, I believe this becomes true. I'm pretty sure. Someone may want to verify that.