Nondeterminism and Nodeterministic Automata - PowerPoint PPT Presentation

About This Presentation
Title:

Nondeterminism and Nodeterministic Automata

Description:

Thus, the state transition graphs of DFA's have one (and only one) edge for each ... ( Recall that, just for convenience, we agreed not to draw the edge for a ... – PowerPoint PPT presentation

Number of Views:48
Avg rating:3.0/5.0
Slides: 15
Provided by: csR4
Learn more at: http://www.cs.rpi.edu
Category:

less

Transcript and Presenter's Notes

Title: Nondeterminism and Nodeterministic Automata


1
Nondeterminism and Nodeterministic Automata
2
Nondeterminism and Nondeterministic Automata
  • The computational machine models that we
    learned in the class are deterministic in the
    sense that the next move is uniquely determined
    by the current state and the input (i.e.,
    external stimulus). Thus, the state transition
    graphs of DFA's have one (and only one) edge for
    each input symbol. (Recall that, just for
    convenience, we agreed not to draw the edge for a
    transition with an input symbol leading to the
    dead state.) Deterministic machines follow our
    intuition, because the models are based on the
    determinism, which propose that, for a given
    cause (current state of the system and external
    input), the effect (state change and the output
    of the system) is uniquely determined.
  • Nondeterminism does not go along our intuition
    because it allows multiple conflicting effects
    for a given cause. Consider the state transition
    graph shown on the following page, which has
    transitions which violate the determinism. For
    example, the transition ?(1, a) 1, 2 says
    that in state 1 the automaton, reading input
    symbol a, enters states 1 and 2. (Note that the
    machine enters states 1 and 2 at the same time.We
    call such machines nondeterministic finite
    automata (NFA).

3
Nondeterministic Automata (conted)
Nodeterministic FA
Nondeterministic transitions ?(1, a) 1, 2
?(4, b) 2, 3, 4 ?(2, ?) 2, 3
Deterministic transitions ?(1, b) 3 ?(3,
a) 4 ?(4, a) 2
Notice that in any state p, the machine stays
in the same state while there is no input,
which implicitly there is ?(p, ?) p.
Therefore, if there is an explicit transition,
like from state 2 to state 3 in the above graph,
the transition is nondeterministic,
because ?(2, ?) 2, 3. We will deal with such
?-transitions later as a separate topic. Until
then we study nondeterministic automata with no
?-transitions.
4
Nondeterministic Automata (conted)
If an FA has transition ?(p, a) q, r, we
say that the machine, in state p reading a,
nondeterministically enters states q and r. After
taking this transition, the machine is in both q
and r. We think that two machines, one in q and
the other in r, continue the computation
independently for the same input. Formally an NFA
M is defined by the same tuple M (Q, ?, ?, q0,
Z0, F ) as for DFA. The only difference is the
transition function ? Q ? ? ? 2Q ,which
implies that in a state in Q, reading a symbol in
?, the machine can enter simultaneously in some
states (i.e., a subset of Q). Notice that DFA is
a special case of NFA which for an input symbol,
takes a transition to a single state. For a
string x, let ?(q0, x) S, where S is the set of
states that the machine enters after reading
string x. The language accepted by an NFA M is
defined as follows L(M) x x ? a,b,
?(q0, x) S, and S ? F ? ? . Notice the
accepting condition, S ?F ? ? . This implies that
if there exists at least one sequence of
transition that ends up in an accepting state,
then we say the input x is accepted. All
non-accepting cases are ignored. If there is no
accepting case (i.e., S ? F ?), then we say the
input is rejected.
5
Nondeterministic Automata (conted)
  • For example, consider the NFA shown in Figure
    (a) below. Figure (b) shows all possible
    sequences of transitions for input bbba, where
    nodes with label X denote the dead state which is
    not shown on the state transition graph. String
    bbba is accepted by the machine since there
    exists a sequence of transitions, which ends in
    an accepting state (q2 in the figure). Note that
    NFA's are similar to parallel machines in the
    sense that they explore an answer simultaneously
    in more than one way. However, nondeterministic
    machines do not produce (or announce) the final
    result out of all possible sequences of
    operations. We, the user, must search all
    possible terminating states of the machine and
    decide whether it satisfies the accepting
    condition or not.

6
Nondeterministic Automata (conted)
Designing NFA
7
Nondeterministic Automata (conted)
Nodeterministic PDA
Notice that a PDA is nondeterministic if there is
a state q, an input symbol t, and a stack symbol
s such that either (a) ?(q, t, s) gt 1,
or (b) ?(q, t, s) ? 0 and ?(q, ?, s)
? 0 (see case above)
8
Nondeterministic Automata (conted)
Designing NPDA
9
Nondeterministic Automata (conted)
Designing NPDA
Figure (b) NPDA accepting aibjck i, j, k gt 0,
and i j or j k
10
Nondeterministic Automata (conted)
Nodeterministic TM and LBA
Nondeterministic transitions ?(1, a) (2, b,
R), (3, b, R) ?(2, b) (2, a, R), (2, b, R),
(2, a, L) ?(3, a) (4, b, R), (4, b,
L) Deterministic transitions ?(3, b) (4, a,
L) ?(4, a) (4, b, R) ?(4, b) (2, a, R)
Notice that if there is a pair of a state q and
a symbol t such that ?(q, t) gt 1, then the
automaton is nondeterministic.
11
Nondeterminism and nondeterministic Algorithms
Nondeterministic automata are different from
probabilistic machines which change their state
based on some probability. If an NFA has
nondetermininistic transition ? (p, a) q, r,
then reading a in state p the machine definitely
enters both states q and r. The same concept of
nondeterminism can be applied to algorithm
design. Instead of nondeterministic transition,
we use nondeterministic guess (or choose) in
nondeterministic algorithms. For a finite set S,
let nondet_choose(S) mean nondeterministically
choosing an element in S. For example,
suppose that in an algorithm we have the
following statement.
.
.
x nondet_choose (q, r)
. .


12
Nondeterministic Algorithms
Upon execution of this assignment statement the
algorithm forks into two independently running
program instances, one with x q, and the other
with x r.
This way nondeterministic algorithms can search
the solution space of the given problem
simultaneously. As in the nondeterministic
automata, if there is no instances of
computation generating the answer, we say the
algorithm fails to give the answer.
13
Nondeterministic Algorithms (conted)
If we assume that the statement nondet_choose( )
takes constant time, we can solve many, so
called, intractable problems, for which only
exponential-time algorithms are available, can be
solved in polynomial time. For example, consider
the sum-of-subset problem, which is given as
follows
Given a set S of n integers and an integer M, is
there any sum of subset of S that is equal to M?
Given S 8, 21, 13, 20, 7, 11, 5 and M 34,
for example, the answer should be yes, since 8
21 5 34. This problem, which is one of the
well known intractable problems, can be
solved in linear-time, if we use the function
nondet_choose( ). Suppose that the set S is given
in an array. The nondeterministic algorithm in
the following slide solves the problem in
linear-time.
14
Nondeterministic Algorithms (conted)
Nondet-Sum-of-Subset (int S , int n, int M) //
S is an integer array of size n. int i,
sum 0 boolean selected for ( i 0 i
lt n i) selected nondet_choose(true,
false) if (selected) sum Si
if (sum M) return yes else
return no
Notice that in the algorithm above, by
selected nondet_choose(true, false) for
each element Si, we are considering both cases
of adding and not adding it to the sum. Thus the
algorithm examines all possible sums of subsets.
If there is an output yes, then we can say
the answer is yes, ignoring all other no
answers.
Write a Comment
User Comments (0)
About PowerShow.com