CMPS 260 Spring 2022
Homework #2: Finite Automata
Due: 2pm, Wednesday, Febrary 23

Each problem asks you to "present" a DFA (or finite transducer). Such a presentation should be in the form of a transition graph or a two-dimensional table describing the transition function and identifying which state is initial and which are final/accepting. (You can find an example on a course web page.) Either way, you should name each state in a manner that suggests what data/info the DFA "remembers" when in that state.

1. Present a DFA (deterministic finite automaton) that recognizes/accepts the language

L1 = { w ∈ {0,1}*  |  n0(w) ≡ 1 (mod 2)  ∧  n1(w) ≠ 0 (mod 3) }

In accord with Linz's notation, nc(x) is the number of occurrences of symbol c in string x.

In words, L1 contains precisely those bit strings in which the number of occurrences of 0 is odd and the number of occurrences of 1 is not divisible by three.


2. Present a DFA that recognizes/accepts the language

L2 = { w ∈ {0,1}*  |  n0(w) ≡ 0 (mod 2)  ∧  n1(w) ≥ 3 }

In words, L2 contains precisely those bit strings in which the number of occurrences of 0 is even and the number of occurrences of 1 is at least three.


3. Present a DFA that recognizes/accepts the language

L3 = { w ∈ {0,1}*  |  010 is a substring of w but 0101 is not }

Hint: If your DFA has fewer than eight states, it is wrong.


4. Present a DFA that recognizes/accepts the language

L4 = { w ∈ {0,1}*  |  n0(w) + 3·n1(w) ≡ 1 (mod 4) }

In words, L4 contains precisely those bit strings in which the number obtained by adding the number of occurrences of 0 to three times the number of occurrences of 1 is one more than a multiple of four.


5. Present a DFA that recognizes/accepts the language

L5 = { w ∈ {0,1}*  |  one of 000, 001, or 101 is a suffix of w }

You will be rewarded with a small bonus if no two states in your DFA are equivalent/indistinguishable.


6. Present a finite transducer (either a Mealy machine or a Moore machine[1]) that, given as input a bit string, echoes that bit string, except that it truncates any run of length greater than three.

A run within a string is a substring all of whose symbols are the same and such that any symbol appearing to its immediate left or right is different. For example, if u and v are strings over the alphabet {0,1}, then in u0000v, the indicated occurrence of 0000 is a run iff u ends with 1 (or is empty) and v begins with 1 (or is empty).

Thus, the machine you are to describe would produce 0103130110130 (i.e., 0100011101101110) as output in response to the input 0105140110160 (i.e., 0100000111101101111110). (Each run of bits of length greater than three in the input string appears as a run of length three in the output string.)


7. Present a finite transducer (either a Mealy machine or a Moore machine[1]) that, given an even-length bit string x = x1x2x2...x2n as input, produces as output the bit string y = x2x1x4x3 ... x2nx2n-1. That is, each pair of adjacent bits get swapped. (If x is of odd length, the output produced should be the same as if the last bit of x was not there.) For example, in response to the input 01101101, the machine should produce 10011110 as output.


Footnote

[1] In a Mealy machine, each transition specifies an output string (possibly the empty string, denoted by λ) that is produced each time that transition is taken. In a Moore machine, each state specifes an output string (again, possibly empty) that is produced each time that state is entered via some transition.

For more, see Appendix A in the Linz textbook.