Top Banner
Non- Deterministic Finite Automata
33

Non-Deterministic Finite Automata. HM2 samples 1. Question ID 74: Examine the following DFA: Identify in the list below the string that this automaton.

Mar 31, 2015

Download

Documents

Christy Madson
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Non-Deterministic Finite Automata. HM2 samples 1. Question ID 74: Examine the following DFA: Identify in the list below the string that this automaton.

Non-Deterministic Finite Automata

Page 2: Non-Deterministic Finite Automata. HM2 samples 1. Question ID 74: Examine the following DFA: Identify in the list below the string that this automaton.

HM2 samples1. 

  Question ID 74: Examine the following DFA:

                                                                    

Identify in the list below the string that this automaton accepts. 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.

Page 3: Non-Deterministic Finite Automata. HM2 samples 1. Question ID 74: Examine the following DFA: Identify in the list below the string that this automaton.

HM2 Samples4.  

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

 

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?

Page 4: Non-Deterministic Finite Automata. HM2 samples 1. Question ID 74: Examine the following DFA: Identify in the list below the string that this automaton.

Formal Definition of DFA A DFA consists of:

Alphabet A set of states Q A transition function δ : Q Q One start state q0

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 c1c2…cn with ci States are qi = δ(qi-1,ci ) for i=1…n

qn is an accepting state

Page 5: Non-Deterministic Finite Automata. HM2 samples 1. Question ID 74: Examine the following DFA: Identify in the list below the string that this automaton.

NFA and -NFA

Nondeterministic Finite AutomataSame input may produce multiple pathsAllows transition with an empty string or

transition from one state to different states given a character

q1 q2

empty string transition

q1

q21

q31

nondeterministic transition

Page 6: Non-Deterministic Finite Automata. HM2 samples 1. Question ID 74: Examine the following DFA: Identify in the list below the string that this automaton.
Page 7: Non-Deterministic Finite Automata. HM2 samples 1. Question ID 74: Examine the following DFA: Identify in the list below the string that this automaton.
Page 8: Non-Deterministic Finite Automata. HM2 samples 1. Question ID 74: Examine the following DFA: Identify in the list below the string that this automaton.

The Language Accepted by a NFA

Page 9: Non-Deterministic Finite Automata. HM2 samples 1. Question ID 74: Examine the following DFA: Identify in the list below the string that this automaton.
Page 10: Non-Deterministic Finite Automata. HM2 samples 1. Question ID 74: Examine the following DFA: Identify in the list below the string that this automaton.
Page 11: Non-Deterministic Finite Automata. HM2 samples 1. Question ID 74: Examine the following DFA: Identify in the list below the string that this automaton.

EXAMPLE

Page 12: Non-Deterministic Finite Automata. HM2 samples 1. Question ID 74: Examine the following DFA: Identify in the list below the string that this automaton.

Another Example

1 2 3 4

0,1

1 0,10, 1

Accept strings containing a 1 in the third position from the back

Page 13: Non-Deterministic Finite Automata. HM2 samples 1. Question ID 74: Examine the following DFA: Identify in the list below the string that this automaton.

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

Page 14: Non-Deterministic Finite Automata. HM2 samples 1. Question ID 74: Examine the following DFA: Identify in the list below the string that this automaton.

RECAP Definition: NFA

An NFA is defined by a 5-tuple, withAlphabet A set of states QA transition function δ : Q Σ P(Q)One start state q0

One or more accepting states F Q Notation: P(Q) is power set of Q What is the difference from DFA?

Page 15: Non-Deterministic Finite Automata. HM2 samples 1. Question ID 74: Examine the following DFA: Identify in the list below the string that this automaton.

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?

Page 16: Non-Deterministic Finite Automata. HM2 samples 1. Question ID 74: Examine the following DFA: Identify in the list below the string that this automaton.

RECAP Languages

Language accepted by a NFA is the set of strings such that NFA ends at an accepting stateEach string of language is c1c2…cn with ciΣ

(possibly with ε)States are qi δ(qi-1,ci) for i=1…n

qn is an accepting state

