1 / 20

Lecture 21

Lecture 21. NFA’s with l -transitions NFA- l ’s Formal definition Simplifies construction LNFA- l Showing LNFA -l is a subset of LNFA (extra credit) and therefore a subset of LFSA. Defining NFA- l ’s. Change: l -transitions. We now allow an NFA M to change state without reading input

gannon
Download Presentation

Lecture 21

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. Lecture 21 • NFA’s with l-transitions • NFA-l’s • Formal definition • Simplifies construction • LNFA-l • Showing LNFA-l is a subset of LNFA (extra credit) • and therefore a subset of LFSA

  2. Defining NFA-l’s

  3. Change: l-transitions • We now allow an NFA M to change state without reading input • That is, we add the following categories of transitions to d • d(q,l) is allowed

  4. a,b a,b a a b a l b a a b l a,b a,b Example

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

  6. LNFA-l subset LFSA • Recap of what we already know • Let M be any NFA • There exists an algorithm A1 which constructs an FSA M’ such that L(M’) = L(M) • New goal • Let M be any NFA-l • There exists an algorithm A2 which constructs an FSA M’ such that L(M’) = L(M)

  7. A2 Visualization • Goal • Let M be any NFA-l • There exists an algorithm A2 which constructs an FSA M’ such that L(M’) = L(M) NFA-l M FSA M’

  8. NFA M1 NFA-l M A2 FSA M’ A2’ A1 NFA-l M FSA M’ Algorithm A2 Modified Goal • Question • Can we use any existing algorithms to simplify the task of developing algorithm A2? • Yes, we can use algorithm A1 which converts an NFA M1 into an FSA M’ such that L(M’) = L(M1)

  9. NFA M1 A2’ A1 NFA-l M FSA M’ Algorithm A2 Answer-Preserving Input Transformation Sidebar • Example of real-life answer-preserving input transformation • Problem P2 that algorithm A2 solves: Converting NFA-l M into FSA M’ s.t. L(M’) = L(M) • Problem P1 that algorithm A1 solves: Converting NFA M1 into FSA M’ s.t. L(M’) = L(M1) • Input Transformation Algorithm A2’: converts an NFA-l M into an NFA M1 s.t. L(M1) = L(M) • A2’ maps input for problem P2 into an input for problem P1. • Essentially, P2 <= P1

  10. NFA-l M A2’ NFA M1 New Goal (extra credit) • Difficulty • NFA-l M can make transitions on l • How can the NFA M1 simulate these l-transitions? a l b l l b 1 2 3 4 5 6

  11. NFA-l M A2’ NFA M1 b b b Basic Idea • For each state q of M and each character a of S, figure out which states are reachable from q taking any number of l-transitions and exactly one transition on that character a. • In the NFA-d M1, directly connect q to each of these states using an arc labeled with a. a l b l l b 1 2 3 4 5 6 1 2 3 4 5 6

  12. NFA-d M1 NFA-l M A2’ b b b b b b Process State 2 a l b l l b 1 2 3 4 5 6 1 2 3 4 5 6

  13. NFA-d M1 NFA-l M A2’ b a b b a b b b b Process State 3 a l b l l b 1 2 3 4 5 6 1 2 3 4 5 6

  14. a l b l l b 1 2 3 4 5 6 NFA-d M1 NFA-l M A2’ b b b b b b Final Picture a a a a b 1 2 3 4 5 6 b b

  15. Input NFA-l M = (Q, S, q0, d, A) Output NFA M1 = (Q1, S1, q1, d1, A1) What is Q1? Q1 = Q In this case, Q1 = {1,2,3,4,5,6} What is S1? S1 = S In this case, S1 = S = {a,b} What is q1? We always make q1 = q0 In this case q1 = 1 a l b l l b 1 2 3 4 5 6 Construction

  16. Input NFA-l M = (Q, S, q0, d, A) Output NFA M1 = (Q1, S1, q1, d1, A1) What is d1? d1(q,a) = the set of states reachable from state q in M taking any number of l-transitions and exactly one transition on the character a More on this later In this case d1(1,a) = {} d1(1,b) = {3,4,5} What is A1? A1 = A with one minor change If an accepting state is reachable from q0 using only l-transitions, then we make q1 an element of A1 In this case, using only l-transitions, no accepting state is reachable from q0, so A1 = A a l b l l b 1 2 3 4 5 6 Construction

  17. d1(q,a) = the set of states reachable from state q in M taking 0 or more l-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 l-transitions We call this set of states L(q) Next, compute all states reachable from any element of L(q) using the character a We can denote these states as d(L(q),a) Finally, compute all states reachable from states in d(L(q),a) using 0 or more l-transitions We denote these states as L(d(L(q),a)) This is the desired answer a l b l l b 1 2 3 4 5 6 Computing d1(q,a)

  18. d1(1,b) = {3,4,5} Compute L(1), all states reachable from state 1 using 0 or more l-transitions L(1) = {1,2} Compute d(L(q),b), all states reachable from any element L(1) of using the character b: d(L(q),b) = d({1,2},b) = d(1,b) U d(2,b) = {} U {3} = {3} Compute L(d(L(q),a)), all states reachable from states in d(L(q),a) using 0 or more l-transitions L(d(L(q),a)) = L(3) = {3,4,5} a l b l l b 1 2 3 4 5 6 Example

  19. Comments • For extra credit, you should be able to execute this algorithm • Convert any NFA-l into an equivalent NFA. • For extra credit, you should understand the idea behind this algorithm • Why the transition function is computed the way it is • Why A1 may need to include q1 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-l into an equivalent FSA

  20. LNFA-l = 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-l M s.t. L(M) = L

More Related