Say we have a polynomial with real coefficients and no repeated roots. Knowing that the roots of a polynomial vary continuously in the coefficients (so long as we don't change the degree), it seems intuitive that all sufficiently close polynomials will have the same number of real roots, because in order to make two real roots non-real, or vice versa, you'd have to first bring them together in order to satisfy the constraint that the non-real ones must be conjugates, and it's not too hard to see that all sufficiently close polynomials will also have no repeated roots (nonzero discriminant is an open set).
However I'm at a loss as to how to formalize the "you'd have to bring them together" argument above. That repeated roots can be avoided is easy because we have the discriminant as noted above, and looking at the sign of the discriminant shows the number of real roots won't change mod 4, but I'm not sure how to do better than that algebraically. It would be nice if Sturm's Theorem could be used but I don't expect that the polynomial quotients involved would be continuous at all the relevant points.
Is there any sort of nice algebraic way to do this, or is the best way to formalize the intuitive argument using continuity of roots? In the latter case, how would you actually prove that you have to bring two of them together?
(A possible workaround I thought of for the algebraic approach would be to use a different, more general Sturm chain -- in particular, for polynomials of degree n, consider $\mathbb{R}(a_0,\ldots,a_n)$ ($a_0,\ldots,a_n$ indeterminates) and the generic polynomial $a_n x^n+\ldots+a_0$ and its derivative, take quotients and remainders there, and only afterward plug in the real numbers, thus getting rid of discontinuous-degree-change issues. However this, or at least this particular variant, doesn't seem to actually work, as far as I can tell -- checking by hand the degree 3 case seems to indicate that this won't work since anything that's an intermediate initial coefficient will end up getting divided by, and the first one of those is $\frac{2}{9}\frac{a_2^2}{9a_3}-\frac{2}{3}a_1$, which can still be 0 without either $a_3$ or the discriminant being 0, which are the two things that can obviously be safely divided by.)