Homework 3
Last updated: Tue, 15 Feb 2022 19:57:42 -0500
Out: Mon Feb 14, 00:00 EST Due: Sun Feb 20, 23:59 EST
This assignment explores regular expressions.
Homework Problems
Fun With Regular Expressions (5 points)
Fun With Induction (6 points)
Reversing Strings (4 6 points)
Another Closed Operation (10 points)
README (1 point)
Total: 26 28 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\{\right\}
\left\{\varepsilon\right\}
\left\{\texttt{xy},\texttt{yz}\right\}
\left\{w\mid w\textrm{ contains the substring }\texttt{xyz}\right\}
\left\{w\mid w\textrm{ is a string that starts and ends with the same symbol}\right\}
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 Fun With Induction
Prove that the following statement is true, for z\neq 1:
\sum_{i=0}^m z^i=\frac{1-z^{m+1}}{1-z}
Use induction on one of the natural numbers in the equation.
which value the induction is "on",
base case(s),
and inductive case(s) (where each includes an inductive hypothesis)
the subgoal that needs to be proved in that case,
and a proof of that subgoal that is a step-by-step derivation, starting from a known definition or theorem, and ending in the desired goal, along with a justification for why each step is valid.
3 Reversing Strings
This problem has two parts:
This part added on Tues 2/15
NEW: Give a recursive definition of strings, with a base case and a recursive case.If you are unsure how to proceed, look at the recursive definition of natural numbers from lecture as a guide.
Define a function \mathrm{rev} for reversing strings.
For example \mathrm{rev}(\texttt{abc}) = \texttt{cba}
Your function should be a recursive definition with a base case and recursive case.
UPDATE: Your recursive definition from the first part above should dictate what the structure of this function looks like.
4 Another Closed Operation
Show that the following operation, \mathrm{REV}, is closed for regular languages:
\mathrm{REV}(A) = \left\{w\mid w = \mathrm{rev}(x),\textrm{ for some }x\in A\right\}
Use regular expressions and proof by induction.