Docsity

Converting NFA-λ to Equivalent FSA: Algorithm and Explanation - Prof. Eric Torng, Study notes of Computer Science

Toggle sidebar
bg1
1
1
Module 20
• NFA’s with λ-transitions
– NFA-λ’s
• Formal definition
• Simplifies construction
– LNFA-λ
– Showing LNFA−λ is a subset of LNFA (extra
credit)
• 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
a,b
a b a
b
a,b a,b
aab
λ
λ
5
Defining L(M) and LNFA-λ *
• M accepts string x if one
of the configurations
reached is an accepting
configuration
– (q0, x) |-*(f, λ),f A
• M rejects string x if all
configurations reached are
either not halting
configurations or are
rejecting configurations
• L(M) or Y(M)
• N(M)
• LNFA-λ
– Language L is in
language class LNFA-
λiff
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)
pf3
pf4

Partial preview of the text

Download Converting NFA-λ to Equivalent FSA: Algorithm and Explanation - Prof. Eric Torng and more Study notes Computer Science in PDF only on Docsity!

1

Module 20

• NFA’s with λ-transitions

  • NFA-λ’s
    • Formal definition
    • Simplifies construction
  • LNFA-λ
  • Showing LNFA−λ is a subset of LNFA (extra

credit)

  • 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

a,b a b a

b

a,b a,b

a a b

λ

λ

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  A
  • M rejects string x if all configurations reached are either not halting configurations or are rejecting configurations - L(M) or Y(M) - N(M) - LNFA-λ - Language L is in language class LNFA- λ iff

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 A 2 FSA M’

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 A 2 FSA M’

NFA-λ M FSA M’

Algorithm A 2

NFA

M 1

A2’ A 1

9

New Goal

(extra credit)

  • Difficulty
    • NFA-λ M can make transitions on λ
    • How can the NFA M 1 simulate these λ-transitions?

NFA-λ M A2’ NFA M 1

λ λ

a b λ b 1 2 3 4 5 6

10

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 A2’ NFA M 1

λ λ

a b λ b 1 2 3 4 5 6

b b

b

11

Process State 2 NFA-λ^ M^ A2’ NFA-δ^ M 1

λ λ

a b λ b 1 2 3 4 5 6

b b

b

b (^) b

b

12

Process State 3 NFA-λ^ M^ A2’ NFA-δ^ M 1

λ λ

a b λ b 1 2 3 4 5 6

b b

b

b (^) b

b

a a

b

19

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