Vous êtes sur la page 1sur 5

Chapter 2: Finite Automata ∗

Peter Cappello
Department of Computer Science
University of California, Santa Barbara
Santa Barbara, CA 93106
cappello@cs.ucsb.edu

• Please read the corresponding chapter before attending this lecture.


• These notes are not complete. They are supplemented with figures and mate-
rial that arises during the lecture in response to questions.
• Please report any errors in these notes to me (cappello@cs.ucsb.edu). I’ll fix
them immediately.

Based on An Introduction to Formal Languages and Automata, 3rd Ed., Peter Linz, Jones and Bartlett
Publishers, Inc.

1
2.2 Nondeterministic Finite Acceptors

Definition of a Nondeterministic Finite Acceptor

Defn. 2.4 A nondeterministic finite acceptor (NFA) is defined


by a 5-tuple
M = (Q, Σ, δ, q0, F ),
where Q, Σ, q0, F are defined as for DFAs, but
δ : Q × (Σ ∪ {λ}) 7→ 2Q.
This definition differs from that for a DFA in 3 ways:
• The value of the transition function is a set of successor states.
• The set of successor states may be empty: There is no successor
state.
• The transition function allows moves “on λ” that do not advance the
read head.

2
Transition graphs for NFAs are suitably modified:
• If
δ(q, a) = {s1 , s2, . . . , sk },
where each si ∈ Q, then there is an arc labelled a (including λ) from
the node labelled q to each of the nodes labelled s1, s2, . . . , sk .

Figure 1: An NFA

• Transitions that are unspecified implicitly indicate a transition to the


empty set: There is no successor state, illustrated in Fig. 2.

Figure 2: An NFA that accepts {01n : n ≥ 0}.

The transition function, δ, is extended analogously. We describe it in


terms of transition graphs:

3
Defn. 2.5 For an NFA, the extended transition function is defined
so that δ ∗(q, w) contains q 0 ⇔ there is a path in the TG from q to q 0
labelled w, ∀q, q 0 ∈ Q, w ∈ Σ∗.
For the NFA given in Fig. 3, what is:
• δ ∗(q0 , a)?
• δ ∗(q1 , λ)?
• δ ∗(q1 , a)?
• δ ∗(q2 , a)?
• δ ∗(q0 , b)?

Figure 3: An NFA for {an : n > 0}.

Informally, a word w is accepted by an NFA if there is a path labelled


w from its initial state to some final state.

4
Defn. 2.6 The language L(M ) accepted by NFA M = (Q, Σ, δ, q0, F )
is
{w ∈ Σ∗ : δ ∗(q0, w) ∩ F 6= ∅}.

Why Nondeterminism?

Although many reasons may be put forth, 1 reason is that choices are
represented by nondeterminism succinctly.
For example, given NFA M1 and NFA M2, construct an NFA M3 such
that L(M3) = L(M1) ∪ L(M2).

Vous aimerez peut-être aussi