\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 7, 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. 

Any finite automata you draw should be drawn in \LaTeX{} using Tikz. Please see
A6 for guidance and examples.\\

\begin{enumerate}

    \item (5 points) Give a regular expression describing each of the following languages over $\Sigma = \{0, 1\}$:
        \begin{enumerate}
            \item $\{w : \text{ the first and last symbols of $w$ are not equal}\} $
            \item $\{w: w \text{ has an even number of $1$'s}\}$
        \end{enumerate}

    \item (5 points) Design an NFA that accepts the language described by the regular expression $((0 \cup 1)(11)^* \cup 0)^*$.

    \item (5 points) Prove that the language $\{\epsilon, 0, 1, 00, 11, 000, 111, 0000, 1111, \ldots\}$ is regular.

    \item (5 points) Give a regular expression that describes the language accepted by the following DFA:

    \begin{center}
    \begin{tikzpicture}
    \node[state, initial, accepting] (s1) {1};
    \node[state, right of=s1] (s2) {2};
    \node[state, below right of=s1] at (-0.5, 0) (s3) {3};
    \draw (s1) edge[loop above] node{a} (s1)
          (s1) edge[above] node{$b$} (s2)
          (s2) edge[loop above] node{b} (s2)
          (s2) edge[left] node{a} (s3)
          (s3) edge[loop below] node{a} (s3)
          (s3) edge[left] node{$b$} (s1)
    ;
    \end{tikzpicture}
    \end{center}


\end{enumerate}

\end{document}

