Introduction to the Theory of Computation John Paxton

  • Slides: 11
Download presentation
Introduction to the Theory of Computation John Paxton Montana State University Summer 2003

Introduction to the Theory of Computation John Paxton Montana State University Summer 2003

Humor • In a train carriage there was Bill Clinton, George Bush, Janet Reno

Humor • In a train carriage there was Bill Clinton, George Bush, Janet Reno and Bo Derek. After several minutes of the trip, the train passes through a dark tunnel and the unmistakable sound of a slap is heard. When they leave the tunnel, Clinton has a big red slap mark on his cheek. (1) Bo Derek thought - "That sleazeball Clinton wanted to touch me and by mistake, he must have put his hand on Janet Reno, who in turn must have slapped his face. " (2) Janet Reno thought - "That dirty Bill Clinton laid his hands on Bo Derek and she smacked him. " (3) Bill Clinton thought - "George put his hand on Bo Derek and by mistake she slapped me. " (4) George Bush thought - "I hope there's another tunnel soon so I can smack Clinton again. "

1. 4 Nonregular Languages • A = { w | w has an equal

1. 4 Nonregular Languages • A = { w | w has an equal number of 0 s and 1 s}. Is A regular? • B = { w | w has an equal number of 01 s and 10 s} Is B regular?

Pumping Lemma • If A is a regular language, then there is a number

Pumping Lemma • If A is a regular language, then there is a number p (the pumping length) where, if s is any string in A of length at least p, then s may be divided into three pieces, s = xyz, satisfying the following conditions:

Pumping Lemma 1. for each i >= 0, xyiz A 2. |y| > 0

Pumping Lemma 1. for each i >= 0, xyiz A 2. |y| > 0 3. |xy| <= p

Proof Idea • Pigeonhole Principle y qm x qn q 1 z

Proof Idea • Pigeonhole Principle y qm x qn q 1 z

Example: 0*1*0 • p >= 3 1 0 e 0

Example: 0*1*0 • p >= 3 1 0 e 0

Example: 0*1*0 • s = 00012 p 0 • s = 0 p 0

Example: 0*1*0 • s = 00012 p 0 • s = 0 p 0 x = 000, y = 1, z = 12 p-10 x = e, y = 0, z = 0 p-10

Example • Prove that C = {0 n 1 n | n >= 0}

Example • Prove that C = {0 n 1 n | n >= 0} is not regular • Assume C is regular, let s = 0 p 1 p • Since |xy| <= p and |y| > 0, then y must consist of 1 or more 0 s, call this number k • xyz = 0 j 0 k 0 p-j-k 1 p = 0 p 1 p C • xy 2 z = 0 j 02 k 0 p-j-k 1 p = 0 p+k 1 p C • Contradiction!

Exercises • Prove that A = { w | w has an equal number

Exercises • Prove that A = { w | w has an equal number of 0 s and 1 s} is not regular. • Prove that D = { ww | w {0, 1}* } is not regular. • Prove that E = {0 i 1 j | i > j} is not regular.

Exercise • Show that F = {ak | where k is a multiple of

Exercise • Show that F = {ak | where k is a multiple of n} is regular for all n >= 1. • Show the language G = { w | w is not a palindrome } satisifies the three conditions of the pumping lemma even though it is not regular. Explain why this fact does not contradict the pumping lemma.