I was reading this proof on MO of the following fact:
Let $f$ be an infinitely differentiable function on $[0,1]$ and suppose that for each $x \in [0,1]$ there is an integer $n \in \mathbb{N}$ such that $f^{(n)}(x)=0$. Then, $f$ is a polynomial.
I understood the outline of the proof, except for one step: assuming that $f$ is not a polynomial, it is claimed in the answer that the set
$$ X = \{x \in [0,1] : \text{$f|_{(a,b)}$ is not a polynomial} \ (\forall (a,b) \text{ containing $x$}) \} $$
is not empty. I have failed to understand why is that the case, so I am trying to see why $X = \emptyset$ would imply $f$ being a polynomial. I understand that by compactness of $[0,1]$, by assuming $X$ empty we would have intervals $I_1, \dots, I_n$ covering $[0,1]$ such that each restriction of $f$ is a polynomial, i.e. $f$ would be 'a polynomial piecewise'.
How can we conclude that $f$ itself is a polynomial?
The point is that if $f(x) = p_1(x)$ for $x \in (a,b)$ and $f(x) = p_2(x)$ for $x \in (c,d)$, where $(a,b) \cap (c,d) \ne \emptyset$, then $p_1 = p_2$. You can see this by considering the Taylor series about a point in the intersection.