Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
20 views

Lecture 5 NFA Equivalence

This document discusses the equivalence of non-deterministic finite automata (NFAs) and deterministic finite automata (DFAs). It shows that for every NFA there exists an equivalent DFA by constructing a DFA from an NFA that simulates the NFA's computation. The construction creates DFA states that are subsets of the NFA states and defines transitions between these states to account for the non-determinism in the NFA.

Uploaded by

vbweuhvbw
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Lecture 5 NFA Equivalence

This document discusses the equivalence of non-deterministic finite automata (NFAs) and deterministic finite automata (DFAs). It shows that for every NFA there exists an equivalent DFA by constructing a DFA from an NFA that simulates the NFA's computation. The construction creates DFA states that are subsets of the NFA states and defines transitions between these states to account for the non-determinism in the NFA.

Uploaded by

vbweuhvbw
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

Lecture 5: NFA Equivalence

CSC 320: Foundations of Computer Science


Quinton Yong
quintonyong@uvic.ca
NFAs and DFAs
• A DFA can be considered a special case of an NFA
• We just have to change the transition function definition slightly

1 𝑞2 0, 1 1 𝑞2 0, 1

𝑞1 𝑞3 0, 1 𝑞1 𝑞3 0, 1

• Identical state
0 0 diagram
DFA 𝑴 NFA 𝑴′
𝑞1 , 𝑞2 , 𝑞3 , 0, 1 , 𝛿, 𝑞1 , 𝑞3 with 𝑞1 , 𝑞2 , 𝑞3 , 0, 1 , 𝛿, 𝑞1 , 𝑞3 with
𝛿: 𝑄 × Σ → 𝑄 defined by 𝛿: 𝑄 × Σ ∪ 𝜀 → 𝒫(𝑄) defined by
𝜹 𝟎 𝟏 𝜹 𝟎 𝟏 𝜺
𝑞1 𝑞3 𝑞2 𝑞1 {𝑞3 } {𝑞2 } ∅ • Next states are
𝑞2 𝑞3 𝑞3 𝑞2 {𝑞3 } {𝑞3 } ∅ singleton sets
𝑞3 𝑞3 𝑞3 𝑞3 {𝑞3 } {𝑞3 } ∅ • No 𝜀 transitions
NFAs and DFAs

• Recall that this state diagram was not a valid DFA


• 𝒒𝟑 does not have an outgoing transition for symbol 2

𝑞4 0, 1, 2

𝑞3 0, 1

• However, this is a valid state diagram for an NFA


• In NFAs, we do not require outgoing transitions for each alphabet symbol from
every state
NFAs and DFAs

• Definition: Let 𝑴𝟏 and 𝑴𝟐 each be a DFA or an NFA. We call 𝑴𝟏 and 𝑴𝟐


equivalent if 𝑳 𝑴𝟏 = 𝑳(𝑴𝟐 ).

• Clearly, for every DFA there exists an equivalent NFA

• Recall, we claimed that the computational power of DFAs and NFAs are equal

• So, we will also prove that for every NFA there also exists an equivalent DFA
Equivalence of NFAs and DFAs
First: We show that for every DFA, there exists an equivalent NFA

Proof: (easy)
Let 𝑫 = (𝑸𝑫, 𝚺, 𝜹𝑫, 𝒒𝑫, 𝑭𝑫) be a DFA.
We can build NFA 𝑵 = 𝑸𝑵 , 𝚺, 𝜹𝑵 , 𝒒𝑵 , 𝑭𝑵 with 𝑳 𝑫 = 𝑳 𝑵 as follows:
• 𝑸𝑵 ≔ 𝑸𝑫

• 𝒒𝑵 ≔ 𝒒𝑫 States, start state, and accept states are the same

• 𝑭𝑵 ≔ 𝑭𝑫

• 𝜹𝑵 : 𝑸𝑵 × 𝚺 ∪ 𝜺 → 𝓟 𝑸𝑵 with • Exact same transitions, but written as set


