Pumping lemma
This presentation is the property of its rightful owner.
Sponsored Links
1 / 64

Pumping Lemma PowerPoint PPT Presentation


  • 333 Views
  • Uploaded on
  • Presentation posted in: General

Pumping Lemma. Problem: Let B be the language of all palindromes over {0,1} containing an equal number of 0s and 1s. Show that B is not CFL Solution: We assume that B is a CFL and obtain a contradiction.

Download Presentation

Pumping Lemma

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Pumping lemma

Pumping Lemma

Problem:

  • Let B be the language of all palindromes over {0,1} containing an equal number of 0s and 1s. Show that B is not CFL

    Solution:

  • We assume that B is a CFL and obtain a contradiction.

  • Let p be the pumping constant of B that is guaranteed to exist by the pumping lemma. Select the string s= 0p1p1p0p.

  • Clearly sis a member of B and of length at least p . We can show that no matter how we divide sinto uvxyz, one of the conditions of the lemma is violated.

    • Pumping lemma, | vxy |<= p , we can only place vxy in the following ways:


Pumping lemma

  • vxy completely falls in the first 0p

    • If we pump v and y , then the new string is no longer a palindrome, and the number of 0s will be greater than the number of 1s, which is a contradiction.

  • vxy falls between 0pand 1p

    • In this case, v will only contain 0s while y will only contain 1s. So if we pump s , the new string is no longer palindrome, which is a contradiction.

  • vxy completely falls in the first 1p

    • Similar to (1), after pumping s , the number of 1s will be greater than the number of 0s, which is a contradiction.

  • vxy falls between 1pand 1p

    • After pumping s , the number of 1s will be greater than the number of 0s, which is a contradiction.

  • vxy completely falls in the second 1p

    • This case is same with (3).

  • vxy falls between 1pand 0p

    • Similar to (2), v will only contain 1s while y will only contain 0s. So if we pump s , the new string is no longer palindrome, which is a contradiction.

  • vxy completely falls in the second 0p

    • This case is same with (1).

      Hence, B is not context free.


Pumping lemma

  • Let L = {w  {0; 1}* : w = wR}.

  • (a) Show that L is context-free by giving a context-free grammar for L.

  • (b) Show that L is context-free by giving a pushdown automaton for L.

  • (c) Show that L is not regular.


Pumping lemma

CFG

  • L is a symmetric language. Consider a context-free grammar for L : (V, Σ, R, S) , where

    i. V = {S}

    ii. Σ = {0,1}

    iii. Rules:

    S  0S0 |1S1| 0 |1|ε

    iv. S = S V


Pumping lemma

PDA


Pumping lemma1

Pumping Lemma

  • Assume that L regular. Let p be the pumping constant given by the pumping lemma.

  • Let sbe the string 1p-1101p.

  • scan be split into three pieces, s =xyz , where for any i >= 0 the string xyiz is in L .

  • According to the pumping lemma condition, we must have | xy |<= p . If this is the case, then y must consist only of 1’s, so xyyz L . Therefore scannot be pumped.

  • This is a contradiction.


Pushdown automaton pda

Pushdown Automaton -- PDA

Input String

Stack

States


Pumping lemma

Initial Stack Symbol

Stack

Stack

stack

head

top

bottom

special symbol

Appears at time 0


The states

The States

Pop

symbol

Input

symbol

Push

symbol


Pumping lemma

input

stack

top

Replace


Pumping lemma

input

stack

top

Push


Pumping lemma

input

stack

top

Pop


Pumping lemma

input

stack

top

No Change


Pumping lemma

Empty Stack

input

stack

empty

Pop

top

The automaton HALTS

No possible transition after


Pumping lemma

A Possible Transition

input

stack

Pop

top


Non determinism

Non-Determinism

PDAs are non-deterministic

Allowed non-deterministic transitions


Example pda

Example PDA

PDA


Pumping lemma

Basic Idea:

  • Push the a’s

  • on the stack

2. Match the b’s on input

with a’s on stack

3. Match

found


Pumping lemma

Input

Stack


Pumping lemma

Input

Stack


Pumping lemma

Input

Stack


Pumping lemma

Input

Stack


Pumping lemma

Input

Stack


Pumping lemma

Input

Stack


Pumping lemma

Input

Stack


Pumping lemma

Input

Stack


Pumping lemma

Input

Stack

accept


Pumping lemma

  • A string is accepted if there is a computation such that:

    • All the input is consumed

    • The last state is an accepting state

    • At the end of the computation,

    • we do not care about the stack contents

    • (the stack can be empty at the last state)


Pumping lemma

is the language accepted by the PDA:


Pumping lemma

reject


Another pda example

Another PDA example


Pumping lemma

  • Push v

  • on stack

3. Match vR on input

with v on stack

2. Guess

middle

of input

4. Match

found


Pumping lemma

Guess the middle

of string


Pumping lemma

accept


Pumping lemma

Rejection Example:

Input


Pumping lemma

Guess the middle

of string


Pumping lemma

There is no possible transition.

Input is not consumed


Pumping lemma

Another computation on same string:


Pumping lemma

final state

is not reached


Another pda example1

Another PDA example

aab

abbb (r)


Pushing strings

Pushing Strings

Pop

symbol

Input

symbol

Push

string


Pumping lemma

Example:

pushed

string

top

Push


Another pda example2

Another PDA example

abbbaa


  • Login