\documentclass[11pt]{article}

\newcommand{\pset}{
    5
}
\newcommand{\subtitle}{
    From Nonregular Languages to Counter Automata
}
\newcommand{\duedate}{
    Friday, October 10
}

% Page Setup
\usepackage{geometry}
\geometry{
    a4paper,
    margin={2.5cm}
}

% Basic Packages
\usepackage{amssymb}
\usepackage{stmaryrd}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{mathtools}
\usepackage{mathpartir}
\usepackage{enumitem}
\usepackage{mathabx}

% Font
\usepackage{charter}

% Bibliography and index
\usepackage[backend=biber, style=numeric]{biblatex}
\addbibresource{refs.bib}
\usepackage{makeidx}
\makeindex

% Colors and Graphics
\usepackage[dvipsnames, x11names]{xcolor}
\usepackage{tikz}
\usetikzlibrary{
    cd,
    fit,
    calc,
    positioning,
    arrows,
    automata,
    shapes
}
\tikzset{
    baseline = (current bounding box.center),
    every state/.append style = {
        rectangle,
        rounded corners=5pt,
		inner sep = 3pt,
		minimum size = 18pt,
		initial text = {},
        fill=Azure1
	},
	every edge/.append style = {
		->,
		>=stealth,
		bend angle=10,
		thick
	}
}
\usepackage{musicography}
\usepackage{graphicx}
\usepackage{svg}
\graphicspath{../imgs/}

% Hyperlinks
\usepackage{hyperref}
\hypersetup{
    colorlinks,
    linkcolor   = black,
    filecolor   = RubineRed,
    urlcolor    = RubineRed,
    citecolor   = RubineRed,
    pdftitle    = {CSCI 341 Course Materials}
}
\usepackage[capitalize]{cleveref}

% Environments
\theoremstyle{theorem} % In Italics
\newtheorem{theorem}                    {{\color{Purple}Theorem}}[section]
\newtheorem{lemma}          [theorem]   {{\color{Magenta}Lemma}}
\newtheorem{proposition}    [theorem]   {Proposition}
\newtheorem{corollary}      [theorem]   {Corollary}
\newtheorem{question}                   {{\color{red}Question}}

\theoremstyle{definition} % Not in italics
\newtheorem{definition}     [theorem]   {{\color{NavyBlue}Definition}}
\newtheorem{example}        [theorem]   {{\color{ForestGreen}Example}}
\newtheorem{problem}                    {{\color{BurntOrange}Problem}}

\theoremstyle{remark} % Subdued label
\newtheorem{remark}[theorem]        {{\color{Gray}Remark}}

% (1), (2), ...
\renewcommand\labelenumi{(\theenumi)}

% Go nuts with line breaks 
\allowdisplaybreaks

%%%%%%%%%%
% MACROS %
%%%%%%%%%%

\newcommand{\op}{\mathrm{op}}               % Opposite
\newcommand{\inv}{{-1}}                     % Inverse
\newcommand{\id}{\mathsf{id}}               % Identity f(x) = x
\newcommand{\Det}{\mathrm{Det}}             % determinize
\newcommand{\Lang}{\mathcal{L}}             % Language

\newcommand{\incl}{\mathsf{incl}}           % Inclusion
\newcommand{\proj}{\mathsf{proj}}           % Projection

% Numbers and Standard notation
\newcommand{\NN}{\mathbb{N}}                % 0, 1, 2, 3, 4, ...
\newcommand{\ZZ}{\mathbb{Z}}                % ..., -2, -1, 0, 1, 2, ...
\newcommand{\QQ}{\mathbb{Q}}                % n/m for n and m in \NN and m > 0
\newcommand{\RR}{\mathbb{R}}                % real numbers
\newcommand{\pRR}{\mathbb{R}_{+}}           % positive real numbers

\newcommand{\dom}{\mathrm{dom}}             % Domain
\newcommand{\cod}{\mathrm{cod}}             % Codomain

\newcommand{\Grph}{\operatorname{Grph}}     % Graph of a function

