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, Deterministic Finite Automata, Nondeterministic Finite Automata, An Application, Finite Automata with Epsilon Transitions. CHAPTER - 3 : REGULAR EXPRESSIONS AND LANGUAGES Regular Expressions, Finite Automata and Regular Expressions, Applications of Regular Expressions, Algebraic Laws for Regular Expressions. UNIT - II CHAPTER - 4 : PROPERTIES OF REGULAR LANGUAGES Proving Languages not to be Regular, Closure Properties of Regular Languages, Decision Properties of Regular Languages, Equivalence and Minimization of Automata. CHAPTER - 5 : CONTEXT FREE GRAMMARS AND LANGUAGES Context Free Grammars, Parses Trees, Applications, Ambiguity in Grammars and Languages. UNIT - III CHAPTER - 6 : PUSHDOWN AUT UTOMA OMATA Definition, Languages of PDA, Equivalence of PDA s and CFG s Deterministic Pushdown Automata. CHAPTER - 7 : PROPERTIES OF CONTEXT FREE LANGUAGES Normal Forms for Context Free Grammars, Pumping Lemma, Closure Properties, Decision Properties of CFL s.
ii Contents UNIT - IV CHAPTER - 8 : INTRODUCTION TO TURING MACHINES UNIT - V Problems that Computers Cannot Solve, The Turing Machines, Programming Techniques for Turing Machines, Extensions to the Turing for Machines, Restricted Turing Machines, Turing Machines and Computers. CHAPTER - 9 : UNDECIDABILITY A Language That is Not Recursively Enumerable, An Undecidable Problem That is RE, Undecidable Problems About Turing Machines, Post s Correspondence Problem, Other Undecidable Problems. CHAPTER - 10 : INTRACT CTABLE PROBLEMS The Classes P and NP, An NP Complete Problem, A Restricted Satisfiability Problem.
Contents iii automata, languages ages and computation FOR b.e. (o.u) Iii year i semester (COMMON TO CSE & IT) CONTENTS UNIT - I [CH. H. - 1] ] [AUTOMATA AUTOMATA]... 1.1-1.16 1.1 INTRODUCTION TO FINITE AUT UTOMA OMATA... 1.2 1.1.1 Structural Representations... 1.3 1.1.2 Automata and Complexity... 1.4 1.2 INDUCTIVE PROOFS... 1.4 1.2.1 Inductions on Integers... 1.4 1.3 THE CENTRAL CONCEPTS OF AUTOMA OMATA A THEORY... 1.6 1.3.1 Alphabets... 1.6 1.3.2 Strings... 1.6 1.3.2.1 The Empty String... 1.6 1.3.2.2 Length of String... 1.6 1.3.2.3 Powers of an Alphabet... 1.7 1.3.2.4 Concatenation of String... 1.8 1.3.3 Languages... 1.8 1.3.4 Solved Problems... 1.10 Expected University Questions with Answers... 1.16 UNIT - I [CH. - 2] ] [FINITE AUTOMATA]... 1.17-1.92 2.1 INTRODUCTION TO FINITE AUT UTOMA OMATA... 1.17 2.2 AN INFORMAL PICTURE OF FINITE AUTOMA OMATA... 1.17 2.3 DETERMINISTIC FINITE AUTOMA OMATA A (DFA)... 1.20 2.3.1 Definition of a Deterministic Finite Automaton... 1.20 2.3.2 How a DFA Processes Strings... 1.21
iv Contents 2.3.3 Simpler Notations for DFA s... 1.22 2.3.3.1 Transition Diagrams... 1.22 2.3.3.2 Transition Tables... 1.23 2.3.4 Extending the Transition Function to Strings... 1.23 2.3.5 The Language of a DFA... 1.25 2.3.6 Solved Problems... 1.28 2.4 NON-DETERMINISTIC FINITE AUTOMA OMATA A (NFA) A)... 1.43 2.4.1 An Informal View of NFA... 1.44 2.4.2 Definition of NFA... 1.45 2.4.3 The Extended Transition Function... 1.46 2.4.4 The Language of an NFA... 1.46 2.4.5 Equivalent of DFA A and NFA... 1.47 2.4.6 A Bad Case for the Subset Construction... 1.53 2.4.7 Differences between NFA A and DFA... 1.54 2.4.8 Solved Problems... 1.54 2.5 AN APPLICATION (TEXT SEARCH)... 1.72 2.5.1 Finding Strings in Text ext... 1.72 2.5.2 NFA A for Text ext Search... 1.73 2.5.3 A DFA A to Recognize a Set of Keywords... 1.73 2.5.4 Solved Problems... 1.75 2.6 FINITE AUT UTOMA OMATA A WITH EPSILON TRANSITIONS... 1.79 2.6.1 Uses of ε-transitions... 1.79 2.6.2 The Formal Notation for an ε-nf -NFA... 1.80 2.6.3 Epsilon Closures... 1.81 2.6.4 Extended Transitions and Languages for ε-nf -NFA s... 1.82 2.6.5 Eliminating ε-transitions... 1.82 2.6.6 Solved Problems... 1.83 Expected University Questions with Answers... 1.92
Contents v UNIT - I [CH. H. - 3] ] [REGULAR EXPRESSIONS AND LANGUAGES]... 1.93-1.148 3.1 REGULAR EXPRESSIONS... 1.94 3.1.1 The Operators of Regular Expressions... 1.94 3.1.2 Building Regular Expressions... 1.95 3.1.3 Precedence of Regular Expression Operators... 1.97 3.1.4 Solved Problems... 1.97 3.2 FINITE AUTOMA OMATA A AND REGULAR EXPRESSIONS... 1.101 3.2.1 From DFA s to Regular Expressions... 1.102 3.2.2 Converting DFA s to Regular Expression by Eliminating States... 1.106 3.2.3 Converting Regular Expressions to Automata... 1.110 3.2.4 Solved Problems... 1.114 3.3 APPLICATIONS OF REGULAR EXPRESSIONS... 1.135 3.3.1 Regular Expressions in UNIX... 1.135 3.3.2 Lexical Analysis... 1.136 3.3.3 Finding Patterns in Text ext... 1.137 3.4 ALGEBRAIC LAWS FOR REGULAR EXPRESSIONS... 1.138 3.4.1 Associativity and Commutativity... 1.138 3.4.2 Identities and Annihilators... 1.139 3.4.3 Distributed Laws... 1.139 3.4.4 The Idempotent Law... 1.139 3.4.5 Laws Involving Closures... 1.140 3.4.6 Solved Problems... 1.140 Expected University Questions with Answers... 1.148 UNIT - II [CH. - 4] ] [PROPERTIES OF REGULAR LANGUAGES]... 2.1-2.78 4.1 PROPERTIES OF REGULAR LANGUAGES... 2.2 4.2 PROVING LANGUAGES GES NOT TO BE REGULAR... 2.2 4.2.1 The Pumping Lemma for Regular Languages... 2.2 4.2.2 Applications of the Pumping Lemma... 2.5 4.2.3 Solved Problems... 2.6
vi Contents 4.3 CLOSURE PROPERTIES OF REGULAR LANGUAGES... 2.15 4.3.1 Closure of Regular Languages Under Boolean Operations... 2.16 4.3.1.1 Closure Under Union... 2.16 4.3.1.2 Closure Under Complementation... 2.16 4.3.1.3 Closure Under Intersection... 2.17 4.3.1.4 Closure Under Difference... 2.19 4.3.2 Reversal... 2.20 4.3.3 Homomorphisms... 2.21 4.3.4 Inverse Homomorphisms... 2.22 4.3.5 Solved Problems... 2.24 4.4 DECISION PROPERTIES OF REGULAR LANGUAGES... 2.30 4.4.1 Converting Among Representations... 2.30 4.4.1.1 Converting NFA s s to DFA s s... 2.30 4.4.1.2 DFA A to NFA A Conversion... 2.31 4.4.1.3 Automaton to Regular Expression Conversion... 2.31 4.4.1.4 Regular Expression to Automation Conversion... 2.31 4.4.2 Testing Empitness of Regular Languages... 2.31 4.4.3 Testing Membership in a Regular Language... 2.32 4.4.4 Solved Problems... 2.34 4.5 EQUIVALENCE AND MINIMIZATION OF AUTOMA OMATA... 2.54 4.5.1 Testing Equivalence of States... 2.54 4.5.2 Testing Equivalence of Regular Languages... 2.59 4.5.3 Minimization of DFA s... 2.60 4.5.4 Solved Problems... 2.65 Expected University Questions with Answers... 2.77-2.78
Contents vii UNIT - II [CH. H. - 5] ] [CONTEXT FREE GRAMMARS AND LANGUAGES]... 2.79-2.134 5.1 CONTEXT FREE GRAMMARS... 2.80 5.1.1 An Informal Example... 2.80 5.1.2 Definition of Context Free Grammars... 2.83 5.1.3 Derivations Using a Grammar... 2.85 5.1.4 Leftmost and Rightmost Derivations... 2.87 5.1.5 The Language of Grammar... 2.89 5.1.6 Sentential Forms... 2.89 5.1.7 Solved Problems... 2.90 5.2 PARSE TREES... 2.103 5.2.1 Constructing Parse Trees... 2.103 5.2.2 The Yield of a Parse Tree ree... 2.103 5.2.3 Inference, Derivations and Parse Trees... 2.105 5.2.4 From Inferences to Trees... 2.106 5.2.5 From Trees to Derivations... 2.108 5.2.6 From Derivations to Recursive Inferences... 2.109 5.2.7 Solved Problems... 2.110 5.3 APPLICATIONS OF CONTEXT-FREE GRAMMARS... 2.118 5.3.1 Parsers... 2.118 5.3.2 The YACC Parser Generator... 2.120 5.3.3 Markup Languages... 2.121 5.3.4 XML and Document Type Definitions... 2.121 5.3.5 Solved Problem... 2.123 5.4 AMBIGUITY IN GRAMMARS AND LANGUAGES... 2.123 5.4.1 Ambiguous Grammars... 2.123 5.4.2 Removing Ambiguity From Grammars... 2.125 5.4.3 Inherent Ambiguity... 2.127 5.4.4 Solved Problems... 2.129 Expected University Questions with Answers... 2.134
viii Contents UNIT - III [CH. H. - 6] ] [PUSHDOWN AUTOMATA]... 3.1-3.48 6.1 INTRODUCTION... 3.2 6.2 DEFINITION OF PUSHDOWN AUTOMA OMATA A (PDA)... 3.2 6.2.1 The Formal Definition of Pushdown Automata... 3.3 6.2.2 A Graphical Notation for PDA s... 3.6 6.2.3 Instantaneous Descriptions of a PDA... 3.6 6.3 THE LANGUAGES OF A PDA... 3.7 6.3.1 Acceptance Final State... 3.7 6.3.2 Accepting by Empty Stack... 3.8 6.3.3 From Empty Stack To o Final State... 3.9 6.3.4 From Final State to Empty Stack... 3.11 6.3.5 Solved Problems... 3.16 6.4 EQUIVALENCE OF PDA S S AND CFG S... 3.23 6.4.1 From Grammars to Pushdown Automata Procedure... 3.23 6.4.2 From PDA s s to Grammars... 3.27 6.4.3 Solved Problems... 3.29 6.5 DETERMINISTIC PUSHDOWN AUTOMA OMATA... 3.36 6.5.1 Definition of Deterministic PDA... 3.36 6.5.2 Regular Languages and Deterministic PDA s... 3.37 6.5.3 DPDA s and Context Free Languages... 3.38 6.5.4 DPDA s and Ambiguous Grammars... 3.38 6.5.5 Solved Problems... 3.40 Expected University Questions with Answers... 3.47-3.48
Contents ix UNIT - III [CH. H. - 7] ] [PROPERTIES OF CONTEXT FREE LANGUAGES]... 3.49-3.112 7.1 NORMAL FORMS FOR CONTEXT FREE GRAMMARS... 3.50 7.1.1 Eliminating Useless Symbols... 3.50 7.1.2 Computing the Generating and Reachable Symbols... 3.57 7.1.3 Eliminating ε-productions... 3.58 7.1.4 Eliminating Unit Productions... 3.61 7.1.5 Chomsky Normal Form... 3.64 7.1.5.1 Reduction of CFG to CNF... 3.64 7.1.6 The Greibach Normal Form... 3.68 7.1.6.1 Conversion of CNF into GNF... 3.70 7.1.6.2 CNF Vs GNF... 3.73 7.1.7 Solved Problems... 3.73 7.2 PUMPING LEMMA FOR CONTEXT FREE LANGUAGES... 3.81 7.2.1 Statement of the Pumping Lemma... 3.81 7.2.2 OGDEN s Lemma... 3.84 7.2.3 Applications of Pumping Lemma... 3.84 7.2.4 Solved Problems... 3.86 7.3 CLOSURE PROPERTIES... 3.88 7.3.1 Substitution... 3.88 7.3.2 Applications of the Substitution Theorem... 3.90 7.3.3 Reversal... 3.96 7.3.4 Intersection With a Regular Language... 3.96 7.3.5 Inverse Homomorphism... 3.102 7.4 DECISION PROPERTIES OF CFL S S... 3.103 7.4.1 Testing Empitness of CFL s s... 3.104 7.4.1.1 Finiteness... 3.106 7.4.2 Testing Membership in a CFL... 3.107 Expected University Questions with Answers... 3.111-3.112
x Contents UNIT - IV [CH. H. - 8] ] [INTRODUCTION TO TURING MACHINES]... 4.1-4.62 8.1 INTRODUCTION TO TURING MACHINES... 4.2 8.2 PROBLEMS THAT T COMPUTERS CANNOT SOLVE... 4.2 8.3 THE TURING MACHINE... 4.3 8.3.1 Turing Machine Model... 4.4 8.3.2 Transition Table... 4.5 8.3.3 Instantaneous Description (ID) For Turning Machines... 4.5 8.3.4 Acceptance of a Language by TM... 4.8 8.3.5 Construction of Turing Machine (TM)... 4.10 8.3.6 Transition Diagram for Turing Machine (TM)... 4.15 8.3.7 Turing Machines and Halting... 4.19 8.3.8 Solved Problems... 4.19 8.4 PROGRAMMING TECHNIQUES FOR TURING MACHINES... 4.34 8.4.1 Storage in the State... 4.34 8.4.2 Multiple Track rack... 4.35 8.4.3 Subroutines... 4.35 8.4.4 Solved Problems... 4.36 8.5 EXTENSIONS TO O THE TURING MACHINES... 4.40 8.5.1 Multi-Tape Turing Machines... 4.41 8.5.2 Equivalence of Single-Tape and Multi-Tape TM s... 4.42 8.5.3 Non-Deterministic Turing Machines... 4.43 8.6 RESTRICTED TURING MACHINES... 4.46 8.6.1 Turing Machine With Semi Infinite Tape ape... 4.46 8.6.2 Multistack Machines... 4.47 8.6.3 Counter Machines... 4.48 8.6.4 Off Line Turing Machine... 4.49 8.6.5 Linear Bounded Automata (LBA)... 4.50
Contents xi 8.7 TURING MACHINE AND COMPUTERS... 4.52 8.7.1 Turing Machine as a Computer of Integer Functions unctions... 4.52 8.7.2 Solved Problems... 4.56 8.7.3 Turing Machine as a Generating Device... 4.59 Expected University Questions with Answers... 4.61-4.62 UNIT - V [CH. H. - 9] ] [UNDECIDABILITY UNDECIDABILITY]... 5.1-5.40 9.1 INTRODUCTION TO UNDECIDABILITY... 5.2 9.2 A LANGUAGE GE THAT T IS NOT RECURSIVELY ENUMERABLE... 5.2 9.2.1 Enumerating the Binary Strings... 5.3 9.2.2 Codes for Turing Machines... 5.3 9.2.3 The Diagonalization Language... 5.8 9.2.4 Proof That L d is Not Recursively Enumerable... 5.9 9.3 AN UNDECIDABLE PROBLEM THAT T IS RE... 5.10 9.3.1 Recursive Languages... 5.10 9.3.2 Complements of Recursive and R E Languages... 5.11 9.3.3 The Universal Language... 5.12 9.3.4 Undecidability of the Universal Language... 5.14 9.3.5 Halting Problem... 5.15 9.3.5.1 Reduction of Problems to Halting Problem of Turing Machine... 5.17 9.4 UNDECIDABLE PROBLEMS ABOUT TURING MACHINES... 5.18 9.4.1 Reduction... 5.18 9.4.2 Turing Machines That Accept the Empty Language... 5.19 9.4.3 Rice s Theorem and Properties of the RE Languages... 5.21 9.4.4 Problems About Turing Machine Specifications... 5.23 9.5 POST S CORRESPONDENCE PROBLEM (PCP)... 5.23 9.5.1 Definition of Post ost s Correspondence Problem roblem... 5.24 9.5.2 The Modified PCP... 5.27 9.5.2.1 Construction of PCP from MPCP... 5.28 9.5.3 Completion of the Proof of PCP Undecidability... 5.31
xii Contents 9.6 OTHER UNDECIDABLE PROBLEMS... 5.36 9.6.1 Problems About Programs... 5.36 9.6.2 Undecidability of Ambiguity of CFG s... 5.36 9.6.3 The Complement of a List Language... 5.38 Expected University Questions with Answers... 5.39-5.40 UNIT - V [CH. H. - 10] ] [INTRACTABLE PROBLEMS]... 5.41-5.66 10.1 INTRODUCTION TO INTRACT CTABLE PROBLEMS... 5.42 10.2 THE CLASSES P AND NP... 5.42 10.2.1 Problems Solvable in Polynomial Time (P)... 5.42 10.2.2 An Example : Kruskal s Algorithm... 5.43 10.2.3 Non Deterministic Polynomial Time (NP)... 5.46 10.2.4 An NP : Problem : The Traveling Salesman Problem... 5.47 10.2.5 Polynomial Time Reductions eductions... 5.51 10.2.6 NP-Complete Problems... 5.51 10.2.7 NP-Hard... 5.53 10.3 AN NP COMPLETE PROBLEM... 5.53 10.3.1 The Satisfiability Problem... 5.53 10.3.2 Representing SAT T Instances... 5.55 10.3.3 Cook s s Theorem to Prove SAT T in NP Complete... 5.55 10.4 A RESTRICTED SATISFIABILITY PROBLEM... 5.60 10.4.1 Normal Forms for Boolean Expressions... 5.60 10.4.2 Converting Expressions to CNF (Reduction of SAT to CSAT) T)... 5.61 10.4.3 NP Completeness of CSAT... 5.62 10.4.4 NP Completeness of 3SAT... 5.62 Expected University Questions with Answers... 5.65-5.66 LATEST UNIVERSITY QUESTION PAPER [November/December - 2012] [Main]... QP.1.1 - QP.4.4