[guided]The structure of this decidability proof is the standard pattern for reducing a question about an infinite set (*is there any word in this possibly-infinite language?*) to a question about a finite, explicitly enumerable set (*is there a word of bounded length in this language?*). Three ingredients are doing the work.
*First ingredient: an effective representation.* The regular grammar $G$ has a finite description, and that description can be mechanically transformed into a deterministic automaton $D$ with the same language. This is where [Regular Grammars Produce Nondeterministic Automata](/theorems/1792) and the subset construction [Nondeterministic and Deterministic Automata Are Equivalent](/theorems/1791) matter: they are not just existence statements but *constructions* — given the data of $G$, we write down the data of $D$ explicitly. Without effective constructions, we could not run the algorithm on specific inputs.
*Second ingredient: a length bound.* The short-word theorem [Nonempty Regular Languages Contain Short Words](/theorems/1794) is what makes the search finite. Absent this theorem, emptiness might still be decidable (indeed it is for regular languages by other routes), but we would have no obvious finite search space. The pumping lemma provides a *witness shrinker*: any word in $\mathcal{L}(G)$ can be pumped down until its length drops below $n$. So the existence of *some* element is equivalent to the existence of a *short* element, and short elements come from a finite alphabet lying in a bounded-length universe.
*Third ingredient: a membership decider.* Even with a finite search space, we must be able to check each candidate. For regular languages this is trivial — simulate the DFA — but the step is not a priori free; it requires a decidable membership problem. For context-free languages, say, the search space analogue exists (context-free pumping), and membership is decidable (the CYK algorithm), so emptiness is likewise decidable. For context-sensitive or Type-0 languages the analogue breaks down: membership is undecidable for Type-0 grammars and PSPACE-hard for context-sensitive, and emptiness is undecidable for Type-0.
*Why $n = |Q|$ suffices as a pumping number.* The pumping lemma proved in [Pumping Lemma for Regular Languages](/theorems/1793) specifically uses $n = |Q|$ because any run of $D$ on a word of length $\geq n$ visits $n + 1$ states in a set of size $n$, forcing a repetition (pigeonhole). So the pumping number is tight to the number of states of the deterministic automaton, not a loose constant. This gives us a concrete, computable bound.
*Why not search over $\Sigma^\star$ naively?* If one tried to decide emptiness by enumerating all words of $\Sigma^\star$ and checking each, the procedure would fail when $\mathcal{L}(G) = \varnothing$: it would enumerate forever without finding a witness, never halting. The pumping-lemma bound converts this semi-decision procedure into a full decision procedure by cutting off the search at length $n - 1$. If *any* word in $\mathcal{L}(G)$ exists, there exists one of length $< n$; if no word of length $< n$ is in $\mathcal{L}(G)$, we can be confident that no word of any length is, and output "empty" safely.
*Complexity observation.* The algorithm runs in time roughly $|S_{<n}| \cdot n \leq n \cdot |\Sigma|^{n-1} \cdot n = n^2 \cdot |\Sigma|^{n-1}$, which is exponential in $n$. This is not the best bound — one can decide emptiness of a DFA in linear time by computing the set of states reachable from $q_0$ and checking whether it meets $F$. But the exponential bound suffices for decidability, which is the point here.[/guided]