[proofplan]
Since $f$ is an irreducible cubic over $\mathbb{Q}$, its Galois group $G = \operatorname{Gal}(f)$ acts faithfully on the three roots, embedding $G$ into $S_3$. We show that $3 \mid |G|$ using the Tower Law, which restricts $G$ to either $A_3$ (order $3$) or $S_3$ (order $6$). The Discriminant and the Alternating Group theorem then distinguishes the two cases: $G \subseteq A_3$ if and only if $\Delta$ is a perfect square in $\mathbb{Q}$.
[/proofplan]
[step:Embed $\operatorname{Gal}(f)$ into $S_3$ and show $3$ divides $|\operatorname{Gal}(f)|$]
Let $L$ be the splitting field of $f$ over $\mathbb{Q}$, and let $\alpha_1, \alpha_2, \alpha_3$ be the roots of $f$ in $L$. Since $f$ is irreducible of degree $3$ and $\operatorname{char} \mathbb{Q} = 0$, $f$ is separable, so by the [Splitting Fields of Separable Polynomials Are Galois](/theorems/1271) theorem, $L/\mathbb{Q}$ is a Galois extension with $G = \operatorname{Gal}(L/\mathbb{Q})$.
Each $\sigma \in G$ permutes the roots $\{\alpha_1, \alpha_2, \alpha_3\}$ (since $\sigma$ maps roots of $f$ to roots of $f$), and distinct automorphisms induce distinct permutations (since $L = \mathbb{Q}(\alpha_1, \alpha_2, \alpha_3)$). This gives an injective homomorphism $G \hookrightarrow S_3$, so we view $G$ as a subgroup of $S_3$.
Since $f$ is irreducible over $\mathbb{Q}$, $[\mathbb{Q}(\alpha_1) : \mathbb{Q}] = 3$. By the [Tower Law](/theorems/1248), $[L : \mathbb{Q}] = [L : \mathbb{Q}(\alpha_1)] \cdot [\mathbb{Q}(\alpha_1) : \mathbb{Q}] = 3 \cdot [L : \mathbb{Q}(\alpha_1)]$. Since $L/\mathbb{Q}$ is Galois, $|G| = [L : \mathbb{Q}]$, so $3 \mid |G|$.
[guided]
We establish the basic setup. Let $L$ be the splitting field of $f$ over $\mathbb{Q}$ and $\alpha_1, \alpha_2, \alpha_3$ the three roots of $f$ in $L$. Since $f$ is irreducible over $\mathbb{Q}$ and $\operatorname{char} \mathbb{Q} = 0$, $f$ is separable (irreducible polynomials over fields of characteristic zero are always separable). By the [Splitting Fields of Separable Polynomials Are Galois](/theorems/1271) theorem, $L/\mathbb{Q}$ is Galois.
Every $\sigma \in G = \operatorname{Gal}(L/\mathbb{Q})$ permutes the set of roots: if $f(\alpha_i) = 0$, then $f(\sigma(\alpha_i)) = \sigma(f(\alpha_i)) = \sigma(0) = 0$ since $f$ has coefficients in $\mathbb{Q}$ and $\sigma$ fixes $\mathbb{Q}$. Since $L = \mathbb{Q}(\alpha_1, \alpha_2, \alpha_3)$, an automorphism is determined by its action on the roots, so the map $G \to S_3$ sending $\sigma$ to its permutation of the roots is injective.
How large is $G$? Since $f$ is irreducible of degree $3$, the minimal polynomial of $\alpha_1$ over $\mathbb{Q}$ is $f$ itself, giving $[\mathbb{Q}(\alpha_1) : \mathbb{Q}] = 3$. By the [Tower Law](/theorems/1248), $[L : \mathbb{Q}] = [L : \mathbb{Q}(\alpha_1)] \cdot 3$. Since $L/\mathbb{Q}$ is Galois, $|G| = [L:\mathbb{Q}]$, so $3 \mid |G|$.
[/guided]
[/step]
[step:Identify the possible subgroups of $S_3$ and restrict to $A_3$ or $S_3$]
The subgroups of $S_3$ have orders dividing $|S_3| = 6$, so $|G| \in \{1, 2, 3, 6\}$. Since $3 \mid |G|$, we have $|G| \in \{3, 6\}$.
The subgroups of $S_3$ of order $3$ are: $A_3 = \{e, (1\;2\;3), (1\;3\;2)\}$, which is the unique subgroup of order $3$ (by [Lagrange's Theorem](/theorems/841), there is only one Sylow $3$-subgroup of $S_3$ since the number of Sylow $3$-subgroups divides $2$ and is congruent to $1 \pmod{3}$, giving exactly one). The only subgroup of $S_3$ of order $6$ is $S_3$ itself.
Therefore $G \cong A_3$ or $G \cong S_3$.
[/step]
[step:Apply the discriminant criterion to distinguish the two cases]
By the [Discriminant and the Alternating Group](/theorems/1325) theorem, for a separable polynomial $f$ with splitting field $L$ and Galois group $G \subseteq S_n$, we have $G \subseteq A_n$ if and only if $\operatorname{disc}(f)$ is a perfect square in $\mathbb{Q}$.
Applying this with $n = 3$: $G \subseteq A_3$ if and only if $\Delta = \operatorname{disc}(f)$ is a perfect square in $\mathbb{Q}$. Since the only possibilities for $G$ are $A_3$ and $S_3$:
- If $\Delta$ is a perfect square in $\mathbb{Q}$, then $G \subseteq A_3$, and since $3 \mid |G|$ and $|A_3| = 3$, we get $G = A_3 \cong \mathbb{Z}/3\mathbb{Z}$.
- If $\Delta$ is not a perfect square in $\mathbb{Q}$, then $G \not\subseteq A_3$, so $G = S_3$.
[guided]
We now invoke the [Discriminant and the Alternating Group](/theorems/1325) theorem. This theorem states: if $f$ is a separable polynomial with splitting field $L$ over a field $K$, and $G = \operatorname{Gal}(L/K) \subseteq S_n$ acts on the roots, then $G \subseteq A_n$ if and only if $\operatorname{disc}(f)$ is a perfect square in $K$.
We verify the hypotheses. We need $f$ to be separable: this holds because $f$ is irreducible over $\mathbb{Q}$ and $\operatorname{char} \mathbb{Q} = 0$. The splitting field is $L$, and $G = \operatorname{Gal}(L/\mathbb{Q})$ is embedded into $S_3$ via the root permutation action (each automorphism permutes the three roots, and since $L = \mathbb{Q}(\alpha_1, \alpha_2, \alpha_3)$, distinct automorphisms induce distinct permutations).
Applying the theorem with $K = \mathbb{Q}$ and $n = 3$: $G \subseteq A_3$ if and only if $\Delta = \operatorname{disc}(f)$ is a perfect square in $\mathbb{Q}$.
Now we combine this with our constraint $G \in \{A_3, S_3\}$:
**Case 1: $\Delta$ is a perfect square in $\mathbb{Q}$.** Then $G \subseteq A_3$. Since $3 \mid |G|$ and $|A_3| = 3$, we must have $|G| = 3$, so $G = A_3$. As a group of prime order, $A_3 \cong \mathbb{Z}/3\mathbb{Z}$.
**Case 2: $\Delta$ is not a perfect square in $\mathbb{Q}$.** Then $G \not\subseteq A_3$. Since $G$ is a subgroup of $S_3$ with $3 \mid |G|$ and $G \neq A_3$, the only possibility is $G = S_3$.
This completes the classification: $\operatorname{Gal}(f) \cong A_3 \cong \mathbb{Z}/3\mathbb{Z}$ if $\Delta$ is a perfect square, and $\operatorname{Gal}(f) \cong S_3$ otherwise.
[/guided]
[/step]