On this page:
1 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 2

Last updated: Wed, 7 Oct 2020 12:06:42 -0400

Out: Wed Sept 23, 00:00 EST Due: Tues Sept 29, 23:59 EST

This assignment involves non-deterministic finite automata (NFAs).

Homework Problems

  1. 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

Submitting

Note: This assignment has a non-code component, see NFAs vs DFAs.

1 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 (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.

Your Tasks

  1. Design a data representation for the NFAs from the textbook. You may use objects, structs, or anything else available in your language.

  2. Implement your data representation in your chosen language.

  3. Write a predicate (a function or method that returns true or false) that takes an input string and an instance of your NFA and "runs" it on the NFA. It should return true if the NFA accepts the input, and false otherwise.

2 NFAs and the Language They Recognize

The language that a 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

Your Task

Implement the union operation for your NFAs. It should be much easier now with NFAs.

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.

NOTE: When combining NFAs be careful with duplicate state names. Since the given files may use the same state names, it may be a good idea to first rename them to something unique.

Your solution will be tested as follows:

4 NFA -> DFA (Optional Bonus)

Implement the proof by construction of Theorem 1.39 from the textbook.

In other words, implement a function or method that converts an NFA from the 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. Your solutions from HW1 should be useful here, specifically, use the solution from Create Your Own DFA to write the XML output, and use the solution from A Data Representation for DFAs 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 form but the submission must either be a pdf or readable as plain text. Also, make sure you assign it to the proper problem in gradescope when submitting.