• 𝜹𝑵 𝒒, 𝒂 ≔ 𝜹𝑫 𝒒, 𝒂 for all 𝒂 ∈ 𝚺 containing the outgoing state in DFA
• 𝜹𝑵 𝒒, 𝜺 ≔ ∅ • No 𝜺-transitions
Equivalence of NFAs and DFAs
Next: We show that for every NFA, there exists an equivalent DFA

Proof: Let 𝑵 = 𝑸𝑵 , 𝚺, 𝜹𝑵 , 𝒒𝑵 , 𝑭𝑵 be an NFA. Construct DFA 𝑫 = (𝑸𝑫 , 𝚺, 𝜹𝑫 , 𝒒𝑫 , 𝑭𝑫)


such that 𝑳 𝑫 = 𝑳 𝑵 .
0, 1 1
𝑵
0 𝜀
𝑞0 𝑞1 𝑞2

Idea: Build 𝑫 such that is simulates the computation of 𝑵.


• Since states can go to a set of states in NFAs, create a state in 𝑫 for every
possible subset of states of 𝑸𝑵
𝑫 0 …
{𝑞0 } {𝑞0, 𝑞1, 𝑞2}
NFA to DFA Construction
Proof continued: Given NFA 𝑵 = 𝑸𝑵 , 𝚺, 𝜹𝑵 , 𝒒𝑵 , 𝑭𝑵 , build DFA 𝑫 = (𝑸𝑫 , 𝚺, 𝜹𝑫 , 𝒒𝑫, 𝑭𝑫):
For now, let’s ignore the 𝜺-transitions of 𝑵.

{𝑞0, 𝑞1, 𝑞2} • 𝑸𝑫 ≔ 𝓟 𝑸𝑵 New states are all possible subsets of states in NFA

• 𝒒𝑫 ≔ {𝒒𝑵} Start state is the singleton set containing NFA start state

Next state is the state corresponding to set of all reachable


• 𝜹𝑫 is defined as follows: states in NFA from the states in current DFA state
• Let 𝑺 ∈ 𝑸𝑫 be a state of the DFA 𝑫 and let 𝒂 ∈ 𝚺. Recall, 𝑺 ⊆ 𝑸𝑵 .

• 𝜹𝑫 𝑺, 𝒂 ≔ {𝒒 ∈ 𝑸𝑵 ∣ 𝒒 ∈ 𝜹𝑵 𝒔, 𝒂 for some 𝒔 ∈ 𝑺}

• 𝑭𝑫 ≔ {𝑺 ∈ 𝑸𝑫 ∣ there exists a 𝒒 ∈ 𝑺 with 𝒒 ∈ 𝑭𝑵 } Accept states are the states which


contain an accept state in NFA
NFA to DFA Construction (𝜺-transitions)
Proof continued: Next, modify the 𝑫 to simulate the 𝜺-transitions in NFA
All states in 𝑺 plus states reachable by 𝜺-transitions (0 or more) from states in 𝑺
• For any state 𝑺 ∈ 𝑸𝑫 , let 𝑬 𝑺 = {𝒒 ∣ 𝒒 can be reached from some state in 𝑺 by
traveling 𝟎 or more 𝜺-transitions}
𝑵 0, 1 1 State 𝑺 in 𝑫
0 𝜀 {𝑞0 , 𝑞1 } 𝑬 𝑺 = {𝑞0 , 𝑞1 , 𝒒𝟐 }
𝑞0 𝑞1 𝑞2

• Modify 𝑫 as follows:
• 𝒒𝑫 ≔ 𝑬 𝒒𝑵 Start state is 𝐸() of start state in NFA
• 𝜹𝑫 𝑺, 𝒂 ≔ {𝒒 ∈ 𝑸𝑵 ∣ 𝒒 ∈ 𝑬 𝜹𝑵 𝒔, 𝒂 for some 𝒔 ∈ 𝑺}

{𝑞0 , 𝑞1 }
1 {𝑞0, 𝑞1, 𝑞2}
NFA to DFA Example
𝑵 1 𝑞2 0

𝑞1 𝑞3
𝑫
𝜀
0,1 0,1

