61 Nondeterminism and Nodeterministic Automata. 62 The computational machine models that we learned in the class are deterministic in the sense that the.

Slides:



Advertisements
Similar presentations
CSC 361NFA vs. DFA1. CSC 361NFA vs. DFA2 NFAs vs. DFAs NFAs can be constructed from DFAs using transitions: Called NFA- Suppose M 1 accepts L 1, M 2 accepts.
Advertisements

Nondeterministic Finite Automata CS 130: Theory of Computation HMU textbook, Chapter 2 (Sec 2.3 & 2.5)
Finite Automata CPSC 388 Ellen Walker Hiram College.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 2 Mälardalen University 2005.
1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 3 School of Innovation, Design and Engineering Mälardalen University 2012.
YES-NO machines Finite State Automata as language recognizers.
Introduction to Computability Theory
1 Introduction to Computability Theory Lecture12: Decidable Languages Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.
Intro to DFAs Readings: Sipser 1.1 (pages 31-44) With basic background from Sipser 0.
Introduction to Computability Theory
Intro to DFAs Readings: Sipser 1.1 (pages 31-44) With basic background from Sipser 0.
CS5371 Theory of Computation
Courtesy Costas Busch - RPI1 Non Deterministic Automata.
Finite Automata Finite-state machine with no output. FA consists of States, Transitions between states FA is a 5-tuple Example! A string x is recognized.
Lecture 3 Goals: Formal definition of NFA, acceptance of a string by an NFA, computation tree associated with a string. Algorithm to convert an NFA to.
56 Rumination on the Formal Definition of DPDA In the definition of DPDA, there are some parts that do not agree with our intuition. Let M = (Q, , ,

CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Nondeterminism.
Lecture 3 Goals: Formal definition of NFA, acceptance of a string by an NFA, computation tree associated with a string. Algorithm to convert an NFA to.
FSA Lecture 1 Finite State Machines. Creating a Automaton  Given a language L over an alphabet , design a deterministic finite automaton (DFA) M such.
1 Non-Deterministic Automata Regular Expressions.
CS5371 Theory of Computation Lecture 8: Automata Theory VI (PDA, PDA = CFG)
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
Finite State Machines Data Structures and Algorithms for Information Processing 1.
Formal Language Finite set of alphabets Σ: e.g., {0, 1}, {a, b, c}, { ‘{‘, ‘}’ } Language L is a subset of strings on Σ, e.g., {00, 110, 01} a finite language,
NFA ε - NFA - DFA equivalence. What is an NFA An NFA is an automaton that its states might have none, one or more outgoing arrows under a specific symbol.
Lecture 03: Theory of Automata:08 Finite Automata.
Basics of automata theory
Nondeterministic Finite Automata CS 130: Theory of Computation HMU textbook, Chapter 2 (Sec 2.3 & 2.5)
DECIDABILITY OF PRESBURGER ARITHMETIC USING FINITE AUTOMATA Presented by : Shubha Jain Reference : Paper by Alexandre Boudet and Hubert Comon.
Lecture 07: Formal Methods in SE Finite Automata Lecture # 07 Qaisar Javaid Assistant Professor.
4b 4b Lexical analysis Finite Automata. Finite Automata (FA) FA also called Finite State Machine (FSM) –Abstract model of a computing entity. –Decides.
Push-down Automata Section 3.3 Fri, Oct 21, 2005.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2010.
CMSC 330: Organization of Programming Languages Finite Automata NFAs  DFAs.
NFA defined. NFA A Non-deterministic Finite-state Automata (NFA) is a language recognizing system similar to a DFA. It supports a level of non-determinism.
Recognising Languages We will tackle the problem of defining languages by considering how we could recognise them. Problem: Is there a method of recognising.
Modeling Computation: Finite State Machines without Output
Lecture 04: Theory of Automata:08 Transition Graphs.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2007.
Lecture Notes 
Finding Regular Simple Paths Sept. 2013Yangjun Chen ACS Finding Regular Simple Paths in Graph Databases Basic definitions Regular paths Regular simple.
Overview of Previous Lesson(s) Over View  A token is a pair consisting of a token name and an optional attribute value.  A pattern is a description.
Nondeterministic Finite Automata (NFAs). Reminder: Deterministic Finite Automata (DFA) q For every state q in Q and every character  in , one and only.
98 Nondeterministic Automata vs Deterministic Automata We learned that NFA is a convenient model for showing the relationships among regular grammars,
Chapter 5 Finite Automata Finite State Automata n Capable of recognizing numerous symbol patterns, the class of regular languages n Suitable for.
Finite Automata Great Theoretical Ideas In Computer Science Victor Adamchik Danny Sleator CS Spring 2010 Lecture 20Mar 30, 2010Carnegie Mellon.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.
Nondeterministic Finite State Machines Chapter 5.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2006.
Finite Automata A simple model of computation. 2 Finite Automata2 Outline Deterministic finite automata (DFA) –How a DFA works.
Prof. Busch - LSU1 Time Complexity. Prof. Busch - LSU2 Consider a deterministic Turing Machine which decides a language.
1 Section 11.2 Finite Automata Can a machine(i.e., algorithm) recognize a regular language? Yes! Deterministic Finite Automata A deterministic finite automaton.
Lecture #4 Thinking of designing an abstract machine acts as finite automata. Advanced Computation Theory.
Lecture #5 Advanced Computation Theory Finite Automata.
Theory of Computation Automata Theory Dr. Ayman Srour.
Deterministic Finite Automata (DFAs). Reminder: Functions vs Relations Let P = {p: p is a person} M = {m: m is a male} S 1 = {(m,p): m is in M, p is in.
Nondeterminism The Chinese University of Hong Kong Fall 2011
Theory of Computation Pushdown Automata pda Lecture #10.
Chapter 2 Finite Automata
Finite Automata.
Jaya Krishna, M.Tech, Assistant Professor
Chapter 2 FINITE AUTOMATA.
Hierarchy of languages
NFAs and Transition Graphs
Chapter Five: Nondeterministic Finite Automata
CSC312 Automata Theory Transition Graphs Lecture # 9
NFAs and Transition Graphs
Instructor: Aaron Roth
Presentation transcript:

61 Nondeterminism and Nodeterministic Automata

62 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). Nondeterminism and Nondeterministic Automata

63 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} a b a  a a, b b b * 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. Nondeterministic Automata (cont’ed)

