CS375: Logic and Theory of Computing

Size: px
Start display at page:

Download "CS375: Logic and Theory of Computing"

Transcription

1 CS375: Logic and Theory of Computing Fuhua (Frank) Cheng Department of Computer Science University of Kentucky 1

2 Tale of Contents: Week 1: Preliminaries (set alger relations, functions) (read Chapters 1-4) Weeks 3-6: Regular Languages, Finite Automata (Chapter 11) Weeks 7-9: Context-Free Languages, Pushdown Automata (Chapters 12) Weeks 10-12: Turing Machines (Chapter 13) 2

3 Tale of Contents (conti): Weeks 13-14: Propositional Logic (Chapter 6), Predicate Logic (Chapter 7), Computational Logic (Chapter 9), Algeraic Structures (Chapter 10) 3

4 7. Context-Free Languages & Pushdown Automata- Pushdown Automata Transform an empty-stack PDA to a C-F grammar such that language accepted y the PDA is the same as language generated y the C-F grammar C-F grammar 4

5 Relationship etween accepting and generating: How would a PDA accept a symol a in an input string? B w = a Must have i x (State j could e the same as state i, and B can not e Ʌ ) j How would a CFG generate a string with a symol a in it? Must have w = a B a w1 (B is a non-terminal, w1 is a string of terminals and/or non-terminals ut do not contain and w1 could e Ʌ) 5

6 Relationship etween accepting and generating: How would a PDA accept a symol a in an input string as follows? w = a Must have i B x (State j could e the same as state i, and B can not e Ʌ ) j How would a CFG generate a symol a in an input string as follows? Must have w = a B a (B is a non-terminal) 6

7 Relationship etween accepting and generating: How would a PDA accept a string a c? B w = a c Must have x i j c, B x k (State j could e the same as state i, and B can not e Ʌ ) How would a CFG generate a string a c? w = a c Must have Bik a Bjk (Bik and Bjk are non-terminals, and Bjk could e Ʌ) 7

8 Transform an empty-stack PDA to a C-F grammar Basic idea: Define non-terminals Bij for the CFG that can generate all strings w that: upon reading w on the input tape of the PDA will take you from state i to state j in the PDA and have a net result of ping B off the stack In essence, B is eventually replaced y w It may take many moves to get there. 8

9 Transform an empty-stack PDA to a C-F grammar B (B is removed) i w j B ij w (leftmost derivation) 9

10 Transform an empty-stack PDA to a C-F grammar Type 1: PDA instruction a is the string accepted Grammar Production B ij a B can reach an emptystack status 10

11 Transform an empty-stack PDA to a C-F grammar Type 1: The string accepted PDA instruction Grammar Production B ij a Example:, 1 2 B B 12 a

12 Transform an empty-stack PDA to a C-F grammar Type 2: PDA instruction Grammar Production B ik a B jk for each state k B B accepted string is a followed y whatever is accepted etween state j and state k 12

13 Transform an empty-stack PDA to a C-F grammar PDA instruction Grammar Production B ik ab jk for each state k Example: 1 B nop 2, B 3 c, B 4 B B14 ab24 13 ab 23 13

14 Transform an empty-stack PDA to a C-F grammar Type 3: PDA instruction Grammar Production B il ac jk B kl for each state k and l B C B B 14

15 Transform an empty-stack PDA to a C-F grammar PDA instruction Grammar Production B il ac jk B kl for each state k and l Example: B B C B 1 B Push(C) 2, C 3 c, B 4 B13 a C 23 B14 a C23B34 15

16 Transform an empty-stack PDA to a C-F grammar Type 4: PDA instruction The production that will generate the string accepted y the PDA etween state i and state j Grammar Production S ij for each ( S is start state j symol) Could lead to an empty-stack status 16

17 Transform an empty-stack PDA to a C-F grammar Type 4: PDA instruction Grammar Production S ij for each state j Example: start 1 nop 2 c, 3 S a 23 (Type 2) 17

18 Example. Transform the following empty-stack PDA into a C-F grammar. Solution: Type 4 The start state 0 with on the stack gives: S 01 18

19 Example. Transform the following empty-stack PDA into a C-F grammar. Solution: Type 1 The operation (1,,, 1) gives a 11 19

20 Example. Transform the following empty-stack PDA into a C-F grammar. Solution: Type 1 The operation (1, A,, 1) gives A a 11 20

21 Example. Transform the following empty-stack PDA into a C-F grammar. Solution: Type 2 The nop operation (0, A, nop, 1) gives A01 aa 11 21

22 Example. Transform the following empty-stack PDA into a C-F grammar. Solution: Type 3 The push operation (0,, push(a), 0) gives aa

23 Empty-stack PDA: C-G Grammar: S a A 11 a A 01 aa 11 aa Leftmost derivation S 01 aa aaa aaa 11 aaaa The language accepted y this PDA has one element only: aaaa 23

24 Empty-stack PDA: C-G Grammar: S a A 11 a A aa 01 aa (0, aaa ) (0, aa A) (1, a A) (1, ) Accepted 24 A

25 Example. Find a grammar for the language L = {w { }* na(w) = n(w)} y (1) constructing an empty-stack PDA to accept L and then (2) transforming it into a C-F grammar. Solution: (1) To accept lamda and to reach empty-stack status To ensure # of a s and # of s are the same 25

26 Note the following two PDAs are equivalent: Solution 2 of HW6, #4 26

27 Solution: (1) Consider: aaaaa Accepted Hence, the aove PDA accepts L 27 B A A Stack is empty

28 Solution: (2) PDA Transformed into C - F grammar : S aa B A aaa Type =? B a B B 28

29 Solution: (2) PDA Transformed into C - F grammar : S aa B A aaa Type =? B a B B 29

30 Solution: (2) PDA Transformed into C - F grammar : S A B aa aa a B A B B Type =? 30

31 Solution: (2) PDA Transformed into C - F grammar : S A B aa aa a B A B B Type =? 31

32 Solution: (2) PDA Transformed into C - F grammar : S A B aa aa a B A B B University of Kentucky Type =? 3/22/