Transition table for DFA 𝑫


𝜹𝑫 𝟎 𝟏

𝑞1
𝑞2
𝑞3
𝑞1 , 𝑞2
𝑞1 , 𝑞3
𝑞2 , 𝑞3 𝑸𝑫 ≔ 𝓟 𝑸𝑵
𝑞1 , 𝑞2 , 𝑞3
NFA to DFA Example
𝑵 1 𝑞2 0

𝑞1 𝑞3
𝑫
𝜀
0,1 0,1

Transition table for DFA 𝑫


𝜹𝑫 𝟎 𝟏

𝑞1
𝑞2
𝑞3
𝑞1 , 𝑞2
𝑞1 , 𝑞3
𝑞2 , 𝑞3 𝒒𝑫 ≔ 𝑬 𝒒𝑵
𝑞1 , 𝑞2 , 𝑞3
NFA to DFA Example
𝑵 1 𝑞2 0

𝑞1 𝑞3
𝑫
𝜀
0,1 0,1

Transition table for DFA 𝑫


𝜹𝑫 𝟎 𝟏
∅ ∅ ∅ {𝑞1 , 𝑞3 } 0,1
𝑞1
𝑞2

𝑞3
𝑞1 , 𝑞2
𝑞1 , 𝑞3 DFA state ∅ represents when an NFA state has
𝑞2 , 𝑞3 no outgoing transitions for a symbol
𝑞1 , 𝑞2 , 𝑞3
NFA to DFA Example
𝑵 1 𝑞2 0

𝑞1 𝑞3
𝑫
𝜀
0,1 0,1

Transition table for DFA 𝑫


𝜹𝑫 𝟎 𝟏
∅ ∅ ∅ {𝑞1 , 𝑞3 } 0,1
𝑞1
𝑞2

𝑞3
𝑞1 , 𝑞2
𝑞1 , 𝑞3
𝑞2 , 𝑞3 𝜹𝑫 𝑺, 𝒂 ≔ {𝒒 ∈ 𝑸𝑵 ∣ 𝒒 ∈ 𝑬 𝜹𝑵 𝒔, 𝒂 for some 𝒔 ∈ 𝑺}
𝑞1 , 𝑞2 , 𝑞3
NFA to DFA Example
𝑵 1 𝑞2 0

𝑞1 𝑞3
𝑫
𝜀
0,1 0,1

Transition table for DFA 𝑫


𝜹𝑫 𝟎 𝟏
∅ ∅ ∅ {𝑞1 , 𝑞3 } 0,1
𝑞1
𝑞2 0 ∅
𝑞3
𝑞1 , 𝑞2
𝑞1 , 𝑞3 𝑞1 , 𝑞3
𝑞2 , 𝑞3 𝜹𝑫 𝑺, 𝒂 ≔ {𝒒 ∈ 𝑸𝑵 ∣ 𝒒 ∈ 𝑬 𝜹𝑵 𝒔, 𝒂 for some 𝒔 ∈ 𝑺}
𝑞1 , 𝑞2 , 𝑞3
NFA to DFA Example
𝑵 1 𝑞2 0

𝑞1 𝑞3
𝑫
𝜀
0,1 0,1

Transition table for DFA 𝑫


𝜹𝑫 𝟎 𝟏 1
∅ ∅ ∅ {𝑞1 , 𝑞3 } {𝑞1, 𝑞2, 𝑞3} 0,1
𝑞1
𝑞2 0 ∅
𝑞3
𝑞1 , 𝑞2
𝑞1 , 𝑞3 𝑞1 , 𝑞3 𝑞1 , 𝑞2 , 𝑞3
𝑞2 , 𝑞3 𝜹𝑫 𝑺, 𝒂 ≔ {𝒒 ∈ 𝑸𝑵 ∣ 𝒒 ∈ 𝑬 𝜹𝑵 𝒔, 𝒂 for some 𝒔 ∈ 𝑺}
𝑞1 , 𝑞2 , 𝑞3
NFA to DFA Example
𝑵 1 𝑞2 0

