Automata Theory �and�Compiler Design�(17CI15)
B.Tech. CSE – V Sem, A.Y:2020-21
Why Theory of Computation?
Theory of computation
Automata theory and Formal Languages
Computability theory
Computational Complexity theory
computational models
problems
the problems can be solved
based on the resources time
and space complexity?
Automata Theory and Compiler Design
Unit-1
Unit-2
Unit-3
and Bottom up parsing)
Unit-4
Unit-5
Text books:
Pre-requisite: Set theory and Graph theory, programming language and data structures
Course Outcomes
At the end of the course, the student shall be able to
CO 1: Design Finite Automata and Regular expressions for regular languages
CO 2: Design Context-free grammar and push-down automata for CFL
CO 3: Design and Implement Lexical and Syntax Analyzer
CO 4: Create framework for syntax directed translation schemes and
understand the run-time organization of the program.
CO 5: Analyze various code optimization techniques and understand the
design issues of code generation
Introduction to Automata Theory
( or)
A Mathematical model to provide a proof for the computational problems that are solvable by the computer
Components of Automata
The components of Automata are
| | | | | | | | | |
Q1, Q2,…..Qn
Input tape
Read/Write Head
Finite Control
Introduction to Finite Automata
OFF
ON
on(1)
off(0)
State | on(1) | off(0) |
OFF | ON | -- |
ON | -- | OFF |
Example 2 – Modelling the Binary Adder
Without carry
With carry
00 | 0
10 | 0
11 | 0
00 | 1
01 | 1
10 | 1
11 | 1
01 | 0
Note : So, problem will be represented as a language and problem-solving means constructing an equivalent automaton.
Carry | 1 | No | No | 1 | |
Input number1 | | 1 | 1 | 0 | 1 |
Input number 2 | | 1 | 0 | 0 | 1 |
Output | 1 | 0 | 0 | 1 | 0 |
Mathematical Notations
Example s
∑ = {0,1} or {a,b} or { a-zA-Z0-9,+,-,*…}
“ababb” is a string over the alphabet {a,b}
“a+b*c” is a string over the alphabet {a-zA-Z0-9,+,*}
Example
L1 = {0,1,00,11,01,10,….} over the alphabet ∑ ={ 0,1 }
L2= {ab, aab,aaab,aaaab,…..} over the alphabet ∑ ={ a,b }
Finite Automaton (FA)
Deterministic Finite Automata
Formally ,a DFA is defined by the 5-tuple M= {Q, ∑ , δ ,q0, F}
Q x ∑ --> Q
Example
What is the language accepted by the following Finite Automaton?
q0
q1
0,1
0,1
q0
0,1
q0
0,1
M1 :
M2 :
q0
q1
a,b
a,b
L(M1) or L1= {ϵ, 0, 1, 00, 01,…}
L2 = {, 0, 1, 000,001,010…}
M3 :
L3 = {ϵ, aa, ba,ab,bb,…}
M4 :
L5 = Φ ( empty set)
q0
q1
0
1
1
0
M5:
L5 = {0, 00,10,000,010,100…..}
Strings ending with zero
q0
q1
q2
b
a
a, b
b
M6:
L6 = {ba,bab,babb,abab,aaaba,…….}
Strings ending with either one a (or) zero or more b
What is the language accepted by the following Finite Automaton?
States required to construct FA
States required to represent the string | Length of the string | Minimum No. of states | DFA or NFA |
| | |
|
| | | |
| | | |
| | | |
q0
q1
q2
0
1
q0
q1
w
“a” (or) “0”
1
2
“01”
2
3
where w = a or b or 0 or 1
“abba”
4
5
“01001…..”
n
n+1
Example 1:
Step 1 : The minimum possible string having “ba” as a substring is “ba”. so, minimum number of states to represent “ba” is 3
Step 2: Place the missing transitions of each state with out changing the original property of the language(i.e., having “ba” as a substring).
q0
q1
q2
b
a
For q0 transition a is missing, the possibilities are (q0 , a)= q0 , (q0 , a)= q1, (q0 , a)= q2
a
a
a
x
x
q0
q1
q2
b
a
Problem: Construct a Deterministic Finite Automata for the Language L over the alphabet {a,b} and whose strings have “ba” as a substring
Among the possibilities (q0 , a)= q0 is valid and (q0 , a)= q1, (q0 , a)= q2 are invalid
q0
q1
q2
b
a
a
For q1 transition b is missing, the possibilities are (q1 , b)= q0 , (q1 , b)= q1, (q1 , b)= q2
q0
q1
q2
b
a
a
Among the possibilities (q1 , b)= q1 is valid and (q1, b)= q0, (q1, b)= q2 are invalid
b
b
b
x
x
For q2 transitions a, and b are missing, the possibilities are
(q2 , a)= q0 , (q2 , a)= q1, (q2 , a)= q2 and (q2 , b)= q0 , (q2 , b)= q1, (q2 , b)= q2
q0
q1
q2
b
a
a
b
q0
q1
q2
b
a
a
b
Among the possibilities (q2 , a)= q2 and (q2 , b)= q2 are valid and remaining are invalid
a,b
Equivalent representation of FA
q0
q1
q2
b
a
a
b
a,b
δ | a | b |
q0 | q0 | q1 |
q1 | q2 | q1 |
q2 | q2 | q2 |
δ (q0 , a ) = q0
δ (q0 , b ) = q1
δ (q1 , a ) = q2
δ (q1 , b ) = q1
δ (q2 , a ) = q2
δ (q2 , b ) = q2
Transition diagram
Transition table
Transitions
A finite Automata M= {Q, ∑ , δ ,q0, F} where
Q= { q0,q1,q2} , ∑ = {a,b} , initial state= q0 , F={ q2}
where transition function δ is represented as
Language accepted by DFA(M)
q0
q1
q2
b
a
a
b
a,b
= δ( δ(q0, abb), a)
= δ(δ(δ(q0, ab), b)a)
= δ(δ(δ(δ(q0, a),b), b)a)
= δ(δ(δ(δ(δ(q0, ϵ),a),b), b)a)
= δ(δ(δ(δ(q0,a),b), b)a)
= δ(δ(δ(q0,b), b)a)
= δ(δ(q1,b)a)
= δ(q1,a) =q2 ( Accept state)
δ ( q0, abba)
^
^
^
^
^
L(M) = { w | δ(q0, w) is in F }
^
^
δ
( q, wa) =
^
δ
( q, w),a)
δ(
δ
^
(q, ϵ) = q
Extended transition function ( )
^
δ
q0
a
q0
b
q1
b
q1
a
q2
Informally, transition path is represented as
Language accepted by FA
The language of a DFA M = (Q, Σ, δ, q0 , F), denoted L(M) is defined by
The language of M is the set of strings w that take the start state q0 to one of the accepting states.
If L is a L(M) from some DFA, then L is a regular language
^
L(M) = { w | δ(q0, w) is in F }
Deterministic Finite Automata
q0
start
q1
0
1
0,1
0
1
q2
Accepting
state
q2
q2
q2
q2
q1
q1
q0
q1
q0
1
0
states
symbols
Construct DFA for the Language L over the alphabet {0,1} and whose strings
contains 01 as a substring
Example
Construct DFA for the language over the alphabet {0,1} and whose string have
Example
Construct DFA for the language L over the alphabet {a,b} and
whose string length is divisible by 3 (or) multiple of 3
Construct DFA for the following language L
L ={ w ϵ { a,b}* | |w| mod 3 = 0 }
(or)
Construct DFA for the following language L
Example
Construct DFA for the language L over the alphabet {a,b} and whose strings having
Construct DFA for the language L over the alphabet {a,b} and whose strings having
Non-deterministic Finite Automata(NFA)
Mathematically a NFA is defined by the 5-tuple M= {Q, ∑ , δ ,q0, F}
Q x ∑ --> 2Q
Non-deterministic Finite Automata (NFA)
qi
1
1
qj
qk
…
How to use an NFA?
NFA for strings containing substring 01
q0
start
q1
0
0,1
0,1
1
q2
Final
state
{q2}
{q2}
q2
{q2}
Φ
q1
{q0}
{q0,q1}
q0
1
0
states
symbols
What will happen if at state q1 �an input of 0 is received?
NFA will halt and says, w is not accepted
More Natural way of constructing the automata.
3 possible cases strings may contain 01
q0
start
q1
0
0,1
0,1
1
q2
Final
state
δ ( q0, 000)
δ ( q0, 00)
δ ( q1, 00)
δ ( q0, 0)
δ ( q1, 0)
q0
0
0
0
0
0
Among the leaves { q0 } , there is no
final state . So, the string 1000 is
not accepted
δ ( q0, 010)
δ ( q0, 10)
δ ( q1, 10)
δ ( q0, 0)
δ ( q2, 0)
q0
q2
0
0
1
1
0
0
δ ( q0, 1000)
1
Halt, No
transition
for q1 on 0
X
X
0
Among the leaves { q0 , q1,q2 } , there is a
final state . So, the string 010 is accepted
0
Halt, No transition for q1 on 0
Acceptance of strings by NFA
q1
0
NFA to DFA construction: Example
q0
q1
0
0,1
q2
1
NFA:
δN | 0 | 1 |
q0 | {q0,q1} | {q0} |
q1 | Ø | {q2} |
q2 | Ø | Ø |
DFA:
δD | 0 | 1 |
Ø | Ø | Ø |
[q0] | [q0,q1] | [q0] |
[q1] | Ø | {q2} |
*[q2] | Ø | Ø |
[q0,q1] | {q0,q1} | {q0,q2} |
*[q0,q2] | {q0,q1} | {q0} |
*[q1,q2] | Ø | {q2} |
*[q0,q1,q2] | {q0,q1} | {q0,q2} |
2. Determine transitions
δD | 0 | 1 |
[q0] | [q0,q1] | [q0] |
[q0,q1] | [q0,q1] | [q0,q2] |
*[q0,q2] | [q0,q1] | [q0] |
[q0]
1
0
[q0,q1]
1
[q0,q2]
0
0
1
To avoid enumerating all of power set, do �“lazy creation of states”
3. Retain only those states � reachable from {q0}
1. Enumerate all possible subsets
NFA to DFA: Repeating the example using �LAZY CREATION
q0
q1
0
0,1
q2
1
NFA:
δN | 0 | 1 |
q0 | {q0,q1} | {q0} |
q1 | Ø | {q2} |
q2 | Ø | Ø |
DFA:
δD | 0 | 1 |
[q0] | [q0,q1] | [q0] |
[q0,q1] | [q0,q1] | [q0,q2] |
*[q0,q2] | [q0,q1] | [q0] |
[q0]
1
0
[q0,q1]
1
[q0,q2]
0
0
1
Idea: Introduce states as you go
(on a need basis)
Summary
,initial state and set of final states.
unique.
q0
q1
q2
b
a
a
b
a,b
q0
q1
b
a
a,b
i)
ii)
Properties of DFAs and NFAs
Finite Automata(NFA) with ε-Transitions
Definition: ε -NFAs are those NFAs with at least one explicit ε-transition defined.
Automata | Components | Transition function | Extended transition function ( δ ) |
DFA | ( Q , ∑, δ, q0, F ) | δ : Q x ∑ ---> Q | |
NFA | ( Q , ∑, δ, q0, F ) | δ : Q x ∑ ---> 2Q | |
NFA with Epsilion | ( Q , ∑, δ, q0, F ) | δ : Q x ∑ υ { ϵ} --> 2Q | |
^
(q, ϵ ) = q
δ
^
(q, wa ) =
δ
^
δ
^
δ (
(q, w), a )
(q, ϵ ) = q
δ
^
(q, wa ) =
δ
^
δ
^
δ (
(q, w), a )
(q, ϵ ) = ϵ- closure(q)
δ
^
(q, wa ) =
δ
^
δ
^
δ (
(q, w), a )
Example of an ε-NFA
L = {w | w is empty, or if non-empty will end in 01}
δE | 0 | 1 | ε |
q0 | Ø | Ø | {q1} |
q1 | {q0,q1} | {q0} | Ø |
q2 | Ø | {q2} | Ø |
q3 | Ø | Ø | Ø |
start
q1
q2
0
0,1
1
q3
q0
ε
ε-closure (q0)
= { q0 , q1 }
ε-closure(q1)
= { q1 }
ε-closure(q2)
= { q2 }
ε-closure(q3)
= { q3 }
Example of an ε-NFA
q0
q1
q2
ϵ
a
b
c
ϵ
For the string aac, we can view as a, a ,ϵ, ϵ, c
Identity
a. ϵ = ϵ . a = a
a. Φ = a. Φ = Φ
q0
a
Example of an ε-NFA
L = {w | w is empty, or if non-empty will end in 01}
δE | 0 | 1 | ε |
q’0 | Ø | Ø | {q’0,q0} |
q0 | {q0,q1} | {q0} | {q0} |
q1 | Ø | {q2} | {q1} |
q2 | Ø | Ø | {q2} |
ε-closure (q’0)
ε-closure(q0)
start
q0
q1
0
0,1
1
q2
q’0
ε
ε-closure(q1)
ε-closure(q2)
Simulation of ε-NFA
Simulate for w=101
L = {w | w is empty, or if non-empty will end in 01}
q0
q1
q0
ε
ε
q1
0
q1
1
q1
1
Ø
1
x
To simulate any transition:� Step 1) Go to all immediate destination states.
Step 2) From there go to all their ε-closure states as well.
start
q1
q2
0
0,1
1
q3
q0
ε
δE | 0 | 1 | ε |
q0 | Ø | Ø | {q1} |
q1 | {q1,q2} | {q1} | Ø |
q2 | Ø | {q3} | Ø |
q3 | Ø | Ø | Ø |
q2
0
q3
1
Example of another ε-NFA
Simulate for w=101:
?
δE | 0 | 1 | ε |
*q’0 | Ø | Ø | {q’0,q0,q3} |
q0 | {q0,q1} | {q0} | {q0,q3} |
q1 | Ø | {q2} | {q1} |
*q2 | Ø | Ø | {q2} |
q3 | Ø | {q2} | {q3} |
start
q0
q1
0
0,1
1
q2
q’0
ε
ε
q3
1
To simulate any transition:� Step 1) Go to all immediate destination states.
Step 2) From there go to all their ε-closure states as well.
Conversion of ε-NFA to DFA
40
L = {w | w is empty, or if non-empty will end in 01}
start
q0
q1
0
0,1
1
q2
q’0
ε
δE | 0 | 1 | ε |
*q’0 | Ø | Ø | {q’0,q0} |
q0 | {q0,q1} | {q0} | {q0} |
q1 | Ø | {q2} | {q1} |
*q2 | Ø | Ø | {q2} |
δD | 0 | 1 |
*{q’0,q0} | | |
… | | |
Conversion of ε-NFA to DFA
41
L = {w | w is empty, or if non-empty will end in 01}
start
q1
q2
0
0,1
1
q3
q0
ε
δE | 0 | 1 | ε |
*q0 | Ø | Ø | {q0,q1} |
q1 | {q1,q2} | {q1} | {q1} |
q2 | Ø | {q3} | {q2} |
*q3 | Ø | Ø | {q3} |
δD | 0 | 1 |
*{q0,q1} | {q1,q2} | {q1} |
{q1,q2} | {q1,q2} | {q1,q3} |
{q1} | {q1,q2} | {q1} |
*{q1,q3} | {q1,q2} | {q1} |
{q0, q1}
0
start
{q1,q2}
{q1,q3}
1
0
q1
1
1
0
0
1
union
ECLOSE
Equivalency of DFA, NFA, ε-NFA
Applications of Interest
43
When to call two states in a DFA “equivalent”?
Two states p and q are said to be equivalent iff:
p
q
AND
w
p
q
w
🡺 p≡ q
Computing equivalent states in a DFA
45
A
C
E
G
B
D
F
H
0
1
1
1
1
1
1
1
0
0
0
0
0
0
0
1
Table Filling Algorithm
A | = | | | | | | | |
B | = | = | | | | | | |
C | x | x | = | | | | | |
D | x | x | x | = | | | | |
E | x | x | x | x | = | | | |
F | x | x | x | x | x | = | | |
G | x | x | x | = | x | x | = | |
H | x | x | = | x | x | x | x | = |
| A | B | C | D | E | F | G | H |
Pass #0
Pass #1
Pass #2
….
(keep repeating until table complete)
Table Filling Algorithm - step by step
46
A
C
E
G
B
D
F
H
0
1
1
1
1
1
1
1
0
0
0
0
0
0
0
1
A | = | | | | | | | |
B | | = | | | | | | |
C | | | = | | | | | |
D | | | | = | | | | |
E | | | | | = | | | |
F | | | | | | = | | |
G | | | | | | | = | |
H | | | | | | | | = |
| A | B | C | D | E | F | G | H |
Table Filling Algorithm - step by step
47
A
C
E
G
B
D
F
H
0
1
1
1
1
1
1
1
0
0
0
0
0
0
0
1
A | = | | | | | | | |
B | | = | | | | | | |
C | | | = | | | | | |
D | | | | = | | | | |
E | X | X | X | X | = | | | |
F | | | | | X | = | | |
G | | | | | X | | = | |
H | | | | | X | | | = |
| A | B | C | D | E | F | G | H |
Table Filling Algorithm - step by step
48
A
C
E
G
B
D
F
H
0
1
1
1
1
1
1
1
0
0
0
0
0
0
0
1
A | = | | | | | | | |
B | | = | | | | | | |
C | X | | = | | | | | |
D | X | | | = | | | | |
E | X | X | X | X | = | | | |
F | | | | | X | = | | |
G | X | | | | X | | = | |
H | X | | | | X | | | = |
| A | B | C | D | E | F | G | H |
Table Filling Algorithm - step by step
49
A
C
E
G
B
D
F
H
0
1
1
1
1
1
1
1
0
0
0
0
0
0
0
1
A | = | | | | | | | |
B | | = | | | | | | |
C | X | X | = | | | | | |
D | X | X | | = | | | | |
E | X | X | X | X | = | | | |
F | | | | | X | = | | |
G | X | X | | | X | | = | |
H | X | X | | | X | | | = |
| A | B | C | D | E | F | G | H |
Table Filling Algorithm - step by step
50
A
C
E
G
B
D
F
H
0
1
1
1
1
1
1
1
0
0
0
0
0
0
0
1
A | = | | | | | | | |
B | | = | | | | | | |
C | X | X | = | | | | | |
D | X | X | X | = | | | | |
E | X | X | X | X | = | | | |
F | | | X | | X | = | | |
G | X | X | X | | X | | = | |
H | X | X | = | | X | | | = |
| A | B | C | D | E | F | G | H |
Table Filling Algorithm - step by step
51
A
C
E
G
B
D
F
H
0
1
1
1
1
1
1
1
0
0
0
0
0
0
0
1
A | = | | | | | | | |
B | | = | | | | | | |
C | X | X | = | | | | | |
D | X | X | X | = | | | | |
E | X | X | X | X | = | | | |
F | | | X | X | X | = | | |
G | X | X | X | = | X | | = | |
H | X | X | = | X | X | | | = |
| A | B | C | D | E | F | G | H |
Table Filling Algorithm - step by step
52
A
C
E
G
B
D
F
H
0
1
1
1
1
1
1
1
0
0
0
0
0
0
0
1
A | = | | | | | | | |
B | | = | | | | | | |
C | X | X | = | | | | | |
D | X | X | X | = | | | | |
E | X | X | X | X | = | | | |
F | | | X | X | X | = | | |
G | X | X | X | = | X | X | = | |
H | X | X | = | X | X | X | | = |
| A | B | C | D | E | F | G | H |
Table Filling Algorithm - step by step
53
A
C
E
G
B
D
F
H
0
1
1
1
1
1
1
1
0
0
0
0
0
0
0
1
A | = | | | | | | | |
B | | = | | | | | | |
C | X | X | = | | | | | |
D | X | X | X | = | | | | |
E | X | X | X | X | = | | | |
F | | | X | X | X | = | | |
G | X | X | X | = | X | X | = | |
H | X | X | = | X | X | X | X | = |
| A | B | C | D | E | F | G | H |
Table Filling Algorithm - step by step
54
A
C
E
G
B
D
F
H
0
1
1
1
1
1
1
1
0
0
0
0
0
0
0
1
A | = | | | | | | | |
B | = | = | | | | | | |
C | X | X | = | | | | | |
D | X | X | X | = | | | | |
E | X | X | X | X | = | | | |
F | X | X | X | X | X | = | | |
G | X | X | X | = | X | X | = | |
H | X | X | = | X | X | X | X | = |
| A | B | C | D | E | F | G | H |
Look 1-hop away again for distinguishing states or strings
continue….
Table Filling Algorithm - step by step
55
A
C
E
G
B
D
F
H
0
1
1
1
1
1
1
1
0
0
0
0
0
0
0
1
A | = | | | | | | | |
B | = | = | | | | | | |
C | X | X | = | | | | | |
D | X | X | X | = | | | | |
E | X | X | X | X | = | | | |
F | X | X | X | X | X | = | | |
G | X | X | X | = | X | X | = | |
H | X | X | = | X | X | X | X | = |
| A | B | C | D | E | F | G | H |
Equivalences:
Look 1-hop away again for distinguishing states or strings
continue….
Table Filling Algorithm - step by step
56
A
C
E
G
B
D
F
H
0
1
1
1
1
1
1
1
0
0
0
0
0
0
0
1
A
C
E
D
F
0
1
1
0
0
0
1
1
0
1
Equivalences:
Retrain only one copy for � each equivalence set of states
Table Filling Algorithm – special case
57
A | = | | | | | | | |
B | | = | | | | | | |
C | | | = | | | | | |
D | | | | = | | | | |
E | | | | | = | | | |
F | | | | | | = | | |
G | | | | | | | = | |
H | | | | | | | | = |
| A | B | C | D | E | F | G | H |
Q) What happens if the input DFA� has more than one final state?� Can all final states initially be treated� as equivalent to one another?
A
C
E
G
B
D
F
H
0
1
1
1
1
1
1
1
0
0
0
0
0
0
0
1
?
Regular Expressions vs. Finite Automata
< input: string , output: [accept/reject] >
Regular Expressions
Regular �expressions
Finite Automata�(DFA, NFA, ε-NFA)
Regular�Languages
=
Automata/machines
Syntactical �expressions
Formal language �classes
Language Operators
Kleene Closure (the * operator)
Example:
“i” here refers to how many strings to concatenate from the parent language L to produce strings in the language Li
Kleene Closure
Σ* denotes the set of all words over an alphabet Σ
Example for construction of regular expression
Precedence of Operators
Finite Automata (FA) & Regular Expressions (Reg Ex)
ε -NFA
NFA
DFA
Reg Ex
Theorem 2
Theorem 1
Kleene Theorem
DFA to RE construction
Example:
q0
q1
q2
0
1
1
0
0,1
(1*)
0
(0*)
1
(0 + 1)*
Informally, trace all distinct paths (traversing cycles only once) �from the start state to each of the final states and enumerate all the expressions along the way
1*00*1(0+1)*
00*
1*
1
(0+1)*
Q) What is the language?
RE to ε-NFA construction
Example:
(0+1)*01(0+1)*
0
1
ε
ε
ε
ε
ε
ε
ε
0
1
0
1
ε
ε
ε
ε
ε
ε
(0+1)*
01
(0+1)*
Algebraic Laws of Regular Expressions
Some languages are not regular
When is a language is regular? �if we are able to construct one of the following: DFA or NFA or ε -NFA or regular expression
When is it not?�If we can show that no FA can be built for a language
69
How to prove languages are not regular?
What if we cannot come up with any FA?
A) Can it be language that is not regular?
B) Or is it that we tried wrong approaches?
�How do we decisively prove that a language is not regular?
70
“The hardest thing of all is to find a black cat in a dark room, �especially if there is no cat!” -Confucius
Example of a non-regular language
Let L = {w | w is of the form 0n1n , for all n≥0}
71
Rationale…
Uses Pigeon Hole Principle
The Pumping Lemma for Regular Languages
What it is? �The Pumping Lemma is a property of all regular languages.
How is it used? �A technique that is used to show that a given language is not regular
73
Pumping Lemma for Regular Languages
Let L be a regular language
Then there exists some constant N such that for every string w ∈ L s.t. |w|≥N, there exists a way to break w into three parts, w=xyz, such that:
74
This property should hold for all regular languages.
Definition: N is called the “Pumping Lemma Constant”
Pumping Lemma: Proof
75
Pumping Lemma: Proof…
76
yk (for k loops)
p0
pi
pm
x
z
=pj
This proves part (3) of the lemma
Pumping Lemma: Proof…
77
p0
pi
pm
x
z
yk (for k loops)
=pj
The Purpose of the Pumping Lemma for RL
78
How to use the pumping lemma?
Think of playing a 2 person game
79
How to use the pumping lemma?�(The Steps)
=> this implies we have successfully broken the pumping lemma for the language, and hence that the adversary is wrong.
(Note: In this process, we may have to try many values of k, starting with k=0, and then 2, 3, .. so on, until wk ∉ L )
80
Using the Pumping Lemma
3. Using N, we construct our template string w
4. Demonstrate to the adversary, either through pumping up or down on w, that some string wk ∉ L�(this should happen regardless of w=xyz)
1. Claims L is regular
2. Provides N
81
Note: We don’t have any control over N, except that it is positive.� We also don’t have any control over how to split w=xyz, � but xyz should respect the P/L conditions (1) and (2).
Example of using the Pumping Lemma to prove that a language is not regular
Let Leq = {w | w is a binary string with equal number of 1s and 0s}
82
🡺 adv.
🡺 you
🡺 adv.
🡺you
Note: This N can be anything (need not necessarily be the #states in the DFA. � It’s the adversary’s choice.)
Proof…
83
Another way of proving this will be to show that if �the #0s is arbitrarily pumped up (e.g., k=2),�then the #0s will become exceed the #1s
🡺 you
Template string w = 0N1N = 00 …. 011 … 1
N
N
Setting k=0 is �referred to as�“pumping down”
Setting k>1 is �referred to as�“pumping up”
Exercise 2
Prove L = {0n10n | n≥ 1} is not regular
Note: This n is not to be confused with the pumping lemma constant N. That can be different.
In other words, the above question is same as proving:
84
Example 3: Pumping Lemma
Claim: L = { 0i | i is a perfect square} is not regular
85