[proofplan]
We prove both implications by contrapositive, in each case translating reducibility of $V$ into a witness of non-primality of $I(V)$ and vice versa. The forward direction uses that a non-trivial decomposition $V = V_1 \cup V_2$ produces functions $f_1, f_2$ vanishing on one piece but not the other, whose product vanishes on the union; the reverse direction uses a non-prime relation $g_1 g_2 \in I(V)$ with $g_i \notin I(V)$ to cut $V$ into $V \cap V(g_1)$ and $V \cap V(g_2)$. The bridge between algebra and geometry is the inclusion-reversing pair $(I, V)$ together with the [Hilbert Nullstellensatz](/theorems/2124) — concretely, the fact that $I(V_1) \subsetneq I(V_2)$ for varieties $V_1 \supsetneq V_2$, which guarantees the witness functions exist.
[/proofplan]
[step:Set up the algebra–geometry correspondence and the witness lemma]
Recall the operators
\begin{align*}
V : \{\text{ideals of } k[X_1, \ldots, X_n]\} &\to \{\text{subsets of } \mathbb{A}^n_k\}, \\
I : \{\text{subsets of } \mathbb{A}^n_k\} &\to \{\text{ideals of } k[X_1, \ldots, X_n]\},
\end{align*}
defined by $V(J) = \{p \in \mathbb{A}^n_k : f(p) = 0 \text{ for all } f \in J\}$ and $I(S) = \{f \in k[X_1, \ldots, X_n] : f(p) = 0 \text{ for all } p \in S\}$. Both are inclusion-reversing. By definition of a variety, $V$ in the statement is closed in the Zariski topology, so $V(I(V)) = V$.
We will use the following fact repeatedly: if $V_1, V_2$ are varieties with $V_1 \subsetneq V_2$, then $I(V_2) \subsetneq I(V_1)$, i.e., the inclusion of ideals is strict. Indeed, $V_1 \subset V_2$ gives $I(V_2) \subset I(V_1)$ by inclusion-reversal. If equality held, applying $V$ would give $V_2 = V(I(V_2)) = V(I(V_1)) = V_1$, contradicting $V_1 \subsetneq V_2$. Hence $I(V_2) \subsetneq I(V_1)$, and we may pick $f \in I(V_1) \setminus I(V_2)$ — a polynomial vanishing on the smaller variety but not on the larger.
[/step]
[step:Suppose $V$ is reducible and produce $f_1, f_2 \notin I(V)$ with $f_1 f_2 \in I(V)$]
Suppose $V$ is reducible. By definition of reducibility, there exist closed subvarieties $V_1, V_2 \subsetneq V$ with $V = V_1 \cup V_2$. We will show that $I(V)$ is not prime by exhibiting two polynomials $f_1, f_2 \notin I(V)$ whose product lies in $I(V)$.
By the witness lemma of Step 1 applied to the strict inclusions $V_1 \subsetneq V$ and $V_2 \subsetneq V$, we may choose
\begin{align*}
f_1 &\in I(V_2) \setminus I(V_1), \\
f_2 &\in I(V_1) \setminus I(V_2).
\end{align*}
Concretely: $f_1$ vanishes on $V_2$ but not on all of $V_1$; $f_2$ vanishes on $V_1$ but not on all of $V_2$.
We claim $f_1, f_2 \notin I(V)$. For if $f_1 \in I(V) = I(V_1 \cup V_2) = I(V_1) \cap I(V_2)$, then in particular $f_1 \in I(V_1)$, contradicting $f_1 \notin I(V_1)$. The argument for $f_2$ is symmetric.
We claim $f_1 f_2 \in I(V)$. Pick any $p \in V = V_1 \cup V_2$. If $p \in V_1$, then $f_2(p) = 0$ since $f_2 \in I(V_1)$, so $(f_1 f_2)(p) = f_1(p)\, f_2(p) = 0$. If $p \in V_2$, then $f_1(p) = 0$, so again $(f_1 f_2)(p) = 0$. Hence $f_1 f_2$ vanishes on $V$, i.e. $f_1 f_2 \in I(V)$.
Combining: $I(V)$ contains the product $f_1 f_2$ of two elements neither of which lies in $I(V)$. By definition of a prime ideal — a proper ideal $\mathfrak{p}$ such that $ab \in \mathfrak{p}$ implies $a \in \mathfrak{p}$ or $b \in \mathfrak{p}$ — this exhibits $I(V)$ as not prime.
[guided]
We are given that $V$ is reducible: $V = V_1 \cup V_2$ with each $V_i$ a closed proper subvariety of $V$. We aim to contradict primality of $I(V)$. The strategy is to find two polynomials whose product lies in $I(V)$ but neither factor does.
\textbf{Where do the witnesses come from?} The witness lemma from Step 1 says that if a variety $W'$ sits strictly inside a variety $W$, there is some polynomial vanishing on $W'$ but not on $W$. Applied to the strict inclusions $V_2 \subsetneq V$ and $V_1 \subsetneq V$ (and noting that $V_1 \subsetneq V$ together with $V = V_1 \cup V_2$ forces $V_2 \not\subset V_1$, so $V_2 \subsetneq V$ is also strict; symmetrically $V_1 \subsetneq V$), this yields polynomials
\begin{align*}
f_1 \in I(V_2) \setminus I(V_1), \qquad f_2 \in I(V_1) \setminus I(V_2).
\end{align*}
The choices are tailored: we want each $f_i$ to vanish on the \emph{other} component, but not on its own component. That asymmetry is exactly what makes the next steps work.
\textbf{Verifying $f_i \notin I(V)$.} Recall that $I(V_1 \cup V_2) = I(V_1) \cap I(V_2)$ (a polynomial vanishes on a union iff it vanishes on each component). So $I(V) = I(V_1) \cap I(V_2)$. If $f_1$ were in $I(V)$, it would in particular be in $I(V_1)$, contradicting our choice $f_1 \notin I(V_1)$. Similarly $f_2 \notin I(V)$.
\textbf{Verifying $f_1 f_2 \in I(V)$.} We must check that $(f_1 f_2)(p) = 0$ for every $p \in V = V_1 \cup V_2$. For each point we use only \emph{one} of the factors:
\begin{itemize}
\item If $p \in V_1$: $f_2 \in I(V_1)$ tells us $f_2(p) = 0$, so $(f_1 f_2)(p) = f_1(p) \cdot 0 = 0$.
\item If $p \in V_2$: $f_1 \in I(V_2)$ tells us $f_1(p) = 0$, so $(f_1 f_2)(p) = 0 \cdot f_2(p) = 0$.
\end{itemize}
Either way, the product vanishes. Since $V = V_1 \cup V_2$, every $p \in V$ falls into one of the two cases, and $f_1 f_2$ vanishes on all of $V$.
\textbf{Conclusion.} We have produced $f_1, f_2 \notin I(V)$ with $f_1 f_2 \in I(V)$. This is exactly the failure of the prime ideal axiom: a prime ideal $\mathfrak{p}$ satisfies $ab \in \mathfrak{p} \implies a \in \mathfrak{p} \text{ or } b \in \mathfrak{p}$. So $I(V)$ is not prime.
\textbf{Why do we need both witnesses?} A single witness $f \in I(V_1) \setminus I(V_2)$ gives no information: the product of $f$ with itself, $f^2$, vanishes wherever $f$ does, which is on $V_1$ but not necessarily on $V$. We genuinely need a \emph{pair}: one polynomial covering each component. The reducibility of $V$ provides exactly the structure to find such a pair.
[/guided]
[/step]
[step:Suppose $I(V)$ is not prime and decompose $V = V_1 \cup V_2$]
Suppose $I(V)$ is not prime. Since $V$ is a variety, $I(V)$ is a proper ideal of $k[X_1, \ldots, X_n]$ (it does not contain $1$, since $V$ is non-empty for a variety in our convention; more carefully, the empty variety has $I(\varnothing) = k[X_1, \ldots, X_n]$, which is conventionally not called prime). The negation of primality therefore gives polynomials
\begin{align*}
g_1, g_2 \in k[X_1, \ldots, X_n], \qquad g_1, g_2 \notin I(V), \qquad g_1 g_2 \in I(V).
\end{align*}
Define
\begin{align*}
V_i := V \cap V(g_i) = \{p \in V : g_i(p) = 0\}, \qquad i = 1, 2.
\end{align*}
Each $V_i$ is closed in $V$ (intersection of $V$ with the Zariski-closed set $V(g_i)$), and each $V_i \subset V$.
We claim each $V_i \subsetneq V$ is a strict subvariety. If $V_i = V$, then $g_i$ would vanish on every point of $V$, i.e. $g_i \in I(V)$, contradicting $g_i \notin I(V)$.
We claim $V = V_1 \cup V_2$. The inclusion $V_1 \cup V_2 \subset V$ is immediate from $V_i \subset V$. For the reverse: take any $p \in V$. Then $(g_1 g_2)(p) = 0$ since $g_1 g_2 \in I(V)$, i.e. $g_1(p) g_2(p) = 0$. Since $k$ is an integral domain (in fact a field), this forces $g_1(p) = 0$ or $g_2(p) = 0$, i.e. $p \in V(g_1)$ or $p \in V(g_2)$. Combined with $p \in V$, we get $p \in V_1$ or $p \in V_2$, hence $p \in V_1 \cup V_2$.
Thus $V$ is the union of two closed proper subvarieties, so $V$ is reducible.
[/step]
[step:Combine the two implications to conclude]
Step 2 showed: $V$ reducible $\implies$ $I(V)$ not prime, hence by contrapositive, $I(V)$ prime $\implies$ $V$ irreducible.
Step 3 showed: $I(V)$ not prime $\implies$ $V$ reducible, hence by contrapositive, $V$ irreducible $\implies$ $I(V)$ prime.
Combining,
\begin{align*}
V \text{ is irreducible} \iff I(V) \text{ is a prime ideal},
\end{align*}
which is the desired equivalence.
[/step]