Theory of Computation

Similar documents
CT32 COMPUTER NETWORKS DEC 2015

CS402 - Theory of Automata Glossary By

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

JNTUWORLD. Code No: R

(Refer Slide Time: 0:19)

Slides for Faculty Oxford University Press All rights reserved.

Final Course Review. Reading: Chapters 1-9

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

6 NFA and Regular Expressions

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


Complexity Theory. Compiled By : Hari Prasad Pokhrel Page 1 of 20. ioenotes.edu.np

UNIT I PART A PART B

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

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

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

Learn Smart and Grow with world

THEORY OF COMPUTATION

9.5 Equivalence Relations

(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

TOPIC PAGE NO. UNIT-I FINITE AUTOMATA

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

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

Decision Properties for Context-free Languages

LECTURE NOTES THEORY OF COMPUTATION

ECS 120 Lesson 16 Turing Machines, Pt. 2

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2016

Reflection in the Chomsky Hierarchy

CHAPTER 8. Copyright Cengage Learning. All rights reserved.

Computer Sciences Department

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

Theory of Computation Dr. Weiss Extra Practice Exam Solutions

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

QUESTION BANK. Unit 1. Introduction to Finite Automata

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

To illustrate what is intended the following are three write ups by students. Diagonalization

LECTURE NOTES THEORY OF COMPUTATION

Ambiguous Grammars and Compactification

Assignment 4 Solutions of graph problems

Multiple Choice Questions

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

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

Name: Finite Automata

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

Outline. Language Hierarchy

CS525 Winter 2012 \ Class Assignment #2 Preparation

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

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

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

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

Theory Bridge Exam Example Questions Version of June 6, 2008

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

Computation Engineering Applied Automata Theory and Logic. Ganesh Gopalakrishnan University of Utah. ^J Springer

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

Regular Languages and Regular Expressions

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

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

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

Material from Recitation 1

Actually talking about Turing machines this time

Formal Definition of Computation. Formal Definition of Computation p.1/28

AUBER (Models of Computation, Languages and Automata) EXERCISES

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

Interpreter. Scanner. Parser. Tree Walker. read. request token. send token. send AST I/O. Console

Theory of Programming Languages COMP360

Problems, Languages, Machines, Computability, Complexity

Theory of Computations Spring 2016 Practice Final Exam Solutions

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

Languages and Compilers

CSE 105 THEORY OF COMPUTATION

A Note on the Succinctness of Descriptions of Deterministic Languages

CIT3130: Theory of Computation. Regular languages

Total No. of Questions : 18] [Total No. of Pages : 02. M.Sc. DEGREE EXAMINATION, DEC First Year COMPUTER SCIENCE.

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

Normal Forms for CFG s. Eliminating Useless Variables Removing Epsilon Removing Unit Productions Chomsky Normal Form

CS402 Theory of Automata Solved Subjective From Midterm Papers. MIDTERM SPRING 2012 CS402 Theory of Automata

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 ǫ.

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

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

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

A set with only one member is called a SINGLETON. A set with no members is called the EMPTY SET or 2 N

Introduction to Computers & Programming

Chapter 14: Pushdown Automata

CIS 1.5 Course Objectives. a. Understand the concept of a program (i.e., a computer following a series of instructions)

CMPSCI 250: Introduction to Computation. Lecture 20: Deterministic and Nondeterministic Finite Automata David Mix Barrington 16 April 2013

1 Finite Representations of Languages

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

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

Front End: Lexical Analysis. The Structure of a Compiler

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

CSE 20 DISCRETE MATH. Fall

Theory of Computations Spring 2016 Practice Final

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

CSE 105 THEORY OF COMPUTATION

(DMTCS 01) Answer Question No.1 is compulsory (15) Answer One question from each unit (4 15=60) 1) a) State whether the following is True/False:

Theory of Computation, Homework 3 Sample Solution

CSE 20 DISCRETE MATH. Winter

10/11/2018. Partial Orderings. Partial Orderings. Partial Orderings. Partial Orderings. Partial Orderings. Partial Orderings

A Characterization of the Chomsky Hierarchy by String Turing Machines

