For each problem, you are to present a DFA (in the form of a transition diagram) that accepts the described language. If the alphabet is not explicitly indicated, assume that it is {a,b}.
1. The language containing precisely those strings whose first and last symbols are different (i.e., one of them is a and the other is b).
Solution:
Logic: Let xy denote the input string, where x is that prefix of the input string that the DFA has read so far. If x = λ, the DFA will be in state λ. Otherwise, the DFA will be in that state whose two-symbol name is formed using the first and last symbols in x, respectively. |
Expressed using a set former: { x ∈ {a,b}* | #a(x) is even ∧ #b(x) is at least three }
Solution:
Logic: Let xy denote the input string, where x is that prefix of the input string that the DFA has read so far. Then the DFA will be in state [k,m], where
|
Expressed using a set former: { xaaby | x,y ∈ {a,b}* }
Solution:
Logic: Let xy denote the input string, where x is that prefix of the input string that the DFA has read so far. If aab (the "target" string) is a substring of x (and hence of xy), the DFA will be in the lone accepting state. Otherwise, the DFA will be in that state whose name corresponds to the longest prefix of aab that is also a suffix of x. |
Solution:
Logic: Let xy denote the input string, where x is that prefix of the input string that the DFA has read so far. If aba (the "target" string) is a substring of x (and hence of xy), the DFA will be in the lone non-accepting state. Otherwise, the DFA will be in that state whose name corresponds to the longest prefix of aba that is also a suffix of x. |
Solution:
Logic: Let xy denote the input string, where x is that prefix of the input string that the DFA has read so far.
|