ArticleslgStudy

science

Nondeterministic finite automaton

Nondeterministic finite automaton is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Nondeterministic finite automaton rather than just read about it. In short: In automata theory, a finite-state machine is called a deterministic finite automaton (DFA), if each of its transitions is uniquely determined by its source state and input symbol, and reading an input symbol is required for each state transition. A nondeterministic finite automaton (NFA), or nondeterministic finite-state machine, does not need to obey these restrictions.

Nondeterministic finite automaton — main illustration
Nondeterministic finite automaton — illustration

Key takeaways

  • Nondeterministic finite automaton belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Nondeterministic finite automaton to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Nondeterministic finite automaton from memory before moving on to harder problems.

Reference excerpt

In automata theory, a finite-state machine is called a deterministic finite automaton (DFA), if

each of its transitions is uniquely determined by its source state and input symbol, and reading an input symbol is required for each state transition. A nondeterministic finite automaton (NFA), or nondeterministic finite-state machine, does not need to obey these restrictions. In particular, every DFA is also an NFA. Sometimes the term NFA is used in a narrower sense, referring to an NFA that is not a DFA, but not in this article. Using the subset construction algorithm, each NFA can be translated to an equivalent DFA; i.e., a DFA recognizing the same formal language. Like DFAs, NFAs only recognize regular languages. NFAs were introduced in 1959 by Michael O. Rabin and Dana Scott, who also showed their equivalence to DFAs. NFAs are used in the implementation of regular expressions: Thompson's construction is an algorithm for compiling a regular expression to an NFA that can efficiently perform pattern matching on strings. Conversely, Kleene's algorithm can be used to convert an NFA into a regular expression (whose size is generally exponential in the input automaton). NFAs have been generalized in multiple ways, e.g., nondeterministic finite automata with ε-moves, finite-state transducers, pushdown automata, alternating automata, ω-automata, and probabilistic automata. Besides the DFAs, other known special cases of NFAs are unambiguous finite automata (UFA) and self-verifying finite automata (SVFA).

Informal introduction There are at least two equivalent ways to describe the behavior of an NFA. The first way makes use of the nondeterminism in the name of an NFA. For each input symbol, the NFA transitions to a new state until all input symbols have been consumed. In each step, the automaton nondeterministically "chooses" one of the applicable transitions. If there exists at least one "lucky run", i.e. some sequence of choices leading to an accepting state after completely consuming the input, it is accepted. Otherwise, i.e. if no choice sequence at all can consume all the input and lead to an accepting state, the input is rejected. In the second way, the NFA consumes a string of input symbols, one by one. In each step, whenever two or more transitions are applicable, it "clones" itself into appropriately many copies, each one following a different transition. If no transition is applicable, the current copy is in a dead end, and it "dies". If, after consuming the complete input, any of the copies is in an accept state, the input is accepted, else, it is rejected.

Formal definition For a more elementary introduction of the formal definition, see automata theory.

Automaton An NFA is represented formally by a 5-tuple, (Q,Σ,δ,q0,F), consisting of

a finite set of states Q, a finite set of input symbols called the alphabet Σ, a transition function δ : Q×Σ→𝒫(Q), an initial (or start) state q0∈Q, and a set of accepting (or final) states F⊆Q. Here, 𝒫(Q) denotes the power set of Q.

Recognized language Given an NFA M=(Q,Σ,δ,q0,F), its recognized language is denoted by L(M), and is defined as the set of all strings over the alphabet Σ that are accepted by M. Loosely corresponding to the above informal explanations, there are several equivalent formal definitions of a string w=a1a2...an being accepted by M:

w is accepted if a sequence of states, r0,r1,...,rn, exists in Q such that: r0=q0 ri+1∈δ(ri,ai+1), for i=0,…,n−1 rn∈F. In words, the first condition says that the machine starts in the start state q0. The second condition says that given each character of string w, the machine will transition from state to state according to the transition function δ. 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. In order for w to be accepted by M, it is not required that every state sequence ends in an accepting state, it is sufficient if one does. Otherwise, i.e. if it is impossible at all to get from q0 to a state from F by following w, it is said that the automaton rejects the string. The set of strings M accepts is the language recognized by M and this language is denoted by L(M). Alternatively, w is accepted if δ∗(q0,w)∩F≠∅︀, where δ∗:Q×Σ∗→𝒫(Q) is defined recursively by: δ∗(r,ε)={r} where ε is the empty string, and δ∗(r,xa)=⋃r′∈δ∗(r,x)δ(r′,a) for all x∈Σ∗,a∈Σ. In words, δ∗(r,x) is the set of all states reachable from state r by consuming the string x. The string w is accepted if some accepting state in F can be reached from the start state q0 by consuming w.

Initial state The above automaton definition uses a single initial state, which is not necessary. Sometimes, NFAs are defined with a set of initial states. There is an easy construction that translates an NFA with multiple initial states to an NFA with a single initial state, which provides a convenient notation.

