简体   繁体   中英

Creating a deterministic finite automata

I need to create a non-empty DFA over the language {a,b,c} with the following properties:

  1. First symbol is a.
  2. Has an even number of b's.
  3. Last symbol is a c.

I was just wondering, should I create 3 seperate automatas, and then combine them using intersections, or should I just create the one, and if that is the case, how can it has an even number of b's? I know I can alternate the states, but not sure how to do it with it all combined.

Thanks

Here's your automaton (assuming that 0 is even and therefor 0 b's is ok):

[start](a) -> [1]
[start](b,c,<eoi>) -> [reject]

[1](a) -> [1]
[1](<eoi>) -> [reject]

[1](c) -> [2]
[1](b) -> [3]

[2](<eoi>) -> [accept]
[2](c) -> [2]
[2](a) -> [1]
[2](b) -> [3]

[3](<eoi>) -> [reject]
[3](a,c) -> [3]
[3](b)->[1]

Where is "end-of-input".

State 1: even number of b's, the last symbol processed not c. State 2: even number of b's, the last symbol processed is c. State 3: odd number of b's.

[enter image description here][1] Your required DFA is shown in the attached image [1]: https://i.stack.imgur.com/1K3Xw.jpg

Now let us try to understand how the DFA is constructed. Initial state- 'q0' Now we take a on 'q0' for making the starting symbol of string 'a'. After that we want to construct our DFA which contains even number of 'b's' for that we take b on 'q1','q2'. And our required DFA has last symbol is a 'c'. So we take 'c' on 'q3'. The final state is 'q4'. Now we see transition of each state. On 'q0' we take string symbol 'a' for starting symbol and we goes to state 'q1'. If we take string symbols 'b' and 'c' on state 'q0' we goes to the state 'q5'. If we take 'a','c' on state 'q1' then we stay in the same state 'q1'. Now we take 'b' on 'q1' then we goes to the state 'q2'. In the constructing DFA we have odd number of 'b's' ie 1. But we take even number of 'b's'. If we take 'a','c' on state 'q2' then we stay in the same state 'q2'. If we take string symbol 'b' on state 'q2' then we goes to the state 'q3'. If we take 'a'on state 'q3' then we stay in the same state 'q3'. If we take string symbol 'b' on state 'q3' then we goes to the state 'q2'. If we take string symbol 'c' on state 'q3' then we goes to the state 'q4' which is final state. Because in that DFA we follow the properties which we required. If we take string symbol 'b' on state 'q4' then we goes to the state 'q2'. If we take string symbol 'a' on state 'q4' then we goes to the state 'q3'. This is our required DFA.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM