Closure Properties of CFLs; Introducing TMs. CS154 Chris Pollett Apr 9, 2007.

Similar documents
Yet More CFLs; Turing Machines. CS154 Chris Pollett Mar 8, 2006.

Theory of Languages and Automata

Theory of Computation, Homework 3 Sample Solution

Theory of Computation p.1/?? Theory of Computation p.2/?? A Turing machine can do everything that any computing

CSE 105 THEORY OF COMPUTATION

ECS 120 Lesson 16 Turing Machines, Pt. 2

Outline. Language Hierarchy

I have read and understand all of the instructions below, and I will obey the Academic Honor Code.

CISC 4090 Theory of Computation

Enumerations and Turing Machines

Actually talking about Turing machines this time

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2016

CSE 105 THEORY OF COMPUTATION

Midterm Exam II CIS 341: Foundations of Computer Science II Spring 2006, day section Prof. Marvin K. Nakayama

CS 44 Exam #2 February 14, 2001

Multiple Choice Questions

CS21 Decidability and Tractability

Theory of Computations Spring 2016 Practice Final Exam Solutions

Theory Bridge Exam Example Questions Version of June 6, 2008

Variants of Turing Machines

Final Course Review. Reading: Chapters 1-9

CSE 105 THEORY OF COMPUTATION

Turing Machines. A transducer is a finite state machine (FST) whose output is a string and not just accept or reject.

CS210 THEORY OF COMPUTATION QUESTION BANK PART -A UNIT- I


Limitations of Algorithmic Solvability In this Chapter we investigate the power of algorithms to solve problems Some can be solved algorithmically and

CSC-461 Exam #2 April 16, 2014

PDA s. and Formal Languages. Automata Theory CS 573. Outline of equivalence of PDA s and CFG s. (see Theorem 5.3)

Decidable Problems. We examine the problems for which there is an algorithm.

Context Free Grammars. CS154 Chris Pollett Mar 1, 2006.

DHANALAKSHMI SRINIVASAN INSTITUTE OF RESEARCH AND TECHNOLOGY SIRUVACHUR, PERAMBALUR DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

CS5371 Theory of Computation. Lecture 8: Automata Theory VI (PDA, PDA = CFG)

TAFL 1 (ECS-403) Unit- V. 5.1 Turing Machine. 5.2 TM as computer of Integer Function

CT32 COMPUTER NETWORKS DEC 2015

From Theorem 8.5, page 223, we have that the intersection of a context-free language with a regular language is context-free. Therefore, the language

R10 SET a) Construct a DFA that accepts an identifier of a C programming language. b) Differentiate between NFA and DFA?

1. Draw the state graphs for the finite automata which accept sets of strings composed of zeros and ones which:

(a) R=01[((10)*+111)*+0]*1 (b) ((01+10)*00)*. [8+8] 4. (a) Find the left most and right most derivations for the word abba in the grammar

Chapter 14: Pushdown Automata

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

UNIT I PART A PART B

More Simulations. CS154 Chris Pollett Apr 25, 2007.

Decision Properties for Context-free Languages

Theory of Computation Dr. Weiss Extra Practice Exam Solutions

QUESTION BANK. Unit 1. Introduction to Finite Automata

Computer Sciences Department

Theory of Computations Spring 2016 Practice Final

Does this program exist? Limits of computability. Does this program exist? A helper function. For example, if the string program is

Formal Languages and Automata

Theory of Computation

Turing Machine as Transducer. Turing Machines. Computation with Turing Machines. Computation with Turing Machines. Computation with Turing Machines

Sets MAT231. Fall Transition to Higher Mathematics. MAT231 (Transition to Higher Math) Sets Fall / 31

More Closure Properties, Algorithms, and the Pumping Lemma. CS154 Chris Pollett Feb 21, 2007.

Ambiguous Grammars and Compactification

CS154 Midterm Examination. May 4, 2010, 2:15-3:30PM

CS6160 Theory of Computation Problem Set 2 Department of Computer Science, University of Virginia

JNTUWORLD. Code No: R

Turing Machines, continued

Lecture 18: Turing Machines

Context-Free Grammars

1. (10 points) Draw the state diagram of the DFA that recognizes the language over Σ = {0, 1}

Regular Languages (14 points) Solution: Problem 1 (6 points) Minimize the following automaton M. Show that the resulting DFA is minimal.

Recursive and Recursively Enumerable Languages

1. [5 points each] True or False. If the question is currently open, write O or Open.

