1 / 14

Nondeterminism

CSC 4170 Theory of Computation. Nondeterminism. Section 1.2. 1.2.a. An NFA without  -transitions. q 1. 1. q 2. 0,1. q 3. 0,1. 0 1 0 1 0. What language does this NFA recognize?. 1.2.b. An NFA with  -transitions. 1. b. . a. a. 3. a,b. 2. b a b a b. Does this NFA accept:

carmine
Download Presentation

Nondeterminism

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSC 4170 Theory of Computation Nondeterminism Section 1.2

  2. 1.2.a An NFA without -transitions q1 1 q2 0,1 q3 0,1 0 1 0 1 0 What language does this NFA recognize?

  3. 1.2.b An NFA with -transitions 1 b  a a 3 a,b 2 b a b a b • Does this NFA accept: •  ? • a ? • b ? • aaa…a ?

  4. 1.2.c Formal definition of a nondeterministic finite automaton 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. 1.2.d Our automaton formalized 1 Q: : : s: F: b  a a a b  1 2 3 3 a,b 2 A = (Q, , , s, F)

  6. 1.2.e Formal definition of accepting by NFA M = (Q, , , s, F) 1 b  a a 3 a,b 2 • M accepts the string x iff x can be written as • u1 u2 … un • where each ui is in , andthere is a sequence • r1, r2,…, rn, rn+1 • of states such that: • r1= s • ri+1(ri,ui), for each i with 1in • rn+1  F Example: aa u1 u2 … un aa = r1, r2,…, rn, rn+1

  7. 1.2.f What language does this NFA recognize? 0 0   0 0 0 0 0 0 0 0 0 0 0

  8. 1.2.g What language does this DFA recognize? 1 2 0 0 0 0 3 0 0 5 4 0

  9. 1.2.h Equivalence of NFAs and DFAs Two machines are said to beequivalent, if they recognize the same language. Theorem 1.39Every 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 • For RQ and a, let • (R,a) = {q | q can be reached from R by traveling • along an a-arrow} a

  10. 1.2.i The Subset Construction 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. 1.2.j Q’: : ’: s’: F’: Applying the subset construction to our NFA N = (Q, , , s, F) 1 a b  {1} {2} {3} {1,2} {1,3} {2,3} {1,2,3} b  a a 3 a,b 2 • Q’ = P (Q) • ’(R,a) = (R,a) • s’ = {s} • F’= {R | R is a subset of Q containing an • accept state of N}

  12. 1.2.k {,{1},{2},{3}, {1,2},{1,3},{2,3},{1,2,3}} D a,b Q’: : ’: s’: F’: The resulting DFA {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} a {2} {1,2,3} {3} {1,2,3} {2,3} a b a,b {1,2,3} {1,2} {1,3} {{1},{1,2},{1,3},{1,2,3}} a

  13. 1.2.l {,{1},{2},{3}, {1,2},{1,3},{2,3},{1,2,3}} D a,b Q’: : ’: s’: F’: Removing unreachable states {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} a {2} {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. 1.2.m N D a,b Testing in work {3} b  1 a b  a b {1,3} b a a b 3 a,b 2 {2,3} a {2} a b b a a {1,2,3} a

More Related