\documentclass[11pt]{article}

\newcommand{\pset}{
    6
}
\newcommand{\subtitle}{
    Stack Automata
}
\newcommand{\duedate}{
    Friday, October 17
}

% 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!

\begin{problem}
    [Pop-Push]
    By induction on the length of the program, prove that every valid stack program is equivalent to either \(\mathtt{skip}\) or a program of the following form:
    \[
        \mathtt{pop}~\sigma_1 {.}
        \mathtt{pop}~\sigma_2 \dots
        \mathtt{pop}~\sigma_n {.}
        \mathtt{push}~\tau_1 {.}
        \mathtt{push}~\tau_2 \dots
        \mathtt{push}~\tau_m
        \qquad \text{(*)}
    \]
    for some \(n,m \in \mathbb N\).
\end{problem}

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

\begin{problem}
    [2 is better than 1]
    Consider the language 
    \[
        L = \{w \mid w = w^{\text{op}}\}
    \]
    in the alphabet \(A = \{a, b, c\}\).
    Design a stack automaton \(\mathcal S = (Q, A, \Sigma, \delta, F)\) with a state \(x\in Q\) such that \(L = \mathcal L(\mathcal S, x)\).
\end{problem}

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

\begin{problem}
    [Algorithmic Balancing]
    Let \(L\) be the set of balanced strings of brackets, where the bracket symbols are \(A = \{\mathtt{(}, \mathtt{)}, \mathtt{[}, \mathtt{]}, \mathtt{\{}, \mathtt{\}}\}\), from Balancing Act.
    In that problem, you designed a grammar with a variable that derives \(L\).
    \begin{enumerate}
        \item
            Use the Grammar-to-Automaton construction to design a stack automaton with a state that accepts \(L\).
        \item
            Can you think of a smaller stack automaton with a state that accepts \(L\)?
    \end{enumerate}
\end{problem}

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

\begin{problem}
    [Basic Stack Programs Unite]
    Fix a set of stack symbols \(\Sigma\).
    Let \(p_1,p_2,\dots, p_n \in \{\mathtt{push}~\sigma, \mathtt{pop}~\sigma \mid \sigma \in \Sigma\}\), i.e., let them be basic stack programs.
    Assume that \(p_1\dots p_i = \mathtt{skip}\) if and only if \(i = 0\) or \(i = n\). 
    Now prove that 
    \begin{enumerate}
        \item \(p_1 p_n = \mathtt{skip}\)
        \item \(p_2\dots p_{n-1} = \mathtt{skip}\)
    \end{enumerate}
\end{problem}

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

\begin{problem}
    [Intersection-product Construction]
    Prove the claim in the proof of the Intersecting with a Regular Language theorem.
\end{problem}

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

\begin{problem}
    [Comes in 3s]
    Consider the language 
    \[
        L = \{a^nb^n \mid n \in \mathbb{N} \text{ and } n = 3k + 1 \text{ for some \(k \in \mathbb N\)}\}
    \]
    \begin{enumerate}
        \item Use the Intersection-Product conctruction to design a stack automaton \(\mathcal S = (Q, A, \Sigma, \delta, F)\) with a state \(x\in Q\) such that \(L = \mathcal L(\mathcal S, x)\).
        \item Design a grammar \(\mathcal G = (X, A, R)\) with a variable that derives \(L\).
    \end{enumerate}
\end{problem}

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

\end{document}