𝑞1 𝑞3
𝑫
𝜀
0,1 0,1

Transition table for DFA 𝑫


𝜹𝑫 𝟎 𝟏 1
∅ ∅ ∅ {𝑞1 , 𝑞3 } {𝑞1, 𝑞2, 𝑞3} 0,1
0
𝑞1
𝑞2 0 ∅
𝑞3
𝑞1 , 𝑞2
𝑞1 , 𝑞3 𝑞1 , 𝑞3 𝑞1 , 𝑞2 , 𝑞3
𝑞2 , 𝑞3 𝜹𝑫 𝑺, 𝒂 ≔ {𝒒 ∈ 𝑸𝑵 ∣ 𝒒 ∈ 𝑬 𝜹𝑵 𝒔, 𝒂 for some 𝒔 ∈ 𝑺}
𝑞1 , 𝑞2 , 𝑞3 𝑞1 , 𝑞3
NFA to DFA Example
𝑵 1 𝑞2 0

𝑞1 𝑞3
𝑫
𝜀
0,1 0,1

Transition table for DFA 𝑫


𝜹𝑫 𝟎 𝟏 1
∅ ∅ ∅ {𝑞1 , 𝑞3 } {𝑞1, 𝑞2, 𝑞3} 0,1
0
𝑞1
𝑞2 0 1 ∅
𝑞3
𝑞1 , 𝑞2
𝑞1 , 𝑞3 𝑞1 , 𝑞3 𝑞1 , 𝑞2 , 𝑞3
𝑞2 , 𝑞3 𝜹𝑫 𝑺, 𝒂 ≔ {𝒒 ∈ 𝑸𝑵 ∣ 𝒒 ∈ 𝑬 𝜹𝑵 𝒔, 𝒂 for some 𝒔 ∈ 𝑺}
𝑞1 , 𝑞2 , 𝑞3 𝑞1 , 𝑞3 𝑞1 , 𝑞2 , 𝑞3
NFA to DFA Example
𝑵 1 𝑞2 0

𝑞1 𝑞3
𝑫
𝜀
0,1 0,1
{𝑞1 }

Transition table for DFA 𝑫 0


𝜹𝑫 𝟎 𝟏 1
∅ ∅ ∅ {𝑞1 , 𝑞3 } {𝑞1, 𝑞2, 𝑞3} 0,1
0
𝑞1 𝑞1 , 𝑞3
𝑞2 0 1 ∅
𝑞3
𝑞1 , 𝑞2
𝑞1 , 𝑞3 𝑞1 , 𝑞3 𝑞1 , 𝑞2 , 𝑞3
𝑞2 , 𝑞3 𝜹𝑫 𝑺, 𝒂 ≔ {𝒒 ∈ 𝑸𝑵 ∣ 𝒒 ∈ 𝑬 𝜹𝑵 𝒔, 𝒂 for some 𝒔 ∈ 𝑺}
𝑞1 , 𝑞2 , 𝑞3 𝑞1 , 𝑞3 𝑞1 , 𝑞2 , 𝑞3
NFA to DFA Example
𝑵 1 𝑞2 0

𝑞1 𝑞3
𝑫
𝜀
0,1 0,1
{𝑞1 }
1
Transition table for DFA 𝑫 0
𝜹𝑫 𝟎 𝟏 1
∅ ∅ ∅ {𝑞1 , 𝑞3 } {𝑞1, 𝑞2, 𝑞3} 0,1
0
𝑞1 𝑞1 , 𝑞3 𝑞1 , 𝑞2 , 𝑞3
𝑞2 0 1 ∅
𝑞3
𝑞1 , 𝑞2
𝑞1 , 𝑞3 𝑞1 , 𝑞3 𝑞1 , 𝑞2 , 𝑞3
𝑞2 , 𝑞3 𝜹𝑫 𝑺, 𝒂 ≔ {𝒒 ∈ 𝑸𝑵 ∣ 𝒒 ∈ 𝑬 𝜹𝑵 𝒔, 𝒂 for some 𝒔 ∈ 𝑺}
𝑞1 , 𝑞2 , 𝑞3 𝑞1 , 𝑞3 𝑞1 , 𝑞2 , 𝑞3
NFA to DFA Example
𝑵 1 𝑞2 0

