|
|
(One intermediate revision by one other user not shown) |
Line 1: |
Line 1: |
| In [[automata theory]], a '''nondeterministic finite automaton''' (NFA), or nondeterministic finite state machine, is a [[finite state machine]] that '''''(1)''''' does not require input symbols for state transitions and '''''(2)''''' is capable of transitioning to zero or two or more states for a given start state and input symbol. This distinguishes it from a [[deterministic finite automaton]] (DFA), in which all transitions are uniquely determined and in which an input symbol is required for all state transitions.
| | Hiya and welcome there, I am Adrianne and I totally really like that name. Vermont has always been my current home and I really like every day living suitable here. Gardening is what I do a week. I am a people manager but rather soon I'll be without any help. You can find my website here: http://circuspartypanama.com<br><br>Review my site [http://circuspartypanama.com clash of clans hack cydia] |
| Although NFA and DFA have distinct definitions, all NFAs can be translated to equivalent DFAs using the subset construction algorithm,<ref>{{cite book |title=Introduction to Languages and the Theory of Computation |last1=Martin |first1=John |year=2010 |page=108 |publisher=McGraw Hill |isbn= 978-0071289429}}</ref> i.e., constructed DFAs and their corresponding NFAs recognize the same [[formal language]].
| |
| Like DFAs, NFAs only recognize [[regular languages]].
| |
| | |
| NFAs were introduced in 1959 by [[Michael O. Rabin]] and [[Dana Scott]],<ref>{{cite journal |doi=10.1147/rd.32.0114 |last=Rabin |first=M. O. |last2=Scott |first2=D. |title=Finite Automata and Their Decision Problems |journal=IBM Journal of Research and Development |url=http://ieeexplore.ieee.org/xpl/freeabs_all.jsp?arnumber=5392601 |format=PDF, IEEE Xplore access required |volume=3 |issue=2 |pages=114–125 |date=April 1959 |accessdate=2007-03-15 }}</ref> who also showed their equivalence to DFAs.
| |
| | |
| NFAs have been generalized in multiple ways, e.g., [[nondeterministic finite automaton with ε-moves]], [[pushdown automaton]], [[ω-automaton]], and [[probabilistic automata]].
| |
| | |
| ==Informal introduction==
| |
| | |
| An NFA, similar to a [[deterministic finite automaton|DFA]], consumes a string of input symbols. For each input symbol, it transitions to a new state until all input symbols have been consumed.
| |
| Unlike a DFA, it is non-deterministic, i.e., for some state and input symbol, the next state may be one of two or more possible states. Thus, in the formal definition, the next state is an element of the [[power set]] of the states, which is a set of states to be considered at once.
| |
| The notion of accepting an input is similar to that for the DFA.
| |
| When the last input symbol is consumed, the NFA accepts if and only if there is ''some'' set of transitions that will take it to an accepting state. Equivalently, it rejects, if, no matter what transitions are applied, it would not end in an accepting state.
| |
| | |
| ==Formal definition==
| |
| An ''NFA'' is represented formally by a [[n-tuple|5-tuple]],
| |
| (''Q'', Σ, Δ, ''q<sub>0</sub>'', ''F''), consisting of
| |
| * a finite [[Set (mathematics)|set]] of states ''Q''
| |
| * a finite set of [[input symbol]]s Σ
| |
| * a transition [[Relation (logic)|relation]] Δ : ''Q'' × Σ → ''P''(''Q'').
| |
| * an ''initial'' (or ''start'') state ''q''<sub>0</sub> ∈ ''Q''
| |
| * a set of states ''F'' distinguished as ''accepting'' (or ''final'') ''states'' ''F'' ⊆ ''Q''.
| |
| | |
| Here, ''P''(''Q'') denotes the [[power set]] of ''Q''.
| |
| Let ''w = a<sub>1</sub>a<sub>2</sub> ... a<sub>n</sub>'' be a word over the alphabet Σ. The automaton ''M'' accepts the word ''w'' if a sequence of states,
| |
| ''r<sub>0</sub>,r<sub>1</sub>, ..., r<sub>n</sub>'', exists in ''Q'' with the following conditions:
| |
| # ''r<sub>0</sub>'' = ''q''<sub>''0''</sub>
| |
| # ''r<sub>i+1</sub>'' ∈ Δ(''r<sub>i</sub>'', ''a<sub>i+1</sub>''), for ''i'' = ''0, ..., n−1''
| |
| # ''r<sub>n</sub>'' ∈ ''F''.
| |
| In words, the first condition says that the machine starts in the start state ''q''<sub>0</sub>. The second condition says that given each character of string ''w'', the machine will transition from state to state according to the transition relation Δ. The last condition says that the machine accepts ''w'' if the last input of ''w'' causes the machine to halt in one of the accepting states. Otherwise, it is said that the automaton ''rejects'' the string. The set of strings ''M'' accepts is the [[Formal language|language]] ''recognized'' by ''M'' and this language is denoted by ''L(M)''.
| |
| | |
| We can also define ''L(M)'' in terms of Δ*: Q × Σ* → ''P''(''Q'') such that:
| |
| # Δ*(''r'', ε)= {''r''} where ε is the empty string, and
| |
| # If ''x'' ∈ Σ*, ''a'' ∈ Σ, and Δ*(''r'', x)={r<sub>1</sub>, r<sub>2</sub>,..., r<sub>k</sub>} then Δ*(''r'', ''xa'')= Δ(r<sub>1</sub>, a)∪...∪Δ(r<sub>k</sub>, a).
| |
| Now L(M) = {w | Δ*(q<sub>0</sub>, w) ∩ ''F'' ≠ ∅}.
| |
| | |
| Note that there is a ''single initial state'', which is not necessary. Sometimes, NFAs are defined with a set of initial states. There is an easy [[automata construction|construction]] that translates a NFA with multiple initial states to a NFA with single initial state, which provides a convenient notation.
| |
| | |
| For more elementary introduction of the formal definition see [[automata theory]].
| |
| | |
| ==Example==
| |
| [[File:NFASimpleExample.svg|thumb|250px|The [[state diagram]] for ''M'']]
| |
| Let ''M'' be a NFA, with a binary alphabet, that determines if the input ends with a 1.
| |
| | |
| In formal notation, let ''M'' = ({''p'', ''q''}, {0, 1}, Δ, ''p'', {''q''}) where
| |
| the transition relation Δ can be defined by this [[state transition table]]:
| |
| {| border="1" cellpadding="1" align="center"
| |
| |
| |
| |<center>'''0'''</center>
| |
| |<center>'''1'''</center>
| |
| |-
| |
| |<center>''p''</center>
| |
| |<center>{''p''}</center>
| |
| |<center>{''p'',''q''}</center>
| |
| |-
| |
| |<center>''q''</center>
| |
| |<center>∅</center>
| |
| |<center>∅</center>
| |
| |-
| |
| |}
| |
| Note that Δ(''p'',1) has more than one state therefore ''M'' is nondeterministic.
| |
| The language of ''M'' can be described by the [[regular language]] given by the [[regular expression]] (0|1)*1.
| |
| | |
| ==Variations of NFA==
| |
| * [[Deterministic finite automaton]] (DFA): In this automaton, for each state and alphabet, the transition relation has exactly one state.
| |
| * [[Nondeterministic finite automaton with ε-moves]](NFA-ε): This automaton replaces the transition relation with the one that allows the [[empty string]] ε as a possible input, so the transition relation is defined as Δ : ''Q'' × (Σ ∪{ε}) → ''P''(''Q'').
| |
| | |
| ==Equivalence to DFA==
| |
| | |
| For each NFA, there is a DFA such that both recognize the same [[formal language]].
| |
| The DFA can be [[automata construction|constructed]] using the [[powerset construction]].
| |
| It is important in theory because it establishes that NFAs, despite their additional flexibility, are unable to recognize any language that cannot be recognized by some DFA. It is also important in practice for converting easier-to-construct NFAs into more efficiently executable DFAs. However, if the NFA has ''n'' states, the resulting DFA may have up to 2<sup>''n''</sup> states, an exponentially larger number, which sometimes makes the construction impractical for large NFAs.
| |
| | |
| ==Closure properties==
| |
| | |
| NFAs are said to be [[closed under]] a ([[binary operator|binary]]/[[unary operator|unary]]) operator
| |
| if NFAs recognize the languages
| |
| that are obtained by applying the operation on the NFA recognizable languages.
| |
| The NFAs are closed under the following operations.
| |
| | |
| *Union
| |
| *Intersection
| |
| *Concatenation
| |
| *Negation
| |
| *[[Kleene closure]]
| |
| | |
| Since NFAs are equivalent to
| |
| [[nondeterministic finite automaton with ε-moves]](NFA-ε),
| |
| the above closures are proved using closure properties of NFA-ε.
| |
| The above closure properties imply that NFAs only recognize [[regular languages]].
| |
| | |
| NFAs can be constructed from any [[regular expression]] using [[Thompson's construction algorithm]].
| |
| | |
| ==Properties==
| |
| The machine starts in the specified initial state and reads in a string of symbols from its [[Alphabet (computer science)|alphabet]]. The automaton uses the [[state transition function]] Δ to determine the next state using the current state, and the symbol just read or the empty string. However, "the next state of an NFA depends not only on the current input event, but also on an arbitrary number of subsequent input events. Until these subsequent events occur it is not possible to determine which state the machine is in".<ref>FOLDOC Free Online Dictionary of Computing, ''[http://foldoc.org/nfa Finite State Machine]''</ref> If, when the automaton has finished reading, it is in an accepting state, the NFA is said to accept the string, otherwise it is said to reject the string.
| |
| | |
| The set of all strings accepted by an NFA is the language the NFA accepts. This language is a [[regular language]].<ref>[http://cs.stackexchange.com/questions/2016/how-to-convert-finite-automata-to-regular-expressions How to convert finite automata to regular expressions?]</ref>
| |
| | |
| For every NFA a [[deterministic finite automaton]] (DFA) can be found that accepts the same language. Therefore it is possible to convert an existing NFA into a DFA for the purpose of implementing a (perhaps) simpler machine. This can be performed using the [[powerset construction]], which may lead to an exponential rise in the number of necessary states. A formal proof of the powerset construction is given [[Powerset construction|here]].
| |
| | |
| ==Implementation==
| |
| | |
| There are many ways to implement a NFA:
| |
| | |
| * Convert to the equivalent DFA. In some cases this may cause exponential blowup in the size of the automaton and thus auxiliary space proportional to the number of states in the NFA (as storage of the state value requires at most one bit for every state in the NFA)<ref>http://cseweb.ucsd.edu/~ccalabro/essays/fsa.pdf</ref>
| |
| * Keep a [[set data structure]] of all states which the machine might currently be in. On the consumption of the last input symbol, if one of these states is a final state, the machine accepts the string. In the worst case, this may require auxiliary space proportional to the number of states in the NFA; if the set structure uses one bit per NFA state, then this solution is exactly equivalent to the above.
| |
| * Create multiple copies. For each n way decision, the NFA creates up to <math>n-1</math> copies of the machine. Each will enter a separate state. If, upon consuming the last input symbol, at least one copy of the NFA is in the accepting state, the NFA will accept. (This, too, requires linear storage with respect to the number of NFA states, as there can be one machine for every NFA state.)
| |
| * Explicitly propagate tokens through the transition structure of the NFA and match whenever a token reaches the final state. This is sometimes useful when the NFA should encode additional context about the events that triggered the transition. (For an implementation that uses this technique to keep track of object references have a look at Tracematches.<ref>Allan, C., Avgustinov, P., Christensen, A. S., Hendren, L., Kuzins, S., Lhoták, O., de Moor, O., Sereni, D., Sittampalam, G., and Tibble, J. 2005. [http://abc.comlab.ox.ac.uk/papers#oopsla2005 Adding trace matching with free variables to AspectJ]. In Proceedings of the 20th Annual ACM SIGPLAN Conference on Object Oriented Programming, Systems, Languages, and Applications (San Diego, CA, USA, October 16–20, 2005). OOPSLA '05. ACM, New York, NY, 345-364.</ref>)
| |
| | |
| ==Application of NFA==
| |
| NFAs and DFAs are equivalent in that if a language is recognized by an NFA, it is also recognized by a DFA and vice versa. The establishment of such equivalence is important and useful. It is useful because constructing an NFA to recognize a given language is sometimes much easier than constructing a DFA for that language. It is important because NFAs can be used to reduce the complexity of the mathematical work required to establish many important properties in the [[theory of computation]]. For example, it is much easier to prove [[Regular languages#Closure properties|closure properties]] of [[regular language]]s using NFAs than DFAs.
| |
| | |
| * The [[Union of two regular languages|union]] of two [[regular language]]s is regular.
| |
| * The concatenation of two [[regular language]]s is regular.
| |
| * The [[Kleene closure]] of a [[regular language]] is regular.
| |
| | |
| ==See also==
| |
| * [[Turing Machine]]
| |
| * [[Deterministic finite automaton]]
| |
| * [[Pushdown automaton]]
| |
| | |
| == Notes ==
| |
| <references/>
| |
| | |
| == References ==
| |
| * M. O. Rabin and D. Scott, "Finite Automata and their Decision Problems", ''IBM Journal of Research and Development'', '''3''':2 (1959) pp. 115–125.
| |
| * Michael Sipser, ''Introduction to the Theory of Computation''. PWS, Boston. 1997. ISBN 0-534-94728-X. ''(see section 1.2: Nondeterminism, pp.47–63.)''
| |
| * John E. Hopcroft and Jeffrey D. Ullman, ''[[Introduction to Automata Theory, Languages, and Computation]]'', Addison-Wesley Publishing, Reading Massachusetts, 1979. ISBN 0-201-02988-X. ''(See chapter 2.)''
| |
| | |
| {{Formal languages and grammars}}
| |
| | |
| {{DEFAULTSORT:Nondeterministic Finite-State Machine}}
| |
| [[Category:Models of computation]]
| |
| [[Category:Automata theory]]
| |
| | |
| [[nl:Eindigetoestandsautomaat#Niet-deterministische eindige automaten]]
| |