156
The Limits of Context- Free Languages

The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

The Limits of Context-Free Languages

Page 2: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Announcements

● Problem Set 6 due right now.● Problem Set 7 out, due next Friday, November

18.● Covers context-free languages, CFGs, PDAs, and

the limits of CFLs (from today's lecture)● Ask questions in office hours!● Email questions to [email protected]

● Problem Set 4 graded, will be returned at end of class.

Page 3: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

All Languages

Page 4: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

RegularLanguages

All Languages

Page 5: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

RegularLanguages DCFLs

All Languages

Page 6: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

RegularLanguages CFLsDCFLs

All Languages

Page 7: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

RegularLanguages CFLsDCFLs

All Languages

What sorts of languages are out

here?

Page 8: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

The Pumping Lemma for Regular Languages

● Let L be a regular language, so there is a DFA D for L.

● A sufficiently long string w L must visit some ∈state in D twice.

● This means w went through a loop in the D.● By replicating the characters that went through

the loop in the D, we can “pump” a portion of w to produce new strings in the language.

Page 9: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

The Pumping Lemma Intuition

● The model of computation used has a finite description.

● For sufficiently long strings, the model of computation must repeat some step of the computation to recognize the string.

● Under the right circumstances, we can iterate this repeated step zero or more times to produce more and more strings.

Page 10: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Recall: Parse Trees

R → a | b | c | …

R → “ε”

R → Ø

R → RR

R → R “|” R

R → R*

R → (R)

R

Page 11: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Recall: Parse Trees

R → a | b | c | …

R → “ε”

R → Ø

R → RR

R → R “|” R

R → R*

R → (R)

R

R R

|

Page 12: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Recall: Parse Trees

R → a | b | c | …

R → “ε”

R → Ø

R → RR

R → R “|” R

R → R*

R → (R)

R

R R

|

R R

Page 13: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Recall: Parse Trees

R → a | b | c | …

R → “ε”

R → Ø

R → RR

R → R “|” R

R → R*

R → (R)

R

R R

|

R R

a

Page 14: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Recall: Parse Trees

R → a | b | c | …

R → “ε”

R → Ø

R → RR

R → R “|” R

R → R*

R → (R)

R

R R

|

R R

a a

Page 15: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Recall: Parse Trees

R → a | b | c | …

R → “ε”

R → Ø

R → RR

R → R “|” R

R → R*

R → (R)

R

R R

|

R R

a a

R

*

Page 16: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Recall: Parse Trees

R → a | b | c | …

R → “ε”

R → Ø

R → RR

R → R “|” R

R → R*

R → (R)

R

R R

|

R R

a a

R

*b

Page 17: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Recall: Parse Trees

R → a | b | c | …

R → “ε”

R → Ø

R → RR

R → R “|” R

R → R*

R → (R)

R

R R

|

R R

a a

R

*b

Page 18: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Parse Trees Revisited

S → [P]

P → RR | a

R → (P) | b

Page 19: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Parse Trees Revisited

S → [P]

P → RR | a

R → (P) | b

S

Page 20: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Parse Trees Revisited

S → [P]

P → RR | a

R → (P) | b

( )a b

S

[ ]

Page 21: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Parse Trees Revisited

S → [P]

P → RR | a

R → (P) | b

P

( )a b

S

[ ]

Page 22: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Parse Trees Revisited

S → [P]

P → RR | a

R → (P) | b

P

R R

( )a b

S

[ ]

Page 23: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Parse Trees Revisited

S → [P]

P → RR | a

R → (P) | b

P

R R

( )a b

S

[ ]

Page 24: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Parse Trees Revisited

S → [P]

P → RR | a

R → (P) | b

P

R R

( )

P

a b

S

[ ]

Page 25: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Parse Trees Revisited

S → [P]

P → RR | a

R → (P) | b

P

R R

( )

P

a b

S

[ ]

Page 26: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Parse Trees Revisited

S → [P]

P → RR | a

R → (P) | b

P

R R

( )

P

a b

S

[ ]

Page 27: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Parse Trees Revisited

S → [P]

P → RR | a

R → (P) | b

P

R R

( )

P

a b

S

[ ]

The nonterminal P appears twice.

Page 28: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Parse Trees Revisited

S → [P]

P → RR | a

R → (P) | b

P

R R

( )

P

a b

S

[ ]

Page 29: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Parse Trees Revisited

S → [P]

P → RR | a

R → (P) | b

P

R R

( )

P

a b

S

[ ]

Page 30: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Parse Trees Revisited

S → [P]

P → RR | a

R → (P) | b

P

R R

( )

P

a b

S

[ ]

Page 31: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Parse Trees Revisited

S → [P]

P → RR | a

R → (P) | b

P

R R

( )

P

a b

S

[ ]

Page 32: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Parse Trees Revisited

S → [P]

P → RR | a

R → (P) | b

P

R R

( )

P

a b

S

[ ]

Page 33: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Parse Trees Revisited

S → [P]

P → RR | a

R → (P) | b

P

R R

( )

P

a b

S

[ ]

P

R R

( ) b

Page 34: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Parse Trees Revisited

S → [P]

P → RR | a

R → (P) | b

P

R R

( )

P

a b

S

[ ]

Page 35: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Parse Trees Revisited

S → [P]

P → RR | a

R → (P) | b

P

R R

( )

P

a b

S

[ ]

Page 36: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Parse Trees Revisited

S → [P]

P → RR | a

R → (P) | b

P

R R

( )

P

a b

S

[ ]

Page 37: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Parse Trees Revisited

S → [P]

P → RR | a

R → (P) | b

P

R R

( )

P

a b

S

[ ]

Page 38: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Parse Trees Revisited

S → [P]

P → RR | a

R → (P) | b

P

R R

( )

P

a b

S

[ ]

Page 39: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Parse Trees Revisited

S → [P]

P → RR | a

R → (P) | b

P

a

S

[ ]

Page 40: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Parse Trees Revisited

S → [P]

P → RR | a

R → (P) | b

P

a

S

[ ]

Page 41: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

S

R

u v y zx

R

Page 42: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

S

R

u v y zx

R

uvxyz L∈

Page 43: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

S

R

u v y zx

R

uvxyz L∈

Page 44: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

S

R

u v y z

x

R

uvxyz L∈

Page 45: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

S

R

u v y z

xv y

R

R

uv2xy2z L∈

Page 46: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

S

R

u v y z

x

v yR

R

uv2xy2z L∈

Page 47: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

S

R

u v y z

x

R

R

v

v

y

y

R

uv3xy3z L∈

Page 48: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

S

R

u v y zx

R

uvxyz L∈

Page 49: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

S

u zx

R

uvxyz L∈

Page 50: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

S

u z

x

R

uv0xy0z L∈

Page 51: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

For any context-free language L,

There exists a positive natural number n such that

For any w L with |w| ≥ n,∈

There exists strings u, v, x, y, z such that

For any natural number i,

w = uvxyz,

|vxy| ≤ n,

|vy| > 0

uvixyiz L∈

The Pumping Lemma for CFLS

Page 52: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

For any context-free language L,

There exists a positive natural number n such that

For any w L with |w| ≥ n,∈

There exists strings u, v, x, y, z such that

For any natural number i,

w = uvxyz,

|vxy| ≤ n,

|vy| > 0

uvixyiz L∈

w can be broken into five pieces,

The Pumping Lemma for CFLS

Page 53: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

For any context-free language L,

There exists a positive natural number n such that

For any w L with |w| ≥ n,∈

There exists strings u, v, x, y, z such that

For any natural number i,

w = uvxyz,

|vxy| ≤ n,

|vy| > 0

uvixyiz L∈

w can be broken into five pieces,

where the middle three pieces aren't too long,

The Pumping Lemma for CFLS

Page 54: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

For any context-free language L,

There exists a positive natural number n such that

For any w L with |w| ≥ n,∈

There exists strings u, v, x, y, z such that

For any natural number i,

w = uvxyz,

|vxy| ≤ n,

|vy| > 0

uvixyiz L∈

where the 2nd and 4th pieces aren't both empty, and

w can be broken into five pieces,

where the middle three pieces aren't too long,

The Pumping Lemma for CFLS

Page 55: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

For any context-free language L,

There exists a positive natural number n such that

For any w L with |w| ≥ n,∈

There exists strings u, v, x, y, z such that

For any natural number i,

w = uvxyz,

|vxy| ≤ n,

|vy| > 0

uvixyiz L∈ where the 2nd and 4th pieces can be replicated 0 or more times

where the 2nd and 4th pieces aren't both empty, and

w can be broken into five pieces,

where the middle three pieces aren't too long,

The Pumping Lemma for CFLS

Page 56: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

For any context-free language L,

There exists a positive natural number n such that

For any w L with |w| ≥ n,∈

There exists strings u, v, x, y, z such that

For any natural number i,

w = uvxyz,

|vxy| ≤ n,

|vy| > 0

uvixyiz L∈ where the 2nd and 4th pieces can be replicated 0 or more times

where the 2nd and 4th pieces aren't both empty, and

w can be broken into five pieces,

where the middle three pieces aren't too long,

The Pumping Lemma for CFLS

Note that we pump both v and y at the same time, not just one or the other.

Page 57: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

For any context-free language L,

There exists a positive natural number n such that

For any w L with |w| ≥ n,∈

There exists strings u, v, x, y, z such that

For any natural number i,

w = uvxyz,

|vxy| ≤ n,

|vy| > 0

uvixyiz L∈ where the 2nd and 4th pieces can be replicated 0 or more times

where the 2nd and 4th pieces aren't both empty, and

w can be broken into five pieces,

where the middle three pieces aren't too long,

The Pumping Lemma for CFLS

The two strings to pump, collectively, cannot be too long.

Page 58: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

For any context-free language L,

There exists a positive natural number n such that

For any w L with |w| ≥ n,∈

There exists strings u, v, x, y, z such that

For any natural number i,

w = uvxyz,

|vxy| ≤ n,

|vy| > 0

uvixyiz L∈ where the 2nd and 4th pieces can be replicated 0 or more times

where the 2nd and 4th pieces aren't both empty, and

w can be broken into five pieces,

where the middle three pieces aren't too long,

The Pumping Lemma for CFLS

The two strings to pump, collectively, cannot be too long.

They also must be close to one

another.

Page 59: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

For any context-free language L,

There exists a positive natural number n such that

For any w L with |w| ≥ n,∈

There exists strings u, v, x, y, z such that

For any natural number i,

w = uvxyz,

|vxy| ≤ n,

|vy| > 0

uvixyiz L∈ where the 2nd and 4th pieces can be replicated 0 or more times

where the 2nd and 4th pieces aren't both empty, and

w can be broken into five pieces,

where the middle three pieces aren't too long,

The Pumping Lemma for CFLSThe pumping length is not simple; see Sipser for details.

Page 60: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

The Pumping Lemma Game

ADVERSARY YOU

Page 61: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

The Pumping Lemma Game

ADVERSARY YOU

Maliciously choose pumping length n.

Page 62: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

The Pumping Lemma Game

ADVERSARY YOU

Maliciously choose pumping length n.

Cleverly choose a string w L, |w| ≥ n∈

Page 63: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

The Pumping Lemma Game

ADVERSARY YOU

Maliciously choose pumping length n.

Maliciously split w = uvxyz, with |vy| > 0

and |vxy| ≤ n

Cleverly choose a string w L, |w| ≥ n∈

Page 64: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

The Pumping Lemma Game

ADVERSARY YOU

Maliciously choose pumping length n.

Maliciously split w = uvxyz, with |vy| > 0

and |vxy| ≤ n

Cleverly choose a string w L, |w| ≥ n∈

Cleverly choose i such that uvixyiz L∉

Page 65: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

The Pumping Lemma Game

ADVERSARY YOU

Maliciously choose pumping length n.

Maliciously split w = uvxyz, with |vy| > 0

and |vxy| ≤ n

Cleverly choose a string w L, |w| ≥ n∈

Cleverly choose i such that uvixyiz L∉

Grrr! Aaaargh!

Page 66: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

The Pumping Lemma Game

ADVERSARY YOU

Maliciously choose pumping length n.

Maliciously split w = uvxyz, with |vy| > 0

and |vxy| ≤ n

Cleverly choose a string w L, |w| ≥ n∈

Cleverly choose i such that uvixyiz L∉

Grrr! Aaaargh!

L = { 0n1n2n | n }∈ℕ

Page 67: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

The Pumping Lemma Game

ADVERSARY YOU

Maliciously choose pumping length n.

Maliciously split w = uvxyz, with |vy| > 0

and |vxy| ≤ n

Cleverly choose a string w L, |w| ≥ n∈

Cleverly choose i such that uvixyiz L∉

Grrr! Aaaargh!

000111000

L = { 0n1n2n | n }∈ℕ

Page 68: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Theorem: L = {0n1n2n | n } is not context-free.∈ℕProof: By contradiction; assume that L is context-free. Let n be the length guaranteed by the pumping lemma. Consider the string w = 0n1n2n. Then w L ∈and |w| = 3n ≥ n. Then we can write w = uvxyz such that |vxy| ≤ n, |vy| > 0, and for any natural number i, uvixyiz L. We consider two cases for vxy:∈

Case 1: vxy is completely contained in 0n, 1n, or 2n. In that case, the string uv2xy2z L, because this string has more copies of 0 or 1 or 2 than the other ∉two symbols. This contradicts the pumping lemma.

Case 2: vxy either consists of 0s and 1s or of 1s and 2s (it cannot consist of all three symbols, because |vxy| ≤ n). Then if vxy has no 2s in it, uv2xy2z L ∉because it contains more 0s or 1s than 2s, and similarly if vxy has no 0s in it uv2xy2z L because it contains more 1s or 2s than 0s. This contradicts the ∉pumping lemma.

In either case we reach a contradiction, so our L is not context-free. ■

For any context-free language L, There exists a positive natural number n such that For any w L with |w| ≥ n,∈ There exists strings u, v, x, y, z such that For any natural number i, w = uvxyz, |vxy| ≤ n, |vy| > 0 uvixyiz L∈

Page 69: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Theorem: L = {0n1n2n | n } is not context-free.∈ℕProof: By contradiction; assume that L is context-free. Let n be the length guaranteed by the pumping lemma. Consider the string w = 0n1n2n. Then w L ∈and |w| = 3n ≥ n. Then we can write w = uvxyz such that |vxy| ≤ n, |vy| > 0, and for any natural number i, uvixyiz L. We consider two cases for vxy:∈

Case 1: vxy is completely contained in 0n, 1n, or 2n. In that case, the string uv2xy2z L, because this string has more copies of 0 or 1 or 2 than the other ∉two symbols. This contradicts the pumping lemma.

Case 2: vxy either consists of 0s and 1s or of 1s and 2s (it cannot consist of all three symbols, because |vxy| ≤ n). Then if vxy has no 2s in it, uv2xy2z L ∉because it contains more 0s or 1s than 2s, and similarly if vxy has no 0s in it uv2xy2z L because it contains more 1s or 2s than 0s. This contradicts the ∉pumping lemma.

In either case we reach a contradiction, so our L is not context-free. ■

For any context-free language L, There exists a positive natural number n such that For any w L with |w| ≥ n,∈ There exists strings u, v, x, y, z such that For any natural number i, w = uvxyz, |vxy| ≤ n, |vy| > 0 uvixyiz L∈

Page 70: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Theorem: L = {0n1n2n | n } is not context-free.∈ℕProof: By contradiction; assume that L is context-free. Let n be the length guaranteed by the pumping lemma. Consider the string w = 0n1n2n. Then w L ∈and |w| = 3n ≥ n. Then we can write w = uvxyz such that |vxy| ≤ n, |vy| > 0, and for any natural number i, uvixyiz L. We consider two cases for vxy:∈

Case 1: vxy is completely contained in 0n, 1n, or 2n. In that case, the string uv2xy2z L, because this string has more copies of 0 or 1 or 2 than the other ∉two symbols. This contradicts the pumping lemma.

Case 2: vxy either consists of 0s and 1s or of 1s and 2s (it cannot consist of all three symbols, because |vxy| ≤ n). Then if vxy has no 2s in it, uv2xy2z L ∉because it contains more 0s or 1s than 2s, and similarly if vxy has no 0s in it uv2xy2z L because it contains more 1s or 2s than 0s. This contradicts the ∉pumping lemma.

In either case we reach a contradiction, so our L is not context-free. ■

For any context-free language L, There exists a positive natural number n such that For any w L with |w| ≥ n,∈ There exists strings u, v, x, y, z such that For any natural number i, w = uvxyz, |vxy| ≤ n, |vy| > 0 uvixyiz L∈

Page 71: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Theorem: L = {0n1n2n | n } is not context-free.∈ℕProof: By contradiction; assume that L is context-free. Let n be the length guaranteed by the pumping lemma. Consider the string w = 0n1n2n. Then w L ∈and |w| = 3n ≥ n. Then we can write w = uvxyz such that |vxy| ≤ n, |vy| > 0, and for any natural number i, uvixyiz L. We consider two cases for vxy:∈

Case 1: vxy is completely contained in 0n, 1n, or 2n. In that case, the string uv2xy2z L, because this string has more copies of 0 or 1 or 2 than the other ∉two symbols. This contradicts the pumping lemma.

Case 2: vxy either consists of 0s and 1s or of 1s and 2s (it cannot consist of all three symbols, because |vxy| ≤ n). Then if vxy has no 2s in it, uv2xy2z L ∉because it contains more 0s or 1s than 2s, and similarly if vxy has no 0s in it uv2xy2z L because it contains more 1s or 2s than 0s. This contradicts the ∉pumping lemma.

In either case we reach a contradiction, so our L is not context-free. ■

For any context-free language L, There exists a positive natural number n such that For any w L with |w| ≥ n,∈ There exists strings u, v, x, y, z such that For any natural number i, w = uvxyz, |vxy| ≤ n, |vy| > 0 uvixyiz L∈

Page 72: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Theorem: L = {0n1n2n | n } is not context-free.∈ℕProof: By contradiction; assume that L is context-free. Let n be the length guaranteed by the pumping lemma. Consider the string w = 0n1n2n. Then w L ∈and |w| = 3n ≥ n. Then we can write w = uvxyz such that |vxy| ≤ n, |vy| > 0, and for any natural number i, uvixyiz L. We consider two cases for vxy:∈

Case 1: vxy is completely contained in 0n, 1n, or 2n. In that case, the string uv2xy2z L, because this string has more copies of 0 or 1 or 2 than the other ∉two symbols. This contradicts the pumping lemma.

Case 2: vxy either consists of 0s and 1s or of 1s and 2s (it cannot consist of all three symbols, because |vxy| ≤ n). Then if vxy has no 2s in it, uv2xy2z L ∉because it contains more 0s or 1s than 2s, and similarly if vxy has no 0s in it uv2xy2z L because it contains more 1s or 2s than 0s. This contradicts the ∉pumping lemma.

In either case we reach a contradiction, so our L is not context-free. ■

For any context-free language L, There exists a positive natural number n such that For any w L with |w| ≥ n,∈ There exists strings u, v, x, y, z such that For any natural number i, w = uvxyz, |vxy| ≤ n, |vy| > 0 uvixyiz L∈

Page 73: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Theorem: L = {0n1n2n | n } is not context-free.∈ℕProof: By contradiction; assume that L is context-free. Let n be the length guaranteed by the pumping lemma. Consider the string w = 0n1n2n. Then w L ∈and |w| = 3n ≥ n. Then we can write w = uvxyz such that |vxy| ≤ n, |vy| > 0, and for any natural number i, uvixyiz L.∈ We consider two cases for vxy:

Case 1: vxy is completely contained in 0n, 1n, or 2n. In that case, the string uv2xy2z L, because this string has more copies of 0 or 1 or 2 than the other ∉two symbols. This contradicts the pumping lemma.

Case 2: vxy either consists of 0s and 1s or of 1s and 2s (it cannot consist of all three symbols, because |vxy| ≤ n). Then if vxy has no 2s in it, uv2xy2z L ∉because it contains more 0s or 1s than 2s, and similarly if vxy has no 0s in it uv2xy2z L because it contains more 1s or 2s than 0s. This contradicts the ∉pumping lemma.

In either case we reach a contradiction, so our L is not context-free. ■

For any context-free language L, There exists a positive natural number n such that For any w L with |w| ≥ n,∈ There exists strings u, v, x, y, z such that For any natural number i, w = uvxyz, |vxy| ≤ n, |vy| > 0 uvixyiz L∈

Page 74: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Theorem: L = {0n1n2n | n } is not context-free.∈ℕProof: By contradiction; assume that L is context-free. Let n be the length guaranteed by the pumping lemma. Consider the string w = 0n1n2n. Then w L ∈and |w| = 3n ≥ n. Then we can write w = uvxyz such that |vxy| ≤ n, |vy| > 0, and for any natural number i, uvixyiz L. We consider two cases for vxy:∈

Case 1: vxy is completely contained in 0n, 1n, or 2n. In that case, the string uv2xy2z L, because this string has more copies of 0 or 1 or 2 than the other ∉two symbols. This contradicts the pumping lemma.

Case 2: vxy either consists of 0s and 1s or of 1s and 2s (it cannot consist of all three symbols, because |vxy| ≤ n). Then if vxy has no 2s in it, uv2xy2z L ∉because it contains more 0s or 1s than 2s, and similarly if vxy has no 0s in it uv2xy2z L because it contains more 1s or 2s than 0s. This contradicts the ∉pumping lemma.

In either case we reach a contradiction, so our L is not context-free. ■

For any context-free language L, There exists a positive natural number n such that For any w L with |w| ≥ n,∈ There exists strings u, v, x, y, z such that For any natural number i, w = uvxyz, |vxy| ≤ n, |vy| > 0 uvixyiz L∈

Page 75: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Theorem: L = {0n1n2n | n } is not context-free.∈ℕProof: By contradiction; assume that L is context-free. Let n be the length guaranteed by the pumping lemma. Consider the string w = 0n1n2n. Then w L ∈and |w| = 3n ≥ n. Then we can write w = uvxyz such that |vxy| ≤ n, |vy| > 0, and for any natural number i, uvixyiz L. We consider two cases for vxy:∈

Case 1: vxy is completely contained in 0n, 1n, or 2n. In that case, the string uv2xy2z L, because this string has more copies of 0 or 1 or 2 than the other ∉two symbols. This contradicts the pumping lemma.

Case 2: vxy either consists of 0s and 1s or of 1s and 2s (it cannot consist of all three symbols, because |vxy| ≤ n). Then if vxy has no 2s in it, uv2xy2z L ∉because it contains more 0s or 1s than 2s, and similarly if vxy has no 0s in it uv2xy2z L because it contains more 1s or 2s than 0s. This contradicts the ∉pumping lemma.

In either case we reach a contradiction, so our L is not context-free. ■

For any context-free language L, There exists a positive natural number n such that For any w L with |w| ≥ n,∈ There exists strings u, v, x, y, z such that For any natural number i, w = uvxyz, |vxy| ≤ n, |vy| > 0 uvixyiz L∈

Proofs using the pumping lemma for CFLs tend to be much harder than those for regular languages because there is no restriction on where in the

string the portion that can be pumped can be. The string to pump must be very carefully constructed.

Page 76: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Theorem: L = {0n1n2n | n } is not context-free.∈ℕProof: By contradiction; assume that L is context-free. Let n be the length guaranteed by the pumping lemma. Consider the string w = 0n1n2n. Then w L ∈and |w| = 3n ≥ n. Then we can write w = uvxyz such that |vxy| ≤ n, |vy| > 0, and for any natural number i, uvixyiz L. We consider two cases for vxy:∈

Case 1: vxy is completely contained in 0n, 1n, or 2n. In that case, the string uv2xy2z L, because this string has more copies of 0 or 1 or 2 than the other ∉two symbols. This contradicts the pumping lemma.

Case 2: vxy either consists of 0s and 1s or of 1s and 2s (it cannot consist of all three symbols, because |vxy| ≤ n). Then if vxy has no 2s in it, uv2xy2z L ∉because it contains more 0s or 1s than 2s, and similarly if vxy has no 0s in it uv2xy2z L because it contains more 1s or 2s than 0s. This contradicts the ∉pumping lemma.

In either case we reach a contradiction, so our L is not context-free. ■

For any context-free language L, There exists a positive natural number n such that For any w L with |w| ≥ n,∈ There exists strings u, v, x, y, z such that For any natural number i, w = uvxyz, |vxy| ≤ n, |vy| > 0 uvixyiz L∈

Page 77: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Theorem: L = {0n1n2n | n } is not context-free.∈ℕProof: By contradiction; assume that L is context-free. Let n be the length guaranteed by the pumping lemma. Consider the string w = 0n1n2n. Then w L ∈and |w| = 3n ≥ n. Then we can write w = uvxyz such that |vxy| ≤ n, |vy| > 0, and for any natural number i, uvixyiz L. We consider two cases for vxy:∈

Case 1: vxy is completely contained in 0n, 1n, or 2n. In that case, the string uv2xy2z L, because this string has more copies of 0 or 1 or 2 than the other ∉two symbols. This contradicts the pumping lemma.

Case 2: vxy either consists of 0s and 1s or of 1s and 2s (it cannot consist of all three symbols, because |vxy| ≤ n). Then if vxy has no 2s in it, uv2xy2z L ∉because it contains more 0s or 1s than 2s, and similarly if vxy has no 0s in it uv2xy2z L because it contains more 1s or 2s than 0s. This contradicts the ∉pumping lemma.

In either case we reach a contradiction, so our L is not context-free. ■

For any context-free language L, There exists a positive natural number n such that For any w L with |w| ≥ n,∈ There exists strings u, v, x, y, z such that For any natural number i, w = uvxyz, |vxy| ≤ n, |vy| > 0 uvixyiz L∈

Page 78: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Theorem: L = {0n1n2n | n } is not context-free.∈ℕProof: By contradiction; assume that L is context-free. Let n be the length guaranteed by the pumping lemma. Consider the string w = 0n1n2n. Then w L ∈and |w| = 3n ≥ n. Then we can write w = uvxyz such that |vxy| ≤ n, |vy| > 0, and for any natural number i, uvixyiz L. We consider two cases for vxy:∈

Case 1: vxy is completely contained in 0n, 1n, or 2n. In that case, the string uv2xy2z L, because this string has more copies of 0 or 1 or 2 than the other ∉two symbols. This contradicts the pumping lemma.

Case 2: vxy either consists of 0s and 1s or of 1s and 2s (it cannot consist of all three symbols, because |vxy| ≤ n). Then if vxy has no 2s in it, uv2xy2z L ∉because it contains more 0s or 1s than 2s, and similarly if vxy has no 0s in it uv2xy2z L because it contains more 1s or 2s than 0s. This contradicts the ∉pumping lemma.

In either case we reach a contradiction, so our L is not context-free. ■

For any context-free language L, There exists a positive natural number n such that For any w L with |w| ≥ n,∈ There exists strings u, v, x, y, z such that For any natural number i, w = uvxyz, |vxy| ≤ n, |vy| > 0 uvixyiz L∈

Page 79: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Theorem: L = {0n1n2n | n } is not context-free.∈ℕProof: By contradiction; assume that L is context-free. Let n be the length guaranteed by the pumping lemma. Consider the string w = 0n1n2n. Then w L ∈and |w| = 3n ≥ n. Then we can write w = uvxyz such that |vxy| ≤ n, |vy| > 0, and for any natural number i, uvixyiz L. We consider two cases for vxy:∈

Case 1: vxy is completely contained in 0n, 1n, or 2n. In that case, the string uv2xy2z L, because this string has more copies of 0 or 1 or 2 than the other ∉two symbols. This contradicts the pumping lemma.

Case 2: vxy either consists of 0s and 1s or of 1s and 2s (it cannot consist of all three symbols, because |vxy| ≤ n). Then if vxy has no 2s in it, uv2xy2z L ∉because it contains more 0s or 1s than 2s, and similarly if vxy has no 0s in it uv2xy2z L because it contains more 1s or 2s than 0s. This contradicts the ∉pumping lemma.

In either case we reach a contradiction, so our L is not context-free. ■

For any context-free language L, There exists a positive natural number n such that For any w L with |w| ≥ n,∈ There exists strings u, v, x, y, z such that For any natural number i, w = uvxyz, |vxy| ≤ n, |vy| > 0 uvixyiz L∈

Page 80: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Theorem: L = {0n1n2n | n } is not context-free.∈ℕProof: By contradiction; assume that L is context-free. Let n be the length guaranteed by the pumping lemma. Consider the string w = 0n1n2n. Then w L ∈and |w| = 3n ≥ n. Then we can write w = uvxyz such that |vxy| ≤ n, |vy| > 0, and for any natural number i, uvixyiz L. We consider two cases for vxy:∈

Case 1: vxy is completely contained in 0n, 1n, or 2n. In that case, the string uv2xy2z L, because this string has more copies of 0 or 1 or 2 than the other ∉two symbols. This contradicts the pumping lemma.

Case 2: vxy either consists of 0s and 1s or of 1s and 2s (it cannot consist of all three symbols, because |vxy| ≤ n). Then if vxy has no 2s in it, uv2xy2z L ∉because it contains more 0s or 1s than 2s, and similarly if vxy has no 0s in it uv2xy2z L because it contains more 1s or 2s than 0s. This contradicts the ∉pumping lemma.

In either case we reach a contradiction, so our L is not context-free. ■

For any context-free language L, There exists a positive natural number n such that For any w L with |w| ≥ n,∈ There exists strings u, v, x, y, z such that For any natural number i, w = uvxyz, |vxy| ≤ n, |vy| > 0 uvixyiz L∈

Note how we chose w so that vxy can't span all three groups of symbols. This makes it impossible to pump

all three groups at once.

Page 81: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Theorem: L = {0n1n2n | n } is not context-free.∈ℕProof: By contradiction; assume that L is context-free. Let n be the length guaranteed by the pumping lemma. Consider the string w = 0n1n2n. Then w L ∈and |w| = 3n ≥ n. Then we can write w = uvxyz such that |vxy| ≤ n, |vy| > 0, and for any natural number i, uvixyiz L. We consider two cases for vxy:∈

Case 1: vxy is completely contained in 0n, 1n, or 2n. In that case, the string uv2xy2z L, because this string has more copies of 0 or 1 or 2 than the other ∉two symbols. This contradicts the pumping lemma.

Case 2: vxy either consists of 0s and 1s or of 1s and 2s (it cannot consist of all three symbols, because |vxy| ≤ n). Then if vxy has no 2s in it, uv2xy2z L ∉because it contains more 0s or 1s than 2s, and similarly if vxy has no 0s in it uv2xy2z L because it contains more 1s or 2s than 0s. ∉ This contradicts the pumping lemma.

In either case we reach a contradiction, so our L is not context-free. ■

For any context-free language L, There exists a positive natural number n such that For any w L with |w| ≥ n,∈ There exists strings u, v, x, y, z such that For any natural number i, w = uvxyz, |vxy| ≤ n, |vy| > 0 uvixyiz L∈

Page 82: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Theorem: L = {0n1n2n | n } is not context-free.∈ℕProof: By contradiction; assume that L is context-free. Let n be the length guaranteed by the pumping lemma. Consider the string w = 0n1n2n. Then w L ∈and |w| = 3n ≥ n. Then we can write w = uvxyz such that |vxy| ≤ n, |vy| > 0, and for any natural number i, uvixyiz L. We consider two cases for vxy:∈

Case 1: vxy is completely contained in 0n, 1n, or 2n. In that case, the string uv2xy2z L, because this string has more copies of 0 or 1 or 2 than the other ∉two symbols. This contradicts the pumping lemma.

Case 2: vxy either consists of 0s and 1s or of 1s and 2s (it cannot consist of all three symbols, because |vxy| ≤ n). Then if vxy has no 2s in it, uv2xy2z L ∉because it contains more 0s or 1s than 2s, and similarly if vxy has no 0s in it uv2xy2z L because it contains more 1s or 2s than 0s. This contradicts the ∉pumping lemma.

In either case we reach a contradiction, so our L is not context-free. ■

For any context-free language L, There exists a positive natural number n such that For any w L with |w| ≥ n,∈ There exists strings u, v, x, y, z such that For any natural number i, w = uvxyz, |vxy| ≤ n, |vy| > 0 uvixyiz L∈

Page 83: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Theorem: L = {0n1n2n | n } is not context-free.∈ℕProof: By contradiction; assume that L is context-free. Let n be the length guaranteed by the pumping lemma. Consider the string w = 0n1n2n. Then w L ∈and |w| = 3n ≥ n. Then we can write w = uvxyz such that |vxy| ≤ n, |vy| > 0, and for any natural number i, uvixyiz L. We consider two cases for vxy:∈

Case 1: vxy is completely contained in 0n, 1n, or 2n. In that case, the string uv2xy2z L, because this string has more copies of 0 or 1 or 2 than the other ∉two symbols. This contradicts the pumping lemma.

Case 2: vxy either consists of 0s and 1s or of 1s and 2s (it cannot consist of all three symbols, because |vxy| ≤ n). Then if vxy has no 2s in it, uv2xy2z L ∉because it contains more 0s or 1s than 2s, and similarly if vxy has no 0s in it uv2xy2z L because it contains more 1s or 2s than 0s. This contradicts the ∉pumping lemma.

In either case we reach a contradiction, so our L is not context-free. ■

For any context-free language L, There exists a positive natural number n such that For any w L with |w| ≥ n,∈ There exists strings u, v, x, y, z such that For any natural number i, w = uvxyz, |vxy| ≤ n, |vy| > 0 uvixyiz L∈

Page 84: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Theorem: L = {0n1n2n | n } is not context-free.∈ℕProof: By contradiction; assume that L is context-free. Let n be the length guaranteed by the pumping lemma. Consider the string w = 0n1n2n. Then w L ∈and |w| = 3n ≥ n. Then we can write w = uvxyz such that |vxy| ≤ n, |vy| > 0, and for any natural number i, uvixyiz L. We consider two cases for vxy:∈

Case 1: vxy is completely contained in 0n, 1n, or 2n. In that case, the string uv2xy2z L, because this string has more copies of 0 or 1 or 2 than the other ∉two symbols. This contradicts the pumping lemma.

Case 2: vxy either consists of 0s and 1s or of 1s and 2s (it cannot consist of all three symbols, because |vxy| ≤ n). Then if vxy has no 2s in it, uv2xy2z L ∉because it contains more 0s or 1s than 2s, and similarly if vxy has no 0s in it uv2xy2z L because it contains more 1s or 2s than 0s. This contradicts the ∉pumping lemma.

In either case we reach a contradiction, so our L is not context-free. ■

For any context-free language L, There exists a positive natural number n such that For any w L with |w| ≥ n,∈ There exists strings u, v, x, y, z such that For any natural number i, w = uvxyz, |vxy| ≤ n, |vy| > 0 uvixyiz L∈

Page 85: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Using the Pumping Lemma

● Keep the following in mind when using the context-free pumping lemma when w = uvxyz:● Both v and y must be pumped at the same time.● v and y need not be contiguous in the string.● One of v and y may be empty.● vxy may be anywhere in the string.

● I strongly suggest reading through Sipser to get a better sense for how these proofs work.

Page 86: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

(Non) Closure Properties of CFLs

Page 87: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

(Non) Closure Properties of CFLs

● Now that we have a single non-context-free language, we can prove that CFLs are not closed under certain operations.

● Let L1 = { 0n1n2m | n, m }∈ℕ

● Let L2 = {0m1n2n | n, m }∈ℕ

● Both of these languages are context-free.● Can either find an explicit CFG, or note that these languages are

the concatenation of two CFLs.

● But L1 ∩ L

2 = { 0n1n2n | n }, which is not a CFL.∈ℕ

● Context-free languages are not closed under intersection.

Page 88: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

(Non) Closure under Complement

● Recall that if L is regular, L is regular as well.● However, if L is context-free, L may not be a

context-free language.● Intuition: Using union and complement, we can

construct the intersection.

Page 89: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

(Non) Closure under Complement

● Recall that if L is regular, L is regular as well.● However, if L is context-free, L may not be a

context-free language.● Intuition: Using union and complement, we can

construct the intersection.

L1

L2

Page 90: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

(Non) Closure under Complement

L1

L2

● Recall that if L is regular, L is regular as well.● However, if L is context-free, L may not be a

context-free language.● Intuition: Using union and complement, we can

construct the intersection.

Page 91: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

(Non) Closure under Complement

● Recall that if L is regular, L is regular as well.● However, if L is context-free, L may not be a

context-free language.● Intuition: Using union and complement, we can

construct the intersection.

L1 ∪ L

2

Page 92: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

(Non) Closure under Complement

● Recall that if L is regular, L is regular as well.● However, if L is context-free, L may not be a

context-free language.● Intuition: Using union and complement, we can

construct the intersection.

L1 ∪ L

2

Page 93: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

(Non) Closure under Subtraction

● Recall that if L1 and L

2 are regular, L

1 – L

2 is

regular as well.

● However, if L1 and L

2 are context-free, L

1 – L

2

may not be context-free.● Intuition: We can construct the complement

from the difference.● Σ* is context-free because it is regular.● But Σ* - L = L, which may not be context-free.

Page 94: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Summary of CFLs

● CFLs are strictly more powerful than the regular languages.

● CFLs can be described by CFGs (generation) or PDAs (recognition).

● CFGs encompass two classes of languages – deterministic and nondeterministic CFLs.

● Context-free languages have a pumping lemma just as regular languages do.

Page 95: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Beyond CFLs

Page 96: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Computability Theory

● Finite automata represent computers with bounded memory.● They accept precisely the regular languages.

● Pushdown automata represent computers with a weak infinite memory.● They accept precisely the context-free languages.

● Regular and context-free languages are comparatively weak.

Page 97: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

RegularLanguages CFLsDCFLs

All Languages

Page 98: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

RegularLanguages CFLsDCFLs

All Languages

Computable Languages

Page 99: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

All Languages

That same drawing, to scale.

Page 100: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Defining Computability

● In order to talk about what languages we could ever hope to recognize with a computer, we need to formalize our model of computation with an automaton.

● The standard automaton for this job is the Turing machine, named after Alan Turing, the “Father of Computer Science.”

Page 101: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

A Better Memory Device

● The pushdown automaton used a (potentially infinite) stack as its memory device.

● This severely limits how the memory can be used:● Accessing old data only possible after discarding

old data.● Can't keep track of multiple unbounded quantities.

Page 102: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

A Better Memory Device

● A Turing machine is a finite automaton equipped with an infinite tape as its memory.

● The tape begins with the input to the machine written on it, followed by infinitely many blank cells.

● The machine has a tape head that can read and write a single memory cell at a time.

0 0 1

Page 103: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

A Better Memory Device

● A Turing machine is a finite automaton equipped with an infinite tape as its memory.

● The tape begins with the input to the machine written on it, followed by infinitely many blank cells.

● The machine has a tape head that can read and write a single memory cell at a time.

0 0 1

Page 104: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

A Better Memory Device

● A Turing machine is a finite automaton equipped with an infinite tape as its memory.

● The tape begins with the input to the machine written on it, followed by infinitely many blank cells.

● The machine has a tape head that can read and write a single memory cell at a time.

A 0 1

Page 105: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

A Better Memory Device

● A Turing machine is a finite automaton equipped with an infinite tape as its memory.

● The tape begins with the input to the machine written on it, followed by infinitely many blank cells.

● The machine has a tape head that can read and write a single memory cell at a time.

A A 1

Page 106: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

A Better Memory Device

● A Turing machine is a finite automaton equipped with an infinite tape as its memory.

● The tape begins with the input to the machine written on it, followed by infinitely many blank cells.

● The machine has a tape head that can read and write a single memory cell at a time.

A A B

Page 107: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

A Better Memory Device

● A Turing machine is a finite automaton equipped with an infinite tape as its memory.

● The tape begins with the input to the machine written on it, followed by infinitely many blank cells.

● The machine has a tape head that can read and write a single memory cell at a time.

A A B X

Page 108: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

A Better Memory Device

● A Turing machine is a finite automaton equipped with an infinite tape as its memory.

● The tape begins with the input to the machine written on it, followed by infinitely many blank cells.

● The machine has a tape head that can read and write a single memory cell at a time.

A A X X

Page 109: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

A Better Memory Device

● A Turing machine is a finite automaton equipped with an infinite tape as its memory.

● The tape begins with the input to the machine written on it, followed by infinitely many blank cells.

● The machine has a tape head that can read and write a single memory cell at a time.

A A X X

Page 110: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

A Better Memory Device

● A Turing machine is a finite automaton equipped with an infinite tape as its memory.

● The tape begins with the input to the machine written on it, followed by infinitely many blank cells.

● The machine has a tape head that can read and write a single memory cell at a time.

A A X X A

Page 111: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

A Better Memory Device

● A Turing machine is a finite automaton equipped with an infinite tape as its memory.

● The tape begins with the input to the machine written on it, followed by infinitely many blank cells.

● The machine has a tape head that can read and write a single memory cell at a time.

A A X X A A

Page 112: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

A Better Memory Device

● A Turing machine is a finite automaton equipped with an infinite tape as its memory.

● The tape begins with the input to the machine written on it, followed by infinitely many blank cells.

● The machine has a tape head that can read and write a single memory cell at a time.

A A X X A A A

Page 113: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

The Turing Machine

● A Turing machine consists of three parts:● A finite-state control used to determine which actions to take,● an infinite tape serving as both input and scratch space, and● a tape head that can read and write the tape and move left or right.

● At each step, the Turing machine● Replaces the contents of the current cell with a new symbol (which

could optionally be the same symbol as before),● Changes state, and● Moves the tape head to the left or to the right.

● The Turing machine accepts if it enters a special accept state. It rejects if it enters a special reject state.

Page 114: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

A Simple Turing Machine

Page 115: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

A Simple Turing Machine

q0

qacc

qrej

q1

start

1 → B, R

1 → B, R

B → B, R

B → B, R

qacc

qrej

Page 116: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

A Simple Turing Machine

q0

qacc

qrej

q1

start

1 → B, R

1 → B, R

B → B, R

B → B, R

qacc

qrej

Each transition of the form

x y, D→

means “upon reading x, replace it with symbol y and move the tape head in direction D (which is either L or R).

The letter B represents a blank.

Page 117: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

A Simple Turing Machine

q0

qacc

qrej

q1

start

1 → B, R

1 → B, R

B → B, R

B → B, R

qacc

qrej

This special accept state causes the

machine to immediately accept.

Each transition of the form

x y, D→

means “upon reading x, replace it with symbol y and move the tape head in direction D (which is either L or R).

The letter B represents a blank.

Page 118: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

A Simple Turing Machine

q0

qacc

qrej

q1

start

1 → B, R

1 → B, R

B → B, R

B → B, R

qacc

qrej

Each transition of the form

x y, D→

means “upon reading x, replace it with symbol y and move the tape head in direction D (which is either L or R).

The letter B represents a blank.

This special accept state causes the

machine to immediately accept.

This special reject state causes the

machine to immediately reject.

Page 119: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

A Simple Turing Machine

q0

qacc

qrej

q1

start

1 → B, R

1 → B, R

B → B, R

B → B, R

qacc

qrej

Page 120: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

A Simple Turing Machine

q0

qacc

qrej

q1

start

1 → B, R

1 → B, R

B → B, R

B → B, R

qacc

qrej

1 1 1 1

Page 121: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

q0

q0

q1

A Simple Turing Machineq

acc

qrej

q1

start

1 → B, R

1 → B, R

B → B, R

B → B, R

qacc

qrej

1 1 1 1

Page 122: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

q0

q0

q1

A Simple Turing Machineq

acc

qrej

q1

start

1 → B, R

1 → B, R

B → B, R

B → B, R

qacc

qrej

1 1 1 1

Page 123: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

q0

q0

q1

A Simple Turing Machineq

acc

qrej

q1

start

1 → B, R

1 → B, R

B → B, R

B → B, R

qacc

qrej

1 1 1 1

Page 124: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

q0

q0

q1

A Simple Turing Machineq

acc

qrej

q1

start

1 → B, R

1 → B, R

B → B, R

B → B, R

qacc

qrej

1 1 1

Page 125: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

q0

q0

q1

A Simple Turing Machineq

acc

qrej

q1

start

1 → B, R

1 → B, R

B → B, R

B → B, R

qacc

qrej

1 1 1

Page 126: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

q1

q0

q0

q1

A Simple Turing Machineq

acc

qrej

start

1 → B, R

1 → B, R

B → B, R

B → B, R

qacc

qrej

1 1 1

Page 127: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

q1

q0

q0

q1

A Simple Turing Machineq

acc

qrej

start

1 → B, R

1 → B, R

B → B, R

B → B, R

qacc

qrej

1 1 1

Page 128: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

q1

q0

q0

q1

A Simple Turing Machineq

acc

qrej

start

1 → B, R

1 → B, R

B → B, R

B → B, R

qacc

qrej

1 1

Page 129: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

q1

q0

q0

q1

A Simple Turing Machineq

acc

qrej

start

1 → B, R

1 → B, R

B → B, R

B → B, R

qacc

qrej

1 1

Page 130: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

q0

q1

q1

q0

A Simple Turing Machineq

acc

qrej

start

1 → B, R

1 → B, R

B → B, R

B → B, R

qacc

qrej

1 1

Page 131: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

q0

q1

q1

q0

A Simple Turing Machineq

acc

qrej

start

1 → B, R

1 → B, R

B → B, R

B → B, R

qacc

qrej

1 1

Page 132: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

q0

q1

q1

q0

A Simple Turing Machineq

acc

qrej

start

1 → B, R

1 → B, R

B → B, R

B → B, R

qacc

qrej

1

Page 133: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

q0

q1

q1

q0

A Simple Turing Machineq

acc

qrej

start

1 → B, R

1 → B, R

B → B, R

B → B, R

qacc

qrej

1

Page 134: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

q1

q0

q0

q1

A Simple Turing Machineq

acc

qrej

start

1 → B, R

1 → B, R

B → B, R

B → B, R

qacc

qrej

1

Page 135: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

q1

q0

q0

q1

A Simple Turing Machineq

acc

qrej

start

1 → B, R

1 → B, R

B → B, R

B → B, R

qacc

qrej

1

Page 136: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

q1

q0

q0

q1

A Simple Turing Machineq

acc

qrej

start

1 → B, R

1 → B, R

B → B, R

B → B, R

qacc

qrej

Page 137: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

q1

q0

q0

q1

A Simple Turing Machineq

acc

qrej

start

1 → B, R

1 → B, R

B → B, R

B → B, R

qacc

qrej

Page 138: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

q1

q0

q1

q0

A Simple Turing Machineq

acc

qrej

start

1 → B, R

1 → B, R

B → B, R

B → B, R

qacc

qrej

Page 139: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

q1

q0

q1

q0

A Simple Turing Machineq

acc

qrej

start

1 → B, R

1 → B, R

B → B, R

B → B, R

qacc

qrej

Page 140: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

q1

q0

q1

q0

A Simple Turing Machineq

acc

qrej

start

1 → B, R

1 → B, R

B → B, R

B → B, R

qacc

qrej

Page 141: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

q0

q1

q0

q1

A Simple Turing Machineq

acc

qrej

start

1 → B, R

1 → B, R

B → B, R

B → B, R

qacc

qrej

Page 142: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

q0

q1

q0

q1

A Simple Turing Machineq

acc

qrej

start

1 → B, R

1 → B, R

B → B, R

B → B, R

qacc

qrej

Page 143: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

q0

q1

q0

q1

A Simple Turing Machineq

acc

qrej

start

1 → B, R

1 → B, R

B → B, R

B → B, R

qacc

qrej

Page 144: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

q0

q1

A Simple Turing Machine

q0

qacc

qrej

q1

start

1 → B, R

1 → B, R

B → B, R

B → B, R

qacc

qrej

1

Page 145: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

q0

q0

q1

A Simple Turing Machineq

acc

qrej

q1

start

1 → B, R

1 → B, R

B → B, R

B → B, R

qacc

qrej

1

Page 146: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

q0

q0

q1

A Simple Turing Machineq

acc

qrej

q1

start

1 → B, R

1 → B, R

B → B, R

B → B, R

qacc

qrej

1

Page 147: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

q0

q0

q1

A Simple Turing Machineq

acc

qrej

q1

start

1 → B, R

1 → B, R

B → B, R

B → B, R

qacc

qrej

1

Page 148: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

q0

q0

q1

A Simple Turing Machineq

acc

qrej

q1

start

1 → B, R

1 → B, R

B → B, R

B → B, R

qacc

qrej

Page 149: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

q0

q0

q1

A Simple Turing Machineq

acc

qrej

q1

start

1 → B, R

1 → B, R

B → B, R

B → B, R

qacc

qrej

Page 150: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

q0

q1

q0

q1

A Simple Turing Machineq

acc

qrej

start

1 → B, R

1 → B, R

B → B, R

B → B, R

qacc

qrej

Page 151: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

q0

q1

q0

q1

A Simple Turing Machineq

acc

qrej

start

1 → B, R

1 → B, R

B → B, R

B → B, R

qacc

qrej

Page 152: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

q0

q1

q0

q1

A Simple Turing Machineq

acc

qrej

start

1 → B, R

1 → B, R

B → B, R

B → B, R

qacc

qrej

Page 153: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

q0

q1

q0

q1

A Simple Turing Machineq

acc

qrej

start

1 → B, R

1 → B, R

B → B, R

B → B, R

qacc

qrej

Page 154: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

q0

q1

q0

q1

A Simple Turing Machineq

acc

qrej

start

1 → B, R

1 → B, R

B → B, R

B → B, R

qacc

qrej

Page 155: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

q0

q1

q0

q1

A Simple Turing Machineq

acc

qrej

start

1 → B, R

1 → B, R

B → B, R

B → B, R

qacc

qrej

Page 156: The Limits of Context- Free Languages - KeithSchwarz.com...Announcements Problem Set 6 due right now. Problem Set 7 out, due next Friday, November 18. Covers context-free languages,

Mean: 92Median: 98Stdev: 21

10 20 30 40 50 60 70 80 90 100 110 120 125

Problem Set 4 Grades