𝑞1 𝑞3
𝑫
𝜀
0,1 0,1
{𝑞1 }
1
Transition table for DFA 𝑫 0
𝜹𝑫 𝟎 𝟏 1
{𝑞1 , 𝑞3 } {𝑞1, 𝑞2, 𝑞3} 0,1 {𝑞2 }
0 {𝑞3 }
∅ ∅ ∅
0
𝑞1 𝑞1 , 𝑞3 𝑞1 , 𝑞2 , 𝑞3
𝑞2 𝑞3 0 1 ∅
𝑞3
𝑞1 , 𝑞2
𝑞1 , 𝑞3 𝑞1 , 𝑞3 𝑞1 , 𝑞2 , 𝑞3
𝑞2 , 𝑞3 𝜹𝑫 𝑺, 𝒂 ≔ {𝒒 ∈ 𝑸𝑵 ∣ 𝒒 ∈ 𝑬 𝜹𝑵 𝒔, 𝒂 for some 𝒔 ∈ 𝑺}
𝑞1 , 𝑞2 , 𝑞3 𝑞1 , 𝑞3 𝑞1 , 𝑞2 , 𝑞3
NFA to DFA Example
𝑵 1 𝑞2 0

𝑞1 𝑞3
𝑫
𝜀
0,1 0,1
{𝑞1 }
1
Transition table for DFA 𝑫 0
𝜹𝑫 𝟎 𝟏 1
{𝑞1 , 𝑞3 } {𝑞1, 𝑞2, 𝑞3} 0,1 {𝑞2 }
0 {𝑞3 }
∅ ∅ ∅
0
𝑞1 𝑞1 , 𝑞3 𝑞1 , 𝑞2 , 𝑞3
1
𝑞2 𝑞3 ∅ 0 1 ∅
𝑞3
𝑞1 , 𝑞2
𝑞1 , 𝑞3 𝑞1 , 𝑞3 𝑞1 , 𝑞2 , 𝑞3
𝑞2 , 𝑞3 𝜹𝑫 𝑺, 𝒂 ≔ {𝒒 ∈ 𝑸𝑵 ∣ 𝒒 ∈ 𝑬 𝜹𝑵 𝒔, 𝒂 for some 𝒔 ∈ 𝑺}
𝑞1 , 𝑞2 , 𝑞3 𝑞1 , 𝑞3 𝑞1 , 𝑞2 , 𝑞3
NFA to DFA Example
𝑵 1 𝑞2 0

𝑞1 𝑞3
𝑫
𝜀
0,1 0,1
{𝑞1 } {𝑞2 , 𝑞3 }
1
Transition table for DFA 𝑫 0 0,1
𝜹𝑫 𝟎 𝟏 1
{𝑞1 , 𝑞3 } {𝑞1, 𝑞2, 𝑞3} 0,1 {𝑞2 }
0 {𝑞3 }
∅ ∅ ∅
0
𝑞1 𝑞1 , 𝑞3 𝑞1 , 𝑞2 , 𝑞3
0 1 1
𝑞2 𝑞3 ∅ 0 {𝑞1 , 𝑞2 } 1 ∅ 0,1
𝑞3 𝑞3 𝑞3
𝑞1 , 𝑞2 𝑞1 , 𝑞3 𝑞1 , 𝑞2 , 𝑞3
𝑞1 , 𝑞3 𝑞1 , 𝑞3 𝑞1 , 𝑞2 , 𝑞3
𝑞2 , 𝑞3 𝑞3 𝑞3
𝑞1 , 𝑞2 , 𝑞3 𝑞1 , 𝑞3 𝑞1 , 𝑞2 , 𝑞3
NFA to DFA Example
𝑵 1 𝑞2 0

