\documentclass[11pt]{article}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{hyperref}
\usepackage[margin=1in]{geometry}
\setlength{\parindent}{0pt}
\setlength{\parskip}{1em}

\usepackage{syntax}
% tikz package and associated configuration for drawing automata
\usepackage{tikz}
\usetikzlibrary{automata, positioning, arrows}
\tikzset{
->, % makes the edges directed
>=stealth', % makes the arrow heads bold
node distance=3cm, % specifies the minimum distance between two nodes. Change if necessary.
every state/.style={thick, fill=gray!10}, % sets the properties for each ’state’ node
initial text=$ $, % sets the text that appears on the start arrow
}

\title{CSCI 301 - Assignment 8, Fall 2024}
\author{Your name here}
\date{}

\newcommand{\answer}{%
  \par\noindent%
  \textbf{Answer\\}%
}

\newcommand{\inlineanswer}{%
  \hspace{1em} \textbf{Answer:} %
}

\begin{document}

\maketitle

Modify the .tex source file for this document, adding your answers below each question.
This is an individual assignment. See the syllabus for the collaboration policy. 

\begin{enumerate}

    \item (5 points) Prove that the language $L_1 = \{a^nb^{n+2} : n \ge 0\}$ is context-free by
giving a context-free grammar for $L_1$.

% Here's an example of how to typset a grammar: 
%\begin{align*}
%    S &\rightarrow A \mid \epsilon\\
%    A &\rightarrow B \mid t\\
%    B &\rightarrow v\\
%\end{align*}

\item (5 points) Prove that the language $L_2 = \{a^ib^jc^k : (i , j, k \ge 0) \land (i = j \lor j = k)\}$ is context-free by
constructing a context-free grammar for $L_2$.

\item (10 points) Consider the grammar $S \rightarrow S(S)S \mid \epsilon$.
    \begin{enumerate}
        \item (2 points) Give a leftmost derivation for the string $(()())$.
        \item (3 points) Prove that the grammar is ambiguous.
        \item (2 points) Compute $FIRST(S)$.
        \item (3 points) An LL(1) parse table for the above grammar would have the following form:

            \begin{tabular}{r|c|c|c}
                               & $($          &   $)$         & $\$$         \\\hline
                $S\rightarrow$ & \hspace{3em} &  \hspace{3em} & \hspace{3em} \\
            \end{tabular}\\

            Give a correct LL(1) parse table for this grammar, or explain why one does not exist.

            
    \end{enumerate}

\end{enumerate}

\end{document}

