1 / 16

Non-deterministic finite automaton

Non-deterministic finite automaton. NFA – definition. A nondeterministic finite automaton (or NFA) can be formally defined as a 5-tuple ( Q ,  , T , q D , F ) where Q is a finite set of states.  is the alphabet (defining what set of

trang
Download Presentation

Non-deterministic finite automaton

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Non-deterministic finite automaton Dr. Shakir Al Faraji

  2. NFA – definition A nondeterministic finite automaton (or NFA) can be formally defined as a 5-tuple ( Q ,  , T, qD, F ) where Q is a finite set of states.  is the alphabet (defining what set of input strings the automaton operates on). Dr. Shakir Al Faraji

  3. NFA – Cont. T:Q ( U )Q is the transition function. qD Q is the starting state. FQ is a set of final (or accepting states). Note how this definition differs from that of a deterministic finite automaton (DFA) only by the definition of the transition function T. Operation of the NDFA (0r NFA) begins at qD , and movement from state to state is governed by the transition functionT. Dr. Shakir Al Faraji

  4. NFA – Cont. The transition function takes the first symbol of the (remaining) input string and the current state as its input, and after the transition this first symbol is removed only if the transition is defined for a symbol in  instead of . Conceptually, all possible transitions from a current state are followed simultaneously (hence the non-determinism). Dr. Shakir Al Faraji

  5. NFA – Cont. Once every possible transition has been executed, the NFA is halted. If any of the states reached upon halting are in for some input string, and the entire input string is consumed to reach that state, then the NFA accepts that string. Dr. Shakir Al Faraji

  6. NFA – Examples NFAs represent regular languages, and can be used to test whether any string is in the language it represents. Consider the following regular language over the alphabet  = { a, b } (represented by the regular expression aa*b Dr. Shakir Al Faraji

  7. NFA – Examples This language can be represented by the following NFA. Dr. Shakir Al Faraji

  8. NFA – Examples If given the string aaab as input, operation of the NFA is as follows. For state 0 with a leading a as its input, the only possible transition to follow is to 1 (which consumes the a). This transforms X to { (1,aab) }. Dr. Shakir Al Faraji

  9. NFA – Examples Now there are two possible transitions to follow for state 1 with a leading a. One transition is back to 1, consuming the a, while the other is to 2, leaving the a. Thus X is then { (1,ab) , (2,aab) }. Dr. Shakir Al Faraji

  10. NFA – Examples Again, the same transitions are possible for state 1, while no transition at all is available for state 2 with a leading a, so X is then { (1,b) , (2,aab) , (2,ab) }. Dr. Shakir Al Faraji

  11. NFA – Examples Again, the same transitions are possible for state 1, while no transition at all is available for state 2 with a leading a, so X is then { (1,b) , (2,aab) , (2,ab) }. At this point, there is still no possible transition from 2, and the only possible transition from 1 is to 2 (leaving the input string as it is). This then gives { (2,aab) , (2,ab) , (2,b) }. Dr. Shakir Al Faraji

  12. NFA – Examples Only state 2 with remaining input of b has a transition leading from it, giving { (2,aab) , (2,ab) , (3, ) } . At this point no further transitions are possible, and so the NFA is halted. Since 3 is in F, and the input string can be reduced to  when it reached 3, the NFA accepts aaab. Dr. Shakir Al Faraji

  13. NFA – Examples If the input string were instead aaaba, processing would occur as before until { (2,aaba) , (2,aba) , (3,a) }. is reached and the NFA halts. Although 3 is in F, it is not possible to reduce the input string completely before reaching 3. Therefore aaaba is not accepted by this NFA. Dr. Shakir Al Faraji

  14. NFA – Examples (a+b)*aa(a+b)* Dr. Shakir Al Faraji

  15. a,b a a a,b + - NFA – Examples (a+b)*aa(a+b)* Dr. Shakir Al Faraji

  16. END Dr. Shakir Al Faraji

More Related