33 Solution: (2) PDA Transformed into C - F grammar : S A B aa aa a B A B B 33 Type =?

34 Solution: (2) PDA Transformed into C - F grammar : S A B aa aa a B A B B Type =? 34

35 Solution: (2) PDA Transformed into C - F grammar : S A B aa aa a B A B B Type =? 35

36 Solution: (2) PDA Transformed into C - F grammar S A B aa aa a B A B B : Simplified CFG : S aas BS A aaa B a BB 36

37 Solution: (2) Simplified CFG : S aas BS A aaa B a BB Derivation of aaa : S aas aaaas aaas aaaaas aaaas aaas aaa 37

38 Nondeterministic PDAs are more powerful than deterministic PDAs. An example is to consider the language of even Palindromes (such as: aaaaaa) over { }. A context-free grammar for the language is given y S Λ asa S Left half and right half are symmetric Any PDA to accept the language must make a nondeterministic decision to start comparing the 2nd half of a string with the reverse of the first half. 38

39 Example: consider the following PDA a a, a, Start 0 1 2,, a,,, nop nop nop,, push ( ), push ( ), a push ( ) This non-deterministic PDA accepts the language of even palindromes over { } 39

40 Example: consider the following PDA Why is this an non-deterministic PDA? a a, a, Start 0,, a,,, nop nop nop 1 2,, push ( ), push ( ), a push ( ) 40

41 Example: Does it accept consider even the palindromes following PDA over { }? a a, a, Start 0,, a,,, nop nop nop 1 2,, push ( ), push ( ), a push ( ) Consider (0, a ) If we make a guess here (0, a) (0, a) (0, a) (0, Ʌ a) (1, a) (1, a) (1, a) 41 (1, Ʌ, ) (2, Ʌ, Ʌ)

42 Example: The PDA may consider guess the the following middle wrong: PDA a a, a, Start 0,, a,,, nop nop nop 1 2,, push ( ), push ( ), a push ( ) Consider (0, a ) If the PDA made a guess here (0, a) (0, a) (0, Ʌ a) (1, a) (1, a) 42 It gets stuck here!

43 Example: This PDA can consider only accept the following even palindromes: PDA a a, a, Start 0,, a,,, nop nop nop 1 2,, push ( ), push ( ), a push ( ) Consider (0, aa ) (0, a a) (0, aa) (0, aa) (0, aa) (0, aa) (0, Ʌ, aaa) 43 (1, Ʌ, aaa) It gets stuck here!

44 There is in general no way to translate a nondeterministic PDA (NPDA) into a deterministic one. Indeed, there is no DPDA which recognizes the language of even palindromes. That is why we can say that NPDAs are more powerful than DPDAs. However, we can define a similar language L1 over {, $} which can e recognized y a DPDA: L1 = { w$w R w ϵ { }* } 44

45 Example: consider the following PDA A DPDA for L1: a a, a, Start 0 $, $, a $,,, nop nop nop 1 2,, push ( ), push ( ), a push ( ) Consider (0, a$ ) Is this PDA indeed deterministic? (0, $ a) (0, $ a) (0, $ a) (1, a) (1, a) (1, a) What do you see here? 45 (1, Ʌ, ) (2, Ʌ, Ʌ)

46 Note that 1. Final-state acceptance and empty-stack acceptance are equivalent only for NPDAs 2. Final-state acceptance and empty-stack acceptance are not equivalent for DPDAs. For DPDAs, the class of languages defined y final-state acceptance is igger. Why? 46

47 Recall: The following is a C-F grammar for the language of even palindromes over { } S Λ asa S Using the CFG to PDA algorithm, we can transform the grammar into an empty-stack NPDA as follows: (0,, 0) (0,,,, 0) (0, Λ, S,, 0) (0, Λ, S,, push(a), push(s), push(a), 0) (0, Λ, S,, push(), push(s), push(), 0) 47

48 Question: Is this empty-stack NPDA (0,, 0); (0,,,, 0); (0, Λ, S,, 0); (0, Λ, S,, push(a), push(s), push(a), 0); (0, Λ, S,, push(), push(s), push(), 0) equivalent to the following final-state NPDA? P1 P2 a a, a, Start 0 1, 2,, a, nop nop nop, push ( ), push ( ), a push ( ) 48

49 Question: Or, is this empty-stack PDA P1 a, a,, Start 0,, push (, a),, push (,, ) equivalent to the following final-state PDA? P2 a a, a, Start, push ( ) 0, push ( ) 1, 2,, a, nop nop nop, a push ( ) 49

50 It is easy to see that P1 accepts even palindromes a, a,, Start 0,, push (, a),, push (,, ) Consider (0, a ) (0, Ʌa ) (0, a aa) (0, a) (0, Ʌ a) (0, a) (0, a) (0, Ʌ a) (0, a) (0, a) (0, Ʌ a) (0, a) (0, a) (0, a) (0, Ʌ, Ʌ) Accepted 50 P1

51 P1 can only accept even palindromes a, a,, Start 0,, push (, a),, push (,, ) Consider (0, aa ) (0, Ʌaa ) (0, aa aa) (0, a a) (0, Ʌa a) (0, a aaa) (0, aa) (0, Ʌ aa) (0, aa) (0, aa) (0, Ʌ a) (0, aa) (0, aa) It gets stuck here! 51

52 Since P2 accepts and can only accept even palindromes over { }, P1 and P2 are equivalent. The question then is: can P1 and P2 e transformed to a C-F grammar for the language of even palindromes over { }? S Λ asa S 52

53 How to handle Type 3 PDA instructions for P1: a, a,, Start 0,, push (, a),, push (,, ) Consider the following situation: P1,, push (, a) 0 0 Y a a Y 53 a Y a Y Y

54 How to handle Type 3 PDA instructions for P1: a, a,, Start 0,, push (, a),, push (,, ) Consider the following situation: P1,, push (, a) 0 0 a, a Y a a Y 54 a Y a Y Y

55 How to handle Type 3 PDA instructions for P1: a, a,, Start 0,, push (, a),, push (,, ) Consider the following situation: P1,, push (, a) 0 0 a, a A A 55