Isomorphism An isomorphism φ from an automaton (Q,Σ,δ,q0,F) to an automaton (Q′,Σ,δ′,q'0,F′) is a bijective mapping φ:Q→Q′ such that

φ(q0)=q'0, q∈F if, and only if, φ(q)∈F′, for each q∈Q, and r∈δ(q,a) if, and only if, φ(r)∈δ′(φ(q),a), for each q,r∈Q and a∈Σ. Intuitively, two automata are isomorphic if they share the same alphabet and one can be obtained by systematically renaming the states of the other.

Example

The following automaton M, with a binary alphabet, determines if the input ends with a 1. Let M=({p,q},{0,1},δ,p,{q}) where the transition function δ can be defined by this state transition table (cf. upper left picture):

StateInput01p{p}{p,q}q∅︀∅︀ Since the set δ(p,1) contains more than one state, M is nondeterministic. The language of M can be described by the regular language given by the regular expression (0|1)*1. All possible state sequences for the input string "1011" are shown in the lower picture. The string is accepted by M since one state sequence satisfies the above definition; it does not matter that other sequences fail to do so. The picture can be interpreted in a couple of ways:

In terms of the above "lucky-run" explanation, each path in the picture denotes a sequence of choices of M. In terms of the "cloning" explanation, each vertical column shows all clones of M at a given point in time, multiple arrows emanating from a node indicate cloning, a node without emanating arrows indicating the "death" of a clone. The feasibility to read the same picture in two ways also indicates the equivalence of both above explanations.

… excerpt ends here. Continue reading the full article.

Illustrations

Nondeterministic finite automaton: The state diagram for M. It is not deterministic since in state p reading a 1 can lead to p or to q.
The state diagram for M. It is not deterministic since in state p reading a 1 can lead to p or to q.
Nondeterministic finite automaton: All possible runs of M on input string "10"
All possible runs of M on input string "10"
Nondeterministic finite automaton: All possible runs of M on input string "1011".Arc label: input symbol, node label: state, @media screen{html.skin-theme-clientpref-night .mw-parser-output div:not(.notheme)>.tmp-color,html.skin-theme-clientpref-night .mw-parser-output p>.tmp-color,html.skin-theme-clientpref-night .mw-parser-output table:not(.notheme) .tmp-color{color:inherit!important}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output div:not(.notheme)>.tmp-color,html.skin-theme-clientpref-os .mw-parser-output p>.tmp-color,html.skin-theme-clientpref-os .mw-parser-output table:not(.notheme) .tmp-color{color:inherit!important}}green: start state, red: accepting state(s).


InputState sequence
1011

1pq?

2pppq?

3ppppq
All possible runs of M on input string "1011".Arc label: input symbol, node label: state, @media screen{html.skin-theme-clientpref-night .mw-parser-output div:not(.notheme)>.tmp-color,html.skin-theme-clientpref-night .mw-parser-output p>.tmp-color,html.skin-theme-clientpref-night .mw-parser-output table:not(.notheme) .tmp-color{color:inherit!important}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output div:not(.notheme)>.tmp-color,html.skin-theme-clientpref-os .mw-parser-output p>.tmp-color,html.skin-theme-clientpref-os .mw-parser-output table:not(.notheme) .tmp-color{color:inherit!important}}green: start state, red: accepting state(s). InputState sequence 1011 1pq? 2pppq? 3ppppq
Nondeterministic finite automaton: The state diagram for M
The state diagram for M
Nondeterministic finite automaton: Composed NFA accepting the union of the languages of some given NFAs N(s) and N(t). For an input string w in the language union, the composed automaton follows an ε-transition from q to the start state (left colored circle) of an appropriate subautomaton — N(s) or N(t) — which, by following w, may reach an accepting state (right colored circle); from there, state f can be reached by another ε-transition. Due to the ε-transitions, the composed NFA is properly nondeterministic even if both N(s) and N(t) were DFAs; vice versa, constructing a DFA for the union language (even of two DFAs) is much more complicated.
Composed NFA accepting the union of the languages of some given NFAs N(s) and N(t). For an input string w in the language union, the composed automaton follows an ε-transition from q to the start state (left colored circle) of an appropriate subautomaton — N(s) or N(t) — which, by following w, may reach an accepting state (right colored circle); from there, state f can be reached by another ε-transition. Due to the ε-transitions, the composed NFA is properly nondeterministic even if both N(s) and N(t) were DFAs; vice versa, constructing a DFA for the union language (even of two DFAs) is much more complicated.

Worked examples

Example 1 — a first encounter with Nondeterministic finite automaton

Start with the simplest possible case. Write down what Nondeterministic finite automaton claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Nondeterministic finite automaton before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Nondeterministic finite automaton ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Nondeterministic finite automaton

In research
Nondeterministic finite automaton appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Nondeterministic finite automaton in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Nondeterministic finite automaton is common in secondary-school and first-year university syllabi. It links to neighbouring topics Finite-state machines, so understanding it makes those chapters shorter.
In everyday life
Look for Nondeterministic finite automaton outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Nondeterministic finite automaton” →

How to study Nondeterministic finite automaton in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Nondeterministic finite automaton means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Nondeterministic finite automaton out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Nondeterministic finite automaton in simple terms?

In automata theory, a finite-state machine is called a deterministic finite automaton (DFA), if each of its transitions is uniquely determined by its source state and input symbol, and reading an input symbol is required for each state transition. A nondeterministic finite automaton (NFA), or nonde…

Why does Nondeterministic finite automaton matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Nondeterministic finite automaton?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Nondeterministic finite automaton.

Tags

  • Finite-state machines

Keep exploring