I'm reading a proof of following result:
Let $f(X) \in \mathbb{Z}[X]$ be a monic polynomial. Let $p$ be a prime number. Suppose $f(X)$ mod $p$ is separable in $\mathbb{Z}/p\mathbb{Z}[X]$. Then $f(X)$ is separable in $\mathbb{Q}$.
Proof: Suppose $f(X)$ is not separable in $\mathbb{Q}$ then
Since $\mathbb{Q}$ is perfect, there exists a monic irreducible $g(X) \in \mathbb{Z}[X]$ such that $f(X)$ is divisible by $g(X)^2$.
I don't understand how does one get $g(x)$ using the perfectness of $\mathbb Q$ ?
"$\mathbb Q$ is perfect" means that every irreducible polynomial in $\mathbb Q[x]$ has no repeated roots.
So let's write our $f(x)$ as a product $$ f(x) = g_1(x) g_2(x) \dots g_n(x),$$ where $g_1(x) , \dots, g_n(x)$ are irreducible monic polynomials.
By assumption, $f(x)$ is not separable, which means that there exists an $\alpha \in \mathbb Q$ such that $\alpha$ is a repeated root of $f(x)$.
So either $\alpha$ is a repeated root of $g_{i}(x)$ for some $i$, or $\alpha$ is a root of $g_{i}(x)$ and $g_{j}(x)$ for $i \neq j$. The first option is impossible, since $g_i(x)$ is irreducible and $\mathbb Q$ is perfect. So we are left with the second option.
But $g_i (x)$ and $g_j (x)$ are both minimal polynomials of $\alpha$, so they are equal! Thus, taking $g(x) : = g_i (x) = g_j(x)$, we have that $g(x)^2 | f(x)$.