CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020...

64
CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 1 CS310 : Automata Theory 2020 Lecture 12: Applications of the pumping lemma Instructor: S. Akshay IIT Bombay, India 06-02-2020

Transcript of CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020...

Page 1: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 1

CS310 : Automata Theory 2020

Lecture 12: Applications of the pumping lemma

Instructor: S. Akshay

IIT Bombay, India

06-02-2020

Page 2: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 2

Recap

I Deterministic finite state automata (DFA): run, accepting run,(extended) transition relation

I Regular languages: closure under Union, intersection andcomplementation

I Non-deterministic finite state automata (NFA): the Subset construction,worst-case exponential blowup

I Applications 1: text search using automata.

I ε-NFA: conversion to NFA.

I Regular expressions: definition, laws, conversion to ε-NFA and back.

I Applications 2: regular expressions in GREP, emacs, python etc.

I Properties of regular languages: Non regularity

Page 3: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 2

Recap

I Deterministic finite state automata (DFA): run, accepting run,(extended) transition relation

I Regular languages: closure under Union, intersection andcomplementation

I Non-deterministic finite state automata (NFA): the Subset construction,worst-case exponential blowup

I Applications 1: text search using automata.

I ε-NFA: conversion to NFA.

I Regular expressions: definition, laws, conversion to ε-NFA and back.

I Applications 2: regular expressions in GREP, emacs, python etc.

I Properties of regular languages: Non regularity

Page 4: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3

Pumping lemma

Theorem (Pumping lemma)

Let L be a regular language.

Then

I there exists a constant n such that

I for every word w ∈ L such that |w | ≥ n,I we can break w into three words w = xyz , such that

1. y 6= ε,2. |xy | ≤ n, and3. for all k ≥ 0, xykz ∈ L.

Let us write the above lemma as a logical statement

∃n. ∀w ∈ L. (|w | ≥ n⇒ ∃xyz . (xyz = w ∧y 6= ε∧|xy | ≤ n∧(∀k . xykz ∈ L)))

Page 5: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3

Pumping lemma

Theorem (Pumping lemma)

Let L be a regular language. Then

I there exists a constant n such that

I for every word w ∈ L such that |w | ≥ n,I we can break w into three words w = xyz , such that

1. y 6= ε,2. |xy | ≤ n, and3. for all k ≥ 0, xykz ∈ L.

Let us write the above lemma as a logical statement

∃n. ∀w ∈ L. (|w | ≥ n⇒ ∃xyz . (xyz = w ∧y 6= ε∧|xy | ≤ n∧(∀k . xykz ∈ L)))

Page 6: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3

Pumping lemma

Theorem (Pumping lemma)

Let L be a regular language. Then

I there exists a constant n such that

I for every word w ∈ L such that |w | ≥ n,

I we can break w into three words w = xyz , such that

1. y 6= ε,2. |xy | ≤ n, and3. for all k ≥ 0, xykz ∈ L.

Let us write the above lemma as a logical statement

∃n. ∀w ∈ L. (|w | ≥ n⇒ ∃xyz . (xyz = w ∧y 6= ε∧|xy | ≤ n∧(∀k . xykz ∈ L)))

Page 7: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3

Pumping lemma

Theorem (Pumping lemma)

Let L be a regular language. Then

I there exists a constant n such that

I for every word w ∈ L such that |w | ≥ n,I we can break w into three words w = xyz , such that

1. y 6= ε,2. |xy | ≤ n, and3. for all k ≥ 0, xykz ∈ L.

Let us write the above lemma as a logical statement

∃n. ∀w ∈ L. (|w | ≥ n⇒ ∃xyz . (xyz = w ∧y 6= ε∧|xy | ≤ n∧(∀k . xykz ∈ L)))

Page 8: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3

Pumping lemma

Theorem (Pumping lemma)

Let L be a regular language. Then

I there exists a constant n such that

I for every word w ∈ L such that |w | ≥ n,I we can break w into three words w = xyz , such that

1. y 6= ε,2. |xy | ≤ n, and3. for all k ≥ 0, xykz ∈ L.

Let us write the above lemma as a logical statement

