On this page:
1 A Data Representation for NFAs
2 NFAs and the Language They Recognize
3 The Union Operation, on NFAs
4 NFA -> DFA (Optional Bonus)
5 NFAs vs DFAs

Homework 3

Last updated: Fri, 19 Feb 2021 13:53:13 -0500

Out: Mon Feb 15, 00:00 EST Due: Sun Feb 21, 23:59 EST

This assignment explores non-deterministic finite automata (NFAs) using code.

Homework Problems

  1. A Data Representation for NFAs (4 points, 3 manually graded)

  2. NFAs and the Language They Recognize (5 points)

  3. The Union Operation, on NFAs (4 points)

  4. NFA -> DFA (Optional Bonus) (5 points)

  5. NFAs vs DFAs (6 points) (NOTE: This is a non-coding problem.)

  6. README (1 point)

Total: 20 points (+ 5 bonus points)

Submitting

Submit the solution to this assignment in Gradescope hw3.

A submission must include the following files (NOTE: everything is case-sensitive):

1 A Data Representation for NFAs

Recall Definition 1.37 from the book. An NFA is a 5-tuple (Q,\Sigma,\delta,q_0,F), where:
  • Q is a finite set of states,

  • \Sigma is a finite alphabet,

  • \delta:Q\times\Sigma_\epsilon\rightarrow \mathcal{P}(Q) is the transition function mapping a state and a (possibly empty string) input to a set of states,

  • q_0\in Q is the start state, and

  • F\subseteq Q is the set of accept states.

It’s nearly identical to the definition for DFAs, except for the transition function.

Your Tasks

  1. Design a data representation for this formal definition of NFAs. You may use objects, structs, or anything else available in your language.

  2. Write up an informal description of your chosen representation in a section of your README, labeled NFA Data Representation.

  3. Implement your data representation in your chosen language.

2 NFAs and the Language They Recognize

This problem asks to demonstrate that you understand computation with NFAs.

The language that an NFA recognizes is the set of all strings accepted by the NFA.

Your Tasks

Your solution will be tested as follows:

3 The Union Operation, on NFAs

This problem asks you to demonstrate that you understand the NFA-based proof showing that the union operation is closed for regular languages.

Your Task

Implement the union operation for NFAs. It should be much easier than the DFA version.

Specifically, write a function that, given:

  • an NFA recognizing language A_1, and

  • an NFA recognizing language A_2

returns an NFA recognizing A_1 \cup A_2.

To do this, you’ll need to be able to extract individual components of an NFA instance, e.g., the states, transitions, etc., and use them to create a new NFA.

HINTS:

Your solution will be tested as follows:

4 NFA -> DFA (Optional Bonus)

This problem asks you to demonstrate that you understand the proof of Theorem 1.39.

In other words, implement a function or method that converts an NFA from the A Data Representation for NFAs problem to a DFA (from Homework 1, A Data Representation for DFAs problem).

Your solution should emit a DFA automaton XML element. The solution from HW2 will be useful here: use the solution from DFA->XML to write the XML output, and use the solution from DFAs and the Language They Recognize to check that your output is actually a valid DFA.

Your solution will be tested as follows:

5 NFAs vs DFAs

Give a proof of the following theorem:

For any language A, some DFA M recognizes A

if and only if some NFA N recognizes A.

You may assume the theorem from NFA -> DFA (Optional Bonus)

You may write up your proof in any way but the submission must be either a pdf or plain text. Also, make sure you assign it to the proper problem in gradescope when submitting.