1 / 89

Theory of Computation

Theory of Computation. Nondeterministic Finite Automaton (NFA). An NFA is a collection of three things 1) Finite states with one initial and some final states 2) Finite set of input letters ( Σ ) from which input strings are formed

meyermark
Télécharger la présentation

Theory of Computation

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. Theory of Computation

  2. Nondeterministic Finite Automaton (NFA) An NFA is a collection of three things 1) Finite states with one initial and some final states 2) Finite set of input letters (Σ) from which input strings are formed 3) Finite set of transitions, showing where to move if a letter is input at certain state, there may be more than one transition for certain letters and there may not be any transition for certain letters.

  3. Observations The string is supposed to be accepted, if there exists at least one successful path, otherwise rejected. NFA can be considered to be an intermediate structure between FA and TG.

  4. Example The above NFA accepts the language consisting of a and ab. 2+ a a 1- 3 a b 4 5+

  5. Example The above NFA accepts the language of strings, defined over Σ = {a, b}, containing aa. a, b a,b a a 1- 3+ 2

  6. Non-determinism This refers to situations in which the next state of a computation is not uniquely determined by the current state. In these situations we know only a range of possibilities

  7. Converting an FA to an equivalent NFA If a language is accepted by an FA, then there exists a TG accepting that language(Kleene’s theorem). Since, an NFA is also a TG, there exists an NFA accepting the language accepted by the given FA. In this case these FA and NFA are said to be equivalent to each others.

  8. Example Consider the following FA corresponding to (a+b)*b The above FA may be equivalent to the following NFA a b b - + a a, b b - +

  9. Example Consider the following FA The above FA may be equivalent to the following NFA a,b b a a - + 1 b a,b a, b a a - + 1

  10. Note Every FA can be considered to be an NFA, but the converse may not true. Every NFA can be considered to be a TG, but the converse may not true.

  11. An NFA can be considered to be a TG, so a RE corresponding to the given NFA can be determined Again using Kleene’s theorem, an FA can be built corresponding to that RE. NFA to FA

  12. Example 2 b a 1- 4+ b a 3 a 1- 2 b 4+ a b a a, b 3 b a, b 

  13. Nondeterministic Finite Automaton (NFA) Cont… Alphabet =

  14. Alphabet = Two choices

  15. Alphabet = Two choices No transition No transition

  16. First Choice

  17. First Choice

  18. First Choice

  19. First Choice All input is consumed “accept”

  20. Second Choice

  21. Second Choice

  22. Second Choice No transition: the automaton hangs

  23. Second Choice Input cannot be consumed “reject”

  24. An NFA accepts a string: if there is a computation of the NFA that accepts the string i.e., all the input is consumed and the automaton is in an accepting state

  25. Example is accepted by the NFA: “accept” “reject” because this computation accepts

  26. Rejection example

  27. First Choice

  28. First Choice “reject”

  29. Second Choice

  30. Second Choice

  31. Second Choice “reject”

  32. Example is rejected by the NFA: “reject” “reject” All possible computations lead to rejection

  33. Rejection example

  34. First Choice

  35. First Choice No transition: the automaton hangs

  36. First Choice Input cannot be consumed “reject”

  37. Second Choice

  38. Second Choice

  39. Second Choice No transition: the automaton hangs

  40. Second Choice Input cannot be consumed “reject”

  41. is rejected by the NFA: “reject” “reject” All possible computations lead to rejection

  42. Language accepted:

  43. Lambda Transitions

  44. (read head does not move)

  45. all input is consumed “accept” String is accepted

  46. Rejection Example

More Related