∃n. ∀w ∈ L. (|w | ≥ n⇒ ∃xyz . (xyz = w ∧y 6= ε∧|xy | ≤ n∧(∀k . xykz ∈ L)))

Page 9: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3

Pumping lemma

Theorem (Pumping lemma)

Let L be a regular language. Then

I there exists a constant n such that

I for every word w ∈ L such that |w | ≥ n,I we can break w into three words w = xyz , such that

1. y 6= ε,2. |xy | ≤ n, and3. for all k ≥ 0, xykz ∈ L.

Let us write the above lemma as a logical statement

∃n. ∀w ∈ L. (|w | ≥ n⇒ ∃xyz . (xyz = w ∧y 6= ε∧|xy | ≤ n∧(∀k . xykz ∈ L)))

Page 10: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3

Pumping lemma

Theorem (Pumping lemma)

Let L be a regular language. Then

I there exists a constant n such that

I for every word w ∈ L such that |w | ≥ n,I we can break w into three words w = xyz , such that

1. y 6= ε,2. |xy | ≤ n, and3. for all k ≥ 0, xykz ∈ L.

Let us write the above lemma as a logical statement

∃n. ∀w ∈ L. (|w | ≥ n⇒ ∃xyz . (xyz = w ∧y 6= ε∧|xy | ≤ n∧(∀k . xykz ∈ L)))

Page 11: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 4

Proving the pumping lemma

Proof (of the pumping lemma)

I If L is regular, then there exists DFA A such that L = L(A).

I Suppose A has n states.

I Consider a word w = a1 . . . am ∈ L such that m ≥ n.

I Let q0, . . . , qm be the run of A on w . Therefore, qm is an acceptingstate.

I By pigeonhole principle, at least two states in q0, . . . , qn︸ ︷︷ ︸n+1

should be equal.

I Therefore, there are i and j such that 0 ≤ i < j ≤ n and qi = qj .

Page 12: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 4

Proving the pumping lemma

Proof (of the pumping lemma)

I If L is regular, then there exists DFA A such that L = L(A).

I Suppose A has n states.

I Consider a word w = a1 . . . am ∈ L such that m ≥ n.

I Let q0, . . . , qm be the run of A on w . Therefore, qm is an acceptingstate.

I By pigeonhole principle, at least two states in q0, . . . , qn︸ ︷︷ ︸n+1

should be equal.

I Therefore, there are i and j such that 0 ≤ i < j ≤ n and qi = qj .

Page 13: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 4

Proving the pumping lemma

Proof (of the pumping lemma)

I If L is regular, then there exists DFA A such that L = L(A).

I Suppose A has n states.

I Consider a word w = a1 . . . am ∈ L such that m ≥ n.

I Let q0, . . . , qm be the run of A on w . Therefore, qm is an acceptingstate.

I By pigeonhole principle, at least two states in q0, . . . , qn︸ ︷︷ ︸n+1

should be equal.

I Therefore, there are i and j such that 0 ≤ i < j ≤ n and qi = qj .

Page 14: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 4

Proving the pumping lemma

Proof (of the pumping lemma)

I If L is regular, then there exists DFA A such that L = L(A).

I Suppose A has n states.

I Consider a word w = a1 . . . am ∈ L such that m ≥ n.

I Let q0, . . . , qm be the run of A on w . Therefore, qm is an acceptingstate.

I By pigeonhole principle, at least two states in q0, . . . , qn︸ ︷︷ ︸n+1

should be equal.

I Therefore, there are i and j such that 0 ≤ i < j ≤ n and qi = qj .

Page 15: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 4

Proving the pumping lemma

Proof (of the pumping lemma)

I If L is regular, then there exists DFA A such that L = L(A).

I Suppose A has n states.

I Consider a word w = a1 . . . am ∈ L such that m ≥ n.

I Let q0, . . . , qm be the run of A on w . Therefore, qm is an acceptingstate.

I By pigeonhole principle, at least two states in q0, . . . , qn︸ ︷︷ ︸n+1

should be equal.

I Therefore, there are i and j such that 0 ≤ i < j ≤ n and qi = qj .

Page 16: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 4

Proving the pumping lemma

Proof (of the pumping lemma)

I If L is regular, then there exists DFA A such that L = L(A).

I Suppose A has n states.

