NonDeterministic Finite Automata - PowerPoint PPT Presentation

1 / 115
About This Presentation
Title:

NonDeterministic Finite Automata

Description:

Formal Definition of NFAs. Set of states, i.e. Input aplhabet, i.e. Transition function ... Is the result of following exactly. one transition. Fall 2005 ... – PowerPoint PPT presentation

Number of Views:136
Avg rating:3.0/5.0
Slides: 116
Provided by: costas
Category:

less

Transcript and Presenter's Notes

Title: NonDeterministic Finite Automata


1
Non-Deterministic Finite Automata
2
Nondeterministic Finite Automaton (NFA)
Alphabet
3
Alphabet
Two choices
4
Alphabet
Two choices
No transition
No transition
5
First Choice
6
First Choice
7
First Choice
8
First Choice
All input is consumed
accept
9
Second Choice
10
Second Choice
11
Second Choice
No transition the automaton hangs
12
Second Choice
Input cannot be consumed
reject
13
An NFA accepts a string if there is a
computation of the NFA that accepts the string
i.e., all the input is consumed and the
automaton is in an accepting state
14
Example
is accepted by the NFA
accept
reject
because this computation accepts
15
Rejection example
16
First Choice
17
First Choice
reject
18
Second Choice
19
Second Choice
20
Second Choice
reject
21
An NFA rejects a string if there is no
computation of the NFA that accepts the string.
For each computation
  • All the input is consumed and the
  • automaton is in a non final state

OR
  • The input cannot be consumed

22
Example
is rejected by the NFA
reject
reject
All possible computations lead to rejection
23
Rejection example
24
First Choice
25
First Choice
No transition the automaton hangs
26
First Choice
Input cannot be consumed
reject
27
Second Choice
28
Second Choice
29
Second Choice
No transition the automaton hangs
30
Second Choice
Input cannot be consumed
reject
31
is rejected by the NFA
reject
reject
All possible computations lead to rejection
32
Language accepted
33
Lambda Transitions
34
(No Transcript)
35
(No Transcript)
36
(read head does not move)
37
(No Transcript)
38
all input is consumed
accept
String is accepted
39
Rejection Example
40
(No Transcript)
41
(read head doesnt move)
42
No transition the automaton hangs
43
Input cannot be consumed
reject
String is rejected
44
Language accepted
45
Another NFA Example
46
(No Transcript)
47
(No Transcript)
48
(No Transcript)
49
accept
50
Another String
51
(No Transcript)
52
(No Transcript)
53
(No Transcript)
54
(No Transcript)
55
(No Transcript)
56
(No Transcript)
57
accept
58
Language accepted
59
Another NFA Example
60
Language accepted
(redundant state)
61
Remarks
  • The symbol never appears on the
  • input tape
  • Simple automata

62
  • NFAs are interesting because we can
  • express languages easier than DFAs

NFA
DFA
63
Formal Definition of NFAs

Set of states, i.e.
Input aplhabet, i.e.
Transition function
Initial state
Accepting states
64
Transition Function
Is the result of following exactly one
transition
65
(No Transcript)
66
(No Transcript)
67
(No Transcript)
68
Extended Transition Function

69
(No Transcript)
70
(No Transcript)
71
Formally
there is a walk from to with label
72
The Language of an NFA

73

74

75

76

77
Formally
  • The language accepted by NFA is
  • where
  • and there is some

(accepting state)
78

79
NFAs accept the Regular Languages

80
Equivalence of Machines
  • Definition
  • Machine is equivalent to machine
  • if

81
Example of equivalent machines

NFA
DFA
82
We will prove
Languages accepted by NFAs
Regular Languages
Languages accepted by DFAs
NFAs and DFAs have the same computation power
83
We will show
Languages accepted by NFAs
Regular Languages
Languages accepted by NFAs
Regular Languages
84
Proof-Step 1
Languages accepted by NFAs
Regular Languages
Proof
Every DFA is trivially an NFA
Any language accepted by a DFA is also
accepted by an NFA
85
Proof-Step 2
Languages accepted by NFAs
Regular Languages
Any NFA can be converted to an equivalent DFA
Proof
Any language accepted by an NFA is also
accepted by a DFA
86
Convert NFA to DFA

NFA
DFA
87
Convert NFA to DFA

NFA
DFA
88
Convert NFA to DFA

NFA
DFA
89
Convert NFA to DFA

NFA
DFA
90
Convert NFA to DFA

NFA
DFA
91
Convert NFA to DFA

NFA
DFA
92
Convert NFA to DFA

NFA
DFA
93
NFA to DFA Remarks
  • We are given an NFA
  • We want to convert it
  • to an equivalent DFA
  • With

94
  • If the NFA has states
  • the DFA has states in the powerset

95
Procedure NFA to DFA
  • 1. Initial state of NFA
  • Initial state of DFA

96
Example

NFA
DFA
97
Procedure NFA to DFA
  • 2. For every DFAs state
  • Compute in the NFA
  • Add transition to DFA

98
Exampe

NFA
DFA
99
Procedure NFA to DFA
  • Repeat Step 2 for all letters in alphabet,
  • until
  • no more transitions can be added.

100
Example

NFA
DFA
101
Procedure NFA to DFA
  • 3. For any DFA state
  • If some is accepting state in NFA
  • Then,
  • is accepting state in DFA

102
Example

NFA
DFA
103
Theorem
Take NFA

Apply conversion procedure to obtain DFA
Then and are equivalent

104
Proof
AND
105
First we show
Take arbitrary
We will prove
106
NFA
NFA
107
denotes
108
We will show that if
NFA
then
DFA
109
More generally, we will show that if in
(arbitrary string)
NFA
then
DFA
110
Proof by induction on
Induction Basis
NFA
DFA
Is true by construction of
111
Induction hypothesis
NFA
DFA
112
Induction Step
NFA
DFA
113
Induction Step
NFA
DFA
114
Therefore if
NFA
then
DFA
115
We have shown
We also need to show
(proof is similar and omitted)
Write a Comment
User Comments (0)
About PowerShow.com