CSE 105 THEORY OF COMPUTATION

Computability and Complexity

CSE 105 THEORY OF COMPUTATION

Context Free Grammars, Parsing, and Amibuity. CS154 Chris Pollett Feb 28, 2007.

CS402 - Theory of Automata Glossary By

QUESTION BANK. Formal Languages and Automata Theory(10CS56)

T.E. (Computer Engineering) (Semester I) Examination, 2013 THEORY OF COMPUTATION (2008 Course)

14.1 Encoding for different models of computation

Limits of Computation p.1/?? Limits of Computation p.2/??

Derivations of a CFG. MACM 300 Formal Languages and Automata. Context-free Grammars. Derivations and parse trees

Name: CS 341 Practice Final Exam. 1 a 20 b 20 c 20 d 20 e 20 f 20 g Total 207

A Characterization of the Chomsky Hierarchy by String Turing Machines

CpSc 421 Final Solutions

where is the transition function, Pushdown Automata is the set of accept states. is the start state, and is the set of states, is the input alphabet,

AUBER (Models of Computation, Languages and Automata) EXERCISES

HKN CS 374 Midterm 1 Review. Tim Klem Noah Mathes Mahir Morshed

PS3 - Comments. Describe precisely the language accepted by this nondeterministic PDA.

University of Nevada, Las Vegas Computer Science 456/656 Fall 2016

Introduction to Computers & Programming

Automata & languages. A primer on the Theory of Computation. The imitation game (2014) Benedict Cumberbatch Alan Turing ( ) Laurent Vanbever

Recursively Enumerable Languages, Turing Machines, and Decidability

(Refer Slide Time: 0:19)

Formal Grammars and Abstract Machines. Sahar Al Seesi

The Turing Machine. Unsolvable Problems. Undecidability. The Church-Turing Thesis (1936) Decision Problem. Decision Problems

Skyup's Media. PART-B 2) Construct a Mealy machine which is equivalent to the Moore machine given in table.

CS/B.Tech/CSE/IT/EVEN/SEM-4/CS-402/ ItIauIafIaAblll~AladUnrtel1ity

Regular Languages and Regular Expressions

Context-Free Languages & Grammars (CFLs & CFGs) Reading: Chapter 5

pp Variants of Turing Machines (Sec. 3.2)

THEORY OF COMPUTATION

CS311 / MATH352 - AUTOMATA AND COMPLEXITY THEORY

Definition 2.8: A CFG is in Chomsky normal form if every rule. only appear on the left-hand side, we allow the rule S ǫ.

Definition: A context-free grammar (CFG) is a 4- tuple. variables = nonterminals, terminals, rules = productions,,

Automata Theory CS S-FR Final Review

AUTOMATA THEORY AND COMPUTABILITY

Learn Smart and Grow with world

Transcription:

Closure Properties of CFLs; Introducing TMs CS154 Chris Pollett Apr 9, 2007.

Outline Closure Properties of Context Free Languages Algorithms for CFLs Introducing Turing Machines

Closure Properties of CFL CFL are closed under union. Proof idea: let G and H with start symbols S and T respectively, be two CFGs for the CFL s we want to take the union of. Make a new grammar with the same alphabet, with the union of the two grammars productions (after renaming) together with the new rules S ->S T where S is the new start variable. CFLs are closed under intersection by regular languages. Proof idea: use the cartesian product construction on a PDA for the CFL together with a DFA for the regular language. CFLs are not closed under intersection or complementation Proof: The languages {a n b n c m n, m 0} and {a m b n c n n, m 0} are bothe contextfree. Their intersection is {a n b n c n n 0} which is not by the pumping lemma. They are not closed under complementation since using demorgan rules, intersection can be defined from union and complementation.

Algorithms for CFLs We have already given an algorithm (CYK) for checking if a string is in a CFLs. We have also given algorithms for checking for useless variables in grammars, as well as, for eliminating λ-rules from grammars. We now claim there is an algorithm, which given a grammar G written down formally as a 4-tuple, can decide whether or not L(G) is empty. To do this, the algorithm check is the start variable is useless. If it is we know the language is empty; otherwise it is not. We also claim that there is an algorithm to check given G whether or not L(G) is infinite. To do this, we first eliminate λ-rules, unit-productions, and useless symbols from G. We then construct a graph where (A,B) is an edge for two variables A,B in the graph iff A-->xBy for some production in G. If there is a cycle in this graph then C=>* ucv for some variable C in the original grammar. As there are no useless symbols in this grammar, we must have C=>*z, for some string z of terminals. Hence, also, S=>* sct =>* szt, S=>* sct =>* sucvt =>* suzvt, etc. Thus, one can argue there is a cycle in the graph iff G s grammar is infinite.

