Does there exist a polynomial Hamiltonian function $H$ on some $\mathbb{R}^{2n}$ such that

- Any polynomial function $P$ such that $\{P,H\}=0$ is of the form $p(H)$ for some polynomial $p$ in one variable;
- There exists a smooth function $F$ such that $\{F,H\}=0$, and yet $F$ is
*not*of the form $f(H)$ for any smooth function $f$ in one variable?

I am looking for an example of such a phenomenon, or a proof that it cannot occur. A non-Hamiltonian example -- that is, of a polynomial vector field such that the smooth completion of the algebra of its polynomial integrals is strictly smaller than the algebra of its smooth integrals -- would also be helpful. Any references to the literature will be much appreciated, of course.

Thanks in advance!