138k views
5 votes
let d be a language over { a, b } where d = s . give a dfa with five states that recognizes d

User Crauscher
by
8.0k points

1 Answer

5 votes

Final answer:

A DFA for language d with an even number of a's, an odd number of b's, and no 'ab' substring is described, including states and transitions. State Q2 is the accept state, and a trap state Q4 is used for any occurrence of 'ab'.

Step-by-step explanation:

To design a Deterministic Finite Automaton (DFA) for the language d over the alphabet {a, b} such that d contains an even number of a's, an odd number of b's, and does not contain the substring ab, we will use five states. Let's denote the states as Q0 (start state), Q1, Q2 (accept state), Q3, and Q4 (trap state).



We start with the following assumptions for the states:

  • Q0: even a's, even b's (start state)
  • Q1: odd a's, even b's
  • Q2: even a's, odd b's (accept state)
  • Q3: odd a's, odd b's
  • Q4: trap state for the substring ab



Now, let's define the transitions:

  • From Q0, if we read 'a', we move to Q1, since we now have an odd number of a's.
  • From Q0, if we read 'b', we move to Q2, as we now have an odd number of b's.
  • From Q1, if we read 'a', we move back to Q0 (even number of a's).
  • From Q1, we move to Q4 upon reading 'b' as this would create the substring 'ab'.
  • From Q2, we go to Q4 upon reading 'a', to avoid 'ab'.
  • From Q2, if we read 'b', we move to Q3 (still odd number of a's, but now even number of b's).
  • From Q3, reading 'a' goes to Q4 to avoid 'ab'.
  • From Q3, reading 'b' goes back to Q2.
  • In Q4, any input ('a' or 'b') will loop back to Q4, effectively trapping the DFA.



Q2 is our only accept state because it satisfies the condition of having an even number of a's and an odd number of b's, and by our transitions, we ensure we never form the substring 'ab'. If the string ends in this state, it will be accepted by the DFA.

User NikoNyrh
by
8.2k points