• No results found

CHAPTER 1 Regular Languages. Contents

N/A
N/A
Protected

Academic year: 2021

Share "CHAPTER 1 Regular Languages. Contents"

Copied!
7
0
0

Loading.... (view fulltext now)

Full text

(1)

CHAPTER 1

Regular Languages

Contents

• Finite Automata (FA or DFA)

• definitions, examples, designing, regular operations

• Non-deterministic Finite Automata (NFA)

definitions, equivalence of NFAs and DFAs, closure under regular operations

• Regular expressions

definitions, equivalence with finite automata

Non-regular Languages

(2)

Non-regular Languages

• Try to build an automaton that recognizes the language

• The automaton starts by seeing 0 inputs.

• It has to remember the exact number of 0 inputs, since it will later check that number against the number of 1 inputs.

• But the number of 0 inputs can be arbitrary large.

• Intuitively, no finite number of states can remember the exact number of 0 inputs.

• We conclude that this language is not regular.

}.

:

1

0

{

n

m

L

=

m n

=

• To understand the power of finite automata we must also

understand their limitation.

• We will show that certain languages cannot be recognized by any

finite automaton.

(3)

Pumping Lemma

We call p the pumping number of L, and xyz the pumping decomposition of w.

Proof

Consider a regular language L.

• L is accepted by some finite automaton M. • Let p be the number of states of M.

• Now consider a word in L with at least p letters.

• Then w is accepted by M along some path that contains a loop.

• We can construct other paths of M by going through the loop 0,1,2, … times. • These paths also accept words in L.

• In other words, any accepting word w of length at least p can be “pumped “ to find infinitely many other accepted words.

Lemma.

For any regular language L,

there exists a number such that

for every word with at least p letters

there exist x, y, z with w = xyz and |y|>0 and |xy| such that

for every number

1 ≥ p

L

w

p

.

,

0

xy

z

L

i

i

(4)

How to prove that a language is not regular?

•We have to consider all possibilities for the pumping number p,

• all possibilities for the pumping decomposition x,y,z (often by case analysis). • But we are free to choose a single word w,

• and a single iteration number i.

• Choosing a suitable w is usually the crux of the proof (one needs a bit of creative thinking)

• For i, we can typically choose i=0 or i=2.

Example: is not regular.

• Choose any pumping number p (we know only that ). Choose • Consider any pumping decomposition w=xyz (|y|>0 and |xy| ). • Hence and and for .

• Choose i=2. Since is not in L.

for any number

there exists a word with at least p letters such that

for all x, y, z with w = xyz and |y|>0 and |xy|

there exists a number such that

1 ≥ p

L

w

p

.

0

xy

z

L

i

i

Suppose we want to prove that a language L is not regular.

• We can do this by showing that the pumping lemma does not hold for L; that is, we prove the negation of the pumping lemma:

}

:

1

0

{

n

m

L

=

m n

=

1 ≥ p

w

=

o

p

1

p

.

pa x 0= y 0= b b 1 , 1 0p a b p z = − −

(5)

More Examples

Example 2: is not regular.

Choose any pumping number p (we know only that ). • Choose

Consider any pumping decomposition w=xyz (|y|>0 and |xy| ). • There are two possibilities;

a) and and for . b) and and

Choose i=2. We need to show that is not in . a) which is not in , since

b) which is not in , since it contains three 1’s.10 10 ,

2z p b p xy = + b ≥1

}*}

1

,

0

{

:

{

2

=

ss

s

L

1 ≥ p

.

10

10

p p

w

=

pa x 10= y 0= b z = 0pab10p, b ≥1 ε = x y 10= b z = 0pb10p. z xy2 2 L , 10 10 10 2z b p p xy = L2 2 L

Example 3: is not regular.

Choose any pumping number p (we know only that ). • Choose

Consider any pumping decomposition w=xyz (|y|>0 and |xy| ). • Hence, and and for and

Choose i=2. We need to show that is not in , i.e., is not a square. • Indeed,

}

0

:

1

{

2 3

=

n

L

n 1 ≥ p

.

1

p2

w

=

pa x 1= y 1= b b 1 , 1p2 a b z = − − b p.2 + p b a+ ≤ b p z xy2 =1 2+ . ) 1 ( . 1 2 + > 2 + 2 + 2 + < + 2 ≥ p b p a b p p b p p p b 3 L

(6)

since (if were regular, then L would also be regular,

Proving (non)regularity.

To prove that a language L is regular, there are essentially two

options:

1. Find a finite automaton (or regular expression) that defines L.

2. Show that L can be built from simpler regular languages using operations that are known to preserve regularity

• To prove that a language L is not regular, there are again two

options:

1. Show that the negation of the pumping lemma holds for L.

2. Show that a language that is known to be non-regular can be built from L and languages that are known to be regular using operations that are known to preserve regularity.

• Example (of the second proof technique):

w

w

L

4

=

{

{

0

,

1

}*

:

4

L

*).

,

,

,

.,

.

(

i

e

contains the same number of 1’s and 0’s}

is not regular,

*)

1

*

0

(

4

= L

L

(7)

Homework

Problems:

• 1.13 (consider c, f, i from 1.4).

• Do 1.14 and 1.15 for the following two regular

expressions:

• Do 1.17 for 1.17 (c) and language

• Do 1.16 for the following FA

*

1

*

)

000

*

)

1

0

((

)

*

)

1

0

)*)(

11

)(

000

(

(

)

ii

i

}

0

:

1

0

{

n 2n

n

q1

q0

0 0

q2

0, 1 1 1

References

Related documents

If you’re a beer buff, take a guided tour at Deschutes Brewery to learn more about how the craft beer scene got its start in Central Oregon, then visit a few.. of the city’s

In this study we assessed species richness, diversity and faunal composi- tion of ant assemblages in four plant physiognomies along a gradient of plant succes- sion: grassland,

Whilst there are currently no high-level of evidence RCTs to suggest the benefits of acupuncture in bone health, there are several small animal and human trials suggesting

In our “Present Value” estimates, we used as instruments, the fit and its one period lag of the difference of the weighted present value of the fundament (the mark-up over real

Research does that your request form will cause for requesting official interim transcript sent to ou students are you requested move may have.. completed and if

First, we study social and economic impact at the household level, classifying households according to the needs for care of older residents at the time of the baseline and

Speaking a Java idiom, methods are synchronized, that is each method of the same object is executed in mutual exclusion, and method invocations are asynchronous, that is the

A cytolethal distending toxin (CDT)-like effect on Vero cells was observed in 35 (90%) isolates from patients with diarrhoea, in all three isolates from healthy individuals and in