I Consider a word w = a1 . . . am ∈ L such that m ≥ n.

I Let q0, . . . , qm be the run of A on w . Therefore, qm is an acceptingstate.

I By pigeonhole principle, at least two states in q0, . . . , qn︸ ︷︷ ︸n+1

should be equal.

I Therefore, there are i and j such that 0 ≤ i < j ≤ n and qi = qj .

Page 17: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 5

Proving pumping lemma II

Proof (contd.).

I Now, we break w = xyz as follows.

I x = a1a2...aiI y = ai+1ai+2...ajI z = aj+1aj+2...am

I By construction, y 6= ε and |xy | ≤ n.

q0 qi qmx

y

z

I For any k ≥ 0, xykz takes A to qm, which is accepting.

I Therefore, xykz ∈ L for all k ≥ 0.

Page 18: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 5

Proving pumping lemma II

Proof (contd.).

I Now, we break w = xyz as follows.

I x = a1a2...aiI y = ai+1ai+2...ajI z = aj+1aj+2...am

I By construction, y 6= ε and |xy | ≤ n.

q0 qi qmx

y

z

I For any k ≥ 0, xykz takes A to qm, which is accepting.

I Therefore, xykz ∈ L for all k ≥ 0.

Page 19: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 5

Proving pumping lemma II

Proof (contd.).

I Now, we break w = xyz as follows.

I x = a1a2...aiI y = ai+1ai+2...ajI z = aj+1aj+2...am

I By construction, y 6= ε and |xy | ≤ n.

q0 qi qmx

y

z

I For any k ≥ 0, xykz takes A to qm, which is accepting.

I Therefore, xykz ∈ L for all k ≥ 0.

Page 20: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 5

Proving pumping lemma II

Proof (contd.).

I Now, we break w = xyz as follows.

I x = a1a2...aiI y = ai+1ai+2...ajI z = aj+1aj+2...am

I By construction, y 6= ε and |xy | ≤ n.

q0 qi qmx

y

z

I For any k ≥ 0, xykz takes A to qm, which is accepting.

I Therefore, xykz ∈ L for all k ≥ 0.

Page 21: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 6

Contrapositive of pumping lemma

TheoremIf

I for all n,

I there is a word w ∈ L such that |w | ≥ n,I for each breakup of w into three words w = xyz such that

1. y 6= ε and2. |xy | ≤ n,

there is a k ≥ 0 such that xykz 6∈ L,

then L is not regular.

We will see how to apply the above lemma.

Page 22: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 6

Contrapositive of pumping lemma

TheoremIf

I for all n,

I there is a word w ∈ L such that |w | ≥ n,I for each breakup of w into three words w = xyz such that

1. y 6= ε and2. |xy | ≤ n,

there is a k ≥ 0 such that xykz 6∈ L,

then L is not regular.

We will see how to apply the above lemma.

Page 23: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 6

Contrapositive of pumping lemma

TheoremIf

I for all n,

I there is a word w ∈ L such that |w | ≥ n,I for each breakup of w into three words w = xyz such that

1. y 6= ε and2. |xy | ≤ n,

there is a k ≥ 0 such that xykz 6∈ L,

then L is not regular.

We will see how to apply the above lemma.

Page 24: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 6

Contrapositive of pumping lemma

TheoremIf

I for all n,

I there is a word w ∈ L such that |w | ≥ n,I for each breakup of w into three words w = xyz such that

1. y 6= ε and2. |xy | ≤ n,

there is a k ≥ 0 such that xykz 6∈ L,

then L is not regular.

We will see how to apply the above lemma.

Page 25: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 6

Contrapositive of pumping lemma

TheoremIf

I for all n,

I there is a word w ∈ L such that |w | ≥ n,I for each breakup of w into three words w = xyz such that

1. y 6= ε and2. |xy | ≤ n,

there is a k ≥ 0 such that xykz 6∈ L,

then L is not regular.

We will see how to apply the above lemma.

Page 26: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 6

Contrapositive of pumping lemma

TheoremIf

I for all n,

I there is a word w ∈ L such that |w | ≥ n,I for each breakup of w into three words w = xyz such that

1. y 6= ε and2. |xy | ≤ n,

