On this page:
1 A Data Representation for DFAs
2 A Regular Language
3 DFAs and the Language They Recognize
4 Create Your Own DFA
5 The Union Operation
6 The Intersection Operation (Optional Bonus)
7 More DFAs (Optional Bonus)

Homework 1

Last updated: Tue, 22 Sep 2020 15:09:16 -0400

Out: Wed Sept 16, 00:00 EST Due: Tues Sept 22, 23:59 EST

This assignment involves exploring deterministic finite automata (DFAs) using code.

Homework Problems

  1. A Data Representation for DFAs

  2. A Regular Language

  3. DFAs and the Language They Recognize

  4. Create Your Own DFA

  5. The Union Operation

  6. The Intersection Operation (Optional Bonus)

Submitting

Submit your solution to this assignment in Gradescope hw1.

A submission must include the following files:
  • a Makefile with the following targets:
    • setup

    • run-hw1-regular

    • run-hw1-dfa

    • run-hw1-union

    • run-hw1-intersection (optional)

  • a README containing the required information,

  • and finally, files containing the solution to each problem.

1 A Data Representation for DFAs

Recall Definition 1.5 from the book: a DFA is a 5-tuple (Q,\Sigma,\delta,q_0,F), where:
  • Q is a finite set called the states,

  • \Sigma is a finite set called the alphabet,

  • \delta:Q\times\Sigma\rightarrow Q is the transition function,

  • q_0\in Q is the start state, and

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

Since most of the course material on DFAs involves designing, running them, and proofs by construction, we will use programming as a nice way to get hands-on experience.

Your Tasks

  1. Design a data representation for the DFAs 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 DFA and "runs" it on the DFA. It should return true if the DFA accepts the input, and false otherwise.

(There won’t be any explicit tests for this problem, though you’ll need this implementation to do the rest of the homework.)

2 A Regular Language

Create an instance of your DFA recognizing the language:

A = \{w \mid \textrm{length of } w \textrm{ is at least } 3\}

You may assume it has alphabet \Sigma=\{0,1\}.

Recall that a language is regular if some finite automaton recognizes it.

Thus your solution proves that A is a regular language.

Your Task

Implement an instance of your DFA recognizing language A.

Your solution will be tested as follows:

3 DFAs and the Language They Recognize

The language that a DFA recognizes is the set of all strings accepted by the DFA.

Your Tasks

Your solution will be tested as follows:

4 Create Your Own DFA

Your Tasks

5 The Union Operation

Your Task

Implement the union operation for your DFAs. Specifically, write a function that, given:

  • a DFA recognizing language A_1, and

  • a DFA recognizing language A_2

returns a DFA recognizing A_1 \cup A_2.

Your solution proves Theorem 1.25 from the book so rereading that will be helpful.

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

Your solution will be tested as follows:

6 The Intersection Operation (Optional Bonus)

Your Task

Implement intersection for your DFAs. Specifically, write a function that, given:

  • a DFA recognizing language A_1, and

  • a DFA recognizing language A_2

returns a DFA recognizing A_1 \cap A_2.

This is almost the same as union implemented in The Union Operation. See footnote 3 in the proof of Theorem 1.25 for how to implement intersection.

Then, create a "password checking" machine P that recognizes the intersection of the following languages, i.e., A_1 \cap A_2 \cap A_3 \cap A_4.

You may assume the alphabet \Sigma = {A,B,C,a,b,c,1,2,3,!}.

Your solution will be tested as follows:

7 More DFAs (Optional Bonus)

You may attempt this bonus problem only after completing the rest of the assignment.

Your Task

Use your HW1 solution to create another DFA.

Submit it as an automaton XML element in a file named extradfa1.xml.

It must be a new DFA you come up with. It cannot be a DFA that we have seen in class or homeworks. Slight tweaking of previously seen DFAs doesn’t count either.

If your DFA is interesting enough, it may be added to this homework’s test suite.

For this task, you may submit up to three DFAs. Each extra DFA you submit is worth 1 bonus point, for a maximum total of 3 bonus points.

Submit your additional DFAs with the following file names:
  • extradfa1.xml

  • extradfa2.xml

  • extradfa3.xml