Nondeterminism - PowerPoint PPT Presentation

About This Presentation
Title:

Nondeterminism

Description:

Nondeterminism. Section 1.2. CSC 4170. Theory of Computation. An NFA without -transitions ... 0 1 0 1 0. What language does this NFA recognize? An NFA with ... – PowerPoint PPT presentation

Number of Views:30
Avg rating:3.0/5.0
Slides: 15
Provided by: giorgija
Category:

less

Transcript and Presenter's Notes

Title: Nondeterminism


1
Nondeterminism
CSC 4170 Theory of Computation
Section 1.2
2
An NFA without ?-transitions
1.2.a
q1
q2
q3
1
0,1
0,1
0 1 0 1 0
What language does this NFA recognize?



3
An NFA with ?-transitions
1.2.b
1
b
?
a
a
3
2
a,b
b a b a b
  • Does this NFA accept
  • ? ?
  • a ?
  • b ?
  • aaaa ?




4
Formal definition of a nondeterministic finite
automaton
1.2.c
Let ?? ? ? ?
  • A NFA is a 5-tuple (Q, ?, ?, s, F), where
  • Q is a finite set called the states,
  • ? is a finite set called the alphabet,
  • ? is a function of the type Q??? ? P(Q)
    called the transition function,
  • s is an element of Q called the start state,
  • F is a subset of Q called the set of accept
    states.




5
Our automaton formalized
1.2.d
1
Q ? ? s F
b
?
a
a
a b ? 1 2 3

3
2
a,b

A (Q, ?, ?, s, F)



6
Formal definition of accepting by NFA
1.2.e
M (Q, ?, ?, s, F)
1
b
?
a
a
3
2
a,b
  • M accepts the string x iff x can be written as
  • u1 u2 un
  • where each ui is in ??, and there is a sequence
  • r1, r2, , rn, rn1
  • of states such that
  • r1 s
  • ri1? ?(ri,ui), for each i with 1? i ? n
  • rn1 ? F

Example aa
u1 u2 un
aa
r1, r2, , rn, rn1



7
What language does this NFA recognize?
1.2.f


0
0
?

?
0
0
0
0 0 0 0 0 0 0 0



8
What language does this DFA recognize?
1.2.g

2
1
0
0
0
0
3
0
0
5
4
0



9
Equivalence of NFAs and DFAs
1.2.h
Two machines are said to be equivalent, if they
recognize the same language.
Theorem 1.39 Every NFA has an equivalent DFA.
Proof. Consider an NFA
N (Q, ?, ?, s, F) We need
construct an equivalent DFA
D (Q, ?, ?, s,
F) using a procedure called the subset
construction (next slide).
  • Notation
  • For R?Q, let
  • R q q can be reached from R by
    traveling
  • along 0 or more ?-arrows

a
a
a
  • For R?Q and a??, let
  • ?(R,a) q q can be reached from R by
    traveling
  • along an a-arrow



10
The Subset Construction
1.2.i
Constructing DFA D (Q, ?, ?, s, F) from
NFA N (Q, ?, ?, s, F)
  • Q P (Q)
  • ?(R,a) ?(R,a)
  • s s
  • F R R is a subset of Q containing an accept
    state of N
  • D obviously works correctly
  • at every step in the computation, it
    clearly enters a state that
  • corresponds to the subset of states
    that N could be in at that point.

a
?
a
?
a


11
Applying the subset construction to our NFA
1.2.j
Q ? ? s F
N (Q, ?, ?, s, F)
1
a b ?
1 2 3 1,2 1,3 2,3 1,2,3
b
?
a
a
3
2
a,b
  • Q P (Q)
  • ?(R,a) ?(R,a)
  • s s
  • F R R is a subset of Q containing an
  • accept state of N




12
The resulting DFA
1.2.k
?,1,2,3, 1,2,1,3,2,3,1,2,3
D
a,b
Q ? ? s F
3
?
b
a,b
a
a
a b ?
1 2 3 1,2 1,3 2,3 1,2,3
b
? ?
1,3
1
? 2
b
2,3 3
a
b
b
1,3 ?
2,3 2,3
1,3 2
2,3
2
a
1,2,3 3
1,2,3 2,3
a
a,b
b

1,2
1,2,3
1,3
1,1,2,1,3,1,2,3
a



13
Removing unreachable states
1.2.l
?,1,2,3, 1,2,1,3,2,3,1,2,3
D
a,b
Q ? ? s F
3
?
b
a,b
a
a b ?
1 2 3 1,2 1,3 2,3 1,2,3
b
? ?
1,3
? 2
b
2,3 3
a
b
1,3 ?
2,3 2,3
1,3 2
2,3
2
a
1,2,3 3
1,2,3 2,3
a
b

1,2,3
1,3
1,1,2,1,3,1,2,3
a



14
Testing in work
1.2.m
N D
a,b
3
?
b
1
a
b
?
a
b
1,3
b
a
a
b
3
2
a,b
2,3
2
a
a
b
b a a
1,2,3
a

Write a Comment
User Comments (0)
About PowerShow.com