We now return to the question: Suppose A, B are regular languages, - - PowerPoint PPT Presentation

we now return to the question suppose a b are regular
SMART_READER_LITE
LIVE PREVIEW

We now return to the question: Suppose A, B are regular languages, - - PowerPoint PPT Presentation

We now return to the question: Suppose A, B are regular languages, then not A := { w : w is not in A } A U B := { w : w in A or w in B } A o B := { w 1 w 2 : w 1 in A and w 2 in B } A* := { w 1 w 2 w k : k 0 , w i


slide-1
SLIDE 1

We now return to the question:

  • Suppose A, B are regular languages, then
  • not A := { w : w is not in A }
  • A U B := { w : w in A or w in B }
  • A o B := { w1 w2 : w1 in A and w2 in B }
  • A* := { w1 w2 … wk : k  0 , wi in A for every i }
  • A ∩ B := { w : w in A and w in B }

are all regular

slide-2
SLIDE 2
  • All languages
  • Decidable

Turing machines

  • NP
  • P
  • Context-free

Context-free grammars, push-down automata

  • Regular

Automata, non-deterministic automata, regular expressions

Big picture

slide-3
SLIDE 3

How to specify a regular language? Write a picture → complicated Write down formal definition → complicated d(q0 ,0) = q0, … Use symbols from S and operations *, o, U → good ({0} * U {1}) o {001}

slide-4
SLIDE 4

Regular expressions: anything you can write with  , ε , symbols from S, and operations *, o, U Conventions:

  • Write a instead of {a}
  • Write AB for A o B
  • Write ∑ for Ua ∑

∈ a So if ∑ = {a,b} then ∑ = a U b

  • Operation * has precedence over o, and o over U

so 1 U 01* means 1U(0(1)*) Example: 110, 0*, S*, S*001S*, (SS)*, 01 U 10

slide-5
SLIDE 5

Definition Regular expressions RE over S are:  e a if a in S R R' if R, R' are RE R U R' if R, R' are RE R* if R is RE

slide-6
SLIDE 6

Definition The language described by RE: L() =  L(e) = {e} L(a) = {a} if a in S L(R R') = L(R) o L(R') L(R U R') = L(R) U L(R') L(R*) = L(R)*

slide-7
SLIDE 7

Example S = { a, b} RE Language

  • ab U ba ?
  • a*
  • (a U b)*
  • a*ba*
  • S*bS*
  • S*aabS*
  • (SS)*
  • (a*ba*ba*)*
  • a*baba*a
slide-8
SLIDE 8

Example S = { a, b} RE Language

  • ab U ba {ab, ba}
  • a*
  • (a U b)*
  • a*ba*
  • S*bS*
  • S*aabS*
  • (SS)*
  • (a*ba*ba*)*
  • a*baba*a
slide-9
SLIDE 9

Example S = { a, b} RE Language

  • ab U ba {ab, ba}
  • a* {e, a, aa, … } = { w : w has only a}
  • (a U b)*
  • a*ba*
  • S*bS*
  • S*aabS*
  • (SS)*
  • (a*ba*ba*)*
  • a*baba*a
slide-10
SLIDE 10

Example S = { a, b} RE Language

  • ab U ba {ab, ba}
  • a* {e, a, aa, … } = { w : w has only a}
  • (a U b)* all strings
  • a*ba*
  • S*bS*
  • S*aabS*
  • (SS)*
  • (a*ba*ba*)*
  • a*baba*a
slide-11
SLIDE 11

Example S = { a, b} RE Language

  • ab U ba {ab, ba}
  • a* {e, a, aa, … } = { w : w has only a}
  • (a U b)* all strings
  • a*ba* {w : w has exactly one b}
  • S*bS*
  • S*aabS*
  • (SS)*
  • (a*ba*ba*)*
  • a*baba*a
slide-12
SLIDE 12

Example S = { a, b} RE Language

  • ab U ba {ab, ba}
  • a* {e, a, aa, … } = { w : w has only a}
  • (a U b)* all strings
  • a*ba* {w : w has exactly one b}
  • S*bS* {w : w has at least one b}
  • S*aabS*
  • (SS)*
  • (a*ba*ba*)*
  • a*baba*a
slide-13
SLIDE 13

Example S = { a, b} RE Language

  • ab U ba {ab, ba}
  • a* {e, a, aa, … } = { w : w has only a}
  • (a U b)* all strings
  • a*ba* {w : w has exactly one b}
  • S*bS* {w : w has at least one b}
  • S*aabS* {w : w contains the string aab}
  • (SS)*
  • (a*ba*ba*)*
  • a*baba*a
slide-14
SLIDE 14

Example S = { a, b} RE Language

  • ab U ba {ab, ba}
  • a* {e, a, aa, … } = { w : w has only a}
  • (a U b)* all strings
  • a*ba* {w : w has exactly one b}
  • S*bS* {w : w has at least one b}
  • S*aabS* {w : w contains the string aab}
  • (SS)* {w : w has even length}
  • (a*ba*ba*)*
  • a*baba*a
slide-15
SLIDE 15

Example S = { a, b} RE Language

  • ab U ba {ab, ba}
  • a* {e, a, aa, … } = { w : w has only a}
  • (a U b)* all strings
  • a*ba* {w : w has exactly one b}
  • S*bS* {w : w has at least one b}
  • S*aabS* {w : w contains the string aab}
  • (SS)* {w : w has even length}
  • (a*ba*ba*)* {w : w contains even number of b}
  • a*baba*a
slide-16
SLIDE 16

Example S = { a, b} RE Language

  • ab U ba {ab, ba}
  • a* {e, a, aa, … } = { w : w has only a}
  • (a U b)* all strings
  • a*ba* {w : w has exactly one b}
  • S*bS* {w : w has at least one b}
  • S*aabS* {w : w contains the string aab}
  • (SS)* {w : w has even length}
  • (a*ba*ba*)* {w : w contains even number of b}
  • a*baba*a  (anything o  = )
slide-17
SLIDE 17

Theorem: For every RE R there is NFA M: L(M) = L(R)

slide-18
SLIDE 18

Theorem: For every RE R there is NFA M: L(M) = L(R) Construction:

  • R =  M := ?
slide-19
SLIDE 19

Theorem: For every RE R there is NFA M: L(M) = L(R) Construction:

  • R =  M :=
  • R = e M := ?
slide-20
SLIDE 20

Theorem: For every RE R there is NFA M: L(M) = L(R) Construction:

  • R =  M :=
  • R = e M :=
  • R = a M := ?
slide-21
SLIDE 21

Theorem: For every RE R there is NFA M: L(M) = L(R) Construction:

  • R =  M :=
  • R = e M :=
  • R = a M :=
  • R = R U R' ?

a

slide-22
SLIDE 22

Theorem: For every RE R there is NFA M: L(M) = L(R) Construction:

  • R =  M :=
  • R = e M :=
  • R = a M :=
  • R = R U R' use construction for A U B seen earlier
  • R = R o R' ?

a

slide-23
SLIDE 23

Theorem: For every RE R there is NFA M: L(M) = L(R) Construction:

  • R =  M :=
  • R = e M :=
  • R = a M :=
  • R = R U R' use construction for A U B seen earlier
  • R = R o R' use construction for A o B seen earlier
  • R = R* ?

a

slide-24
SLIDE 24

Theorem: For every RE R there is NFA M: L(M) = L(R) Construction:

  • R =  M :=
  • R = e M :=
  • R = a M :=
  • R = R U R' use construction for A U B seen earlier
  • R = R o R' use construction for A o B seen earlier
  • R = R* use construction for A* seen earlier

a

slide-25
SLIDE 25

Example: RE → NFA

RE = (ab U a)*

slide-26
SLIDE 26

Example: RE → NFA a

Ma = L(Ma)=L(a)

RE = (ab U a)*

slide-27
SLIDE 27

Example: RE → NFA

RE = (ab U a)*

a

Ma = L(Ma)=L(a)

b

Mb = L(Mb)=L(b)

slide-28
SLIDE 28

Example: RE → NFA

Mab = L(Mab)=L(ab)

a b e

RE = (ab U a)*

slide-29
SLIDE 29

Example: RE → NFA

Mab = L(Mab)=L(ab)

a b e

RE = (ab U a)*

a

Ma = L(Ma)=L(a)

slide-30
SLIDE 30

Example: RE → NFA

Mab U a = L(Mab U a)=L(ab U a)

a b e

RE = (ab U a)*

e e a

slide-31
SLIDE 31

Example: RE → NFA

M(ab U a)* = L(M(ab U a)*)=L((ab U a)*)=L(RE)

RE = (ab U a)*

a b e a e e e e e

slide-32
SLIDE 32

ANOTHER Example: RE → NFA

RE =(e U a)ba*

slide-33
SLIDE 33

ANOTHER Example: RE → NFA

Me = L(Me)=L(e)

RE =(e U a)ba*

slide-34
SLIDE 34

ANOTHER Example: RE → NFA

Me = L(Me)=L(e)

a

Ma = L(Ma)=L(a)

RE =(e U a)ba*

slide-35
SLIDE 35

ANOTHER Example: RE → NFA

Me U a = L(Me U a)=L(e U a)

RE =(e U a)ba*

e e a

slide-36
SLIDE 36

ANOTHER Example: RE → NFA

Me U a = L(Me U a)=L(e U a)

b

Mb = L(Mb)=L(b)

RE =(e U a)ba*

e e a

slide-37
SLIDE 37

ANOTHER Example: RE → NFA

L(M(e U a)b)=L((e U a)b)

e e a b e e

M(e U a)b =

RE =(e U a)ba*

slide-38
SLIDE 38

ANOTHER Example: RE → NFA

L(M(e U a)b)=L((e U a)b)

e e a b e e a

Ma = L(Ma)=L(a) M(e U a)b =

RE =(e U a)ba*

slide-39
SLIDE 39

ANOTHER Example: RE → NFA

L(M(e U a)b)=L((e U a)b)

e e a b e e

Ma* =

e e a

L(Ma*)=L(a*) M(e U a)b =

RE =(e U a)ba*

slide-40
SLIDE 40

ANOTHER Example: RE → NFA

RE =(e U a)ba*

M(e U a)ba* = L(M(e U a)ba*)=L((e U a)ba*)=L(RE)

e e a b e e e a e e

slide-41
SLIDE 41

Recap: Here “” means “can be converted to” We have seen: RE  NFA  DFA Next we see: DFA  RE In two steps: DFA  Generalized NFA  RE

slide-42
SLIDE 42

Generalized NFA (GNFA) q0 qa a*b* a U b* ab Nondeterministic Transitions labelled by RE Read blocks of input symbols at a time

slide-43
SLIDE 43

Generalized NFA (GNFA) q0 qa a*b* a U b* ab Convention: Unique final state Exactly one transition between each pair of states except nothing going into start state nothing going out of final state If arrow not shown in picture, label = 

slide-44
SLIDE 44
  • Definition: A generalized finite automaton (GNFA)
  • is a 5-tuple (Q, S, d, q0, qa) where
  • Q is a finite set of states
  • S is the input alphabet
  • d : (Q - {qa}) X (Q – {q0}) → Regular Expressions
  • q0 in Q is the start state
  • qa in Q is the accept state
slide-45
SLIDE 45
  • Definition: GNFA (Q, S, d, q0, qa) accepts a string w if
  • ∃integer k, k strings w

1 , w2 , …, wk  S*

such that w = w1 w2 … wk (divide w in k strings)

  • $ sequence of k+1 states r0, r1, .., rk in Q such that:
  • r0 = q0
  • wi+1 L(d(ri ,ri+1 ))  0  i < k
  • rk = qa
  • Differences with NFA are in green
slide-46
SLIDE 46

Example q0 q1 qa a* b* ab Accepts w = aaabbab w1=?

slide-47
SLIDE 47

Example q0 q1 qa a* b* ab Accepts w = aaabbab w1=aaa w2=?

slide-48
SLIDE 48

Example q0 q1 qa a* b* ab Accepts w = aaabbab w1=aaa w2=bb w3=ab r0=q0 r1=?

slide-49
SLIDE 49

Example q0 q1 qa a* b* ab Accepts w = aaabbab w1=aaa w2=bb w3=ab r0=q0 r1=q1 r2=? w1 = aaa  L(d(r0,r1)) = L(d(q0,q1)) = L(a*)

slide-50
SLIDE 50

Example q0 q1 qa a* b* ab Accepts w = aaabbab w1=aaa w2=bb w3=ab r0=q0 r1=q1 r2=q1 r3 = ? w1 = aaa  L(d(r0,r1)) = L(d(q0,q1)) = L(a*) w2 = bb  L(d(r1,r2)) = L(d(q1,q1)) = L(b*)

slide-51
SLIDE 51

Example q0 q1 qa a* b* ab Accepts w = aaabbab w1=aaa w2=bb w3=ab r0=q0 r1=q1 r2=q1 r3 = qa w1 = aaa  L(d(r0,r1)) = L(d(q0,q1)) = L(a*) w2 = bb  L(d(r1,r2)) = L(d(q1,q1)) = L(b*) w3 = ab  L(d(r2,r3)) = L(d(q1,qa)) = L(ab)

slide-52
SLIDE 52

Theorem:  DFA M  GNFA N : L(N) = L(M) Construction: To ensure unique transition between each pair: To ensure unique final state, no transitions ingoing start state, no transitions outgoing final state: 1 1 U 0 e e e e

slide-53
SLIDE 53

Theorem:  GNFA N  RE R : L(R) = L(N) Construction: If N has 2 states, then N = thus R := S q0 qa S qi qj R1R2*R3 U R4 If N has > 2 states, eliminate some state qr  q0, qa : for every ordered pair qi, qj (possibly equal) that are connected through qr qr qi qj R1 R3 R4 Repeat until 2 states remain R2

slide-54
SLIDE 54

Example: DFA → GNFA → RE

q2 q1

a b b,c

DFA

slide-55
SLIDE 55

Example: DFA → GNFA → RE

q2 q1

a b b U c

GNFA

q0 qa

e e

slide-56
SLIDE 56

Example: DFA → GNFA → RE

q2 q1

a b

q0 qa

e e

q2

b

q0 qa

e b U c Eliminate q1: re-draw GNFA with all other states

slide-57
SLIDE 57

Example: DFA → GNFA → RE

q2 q1

a b

q0 qa

e e

q2

b

q0 qa

e b U c Eliminate q1: find a path through q1

slide-58
SLIDE 58

Example: DFA → GNFA → RE

q2 q1

a b

q0 qa

e e

q2

b

q0 qa

e Eliminate q1: add edge to new GNFA b U c e a* (b U c) U Ø Ø Don't forget: no arrow means label Ø

slide-59
SLIDE 59

Example: DFA → GNFA → RE

q2 q1

a b

q0 qa

e e

q2

b

q0 qa

e Eliminate q1: simplify RE on new edge a* (b U c) b U c

slide-60
SLIDE 60

Example: DFA → GNFA → RE

q2 q1

a b

q0 qa

e e

q2

b

q0 qa

e Eliminate q1: if no more paths through q1, start over a* (b U c) b U c

slide-61
SLIDE 61

Example: DFA → GNFA → RE

q2

b

q0 qa

e a* (b U c) Eliminate q2: re-draw GNFA with all other states

q0 qa

slide-62
SLIDE 62

Example: DFA → GNFA → RE

q2

b

q0 qa

e a* (b U c)

q0 qa

Eliminate q2: find a path through q2

slide-63
SLIDE 63

Example: DFA → GNFA → RE

q2

b

q0 qa

e a* (b U c)

q0 qa

Eliminate q2: add edge to new GNFA a* (b U c) b* e U Ø

slide-64
SLIDE 64

Example: DFA → GNFA → RE

q2

b

q0 qa

e a* (b U c)

q0 qa

Eliminate q2: simplify RE on new edge a* (b U c) b*

slide-65
SLIDE 65

Example: DFA → GNFA → RE

q2

b

q0 qa

e a* (b U c)

q0 qa

Eliminate q2: if no more paths through q2, start over a* (b U c) b*

slide-66
SLIDE 66

Example: DFA → GNFA → RE

q0 qa

Only two states remain:

RE = a* (b U c) b*

a* (b U c) b*

slide-67
SLIDE 67

ANOTHER Example: DFA → GNFA → RE

q1

a b

q2

a

q3

DFA

c c b

slide-68
SLIDE 68

ANOTHER Example: DFA → GNFA → RE

q1

a b

q2

a

q0 q

e e

q3

a

GNFA

c c b

slide-69
SLIDE 69

ANOTHER Example: DFA → GNFA → RE

q1

a b

q2

a

q0 q

e e

q3

Eliminate q1: re-draw GNFA with all other states

a

q0 q2

a

q

e

q3

a

b c c b

slide-70
SLIDE 70

ANOTHER Example: DFA → GNFA → RE

q1

a b

q2

a

q0 q

e e

q3

Eliminate q1: find a path through q1

a

q0 q2

a

q

e

q3

a

c c b b

slide-71
SLIDE 71

ANOTHER Example: DFA → GNFA → RE

q1

a b

q2

a

q0 q

e e

q3

Eliminate q1: add edge to new GNFA

a

q0 q2

a

q

e

q3

a

c c e a*b U Ø b b

slide-72
SLIDE 72

ANOTHER Example: DFA → GNFA → RE

q1

a b

q2

a

q0 q

e e

q3

Eliminate q1: find another path through q1

a

q0 q2

a

q

e

q3

a

c c b b e a*b U Ø

slide-73
SLIDE 73

ANOTHER Example: DFA → GNFA → RE

q1

a b

q2

a

q0 q

e e

q3

Eliminate q1: add edge to new GNFA

a

b

q0 q2

a

q

e

q3

a

c c e a*c U Ø b e a*b U Ø

slide-74
SLIDE 74

ANOTHER Example: DFA → GNFA → RE

q1

a b

q2

a

q0 q

e e

q3

Eliminate q1: find another path through q1

a

q0 q2

a

q

e

q3

a

c c b b e a*b U Ø e a*c U Ø

slide-75
SLIDE 75

ANOTHER Example: DFA → GNFA → RE

q1

a b

q2

a

q0 q

e e

q3

Eliminate q1: add edge to new GNFA

a

q0 q2

ca*b U a

q

e

q3

a

c c b b don't forget current q2 → q3 edge! This time is not Ø ! e a*b U Ø e a*c U Ø

slide-76
SLIDE 76

ANOTHER Example: DFA → GNFA → RE

q1

a b

q2

a

q0 q

e e

q3

Eliminate q1: find another path through q1

a

q0 q2 q

e

q3

a

c c b b ca*b U a e a*b U Ø e a*c U Ø

slide-77
SLIDE 77

ANOTHER Example: DFA → GNFA → RE

q1

a b

q2

a

q0 q

e e

q3

a

q0 q2 q

e

q3

a

c c b ca*c U b ca*b U a Eliminate q1: add edge to new GNFA don't forget current q2 → q2 edge! e a*b U Ø e a*c U Ø

slide-78
SLIDE 78

ANOTHER Example: DFA → GNFA → RE

q1

a b

q2

a

q0 q

e e

q3

Eliminate q1: when no more paths through q1, start over (and simplify REs)

a

q0 q2 q

e

q3

a

c c a*b b a*c ca*b U a ca*c U b

slide-79
SLIDE 79

ANOTHER Example: DFA → GNFA → RE

q

e

q3

a

Eliminate q2: re-draw GNFA with all other states

q0 q2 q

e

q3

a

a*b a*c ca*b U a ca*c U b

q0

a*b

slide-80
SLIDE 80

ANOTHER Example: DFA → GNFA → RE

q

e

q3

a

Eliminate q2: find a path through q2

q0 q2 q

e

q3

a

a*b a*c ca*b U a ca*c U b

q0

a*b

slide-81
SLIDE 81

ANOTHER Example: DFA → GNFA → RE

q0 q

e

q3

a

a*c(ca*c U b)*(ca*b U a) U a*b Eliminate q2: add edge to new GNFA

q0 q2 q

e

q3

a

a*b a*c ca*b U a ca*c U b

slide-82
SLIDE 82

ANOTHER Example: DFA → GNFA → RE

q0 q

e

q3

a

a*c(ca*c U b)*(ca*b U a) U a*b Eliminate q2: when no more paths through q2, start over

q0 q2 q

e

q3

a

a*b a*c ca*b U a ca*c U b

slide-83
SLIDE 83

ANOTHER Example: DFA → GNFA → RE

q0 q

e

q3

a

a*c(ca*c U b)*(ca*b U a) U a*b Eliminate q3: re-draw GNFA with all other states

q0 qa

slide-84
SLIDE 84

ANOTHER Example: DFA → GNFA → RE

q0 q

e

q3

a

a*c(ca*c U b)*(ca*b U a) U a*b Eliminate q3: find a path through q3

q0 qa

don't forget: no arrow means Ø Ø Ø

slide-85
SLIDE 85

ANOTHER Example: DFA → GNFA → RE

q0 q

e

q3

a

a*c(ca*c U b)*(ca*b U a) U a*b Eliminate q3: add edge to new GNFA

q0 qa

(a*c(ca*c U b)*(ca*b U a) U a*b) Ø* ε U Ø Ø Ø

slide-86
SLIDE 86

ANOTHER Example: DFA → GNFA → RE

q0 q

e

q3

a

a*c(ca*c U b)*(ca*b U a) U a*b Eliminate q3: when no more paths through q3, start over (and simplify REs)

q0 qa

a*c(ca*c U b)*(ca*b U a) U a*b don't forget: Ø*= ε

slide-87
SLIDE 87

ANOTHER Example: DFA → GNFA → RE

q0 qa

a*c(ca*c U b)*(ca*b U a) U a*b Only two states remain:

RE = a*c(ca*c U b)*(ca*b U a) U a*b

slide-88
SLIDE 88

Recap: Here “” means “can be converted to”

RE  DFA  NFA

Any of the three recognize exactly the regular languages (initially defined using DFA)

slide-89
SLIDE 89

These conversions are used every time you enter an RE, for example for pattern matching using grep

  • The RE is converted to an NFA
  • Then the NFA is converted to a DFA
  • The DFA representation is used to pattern-match

Optimizations have been devised, but this is still the general approach.

slide-90
SLIDE 90

What language is NOT regular? Is { 0n 1n : n  0 } = {ε, 01, 0011, 000111, … } regular?

slide-91
SLIDE 91

Pumping lemma: L regular language  Recall y0 = e, y1 = y, y2 = yy, y3 = yyy, ...  p 0  w  L, |w|  p  x,y,z : w= xyz, |y|> 0, |xy| p  i  0 : xyiz  L

slide-92
SLIDE 92

Pumping lemma: L regular language  We will not see the proof. But here's the idea: p := |Q| for DFA recognizing L If w  L, |w|  p, then during computation 2 states must be the same q Q ∈ y = portion of w that brings back to q can repeat y and still accept string  p 0  w  L, |w|  p  x,y,z : w= xyz, |y|> 0, |xy| p  i  0 : xyiz  L

slide-93
SLIDE 93

Pumping lemma: L regular language  Useful to prove L NOT regular. Use contrapositive: L regular language  A same as (not A)  L not regular  p 0  w  L, |w|  p  x,y,z : w= xyz, |y|> 0, |xy| p  i  0 : xyiz  L A

slide-94
SLIDE 94

Pumping lemma (contrapositive)  L not regular To prove L not regular it is enough to prove not A Not A is the stuff in the box.  p 0  w  L, |w|  p  x,y,z : w = xyz, |y| > 0, |xy|  p  i  0 : xyiz  L not A

slide-95
SLIDE 95

Proving something like  bla  bla  bla  bla bla means winning a game Theory is all about winning games!

slide-96
SLIDE 96

Example NAME THE BIGGEST NUMBER GAME

  • Two players:

You, Adversary.

  • Rules:

First Adversary says a number. Then You say a number. You win if your number is bigger. Can you win this game?

slide-97
SLIDE 97

Example NAME THE BIGGEST NUMBER GAME

  • Two players:

You, Adversary.

  • Rules:

First Adversary says a number. Then You say a number. You win if your number is bigger. You have winning strategy: if adversary says x, you say x+1

slide-98
SLIDE 98

Example NAME THE BIGGEST NUMBER GAME

  • Two players:

You, Adversary. , 

  • Rules:

First Adversary says a number.  x  y : y > x Then You say a number. You win if your number is bigger. You have winning strategy: Claim is true if adversary says x, you say x+1

slide-99
SLIDE 99

Another example: Theorem:  NFA N  DFA M : L(M) = L(N) We already saw a winning strategy for this game What is it?

slide-100
SLIDE 100

Another example: Theorem:  NFA N  DFA M : L(M) = L(N) We already saw a winning strategy for this game The power set construction.

slide-101
SLIDE 101

Games with more moves: Chess, Checkers, Tic-Tac-Toe You can win if  move of the Adversary  move You can make  move of the Adversary  move You can make … : You checkmate

slide-102
SLIDE 102

Pumping lemma (contrapositive)  L not regular Rules of the game: Adversary picks p, You pick w L of length ∈  p, Adversary decomposes w in xyz, where |y| > 0, |xy|p You pick i  0 Finally, you win if xyiz  L  p 0  w  L, |w|  p  x,y,z : w = xyz, |y| > 0, |xy|  p  i  0 : xyiz  L

slide-103
SLIDE 103

Theorem: L := {0n 1n : n  0} is not regular Proof: Use pumping lemma Adversary moves p You move w := 0p 1p Adversary moves x,y,z You move i := 2 You must show xyyz  L: Since |xy|p and w = xyz = 0p 1p , y only has 0 So xyyz = 0p + |y| 1p Since |y| > 0, this is not of the form 0n 1n DONE

 p 0  w  L, |w|  p  x,y,z : w = xyz, |y| > 0, |xy|  p  i  0 : xyiz  L

slide-104
SLIDE 104

Theorem: L := {w : w has as many 0 as 1} not regular Same Proof: Use pumping lemma Adversary moves p You move w := ?

 p 0  w  L, |w|  p  x,y,z : w = xyz, |y| > 0, |xy|  p  i  0 : xyiz  L

slide-105
SLIDE 105

Theorem: L := {w : w has as many 0 as 1} not regular Same Proof: Use pumping lemma Adversary moves p You move w := 0p 1p Adversary moves x,y,z You move i := ?

 p 0  w  L, |w|  p  x,y,z : w = xyz, |y| > 0, |xy|  p  i  0 : xyiz  L

slide-106
SLIDE 106

Theorem: L := {w : w has as many 0 as 1} not regular Same Proof: Use pumping lemma Adversary moves p You move w := 0p 1p Adversary moves x,y,z You move i := 2 You must show xyyz  L: Since |xy|p and w = xyz = 0p 1p , y only has 0 So xyyz = ?

 p 0  w  L, |w|  p  x,y,z : w = xyz, |y| > 0, |xy|  p  i  0 : xyiz  L

slide-107
SLIDE 107

Theorem: L := {w : w has as many 0 as 1} not regular Same Proof: Use pumping lemma Adversary moves p You move w := 0p 1p Adversary moves x,y,z You move i := 2 You must show xyyz  L: Since |xy|p and w = xyz = 0p 1p , y only has 0 So xyyz = 0p + |y| 1p Since |y| > 0, not as many 0 as 1 DONE

 p 0  w  L, |w|  p  x,y,z : w = xyz, |y| > 0, |xy|  p  i  0 : xyiz  L

slide-108
SLIDE 108

Theorem: L := {0j 1k : j > k} is not regular Proof: Use pumping lemma Adversary moves p You move w := ?

 p 0  w  L, |w|  p  x,y,z : w = xyz, |y| > 0, |xy|  p  i  0 : xyiz  L

slide-109
SLIDE 109

Theorem: L := {0j 1k : j > k} is not regular Proof: Use pumping lemma Adversary moves p You move w := 0p+1 1p Adversary moves x,y,z You move i := ?

 p 0  w  L, |w|  p  x,y,z : w = xyz, |y| > 0, |xy|  p  i  0 : xyiz  L

slide-110
SLIDE 110

Theorem: L := {0j 1k : j > k} is not regular Proof: Use pumping lemma Adversary moves p You move w := 0p+1 1p Adversary moves x,y,z You move i := 0 You must show xz  L: Since |xy|p and w = xyz = 0p+1 1p , y only has 0 So xz = 0p + 1 - |y| 1p Since |y| > 0, this is not of the form 0j 1k with j > k

 p 0  w  L, |w|  p  x,y,z : w = xyz, |y| > 0, |xy|  p  i  0 : xyiz  L

slide-111
SLIDE 111

Theorem: L := {uu : u  {0,1}* } is not regular Proof: Use pumping lemma Adversary moves p You move w := ?

 p 0  w  L, |w|  p  x,y,z : w = xyz, |y| > 0, |xy|  p  i  0 : xyiz  L

slide-112
SLIDE 112

Theorem: L := {uu : u  {0,1}* } is not regular Proof: Use pumping lemma Adversary moves p You move w := 0p1 0p 1 Adversary moves x,y,z You move i := ?

 p 0  w  L, |w|  p  x,y,z : w = xyz, |y| > 0, |xy|  p  i  0 : xyiz  L

slide-113
SLIDE 113

Theorem: L := {uu : u  {0,1}* } is not regular Proof: Use pumping lemma Adversary moves p You move w := 0p 1 0p 1 Adversary moves x,y,z You move i := 2 You must show xyyz  L: Since |xy|p and w = xyz = 0p 1 0p 1 , y only has 0 So xyyz = 0p + |y| 1 0p 1 Since |y| > 0, first half of xyyz only 0, so xyyz  L

 p 0  w  L, |w|  p  x,y,z : w = xyz, |y| > 0, |xy|  p  i  0 : xyiz  L

slide-114
SLIDE 114

Theorem: L := { 1n2 : n  0 } is not regular Proof: Use pumping lemma Adversary moves p You move w := ?

 p 0  w  L, |w|  p  x,y,z : w = xyz, |y| > 0, |xy|  p  i  0 : xyiz  L

slide-115
SLIDE 115

Theorem: L := { 1n2 : n  0 } is not regular Proof: Use pumping lemma Adversary moves p You move w := 1p2 Adversary moves x,y,z You move i := ?

 p 0  w  L, |w|  p  x,y,z : w = xyz, |y| > 0, |xy|  p  i  0 : xyiz  L

slide-116
SLIDE 116

Theorem: L := { 1n2 : n  0 } is not regular Proof: Use pumping lemma Adversary moves p You move w := 1p2 Adversary moves x,y,z You move i := 2 You must show xyyz  L: Since |xy|p, |xyyz|  ?

 p 0  w  L, |w|  p  x,y,z : w = xyz, |y| > 0, |xy|  p  i  0 : xyiz  L

slide-117
SLIDE 117

Theorem: L := { 1n2 : n  0 } is not regular Proof: Use pumping lemma Adversary moves p You move w := 1p2 Adversary moves x,y,z You move i := 2 You must show xyyz  L: Since |xy|p, |xyyz|  p2 + p < (p+1)2 Since |y| > 0, |xyyz| > ?

 p 0  w  L, |w|  p  x,y,z : w = xyz, |y| > 0, |xy|  p  i  0 : xyiz  L

slide-118
SLIDE 118

Theorem: L := { 1n2 : n  0 } is not regular Proof: Use pumping lemma Adversary moves p You move w := 1p2 Adversary moves x,y,z You move i := 2 You must show xyyz  L: Since |xy|p, |xyyz|  p2 + p < (p+1)2 Since |y| > 0, |xyyz| > p2 So |xyyz| cannot be … what ?

 p 0  w  L, |w|  p  x,y,z : w = xyz, |y| > 0, |xy|  p  i  0 : xyiz  L

slide-119
SLIDE 119

Theorem: L := { 1n2 : n  0 } is not regular Proof: Use pumping lemma Adversary moves p You move w := 1p2 Adversary moves x,y,z You move i := 2 You must show xyyz  L: Since |xy|p, |xyyz|  p2 + p < (p+1)2 Since |y| > 0, |xyyz| > p2 So |xyyz| cannot be a square. xyyz  L

 p 0  w  L, |w|  p  x,y,z : w = xyz, |y| > 0, |xy|  p  i  0 : xyiz  L

slide-120
SLIDE 120
  • All languages
  • Decidable

Turing machines

  • NP
  • P
  • Context-free

Context-free grammars, push-down automata

  • Regular

Automata, non-deterministic automata, regular expressions

Big picture