Languages and Finite Automata

Standard Representations
of Regular Languages
Regular Languages
DFAs
NFAs
Regular
Grammars
Regular
Expressions
Costas Busch - RPI
1
When we say:
We mean:
We are given
a Regular Language
L
Language L is in a standard
representation
Costas Busch - RPI
2
Elementary Questions
about
Regular Languages
Costas Busch - RPI
3
Membership Question
Question:
Answer:
Given regular language L
and string w
how can we check if w 
L?
Take the DFA that accepts L
and check if w is accepted
Costas Busch - RPI
4
DFA
w
w L
DFA
w
w L
Costas Busch - RPI
5
Question:
Answer:
Given regular language L
how can we check
if L is empty: ( L  ) ?
Take the DFA that accepts
L
Check if there is any path from
the initial state to a final state
Costas Busch - RPI
6
DFA
L
DFA
L
Costas Busch - RPI
7
Question:
Given regular language
how can we check
if L is finite?
Answer: Take the DFA that accepts
L
L
Check if there is a walk with cycle
from the initial state to a final state
Costas Busch - RPI
8
DFA
L is infinite
DFA
L is finite
Costas Busch - RPI
9
Question: Given regular languages L1 and
how can we check if L1  L2 ?
Answer:
Find if
L2
( L1  L2 )  ( L1  L2 )  
Costas Busch - RPI
10
( L1  L2 )  ( L1  L2 )  
and
L1  L2  
L1
L1  L2  
L2
L2 L
2
L1  L2
L1 L1
L2  L1
L1  L2
Costas Busch - RPI
11
( L1  L2 )  ( L1  L2 )  
L1  L2  
L1
or
L1  L2  
L2
L2
L1  L2
L1
L2  L1
L1  L2
Costas Busch - RPI
12
Non-regular languages
Costas Busch - RPI
13
{a b : n  0}
n n
Non-regular languages
{vv : v {a, b}*}
R
Regular languages
a *b
b*c  a
b  c ( a  b) *
etc...
Costas Busch - RPI
14
How can we prove that a language
is not regular?
L
Prove that there is no DFA that accepts
L
Problem: this is not easy to prove
Solution: the Pumping Lemma !!!
Costas Busch - RPI
15
The Pigeonhole Principle
Costas Busch - RPI
16
4 pigeons
3 pigeonholes
Costas Busch - RPI
17
A pigeonhole must
contain at least two pigeons
Costas Busch - RPI
18
n pigeons
...........
m
pigeonholes
nm
...........
Costas Busch - RPI
19
The Pigeonhole Principle
n pigeons
m
pigeonholes
nm
There is a pigeonhole
with at least 2 pigeons
...........
Costas Busch - RPI
20
The Pigeonhole Principle
and
DFAs
Costas Busch - RPI
21
DFA with
b
q1
4
states
b
b
a
q2
b
q3
a
Costas Busch - RPI
b
q4
a
22
In walks of strings:
no state
is repeated
a
aa
aab
b
q1
b
b
a
q2
a
q3
a
Costas Busch - RPI
b
q4
a
23
In walks of strings:
a state
is repeated
aabb
bbaa
abbabb
abbbabbabb...
b
q1
b
b
a
q2
a
q3
a
Costas Busch - RPI
b
q4
a
24
If string
w has length | w |  4 :
Then the transitions of string w
are more than the states of the DFA
Thus, a state must be repeated
b
q1
b
b
a
q2
a
q3
a
Costas Busch - RPI
b
q4
a
25
In general, for any DFA:
String
A state
w has length  number of states
q
walk of
must be repeated in the walk of
w
w
......
q
......
Repeated
state
Costas Busch - RPI
26
In other words for a string
w:
a
transitions are pigeons
q
states are pigeonholes
walk of
w
......
q
......
Repeated state
Costas Busch - RPI
27