% Transitions
\newcommand{\tr}[1]{
    \mathrel{
        \raisebox{-1pt}{
            \(\xrightarrow{#1}\)
        }
    }
}
\newcommand{\bisim}{\mathrel{\raisebox{1pt}{\(\underline{\leftrightarrow}\)}}}

% Text
\newcommand{\code}[1]{\texttt{#1}}
\newcommand{\codeblock}[1]{
    \begin{center}
        \parbox{0.8\textwidth}{
            \ttfamily
            #1
        }
    \end{center}
}

% Boolean statements
\newcommand{\OR}{~\mathrm{or}~}
\newcommand{\AND}{~\mathrm{and}~}
\newcommand{\NOT}{\mathrm{not}~}
\newcommand{\IMPLIES}{~\mathrm{implies}~}
\newcommand{\FORALL}{\mathrm{for\ all}~}
\newcommand{\EXISTS}{\mathrm{there\ exists}~}
\newcommand{\SUCHTHAT}{~\mathrm{such\ that}~}



% Title
\title{CSCI 341 Problem Set \pset}
\author{\subtitle}
\date{Due
    \duedate
}

\begin{document}

\maketitle

Don't forget to check the webspace for hints and additional context for each problem!

\subsection*{Pumping Lengths}

\begin{problem}
    [NOT THE Bs]
    Show that the following language is not regular. 
    \[
        L = \{a^nb^m \mid n \in \mathbb N \text{ and } n > m\}
    \]
\end{problem}

\begin{proof}[Solution.]
    
\end{proof}

\subsection*{Context-free Grammars}

\begin{problem}
    [Balancing Act]
    Recall that a string of parentheses is \emph{balanced} if every left parenthese \(\mathtt{(}\) is eventually followed by a right parenthese \(\mathtt{)}\). 
    But things get more complicated when there are other alternatives to parentheses: what about square brackets? Or curly ones?
    If we take \[
        A = \big\{ \mathtt{(}, \mathtt{)}, \mathtt{[}, \mathtt{]}, \mathtt{\{}, \mathtt{\}}, \mathtt{\langle}, \mathtt{\rangle}  \big\}
    \]
    then we say that a string of brackets \(w \in A^*\) is \emph{balanced} if every left bracket of a given type is eventually followed by a right bracket of the same type, without being interrupted by an unmatched right bracket of a different type. 
    For example, these are all balanced:
    \[
        \mathtt{ 
            \{()\}()
            \qquad
            [] 
            \qquad
            [()\langle()\rangle] 
            \qquad
            [()\{()\}] 
        }
        \hspace{4em}\text{(*)}
    \]
    but these are not: 
    \[
        \mathtt{ 
            ([)] \qquad
            \{()()
            \qquad
            ] 
            \qquad
            \langle[()()\rangle] 
            \qquad
            [()\{(\})] 
        }
    \]
    Let \(L \subseteq A^*\) be the language of balanced strings of brackets.
    \begin{enumerate}
        \item Write down a grammar \(\mathcal G = (X, A, R)\) with a variable that generates \(L\), i.e., for some \(x \in X\), \(\mathcal L(\mathcal G, x) = L\).
        \item Use your grammar to derive each of the words in (*).
        \item Describe what prevents each of the words in (**) from being derivable from your grammar \(\mathcal G\).
    \end{enumerate}
\end{problem}

\begin{proof}
    [Solution.]
\end{proof}

\begin{problem}
    [Arithmetic is Not Regular]
    Prove that the language of arithmetic expressions \(\mathit{ArExp} \subseteq A^*\), derived from \(E\) in the grammar \(\mathcal G = (X, A, R)\) below
    \[\begin{aligned}
        E &\to 
            N
            \mid (E + E)
            \mid (E \times E)
            \mid (E - E)
            \mid (E / E) \\
        N &\to 0 \mid 1 \mid 2 \mid 3 \mid 4 \mid 5 \mid 6 \mid 7 \mid 8 \mid 9 \mid NN
    \end{aligned}\]
    where the alphabet is
    \[
        A = \big\{ (, ), +, \times, -, /, 0,1,2,3,4,5,6,7,8,9 \big\}
    \]
    is not regular. 
\end{problem}

\begin{proof}
    [Solution.]
\end{proof}

\subsection*{Parse Trees}

\begin{problem}
    [Left on Your Own]
    Let \(\mathcal G\) be a grammar with a variable \(x\), and let \(w \in A^*\).
    Prove that if \(w\) has a derivation from \(x\), then \(w\) has a left-most derivation from \(x\).
\end{problem}

\begin{proof}
    [Solution.]
\end{proof}

\subsection*{Counter Automata}

\begin{problem}
    [Cats \(>\) Dogs]
    Let \(A = \{c, a, t, d, o, g\}\). 
    Design an integer-counter automaton with a state \(x\) that accepts the language \(L_{cat}\) of all words \(w \in A^*\) such that the string "\(cat\)" appears in \(w\) more times than "\(dog\)" appears in \(w\).
\end{problem}

\end{document}