Download presentation
Presentation is loading. Please wait.
Published bySamantha Marshall Modified over 8 years ago
1
Nondeterministic Finite Automata (NFAs)
2
Reminder: Deterministic Finite Automata (DFA) q For every state q in Q and every character in , one and only one transition of the following form occurs: q’ sp b a q > b a r b a t ba ab
3
Expressiveness of DFA DFA are a type of programs Contains concepts of imperative languages: sequences, branching and loops. Can implement a newspaper vendor machine or even control a character in a video game Can implement pattern matching: find all text containing “Britney Spears” Can only implement programs that require a constant amount of memory (or “Justin Timberlake”)
4
Another Example sq b a b a r a b q b a a r > sq a r a b q a b b r > What is the language recognized by A? A B What is the language recognized by B?
5
Nondeterministic Finite Automata s q b a r a b q b a a r > a q r b q’ b a b r’ a 1.Why is this automaton nondeterministic? 2.What is the language accepted by this automaton?
6
Nondeterministic Finite Automata (NFA) For every state q in S and every character in , one of the following will happen: qq’ No transition: occurs One or more transitions:qq’ occurs p …
7
Nondeterministic Finite Automaton (NFA) A nondeterministic finite automaton (NFA) is a 5-tuple (Q, , ,s,F) where: Q is a finite set of elements called states is a finite input alphabet s Q called the start state F Q called the favorable states Q × ( {e}) × Q The crucial point is that is a relation Are and representing the same transitions? “the empty word” Book says: (Q, , ,s,F) where: is a transition function, Q × ( {e}) × (Q) “power set”
8
Nondeterministic Finite Automata (NFA) What else can occur in NFAs? qq’ e If next word to process in q is aaabbb and apply this transition, what is the word to be processed in q’? aaabbb “e-transitions” do not process any characters, they just allow to “jump” between states
9
Formal Definition of Computation for NFAs Given a nodeterministic finite automaton N= (Q, , ,s,F), and let w = w 1 w 2 …w n, where each w i is in M accepts w if we can write w as: w = y 1 y 2 …y m, where each y i is in ( {e}) and there is a sequence of states r 0 r 1, r 2 … r m in Q such that: 1.r 0 is the start state of M 2.r i+1 (r i, w i+1 ) for i = 0, …, m-1 3. r m F Language recognized by N: {w in * : N accepts w}
10
Same Example s q b a r a b q b a a r > a q r b q’ b a b r’ a Language accepted by this automaton is the set of all strings containing either the substring “aa” or the substring “bb”
11
Example sq r q b r > b a b 1.Why is this automation nondeterministic? 2.What is the language accepted by this automaton?
12
Why We Study Nondeterministic Computation? Makes it easier to prove properties about Automata –In particular, makes it easier to prove certain properties: If A is a regular language then A R is also regular It also makes it possible to understand the boundaries of computation –P = NP?
13
Oracle in NFAs The oracle explanation of NFAs: given a choice between possible transitions, there is a device, called the oracle, that always chooses the transition that leads to a favorable state Is the oracle explanation compatible with our definition of acceptability in NFAs? Sometimes it is useful to use the oracle when creating NFAs “current state”... … Oracle chooses this transition because it leads to a favorable state
14
NFA vs DFA Every DFA can be seen as an NFA But not every NFA can be seen as a DFA Are DFA’s more expressive? What does this means? For example, is there an DFA that accepts the same language accepted by the following NFA? It means that there an NFA can be constructed that accepts a language L for which no DFA can be constructed that accepts L sq r q b r > b a b
15
NFA vs DFA (2) How about this one? s q b a r a b q b a a r > a q r b q’ b a b r’ a It turns out that for every NFA, a DFA can be constructed such they both accept the same language. We will study a formal proof of this on Wednesday
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.