MA/CSSE 474 Theory of Computation

Size: px
Start display at page:

Download "MA/CSSE 474 Theory of Computation"

Transcription

1 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 that we will not have time to do in class, but may be helpful to you anyway. 1

2 Halting It is possible that a PDA may not halt, never finish reading its input. Let = {a} and consider M = L(M) = {a}: (1, a, ) - (2, a, a) - (3,, ) On any other input except a: M will never halt. M will never finish reading its input unless its input is. Nondeterminism and Decisions 1. There are context-free languages for which no deterministic PDA exists. 2. It is possible that a PDA may not halt, not ever finish reading its input. require time that is exponential in the length of its input. 3. There is no PDA minimization algorithm. It is undecidable whether a PDA is minimal. 2

3 Solutions to the Problem For NDFSMs: Convert to deterministic, or Simulate all paths in parallel. For NDPDAs: No general solution. Formal solutions that usually involve changing the grammar. Such as Chomsky or Greibach Normal form. Practical solutions that: Preserve the structure of the grammar, but Only work on a subset of the CFLs. LL(k), LR(k) (compilers course) What About These Variations? In HW, we see that acceptance by "accepting state only" is equivalent to acceptance by empty stack and accepting state. Equivalent In this sense: Given a language L, there is a PDA that accepts L by accepting state and empty stack iff there is a PDA that accepts L by accepting state only. FSM plus FIFO queue (instead of stack)? FSM plus two stacks? 3

4 Closure Theorems for Context-Free Languages The context-free languages are closed under: Union Concatenation Let G 1 = (V 1, 1, R 1, S 1 ), and G 2 = (V 2, 2, R 2, S 2 ) generate languages L 1 and L 2 Kleene star Reverse Formal details on next slides; we will do them informally Closure Under Union Let G 1 = (V 1, 1, R 1, S 1 ), and G 2 = (V 2, 2, R 2, S 2 ). Assume that G 1 and G 2 have disjoint sets of nonterminals, not including S. Let L = L(G 1 ) L(G 2 ). We can show that L is CF by exhibiting a CFG for it: G = (V 1 V 2 {S}, 1 2, R 1 R 2 {S S 1, S S 2 }, S) 4

5 Closure Under Concatenation Let G 1 = (V 1, 1, R 1, S 1 ), and G 2 = (V 2, 2, R 2, S 2 ). Assume that G 1 and G 2 have disjoint sets of nonterminals, not including S. Let L = L(G 1 )L(G 2 ). We can show that L is CF by exhibiting a CFG for it: G = (V 1 V 2 {S}, 1 2, R 1 R 2 {S S 1 S 2 }, S) Closure Under Kleene Star Let G = (V,, R, S 1 ). Assume that G does not have the nonterminal S. Let L = L(G)*. We can show that L is CF by exhibiting a CFG for it: G = (V 1 {S}, 1, R 1 {S, S SS 1 }, S) 5