there is a k ≥ 0 such that xykz 6∈ L,

then L is not regular.

We will see how to apply the above lemma.

Page 27: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 7

How to use the pumping lemma?

In the theorem, there are two exists quantifiers, namely w and k .

Proving non regularity boils down to the following two quantifierinstantiations.

I Choose a word w for each n

I Find k for each breakup of the w

The instantiations are the creative steps!

Page 28: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 7

How to use the pumping lemma?

In the theorem, there are two exists quantifiers, namely w and k .

Proving non regularity boils down to the following two quantifierinstantiations.

I Choose a word w for each n

I Find k for each breakup of the w

The instantiations are the creative steps!

Page 29: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 7

How to use the pumping lemma?

In the theorem, there are two exists quantifiers, namely w and k .

Proving non regularity boils down to the following two quantifierinstantiations.

I Choose a word w for each n

I Find k for each breakup of the w

The instantiations are the creative steps!

Page 30: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 8

Proving a language non regular

Consider language L

I For each n, we propose a word w ∈ L of length at least n

I We define parameterized word x and non-empty word y such thatI xyz = w for some z andI the parameter space covers all x and y such that |xy | ≤ n.

I For each split x and y , we choose a k such that xykz 6∈ L.

We have proven that L is not regular.

Page 31: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 8

Proving a language non regular

Consider language L

I For each n, we propose a word w ∈ L of length at least n

I We define parameterized word x and non-empty word y such thatI xyz = w for some z andI the parameter space covers all x and y such that |xy | ≤ n.

I For each split x and y , we choose a k such that xykz 6∈ L.

We have proven that L is not regular.

Page 32: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 8

Proving a language non regular

Consider language L

I For each n, we propose a word w ∈ L of length at least n

I We define parameterized word x and non-empty word y such thatI xyz = w for some z andI the parameter space covers all x and y such that |xy | ≤ n.

I For each split x and y , we choose a k such that xykz 6∈ L.

We have proven that L is not regular.

Page 33: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 8

Proving a language non regular

Consider language L

I For each n, we propose a word w ∈ L of length at least n

I We define parameterized word x and non-empty word y such thatI xyz = w for some z andI the parameter space covers all x and y such that |xy | ≤ n.

I For each split x and y , we choose a k such that xykz 6∈ L.

We have proven that L is not regular.

Page 34: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 8

Proving a language non regular

Consider language L

I For each n, we propose a word w ∈ L of length at least n

I We define parameterized word x and non-empty word y such thatI xyz = w for some z andI the parameter space covers all x and y such that |xy | ≤ n.

I For each split x and y , we choose a k such that xykz 6∈ L.

We have proven that L is not regular.

Page 35: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 9

Example 1: using pumping lemma

Example 1

Consider again Leq = {0n1n|n ≥ 0}.

I For each n we need a word. Let it be w = 0n1n.

I The first n characters of w are 0n. The breaks x and y are to be fromwithin 0n.

I Let x = 0i and y = 0j , where i + j ≤ n and j 6= 0.

w = 0i︸︷︷︸x

0j︸︷︷︸y

0n−j−i1n︸ ︷︷ ︸z

I Now we choose k = 0 for each i and j . The corresponding word is

0i (0j)00n−j−i1n = 0n−j1n.

I Clearly, 0n−j1n 6∈ Leq. Therefore, Leq is not regular.

Page 36: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 9

Example 1: using pumping lemma

Example 1

Consider again Leq = {0n1n|n ≥ 0}.

I For each n we need a word. Let it be w = 0n1n.

I The first n characters of w are 0n. The breaks x and y are to be fromwithin 0n.

I Let x = 0i and y = 0j , where i + j ≤ n and j 6= 0.

w = 0i︸︷︷︸x

0j︸︷︷︸y

0n−j−i1n︸ ︷︷ ︸z

I Now we choose k = 0 for each i and j . The corresponding word is

0i (0j)00n−j−i1n = 0n−j1n.

I Clearly, 0n−j1n 6∈ Leq. Therefore, Leq is not regular.

Page 37: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 9

Example 1: using pumping lemma

Example 1

Consider again Leq = {0n1n|n ≥ 0}.

I For each n we need a word. Let it be w = 0n1n.

