On this page:
1 Practice:   Another Operation on a Language
2 Regular Expression Exercises
3 Proof by Induction Exercise
4 Proof by Induction Involving Regular Expressions

Homework 4

Last updated: Mon, 8 May 2023 10:27:28 -0400

Out: Mon Oct 03, 00:00 EST Due: Sun Oct 09, 23:59 EST

This assignment explores regular expressions, and proof by induction.

Homework Problems

  1. Practice: Another Operation on a Language (5 points)

  2. Regular Expression Exercises (6 points)

  3. Proof by Induction Exercise (8 points)

  4. Proof by Induction Involving Regular Expressions (6 + 9 = 15 points)

  5. README (1 point)

Total: 35 points

Submitting

Submit your solution to this assignment in Gradescope hw4. 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 Practice: Another Operation on a Language

Define the following operation on languages, \mathrm{OP3}, to be:

2023-03-03: To reduce potential confusion, the variable names on the right-hand side of the definition of \mathrm{OP3} have been changed from a and b to x and y, so as not overlap with characters in the alphabet. The essence of the problem, however, is unchanged.

\mathrm{OP3}(L) = \left\{x\mid xy \in L, y\in \Sigma^*\right\}

Give the result of applying \mathrm{OP3} on the following languages (assume strings in the language are created with characters from some alphabet \Sigma = \left\{\texttt{a},\texttt{b},\texttt{c}\right\}):

2 Regular Expression Exercises

Come up with regular expressions for the following languages (whose strings use alphabet \Sigma = \left\{\texttt{a},\texttt{b}, \texttt{c}, \texttt{\$}\right\}):
  1. \left\{w\mid w\textrm{ contains the special character }\texttt{\$}\textrm{ somewhere in the string }\right\}

  2. \left\{\texttt{a},\texttt{b}, \texttt{c}\right\}

  3. \left\{\texttt{a},\texttt{b}\right\}\cap \left\{\texttt{\$}, \texttt{c}\right\}

  4. Any string in the set \left\{\texttt{aa}, \texttt{bb}, \texttt{cc}\right\}, repeated zero times

  5. The set of strings that are at least three characters long

  6. The set of strings that either contain the \texttt{\$} special char, or are at least three characters long (it may be easiet to assign your previous answers to variables and use those variables here).

If you wish, you may additionally use the following regular expression abbreviations:

3 Proof by Induction Exercise

Remember that a "proof by induction" is just a proof that involves a recursive definition.

Further, the structure of the proof should exactly follow the structure of the recursive definition.

In this problem, use proof by induction to prove a basic logarithmic identity that you likely learned in algebra class:

\log x^y = y\log x

Specifically, prove that this equality is true for all natural number values of y.

Make sure your proof:
  • clearly states that it is a proof by induction,

  • clearly states the specific "thing" that the induction is "on",

  • has a base case, which must follow the recursive definition of the "thing",

  • has a recursive case, that again must follow the recursive definition,

  • declares an inductive hypothesis, which is an assumption that uses the "smaller" self-reference from the recursive case in the definition,

  • and uses the inductive hypothesis in the proof of the recursive case.

If you need it, your proof may use another logarithmic identity as a known fact: \log ab = \log a + \log b

4 Proof by Induction Involving Regular Expressions

In lecture, when proving the statement:

\textrm{A language } L\textrm{ is a regular language } \textrm{ if and only if } \textrm{ there is a regular expression that describes } L

specifically, in the proof of the reverse direction, we sketched out a conversion function, call it \texttt{RE2NFA}, that given any regular expression as input, converts it to an equivalent NFA.

For this problem, you must do two things:

  1. Write out the full, recursive definition of the \texttt{RE2NFA} function. Its cases and recursive parts should exactly follow the cases and recursive parts in the formal definition of regular expressions.

    Further, if you need to write out an NFA, it should be a formal description. (You may assume that the alphabet of L is \Sigma.) Finally, you may assume and use in your definition additional functions \texttt{UNION}_\textsf{NFA}, \texttt{CONCAT}_\textsf{NFA}, and \texttt{STAR}_\textsf{NFA}, which correspond to the NFA combination operations we defined together in lecture when proving that these operations are closed.

  2. Prove that the conversion performed by \texttt{RE2NFA} "correct".

    Specifically, answer the following questions:

    1. When we say that two things (e.g., a regular expression and an NFA) are "equivalent" in this course, what does this mean?

    2. Now, given a meaning for "equivalent", we can say that the conversion function \texttt{RE2NFA} is "correct" if its input and output are "equivalent". Give a formal (equality) statement for this notion of "correctness".

    3. Prove the statement that you came up with. The proof should be a proof by induction on regular expressions (make sure to say which one). Thus, the proof needs to follow the recursive definition of regular expressions and should have 6 parts: 3 base cases and 3 recursive cases. Make sure that each recursive case declares and uses an inductive hypothesis assumption.