A Characterization of the Chomsky Hierarchy by String Turing Machines

Size: px
Start display at page:

Download "A Characterization of the Chomsky Hierarchy by String Turing Machines"

Transcription

1 A Characterization of the Chomsky Hierarchy by String Turing Machines Hans W. Lang University of Applied Sciences, Flensburg, Germany Abstract A string Turing machine is a variant of a Turing machine designed for easy manipulation of strings. In contrast to the standard Turing machine, a string Turing machine can insert and delete squares on the tape. It is easy to see that the models of standard and string Turing machines are equivalent in computing power. However, in case of the string Turing machine, imposing certain restrictions on the allowed actions of the machine exactly yields recognizers for the type-i language classes of the Chomsky hierarchy. Keywords: Turing machine, Chomsky hierarchy 1. Introduction In standard textbooks on formal languages and automata like [1] or [4] the hierarchy of automata corresponding to the Chomsky hierarchy comprises nondeterministic Turing machine, linear bounded automaton, pushdown automaton, and finite automaton. In this paper, a variant of the Turing machine, called string Turing machine, is introduced. A string Turing machine is able to manipulate strings and, especially, to reduce words to the start symbol according to the productions of a grammar. Restrictions of the form of productions correspond in a beautiful way to restrictions of the actions of the string Turing machine. Thus, the Chomsky hierarchy which is based on restrictions to grammars can also be based on restrictions of string Turing machines. In the following, the Chomsky hierarchy of language classes as characterized by certain restricted forms of grammars is revisited. Then, the new characterization by certain restrictions of string Turing machines is introduced. 2. The Chomsky hierarchy The Chomsky hierarchy identifies language classes L 0, L 1, L 2, L 3 where L 0 L 1 L 2 L 3 All the inclusions are proper. The language classes are denoted as type-i languages for i =0, 1, 2, 3. L 1 is also known as the class of context-sensitive languages, L 2 as the class of context-free languages, and L 3 as the class of regular languages, because their languages are generated by context-sensitive, contextfree, and regular grammars, respectively. Definition: A grammar is a tuple G =(V,T,P,S) with V T the alphabet of variables or nonterminal symbols, the alphabet of terminal symbols where V T = ; moreover, let A = V T, P a finite relation with P A + A ; the elements of P are called productions or replacement rules, S V a special variable, the start symbol. The replacement rules are written in the form u v, indicating that the subword u occurring in some word w may be replaced by the subword v. Given a grammar, the words of a language are generated by applying such a sequence of replacements to the start symbol until a word consisting of terminal symbols only is reached. The sequence of replacements is called a derivation of the word. Languages can also be recognized by grammars in the sense that all words that can be reduced to the start symbol belong to the language [3]. Such a reduction

2 is a derivation in opposite direction. The string Turing machine described later makes use of reductions. 3. Special grammars Certain restrictions on the form of the productions of a grammar may or may not restrict its power to generate a language. However, the restriction that P V A requiring that the left side of each production consists of exactly one variable restricts the languages generated by this kind of grammars to the class L 2 which is a proper subset of L 0. It turns out that the following restrictions imposed on the form of the productions of a grammar correspond to the language classes of the Chomsky hierarchy. Observe that each form of the productions is a special case of the preceding one. Type Productions of the form Name 0 u w Recursively enumerable 1 u v with u v Context-sensitive 2 X v Context-free 3 X ay or X a Regular w 0 w 1 w 2 w 3 w 4 w 5 & string cursor control Fig. 1: String Turing machine symbol is moved one position to the left. A blank symbol is inserted and becomes the new cursor symbol. The delete action is shown in Figure 2(b). The cursor symbol is deleted. The prefix of the string left to the cursor is moved one position to the right. Its last symbol becomes the new cursor symbol. I - insert a b c d & a b c d & (a) (b) Fig. 2: (a) Insert and (b) delete action a b c d & D - delete a b d & where u, v A +, w A, X,Y V, a T. If necessary, as an exception the production S ε is allowed to produce the empty word ε. 4. String Turing machine A string Turing machine is a device as shown in Figure 1. It has access to the symbols of a string, one at a time. A cursor points to the current position. The machine can read the symbol at the cursor position (the cursor symbol) and it can overwrite that symbol by some other symbol. It can also move the cursor to the left and to the right. Moreover, a string Turing machine can insert a symbol at the cursor position and it can delete the cursor symbol. Initially, the string consists of an input word enclosed by the special delimiter symbols and &. The string has finite length, however, by inserting symbols it can be made arbitrarily long. The insert action is performed as depicted in Figure 2(a). The prefix of the string including the cursor Formally, a string Turing machine is defined as follows. Definition: A nondeterministic string Turing machine is a tuple M = (Z, E, A, d, q, p) with Z E a finite, non-empty set of states, the input alphabet, A the string alphabet where E A, d q Z the transition relation with d Z A A Z where A = A {L, R, I, D}, the start state, p {, &} the start position. The string alphabet A contains the special symbols, & and the blank symbol ; these symbols do not belong to the input alphabet. The elements of the set {L, R, I, D} do not belong to A, these elements are