I The first n characters of w are 0n. The breaks x and y are to be fromwithin 0n.

I Let x = 0i and y = 0j , where i + j ≤ n and j 6= 0.

w = 0i︸︷︷︸x

0j︸︷︷︸y

0n−j−i1n︸ ︷︷ ︸z

I Now we choose k = 0 for each i and j . The corresponding word is

0i (0j)00n−j−i1n = 0n−j1n.

I Clearly, 0n−j1n 6∈ Leq. Therefore, Leq is not regular.

Page 38: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 9

Example 1: using pumping lemma

Example 1

Consider again Leq = {0n1n|n ≥ 0}.

I For each n we need a word. Let it be w = 0n1n.

I The first n characters of w are 0n. The breaks x and y are to be fromwithin 0n.

I Let x = 0i and y = 0j , where i + j ≤ n and j 6= 0.

w = 0i︸︷︷︸x

0j︸︷︷︸y

0n−j−i1n︸ ︷︷ ︸z

I Now we choose k = 0 for each i and j . The corresponding word is

0i (0j)00n−j−i1n = 0n−j1n.

I Clearly, 0n−j1n 6∈ Leq. Therefore, Leq is not regular.

Page 39: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 9

Example 1: using pumping lemma

Example 1

Consider again Leq = {0n1n|n ≥ 0}.

I For each n we need a word. Let it be w = 0n1n.

I The first n characters of w are 0n. The breaks x and y are to be fromwithin 0n.

I Let x = 0i and y = 0j , where i + j ≤ n and j 6= 0.

w = 0i︸︷︷︸x

0j︸︷︷︸y

0n−j−i1n︸ ︷︷ ︸z

I Now we choose k = 0 for each i and j . The corresponding word is

0i (0j)00n−j−i1n = 0n−j1n.

I Clearly, 0n−j1n 6∈ Leq. Therefore, Leq is not regular.

Page 40: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 9

Example 1: using pumping lemma

Example 1

Consider again Leq = {0n1n|n ≥ 0}.

I For each n we need a word. Let it be w = 0n1n.

I The first n characters of w are 0n. The breaks x and y are to be fromwithin 0n.

I Let x = 0i and y = 0j , where i + j ≤ n and j 6= 0.

w = 0i︸︷︷︸x

0j︸︷︷︸y

0n−j−i1n︸ ︷︷ ︸z

I Now we choose k = 0 for each i and j . The corresponding word is

0i (0j)00n−j−i1n = 0n−j1n.

I Clearly, 0n−j1n 6∈ Leq. Therefore, Leq is not regular.

Page 41: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 9

Example 1: using pumping lemma

Example 1

Consider again Leq = {0n1n|n ≥ 0}.

I For each n we need a word. Let it be w = 0n1n.

I The first n characters of w are 0n. The breaks x and y are to be fromwithin 0n.

I Let x = 0i and y = 0j , where i + j ≤ n and j 6= 0.

w = 0i︸︷︷︸x

0j︸︷︷︸y

0n−j−i1n︸ ︷︷ ︸z

I Now we choose k = 0 for each i and j . The corresponding word is

0i (0j)00n−j−i1n = 0n−j1n.

I Clearly, 0n−j1n 6∈ Leq. Therefore, Leq is not regular.

Page 42: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 10

Example 2: using pumping lemma

Example 2

Consider again L = {w |w has equal number of 0 and 1}.

I For each n we need a word. Let it be w = 0n1n.

I The first n characters of w are 0n. The breaks x and y are to be fromwithin 0n.

I Let x = 0i and y = 0j , where i + j ≤ n and j 6= 0.

w = 0i︸︷︷︸x

0j︸︷︷︸y

0n−j−i1n︸ ︷︷ ︸z

I Now we choose k = 0 for each i and j . The corresponding word is

0i (0j)00n−j−i1n = 0n−j1n.

I Clearly, 0n−j1n 6∈ L. Therefore, L is not regular.

Page 43: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 10

Example 2: using pumping lemma

Example 2

Consider again L = {w |w has equal number of 0 and 1}.I For each n we need a word. Let it be w = 0n1n.

I The first n characters of w are 0n. The breaks x and y are to be fromwithin 0n.