General Models of Computation So far we have looked at machines that either have bounded memory or access to memory limited to stack operations. We would like to consider models of computation which correspond to general purpose computers. In 1936, Alan Turing presented such a general model of a computer now called a Turing Machine. In this model, the machine has a finite control and a arbitrarily long tape of data consisting of squares able to hold one symbol. The machine also has a read head which can read one square at a time. Initially, this tape is blank except for the n first squares under and to the right of the tape head which have the input. The machine in one step is allowed to read what s under its tape head, write a new symbol, move left or right one square and change its state. The machine has special states which cause it to halt. The contents of the tape when these states are entered is the output of the machine. The first actual computer developed for code-breaking during World War II was actually partially based on his model. It turns out this model is actually equivalent to what can be done on modern computers.

Example Let B be the language {w#w w is a string over 0,1}. This language is not context free. A Turing Machine M that could accept this language might operate as follows: On input w: Zig-zag across the tape to the corresponding positions on either side of the # symbol to check whether these positions contain the same symbol. If they do not, or if no # is found do into the reject state. If they have the same symbol change the symbol to a new symbol X. When all the symbols on the left side of the # have been X d out, check if there are any more symbols to the right of the #. If yes reject; if not accept. By accept or reject, I mean we view the halting states as further partitioned into those which are accepting and those which are rejecting and we enter the appropriate kind of halting state.

Formal Definition of Turing Machine A Turing Machine (TM)s a 6-tuple (Q, Σ, Γ, δ, q 0, H) where 1. Q is a finite set of states 2. Σ Γ are respectively the input and tape alphabets. Γ contains a space symbol _ not in Σ. 3. δ:q x Γ --> Q x Γ x {L, R} is the transition function. (JFLAP allows L,R,S where S is stay put) 4. q 0 Q is the start state. 5. H Q is the set of Halting states of the machine A TM receives its input w=w 1 w 2 w n. on the n squares of its tape under and to the right of the tape head. The input is not allowed to contain blanks. The tape has arbitrarily many tape square to he right and to the left of the starting tape head location. Except for the input, the rest of the tape squares have the blank symbol. Once M starts, it follows the rules prescribed by the transition function. A rule (q,a)-->(q,b, L) says in state q reading an a go to state q, write a b in the current square then move the tape head left. (q,a)-->(q,b, R) would say the same thing except moves the tape head right. Computation continues until the machine enters a halt state.

Diagrams and Examples As you can see above, there is a diagrammatic notation for Turing Machines similar to that for PDA and DFAs. The states are drawn as circles; two concentric circles indicates a halt state (the book calls these final states). Each transition is labeled with a triple x;y, D; where x is supposed to be the symbol being read, y is the symbol to write, and D is the direction to move. For example, the above machine when started on a string over the alphabet {a,b} converts it to a string of the same length consisting of only b s, then stops on the rightmost character of the output string.

Configurations, Yields To specify the state of a computation at a given time (i.e., a configuration) one needs to specify the tape contents, the head position, and the current state. To do this it suffices to consider only the non-blank squares. One can use the notation u q v to represent this information. Here u is a string that represents the contents of the tape to the left of the tape head, q is the current state and v is a string consisting of what is under the tape head followed by the non-blank symbols to the right of the tape head. For example, one might have 0011q 7 1100. This says the tape contents are 00111100, the machine is in state q 7, and it is read the third 1 in this string. We say configuration C yields C if the TM can legally go from C to C in one step. For instance, ua q bv yields u q acv if δ(q,b) =(q, c, L).

Accept, Reject, Recognize, Decide The start configuration of M on input w is the configuration q 0 w. An accepting configuration is one in which the state of the configuration is q accept, where q accept is some state in H. A rejecting configuration is one in which the state of the configuration is q reject where q reject is some state in H. A Turing machine M accepts w if a there is a sequence of configurations C 1, C 2,.., C k such that C 1 is the start configuration of M on w; for i between 1 and k-1, C i yields C i+1 and C k is an accept configuration. The collection of strings M accepts is denoted L(M) and is called the language recognized by M. A language is Turing-recognizable if some TM recognizes it. A language is called decidable if there is some TM which halts on all inputs which recognizes it.