3 called cursor actions. At the beginning, the string Turing machine is in its start state, and the cursor points to one of the symbols or & that enclose the input word. An element (s, a, a,s ) of the transition relation is interpreted in the following way. If the string Turing machine is in state s and reads symbol a at the cursor position, it replaces symbol a by symbol a and enters state s. However, if a is not a symbol but one of the cursor actions, the string Turing machine does not overwrite symbol a but performs the corresponding cursor action: move left (L), move right (R), insert (I) or delete (D). The string Turing machine accepts an input word w, if there is a sequence of transitions that deletes its string completely. 5. Equivalence with standard Turing machine A standard Turing machine can simulate a string Turing machine. The standard Turing machine uses as tape alphabet the alphabet A of the string Turing machine plus symbols a for all symbols a in A. It then simulates the insert action as follows. It overwrites the symbol a under its read/write head by the symbol a. Then it moves all symbols to the right of symbol a by one position to the right. It returns to symbol a, overwrites it by a, moves one position to the right and prints a blank symbol. In a similar way, the standard Turing machine simulates the delete action. It overwrites the symbol a under its read/write head by the symbol a. Then it moves left to the first non-blank symbol on its tape and moves all these symbols by one position to the right until it reaches a. All other actions are identical to those of the string Turing machine. The standard Turing machine enters the accepting state when it has deleted all symbols on the tape. A string Turing machine can simulate a standard Turing machine. It performs identical actions as the standard Turing machine, except when it reaches the delimiter symbols or & (which do not belong to the tape alphabet of the standard Turing machine simulated). Then it performs insert actions if it needs space. When the standard Turing machine enters an accepting state and stops, the string Turing machine deletes its string so that it accepts, too. Otherwise, the string Turing machine does not accept, because at least the symbols and & remain. 6. Recognition of languages by string Turing machines Given a grammar G and a nonempty word w as input string, the string Turing machine tries to reduce the word w to the start symbol S of the grammar. It does so by replacing the right side of some production that occurs in w by the corresponding left side in a nondeterministic way. It repeats this procedure until only the start symbol S remains. Finally, it deletes S and the delimiter symbols and & and recognizes the word w. Otherwise, if no such reduction sequence to the start symbol S is possible, it does not recognize the word w. Example: Let G be a grammar with the productions S asbc abc cb Bc bb bb and let the input word be w = aabbcc. The string Turing machine searches nondeterministically for occurrences of right sides of the productions in the input word w. It finds bb, and replaces it with bb, yielding aabbcc. Then it replaces Bc with cb, yielding aabcbc. Then it replaces abc with S, yielding asbc. Finally, it replaces asbc with S and deletes S and the delimiter symbols and &. Thus, it has recognized the word w. When the right side of a production is longer than the left side, the string Turing machine needs to perform delete actions. When the right side is shorter than the left side, it needs to perform insert actions. However, this last case does only occur in type-0 grammars. Thus, any type-1 language is recognizable by a string Turing machine without insert actions.

4 This observation is part of the following hierarchy theorem for string Turing machines. Recall that the cursor actions L, R, I, D denote left move, right move, insert and delete, respectively. Theorem: Any type-0 language is recognizable by a string Turing machine with cursor actions {I, L, R, D}. Any type-1 language is recognizable by a string Turing machine with cursor actions {L, R, D}. Any type-2 language is recognizable by a string Turing machine with cursor actions {R, D}. Any type-3 language is recognizable by a string Turing machine with cursor actions {D}. Proof sketch: The string Turing machine recognizes a word w of a type-0 language by applying reduction steps in a nondeterministic way until it reaches the start symbol S of the grammar, which it subsequently deletes together with the delimiter symbols and &. In the same way, a string Turing machine recognizes a word w of a type-1 language. However, every type-1 language has a monotonic grammar, i.e. a grammar where no right side of a production is shorter than the left side. Thus, each reduction step can be performed without insert actions. Again in the same way, a string Turing machine recognizes a word w of a type-2 language. Every type-2 (context-free) language has a grammar in reverse Greibach normal form, with each production in the form X Y k 1... Y 0 a where k N 0, X, Y 0,..., Y k 1 V and a T. Observe that when k =0the production has the form X a. Recognition of a context-free language is based on such a grammar in reverse Greibach normal form. When processing an input word, the string Turing machine applies a production after each terminal symbol read. It does so by matching and deleting the right side of the production except of the last symbol, which it overwrites by the left side of the production. Cursor actions {R, D} suffice for this. In this way, the string Turing machine simulates a pushdown automaton. The prefix of the string including the cursor position corresponds to the stack of the pushdown automaton. Every type-3 language is generated by a left linear grammar. A string Turing machine with cursor actions {D} starts at the delimiter symbol & and reads the input word from right to left. When reading the first symbol a, it applies some production X a and enters state X. then it reads the next symbol b and applies some production Y Xb and enters state Y, and so on. If it reads the delimiter symbol and is in the state of the start symbol S, it deletes and accepts, otherwise it overwrites with and rejects. It may seem strange that in the case of type-3 languages the string Turing machine processes the input word from right to left. However, if acceptance by empty string is required there is no other choice. Another possibility would have been to define acceptance by final state and to restrict the type-3 cursor actions to {R}. The following example illustrates the way a word of a context-free language is recognized by a string Turing machine. Example: Consider the grammar S Xb XSb X a which is in reverse Greibach normal form. Let w = aabb be the input word. The string Turing machine first reduces each a to X by the production X a yielding the string XXbb. When it reads the first b it chooses production S Xb. It deletes b with the result that X appears at the cursor position. It overwrites X by the left side of the production, S, yielding the string XSb. It then moves the cursor to the right, reads b, and applies the production S XSb. Namely, it deletes b, deletes S, and overwrites X by the left side S. Now it has reduced the input word w to the start symbol S. In order to make sure that the current word is just S, it moves the