I Let x = 0i and y = 0j , where i + j ≤ n and j 6= 0.

w = 0i︸︷︷︸x

0j︸︷︷︸y

0n−j−i1n︸ ︷︷ ︸z

I Now we choose k = 0 for each i and j . The corresponding word is

0i (0j)00n−j−i1n = 0n−j1n.

I Clearly, 0n−j1n 6∈ L. Therefore, L is not regular.

Page 44: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 10

Example 2: using pumping lemma

Example 2

Consider again L = {w |w has equal number of 0 and 1}.I For each n we need a word. Let it be w = 0n1n.

I The first n characters of w are 0n. The breaks x and y are to be fromwithin 0n.

I Let x = 0i and y = 0j , where i + j ≤ n and j 6= 0.

w = 0i︸︷︷︸x

0j︸︷︷︸y

0n−j−i1n︸ ︷︷ ︸z

I Now we choose k = 0 for each i and j . The corresponding word is

0i (0j)00n−j−i1n = 0n−j1n.

I Clearly, 0n−j1n 6∈ L. Therefore, L is not regular.

Page 45: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 10

Example 2: using pumping lemma

Example 2

Consider again L = {w |w has equal number of 0 and 1}.I For each n we need a word. Let it be w = 0n1n.

I The first n characters of w are 0n. The breaks x and y are to be fromwithin 0n.

I Let x = 0i and y = 0j , where i + j ≤ n and j 6= 0.

w = 0i︸︷︷︸x

0j︸︷︷︸y

0n−j−i1n︸ ︷︷ ︸z

I Now we choose k = 0 for each i and j . The corresponding word is

0i (0j)00n−j−i1n = 0n−j1n.

I Clearly, 0n−j1n 6∈ L. Therefore, L is not regular.

Page 46: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 10

Example 2: using pumping lemma

Example 2

Consider again L = {w |w has equal number of 0 and 1}.I For each n we need a word. Let it be w = 0n1n.

I The first n characters of w are 0n. The breaks x and y are to be fromwithin 0n.

I Let x = 0i and y = 0j , where i + j ≤ n and j 6= 0.

w = 0i︸︷︷︸x

0j︸︷︷︸y

0n−j−i1n︸ ︷︷ ︸z

I Now we choose k = 0 for each i and j . The corresponding word is

0i (0j)00n−j−i1n = 0n−j1n.

I Clearly, 0n−j1n 6∈ L. Therefore, L is not regular.

Page 47: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 10

Example 2: using pumping lemma

Example 2

Consider again L = {w |w has equal number of 0 and 1}.I For each n we need a word. Let it be w = 0n1n.

I The first n characters of w are 0n. The breaks x and y are to be fromwithin 0n.

I Let x = 0i and y = 0j , where i + j ≤ n and j 6= 0.

w = 0i︸︷︷︸x

0j︸︷︷︸y

0n−j−i1n︸ ︷︷ ︸z

I Now we choose k = 0 for each i and j . The corresponding word is

0i (0j)00n−j−i1n = 0n−j1n.

I Clearly, 0n−j1n 6∈ L. Therefore, L is not regular.

Page 48: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 10

Example 2: using pumping lemma

Example 2

Consider again L = {w |w has equal number of 0 and 1}.I For each n we need a word. Let it be w = 0n1n.

I The first n characters of w are 0n. The breaks x and y are to be fromwithin 0n.

I Let x = 0i and y = 0j , where i + j ≤ n and j 6= 0.

w = 0i︸︷︷︸x

0j︸︷︷︸y

0n−j−i1n︸ ︷︷ ︸z

I Now we choose k = 0 for each i and j . The corresponding word is

0i (0j)00n−j−i1n = 0n−j1n.

I Clearly, 0n−j1n 6∈ L. Therefore, L is not regular.

Page 49: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 11

Example 3: using pumping lemmaLet word wR be reverse of word w .

Example 3

Consider Lrev = {wwR |w ∈ {0, 1}∗}.

I For each n, let w = 0n110n

I The first n characters of w are 0n

I Let x = 0i and y = 0j , where i + j ≤ n and j 6= 0.

w = 0i︸︷︷︸x

0j︸︷︷︸y

