Search code examples
formal-languages

Does this DFA have a solution?


I trying to create a DFA that can recognize strings with alphabet {a,b,c} where a and c appear a even number of times and where b appears an uneven number of times.

I am wondering that this may only be expressed with other mathods such as turing machine or context-free languages.

You might find it fun to think of the solution.


Solution

  • This is possible using a DFA simply have a state for each of the combinations of an odd number of a's, b's and c's. So if you're in the state with even # of a's, odd # of b's and an even # of c's then you can accept. You can also define simple transitions for any of the other cases. So naively this can be done with 8 states.