5 cursor to the right, deletes the delimiter symbol &, deletes S, and deletes the other delimiter symbol. Since the string is now empty, the string Turing machine accepts the input word. 7. Language classes recognized by string Turing machines We have seen that every type-i language is recognizable by a corresponding type of nondeterministic string Turing machine, which we call type-i string Turing machine. We show now that, vice-versa, any language recognized by a type-i string Turing machine is a type-i language. Theorem: Any language recognized by a type-i string Turing machine is a type-i language (i =0, 1, 2, 3). Proof: We show that a type-i string Turing machine for i =0, 1, 2, 3 can be simulated by a nondeterministic standard Turing machine, linear bounded automaton, pushdown automaton, and finite automaton, respectively. Thus, if a language is recognized, for instance, by a type-2 string Turing machine, it is recognized by a pushdown automaton and therefore is context-free or type-2. For string Turing machines of type i =0, 1 the construction of a corresponding standard Turing machine and linear bounded automaton, respectively, is obvious. We show in detail the construction of a nondeterministic pushdown automaton from a type-2 string Turing machine and a nondeterministic finite automaton from a type-3 string Turing machine. The input alphabet of the pushdown automaton is the same as that of the string Turing machine, the stack alphabet corresponds to the string alphabet, the sets of states are identical, so is the start state. It is assumed that a stack initially contains the delimiter symbol. The transition relation of a pushdown automaton consists of 5-tuples of the form (s, a, h, h,s ) where s is the current state, a is the symbol read, h is the topmost stack symbol that is popped from the stack, h is the symbol pushed to the stack, and s is the next state. Any of a, h, and h may be the empty word ε. We construct the transition relation d of the pushdown automaton from the transition relation d of the string Turing machine in the following way. 1) For all elements (s, a, R, s ) and (s,b,b,s ) of d where b E let (s, b, ε, b, s ) be an element of d. That is, whenever the string Turing machine moves its cursor to the right the pushdown automaton reads the next input symbol b and pushes it to the stack. Moreover, the tuple (s, ε, ε, &,s ) is added; the pushdown automaton may choose this transition when it has read the input completely. 2) For each element (s, a, a,s ) of d with a A let (s, ε, a, a,s ) be an element of d. That is, when the string Turing machine overwrites symbol a by symbol a, the pushdown automaton pops symbol a from the stack and and pushes symbol a to the stack. 3) For each element (s, a, D, s ) of d let (s, ε, a, ε, s ) be an element of d. That is, when the string Turing machine deletes symbol a, the pushdown automaton pops symbol a from the stack. If the string Turing machine processes a word w, then the pushdown automaton processes w in a corresponding way. If and only if the string Turing machine has reduced its string to the empty string and accepts, then the pushdown automaton accepts with empty stack. Thus, the pushdown automaton recognizes the same language. Any language recognized by a pushdown automaton is context-free. Therefore, any language recognized by a type-2 string Turing machine is context-free. A type-3 Turing machine essentially acts like a nondeterministic finite automaton that processes the input word from right to left. Thus, if L is the language accepted by the string Turing machine, then &L R is the language accepted by the nondeterministic finite automaton, where L R is the mirror image of L. Since &L R is regular, so is L R, and so is L, since the mirror image of a regular language is regular.

6 8. Conclusions We have introduced the concept of the string Turing machine as a natural device for recognizing languages. A string Turing machine can recognize a word by applying reduction steps according to the productions of some grammar. Depending of the type of the grammar, a corresponding type of string Turing machine suffices to recognize the language. We have defined type-i string Turing machines for i =0, 1, 2, 3 where each type i is a special case of type i 1 using only a proper subset of the cursor actions {I, L, R, D}. The main result is that the (nondeterministic) type-i string Turing machines correspond exactly to the typei languages of the Chomsky hierarchy. References [1] J.E. Hopcroft, R. Motwani, J.D. Ullman, Automata Theory, Languages, and Computation, 3rd edition, Addison-Wesley, [2] H.R. Lewis, C.H. Papadimitriou, Elements of the Theory of Computation, Prentice Hall, [3] A. Salomaa, Formal Languages, Academic Press, [4] M. Sipser, Introduction to the Theory of Computation, PWS Publishing Company, 1996.

ONE-STACK AUTOMATA AS ACCEPTORS OF CONTEXT-FREE LANGUAGES *