0n−j−i110n︸ ︷︷ ︸z

I Let k = 2 for each i and j .

0i (0j)20n−j−i110n = 0n+j110n 6∈ Lrev

Page 50: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 11

Example 3: using pumping lemmaLet word wR be reverse of word w .

Example 3

Consider Lrev = {wwR |w ∈ {0, 1}∗}.

I For each n, let w = 0n110n

I The first n characters of w are 0n

I Let x = 0i and y = 0j , where i + j ≤ n and j 6= 0.

w = 0i︸︷︷︸x

0j︸︷︷︸y

0n−j−i110n︸ ︷︷ ︸z

I Let k = 2 for each i and j .

0i (0j)20n−j−i110n = 0n+j110n 6∈ Lrev

Page 51: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 11

Example 3: using pumping lemmaLet word wR be reverse of word w .

Example 3

Consider Lrev = {wwR |w ∈ {0, 1}∗}.

I For each n, let w = 0n110n

I The first n characters of w are 0n

I Let x = 0i and y = 0j , where i + j ≤ n and j 6= 0.

w = 0i︸︷︷︸x

0j︸︷︷︸y

0n−j−i110n︸ ︷︷ ︸z

I Let k = 2 for each i and j .

0i (0j)20n−j−i110n = 0n+j110n 6∈ Lrev

Page 52: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 11

Example 3: using pumping lemmaLet word wR be reverse of word w .

Example 3

Consider Lrev = {wwR |w ∈ {0, 1}∗}.

I For each n, let w = 0n110n

I The first n characters of w are 0n

I Let x = 0i and y = 0j , where i + j ≤ n and j 6= 0.

w = 0i︸︷︷︸x

0j︸︷︷︸y

0n−j−i110n︸ ︷︷ ︸z

I Let k = 2 for each i and j .

0i (0j)20n−j−i110n = 0n+j110n 6∈ Lrev

Page 53: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 11

Example 3: using pumping lemmaLet word wR be reverse of word w .

Example 3

Consider Lrev = {wwR |w ∈ {0, 1}∗}.

I For each n, let w = 0n110n

I The first n characters of w are 0n

I Let x = 0i and y = 0j , where i + j ≤ n and j 6= 0.

w = 0i︸︷︷︸x

0j︸︷︷︸y

0n−j−i110n︸ ︷︷ ︸z

I Let k = 2 for each i and j .

0i (0j)20n−j−i110n = 0n+j110n 6∈ Lrev

Page 54: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 12

Properties of regular languages

Exercises:

1. Is subset of any regular language regular?

2. Is superset of any regular language regular?

3. If L1 ∪ L2 is regular, then are L1 and L2 regular?

4. Is this regular: {0n1m|n 6= m}?5. Is this regular: {0n1m|n > m}?6. Is this regular: {0n1m | n is odd and m is even }7. Is this regular: {0n1n+1|n ≥ 0}

Page 55: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 13

Need for infinite memory

Feels like all non-regular languages needed to remember infinite memory.

In {0n1n|n ≥ 0} we need to remember the number of seen 0s and count the1s to match.

Finite number of states cannot count unboundedly increasing number.

Page 56: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 13

Need for infinite memory

Feels like all non-regular languages needed to remember infinite memory.

In {0n1n|n ≥ 0} we need to remember the number of seen 0s and count the1s to match.

Finite number of states cannot count unboundedly increasing number.

Page 57: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 13

Need for infinite memory

Feels like all non-regular languages needed to remember infinite memory.

In {0n1n|n ≥ 0} we need to remember the number of seen 0s and count the1s to match.

Finite number of states cannot count unboundedly increasing number.

Page 58: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 14

Example 4: using pumping lemma

Example 4

Consider Lprime = {1p|p is a prime number.}.

I For each n, let w = 1p such that p > n + 2

I The first n characters of w are 1n.

I Let x = 1i and y = 1j , where i + j ≤ n and j 6= 0.

w = 1i︸︷︷︸x

1j︸︷︷︸y

1p−j−i︸ ︷︷ ︸z

I So, |xykz | = (p − j) + kj .

I Let k = p − j . Therefore, |xykz | = (p − j)(1 + j).