Page 17: Non-Deterministic Finite Automata. HM2 samples 1. Question ID 74: Examine the following DFA: Identify in the list below the string that this automaton.

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).

Page 18: Non-Deterministic Finite Automata. HM2 samples 1. Question ID 74: Examine the following DFA: Identify in the list below the string that this automaton.

Proof of DNA=NFA More formal proof: Let A be the language

recognized by the NFA N = (Q,Σ,δ,q0,F). Define the DFA M = (Q’,Σ,δ’,q’0,F’) by

1. Q’ = P(Q)2. δ’(R,a) = { qQ | qδ(r,a) for an rR }3. q’0 = { q0 }4. F’ = {RQ’ | R contains an accept state of N}

1 2 3 4

0,1

1 0,10, 1

Page 19: Non-Deterministic Finite Automata. HM2 samples 1. Question ID 74: Examine the following DFA: Identify in the list below the string that this automaton.
Page 20: Non-Deterministic Finite Automata. HM2 samples 1. Question ID 74: Examine the following DFA: Identify in the list below the string that this automaton.

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

Page 21: Non-Deterministic Finite Automata. HM2 samples 1. Question ID 74: Examine the following DFA: Identify in the list below the string that this automaton.

Example

Accept strings containing either 101 or 11 as a substring

1 2 3 4

0,1

1 10,

0,1

Page 22: Non-Deterministic Finite Automata. HM2 samples 1. Question ID 74: Examine the following DFA: Identify in the list below the string that this automaton.

Example: Read: 010110

1 2 3 4

0,1

1 10,

0,1

How would this NFA work?

Page 23: Non-Deterministic Finite Automata. HM2 samples 1. Question ID 74: Examine the following DFA: Identify in the list below the string that this automaton.

Read: 010110

0

1

0

0

1

1

1

2 3

1

1

1 3

2 31 4

1 4 4

1 4 4

2 3

Page 24: Non-Deterministic Finite Automata. HM2 samples 1. Question ID 74: Examine the following DFA: Identify in the list below the string that this automaton.

Definition: εNFA

An NFA is defined by a 5-tuple, withAlphabet A set of states QA transition function δ : Q Σε P(Q)

One start state q0

One or more accepting states F Q

Notation: Σε = Σ{ε}; P(Q) is power set of Q What is the difference from DFA?

Page 25: Non-Deterministic Finite Automata. HM2 samples 1. Question ID 74: Examine the following DFA: Identify in the list below the string that this automaton.

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?

Page 26: Non-Deterministic Finite Automata. HM2 samples 1. Question ID 74: Examine the following DFA: Identify in the list below the string that this automaton.

Languages

Language accepted by a NFA is the set of strings such that NFA ends at an accepting stateEach string of language is c1c2…cn with ciΣε

(possibly with ε)States are qi δ(qi-1,ci) for i=1…n

qn is an accepting state

Page 27: Non-Deterministic Finite Automata. HM2 samples 1. Question ID 74: Examine the following DFA: Identify in the list below the string that this automaton.

The Golden Chain

εNFA NFA DFA REGEX

Page 28: Non-Deterministic Finite Automata. HM2 samples 1. Question ID 74: Examine the following DFA: Identify in the list below the string that this automaton.
Page 29: Non-Deterministic Finite Automata. HM2 samples 1. Question ID 74: Examine the following DFA: Identify in the list below the string that this automaton.
Page 30: Non-Deterministic Finite Automata. HM2 samples 1. Question ID 74: Examine the following DFA: Identify in the list below the string that this automaton.

EpsilonNFA NFA DFA

Page 31: Non-Deterministic Finite Automata. HM2 samples 1. Question ID 74: Examine the following DFA: Identify in the list below the string that this automaton.
Page 32: Non-Deterministic Finite Automata. HM2 samples 1. Question ID 74: Examine the following DFA: Identify in the list below the string that this automaton.

Regular Expressions

Page 33: Non-Deterministic Finite Automata. HM2 samples 1. Question ID 74: Examine the following DFA: Identify in the list below the string that this automaton.