ONE-STACK AUTOMATA AS ACCEPTORS OF CONTEXT-FREE LANGUAGES * ONE-STACK AUTOMATA AS ACCEPTORS OF CONTEXT-FREE LANGUAGES * Pradip Peter Dey, Mohammad Amin, Bhaskar Raj Sinha and Alireza Farahani National University 3678 Aero Court San Diego, CA 92123 {pdey, mamin,

More information

A Note on the Succinctness of Descriptions of Deterministic Languages

A Note on the Succinctness of Descriptions of Deterministic Languages INFORMATION AND CONTROL 32, 139-145 (1976) A Note on the Succinctness of Descriptions of Deterministic Languages LESLIE G. VALIANT Centre for Computer Studies, University of Leeds, Leeds, United Kingdom

More information

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

Regular Languages (14 points) Solution: Problem 1 (6 points) Minimize the following automaton M. Show that the resulting DFA is minimal. Regular Languages (14 points) Problem 1 (6 points) inimize the following automaton Show that the resulting DFA is minimal. Solution: We apply the State Reduction by Set Partitioning algorithm (särskiljandealgoritmen)

More information

CT32 COMPUTER NETWORKS DEC 2015

CT32 COMPUTER NETWORKS DEC 2015 Q.2 a. Using the principle of mathematical induction, prove that (10 (2n-1) +1) is divisible by 11 for all n N (8) Let P(n): (10 (2n-1) +1) is divisible by 11 For n = 1, the given expression becomes (10

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 Sipser Ch 2, 3.1 State and use the Church-Turing thesis. Describe several variants of Turing

More information

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

Turing Machines. A transducer is a finite state machine (FST) whose output is a string and not just accept or reject. Turing Machines Transducers: A transducer is a finite state machine (FST) whose output is a string and not just accept or reject. Each transition of an FST is labeled with two symbols, one designating

More information

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

TAFL 1 (ECS-403) Unit- V. 5.1 Turing Machine. 5.2 TM as computer of Integer Function TAFL 1 (ECS-403) Unit- V 5.1 Turing Machine 5.2 TM as computer of Integer Function 5.2.1 Simulating Turing Machine by Computer 5.2.2 Simulating Computer by Turing Machine 5.3 Universal Turing Machine 5.4

More information

Theory of Computations Spring 2016 Practice Final Exam Solutions

Theory of Computations Spring 2016 Practice Final Exam Solutions 1 of 8 Theory of Computations Spring 2016 Practice Final Exam Solutions Name: Directions: Answer the questions as well as you can. Partial credit will be given, so show your work where appropriate. Try

More information

Theory of Programming Languages COMP360

Theory of Programming Languages COMP360 Theory of Programming Languages COMP360 Sometimes it is the people no one imagines anything of, who do the things that no one can imagine Alan Turing What can be computed? Before people even built computers,

More information

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

Midterm Exam II CIS 341: Foundations of Computer Science II Spring 2006, day section Prof. Marvin K. Nakayama Midterm Exam II CIS 341: Foundations of Computer Science II Spring 2006, day section Prof. Marvin K. Nakayama Print family (or last) name: Print given (or first) name: I have read and understand all of

More information

ECS 120 Lesson 16 Turing Machines, Pt. 2

ECS 120 Lesson 16 Turing Machines, Pt. 2 ECS 120 Lesson 16 Turing Machines, Pt. 2 Oliver Kreylos Friday, May 4th, 2001 In the last lesson, we looked at Turing Machines, their differences to finite state machines and pushdown automata, and their

More information

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,

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, !# #! + Pushdown utomata CS5 ecture Pushdown utomata where pushdown automaton is a 6tuple are finite sets is the set of states is the input alphabet is the stack alphabet is the transition function is

More information

Turing Machine Languages

Turing Machine Languages Turing Machine Languages Based on Chapters 23-24-25 of (Cohen 1997) Introduction A language L over alphabet is called recursively enumerable (r.e.) if there is a Turing Machine T that accepts every word

More information

Limited Automata and Unary Languages

Limited Automata and Unary Languages Limited Automata and Unary Languages Giovanni Pighizzini and Luca Prigioniero Dipartimento di Informatica, Università degli Studi di Milano, Italy {pighizzini,prigioniero}@di.unimi.it Abstract. Limited

More information

Formal languages and computation models

Formal languages and computation models Formal languages and computation models Guy Perrier Bibliography John E. Hopcroft, Rajeev Motwani, Jeffrey D. Ullman - Introduction to Automata Theory, Languages, and Computation - Addison Wesley, 2006.

More information

Finite automata. We have looked at using Lex to build a scanner on the basis of regular expressions.

Finite automata. We have looked at using Lex to build a scanner on the basis of regular expressions. Finite automata We have looked at using Lex to build a scanner on the basis of regular expressions. Now we begin to consider the results from automata theory that make Lex possible. Recall: An alphabet

More information

Decision Properties for Context-free Languages

Decision Properties for Context-free Languages Previously: Decision Properties for Context-free Languages CMPU 240 Language Theory and Computation Fall 2018 Context-free languages Pumping Lemma for CFLs Closure properties for CFLs Today: Assignment

More information

Last lecture CMSC330. This lecture. Finite Automata: States. Finite Automata. Implementing Regular Expressions. Languages. Regular expressions

Last lecture CMSC330. This lecture. Finite Automata: States. Finite Automata. Implementing Regular Expressions. Languages. Regular expressions Last lecture CMSC330 Finite Automata Languages Sets of strings Operations on languages Regular expressions Constants Operators Precedence 1 2 Finite automata States Transitions Examples Types This lecture

More information

Introduction to Computers & Programming

Introduction to Computers & Programming 16.070 Introduction to Computers & Programming Theory of computation 5: Reducibility, Turing machines Prof. Kristina Lundqvist Dept. of Aero/Astro, MIT States and transition function State control A finite

More information

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION CSE 105 THEORY OF COMPUTATION Spring 2018 http://cseweb.ucsd.edu/classes/sp18/cse105-ab/ Today's learning goals Sipser Section 2.2 Define push-down automata informally and formally Trace the computation

More information

Equivalence of NTMs and TMs

Equivalence of NTMs and TMs Equivalence of NTMs and TMs What is a Turing Machine? Similar to a finite automaton, but with unlimited and unrestricted memory. It uses an infinitely long tape as its memory which can be read from and

More information

pp Variants of Turing Machines (Sec. 3.2)

pp Variants of Turing Machines (Sec. 3.2) pp. 176-176-182. Variants of Turing Machines (Sec. 3.2) Remember: a language is Turing recognizable if some TM accepts it. Adding features may simplify programmability but DO NOT affect what a TM can compute.

More information

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION CSE 105 THEORY OF COMPUTATION Fall 2016 http://cseweb.ucsd.edu/classes/fa16/cse105-abc/ Today's learning goals Sipser sec 3.2 Describe several variants of Turing machines and informally explain why they

More information

Turing Machines, continued

Turing Machines, continued Previously: Turing Machines, continued CMPU 240 Language Theory and Computation Fall 2018 Introduce Turing machines Today: Assignment 5 back TM variants, relation to algorithms, history Later Exam 2 due

More information

Chapter 14: Pushdown Automata

Chapter 14: Pushdown Automata Chapter 14: Pushdown Automata Peter Cappello Department of Computer Science University of California, Santa Barbara Santa Barbara, CA 93106 cappello@cs.ucsb.edu The corresponding textbook chapter should

More information

Actually talking about Turing machines this time

Actually talking about Turing machines this time Actually talking about Turing machines this time 10/25/17 (Using slides adapted from the book) Administrivia HW due now (Pumping lemma for context-free languages) HW due Friday (Building TMs) Exam 2 out

More information

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

I have read and understand all of the instructions below, and I will obey the Academic Honor Code. Midterm Exam CS 341-451: Foundations of Computer Science II Fall 2014, elearning section Prof. Marvin K. Nakayama Print family (or last) name: Print given (or first) name: I have read and understand all

More information

Finite Automata. Dr. Nadeem Akhtar. Assistant Professor Department of Computer Science & IT The Islamia University of Bahawalpur

Finite Automata. Dr. Nadeem Akhtar. Assistant Professor Department of Computer Science & IT The Islamia University of Bahawalpur Finite Automata Dr. Nadeem Akhtar Assistant Professor Department of Computer Science & IT The Islamia University of Bahawalpur PhD Laboratory IRISA-UBS University of South Brittany European University

More information

Source of Slides: Introduction to Automata Theory, Languages, and Computation By John E. Hopcroft, Rajeev Motwani and Jeffrey D.

Source of Slides: Introduction to Automata Theory, Languages, and Computation By John E. Hopcroft, Rajeev Motwani and Jeffrey D. Source of Slides: Introduction to Automata Theory, Languages, and Computation By John E. Hopcroft, Rajeev Motwani and Jeffrey D. Ullman And Introduction to Languages and The by J. C. Martin Basic Mathematical

More information

Context Free Languages and Pushdown Automata

Context Free Languages and Pushdown Automata Context Free Languages and Pushdown Automata COMP2600 Formal Methods for Software Engineering Ranald Clouston Australian National University Semester 2, 2013 COMP 2600 Context Free Languages and Pushdown

More information

Theory of Languages and Automata

Theory of Languages and Automata Theory of Languages and Automata Chapter 3- The Church-Turing Thesis Sharif University of Technology Turing Machine O Several models of computing devices Finite automata Pushdown automata O Tasks that

More information

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

Closure Properties of CFLs; Introducing TMs. CS154 Chris Pollett Apr 9, 2007. 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

More information

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

CS5371 Theory of Computation. Lecture 8: Automata Theory VI (PDA, PDA = CFG) CS5371 Theory of Computation Lecture 8: Automata Theory VI (PDA, PDA = CFG) Objectives Introduce Pushdown Automaton (PDA) Show that PDA = CFG In terms of descriptive power Pushdown Automaton (PDA) Roughly

More information

UNIT I PART A PART B

UNIT I PART A PART B OXFORD ENGINEERING COLLEGE (NAAC ACCREDITED WITH B GRADE) DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING LIST OF QUESTIONS YEAR/SEM: III/V STAFF NAME: Dr. Sangeetha Senthilkumar SUB.CODE: CS6503 SUB.NAME:

More information

We can create PDAs with multiple stacks. At each step we look at the current state, the current input symbol, and the top of each stack.

We can create PDAs with multiple stacks. At each step we look at the current state, the current input symbol, and the top of each stack. Other Automata We can create PDAs with multiple stacks. At each step we look at the current state, the current input symbol, and the top of each stack. From all of this information we decide what state

More information

Languages and Compilers

Languages and Compilers Principles of Software Engineering and Operational Systems Languages and Compilers SDAGE: Level I 2012-13 3. Formal Languages, Grammars and Automata Dr Valery Adzhiev vadzhiev@bournemouth.ac.uk Office:

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.2, 3.3 Define variants of TMs Enumerators Multi-tape TMs Nondeterministic TMs

More information

Pushdown Automata. A PDA is an FA together with a stack.

Pushdown Automata. A PDA is an FA together with a stack. Pushdown Automata A PDA is an FA together with a stack. Stacks A stack stores information on the last-in firstout principle. Items are added on top by pushing; items are removed from the top by popping.

More information

Final Course Review. Reading: Chapters 1-9

Final Course Review. Reading: Chapters 1-9 Final Course Review Reading: Chapters 1-9 1 Objectives Introduce concepts in automata theory and theory of computation Identify different formal language classes and their relationships Design grammars

More information

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

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 CSCI 2400 Models of Computation, Section 3 Solutions to Practice Final Exam Here are solutions to the practice final exam. For some problems some details are missing for brevity. You should write complete

More information

Theory and Compiling COMP360

Theory and Compiling COMP360 Theory and Compiling COMP360 It has been said that man is a rational animal. All my life I have been searching for evidence which could support this. Bertrand Russell Reading Read sections 2.1 3.2 in the

More information

Problems, Languages, Machines, Computability, Complexity

Problems, Languages, Machines, Computability, Complexity CS311 Computational Structures Problems, Languages, Machines, Computability, Complexity Lecture 1 Andrew P. Black Andrew Tolmach 1 The Geography Game Could you write a computer program to play the geography

More information

(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

(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 Code No: R05310501 Set No. 1 III B.Tech I Semester Regular Examinations, November 2008 FORMAL LANGUAGES AND AUTOMATA THEORY (Computer Science & Engineering) Time: 3 hours Max Marks: 80 Answer any FIVE

More information

LING/C SC/PSYC 438/538. Lecture 20 Sandiway Fong

LING/C SC/PSYC 438/538. Lecture 20 Sandiway Fong LING/C SC/PSYC 438/538 Lecture 20 Sandiway Fong Today's Topics SWI-Prolog installed? We will start to write grammars today Quick Homework 8 SWI Prolog Cheatsheet At the prompt?- 1. halt. 2. listing. listing(name).

More information

Computer Sciences Department

Computer Sciences Department 1 Reference Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER 3 D E C I D A B I L I T Y 4 Objectives 5 Objectives investigate the power of algorithms to solve problems.

More information

Introduction to Lexing and Parsing

Introduction to Lexing and Parsing Introduction to Lexing and Parsing ECE 351: Compilers Jon Eyolfson University of Waterloo June 18, 2012 1 Riddle Me This, Riddle Me That What is a compiler? 1 Riddle Me This, Riddle Me That What is a compiler?

More information

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

CS6160 Theory of Computation Problem Set 2 Department of Computer Science, University of Virginia CS6160 Theory of Computation Problem Set 2 Department of Computer Science, University of Virginia Gabriel Robins Please start solving these problems immediately, and work in study groups. Please prove

More information

CS402 - Theory of Automata Glossary By

CS402 - Theory of Automata Glossary By CS402 - Theory of Automata Glossary By Acyclic Graph : A directed graph is said to be acyclic if it contains no cycles. Algorithm : A detailed and unambiguous sequence of instructions that describes how

More information

1 Parsing (25 pts, 5 each)

1 Parsing (25 pts, 5 each) CSC173 FLAT 2014 ANSWERS AND FFQ 30 September 2014 Please write your name on the bluebook. You may use two sides of handwritten notes. Perfect score is 75 points out of 85 possible. Stay cool and please

More information

JNTUWORLD. Code No: R

JNTUWORLD. Code No: R Code No: R09220504 R09 SET-1 B.Tech II Year - II Semester Examinations, April-May, 2012 FORMAL LANGUAGES AND AUTOMATA THEORY (Computer Science and Engineering) Time: 3 hours Max. Marks: 75 Answer any five

More information

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

Context-Free Languages & Grammars (CFLs & CFGs) Reading: Chapter 5 Context-Free Languages & Grammars (CFLs & CFGs) Reading: Chapter 5 1 Not all languages are regular So what happens to the languages which are not regular? Can we still come up with a language recognizer?

More information

Theory of Computations Spring 2016 Practice Final

Theory of Computations Spring 2016 Practice Final 1 of 6 Theory of Computations Spring 2016 Practice Final 1. True/False questions: For each part, circle either True or False. (23 points: 1 points each) a. A TM can compute anything a desktop PC can, although

More information

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

PDA s. and Formal Languages. Automata Theory CS 573. Outline of equivalence of PDA s and CFG s. (see Theorem 5.3) CS 573 Automata Theory and Formal Languages Professor Leslie Lander Lecture # 20 November 13, 2000 Greibach Normal Form (GNF) Sheila Greibach s normal form (GNF) for a CFG is one where EVERY production

More information

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

Decidable Problems. We examine the problems for which there is an algorithm. Decidable Problems We examine the problems for which there is an algorithm. Decidable Problems A problem asks a yes/no question about some input. The problem is decidable if there is a program that always

More information

Universal Turing Machine Chomsky Hierarchy Decidability Reducibility Uncomputable Functions Rice s Theorem Decidability Continued

Universal Turing Machine Chomsky Hierarchy Decidability Reducibility Uncomputable Functions Rice s Theorem Decidability Continued CD5080 AUBER odels of Computation, anguages and Automata ecture 14 älardalen University Content Universal Turing achine Chomsky Hierarchy Decidability Reducibility Uncomputable Functions Rice s Decidability

More information

Theory of Computation, Homework 3 Sample Solution

Theory of Computation, Homework 3 Sample Solution Theory of Computation, Homework 3 Sample Solution 3.8 b.) The following machine M will do: M = "On input string : 1. Scan the tape and mark the first 1 which has not been marked. If no unmarked 1 is found,

More information

Multiple Choice Questions

Multiple Choice Questions Techno India Batanagar Computer Science and Engineering Model Questions Subject Name: Formal Language and Automata Theory Subject Code: CS 402 Multiple Choice Questions 1. The basic limitation of an FSM

More information

FAdo: Interactive Tools for Learning Formal Computational Models

FAdo: Interactive Tools for Learning Formal Computational Models FAdo: Interactive Tools for Learning Formal Computational Models Rogério Reis Nelma Moreira DCC-FC& LIACC, Universidade do Porto R. do Campo Alegre 823, 4150 Porto, Portugal {rvr,nam}@ncc.up.pt Abstract

More information

Regular Languages and Regular Expressions

Regular Languages and Regular Expressions Regular Languages and Regular Expressions According to our definition, a language is regular if there exists a finite state automaton that accepts it. Therefore every regular language can be described

More information

MIT Specifying Languages with Regular Expressions and Context-Free Grammars

MIT Specifying Languages with Regular Expressions and Context-Free Grammars MIT 6.035 Specifying Languages with Regular essions and Context-Free Grammars Martin Rinard Laboratory for Computer Science Massachusetts Institute of Technology Language Definition Problem How to precisely

More information

Theory of Computation Dr. Weiss Extra Practice Exam Solutions

Theory of Computation Dr. Weiss Extra Practice Exam Solutions Name: of 7 Theory of Computation Dr. Weiss Extra Practice Exam Solutions Directions: Answer the questions as well as you can. Partial credit will be given, so show your work where appropriate. Try to be

More information

Recursively Enumerable Languages, Turing Machines, and Decidability

Recursively Enumerable Languages, Turing Machines, and Decidability Recursively Enumerable Languages, Turing Machines, and Decidability 1 Problem Reduction: Basic Concepts and Analogies The concept of problem reduction is simple at a high level. You simply take an algorithm

More information

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

Definition: A context-free grammar (CFG) is a 4- tuple. variables = nonterminals, terminals, rules = productions,, CMPSCI 601: Recall From Last Time Lecture 5 Definition: A context-free grammar (CFG) is a 4- tuple, variables = nonterminals, terminals, rules = productions,,, are all finite. 1 ( ) $ Pumping Lemma for

More information

Introduction to the Theory of Computation, Sipser, PWS, ISBN X, 1996

Introduction to the Theory of Computation, Sipser, PWS, ISBN X, 1996 CA320: COMPUTABILITY AND COMPLEXITY 1 1 Introduction CA320 Computability and Complexity Lecturer: Office: L2.55 Phone: 5017 Email: hamilton@computing.dcu.ie WWW: http://www.computing.dcu.ie/ hamilton Course

More information

THEORY OF COMPUTATION

THEORY OF COMPUTATION THEORY OF COMPUTATION UNIT-1 INTRODUCTION Overview This chapter begins with an overview of those areas in the theory of computation that are basic foundation of learning TOC. This unit covers the introduction

More information

Theory Bridge Exam Example Questions Version of June 6, 2008

Theory Bridge Exam Example Questions Version of June 6, 2008 Theory Bridge Exam Example Questions Version of June 6, 2008 This is a collection of sample theory bridge exam questions. This is just to get some idea of the format of the bridge exam and the level of

More information

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

Limitations of Algorithmic Solvability In this Chapter we investigate the power of algorithms to solve problems Some can be solved algorithmically and Computer Language Theory Chapter 4: Decidability 1 Limitations of Algorithmic Solvability In this Chapter we investigate the power of algorithms to solve problems Some can be solved algorithmically and

More information

LLparse and LRparse: Visual and Interactive Tools for Parsing

LLparse and LRparse: Visual and Interactive Tools for Parsing LLparse and LRparse: Visual and Interactive Tools for Parsing Stephen A. Blythe, Michael C. James, and Susan H. Rodger 1 Department of Computer Science Rensselaer Polytechnic Institute Troy, NY 12180-3590

More information

Variants of Turing Machines

Variants of Turing Machines November 4, 2013 Robustness Robustness Robustness of a mathematical object (such as proof, definition, algorithm, method, etc.) is measured by its invariance to certain changes Robustness Robustness of

More information

Compiler Construction

Compiler Construction Compiler Construction Exercises 1 Review of some Topics in Formal Languages 1. (a) Prove that two words x, y commute (i.e., satisfy xy = yx) if and only if there exists a word w such that x = w m, y =

More information

Reflection in the Chomsky Hierarchy

Reflection in the Chomsky Hierarchy Reflection in the Chomsky Hierarchy Henk Barendregt Venanzio Capretta Dexter Kozen 1 Introduction We investigate which classes of formal languages in the Chomsky hierarchy are reflexive, that is, contain

More information

Lexical Analysis - 2

Lexical Analysis - 2 Lexical Analysis - 2 More regular expressions Finite Automata NFAs and DFAs Scanners JLex - a scanner generator 1 Regular Expressions in JLex Symbol - Meaning. Matches a single character (not newline)

More information

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

1. Draw the state graphs for the finite automata which accept sets of strings composed of zeros and ones which: P R O B L E M S Finite Autom ata. Draw the state graphs for the finite automata which accept sets of strings composed of zeros and ones which: a) Are a multiple of three in length. b) End with the string

More information

CS21 Decidability and Tractability

CS21 Decidability and Tractability CS21 Decidability and Tractability Lecture 9 January 26, 2018 Outline Turing Machines and variants multitape TMs nondeterministic TMs Church-Turing Thesis decidable, RE, co-re languages Deciding and Recognizing

More information

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

Skyup's Media. PART-B 2) Construct a Mealy machine which is equivalent to the Moore machine given in table. Code No: XXXXX JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY, HYDERABAD B.Tech II Year I Semester Examinations (Common to CSE and IT) Note: This question paper contains two parts A and B. Part A is compulsory

More information

MIT Specifying Languages with Regular Expressions and Context-Free Grammars. Martin Rinard Massachusetts Institute of Technology

MIT Specifying Languages with Regular Expressions and Context-Free Grammars. Martin Rinard Massachusetts Institute of Technology MIT 6.035 Specifying Languages with Regular essions and Context-Free Grammars Martin Rinard Massachusetts Institute of Technology Language Definition Problem How to precisely define language Layered structure

More information

We show that the composite function h, h(x) = g(f(x)) is a reduction h: A m C.

We show that the composite function h, h(x) = g(f(x)) is a reduction h: A m C. 219 Lemma J For all languages A, B, C the following hold i. A m A, (reflexive) ii. if A m B and B m C, then A m C, (transitive) iii. if A m B and B is Turing-recognizable, then so is A, and iv. if A m

More information

A Formal Study of Practical Regular Expressions

A Formal Study of Practical Regular Expressions International Journal of Foundations of Computer Science c World Scientific Publishing Company A Formal Study of Practical Regular Expressions Cezar Câmpeanu Department of Mathematics and Computer Science,

More information

Formal Languages and Automata

Formal Languages and Automata Mobile Computing and Software Engineering p. 1/3 Formal Languages and Automata Chapter 3 Regular languages and Regular Grammars Chuan-Ming Liu cmliu@csie.ntut.edu.tw Department of Computer Science and

More information

Theory of Computation

Theory of Computation Theory of Computation For Computer Science & Information Technology By www.thegateacademy.com Syllabus Syllabus for Theory of Computation Regular Expressions and Finite Automata, Context-Free Grammar s

More information

Structure of a Compiler: Scanner reads a source, character by character, extracting lexemes that are then represented by tokens.

Structure of a Compiler: Scanner reads a source, character by character, extracting lexemes that are then represented by tokens. CS 441 Fall 2018 Notes Compiler - software that translates a program written in a source file into a program stored in a target file, reporting errors when found. Source Target program written in a High

More information

Learn Smart and Grow with world

Learn Smart and Grow with world Learn Smart and Grow with world All Department Smart Study Materials Available Smartkalvi.com TABLE OF CONTENTS S.No DATE TOPIC PAGE NO. UNIT-I FINITE AUTOMATA 1 Introduction 1 2 Basic Mathematical Notation

More information

6.045J/18.400J: Automata, Computability and Complexity. Practice Quiz 2

6.045J/18.400J: Automata, Computability and Complexity. Practice Quiz 2 6.045J/18.400J: Automata, omputability and omplexity March 21, 2007 Practice Quiz 2 Prof. Nancy Lynch Elena Grigorescu Please write your name in the upper corner of each page. INFORMATION ABOUT QUIZ 2:

More information

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

Limits of Computation p.1/?? Limits of Computation p.2/?? Context-Free Grammars (CFG) There are languages, such as {0 n 1 n n 0} that cannot be described (specified) by finite automata or regular expressions. Context-free grammars provide a more powerful mechanism

More information

TOPIC PAGE NO. UNIT-I FINITE AUTOMATA

TOPIC PAGE NO. UNIT-I FINITE AUTOMATA TABLE OF CONTENTS SNo DATE TOPIC PAGE NO UNIT-I FINITE AUTOMATA 1 Introduction 1 2 Basic Mathematical Notation Techniques 3 3 Finite State systems 4 4 Basic Definitions 6 5 Finite Automaton 7 6 DFA NDFA

More information

LECTURE NOTES THEORY OF COMPUTATION

LECTURE NOTES THEORY OF COMPUTATION LECTURE NOTES ON THEORY OF COMPUTATION P Anjaiah Assistant Professor Ms. B Ramyasree Assistant Professor Ms. E Umashankari Assistant Professor Ms. A Jayanthi Assistant Professor INSTITUTE OF AERONAUTICAL

More information

Outline. Language Hierarchy

Outline. Language Hierarchy Outline Language Hierarchy Definition of Turing Machine TM Variants and Equivalence Decidability Reducibility Language Hierarchy Regular: finite memory CFG/PDA: infinite memory but in stack space TM: infinite

More information

Optimizing Finite Automata

Optimizing Finite Automata Optimizing Finite Automata We can improve the DFA created by MakeDeterministic. Sometimes a DFA will have more states than necessary. For every DFA there is a unique smallest equivalent DFA (fewest states

More information

lec3:nondeterministic finite state automata

lec3:nondeterministic finite state automata lec3:nondeterministic finite state automata 1 1.introduction Nondeterminism is a useful concept that has great impact on the theory of computation. When the machine is in a given state and reads the next

More information

Specifying Syntax COMP360

Specifying Syntax COMP360 Specifying Syntax COMP360 The most important thing in the programming language is the name. A language will not succeed without a good name. I have recently invented a very good name and now I am looking

More information

Introduction to Automata Theory. BİL405 - Automata Theory and Formal Languages 1

Introduction to Automata Theory. BİL405 - Automata Theory and Formal Languages 1 Introduction to Automata Theory BİL405 - Automata Theory and Formal Languages 1 Automata, Computability and Complexity Automata, Computability and Complexity are linked by the question: What are the fundamental

More information

LECTURE NOTES THEORY OF COMPUTATION

LECTURE NOTES THEORY OF COMPUTATION LECTURE NOTES ON THEORY OF COMPUTATION Dr. K Rajendra Prasad Professor Ms. N Mamtha Assistant Professor Ms. S Swarajya Lakshmi Assistant Professor Mr. D Abdulla Assistant Professor INSTITUTE OF AERONAUTICAL

More information

Welcome to MTH401A!! Theory of Computation

Welcome to MTH401A!! Theory of Computation Welcome to MTH401A!! Theory of Computation Contact Information Instructor : Office : 327, Faculty Building Phone : 7880 or 0512-259-7880 Email : akasha@iitk.ac.in Web : www.home.iitk.ac.in/~akasha Office

More information

Model checking pushdown systems

Model checking pushdown systems Model checking pushdown systems R. Ramanujam Institute of Mathematical Sciences, Chennai jam@imsc.res.in Update Meeting, IIT-Guwahati, 4 July 2006 p. 1 Sources of unboundedness Data manipulation: integers,

More information

Pumping Visibly Pushdown Languages

Pumping Visibly Pushdown Languages Pumping Visibly Pushdown Languages STEFAN D. BRUDA Department of Computer Science Bishop s University 2600 College St Sherbrooke, Quebec J1M 1Z7 CANADA stefan@bruda.ca Abstract: Visibly pushdown languages

More information

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

1. (10 points) Draw the state diagram of the DFA that recognizes the language over Σ = {0, 1} CSE 5 Homework 2 Due: Monday October 6, 27 Instructions Upload a single file to Gradescope for each group. should be on each page of the submission. All group members names and PIDs Your assignments in

More information

Nested Words. A model of linear and hierarchical structure in data. Examples of such data

Nested Words. A model of linear and hierarchical structure in data. Examples of such data Nested Words A model of linear and hierarchical structure in data. s o m e w o r d Examples of such data Executions of procedural programs Marked-up languages such as XML Annotated linguistic data Example:

More information

CSCI312 Principles of Programming Languages!

CSCI312 Principles of Programming Languages! CSCI312 Principles of Programming Languages!! Chapter 3 Regular Expression and Lexer Xu Liu Recap! Copyright 2006 The McGraw-Hill Companies, Inc. Clite: Lexical Syntax! Input: a stream of characters from

More information

Compilation 2012 Context-Free Languages Parsers and Scanners. Jan Midtgaard Michael I. Schwartzbach Aarhus University

Compilation 2012 Context-Free Languages Parsers and Scanners. Jan Midtgaard Michael I. Schwartzbach Aarhus University Compilation 2012 Parsers and Scanners Jan Midtgaard Michael I. Schwartzbach Aarhus University Context-Free Grammars Example: sentence subject verb object subject person person John Joe Zacharias verb asked

More information

Lecture 8: Context Free Grammars

Lecture 8: Context Free Grammars Lecture 8: Context Free s Dr Kieran T. Herley Department of Computer Science University College Cork 2017-2018 KH (12/10/17) Lecture 8: Context Free s 2017-2018 1 / 1 Specifying Non-Regular Languages Recall

More information