theory of computing pdf

18
Topic - 4: Regular Topic - 4: Regular Languages Languages Theory of Computing Theory of Computing Dilouar Hossain [email protected]

Upload: dilouar-hossain

Post on 06-Jan-2017

119 views

Category:

Engineering


0 download

TRANSCRIPT

Page 1: Theory of computing pdf

Topic - 4: Regular LanguagesTopic - 4: Regular Languages

Theory of ComputingTheory of Computing

Dilouar [email protected]

Page 2: Theory of computing pdf

Proving Languages not to be Regular The Pumping Lemma for Regular Languages Applications of the Pumping Lemma

Closure Properties of Regular Languages

Topic ContentsTopic Contents

Page 3: Theory of computing pdf

3

Page 4: Theory of computing pdf

4

Page 5: Theory of computing pdf

5

Problem (Example 4.2 of Text Book): Show that the language Leq consisting of all strings with an equal number of 0s and 1s (not in any particular order) is not a regular language.

Soln:Suppose that Leq were regular.Then there would be a constant n satisfying the conditions of the pumping lemma.Let By the pumping lemma, we can break, w = xyz such that y ≠ ε and |xy| ≤ n.

.10 nnw

Page 6: Theory of computing pdf

6

Now, |w| = |0n1n| = n + n = 2n.

Now by the pumping lemma, the string xynz is in Leq.

Here, |xyn| = |x| + n|y| ≥ np > nTherefore the string xynz has n 1s and more than n 0s.So xynz cannot be in Leq, which contradicts our assumption.

Thus the language Lpr is not a regular language.

[Proved]

py

npy

ynxy

p

p

0

.0where,0

and

Page 7: Theory of computing pdf

7

Problem (Page No. 190 of Text Book): Show that the language Lpal consisting of all strings of 0s and 1s which is a palindrome is not a regular language .

Soln:Suppose Lpal is regular.Then there will be a constant n satisfying the conditions of the pumping lemma.Let By the pumping lemma, we can break, w = xyz such that y ≠ ε and |xy| ≤ n.

.100 nnw

Page 8: Theory of computing pdf

8

Now, |w| = |0n10n| = n + 1 + n = 2n + 1.

Now by the pumping lemma, the string xynz is in Lpal.

Here, |xyn| = |x| + n|y| ≥ np > n

py

npy

ynxy

p

p

0

.0where,0

and

Page 9: Theory of computing pdf

9

Therefore the string xynz has more than n 0s to the left of the single 1 and n 0’s to the right of that 1.Hence xynz is not a palindrome.So xynz cannot be in Lpal, which contradicts our assumption.

Thus the language Lpal is not a regular language.

[Proved]

Page 10: Theory of computing pdf

L − M

10

Page 11: Theory of computing pdf

11

Page 12: Theory of computing pdf

Complement language construction:1. Convert the regular expression to an є-NFA 2. Convert the є-NFA to a DFA by the subset

construction.3. Complement the accepting states of that DFA.4. Turn the complement DFA back into a regular

expression.

12

Closure Properties of Regular Languages: Complement

Page 13: Theory of computing pdf

13

Closure Properties of Regular Languages: Complement

Page 14: Theory of computing pdf

14

Page 15: Theory of computing pdf

15

Page 16: Theory of computing pdf

16

Page 17: Theory of computing pdf

17

Page 18: Theory of computing pdf