Lecture 6 Nondeterministic Finite Automata (NFA)

download Lecture 6 Nondeterministic Finite Automata (NFA)

of 23

  • date post

    14-Dec-2015
  • Category

    Documents

  • view

    221
  • download

    3

Embed Size (px)

Transcript of Lecture 6 Nondeterministic Finite Automata (NFA)

  • Slide 1

Lecture 6 Nondeterministic Finite Automata (NFA) Slide 2 NFA Finite Control tape head Slide 3 The tape is divided into finitely many cells. Each cell contains a symbol in an alphabet . al ph a b e t Slide 4 The head scans at a cell on the tape and can read a symbol on the cell. In each move, the head move to the right cell or stop there (in a -move). a Slide 5 The finite control has finitely many states which form a set Q. For each move, the state is changed according to the evaluation of a transition function : Q x ( U {}) 2 (the family of all subsets of Q) QQ Slide 6 (q, a) = {p 1, p 2 } for a in means that if the head reads symbol a and the finite control is in the state q, then the next state should be p 1 or p 2, and the head moves one cell to the right. p q a a p=p 1 or p 2 Slide 7 (q, ) = {p 1, p 2 } means that if the finite control is in the state q, then the next state can be be p 1 or p 2, and the head does not move. This move is called a -move. p q a p=p 1 or p 2 a Slide 8 (q, a) = means that the NFA is stuck. q a ? Slide 9 There are some special states: an initial state s and a final set F of final states. Initially, the NTM is in the initial state s and the head scans the leftmost cell. The tape holds an input string. s Slide 10 When the head gets off the tape, the NFA stops. An input string x is accepted by the NFA if there is a computation path to make the NFA stop at a final state. Otherwise, the input string is rejected. h x Slide 11 The NTM can be represented by M = (Q, , , s, F) where is the alphabet of input symbols. The set of all strings accepted by a NFA M is denoted by L(M). We also say that the language L(M) is accepted by M. Slide 12 The transition diagram of a NFA is an alternative way to represent the DFA. For M = (Q, , , s, F), the transition diagram of M is a symbol-labeled digraph G=(V, E) satisfying the following: V = Q (s =, f = for f \in F) E = { q p | p \in (q, a)}. a Slide 13 0 1 s p, s s p q s q q q s p q 0,1 0 1 0 0 Slide 14 Theorem 1 Every regular language can be accepted by an NFA. Slide 15 G(r) For each regular expression r, we can construct a digraph G(r) with edges labeled by symbols and as follows. If r=, then If r, then Slide 16 Slide 17 ** Slide 18 Slide 19 (01+111)* (01)*(111)* 10(0+1)*00 10(0+1)*+(0+1)*00 ((01)*(10)*0*)* Slide 20 10(0+1)*+(0+1)*00 10(0+1)* (0+1)*00 10 (0+1)* 0 0 1 0 0 0 0,1 Slide 21 (0+1)*0(0+1) 5 0,1 000000 11 1 1 1 Slide 22 Given an NFA M, construct an NFA accepting L(M). R 0 1 0 0 1 0 0 0 1 1 Slide 23 0 1 0 0 1 First, turn NFA to DFA and then do. Is it correct? Answer: No! What is the correct way?