Docsity

Closure Properties and Pumping Lemmas of Regular Languages and Context-Free Languages, Study notes of Computer Science

Toggle sidebar
bg1
CMPSCI 601: Recall From Last Time Lecture 4
Kleene’s Theorem: Let

be any language.
Then the following are equivalent:
1.

, for some DFA
.
2.

, for some NFA
without
transitions
3.

, for some NFA
.
4.

, for some regular expression
.
5.
is regular.
Myhill-Nerode Theorem: The language
is regular
iff
has a finite number of equivalence classes. Fur-
thermore, this number of equivalence classes is equal to
the number of states in the minimum-state DFA that ac-
cepts
.
1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13

Partial preview of the text

Download Closure Properties and Pumping Lemmas of Regular Languages and Context-Free Languages and more Study notes Computer Science in PDF only on Docsity!

CMPSCI 601: Recall From Last Time Lecture 4

Kleene’s Theorem: Let

be any language. Then the following are equivalent:

, for some DFA

.

, for some NFA without transitions

, for some NFA.

, for some regular expression.

is regular.

Myhill-Nerode Theorem: The language

is regular iff   has a finite number of equivalence classes. Fur- thermore, this number of equivalence classes is equal to the number of states in the minimum-state DFA that ac- cepts

.

CMPSCI 601: Regular Language Closure Lecture 4

Closure Theorem for Regular Sets: Let

be

regular languages and let  

and  

be homomorphisms. Then the following languages are regular:

A homomorphism of strings is a function  such that for

any strings  and  , 

. The set  

is

defined as  

.

Let  

be a homomorphism.

If  is a regular expression over

, we can compute a

regular expression 

 by induction on the definition of

regular expressions. Then we can prove by induction that

If  is a DFA with alphabet

and

, we can

make a DFA for  

as follows. States, start, and

final states are the same as . For every letter  in

and

every state  , define 

 to be 

Then for any

, and

^ 

 ^

CMPSCI 601: Review of CFL’s Lecture 4

Definition: A context-free grammar (CFG) is a 4-

tuple

,

 ^  variables = nonterminals,

^   terminals,

 ^  rules = productions,     ^    ,

 ^   ,

 ^ ^  are all finite.

^   

Parse Tree:

V

T F F C D

( E ) E + T E + T T F F V L D 3 * ( x 1 + y 1 + z 1 )

F V L D

T

E

L D

Pumping Lemma for Regular Sets: Let

be a DFA. Let

. Let

s.t.

. Then 

s.t. the following all hold:

^ ^ ^ ^ 

^ ^ ^ ^  , and

^ ^  ^  ^    

Proof: Let

s.t.

.

^ ^ ^

By the Pigeonhole Principle,

. Thus,

for all

N. '

CFL Pumping Lemma: Let

be a CFL. Then there is a constant

, depending only on

, such that if

   ^ and

, then there exist strings 

such that:

^ ^   , and

^    ^  , and

^   ^  , and

 for all  N ,  

Proof: Let

be a CFG with

.

Let

be so large that for

s.t. 

for some

, the parse tree for

has height

.

Let

,

.

The parse tree for

has height greater than

.

Thus, some path repeats a nonterminal,.

y

S

N

N

u v w x

N

Prop:

  

N

is not a CFL.

Proof:

The argument is almost identical. We let

where

is larger than the constant given by the CFL Pumping Lemma. So

 with

^ ,

, and    in

 

for all . Again,

neither  nor can contain letters of two different types,

or  is not in 

(^) 

. But then  cannot

contain equal numbers of  ’s,

’s, and (^)  ’s, as only one or two types of letter have been added.

Any CFL satisfies the conclusion of the CFL Pumping Lemma, but it is not true that any non-CFL must fail to satisfy it. There are other tools that can show a language to be a non-CFL. These include stronger forms of the Pumping Lemma and more closure properties.

Let

be the set of strings in

(^) 

that

have an equal number of  ’s,

’s, and (^)  ’s. You can use the CFL Pumping Lemma on this with the right choice of

, but far easier is using the fact that the intersection of

with 

(^) 

is the language

  .

If

is a CFL and  a regular language, then

 must

be regular. Proving this, however, requires a different characterization of the CFL’s.

ε (^) r Z (^) 0 /

a/A aA/

b/B bB/

q s

Theorem 4.1 Let

be any language. Then the following are equivalent:

1.

, for some CFG . 2.

, for some PDA .

3.

is a context-free language.

Proof: We give only a sketch here – there are detailed proofs in [HMU], [LP], and [S].

To prove (1) implies (2), we can build a “bottom-up parser” or “top-down” parser, similar to those used in real-world compilers except that the latter are deterministic.

The proof that the language of any PDA is a CFL (that (2) implies (1)) is of less practical interest.

Given states  and  , let

 be the set of strings that could

take the PDA from state  with empty stack to state  with

empty stack.

If we can define rules making each

 a CFL we win, be-

cause the language of the PDA is the union of

% for all

final states

, where

is the start state. (So our grammar has a rule

% for each

.)

We have all rules of the form

  , and a rule

whenever moves of the PDA warrant it.

Here I am skipping some assumptions on the PDA, and the (nontrivial) proof that any accepting run of the PDA

corresponds to a valid derivation in our grammar. '