Transcription:

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 and Push-Down Automata, Regular and Context-Free Languages, Pumping Lemma, Turing Machines and Undecidability. Analysis of GATE Papers Year Percentage of Marks Over All Percentage 205 6.00 204 6.00 203 8.00 202 5.00 20 9.00 200 7.00 7.5% 2009 6.66 2008 0.00 2007 8.00 2006 9.33 : 080-67 66 222, info@thegateacademy.com Copyright reserved. Web:www.thegateacademy.com

Contents Contents Chapters Page No. #. Introduction/Preliminaries 3 Introduction Relations 2 3 #2. Finite Automata 4 22 Finite Automata 4 0 Construction of DFA from NFA (Sub Set Construction) 0 Epsilon( )-Closures 2 3 Eliminating -Transitions (Construction of DFA from -NFA) 4 5 Assignment 6 8 Assignment 2 8 9 Answer keys & Explanations 20 22 #3. Regular Expression 23 59 Definitions 23 24 Languages Associated with Regular Expressions 24 25 Algebraic Laws for Regular Expressions 25 26 Converting Regular Expression to Automata ( -NFA) 26 28 Construction of Regular Expression from Finite Automata 28 3 Ordering the Elimination of States 3 33 Finite Automata with Output 33 36 Regular Grammar 36 45 Myhill-Nerode Theorem 45 47 Pumping Lemma for Regular Languages 47 52 Finding (in) Distinguishable States 52 54 Assignment 55 57 Answer keys & Explanations 57 59 #4. Context Free Grammar 60 00 Introduction 60 62 Context Free Language 62 63 Leftmost and Rightmost Derivations Ambiguity 64 65 Simplification of Context Free Grammar 65 Elimination of Useless Symbols 66 69 Normal Forms 70 74 : 080-67 66 222, info@thegateacademy.com Copyright reserved. Web:www.thegateacademy.com i

Pushdown Automata 74 75 Definition of PDA 75 77 NPDA 77 82 Properties of Context Free Language 83 85 Decision Algorithms for CFL s 85 87 Non-Context Free Language 87 89 Pumping Lemma for CFL s 89 9 Membership Algorithm for Context-Free Grammar 9 92 Assignment 93 94 Assignment 2 94 97 Answer keys & Explanations 97 00 Contents #5. Turing Machines 0 34 Introduction 0 03 Modification of Turing Machine 04 07 Two-Pushdown Stack Machine 07 08 Counter Machine 08 0 Multiple Tracks 0 6 Universal Turing Machine 6 7 Context Sensitive Grammar 7 8 Linear Bounded Automata 8 9 Hierarchy of Formal Languages (Chomsky Hierarchy) 9 20 Undecidability 20 2 Universal Language 2 27 The Classes P & NP 27 29 Assignment 30 3 Assignment 2 3 32 Answer Keys & Explanations 33 34 Module Test 35 45 Test Questions 35 4 Answer Keys & Explanations 4 45 Reference Books 46 : 080-67 66 222, info@thegateacademy.com Copyright reserved. Web:www.thegateacademy.com ii

CHAPTER "Yesterday I dared to struggle. Today I dare to win."..bernadette Devlin Introduction/Preliminaries Learning Objectives After reading this chapter, you will know:. Relations Introduction String: A string is a finite sequence of symbols put together. E.g. bbac the length of this string is '4'. Note: The length of empty string denoted by, is the string consisting of zero symbols. Thus = 0. Alphabet: An alphabet is a finite set of symbols. E.g.: {a, b, 0,, B} Formal language: A formal language is a set of strings made up of symbols taken from some alphabet. E.g.: The language consisting of all strings formed by the alphabet {0, } Note:. The empty set,, is a formal language. The cardinality (size) of this language is zero. 2. The set consisting of empty string, { } is a formal language. The cardinality (size) of this language is one. Set: A set is a collection of objects (members of the set) without repetition. i. Finite Set: A set which contains finite number of elements is said to be finite set. E.g.: {, 2, 3, 4} ii. Countably Infinite Set: Sets that can be placed in one-to-one correspondence with the integers are said to be countably infinite or countable or denumerable. E.g.: The set of the finite-length strings from an alphabet are countably infinite, (if : {0, } Then : {0, 0,, 0, 0...} i.e., all possible strings with 0 and'') iii. Uncountable Set: Sets that can't be placed in one-to-one correspondence with the integers are said to be uncountable sets. E.g.: The set of real numbers. :080-67 66 222, info@thegateacademy.com Copyright reserved. Web:www.thegateacademy.com

