Download presentation

Presentation is loading. Please wait.

Published byMaverick Lemay Modified over 3 years ago

1
Pushdown Automata CPSC 388 Ellen Walker Hiram College

2
PDA = FA + Stack

3
A PDA Transaction Read the next symbol from the input Pop a symbol from the stack Push a symbol on the stack Enter a new state

4
Epsilon in PDA Read epsilon –No character is read, input location stays the same Push or pop epsilon –The stack remains unchanged

5
Format of a Transition Items before ; are “input”, items after ; are “action” ( Current state, Input symbol, Symbol popped ; New state, Symbol pushed )

6
PDA for a n b n Assume initial stack contains “Z” (delimiter for bottom of stack) S1, a, ; S2, a - leave Z on bottom S2, a, ; S2, a - push a for each a S2, b, a ; S3, - pop a for each b S3, b, a ; S3, S3, , Z ; S4, Z- Final state if Z reached

7
PDA Diagram For each state: item read, popped, pushed State transitions using arrows as for FA To check the item on top of the stack, then push an additional item, JFLAP allows a double-push (a, Z, aZ)

8
PDA Diagram for a n b n This PDA requires n≥1. (How can we make it accept n=0?)

9
Formal Definition of PDA A PDA is of the form (S, , , , , F) where –Sis a finite collection of states – is the machine's alphabet – is the finite collection of stack symbols – is the finite collection of transitions of the form (p,s,x; q,y) – (an element of S) is the initial state –F(a subset of S) is the set of accept states

10
Formal Definition of Example States: {q0, q1, q2, q3} Alphabet: {a, b} Stack symbols: {Z, a} Transitions (see slide 6) Initial state: q2 Accept states: {q3}

11
All Strings with Equal # a’s and b’s General idea: –If you see an a If there is a b on the stack, pop it Otherwise, push an a –If you see a b If there is an a on the stack, pop it Otherwise, push a b –At the end of the string, if Z is on top, then accept

12
Build a PDA for each: All strings of the form a m b n, n>m All strings consisting of a’s and b’s with at least 3 more a’s than b’s (Hint: use epsilon-transitions) All palindromes over the alphabet {a,b,c} (Hint: it needs to be nondeterministic)

13
Every RL has a PDA to accept it Given the RL, construct an FA for it. Make a PDA with the same FA that reads the input but ignores the stack –For each FA transition (state1, char; state2) create a pda transition (state1, char, ; state2, )

14
PDA’s are more powerful than FA’s Every FA has an equivalent PDA –Proof by construction on previous slide At least one PDA does not have an equivalent FA –Proof by example: a n b n Therefore the class of languages accepted by PDA’s is a superset of the class of languages accepted by FA’s

15
Deterministic vs. Nondeterministic PDA’s Deterministic PDA’s –Every state/stack combination has exactly one transition –No epsilon-transitions (epsilon for both input and stack symbol) Nondeterministic PDA’s are more powerful than deterministic PDA’s –Example: strings from a*b* that have either twice as many a’s as b’s or 3x as many a’s as b’s

16
Not All Languages are Context Free There is a pumping lemma for Context free languages Similar to RL pumping lemma, but you have to pump in two places Non CFL: a n b n c n (Details are beyond the scope of this course)

Similar presentations

OK

C O N T E X T - F R E E LANGUAGES ( use a grammar to describe a language) 1.

C O N T E X T - F R E E LANGUAGES ( use a grammar to describe a language) 1.

© 2018 SlidePlayer.com Inc.

All rights reserved.

To ensure the functioning of the site, we use **cookies**. We share information about your activities on the site with our partners and Google partners: social networks and companies engaged in advertising and web analytics. For more information, see the Privacy Policy and Google Privacy & Terms.
Your consent to our cookies if you continue to use this website.

Ads by Google

Ppt on switching network definition Elements of one act play ppt on tv Ppt on world mental health day Ppt on latest bluetooth technology Ppt on network security free download Ppt on object oriented programming concepts Ppt on blood stain pattern analysis expiration pattern Ppt on air pressure and wind system Ppt on success and failure quotes Ppt on channels of distribution of pepsi