Lecture 3 Final
Lecture 3 Final
840 Lecture 3
Last time:
- Nondeterminism
- NFA → DFA
- Closure under and
- Regular expressions → finite automata
𝑀
Regular Finite
expression automaton
Recall: we did as an example
𝑞1 𝑞2
b For convenience we will assume:
ε - One accept state, separate from the start state
∅ - One arrow from each state to each state, except
a∪b aab
a) only exiting the start state
𝑞3 𝑞4 b) only entering the accept state
ε
We can easily modify a GNFA to have this special form.
GNFA Regular Expressions
Lemma: Every GNFA has an equivalent regular expression
Proof: By induction on the number of states of
Basis :
𝐺=¿ 𝑟 Remember: is in special form
Let
Induction step : Assume Lemma true for states and prove for states
IDEA: Convert -state GNFA to equivalent -state GNFA
GNFA GNFA
states states
-state GNFA (—1)-state GNFA
Check-in 3.1
𝑥 𝑟2 𝑥
𝑟 1 showed
We just 𝑟 how
3 to convert GNFAs to regular expressions 1. Pick any state except
but
𝑞our goal was 𝑞 to show that how𝑞to𝑖 convert DFAs 𝑞to𝑗 the start and accept states.
𝑖 𝑟4 𝑗 ∗
𝑟 (𝑟 2) 𝑟 3 ∪ 𝑟 4
regular expressions. How do we finish 1our goal? 2. Remove .
(a) Show how to convert DFAs to GNFAs 3. Repair the damage by
(b) Show how to convert GNFAs to DFAs recovering all paths that
(c) We are already done. DFAs are a typestates
states of GNFAs. went through .
4. Make the indicated change
Thus DFAs and regular expressions are equivalent. for each pair of states .
Check-in 3.1
Non-Regular Languages
How do we show a language is not regular?
- Remember, to show a language is regular, we give a DFA.
- To show a language is not regular, we must give a proof.
- It is not enough to say that you couldn’t find a DFA for it,
therefore the language isn’t regular.
0101 0110
Intuition: is not regular because DFAs cannot count
unboundedly.
However is regular! Sometimes intuition works, but it can
also be wrong.
Method for Proving Non-regularity
Pumping Lemma: For every regular language ,
there is a number (the “pumping length”) such that
if and then where
1) for all
}
2)
3) 𝑖
Informally: is regular → every long string in can be
Check-in 3.2pumped and the result stays in .
Proof: Let DFA recognize . Let be the number of states in . Pick where .
The Pumping Lemma depends on the fact that
𝑥 𝑦 𝑧 if has 𝑀 states and it runs
𝑦 for more than steps then
𝑠=¿ will enter some state at least twice.
𝑞𝑗 𝑞𝑗
We call that fact:
𝑥 𝑞𝑗 The path that follows
will repeat a state when reading 𝑧 when reading .
because is so long. (a) The Pigeonhole Principle
𝑥 𝑦 𝑦 𝑧 (b) Burnside's Counting Theorem
𝑞𝑗 𝑞𝑗 𝑞 is also(c)
𝑗
The Coronavirus Calculation
accepted Check-in 3.2
Example 1 of Proving Non-regularity
Pumping Lemma: For every regular language , there is a
such that if and then where
1) for all
2)
3)
Let
Show: is not regular
Proof by Contradiction:
Assume (to get a contradiction) that is regular.
The pumping lemma gives as above. Let . 𝑠=¿000 ⋯ 000111 ⋯111
Pumping lemma says that can divide satisfying the 3 conditions. 𝑥𝑦 𝑧
≤𝑝
But has excess 0s and thus contradicting the pumping lemma.
Therefore our assumption ( is regular) is false. We conclude that is not regular.
Example 2 of Proving Non-regularity
Pumping Lemma: For every regular language , there is a
such that if and then where
1) for all
2)
3)
Let Say .
Show: is not regular 𝑠=¿000 ⋯ 000000 ⋯ 000
Proof by Contradiction:
𝑥𝑦 𝑧
≤𝑝 𝑦 =00
Assume (for contradiction) that is regular.
The pumping lemma gives as above. Need to choose . Which ?
Try . But that can be pumped and stay inside . Bad choice. 𝑠=¿000 ⋯ 001000 ⋯ 001
Try . Show cannot be pumped satisfying the 3 conditions.
𝑥𝑦 𝑧
≤𝑝
Contradiction! Therefore is not regular.
Example 3 of Proving Non-regularity
Variant: Combine closure properties with the Pumping Lemma.
In :
3Check-in 3.3
Rule: Variable string of variables and terminals rules 𝐺 2 S RR
Variables: Symbols appearing on left-hand side of rule R,S
Example of generating a string
Terminals: Symbols appearing only on right-hand s 0,1 R 0R1
Start Variable: Top left symbol S Tree of R
S S Resulting
substitutions string
Grammars generate strings Check all of the strings 0that
S 1are 0inS1
1. Write down start variable (a) 001101 0 S 1 00S11
2. Replace any variable according to a rule
Repeat until only terminals remain (b) 000111
R 00R11
3. Result is the generated string (c) 1010 0011∈ 𝐿 ( 𝐺1)
4. is the language of all generated strings.
(d) 𝐿 ( 𝐺 ) ={ 0 𝑘 1 𝑘|𝑘 ≥ 0 }
1
Check-in 3.3
Quick review of today