Introduction/Preliminaries Relations A (binary) relation is a set of ordered tuples. The first component of each tuple is chosen from a set called the domain and the second component of each pair is chosen from a (possibly different) set called the range. E.g. Let A {, 2, 3, 4} be a set. A relation R, on 'A' can be defined as R: {(, 2), (, 3), (, ), (2, 3)} Properties of Relations We say a relation R on set S is. Reflexive: If ara for all a in S 2. Irreflexive: If ara is false for all a is S 3. Transitive: If arb and brc implies arc 4. Symmetric: If arb implies bra 5. Asymmetric: If arb implies that bra is false 6. Anti-symmetric: If arb and bra implies a = b Equivalence Relation: A relation is said to be equivalence relation if it satisfies the following properties.. Reflexive 2. Symmetric 3. Transitive An important property of equivalence relation 'R' on set 'S' is that R partitions 'S' into disjoint nonempty equivalence classes (may be infinite) i.e., S =..., where for each i and j, with i j. = 2. For each 'a' and 'b' in S jarb is true. 3. For each 'a' in i and 'b' in Sj, arb is false. The 's are called equivalence classes. E.g.: The relation 'R' on people defined by prq if and only if 'p' and 'q' were born at the same hour of the same day of some year: The number of equivalence classes are: 24 (no. of hours) 7 (no. of days in a week). Closure of Relations: Suppose P is a set of properties of relations. The P-closure of a relation R is the smallest relation R that includes all the pairs of R and possesses the properties in P. E.g.: Let R = {(, 2), (2, 3), (3, )} be a relation on set {, 2, 3} i. The reflexive-transitive closure of R is denoted by R* is Added by Reflexivity (, 2), (2, 3), (3, ), (, ), (2, 2), (3, 3), (, 3), (2, ), (3, 2) Added by Transitivity : 080-67 66 222, info@thegateacademy.com Copyright reserved. Web:www.thegateacademy.com 2

Introduction/Preliminaries ii. The symmetric closure of R is {(, 2), (2, 3), (3, ), (2, ), (3, 2), (, 3)} Term Definition prefix of s A string obtained by removing zero or more trailing symbols of string s; e.g., ban is a prefix of banana. suffix of s A string formed by deleting zero or more of the leading symbols of s; e.g., nana is a suffix of banana. substring of s A string obtained by deleting a prefix and a suffix from s; e.g., nan is a substring of banana. Every prefix and every suffix of s is a substring of s, but not every substring of s is a prefix or a suffix of s. For every string s, both s and are prefixes, suffixes, and substrings of s. proper prefix, suffix, or Any nonempty string x that is, respectively, a prefix, suffix, or substring of s substring of s such that s x. subsequence of s Any string formed by deleting zero or more not necessarily contiguous symbols from s; e.g., baaa is a subsequence of banana. : 080-67 66 222, info@thegateacademy.com Copyright reserved. Web:www.thegateacademy.com 3

CHAPTER 2 "Shoot for the moon. Even if you miss, you will land among the stars." Les Brown Finite Automata Learning Objectives After reading this chapter, you will know:. Finite Automata 2. Construction of DFA from NFA (Sub Set Construction) 3. Epsilon( )-Closures 4. Eliminating -Transitions (Construction of DFA from -NFA) Finite Automata A finite automaton involves states and transitions among states in response to inputs. They are useful for building several different kinds of software, including the lexical analysis component of a complier and systems for verifying the correctness of circuits or protocols. They also serve as the control unit in many physical systems including: vending machines, elevators, automatic traffic signals, computer microprocessors, and network protocol stacks. Deterministic Finite Automata A DFA captures the basic elements of an abstract machine: it reads in a string, and depending on the input and the way the machine was designed, it outputs either true or false. A DFA is always in one of N states, which we usually name 0 through N-. Each state is labeled true or false. The DFA begins in a designated state called the start state. As the input characters are read in one at a time, the DFA changes from one state to another in a pre-specified way. The new state is completely determined by the current state and the character just read in. When the input is exhausted, the DFA outputs true or false according to the label of the state it is currently in. A Deterministic finite automaton is represented by a Quintuple (5-tuple): (Q,, δ,, F) Where, Q: Finite set of states : Finite set of input symbols called the alphabet. δ: Q X Q (δ is a transition function from Q X to Q) : A start state, one of the states in Q F: A set of final states, such that F Q :080-67 66 222, info@thegateacademy.com Copyright reserved. Web:www.thegateacademy.com 4