6 Closure Under Reverse L R = {w * : w = x R for some x L}. Let G = (V,, R, S) be in Chomsky normal form. Every rule in G is of the form X BC or X a, where X, B, and C are elements of V - and a. X a: L(X) = {a}. {a} R = {a}. X BC: L(X) = L(B)L(C). (L(B)L(C)) R = L(C) R L(B) R. Construct, from G, a new grammar G, such that L(G ) = L R : G = (V G, G, R, S G ), where R is constructed as follows: For every rule in G of the form X BC, add to R the rule X CB. For every rule in G of the form X a, add to R the rule X a. Closure Under Intersection The context-free languages are not closed under intersection: The proof is by counterexample. Let: L 1 = {a n b n c m : n, m 0} L 2 = {a m b n c n : n, m 0} /* equal a s and b s. /* equal b s and c s. Both L 1 and L 2 are context-free, since there exist straightforward context-free grammars for them. But now consider: L = L 1 L 2 = {a n b n c n : n 0} Recall: Closed under union but not closed under intersection implies not closed under complement. And we saw a specific example of a CFL whose complement was not CF. 6

7 The Intersection of a Context-Free Language and a Regular Language is Context-Free L = L(M 1 ), a PDA = (K 1,, 1, 1, s 1, A 1 ). R = L(M 2 ), a deterministic FSM = (K 2,,, s 2, A 2 ). We construct a new PDA, M 3, that accepts L R by simulating the parallel execution of M 1 and M 2. M = (K 1 K 2,, 1,, [s 1, s 2 ], A 1 A 2 ). I use square brackets for ordered pairs of Insert into : states from K 1 K 2, to For each rule ((q 1, a, ), (p 1, )) in 1, distinguish them from and each rule ( q 2, a, p 2 ) in, the tuples that are contains (([q 1, q 2 ] a, ), ([p 1, p 2 ], )). part of the notations for transitions in M 1, For each rule ((q 1,, ), (p 1, ) in 1, M 2, and M. and each state q 2 in K 2, contains (([q 1, q 2 ],, ), ([p 1, q 2 ], )). This works because: we can get away with only one stack. The Difference between a Context-Free Language and a Regular Language is Context-Free Theorem: The difference (L 1 L 2 ) between a context-free language L 1 and a regular language L 2 is context-free. Proof: L 1 L 2 = L 1 L 2. If L 2 is regular then so is L 2. If L 1 is context-free, so is L 1 L 2. 7

8 Deterministic PDAs A PDA M is deterministic iff: M contains no pairs of transitions that compete with each other, and Whenever M is in an accepting configuration it has no available moves. / / M can choose between accepting and taking the -transition, so it is not deterministic. Deterministic CFLs (very quick overview without many details) A language L is deterministic context-free iff L$ can be accepted by some deterministic PDA. Why $? Let L = a* {a n b n : n > 0}. 8

9 An NDPDA for L L = a* {a n b n : n > 0}. A DPDA for L$ L = a* {a n b n : n > 0}. 9

10 DCFL Properties (skip the details). The Deterministic CF Languages are closed under complement. The Deterministic CF Languages are not closed under intersection or union. Nondeterministic CFLs Theorem: There exist CLFs that are not deterministic. Proof: By example. Let L = {a i b j c k, i j or j k}. L is CF. If L is DCF then so is: L = L. = {a i b j c k, i, j, k 0 and i = j = k} {w {a, b, c}* : the letters are out of order}. But then so is: L = L a*b*c*. = {a n b n c n, n 0}. But it isn t. So L is CF but not DCF. This simple fact poses a real problem for the designers of efficient context-free parsers. Solution: design a language that is deterministic. LL(k) or LR(k). 10

11 The CFL Hierarchy Context-Free Languages Over a Single-Letter Alphabet Theorem: Any context-free language over a single-letter alphabet is regular. Proof: Requires Parikh s Theorem, which we are skipping 11

12 Algorithms and Decision Procedures for Context-Free Languages Chapter 14 Decision Procedures for CFLs Membership: Given a language L and a string w, is w in L? Two approaches: If L is context-free, then there exists some context-free grammar G that generates it. Try derivations in G and see whether any of them generates w. Problem (later slide): If L is context-free, then there exists some PDA M that accepts it. Run M on w. Problem (later slide): 12

13 Decision Procedures for CFLs Membership: Given a language L and a string w, is w in L? Two approaches: If L is context-free, then there exists some context-free grammar G that generates it. Try derivations in G and see whether any of them generates w. S S T a Try to derive aaa S S T S T Decision Procedures for CFLs Membership: Given a language L and a string w, is w in L? If L is context-free, then there exists some PDA M that accepts it. Run M on w. Problem: 13

14 Using a Grammar decidecflusinggrammar(l: CFL, w: string) = 1. If given a PDA, build G so that L(G) = L(M). 2. If w = then if S G is nullable then accept, else reject. 3. If w then: 3.1 Construct G in Chomsky normal form such that L(G ) = L(G) { }. 3.2 If G' derives w, it does so in steps. Try all derivations in G' of steps. If one of them derives w, accept. Otherwise reject. How many steps (as a function of w ) in the derivation of w from CNF grammar G'? Using a Grammar decidecflusinggrammar(l: CFL, w: string) = 1. If given a PDA, build G so that L(G) = L(M). 2. If w = then if S G is nullable then accept, else reject. 3. If w then: 3.1 Construct G in Chomsky normal form such that L(G ) = L(G) { }. 3.2 If G' derives w, it does so in 2 w - 1 steps. Try all derivations in G' of 2 w - 1 steps. If one of them derives w, accept. Otherwise reject. Alternative O(n 3 ) algorithm: CKY. a.k.a. CYK. 14

15 Membership Using a PDA Recall CFGtoPDAtopdown, which built: M = ({p, q},, V,, p, {q}), where contains: The start-up transition ((p,, ), (q, S)). For each rule X s 1 s 2 s n. in R, the transition ((q,, X), (q, s 1 s 2 s n )). For each character c, the transition ((q, c, c), (q, )). Can we make this work so there are no -transitions? If every transition consumes an input character then M would have to halt after w steps. Put the grammar into Greibach Normal Form: All rules are of the following form: X a γ, where a and γ (V - )*. We can combine pushing the RHS of the production with matching the first character a. Details on p Greibach Normal Form All rules are of the following form: X aa, where a and A (V - )*. No need to push the a and then immediately pop it. So M = ({p, q},, V,, p, {q}), where contains: 1. The start-up transitions: For each rule S cs 2 s n, the transition: ((p, c, ), (q, s 2 s n )). 2. For each rule X cs 2 s n (where c and s 2 through s n are elements of V - ), the transition: ((q, c, X), (q, s 2 s n )) 15

16 A PDA Without -Transitions Must Halt Consider the execution of M on input w: Each individual path of M must halt within w steps. The total number of paths pursued by M must be less than or equal to P = B w, where B is the maximum number of competing transitions from any state in M. The total number of steps that will be executed by all paths of M is bounded by P w. So all paths must eventually halt. Emptiness Given a context-free language L, is L =? decidecflempty(g: context-free grammar) = 1. Let G = removeunproductive(g). 2. If S is not present in G then return True else return False. 16

17 Finiteness Given a context-free language L, is L infinite? decidecflinfinite(g: context-free grammar) = 1. Lexicographically enumerate all strings in * of length greater than b n and less than or equal to b n+1 + b n. 2. If, for any such string w, decidecfl(l, w) returns True then return True. L is infinite. 3. If, for all such strings w, decidecfl(l, w) returns False then return False. L is not infinite. Why these bounds? Some Undecidable Questions about CFLs Is L = *? Is the complement of L context-free? Is L regular? Is L 1 = L 2? Is L 1 L 2? Is L 1 L 2 =? Is L inherently ambiguous? Is G ambiguous? 17

18 Regular and CF Languages Regular Languages regular exprs. or regular grammars = DFSMs recognize minimize FSMs closed under: concatenation union Kleene star complement intersection pumping theorem D = ND Context-Free Languages context-free grammars = NDPDAs parse try to find unambiguous grammars try to reduce nondeterminism in PDAs find efficient parsers closed under: concatenation union Kleene star intersection w/ reg. langs pumping theorem D ND TURING MACHINE INTRO 18

19 Languages and Machines SD D Context-Free Languages Regular Languages reg exps FSMs cfgs PDAs unrestricted grammars Turing Machines Grammars, SD Languages, and Turing Machines L SD Language Unrestricted Grammar Accepts Turing Machine 19

20 Turing Machines (TMs) We want a new kind of automaton: powerful enough to describe all computable things, unlike FSMs and PDAs. simple enough that we can reason formally about it like FSMs and PDAs, unlike real computers. Goal: Be able to prove things about what can and cannot be computed. Turing Machines At each step, the machine must: choose its next state, write on the current square, and move left or right. 20

21 A Formal Definition A (deterministic) Turing machine M is (K,,,, s, H): K is a finite set of states; is the input alphabet, which does not contain ; is the tape alphabet, which must contain and have as a subset. s K is the initial state; H K is the set of halting states; is the transition function: (K - H) to K {, } non-halting tape state tape direction to move state char char (R or L) Notes on the Definition 1. The input tape is infinite in both directions. 2. is a function, not a relation. So this is a definition for deterministic Turing machines. 3. must be defined for all (state, tape symbol) pairs unless the state is a halting state. 4. Turing machines do not necessarily halt (unlike FSM's and most PDAs). Why? To halt, they must enter a halting state. Otherwise they loop. 5. Turing machines generate output, so they can compute functions. 21

22 An Example M takes as input a string in the language: {a i b j, 0 j i}, and adds b s as required to make the number of b s equal the number of a s. The input to M will look like this: The output should be: The Details (ε) 1 22

23 The Details (ε) 2 The Details (ε) 6 23

24 The Details(aa) a a 1 The Details(aa) a a 2 24

25 The Details(aa) $ a 3 The Details(aa) $ a 3 25

26 The Details(aa) $ a # 4 The Details(aa) $ $ # 3 26

27 The Details(aa) $ $ # 3 The Details(aa) $ $ # 3 27

28 The Details(aa) $ $ # # 4 The Details(aa) $ $ # # 4 28

29 The Details(aa) $ $ # # 4 The Details(aa) $ $ # # 4 29

30 The Details(aa) $ $ # # 5 The Details(aa) a $ # # 5 30

31 The Details(aa) a a # # 5 The Details(aa) a a b # 5 31

32 The Details(aa) a a b b 5 The Details(aa) a a b b 6 32

33 The Details (aabb) a a b b 1 The steps are the same as previous example until we read the b; skip to there The Details (aabb) ε, aa, aabb, a, aab, b $ a b b 3 33

34 The Details (aabb) $ a # b 4 The Details (aabb) $ $ # b 3 34

35 The Details (aabb) $ $ # b 3 The Details (aabb) $ $ # # In state 4, go left until we hit a blank 4 35

36 The Details (aabb) ε, aa, aabb, a, aab, b $ $ # # 4 The Details (aabb) $ $ # # 4 36

37 The Details (aabb) $ $ # # 5 The Details (aabb) $ $ # # 5 Go right, replacing $ with a and # with b, then move left, as in the last part of the previous example. 37

38 The Details(aabb) a a b b 6 The Details (aab) a a b 1 You should try this one. 38

39 The Details (b) b 1 In the first step, move right. Then there is no transition in the diagram. But there is an implied transition to a dead state, i.e. a new halting state that does not accept. Notes on Programming The machine has a strong procedural feel, with one phase coming after another. There are common idioms, like scan left until you find a blank There are two common ways to scan back and forth marking things off. Often there is a final phase to fix up the output. Even a very simple machine is a nuisance to write. 39

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

Context-Free and Noncontext-Free Languages

Context-Free and Noncontext-Free Languages Examples: Context-Free and Noncontext-Free Languages a*b* is regular. A n B n = {a n b n : n 0} is context-free but not regular. A n B n C n = {a n b n c n : n 0} is not context-free The Regular and the

More information

Functions on languages:

Functions on languages: MA/CSSE 474 Final Exam Notation and Formulas page Name (turn this in with your exam) Unless specified otherwise, r,s,t,u,v,w,x,y,z are strings over alphabet Σ; while a, b, c, d are individual alphabet

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

Context Free Languages: Decidability of a CFL

Context Free Languages: Decidability of a CFL Theorem 14.1 Context Free Languages: Decidability of a CFL Statement: Given a CFL L and string w, there is a decision procedure that determines whether w L. Proof: By construction. 1. Proof using a grammar

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

Turing Machines. Chapter 17

Turing Machines. Chapter 17 Turing Machines Chapter 17 Languages and Machines SD D Context-Free Languages Regular Languages reg exps FSMs cfgs PDAs unrestricted grammars Turing Machines Grammars, SD Languages, and Turing Machines

More information

CS481F01 Prelim 2 Solutions

CS481F01 Prelim 2 Solutions CS481F01 Prelim 2 Solutions A. Demers 7 Nov 2001 1 (30 pts = 4 pts each part + 2 free points). For this question we use the following notation: x y means x is a prefix of y m k n means m n k For each of

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

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION FORMAL LANGUAGES, AUTOMATA AND COMPUTATION DECIDABILITY ( LECTURE 15) SLIDES FOR 15-453 SPRING 2011 1 / 34 TURING MACHINES-SYNOPSIS The most general model of computation Computations of a TM are described

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

MA/CSSE 474 Theory of Computation

MA/CSSE 474 Theory of Computation MA/CSSE 474 Theory of Computation Bottom-up parsing Pumping Theorem for CFLs Recap: Going One Way Lemma: Each context-free language is accepted by some PDA. Proof (by construction): The idea: Let the stack

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

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

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

CPS 220 Theory of Computation

CPS 220 Theory of Computation CPS 22 Theory of Computation Review - Regular Languages RL - a simple class of languages that can be represented in two ways: 1 Machine description: Finite Automata are machines with a finite number of

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

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

Final exam study sheet for CS3719 Turing machines and decidability.

Final exam study sheet for CS3719 Turing machines and decidability. Final exam study sheet for CS3719 Turing machines and decidability. A Turing machine is a finite automaton with an infinite memory (tape). Formally, a Turing machine is a 6-tuple M = (Q, Σ, Γ, δ, q 0,

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

Theory Bridge Exam Example Questions

Theory Bridge Exam Example Questions Theory Bridge Exam Example Questions Annotated version with some (sometimes rather sketchy) answers and notes. This is a collection of sample theory bridge exam questions. This is just to get some idea

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

CS 301. Lecture 18 Decidable languages. Stephen Checkoway. April 2, 2018

CS 301. Lecture 18 Decidable languages. Stephen Checkoway. April 2, 2018 CS 301 Lecture 18 Decidable languages Stephen Checkoway April 2, 2018 1 / 26 Decidable language Recall, a language A is decidable if there is some TM M that 1 recognizes A (i.e., L(M) = A), and 2 halts

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

DM17. Beregnelighed. Jacob Aae Mikkelsen

DM17. Beregnelighed. Jacob Aae Mikkelsen DM17 Beregnelighed Jacob Aae Mikkelsen January 12, 2007 CONTENTS Contents 1 Introduction 2 1.1 Operations with languages...................... 2 2 Finite Automata 3 2.1 Regular expressions/languages....................

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

Decidability (What, stuff is unsolvable?)

Decidability (What, stuff is unsolvable?) University of Georgia Fall 2014 Outline Decidability Decidable Problems for Regular Languages Decidable Problems for Context Free Languages The Halting Problem Countable and Uncountable Sets Diagonalization

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

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

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

The Unsolvability of the Halting Problem. Chapter 19

The Unsolvability of the Halting Problem. Chapter 19 The Unsolvability of the Halting Problem Chapter 19 Languages and Machines SD D Context-Free Languages Regular Languages reg exps FSMs cfgs PDAs unrestricted grammars Turing Machines D and SD A TM M with

More information

What languages are Turing-decidable? What languages are not Turing-decidable? Is there a language that isn t even Turingrecognizable?

What languages are Turing-decidable? What languages are not Turing-decidable? Is there a language that isn t even Turingrecognizable? } We ll now take a look at Turing Machines at a high level and consider what types of problems can be solved algorithmically and what types can t: What languages are Turing-decidable? What languages are

More information

Part I: Definitions and Properties

Part I: Definitions and Properties Turing Machines Part I: Definitions and Properties Finite State Automata Deterministic Automata (DFSA) M = {Q, Σ, δ, q 0, F} -- Σ = Symbols -- Q = States -- q 0 = Initial State -- F = Accepting States

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

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: 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

Non-context-Free Languages. CS215, Lecture 5 c

Non-context-Free Languages. CS215, Lecture 5 c Non-context-Free Languages CS215, Lecture 5 c 2007 1 The Pumping Lemma Theorem. (Pumping Lemma) Let be context-free. There exists a positive integer divided into five pieces, Proof for for each, and..

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

UNIT-VIII COMPUTABILITY THEORY

UNIT-VIII COMPUTABILITY THEORY CONTEXT SENSITIVE LANGUAGE UNIT-VIII COMPUTABILITY THEORY A Context Sensitive Grammar is a 4-tuple, G = (N, Σ P, S) where: N Set of non terminal symbols Σ Set of terminal symbols S Start symbol of the

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

Computational Models - Lecture 4

Computational Models - Lecture 4 Computational Models - Lecture 4 Regular languages: The Myhill-Nerode Theorem Context-free Grammars Chomsky Normal Form Pumping Lemma for context free languages Non context-free languages: Examples Push

More information

CPSC 421: Tutorial #1

CPSC 421: Tutorial #1 CPSC 421: Tutorial #1 October 14, 2016 Set Theory. 1. Let A be an arbitrary set, and let B = {x A : x / x}. That is, B contains all sets in A that do not contain themselves: For all y, ( ) y B if and only

More information

Homework 8. a b b a b a b. two-way, read/write

Homework 8. a b b a b a b. two-way, read/write Homework 8 309 Homework 8 1. Describe a TM that accepts the set {a n n is a power of 2}. Your description should be at the level of the descriptions in Lecture 29 of the TM that accepts {ww w Σ } and the

More information

Computational Models - Lecture 5 1

Computational Models - Lecture 5 1 Computational Models - Lecture 5 1 Handout Mode Iftach Haitner and Yishay Mansour. Tel Aviv University. April 10/22, 2013 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice

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

CS5371 Theory of Computation. Lecture 12: Computability III (Decidable Languages relating to DFA, NFA, and CFG)

CS5371 Theory of Computation. Lecture 12: Computability III (Decidable Languages relating to DFA, NFA, and CFG) CS5371 Theory of Computation Lecture 12: Computability III (Decidable Languages relating to DFA, NFA, and CFG) Objectives Recall that decidable languages are languages that can be decided by TM (that means,

More information

Solution Scoring: SD Reg exp.: a(a

Solution Scoring: SD Reg exp.: a(a MA/CSSE 474 Exam 3 Winter 2013-14 Name Solution_with explanations Section: 02(3 rd ) 03(4 th ) 1. (28 points) For each of the following statements, circle T or F to indicate whether it is True or False.

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

V Honors Theory of Computation

V Honors Theory of Computation V22.0453-001 Honors Theory of Computation Problem Set 3 Solutions Problem 1 Solution: The class of languages recognized by these machines is the exactly the class of regular languages, thus this TM variant

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

Notes for Comp 497 (Comp 454) Week 10 4/5/05

Notes for Comp 497 (Comp 454) Week 10 4/5/05 Notes for Comp 497 (Comp 454) Week 10 4/5/05 Today look at the last two chapters in Part II. Cohen presents some results concerning context-free languages (CFL) and regular languages (RL) also some decidability

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

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

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

Introduction to Languages and Computation

Introduction to Languages and Computation Introduction to Languages and Computation George Voutsadakis 1 1 Mathematics and Computer Science Lake Superior State University LSSU Math 400 George Voutsadakis (LSSU) Languages and Computation July 2014

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

Theory of Computation (IX) Yijia Chen Fudan University

Theory of Computation (IX) Yijia Chen Fudan University Theory of Computation (IX) Yijia Chen Fudan University Review The Definition of Algorithm Polynomials and their roots A polynomial is a sum of terms, where each term is a product of certain variables and

More information

Context-Free Languages (Pre Lecture)

Context-Free Languages (Pre Lecture) Context-Free Languages (Pre Lecture) Dr. Neil T. Dantam CSCI-561, Colorado School of Mines Fall 2017 Dantam (Mines CSCI-561) Context-Free Languages (Pre Lecture) Fall 2017 1 / 34 Outline Pumping Lemma

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

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

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

Decidability (intro.)

Decidability (intro.) CHAPTER 4 Decidability Contents Decidable Languages decidable problems concerning regular languages decidable problems concerning context-free languages The Halting Problem The diagonalization method The

More information

6.8 The Post Correspondence Problem

6.8 The Post Correspondence Problem 6.8. THE POST CORRESPONDENCE PROBLEM 423 6.8 The Post Correspondence Problem The Post correspondence problem (due to Emil Post) is another undecidable problem that turns out to be a very helpful tool for

More information

CSE 105 THEORY OF COMPUTATION. Spring 2018 review class

CSE 105 THEORY OF COMPUTATION. Spring 2018 review class CSE 105 THEORY OF COMPUTATION Spring 2018 review class Today's learning goals Summarize key concepts, ideas, themes from CSE 105. Approach your final exam studying with confidence. Identify areas to focus

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

Theory & Practice Book. Computer Science & IT. for. Public Sector Exams

Theory & Practice Book. Computer Science & IT. for. Public Sector Exams Theory & Practice Book Computer Science & IT for Public Sector Exams ISRO, DRDO, BARC, BEL, HAL, NTPC, ONGC, BHEL, SAIL, GAIL, MTNL, FCI, ECL, ATC, DMRC, HLL, UPRVNL, CSPEB, OPTCL... Corporate Office:

More information

ECS 120: Theory of Computation UC Davis Phillip Rogaway February 16, Midterm Exam

ECS 120: Theory of Computation UC Davis Phillip Rogaway February 16, Midterm Exam ECS 120: Theory of Computation Handout MT UC Davis Phillip Rogaway February 16, 2012 Midterm Exam Instructions: The exam has six pages, including this cover page, printed out two-sided (no more wasted

More information

CS 154, Lecture 2: Finite Automata, Closure Properties Nondeterminism,

CS 154, Lecture 2: Finite Automata, Closure Properties Nondeterminism, CS 54, Lecture 2: Finite Automata, Closure Properties Nondeterminism, Why so Many Models? Streaming Algorithms 0 42 Deterministic Finite Automata Anatomy of Deterministic Finite Automata transition: for

More information

Notes for Comp 497 (454) Week 10

Notes for Comp 497 (454) Week 10 Notes for Comp 497 (454) Week 10 Today we look at the last two chapters in Part II. Cohen presents some results concerning the two categories of language we have seen so far: Regular languages (RL). Context-free

More information

This lecture covers Chapter 7 of HMU: Properties of CFLs

This lecture covers Chapter 7 of HMU: Properties of CFLs This lecture covers Chapter 7 of HMU: Properties of CFLs Chomsky Normal Form Pumping Lemma for CFs Closure Properties of CFLs Decision Properties of CFLs Additional Reading: Chapter 7 of HMU. Chomsky Normal

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

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 14 Ana Bove May 14th 2018 Recap: Context-free Grammars Simplification of grammars: Elimination of ǫ-productions; Elimination of

More information

CSE 105 Theory of Computation

CSE 105 Theory of Computation CSE 105 Theory of Computation http://www.jflap.org/jflaptmp/ Professor Jeanne Ferrante 1 Today s Agenda Quick Review of CFG s and PDA s Introduction to Turing Machines and their Languages Reminders and

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

Computational Models: Class 5

Computational Models: Class 5 Computational Models: Class 5 Benny Chor School of Computer Science Tel Aviv University March 27, 2019 Based on slides by Maurice Herlihy, Brown University, and modifications by Iftach Haitner and Yishay

More information

Reducability. Sipser, pages

Reducability. Sipser, pages Reducability Sipser, pages 187-214 Reduction Reduction encodes (transforms) one problem as a second problem. A solution to the second, can be transformed into a solution to the first. We expect both transformations

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

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

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

The Post Correspondence Problem

The Post Correspondence Problem The Post Correspondence Problem - Given a set, P of pairs of strings: where t i, b i Σ P = {[ t 1 b 1 ], t 2 b 2 ],, t k b k ]} - Question: Does there exist a sequence i 1, i 2, i n such that: t i1 t i2

More information

Closure Properties of Context-Free Languages. Foundations of Computer Science Theory

Closure Properties of Context-Free Languages. Foundations of Computer Science Theory Closure Properties of Context-Free Languages Foundations of Computer Science Theory Closure Properties of CFLs CFLs are closed under: Union Concatenation Kleene closure Reversal CFLs are not closed under

More information

The View Over The Horizon

The View Over The Horizon The View Over The Horizon enumerable decidable context free regular Context-Free Grammars An example of a context free grammar, G 1 : A 0A1 A B B # Terminology: Each line is a substitution rule or production.

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

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

Computability and Complexity

Computability and Complexity Computability and Complexity Lecture 10 More examples of problems in P Closure properties of the class P The class NP given by Jiri Srba Lecture 10 Computability and Complexity 1/12 Example: Relatively

More information

Testing Emptiness of a CFL. Testing Finiteness of a CFL. Testing Membership in a CFL. CYK Algorithm

Testing Emptiness of a CFL. Testing Finiteness of a CFL. Testing Membership in a CFL. CYK Algorithm Testing Emptiness of a CFL As for regular languages, we really take a representation of some language and ask whether it represents φ Can use either CFG or PDA Our choice, since there are algorithms to

More information

CS5371 Theory of Computation. Lecture 14: Computability V (Prove by Reduction)

CS5371 Theory of Computation. Lecture 14: Computability V (Prove by Reduction) CS5371 Theory of Computation Lecture 14: Computability V (Prove by Reduction) Objectives This lecture shows more undecidable languages Our proof is not based on diagonalization Instead, we reduce the problem

More information

CSE 355 Test 2, Fall 2016

CSE 355 Test 2, Fall 2016 CSE 355 Test 2, Fall 2016 28 October 2016, 8:35-9:25 a.m., LSA 191 Last Name SAMPLE ASU ID 1357924680 First Name(s) Ima Regrading of Midterms If you believe that your grade has not been added up correctly,

More information

Automata & languages. A primer on the Theory of Computation. Laurent Vanbever. ETH Zürich (D-ITET) October,

Automata & languages. A primer on the Theory of Computation. Laurent Vanbever.   ETH Zürich (D-ITET) October, Automata & languages A primer on the Theory of Computation Laurent Vanbever www.vanbever.eu ETH Zürich (D-ITET) October, 19 2017 Part 5 out of 5 Last week was all about Context-Free Languages Context-Free

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

Decision Problems with TM s. Lecture 31: Halting Problem. Universe of discourse. Semi-decidable. Look at following sets: CSCI 81 Spring, 2012

Decision Problems with TM s. Lecture 31: Halting Problem. Universe of discourse. Semi-decidable. Look at following sets: CSCI 81 Spring, 2012 Decision Problems with TM s Look at following sets: Lecture 31: Halting Problem CSCI 81 Spring, 2012 Kim Bruce A TM = { M,w M is a TM and w L(M)} H TM = { M,w M is a TM which halts on input w} TOTAL TM

More information

CS5371 Theory of Computation. Lecture 10: Computability Theory I (Turing Machine)

CS5371 Theory of Computation. Lecture 10: Computability Theory I (Turing Machine) CS537 Theory of Computation Lecture : Computability Theory I (Turing Machine) Objectives Introduce the Turing Machine (TM) Proposed by Alan Turing in 936 finite-state control + infinitely long tape A stronger

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

Computational Theory

Computational Theory Computational Theory Finite Automata and Regular Languages Curtis Larsen Dixie State University Computing and Design Fall 2018 Adapted from notes by Russ Ross Adapted from notes by Harry Lewis Curtis Larsen

More information

Context Free Grammars

Context Free Grammars Automata and Formal Languages Context Free Grammars Sipser pages 101-111 Lecture 11 Tim Sheard 1 Formal Languages 1. Context free languages provide a convenient notation for recursive description of languages.

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/ Today's learning goals Summarize key concepts, ideas, themes from CSE 105. Approach your final exam studying with

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

CS5371 Theory of Computation. Lecture 10: Computability Theory I (Turing Machine)

CS5371 Theory of Computation. Lecture 10: Computability Theory I (Turing Machine) CS537 Theory of Computation Lecture : Computability Theory I (Turing Machine) Objectives Introduce the Turing Machine (TM)? Proposed by Alan Turing in 936 finite-state control + infinitely long tape A

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

CSCC63 Worksheet Turing Machines

CSCC63 Worksheet Turing Machines 1 An Example CSCC63 Worksheet Turing Machines Goal. Design a turing machine, M that accepts only strings of the form {w#w w {0, 1} }. Idea. Describe in words how the machine would work. Read first symbol

More information