Download presentation

Presentation is loading. Please wait.

Published byChristy Madson Modified over 2 years ago

1
Non-Deterministic Finite Automata

2
HM2 samples 1. Question ID 74: Examine the following DFA: Identify in the list below the string that this automaton accepts. Details Details 2. Question ID 75: The finite automaton below: accepts no word of length zero, no word of length one, and only two words of length two (01 and 10). There is a fairly simple recurrence equation for the number N(k) of words of length k that this automaton accepts. Discover this recurrence and demonstrate your understanding by identifying the correct value of N(k) for some particular k. Note: the recurrence does not have an easy-to-use closed form, so you will have to compute the first few values by hand. You do not have to compute N(k) for any k greater than 14.

3
HM2 Samples 4. Question ID 77: Which automata define the same language? Note: (b) and (d) use transitions on strings. You may assume that there are nonaccepting intermediate states, not shown, that are in the middle of these transitions, or just accept the extension to the conventional finite automaton that allows strings on transitions and, like the conventional FA accepts strings that are the concatenation of labels along any path from the start state to an accepting state. Details Details 5. Question ID 78: Convert the following nondeterministic finite automaton: to a DFA, including the dead state, if necessary. Which of the following sets of NFA states is not a state of the DFA that is accessible from the start state of the DFA?

4
Formal Definition of DFA A DFA consists of: Alphabet A set of states Q A transition function δ : Q Q One start state q 0 One or more accepting states F Q Language accepted by a DFA is the set of strings such that DFA ends at an accepting state Each string is c 1 c 2 …c n with c i States are q i = δ(q i-1,c i ) for i=1…n q n is an accepting state

5
NFA and -NFA Nondeterministic Finite Automata Same input may produce multiple paths Allows transition with an empty string or transition from one state to different states given a character q1q1 q2q2 empty string transition q1q1 q2q2 1 q3q3 1 nondeterministic transition

6

7

8
The Language Accepted by a NFA

9

10

11
EXAMPLE

12
Another Example ,1 1 Accept strings containing a 1 in the third position from the back

13
RECAP: How does NFA work? Start in start state Read a symbol, clone a machine for each matching transition If a symbol is read and there is no way to exit from a state, then that machine dies At end of input if any machine accepts then accept

14
RECAP Definition: NFA An NFA is defined by a 5-tuple, with Alphabet A set of states Q A transition function δ : Q Σ P(Q) One start state q 0 One or more accepting states F Q Notation: P(Q) is power set of Q What is the difference from DFA?

15
RECAP Nondeterministic Transition The function δ : Q Σ P(Q) is the key difference! When reading symbol `a’ while in state q, it may go to one of the states in δ(q,a) Q. Can δ(q,a) map to empty set?

16
RECAP Languages Language accepted by a NFA is the set of strings such that NFA ends at an accepting state Each string of language is c 1 c 2 …c n with c i Σ (possibly with ε) States are q i δ(q i-1,c i ) for i=1…n q n is an accepting state

17
RECAP DFA = NFA Theorem: For every language L accepted by an NFA, there is a DFA that accepts L. In other words, DFA and NFA are equivalent computational models. Proof idea: When keeping track of nondeterministic computation of NFA N, use many ‘fingers’ to point at the set of states of N that can be reached on a given input string. We can simulate this computation with a DFA M with state space P(Q).

18
Proof of DNA=NFA More formal proof: Let A be the language recognized by the NFA N = (Q,Σ,δ,q 0,F). Define the DFA M = (Q’,Σ,δ’,q’ 0,F’) by 1. Q’ = P(Q) 2. δ’(R,a) = { q Q | q δ(r,a) for an r R } 3. q’ 0 = { q 0 } 4. F’ = {R Q’ | R contains an accept state of N} ,1 1

19

20
How does NFA work? Start in start state If any transitions, clone a machine for each transition Read a symbol, clone a machine for each matching transition If a symbol is read and there is no way to exit from a state, then that machine dies At end of input if any machine accepts then accept

21
Example Accept strings containing either 101 or 11 as a substring , , 0,1

22
Example: Read: , , 0,1 How would this NFA work?

23
Read:

24
Definition: εNFA An NFA is defined by a 5-tuple, with Alphabet A set of states Q A transition function δ : Q Σ ε P(Q) One start state q 0 One or more accepting states F Q Notation: Σ ε = Σ {ε}; P(Q) is power set of Q What is the difference from DFA?

25
Nondeterministic Transition The function δ : Q Σ ε P(Q) is the key difference! When reading symbol `a’ while in state q, it may go to one of the states in δ(q,a) Q. ε in Σ ε allows empty-string transitions Can δ(q,a) map to empty set?

26
Languages Language accepted by a NFA is the set of strings such that NFA ends at an accepting state Each string of language is c 1 c 2 …c n with c i Σ ε (possibly with ε) States are q i δ(q i-1,c i ) for i=1…n q n is an accepting state

27
The Golden Chain εNFA NFA DFA REGEX

28

29

30
EpsilonNFA NFA DFA

31

32
Regular Expressions

33

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google