Consider a product of automatons where each state is a pair of states in the first and second automaton and every transition works if it was applied to both elements in pair.
\vspace{2mm}
For union, we call the state $(s_1, s_2)$ accepting if $s_1$ OR $s_2$ is accepting in their respective automaton.
\vspace{2mm}
For intersection, we call it accepting if $s_1$ AND $s_2$ are accepting in their respective automaton.
\end{solution}
\vfill
\pagebreak
\theorem{Pumping Lemma}
Let $A$ be a regular language. \par
There then exists a number $p$, called the \textit{pumping length}, so that any string $s \in A$ of length at least $p$ may be divided into three pieces $s = xyz$ satisfying the following:
\begin{itemize}
\item$|y| > 0$\tab~\tab\hint{In other words, the segment $y$ is not the empty string.}
\item$|xy| \leq p$. \tab~\tab\hint{$|s|$ is the length of a string.}
\item$\forall i > 0$, $x y^i z \in A$\tab\hint{$y^i$ means that $y$ is repeated $i$ times. $y^0$ is the empty string.}
\end{itemize}
When $s$ is divided into $xyz$, either $x$ or $z$ may be the empty string, but $y$ must not be empty. \par
Notice that without the first condition, this theorem is trivially true.
\vspace{2mm}
In english, the pumping lemma states that in any regular language, any string of sufficient length contains a substring that can be \say{pumped} (or repeated) to generate more strings in that language.
\problem{}
Check that the pumping lemma holds with $p =3$ for the following DFA. \par
\hint{This is the same DFA as in \ref{fibonacci}. What kind of strings does it accept?}
How can we use the pumping lemma to show that a language is \textbf{not} regular?
\vfill
%\part{b} Suppose that there is a regular language $L$ in the alphabet $\{a\}$. $L$ contains all strings of $a$'s whose length is some set $S$. Derive from the pumping lemma that if $S$ is infinite then it contains some arithmetic progression.
% \part{c} Prove directly that if $S$ is infinite, than it contains some arithmetic progression. \textit{Hint: look at the first cycle in the DFA you get while reading $aaa\dots$.}
\hint{Look at the first cycle in the DFA you get while reading $s$.}
\begin{solution}
Look at the first place where we come to an already visited state while reading the word. Say the first time we came to this state after reading $x$ and the second time after reading $xy$. Then $y$ doesn't move us from this state and we can omit it or repeat any number of times we want.
\end{solution}
\vfill
\pagebreak
\problem{}
Show that the following languages are not regular: \par
\begin{enumerate}[itemsep=2mm]
% \item $\{a^{n^2}\}$, the language of all strings over the alphabet $\{a\}$ which have a square length. \par
\item$\{0^n1^n ~|~ n \in\mathbb{Z}^+_0\}$ over $\{0, 1\}$, which is the shorthand for the set $\{\varepsilon, 01, 0011, \dots\}$
\item The language ADD over the alphabet $\Sigma=\{0, 1, +, =\}$ where \par
$\text{ADD}=\{ ~ \text{\say{x=y+z}} ~|~ x, y, z ~ \text{are binary integers, and $x$ is the sum of $y$ and $z$}\}$
\item The language of all palindromes over the english alphabet
\end{enumerate}
\begin{solution}
% \textbf{Part A:} \par
% Follows from parts b-c of the previous problem;
% \vspace{2mm}
\textbf{Part A:}\par
Assume this language is regular. Let $p$ be the pumping length. The string $0^p1^p$ must then be accepted, implying that the string $0^{p-|y|}1^p$ (or $0^{p+|y|}1^p$) is also accepted.
\vspace{2mm}
\textbf{Part B:}\par
By pumping $10^{p+1}=10^p+10^p$
\vspace{2mm}
\textbf{Part C:}\par
By pumping $a^pba^p$
\end{solution}
\vfill
\pagebreak
\definition{}
Let $w$ be a string over an alphabet $A$. \par
If $a \in A$, $|w|_a$ is the number of times the letter $a$ occurs in $w$.
\vspace{2mm}
For the following problems, we will use the alphabet $\{a, b\}$.
\problem{}
Show that the language $L_p =\Bigl\{w ~\Bigl|~ \text{$p$ divides } |w|_a - |w|_b \Bigr\}$ is regular for any prime $p$.
\vfill
\problem{}
Show that $L =\Bigl\{ w ~\Big|~ |w|_a - |w|_b =\pm1\Bigr\}$ is not regular.