Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 18 NFA’s with -transitions –NFA- ’s Formal definition Simplifies construction –LNFA- –Showing LNFA  is a subset of LNFA and therefore a subset.

Similar presentations


Presentation on theme: "Lecture 18 NFA’s with -transitions –NFA- ’s Formal definition Simplifies construction –LNFA- –Showing LNFA  is a subset of LNFA and therefore a subset."— Presentation transcript:

1 Lecture 18 NFA’s with -transitions –NFA- ’s Formal definition Simplifies construction –LNFA- –Showing LNFA  is a subset of LNFA and therefore a subset of LFSA

2 Defining NFA- ’s

3 Change:  -transitions We now allow an NFA M to change state without reading input That is, we add the following categories of transitions to  –  (q  is allowed

4 Example a,b a aba b aab

5 Defining L(M) and LNFA- M accepts string x if one of the configurations reached is an accepting configuration –(q 0, x) |- * (f, ),f e A M rejects string x if all configurations reached are either not halting configurations or are rejecting configurations For an NFA- M, L(M) is the set of strings accepted by M LNFA- –Language L is in language class LNFA iff there exists an NFA M such that L(M) = L

6 LNFA- subset LFSA Recap of what we already know –Let M be any NFA –There exists an algorithm A 1 which constructs an FSA M’ such that L(M’) = L(M) New goal –Let M be any NFA- –There exists an algorithm A 2 which constructs an FSA M’ such that L(M’) = L(M)

7 Visualization Goal –Let M be any NFA- –There exists an algorithm A 2 which constructs an FSA M’ such that L(M’) = L(M) NFA- M FSA M’ A2A2

8 Modified Goal Question –Can we use any existing algorithms to simplify the task of developing algorithm A 2 ? Yes, we can use algorithm A 1 which converts an NFA M 1 into an FSA M’ such that L(M’) = L(M 1 ) NFA- M FSA M’A2A2 NFA- M FSA M’ Algorithm A 2 NFA  M 1 A1A1 A 2’

9 Reduction Sidebar Example of real-life reduction –Problem  2 that algorithm A 2 solves: Converting NFA- M into FSA M’ s.t. L(M’) = L(M) –Problem  1 that algorithm A 1 solves: Converting NFA M 1 into FSA M’ s.t. L(M’) = L(M 1 ) –Reduction Algorithm A 2’ : converts an NFA- M into an NFA M 1 s.t. L(M 1 ) = L(M) A 2’ maps input for problem  2 into an input for problem  1. –Essentially,  2 <= m  1 NFA- M FSA M’ Algorithm A 2 NFA  M 1 A1A1 A 2’

10 New Goal Difficulty –NFA- M can make transitions on –How can the NFA M 1 simulate these -transitions? NFA- M NFA M 1 A 2’ a bb 234561

11 Basic Idea For each state q of M and each character  of , figure out which states are reachable from q taking any number of -transitions and exactly one transition on that character . In the NFA-  M 1, directly connect q to each of these states using an arc labeled with . NFA- M NFA M 1 A 2’ a bb 234561 234561 b b b

12 Process State 2 NFA- M NFA-  M 1 A 2’ a bb 234561 234561 b b b b b b

13 Process State 3 NFA- M NFA-  M 1 A 2’ a bb 234561 234561 b b b b b b a a b

14 Final Picture NFA- M NFA-  M 1 A 2’ a bb 234561 234561 b b b b b b a a b b b a a

15 Construction Input NFA- M = (Q, , q 0, , A) Output NFA M 1 = (Q 1,  1, q 1,  1, A 1 ) –What is Q 1 ? Q 1 = Q In this case, Q 1 = {1,2,3,4,5,6} –What is  1 ?  1 =  In this case,  1 =  = {a,b} –What is q 1 ? We always make q 1 = q 0 In this case q 1 = 1 a bb 234561

16 Construction Input NFA- M = (Q, , q 0, , A) Output NFA M 1 = (Q 1,  1, q 1,  1, A 1 ) –What is  1 ?  1 (q,a) = the set of states reachable from state q in M taking any number of -transitions and exactly one transition on the character a –More on this later In this case –  1 (1,a) = {} –  1 (1,b) = {3,4,5} –What is A 1 ? A 1 = A with one minor change –If an accepting state is reachable from q 0 using only  -transitions, then we make q 1 an element of A 1 In this case, using only -transitions, no accepting state is reachable from q 0, so A 1 = A a bb 234561

17 Computing  1 (q,a)  1 (q,a) = the set of states reachable from state q in M taking 0 or more -transitions and exactly one transition on the character a –Break this down into three steps First compute all states reachable from q using 0 or more -transitions –We call this set of states  (q) Next, compute all states reachable from any element of  (q) using the character a –We can denote these states as  (  (q),a) Finally, compute all states reachable from states in  (  (q),a) using 0 or more -transitions –We denote these states as  (  (  (q),a)) –This is the desired answer a bb 234561

18 Example  1 (1,b) = {3,4,5} –Compute  (1), all states reachable from state 1 using 0 or more - transitions  (1) = {1,2} –Compute  (  (q),b), all states reachable from any element  (1) of using the character b:  (  (q),b) =  ({1,2},b) =  (1,b) U  (2,b) = {} U {3} = {3} –Compute  (  (  (q),a)), all states reachable from states in  (  (q),a) using 0 or more -transitions  (  (  (q),a)) =  (3) = {3,4,5} a bb 234561

19 Comments You should be able to execute this algorithm –Convert any NFA- into an equivalent NFA. You should understand the idea behind this algorithm –Why the transition function is computed the way it is –Why A 1 may need to include q 1 in some cases You should understand the importance of this algorithm –Compiler role again –Use in combination with previous algorithm for converting any NFA into an equivalent FSA to create a new algorithm for converting any NFA- into an equivalent FSA

20 LNFA- = LFSA Implications –Let us primarily use the term LFSA to refer to this language class –Given a language L is in LFSA We know there exists an FSA M s.t. L(M) = L We know there exists an NFA M s.t. L(M) = L –To show a language L is in LFSA Show there exists an FSA M s.t. L(M) = L Show there exists an NFA- M s.t. L(M) = L


Download ppt "Lecture 18 NFA’s with -transitions –NFA- ’s Formal definition Simplifies construction –LNFA- –Showing LNFA  is a subset of LNFA and therefore a subset."

Similar presentations


Ads by Google