64 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, , , q 0, Z 0, F ) as for DFA. The only difference is the transition function;  : Q    2 Q,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  (q 0, 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} *,  (q 0, 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. Nondeterministic Automata (cont’ed)

65 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 (q 2 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. q0q0 q1q1 q2q2 a b b a,b b Figure (a): An NFA q0q0 q1q1 q2q2 a b b q0q0 q0q0 q0q0 q1q1 q1q1 q1q1 X X b b bb b b a Figure (b): The profile of nondeterministic transition for input string bbba. Nondeterministic Automata (cont’ed)

66 Designing NFA: a a a, b {xaa | x  {a, b} * } a a a, b b b {x | x  {a, b} * and there is aa followed by bb somewhere in x} Nondeterministic Automata (cont’ed)

67 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) | > 1, or (b) |  (q, t, s) |  0 and |  (q, , s) |  0 (see case * above) Nondeterministic transitions:  (1, a, b) = {(2, aa), (3, aa)}  (3, b, a) = {(3,  ), (3, ba)}  (4, a, b) = {(4, ab)}  (4, , b ) = {(2,  )} Deterministic transitions:  (2, a, b) = {(3, ab)}  (3, a, b) = {(4, ab)}  (3, b, b) = {(2, bb)}  (4, b, a) = {(2, ba)} }*}* (a, b/aa) (b, a/  ), (b, a/ba), (a, a/aa) (b, b/bb) (a, b/ab) (a, b/ab), ( , b/  ) (b, a/ba) Nondeterministic Automata (cont’ed)

68 Designing NPDA: Nondeterministic Automata (cont’ed) q0q0 q1q1 q2q2 q3q3 (X, Z 0 /X Z 0 ) (Y, X/YX ) ( , X/X ) (X, X/  ) ( , Z 0 /Z 0 ) start Figure (a): NPDA accepting {xx R | x  {a, b} + } X, Y  {a, b}

69 Nondeterministic Automata (cont’ed) Designing NPDA: Figure (b): NPDA accepting {a i b j c k | i, j, k > 0, and i = j or j = k } start (a, Z 0 /aZ 0 ) (b, a/  ) (c, Z 0 / Z 0 ) (a, a/ aa) (a, Z 0 /Z 0 ) (c, Z 0 / Z 0 ) (b, Z 0 /bZ 0 ) (b, b/bb) (c, b/  ) ( , Z 0 / Z 0 )

70 Nodeterministic TM and LBA: (a, b, R) (a, b, R), (a, b, L), (b, a, L) (b, a, R), (b, b, R) (b, a, R) (a, b, R) (b, a, L) 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)} Nondeterministic Automata (cont’ed) Notice that if there is a pair of a state q and a symbol t such that |  (q, t) | > 1, then the automaton is nondeterministic.

71 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. Nondeterminism and nondeterministic Algorithms. x = nondet_choose (q, r) ;.

72. x = nondet_choose (q, r) ;. x = nondet_choose (q, r) ; {proceed with x = q). x = nondet_choose (q, r) ; (proceed with x = r). 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. Nondeterministic Algorithms This way nondeterministic algorithms can search the solution space of the given problem simultaneously. As in the nondeterministic automata, if t here is no instances of computation generating the answer, we say the a lgorithm fails to give the answer.

73 Nondeterministic Algorithms (cont’ed) 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 = 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.

74 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 < n; i++) { selected = nondet_choose(true, false); if (selected) sum += S[i]; } if (sum = = M) return “yes”; else return “no”; } Nondeterministic Algorithms (cont’ed) Notice that in the algorithm above, by selected = nondet_choose(true, false) for each element S[i], 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.