If at each point of a closed interval the $m$-th derivative of $f$ is $0$ for $m$ large enough, then $f$ is polynomial I am working on exercice 9.5.2 of Analysis by Zorich and I am stuck at the question b.

a) A set $E\subset X$ of a metric space $(X,d)$ is nowhere dense in X if it is not dense in any ball, that is, if for every ball $B(x,r)$ there is a second ball $B(x_1,r_1)\subset B(x,r)$ containing no points of the set $E$.
A set E is of first category in X if it can be represented as a countable union of nowhere dense sets. A set that is not of first category is of second category in $X$. Show that a complete metric space is set of second category (in itself).
b) Show that if a function $f\in C^{(\infty)}[a,b]$ is such that $\forall x\in [a,b] \;\exists n\in \mathbb{N} \;\forall m>n \;(f^{(m)}(x)=0)$, then $f$ is a polynomial.

Here's my try: Define the sets $S_n:=\{x\in[a,b]\mid f^{(m)}(x)=0\; \forall m>n\}$. Then $\cup_{n=1}^{\infty} S_n =[a,b]$. As $[a,b]$ is a complete metric space, $S_n$ cannot be all nowhere dense. Define $Y:=\{x\in [a,b] \mid \text{ there exists a neighborhood of } x \text{ and } n \text{ such that } S_n \text{ is dense in that neighborhood}$. I want to say that $Y=[a,b]$ so that I could conclude with the compactness of $[a,b]$. But all I can say is that the complement of $Y$ in $[a,b]$ contains no interval.
Can you help me? Thanks!
 A: Here is a sketch of a possible approach, which may have some holes, but it is too long for a comment. Maybe someone can patch it up.Picking up on your idea, set 
$T = \{t\in [a,b]: \forall (c,d)\ni t: f\restriction_{(c,d)}$ is not a polynomial$\}$
Then $T$ is non-empty and closed. By construction, it has no isolated points. Now  we may apply the Baire theorem on $\{T\cap S_n\}$ to find an interval $(c,d)$ such that for some $n\in \mathbb N,\ (c,d)\cap T\subset S_n$.
Now, $f$ is a polynomial on $(c,d)\setminus T,$ which is open and so contains an interval $(\alpha,\beta)$, which we may take to be maximal: indeed, $(c,d)\setminus T$ is a countable disjoint union of intervals $\bigcup_n(a_n,b_n)$ and so $\{x:a',b'\in (a,b)\setminus T\  \text{and} \ b'-a'\ge b_n-a_n\}$ is a maximal interval in $(a,b)\setminus T$.
Now, either $\alpha$ or $\beta\in T$. Suppose $\alpha\in T$. Then, on every interval $(c',c'')$ containing $\alpha,\ f$ is $not$ a polynomial. Choose $c'''$ such that  $c'<\alpha<c'''<c''<d$. Then, $f$ is not a polynomial on $(c''',c'').$ But since $(c''',c'')\subseteq (\alpha,\beta)$, so we have a contradiction. 
So, either there is no such interval $(c,d)$ or $T$ is empty. In either case, the result follows.
A: You can ‘trace’ the $m$th derivative back to the original function recursively. If $f^{(m)}(x) = 0$ for all $x \in [a,b]$, then $f^{(m-1)}(x) = \int f^{(m)}(x) \, \mathrm{d}x = \int 0\,\mathrm{d}x=c_0$. Subsequently, $f^{(m-2)}(x) = \int c_0\,\mathrm{d}x=c_1x+c_0$. Applying this technique $m$ times, we see that $f(x) = c_mx^m + c_{m-1}x^{m-1}+\dots + c_1x + c_0$, which is a polynomial by definition.
(Note that the indices $c_1, c_0$ etc. are not necessarily the same for each iteration, they are just arbitrary constants, where the index indicates the power of $x$ associated to it.)
A: 
b) Show that if a function $f\in C^{(\infty)}[a,b]$ is such that $\forall x\in [a,b] \;\exists n\in \mathbb{N} \;\forall m>n \;(f^{(m)}(x)=0)$, then $f$ is a polynomial.

It suffices to require that $f^n(x)=0$ and this is a well-known fact.