𝑞1 𝑞3
𝑫
𝜀
0,1 0,1
{𝑞1 } {𝑞2 , 𝑞3 }
1
Transition table for DFA 𝑫 0 0,1
𝜹𝑫 𝟎 𝟏 1
{𝑞1 , 𝑞3 } {𝑞1, 𝑞2, 𝑞3} 0,1 {𝑞2 }
0 {𝑞3 }
∅ ∅ ∅
0
𝒒𝟏 𝑞1 , 𝑞3 𝑞1 , 𝑞2 , 𝑞3
0 1 1
𝑞2 𝑞3 ∅ 0 {𝑞1 , 𝑞2 } 1 ∅ 0,1
𝒒𝟑 𝑞3 𝑞3
𝒒𝟏 , 𝒒𝟐 𝑞1 , 𝑞3 𝑞1 , 𝑞2 , 𝑞3
𝒒𝟏 , 𝒒𝟑 𝑞1 , 𝑞3 𝑞1 , 𝑞2 , 𝑞3
𝒒𝟐 , 𝒒𝟑 𝑞3 𝑞3 𝑭𝑫 ≔ {𝑺 ∈ 𝑸𝑫 ∣ there exists a 𝒒 ∈ 𝑺 with 𝒒 ∈ 𝑭𝑵 }
𝒒𝟏 , 𝒒𝟐 , 𝒒𝟑 𝑞1 , 𝑞3 𝑞1 , 𝑞2 , 𝑞3
NFA to DFA Example
𝑵 1 𝑞2 0

𝑞1 𝑞3
𝑫
𝜀
0,1 0,1
{𝑞1 } {𝑞2 , 𝑞3 }
1
Transition table for DFA 𝑫 0 0,1
𝜹𝑫 𝟎 𝟏 1
{𝑞1 , 𝑞3 } {𝑞1 , 𝑞2 , 𝑞3 } 0,1 {𝑞2 }
0 {𝑞3 }
∅ ∅ ∅
0
𝒒𝟏 𝑞1 , 𝑞3 𝑞1 , 𝑞2 , 𝑞3
0 1 1
𝑞2 𝑞3 ∅ 0 {𝑞1 , 𝑞2 } 1 ∅ 0,1
𝒒𝟑 𝑞3 𝑞3
𝒒𝟏 , 𝒒𝟐 𝑞1 , 𝑞3 𝑞1 , 𝑞2 , 𝑞3
𝒒𝟏 , 𝒒𝟑 𝑞1 , 𝑞3 𝑞1 , 𝑞2 , 𝑞3
𝒒𝟐 , 𝒒𝟑 𝑞3 𝑞3
𝒒𝟏 , 𝒒𝟐 , 𝒒𝟑 𝑞1 , 𝑞3 𝑞1 , 𝑞2 , 𝑞3
Equivalence of NFAs and DFAs

• We have shown that:


• For every DFA there exists an equivalent NFA
• For every NFA there exists an equivalent DFA

• So, we know that DFAs and NFAs produce the same set of languages

• Therefore, the languages recognized by NFAs is exactly the set of


regular languages
Regular Languages are Closed under Concatenation

Recall: Given languages 𝑳𝟏 and 𝑳𝟐 over alphabet 𝚺, their concatenation denoted


𝑳𝟏 𝑳𝟐 is defined as 𝑳𝟏 𝑳𝟐 = 𝒘 ∈ 𝚺 ∗ | 𝒘 = 𝒙𝒚 for some 𝒙 ∈ 𝑳𝟏 and 𝒚 ∈ 𝑳𝟐
• E.g. Let 𝑳𝟏 = {0, 10} and 𝑳𝟐 = 0, 11 . Then 𝑳𝟏 𝑳𝟐 = 00, 011, 100, 1011

Theorem: If 𝑳𝟏 and 𝑳𝟐 are regular languages over alphabet Σ, then the language
𝑳𝟏 𝑳𝟐 is a regular language

Proof: Since 𝑳𝟏 and 𝑳𝟐 are regular languages, then there exist DFAs 𝑴𝟏 and 𝑴𝟐
where 𝑳𝟏 = 𝑳(𝑴𝟏 ) and 𝑳𝟐 = 𝑳(𝑴𝟐 )