56 Summarize: CFGs and PDAs have equivalent expressive powers. More formally,... Theorem. For every CFG G, there is a PDA P such that L(G) = L(P). In addition, for every PDA P, there is a CFG G such that L(P) = L(G). Thus, L is CF iff there is a (non-deterministic) PDA P such that L = L(P). CF languages are exactly those languages that are accepted y (non-deterministic) PDAs. 56

57 Summarize: A CF language is called a deterministic final-state CF language if it can e recognized y a deterministic final-state PDA Even palindromes: not a deterministic final-state CFL a NPDA Start, push ( ) 0, push ( ),, a,,, nop nop nop, a push ( ) 1 2, 57

58 Summarize: L1 over {, $} is a deterministic final-state CFL: L1 = { w$w R w ϵ { }* } a DPDA Start, push ( ) 0, push ( ) $, $, a $,,, nop nop nop, a push ( ) 1 2, 58

59 End of Context-Free Language and Pushdown Automata II 59

CS375: Logic and Theory of Computing

CS375: Logic and Theory of Computing CS375: Logic and Theory of Computing Fuhua (Frank) Cheng Department of Computer Science University of Kentucky 1 Tale of Contents: Week 1: Preliminaries (set algera, relations, functions) (read Chapters

More information

CS375: Logic and Theory of Computing

CS375: Logic and Theory of Computing CS375: Logic and Theory of Computing Fuhua (Frank) Cheng Department of Computer Science University of Kentucky 1 Table of Contents: Week 1: Preliminaries (set algebra, relations, functions) (read Chapters

More information

CS375: Logic and Theory of Computing

CS375: Logic and Theory of Computing CS375: Logic and Theory of Computing Fuhua (Frank) Cheng Department of Computer Science University of Kentucky 1 Table of Contents: Week 1: Preliminaries (set algebra, relations, functions) (read Chapters

More information

Foundations of Informatics: a Bridging Course

Foundations of Informatics: a Bridging Course Foundations of Informatics: a Bridging Course Week 3: Formal Languages and Semantics Thomas Noll Lehrstuhl für Informatik 2 RWTH Aachen University noll@cs.rwth-aachen.de http://www.b-it-center.de/wob/en/view/class211_id948.html

More information

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION CSE 105 THEORY OF COMPUTATION Spring 2017 http://cseweb.ucsd.edu/classes/sp17/cse105-ab/ Review of CFG, CFL, ambiguity What is the language generated by the CFG below: G 1 = ({S,T 1,T 2 }, {0,1,2}, { S

More information

Section: Pushdown Automata

Section: Pushdown Automata Section: Pushdown Automata Ch. 7 - Pushdown Automata ADFA=(Q,Σ,δ,q 0,F) input tape a a b b a b tape head head moves current state 0 1 1 Modify DFA by adding a stack. New machine is called Pushdown Automata

More information

1. Draw a parse tree for the following derivation: S C A C C A b b b b A b b b b B b b b b a A a a b b b b a b a a b b 2. Show on your parse tree u,

1. Draw a parse tree for the following derivation: S C A C C A b b b b A b b b b B b b b b a A a a b b b b a b a a b b 2. Show on your parse tree u, 1. Draw a parse tree for the following derivation: S C A C C A b b b b A b b b b B b b b b a A a a b b b b a b a a b b 2. Show on your parse tree u, v, x, y, z as per the pumping theorem. 3. Prove that

More information

October 6, Equivalence of Pushdown Automata with Context-Free Gramm

October 6, Equivalence of Pushdown Automata with Context-Free Gramm Equivalence of Pushdown Automata with Context-Free Grammar October 6, 2013 Motivation Motivation CFG and PDA are equivalent in power: a CFG generates a context-free language and a PDA recognizes a context-free

More information

Introduction to Formal Languages, Automata and Computability p.1/42

Introduction to Formal Languages, Automata and Computability p.1/42 Introduction to Formal Languages, Automata and Computability Pushdown Automata K. Krithivasan and R. Rama Introduction to Formal Languages, Automata and Computability p.1/42 Introduction We have considered

More information

Homework. Context Free Languages. Announcements. Before We Start. Languages. Plan for today. Final Exam Dates have been announced.

Homework. Context Free Languages. Announcements. Before We Start. Languages. Plan for today. Final Exam Dates have been announced. Homework Context Free Languages PDAs and CFLs Homework #3 returned Homework #4 due today Homework #5 Pg 169 -- Exercise 4 Pg 183 -- Exercise 4c,e,i (use JFLAP) Pg 184 -- Exercise 10 Pg 184 -- Exercise

More information

input tape head moves current state a a

input tape head moves current state a a CPS 140 - Mathematical Foundations of CS Dr. S. Rodger Section: Pushdown Automata (Ch. 3.3-3.4) (handout) Pushdown Automata ADFA=(K,,,q 0,F) input tape a a b b a b tape head head moves current state 0

More information

Harvard CS 121 and CSCI E-207 Lecture 10: CFLs: PDAs, Closure Properties, and Non-CFLs

Harvard CS 121 and CSCI E-207 Lecture 10: CFLs: PDAs, Closure Properties, and Non-CFLs Harvard CS 121 and CSCI E-207 Lecture 10: CFLs: PDAs, Closure Properties, and Non-CFLs Harry Lewis October 8, 2013 Reading: Sipser, pp. 119-128. Pushdown Automata (review) Pushdown Automata = Finite automaton

More information

Pushdown Automata (2015/11/23)

Pushdown Automata (2015/11/23) Chapter 6 Pushdown Automata (2015/11/23) Sagrada Familia, Barcelona, Spain Outline 6.0 Introduction 6.1 Definition of PDA 6.2 The Language of a PDA 6.3 Euivalence of PDA s and CFG s 6.4 Deterministic PDA

More information

60-354, Theory of Computation Fall Asish Mukhopadhyay School of Computer Science University of Windsor

60-354, Theory of Computation Fall Asish Mukhopadhyay School of Computer Science University of Windsor 60-354, Theory of Computation Fall 2013 Asish Mukhopadhyay School of Computer Science University of Windsor Pushdown Automata (PDA) PDA = ε-nfa + stack Acceptance ε-nfa enters a final state or Stack is

More information

Harvard CS 121 and CSCI E-207 Lecture 10: Ambiguity, Pushdown Automata

Harvard CS 121 and CSCI E-207 Lecture 10: Ambiguity, Pushdown Automata Harvard CS 121 and CSCI E-207 Lecture 10: Ambiguity, Pushdown Automata Salil Vadhan October 4, 2012 Reading: Sipser, 2.2. Another example of a CFG (with proof) L = {x {a, b} : x has the same # of a s and

More information

Intro to Theory of Computation

Intro to Theory of Computation Intro to Theory of Computation LECTURE 7 Last time: Proving a language is not regular Pushdown automata (PDAs) Today: Context-free grammars (CFG) Equivalence of CFGs and PDAs Sofya Raskhodnikova 1/31/2016

More information

Pushdown Automata. Notes on Automata and Theory of Computation. Chia-Ping Chen

Pushdown Automata. Notes on Automata and Theory of Computation. Chia-Ping Chen Pushdown Automata Notes on Automata and Theory of Computation Chia-Ping Chen Department of Computer Science and Engineering National Sun Yat-Sen University Kaohsiung, Taiwan ROC Pushdown Automata p. 1

More information

Pushdown automata. Twan van Laarhoven. Institute for Computing and Information Sciences Intelligent Systems Radboud University Nijmegen

Pushdown automata. Twan van Laarhoven. Institute for Computing and Information Sciences Intelligent Systems Radboud University Nijmegen Pushdown automata Twan van Laarhoven Institute for Computing and Information Sciences Intelligent Systems Version: fall 2014 T. van Laarhoven Version: fall 2014 Formal Languages, Grammars and Automata

More information

NPDA, CFG equivalence

NPDA, CFG equivalence NPDA, CFG equivalence Theorem A language L is recognized by a NPDA iff L is described by a CFG. Must prove two directions: ( ) L is recognized by a NPDA implies L is described by a CFG. ( ) L is described

More information

Please give details of your answer. A direct answer without explanation is not counted.

Please give details of your answer. A direct answer without explanation is not counted. Please give details of your answer. A direct answer without explanation is not counted. Your answers must be in English. Please carefully read problem statements. During the exam you are not allowed to

More information

Properties of Context Free Languages

Properties of Context Free Languages 1 Properties of Context Free Languages Pallab Dasgupta, Professor, Dept. of Computer Sc & Engg 2 Theorem: CFLs are closed under concatenation If L 1 and L 2 are CFLs, then L 1 L 2 is a CFL. Proof: 1. Let

More information

CS5371 Theory of Computation. Lecture 9: Automata Theory VII (Pumping Lemma, Non-CFL, DPDA PDA)

CS5371 Theory of Computation. Lecture 9: Automata Theory VII (Pumping Lemma, Non-CFL, DPDA PDA) CS5371 Theory of Computation Lecture 9: Automata Theory VII (Pumping Lemma, Non-CFL, DPDA PDA) Objectives Introduce the Pumping Lemma for CFL Show that some languages are non- CFL Discuss the DPDA, which

More information

CS5371 Theory of Computation. Lecture 7: Automata Theory V (CFG, CFL, CNF)

CS5371 Theory of Computation. Lecture 7: Automata Theory V (CFG, CFL, CNF) CS5371 Theory of Computation Lecture 7: Automata Theory V (CFG, CFL, CNF) Announcement Homework 2 will be given soon (before Tue) Due date: Oct 31 (Tue), before class Midterm: Nov 3, (Fri), first hour

More information

Fundamentele Informatica II

Fundamentele Informatica II Fundamentele Informatica II Answer to selected exercises 5 John C Martin: Introduction to Languages and the Theory of Computation M.M. Bonsangue (and J. Kleijn) Fall 2011 5.1.a (q 0, ab, Z 0 ) (q 1, b,

More information

Accept or reject. Stack

Accept or reject. Stack Pushdown Automata CS351 Just as a DFA was equivalent to a regular expression, we have a similar analogy for the context-free grammar. A pushdown automata (PDA) is equivalent in power to contextfree grammars.

More information

MA/CSSE 474 Theory of Computation

MA/CSSE 474 Theory of Computation MA/CSSE 474 Theory of Computation CFL Hierarchy CFL Decision Problems Your Questions? Previous class days' material Reading Assignments HW 12 or 13 problems Anything else I have included some slides online

More information

UNIT-VI PUSHDOWN AUTOMATA

UNIT-VI PUSHDOWN AUTOMATA Syllabus R09 Regulation UNIT-VI PUSHDOWN AUTOMATA The context free languages have a type of automaton that defined them. This automaton, called a pushdown automaton, is an extension of the nondeterministic

More information

CS Pushdown Automata

CS Pushdown Automata Chap. 6 Pushdown Automata 6.1 Definition of Pushdown Automata Example 6.2 L ww R = {ww R w (0+1) * } Palindromes over {0, 1}. A cfg P 0 1 0P0 1P1. Consider a FA with a stack(= a Pushdown automaton; PDA).

More information

Theory of Computation (IV) Yijia Chen Fudan University

Theory of Computation (IV) Yijia Chen Fudan University Theory of Computation (IV) Yijia Chen Fudan University Review language regular context-free machine DFA/ NFA PDA syntax regular expression context-free grammar Pushdown automata Definition A pushdown automaton

More information

NODIA AND COMPANY. GATE SOLVED PAPER Computer Science Engineering Theory of Computation. Copyright By NODIA & COMPANY

NODIA AND COMPANY. GATE SOLVED PAPER Computer Science Engineering Theory of Computation. Copyright By NODIA & COMPANY No part of this publication may be reproduced or distributed in any form or any means, electronic, mechanical, photocopying, or otherwise without the prior permission of the author. GATE SOLVED PAPER Computer

More information

ÖVNINGSUPPGIFTER I SAMMANHANGSFRIA SPRÅK. 17 april Classrum Edition

ÖVNINGSUPPGIFTER I SAMMANHANGSFRIA SPRÅK. 17 april Classrum Edition ÖVNINGSUPPGIFTER I SAMMANHANGSFRIA SPRÅK 7 april 23 Classrum Edition CONTEXT FREE LANGUAGES & PUSH-DOWN AUTOMATA CONTEXT-FREE GRAMMARS, CFG Problems Sudkamp Problem. (3.2.) Which language generates the

More information

SCHEME FOR INTERNAL ASSESSMENT TEST 3

SCHEME FOR INTERNAL ASSESSMENT TEST 3 SCHEME FOR INTERNAL ASSESSMENT TEST 3 Max Marks: 40 Subject& Code: Automata Theory & Computability (15CS54) Sem: V ISE (A & B) Note: Answer any FIVE full questions, choosing one full question from each

More information

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION CSE 105 THEORY OF COMPUTATION Spring 2016 http://cseweb.ucsd.edu/classes/sp16/cse105-ab/ Today's learning goals Sipser Ch 2 Design a PDA and a CFG for a given language Give informal description for a PDA,

More information

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION CSE 105 THEORY OF COMPUTATION Spring 2016 http://cseweb.ucsd.edu/classes/sp16/cse105-ab/ Today's learning goals Sipser Ch 2 Define push down automata Trace the computation of a push down automaton Design

More information

Einführung in die Computerlinguistik

Einführung in die Computerlinguistik Einführung in die Computerlinguistik Context-Free Grammars (CFG) Laura Kallmeyer Heinrich-Heine-Universität Düsseldorf Summer 2016 1 / 22 CFG (1) Example: Grammar G telescope : Productions: S NP VP NP

More information

Outline. CS21 Decidability and Tractability. Machine view of FA. Machine view of FA. Machine view of FA. Machine view of FA.

Outline. CS21 Decidability and Tractability. Machine view of FA. Machine view of FA. Machine view of FA. Machine view of FA. Outline CS21 Decidability and Tractability Lecture 5 January 16, 219 and Languages equivalence of NPDAs and CFGs non context-free languages January 16, 219 CS21 Lecture 5 1 January 16, 219 CS21 Lecture

More information

Computability and Complexity

Computability and Complexity Computability and Complexity Push-Down Automata CAS 705 Ryszard Janicki Department of Computing and Software McMaster University Hamilton, Ontario, Canada janicki@mcmaster.ca Ryszard Janicki Computability

More information

(pp ) PDAs and CFGs (Sec. 2.2)

(pp ) PDAs and CFGs (Sec. 2.2) (pp. 117-124) PDAs and CFGs (Sec. 2.2) A language is context free iff all strings in L can be generated by some context free grammar Theorem 2.20: L is Context Free iff a PDA accepts it I.e. if L is context

More information

Pushdown Automata. Chapter 12

Pushdown Automata. Chapter 12 Pushdown Automata Chapter 12 Recognizing Context-Free Languages We need a device similar to an FSM except that it needs more power. The insight: Precisely what it needs is a stack, which gives it an unlimited

More information

Pushdown Automata (PDA) The structure and the content of the lecture is based on

Pushdown Automata (PDA) The structure and the content of the lecture is based on Pushdown Automata (PDA) The structure and the content of the lecture is based on http://www.eecs.wsu.edu/~ananth/cpts317/lectures/index.htm 1 Excursion: Previous lecture n Context-free grammar G=(V,T,P,S),

More information

Definition: A grammar G = (V, T, P,S) is a context free grammar (cfg) if all productions in P have the form A x where

Definition: A grammar G = (V, T, P,S) is a context free grammar (cfg) if all productions in P have the form A x where Recitation 11 Notes Context Free Grammars Definition: A grammar G = (V, T, P,S) is a context free grammar (cfg) if all productions in P have the form A x A V, and x (V T)*. Examples Problem 1. Given the

More information

CDM Parsing and Decidability

CDM Parsing and Decidability CDM Parsing and Decidability 1 Parsing Klaus Sutner Carnegie Mellon Universality 65-parsing 2017/12/15 23:17 CFGs and Decidability Pushdown Automata The Recognition Problem 3 What Could Go Wrong? 4 Problem:

More information

Pushdown Automata. Reading: Chapter 6

Pushdown Automata. Reading: Chapter 6 Pushdown Automata Reading: Chapter 6 1 Pushdown Automata (PDA) Informally: A PDA is an NFA-ε with a infinite stack. Transitions are modified to accommodate stack operations. Questions: What is a stack?

More information

Theory of Computation - Module 3

Theory of Computation - Module 3 Theory of Computation - Module 3 Syllabus Context Free Grammar Simplification of CFG- Normal forms-chomsky Normal form and Greibach Normal formpumping lemma for Context free languages- Applications of

More information

CFGs and PDAs are Equivalent. We provide algorithms to convert a CFG to a PDA and vice versa.

CFGs and PDAs are Equivalent. We provide algorithms to convert a CFG to a PDA and vice versa. CFGs and PDAs are Equivalent We provide algorithms to convert a CFG to a PDA and vice versa. CFGs and PDAs are Equivalent We now prove that a language is generated by some CFG if and only if it is accepted

More information

Theory of Computation

Theory of Computation Fall 2002 (YEN) Theory of Computation Midterm Exam. Name:... I.D.#:... 1. (30 pts) True or false (mark O for true ; X for false ). (Score=Max{0, Right- 1 2 Wrong}.) (1) X... If L 1 is regular and L 2 L

More information

Pushdown Automata. Pushdown Automata. Pushdown Automata. Pushdown Automata. Pushdown Automata. Pushdown Automata. The stack

Pushdown Automata. Pushdown Automata. Pushdown Automata. Pushdown Automata. Pushdown Automata. Pushdown Automata. The stack A pushdown automata (PDA) is essentially: An NFA with a stack A move of a PDA will depend upon Current state of the machine Current symbol being read in Current symbol popped off the top of the stack With

More information

(pp ) PDAs and CFGs (Sec. 2.2)

(pp ) PDAs and CFGs (Sec. 2.2) (pp. 117-124) PDAs and CFGs (Sec. 2.2) A language is context free iff all strings in L can be generated by some context free grammar Theorem 2.20: L is Context Free iff a PDA accepts it I.e. if L is context

More information

The Idea of a Pushdown Automaton

The Idea of a Pushdown Automaton Pushdown Automata 5DV037 Fundamentals of Computer Science Umeå University Department of Computing Science Stephen J. Hegner hegner@cs.umu.se http://www.cs.umu.se/~hegner The Idea of a Pushdown Automaton

More information

CISC4090: Theory of Computation

CISC4090: Theory of Computation CISC4090: Theory of Computation Chapter 2 Context-Free Languages Courtesy of Prof. Arthur G. Werschulz Fordham University Department of Computer and Information Sciences Spring, 2014 Overview In Chapter

More information

AC68 FINITE AUTOMATA & FORMULA LANGUAGES DEC 2013

AC68 FINITE AUTOMATA & FORMULA LANGUAGES DEC 2013 Q.2 a. Prove by mathematical induction n 4 4n 2 is divisible by 3 for n 0. Basic step: For n = 0, n 3 n = 0 which is divisible by 3. Induction hypothesis: Let p(n) = n 3 n is divisible by 3. Induction

More information

Automata Theory (2A) Young Won Lim 5/31/18

Automata Theory (2A) Young Won Lim 5/31/18 Automata Theory (2A) Copyright (c) 2018 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later

More information

Introduction to Theory of Computing

Introduction to Theory of Computing CSCI 2670, Fall 2012 Introduction to Theory of Computing Department of Computer Science University of Georgia Athens, GA 30602 Instructor: Liming Cai www.cs.uga.edu/ cai 0 Lecture Note 3 Context-Free Languages

More information

AC68 FINITE AUTOMATA & FORMULA LANGUAGES JUNE 2014

AC68 FINITE AUTOMATA & FORMULA LANGUAGES JUNE 2014 Q.2 a. Show by using Mathematical Induction that n i= 1 i 2 n = ( n + 1) ( 2 n + 1) 6 b. Define language. Let = {0; 1} denote an alphabet. Enumerate five elements of the following languages: (i) Even binary

More information

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY 15-453 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY REVIEW for MIDTERM 1 THURSDAY Feb 6 Midterm 1 will cover everything we have seen so far The PROBLEMS will be from Sipser, Chapters 1, 2, 3 It will be

More information

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska LECTURE 14 SMALL REVIEW FOR FINAL SOME Y/N QUESTIONS Q1 Given Σ =, there is L over Σ Yes: = {e} and L = {e} Σ Q2 There are uncountably

More information

Theory of Computation (Classroom Practice Booklet Solutions)

Theory of Computation (Classroom Practice Booklet Solutions) Theory of Computation (Classroom Practice Booklet Solutions) 1. Finite Automata & Regular Sets 01. Ans: (a) & (c) Sol: (a) The reversal of a regular set is regular as the reversal of a regular expression

More information

CISC 4090 Theory of Computation

CISC 4090 Theory of Computation CISC 4090 Theory of Computation Context-Free Languages and Push Down Automata Professor Daniel Leeds dleeds@fordham.edu JMH 332 Languages: Regular and Beyond Regular: Captured by Regular Operations a b

More information

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION CSE 105 THEORY OF COMPUTATION Spring 2016 http://cseweb.ucsd.edu/classes/sp16/cse105-ab/ Today's learning goals Sipser Ch 3.3, 4.1 State and use the Church-Turing thesis. Give examples of decidable problems.

More information

Context-Free Languages

Context-Free Languages CS:4330 Theory of Computation Spring 2018 Context-Free Languages Pushdown Automata Haniel Barbosa Readings for this lecture Chapter 2 of [Sipser 1996], 3rd edition. Section 2.2. Finite automaton 1 / 13

More information

Section 1 (closed-book) Total points 30

Section 1 (closed-book) Total points 30 CS 454 Theory of Computation Fall 2011 Section 1 (closed-book) Total points 30 1. Which of the following are true? (a) a PDA can always be converted to an equivalent PDA that at each step pops or pushes

More information

Pushdown Automata (Pre Lecture)

Pushdown Automata (Pre Lecture) Pushdown Automata (Pre Lecture) Dr. Neil T. Dantam CSCI-561, Colorado School of Mines Fall 2017 Dantam (Mines CSCI-561) Pushdown Automata (Pre Lecture) Fall 2017 1 / 41 Outline Pushdown Automata Pushdown

More information

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska LECTURE 11 CHAPTER 3 CONTEXT-FREE LANGUAGES 1. Context Free Grammars 2. Pushdown Automata 3. Pushdown automata and context -free

More information

Push-down Automata = FA + Stack

Push-down Automata = FA + Stack Push-down Automata = FA + Stack PDA Definition A push-down automaton M is a tuple M = (Q,, Γ, δ, q0, F) where Q is a finite set of states is the input alphabet (of terminal symbols, terminals) Γ is the

More information

Miscellaneous. Closure Properties Decision Properties

Miscellaneous. Closure Properties Decision Properties Miscellaneous Closure Properties Decision Properties 1 Closure Properties of CFL s CFL s are closed under union, concatenation, and Kleene closure. Also, under reversal, homomorphisms and inverse homomorphisms.

More information

Sheet 1-8 Dr. Mostafa Aref Format By : Mostafa Sayed

Sheet 1-8 Dr. Mostafa Aref Format By : Mostafa Sayed Sheet -8 Dr. Mostafa Aref Format By : Mostafa Sayed 09 Introduction Assignment. For = {a, } a) Write 0 strings of the following languages i) All strings with no more than one a,,, a, a, a, a, a, a, a ii)

More information

COMP-330 Theory of Computation. Fall Prof. Claude Crépeau. Lec. 10 : Context-Free Grammars

COMP-330 Theory of Computation. Fall Prof. Claude Crépeau. Lec. 10 : Context-Free Grammars COMP-330 Theory of Computation Fall 2017 -- Prof. Claude Crépeau Lec. 10 : Context-Free Grammars COMP 330 Fall 2017: Lectures Schedule 1-2. Introduction 1.5. Some basic mathematics 2-3. Deterministic finite

More information

Context Free Languages (CFL) Language Recognizer A device that accepts valid strings. The FA are formalized types of language recognizer.

Context Free Languages (CFL) Language Recognizer A device that accepts valid strings. The FA are formalized types of language recognizer. Context Free Languages (CFL) Language Recognizer A device that accepts valid strings. The FA are formalized types of language recognizer. Language Generator: Context free grammars are language generators,

More information

Rumination on the Formal Definition of DPDA

Rumination on the Formal Definition of DPDA Rumination on the Formal Definition of DPDA In the definition of DPDA, there are some parts that do not agree with our intuition. Let M = (Q, Σ, Γ, δ, q 0, Z 0, F ) be a DPDA. According to the definition,

More information

Theory of Computation Turing Machine and Pushdown Automata

Theory of Computation Turing Machine and Pushdown Automata Theory of Computation Turing Machine and Pushdown Automata 1. What is a Turing Machine? A Turing Machine is an accepting device which accepts the languages (recursively enumerable set) generated by type

More information

Part 4 out of 5 DFA NFA REX. Automata & languages. A primer on the Theory of Computation. Last week, we showed the equivalence of DFA, NFA and REX

Part 4 out of 5 DFA NFA REX. Automata & languages. A primer on the Theory of Computation. Last week, we showed the equivalence of DFA, NFA and REX Automata & languages A primer on the Theory of Computation Laurent Vanbever www.vanbever.eu Part 4 out of 5 ETH Zürich (D-ITET) October, 12 2017 Last week, we showed the equivalence of DFA, NFA and REX

More information

Properties of Context-Free Languages. Closure Properties Decision Properties

Properties of Context-Free Languages. Closure Properties Decision Properties Properties of Context-Free Languages Closure Properties Decision Properties 1 Closure Properties of CFL s CFL s are closed under union, concatenation, and Kleene closure. Also, under reversal, homomorphisms

More information

INSTITUTE OF AERONAUTICAL ENGINEERING

INSTITUTE OF AERONAUTICAL ENGINEERING INSTITUTE OF AERONAUTICAL ENGINEERING DUNDIGAL 500 043, HYDERABAD COMPUTER SCIENCE AND ENGINEERING TUTORIAL QUESTION BANK Course Name : FORMAL LANGUAGES AND AUTOMATA THEORY Course Code : A40509 Class :

More information

PUSHDOWN AUTOMATA (PDA)

PUSHDOWN AUTOMATA (PDA) PUSHDOWN AUTOMATA (PDA) FINITE STATE CONTROL INPUT STACK (Last in, first out) input pop push ε,ε $ 0,ε 0 1,0 ε ε,$ ε 1,0 ε PDA that recognizes L = { 0 n 1 n n 0 } Definition: A (non-deterministic) PDA

More information

5 Context-Free Languages

5 Context-Free Languages CA320: COMPUTABILITY AND COMPLEXITY 1 5 Context-Free Languages 5.1 Context-Free Grammars Context-Free Grammars Context-free languages are specified with a context-free grammar (CFG). Formally, a CFG G

More information

Context-free Languages and Pushdown Automata

Context-free Languages and Pushdown Automata Context-free Languages and Pushdown Automata Finite Automata vs CFLs E.g., {a n b n } CFLs Regular From earlier results: Languages every regular language is a CFL but there are CFLs that are not regular

More information

CS500 Homework #2 Solutions

CS500 Homework #2 Solutions CS500 Homework #2 Solutions 1. Consider the two languages Show that L 1 is context-free but L 2 is not. L 1 = {a i b j c k d l i = j k = l} L 2 = {a i b j c k d l i = k j = l} Answer. L 1 is the concatenation

More information

Automata Theory - Quiz II (Solutions)

Automata Theory - Quiz II (Solutions) Automata Theory - Quiz II (Solutions) K. Subramani LCSEE, West Virginia University, Morgantown, WV {ksmani@csee.wvu.edu} 1 Problems 1. Induction: Let L denote the language of balanced strings over Σ =

More information

CPS 220 Theory of Computation Pushdown Automata (PDA)

CPS 220 Theory of Computation Pushdown Automata (PDA) CPS 220 Theory of Computation Pushdown Automata (PDA) Nondeterministic Finite Automaton with some extra memory Memory is called the stack, accessed in a very restricted way: in a First-In First-Out fashion

More information

Before We Start. The Pumping Lemma. Languages. Context Free Languages. Plan for today. Now our picture looks like. Any questions?

Before We Start. The Pumping Lemma. Languages. Context Free Languages. Plan for today. Now our picture looks like. Any questions? Before We Start The Pumping Lemma Any questions? The Lemma & Decision/ Languages Future Exam Question What is a language? What is a class of languages? Context Free Languages Context Free Languages(CFL)

More information

TAFL 1 (ECS-403) Unit- IV. 4.1 Push Down Automata. 4.2 The Formal Definition of Pushdown Automata. EXAMPLES for PDA. 4.3 The languages of PDA

TAFL 1 (ECS-403) Unit- IV. 4.1 Push Down Automata. 4.2 The Formal Definition of Pushdown Automata. EXAMPLES for PDA. 4.3 The languages of PDA TAFL 1 (ECS-403) Unit- IV 4.1 Push Down Automata 4.2 The Formal Definition of Pushdown Automata EXAMPLES for PDA 4.3 The languages of PDA 4.3.1 Acceptance by final state 4.3.2 Acceptance by empty stack

More information

St.MARTIN S ENGINEERING COLLEGE Dhulapally, Secunderabad

St.MARTIN S ENGINEERING COLLEGE Dhulapally, Secunderabad St.MARTIN S ENGINEERING COLLEGE Dhulapally, Secunderabad-500 014 Subject: FORMAL LANGUAGES AND AUTOMATA THEORY Class : CSE II PART A (SHORT ANSWER QUESTIONS) UNIT- I 1 Explain transition diagram, transition

More information

Undecidable Problems and Reducibility

Undecidable Problems and Reducibility University of Georgia Fall 2014 Reducibility We show a problem decidable/undecidable by reducing it to another problem. One type of reduction: mapping reduction. Definition Let A, B be languages over Σ.

More information

The Pumping Lemma. for all n 0, u 1 v n u 2 L (i.e. u 1 u 2 L, u 1 vu 2 L [but we knew that anyway], u 1 vvu 2 L, u 1 vvvu 2 L, etc.

The Pumping Lemma. for all n 0, u 1 v n u 2 L (i.e. u 1 u 2 L, u 1 vu 2 L [but we knew that anyway], u 1 vvu 2 L, u 1 vvvu 2 L, etc. The Pumping Lemma For every regular language L, there is a number l 1 satisfying the pumping lemma property: All w L with w l can be expressed as a concatenation of three strings, w = u 1 vu 2, where u

More information

Automata and Computability. Solutions to Exercises

Automata and Computability. Solutions to Exercises Automata and Computability Solutions to Exercises Spring 27 Alexis Maciel Department of Computer Science Clarkson University Copyright c 27 Alexis Maciel ii Contents Preface vii Introduction 2 Finite Automata

More information

CS 341 Homework 16 Languages that Are and Are Not Context-Free

CS 341 Homework 16 Languages that Are and Are Not Context-Free CS 341 Homework 16 Languages that Are and Are Not Context-Free 1. Show that the following languages are context-free. You can do this by writing a context free grammar or a PDA, or you can use the closure

More information

Fundamentele Informatica 3 Antwoorden op geselecteerde opgaven uit Hoofdstuk 7 en Hoofdstuk 8

Fundamentele Informatica 3 Antwoorden op geselecteerde opgaven uit Hoofdstuk 7 en Hoofdstuk 8 Fundamentele Informatica 3 Antwoorden op geselecteerde opgaven uit Hoofdstuk 7 en Hoofdstuk 8 John Martin: Introduction to Languages and the Theory of Computation Jetty Kleijn Najaar 2008 7.1 (q 0,bbcbb,Z

More information

Automata and Computability. Solutions to Exercises

Automata and Computability. Solutions to Exercises Automata and Computability Solutions to Exercises Fall 28 Alexis Maciel Department of Computer Science Clarkson University Copyright c 28 Alexis Maciel ii Contents Preface vii Introduction 2 Finite Automata

More information

Theory of Computation

Theory of Computation Theory of Computation Lecture #10 Sarmad Abbasi Virtual University Sarmad Abbasi (Virtual University) Theory of Computation 1 / 43 Lecture 10: Overview Linear Bounded Automata Acceptance Problem for LBAs

More information

Pushdown Automata: Introduction (2)

Pushdown Automata: Introduction (2) Pushdown Automata: Introduction Pushdown automaton (PDA) M = (K, Σ, Γ,, s, A) where K is a set of states Σ is an input alphabet Γ is a set of stack symbols s K is the start state A K is a set of accepting

More information

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018 Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018 Lecture 15 Ana Bove May 17th 2018 Recap: Context-free Languages Chomsky hierarchy: Regular languages are also context-free; Pumping lemma

More information

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET Regular Languages and FA A language is a set of strings over a finite alphabet Σ. All languages are finite or countably infinite. The set of all languages

More information

Harvard CS 121 and CSCI E-207 Lecture 12: General Context-Free Recognition

Harvard CS 121 and CSCI E-207 Lecture 12: General Context-Free Recognition Harvard CS 121 and CSCI E-207 Lecture 12: General Context-Free Recognition Salil Vadhan October 11, 2012 Reading: Sipser, Section 2.3 and Section 2.1 (material on Chomsky Normal Form). Pumping Lemma for

More information

Languages, regular languages, finite automata

Languages, regular languages, finite automata Notes on Computer Theory Last updated: January, 2018 Languages, regular languages, finite automata Content largely taken from Richards [1] and Sipser [2] 1 Languages An alphabet is a finite set of characters,

More information

Note: In any grammar here, the meaning and usage of P (productions) is equivalent to R (rules).

Note: In any grammar here, the meaning and usage of P (productions) is equivalent to R (rules). Note: In any grammar here, the meaning and usage of P (productions) is equivalent to R (rules). 1a) G = ({R, S, T}, {0,1}, P, S) where P is: S R0R R R0R1R R1R0R T T 0T ε (S generates the first 0. R generates

More information

Deterministic PDA s. Deepak D Souza. 08 Nov Department of Computer Science and Automation Indian Institute of Science, Bangalore.

Deterministic PDA s. Deepak D Souza. 08 Nov Department of Computer Science and Automation Indian Institute of Science, Bangalore. Deterministic PDA s Deepak D Souza Department of Computer Science and Automation Indian Institute of Science, Bangalore. 08 Nov 2016 Outline 1 Deterministic PDA s 2 Closure properties of DCFL s 3 Complementing

More information

CpSc 421 Final Exam December 15, 2006

CpSc 421 Final Exam December 15, 2006 CpSc 421 Final Exam December 15, 2006 Do problem zero and six of problems 1 through 9. If you write down solutions for more that six problems, clearly indicate those that you want graded. Note that problems

More information

SYLLABUS. Introduction to Finite Automata, Central Concepts of Automata Theory. CHAPTER - 3 : REGULAR EXPRESSIONS AND LANGUAGES

SYLLABUS. Introduction to Finite Automata, Central Concepts of Automata Theory. CHAPTER - 3 : REGULAR EXPRESSIONS AND LANGUAGES Contents i SYLLABUS UNIT - I CHAPTER - 1 : AUT UTOMA OMATA Introduction to Finite Automata, Central Concepts of Automata Theory. CHAPTER - 2 : FINITE AUT UTOMA OMATA An Informal Picture of Finite Automata,

More information

CS481F01 Solutions 6 PDAS

CS481F01 Solutions 6 PDAS CS481F01 Solutions 6 PDAS A. Demers 2 November 2001 1. Give a NPDAs that recognize the following languages: (a) The set of all strings in {0, 1} that contain twice as many 1s as 0s. (answer a) We build

More information

Ogden s Lemma for CFLs

Ogden s Lemma for CFLs Ogden s Lemma for CFLs Theorem If L is a context-free language, then there exists an integer l such that for any u L with at least l positions marked, u can be written as u = vwxyz such that 1 x and at

More information