Induction Finite Automata Suppose is a string of the form a that is a is the last symbol of, and is the string consisting of all but the last symbol. For example is broken into and a. Then δ (, ) δ(δ (, ), a) Now, to compute δ (, ) first compute δ (, )the state that the automaton is in after processing all but the last symbol of. Suppose this state is p; that is, δ (, ). Then δ (, )is what we get by making a transition from state p on input a. That is, δ (, ) = δ (, a) E.g.: Let us design a DFA to accept the language L = { has both an even number of 0's and an even number of 's} It should not be surprising that the job of the states of this DFA is to count both the number of 0's and the number of 's, but count them modulo 2. That is, the state is used to remember whether the number of 0's seen so far is even or odd, and also to remember whether the number of 's seen so far is even or odd. There are thus four states, which can be given the following interpretations: : Both the number of 0's seen so far and the number of 's seen so far are even. : The number of 0's seen so far is even, but the number of 's seen so far is odd. : The number of 's seen so far is even, but the number of 0's seen so far is odd. : Both the number of 0's seen so far and the number of 's seen so far are odd. State is both the start state and the alone the accepting state. It is the start state, because before reading any inputs, the numbers of 0's and 's seen so far are both zero, and zero is even. It is the only accepting state, because it describes exactly the condition for a sequence of 0's and 's to be in language L. We now know almost how to specify the DFA for language L. It is, A ({,,, }, {, }, δ,, { }) Deterministic Finite Automata Start 0 0 0 0 Transition Diagram for the DFA Where the transition function S is described by the transition diagram notice that, how each input 0 causes the state to cross the horizontal, dashed line. Thus, after seeing an even number of 0's we are always above the line, in state or while after seeing an odd number of 0's we are always below the line, in state or. Likewise, every causes the state to cross the vertical, dashed line. Thus, after seeing an even number of 's. We are always to the left, in state or. While after : 080-67 66 222, info@thegateacademy.com Copyright reserved. Web:www.thegateacademy.com 5

Finite Automata seeing an odd number of 's we are to the right, in state or. These observations are an informal proof that the four states have the interpretations attributed to them. However, one could prove the correctness of our claims about the states formally, by a mutual induction with respect to example. We can also represent this DFA by a transition table shown below. However, we are not just concerned with the design of this DFA; we want to use it to illustrate the construction of δ from its transition function δ. Suppose the input is 00. Since this string has even numbers of 0's and 's both, we expect it is in the language. Thus, we expect that δ (, 00) = since is the only accepting state. Let us now verify that claim. Transition Table for the DFA The check involves computing δ (, w) for each prefix w of 00, starting at and going in increasing size. The summary of this calculation is: δ (, ) δ (, ) δ(δ (, ), ) δ(, ) δ (, ) δ(δ (, ), ) δ(, ) δ (, ) δ(δ (, ), ) δ(, ) δ (, ) δ(δ (, ), ) δ(, ) δ (, ) δ(δ (, ), ) δ(, ) δ (, ) δ(δ (, ), ) δ(, ) Acceptance by an Automata A string is said to be acce ted by a finite automaton M (Q,, δ,, F) if δ (, x) = for some in F. The language accepted by M, designated L (M), is the set {x δ (, x) is in F}. A language is a regular set (or just regular) if it is the set accepted by some automaton. There are two preferred notations for describing Automata. Transition diagram 2. Transition table : 080-67 66 222, info@thegateacademy.com Copyright reserved. Web:www.thegateacademy.com 6