We can create an NFA 𝑴 that accepts the strings where the first part is accepted
by 𝑴𝟏 and the second part is accepted by 𝑴𝟐 .
Regular Languages are Closed under Concatenation
𝑴𝟏 = 𝑸𝟏 , 𝚺, 𝜹𝟏 , 𝒒𝟏 , 𝑭𝟏 𝑴𝟐 = 𝑸𝟐 , 𝚺, 𝜹𝟐 , 𝒒𝟐 , 𝑭𝟐

𝑓1 𝑓4
𝑴 𝑞1 𝑓2 𝑞2 𝑓5
𝑓3 𝑓6

Create NFA 𝑴 as follows:


• 𝑴 inherits all states from DFAs 𝑴𝟏 and 𝑴𝟐
Regular Languages are Closed under Concatenation
𝑴𝟏 = 𝑸𝟏 , 𝚺, 𝜹𝟏 , 𝒒𝟏 , 𝑭𝟏 𝑴𝟐 = 𝑸𝟐 , 𝚺, 𝜹𝟐 , 𝒒𝟐 , 𝑭𝟐

𝑓1 𝑓4
𝑴 𝑞1 𝑓2 𝑞2 𝑓5
𝑓3 𝑓6

Create NFA 𝑴 as follows:


• 𝑴 inherits all states from DFAs 𝑴𝟏 and 𝑴𝟐
• The start state of 𝑴 is the start state of 𝑴𝟏
Regular Languages are Closed under Concatenation
𝑴𝟏 = 𝑸𝟏 , 𝚺, 𝜹𝟏 , 𝒒𝟏 , 𝑭𝟏 𝑴𝟐 = 𝑸𝟐 , 𝚺, 𝜹𝟐 , 𝒒𝟐 , 𝑭𝟐

𝑓1 𝑓4
𝑴 𝑞1 𝑓2 𝑞2 𝑓5
𝑓3 𝑓6

Create NFA 𝑴 as follows:


• 𝑴 inherits all states from DFAs 𝑴𝟏 and 𝑴𝟐
• The start state of 𝑴 is the start state of 𝑴𝟏
• The accept states of 𝑴 are the accept states of 𝑴𝟐 (accept states of 𝑴𝟏 are
no longer accept states)
Regular Languages are Closed under Concatenation
𝑴𝟏 = 𝑸𝟏 , 𝚺, 𝜹𝟏 , 𝒒𝟏 , 𝑭𝟏 𝑴𝟐 = 𝑸𝟐 , 𝚺, 𝜹𝟐 , 𝒒𝟐 , 𝑭𝟐

𝑓1 𝜺 𝑓4
𝑓2 𝜺 𝑓5
𝑴 𝑞1
𝜺
𝑞2
𝑓3 𝑓6

Create NFA 𝑴 as follows: 𝑴 = 𝑸𝟏 ∪ 𝑸𝟐 , 𝚺, 𝜹, 𝒒𝟏 , 𝑭𝟐


• 𝑴 inherits all states from DFAs 𝑴𝟏 and 𝑴𝟐
• The start state of 𝑴 is the start state of 𝑴𝟏
• The accept states of 𝑴 are the accept states of 𝑴𝟐 (accept states of 𝑴𝟏 are
no longer accept states)
• The transitions of 𝑴 consist of:
• All transitions of 𝑴𝟏 and all transitions of 𝑴𝟐 (remain the same)
• Add 𝜺-transitions between the previous accept states in 𝑴𝟏 to the start
state of 𝑴𝟐
Regular Language Closure

We have now shown that given regular languages 𝑳𝟏 and 𝑳𝟐 :

• 𝑳𝟏 ∪ 𝑳𝟐 is a regular language

• 𝑳𝟏 ∩ 𝑳𝟐 is a regular language
• 𝑳𝟏 𝑳𝟐 is a regular language

Regular languages are also closed under complement and Kleene star:

• 𝑳𝟏 is a regular language

• 𝑳𝟏∗ is a regular language

You might also like