I Since both (p − k) > 1(why?)and 1 + j > 1(why?), xykz 6∈ Lprime .

Page 59: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 14

Example 4: using pumping lemma

Example 4

Consider Lprime = {1p|p is a prime number.}.

I For each n, let w = 1p such that p > n + 2

I The first n characters of w are 1n.

I Let x = 1i and y = 1j , where i + j ≤ n and j 6= 0.

w = 1i︸︷︷︸x

1j︸︷︷︸y

1p−j−i︸ ︷︷ ︸z

I So, |xykz | = (p − j) + kj .

I Let k = p − j . Therefore, |xykz | = (p − j)(1 + j).

I Since both (p − k) > 1(why?)and 1 + j > 1(why?), xykz 6∈ Lprime .

Page 60: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 14

Example 4: using pumping lemma

Example 4

Consider Lprime = {1p|p is a prime number.}.

I For each n, let w = 1p such that p > n + 2

I The first n characters of w are 1n.

I Let x = 1i and y = 1j , where i + j ≤ n and j 6= 0.

w = 1i︸︷︷︸x

1j︸︷︷︸y

1p−j−i︸ ︷︷ ︸z

I So, |xykz | = (p − j) + kj .

I Let k = p − j . Therefore, |xykz | = (p − j)(1 + j).

I Since both (p − k) > 1(why?)and 1 + j > 1(why?), xykz 6∈ Lprime .

Page 61: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 14

Example 4: using pumping lemma

Example 4

Consider Lprime = {1p|p is a prime number.}.

I For each n, let w = 1p such that p > n + 2

I The first n characters of w are 1n.

I Let x = 1i and y = 1j , where i + j ≤ n and j 6= 0.

w = 1i︸︷︷︸x

1j︸︷︷︸y

1p−j−i︸ ︷︷ ︸z

I So, |xykz | = (p − j) + kj .

I Let k = p − j . Therefore, |xykz | = (p − j)(1 + j).

I Since both (p − k) > 1(why?)and 1 + j > 1(why?), xykz 6∈ Lprime .

Page 62: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 14

Example 4: using pumping lemma

Example 4

Consider Lprime = {1p|p is a prime number.}.

I For each n, let w = 1p such that p > n + 2

I The first n characters of w are 1n.

I Let x = 1i and y = 1j , where i + j ≤ n and j 6= 0.

w = 1i︸︷︷︸x

1j︸︷︷︸y

1p−j−i︸ ︷︷ ︸z

I So, |xykz | = (p − j) + kj .

I Let k = p − j . Therefore, |xykz | = (p − j)(1 + j).

I Since both (p − k) > 1(why?)and 1 + j > 1(why?), xykz 6∈ Lprime .

Page 63: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 14

Example 4: using pumping lemma

Example 4

Consider Lprime = {1p|p is a prime number.}.

I For each n, let w = 1p such that p > n + 2

I The first n characters of w are 1n.

I Let x = 1i and y = 1j , where i + j ≤ n and j 6= 0.

w = 1i︸︷︷︸x

1j︸︷︷︸y

1p−j−i︸ ︷︷ ︸z

I So, |xykz | = (p − j) + kj .

I Let k = p − j . Therefore, |xykz | = (p − j)(1 + j).

I Since both (p − k) > 1(why?)and 1 + j > 1(why?), xykz 6∈ Lprime .

Page 64: CS310 : Automata Theory 2020akshayss/courses/cs310-2020/lec12.pdf · CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 3 Pumping lemma Theorem (Pumping lemma) Let

CS310 : Automata Theory 2020 Instructor: S. Akshay IIT Bombay, India 14

Example 4: using pumping lemma

Example 4

Consider Lprime = {1p|p is a prime number.}.

I For each n, let w = 1p such that p > n + 2

I The first n characters of w are 1n.

I Let x = 1i and y = 1j , where i + j ≤ n and j 6= 0.

w = 1i︸︷︷︸x

1j︸︷︷︸y

1p−j−i︸ ︷︷ ︸z

I So, |xykz | = (p − j) + kj .

I Let k = p − j . Therefore, |xykz | = (p − j)(1 + j).

I Since both (p − k) > 1(why?)and 1 + j > 1(why?), xykz 6∈ Lprime .