Homework 3
Last updated: Mon, 10 Oct 2022 16:36:45 -0400
Out: Mon Oct 03, 00:00 EST Due: Sun Oct 09, 23:59 EST
This assignment explores regular expressions.
Homework Problems
Fun With Regular Expressions (5 points)
Practice: Proving An Operation Closed For Regular Languages (6 points)
Converting Strings To a Different Alphabet (4 + 4 = 8 points)
Caesar Cipher - Closed? (10 points)
README (1 point)
Total: 30 points
Submitting
Submit your solution to this assignment in Gradescope hw3. Please assign each page to the correct problem and make sure your solutions are legible.
A submission must also include a README containing the required information.
1 Fun With Regular Expressions
\left\{\texttt{aab},\texttt{abb}\right\}
\left\{x\mid x\textrm{ contains }\texttt{aaa}\textrm{ somewhere in the string }\right\}
\left\{x\mid x\textrm{ is a string that both starts and ends with \texttt{a}}\right\}
\left\{\varepsilon\right\}
\emptyset
If you wish, you may additionally use the following regular expression abbreviations:
\Sigma = any char in the alphabet of the language
\Sigma^* = zero or more of any char in the alphabet of the language
2 Practice: Proving An Operation Closed For Regular Languages
Show that the following operation, \mathrm{OP2}, is closed for regular languages:
\mathrm{OP2}(L) = \left\{w\mid L \textrm{ does not contain } w\right\}
3 Converting Strings To a Different Alphabet
Give a recursive definition of strings, with a base case and a recursive case. Make sure the recursive case has a reference to a "smaller" string.
You may assume that the strings are drawn from alphabet \Sigma.
If you are unsure how to proceed, look at the recursive definition examples, e.g., natural numbers, from lecture as a guide.
Say we have a function \mathrm{map}:\Sigma_1\rightarrow\Sigma_2 that maps characters in alphabet \Sigma_1 to characters in another alphabet \Sigma_2.
Define a function \mathrm{map}_{str} : \Sigma_1^* \rightarrow \Sigma_2^* that converts strings from alphabet \Sigma_1 to \Sigma_2.
The \mathrm{map}_{str} should be a recursive definition with a base case and recursive case, and should use the single-character \mathrm{map} conversion function.
Hint: You should use the recursive definition from the first part of this problem to help think about what this function looks like.
4 Caesar Cipher - Closed?
A Caesar cipher is a basic encryption algorithm.
It’s essence can be represented by the \mathrm{map} :\Sigma_1\rightarrow\Sigma_2 and \mathrm{map}_{str}:\Sigma_1^*\rightarrow\Sigma_2^* functions from problem Converting Strings To a Different Alphabet.
Now let’s extend the mapping to languages. Specifically, define a function \mathrm{map}_{lang}:
\mathrm{map}_{lang}(L) = \left\{\mathrm{map}_{str}(w)\mid w\in L\right\}
Prove that \mathrm{map}_{lang} is closed for regular languages.