\documentclass[11pt]{article}

\usepackage{exscale}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{latexsym}
\usepackage{times,mathptm}
\usepackage{epsfig}
\usepackage{amsmath}

\textwidth 6.5truein          
\textheight 9.0truein
\oddsidemargin 0.0in
\topmargin -0.8in

\parindent 0pt          
\parskip 0pt
%\def\baselinestretch{1.1}

\begin{document}

\begin{large}
\centerline {\bf Computer Science 423}
\centerline {\bf Fall 2025}
\centerline {\bf Homework 5}
\centerline{\bf My name and section}
%\end{large}
\vskip .5cm

%\begin{Large}
\bf Due: Friday, 10/10/2025 11:59 p.m. \hfill Points: 40
\end{large}
\vskip 0.3cm
Answer the following questions and submit typeset solutions by the due date.  As stated on the syllabus, any collaborators or 
outside sources must be listed under the corresponding problem.  Further, your final submission must be completely your own work.
\begin{enumerate}


\item {[3 points each]}  Let $L=(a^{2n}b^n\ |\ n\ge0\}$.
\begin{enumerate}
\item Show that $L$ is context-free by giving its CFG (using just one variable $S$).
\item Show that $L^2$ is context-free by giving its CFG (using two variables $S$ and $T$).
\item Show that $L^4$ is context-free by giving its CFG (using variables $S$ and $T$).
\item Show that $L^*$ is context-free by giving its CFG (using $S$ and $T$).
\end{enumerate}

Collaborators:

\item {[4 points]} Give a simple description in one sentence for the language generated by the following grammar $G$.  (Hint:
Part of your description can mention strings $G$ cannot produce.)
\begin{eqnarray*}
S&\rightarrow& aSb\ |\ bY\ | \ Ya\\
Y&\rightarrow& bY\ |\ aY\ |\ \epsilon
\end{eqnarray*}

Collaborators:


\item {[8 points]} Give CFGs for the following languages.

\begin{enumerate}

\item {[3 points]} $B=\{w\in\{a, b\}^+\ |\ w $ begins and ends with the same symbol $\}$.

\item {[5 points]} $C=\{a^ib^jc^k\in \{a, b, c\}^*\ |\ |i-j|=k\}$. Note: $|x|$ is the absolute value of $x$

(Hint: Consider two cases: $i\ge j$ and $i<j$. Define $B$ as the union of two languages, corresponding to the two cases, respectively. 
Then start the CFG with $S\rightarrow S_1\ |\ S_2$.)

\end{enumerate}

Collaborators:

\item {[16 points]} Consider the language $F=\{a^ib^jc^k\ |\ i, j, k\ge0 {\rm\ and\ if\ }i=1{\rm\ then\ }j=k\}$.
\begin{enumerate}
\item {[3 points]} Define $F$ as a union of three disjoint languages, $F_0, F_1, F_2$, respectively corresponding to the value/range of $i$, i.e., $i=0$, $i=1$, and $i\ge2$.
\item {[3 points]} For $F_0, F_1, F_2$, answer the simple question whether they are regular, or non-regular but context-free.
\item {[3 points]} Prove that $F$ is not regular by contradiction and closure properties.
\item {[3 points]} Construct a context-free grammar for $F$, based on your answer to (a). Start the grammar with $S\rightarrow S_1\ |\ S_2\ |\ S_3$
\end{enumerate}


Collaborators:

\end{enumerate}

\end{document}
