\documentclass[12pt,ifthen]{article} \usepackage{url} \usepackage{comment} \newif{\ifshowsoln} % \showsolntrue \newcommand{\und}{\_\_\_\_\_\_\_\_\_} \newcommand{\Z}{\mathbb{Z}} \usepackage{amsmath} \usepackage{amssymb} % for \nmid \begin{document} \centerline{\bf CMSC452 Project -- Part 2. Morally Due April 22}. \centerline{\bf LEO is in charge of the Project. Any Questions Go To Him} \section{Intro} Consider the following two machines. The alphabet is $\Sigma=\{0,\ldots,9\}$ and the input is interpreted as numbers in base 10, reading them left to right. \begin{itemize} \item A DFA that {\it recognizes} $\{ w \colon w\equiv 0 \pmod 4 \}$ \item A DFA-classifier that reports what $w$ is congruent to mod 4. \end{itemize} If you found the min DFA for these two problems you would discover that the classifier uses {\it more} states than the recognizer. \\ \\ We wonder for which mods this happens. In the following assignment, you will write Python code that computes and outputs this difference. You have been provided with the DFAMin python program, that minimizes a DFA. \\ \\ In the package, observe that state names may be arbitrary, however, use a dictionary to store the transition function. It should follow the following format: for a transition from state $q$ on symbol $2$, the output $\delta(q, 2) = h$ is expressed as a dictionary entry \begin{verbatim} {(q, 2) : h} \end{verbatim} For clarification, read the code in the DFAMin.py file. \section{Assignment} \begin{enumerate} \item(0 points but you will need it for later questions) Write a program that, given $n$, outputs the DFA-classifier, $M$, for mod $n$. \\ \\ (This is done like in class: compute powers of 10 mod $n$ until you spot a pattern. You can assume the size of the pattern is $\le 100$. Also, note that this is minimized). \\ \item (0 points but you will need it for later questions) Write a program that, given $n$: \begin{enumerate} \item Runs the program that finds the DFA-classifier $M$. \item Takes the DFA classifier and makes it into a DFA $M'$ for $$\{ w \colon w\equiv 0 \pmod n \}$$ This is done by making all of the states in the classifier that report $\equiv 0 \pmod n$ into final states. \item Runs the MINIMIZER on it to get a MIN DFA for the recognizer. Let that be $M''$. \end{enumerate} \item (0 points but you will need it for later questions) Write a program that will, given $n_1,n_2$, computes the size of the DFA classifier, minimized DFA recognizer, and the difference between the two for mod $n_1,n_1+1,\ldots,n_2$ and put them into a table. Here is the kind of output we want if $n_1=7$ and $n_2=10$. The numbers are made up. \begin{tabular}{|l|l|l|l|} \hline $n$ & DFA Classifer & DFA Recognizer & Diff \cr \hline 7 & 42 & 42 & 0 \cr 8 & 12 & 10 & 2 \cr 9 & 9 & 3 & 6 \cr 10 & 12 & 12 & 0 \cr \hline \end{tabular} \\ \\ \item Run the program from your last item on $n_1=2,n_2=50$. \begin{enumerate} \item Present the output. \item Based on the data give a conjecture of the form If $n$ is XXX then Diff will be 0. (It NEED NOT be an iff statement). \item Based on the data give a conjecture of the form If $n$ is XXX then Diff will be at least 1. (It NEED NOT be an iff statement). \end{enumerate} \end{enumerate} \end{document}