Can someone tell me if the attached DFA is correct ?
I am suppose to give DFA for the language that has alphabet Σ ={a, b}
No, for multiple reasons:
bab
ab
Regarding the first point: starting at q1
, we see b
, go to q2
, see a
, go to q3
, see b
, and go to q4
, which is accepting. We saw bab
and accepted it.
Regarding the second point: starting at q1
, we see a
but have no defined transition. The automaton "crashes" and fails to accept. So no string starting with a
is accepted, including ab
.
Regarding the third point: DFAs are often required to show all states and transitions, including dead states and transitions that will never lead back to any accepting state. You don't show all transitions and don't show all states in your automaton.
You can use the Myhill-Nerode theorem to determine how many states a minimal DFA for your language has. We note that the empty state can have appended either the empty string, b
or ab
to get a string in the language; a
can have b
appended; and b
can have the empty string appended. Nothing can be appended to aa
, bb
, or ba
to get a string in the language (so these are indistinguishable); but ab
can have the empty string appended (and so is indistinguishable from b
).
Equivalence classes so determined correspond to states in a minimal DFA. Our equivalence classes are:
b
a
aa
We note that b
is in the language, so the second class will correspond to an accepting state. We notice nothing can be appended to aa
to get a string in the language, so this class corresponds to a dead state in the DFA. We write the transitions between these states by seeing which new equivalence class the appending of a new symbol puts us in:
Appending a
puts us in (3) since appending a
to the empty string gives a
which is in (3). Appending b
puts us in (2) since appending b
to the empty string gives b
which is in (2)
Appending a
puts us in (4) since appending a
to to b
gives ba
which is like aa
in that it isn't a prefix of any string in the language. Appending b
, we arrive in (4) by a similar argument.
Appending a
we get aa
and are in (4). Appending b
we get ab
which is like b
so we are in (2).
All transitions from a dead state return to a dead state; both a
and b
lead back to (4).
You end up with something like:
q1 --a--> q3
| /|
b --b--< a
| / |
vv v
q2 -a,b-> q4 \
^ a,b
\_/
Or in tabular form:
q s q'
== = ==
q1 a q3
q1 b q2
q2 a q4
q2 b q4
q3 a q4
q3 b q2
q4 a q4
q4 b q4