Let $L_1$ be a context-free language and $L_2$ be a regular language. Then $L_1 \cap L_2$ is context-free.
Part of a proof given in the book "Formal languages and automata": Let $M_{1}=\left(Q, \Sigma, \Gamma, \delta_{1}, q_{0}, z, F_{1}\right)$ be an npda that accepts $L_1$, $M_{2}=\left(P, \Sigma, \delta_{2}, p_{0}, F_{2}\right)$ be a dfa that accepts $\mathrm{L}_{2}$. We construct a push-down automaton $\widehat{M}=\left(\widehat{Q}, \Sigma, \Gamma, \widehat{\delta}, \widehat{q_{0}}, z, \widehat{F}\right)$ that simulates the parallel action of $M_{1}$ and $M_{2}$ : Whenever a symbol is read from the input string, $\widehat{M}$ simultaneously executes the moves of $M_{1}$ and $M_{2}$. To this end we let $$ \begin{aligned} \widehat{Q} &=Q \times P \\ \widehat{q_{0}} &=\left(q_{0}, p_{0}\right), \\ \widehat{F} &=F_{1} \times F_{2}, \end{aligned} $$ and define $\widehat{\delta}$ such that $$ \left(\left(q_{k}, p_{l}\right), x\right) \in \widehat{\delta}\left(\left(q_{i}, p_{j}\right), a, b\right) $$ if and only if $$ \left(q_{k}, x\right) \in \delta_{1}\left(q_{i}, a, b\right) $$ and $$ \delta_{2}\left(p_{j}, a\right)=p_{l} . $$ In this, we also require that if $a=\lambda$, then $p_{j}=\mathrm{p}_{1}$. In other words, the states of $\widehat{M}$ are labeled with pairs $\left(q_{i}, p_{j}\right)$, representing the respective states in which $\mathrm{M}_{1}$ and $M_{2}$ can be after reading a certain input string. It is a straightforward induction argument to show that $$ \left(\left(q_{0}, p_{0}\right), w, z\right) \vdash_{\widehat{M}}^{*}\left(\left(q_{r}, p_{s}\right), \lambda, x\right), $$ with $q_{r} \in F_{1}$ and $p_{s} \in F_{2}$ if and only if $$ \left(q_{0}, w, z\right) \vdash_{M_{1}}^{*}\left(q_{r}, \lambda, x\right), $$ and $$ \delta^{*}\left(p_{0}, w\right)=p_{s} $$
Now, my question: I am not really sure how to do that "straightforward induction". I thought to do an induction on the length of the string, with the base case being 0. The base case means that we have lambda as our word. For the induction step I thought of assuming that it holds for strings of length n, and proving for strings of length n + 1. Do I have to prove it in both directions separately, or can I do both directions at once? Could someone help me write formally down why this statement is true, even though it seems quite straightforward?
For the base case, we have 0 steps. The proof just follows from the definition of what 0 steps actually is (doing nothing).
For the inductive case: We say that the statement holds for steps of length n, and proof for steps of length n + 1. We should not say anything about the length of the strings, so they could be of length 0 or longer. From the induction hypotheses we have everything done and have 1 step left. This step is proven by the definition of $\widehat{\delta}$. For the DFA, I made the distinction between lambda-transition and actually consuming a letter.