Download presentation

Presentation is loading. Please wait.

Published byCandice Rogerson Modified about 1 year ago

2
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 = 0 p 1 p 1 p 0 p. – Clearly s is a member of B and of length at least p. We can show that no matter how we divide s into uvxyz, one of the conditions of the lemma is violated. Pumping lemma, | vxy |<= p, we can only place vxy in the following ways:

3
1.vxy completely falls in the first 0 p –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. 2.vxy falls between 0 p and 1 p –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. 3.vxy completely falls in the first 1 p –Similar to (1), after pumping s, the number of 1s will be greater than the number of 0s, which is a contradiction. 4.vxy falls between 1 p and 1 p –After pumping s, the number of 1s will be greater than the number of 0s, which is a contradiction. 5.vxy completely falls in the second 1 p –This case is same with (3). 6.vxy falls between 1 p and 0 p –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. 7.vxy completely falls in the second 0p –This case is same with (1). Hence, B is not context free.

4
Let L = {w {0; 1}* : w = w R }. (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.

5
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

6
PDA

7
Pumping Lemma Assume that L regular. Let p be the pumping constant given by the pumping lemma. Let s be the string 1 p-1 101 p. s can be split into three pieces, s = xyz, where for any i >= 0 the string xy i z 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 s cannot be pumped. This is a contradiction.

9
Pushdown Automaton -- PDA Input String Stack States

10
Initial Stack Symbol Stack bottomspecial symbol stack head top Appears at time 0

11
The States Input symbol Pop symbol Push symbol

12
top input stack Replace

13
Push top input stack

14
Pop top input stack

15
No Change top input stack

16
Pop top input stack Empty Stack empty The automaton HALTS No possible transition after

17
Pop top input stack A Possible Transition

18
Non-Determinism PDAs are non-deterministic Allowed non-deterministic transitions

19
Example PDA PDA

20
Basic Idea: 1.Push the a’s on the stack 2. Match the b’s on input with a’s on stack 3. Match found

21
Input Stack

22
Input Stack

23
Input Stack

24
Input Stack

25
Input Stack

26
Input Stack

27
Input Stack

28
Input Stack

29
accept Input Stack

30
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)

31
is the language accepted by the PDA:

38
reject

39
Another PDA example

40
1.Push v on stack 2. Guess middle of input 3. Match v R on input with v on stack 4. Match found

44
Guess the middle of string

47
accept

48
Rejection Example: Input

51
Guess the middle of string

53
There is no possible transition. Input is not consumed

54
Another computation on same string:

59
final state is not reached

61
Another PDA example aab abbb (r)

62
Pushing Strings Input symbol Pop symbol Push string

63
top Push pushed string Example:

64
Another PDA example abbbaa

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google