theory of computation · closure properties of regular languages, context free grammars,...

16

Upload: others

Post on 15-Oct-2020

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: THEORY OF COMPUTATION · closure properties of Regular languages, Context free grammars, Simplification of Context free grammars and Normal forms, Properties of context free languages
Page 2: THEORY OF COMPUTATION · closure properties of Regular languages, Context free grammars, Simplification of Context free grammars and Normal forms, Properties of context free languages
Page 3: THEORY OF COMPUTATION · closure properties of Regular languages, Context free grammars, Simplification of Context free grammars and Normal forms, Properties of context free languages

THEORY OF COMPUTATION

Page 4: THEORY OF COMPUTATION · closure properties of Regular languages, Context free grammars, Simplification of Context free grammars and Normal forms, Properties of context free languages
Page 5: THEORY OF COMPUTATION · closure properties of Regular languages, Context free grammars, Simplification of Context free grammars and Normal forms, Properties of context free languages

THEORY OF

COMPUTATIONFor B.E. (IT, CS), MCA, BSC, BCA, MSC

and Other Computer Courses

By

Dr. Poonam SinhaHead (IT/MCA),

BUIT, Barkatullah University

Bhopal (MP)

Sunita Gond Apurva SaxenaLecturer, (IT/MCA) Deptt. Lecturer, (IT/MCA) Deptt.

BUIT, Barkatullah University BUIT, Barkatullah University

Bhopal (MP) Bhopal (MP)

UNIVERSITY SCIENCE PRESS(An Imprint of Laxmi Publications (P) Ltd.)

BANGALORE ••••• CHENNAI ••••• COCHIN ••••• GUWAHATI ••••• HYDERABAD

JALANDHAR ••••• KOLKATA ••••• LUCKNOW ••••• MUMBAI ••••• RANCHI ••••• NEW DELHI

INDIA ••••• USA ••••• GHANA ••••• KENYA

Page 6: THEORY OF COMPUTATION · closure properties of Regular languages, Context free grammars, Simplification of Context free grammars and Normal forms, Properties of context free languages

THEORY OF COMPUTATION

Copyright © by Laxmi Publications (P) Ltd. All rights reserved including those of translation into other languages. In accordance with the Copyright (Amendment) Act, 2012, no part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical, photocopying, recording or otherwise. Any such act or scanning, uploading, and or electronic sharing of any part of this book without the permission of the publisher constitutes unlawful piracy and theft of the copyright holder’s intellectual property. If you would like to use material from the book (other than for review purposes), prior written permission must be obtained from the publishers.

Printed and bound in India Typeset at Excellent Graphics, Delhi

First Edition: 2015UTC-9647-195-THEORY OF COMPUTATION-SIN

ISBN 978-93-83828-25-8

Limits of Liability/Disclaimer of Warranty: The publisher and the author make no representation or warranties with respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties. The advice, strategies, and activities contained herein may not be suitable for every situation. In performing activities adult supervision must be sought. Likewise, common sense and care are essential to the conduct of any and all activities, whether described in this book or otherwise. Neither the publisher nor the author shall be liable or assumes any responsibility for any injuries or damages arising herefrom. The fact that an organization or Website if referred to in this work as a citation and/or a potential source of further information does not mean that the author or the publisher endorses the information the organization or Website may provide or recommendations it may make. Further, readers must be aware that the Internet Websites listed in this work may have changed or disappeared between when this work was written and when it is read.

All trademarks, logos or any other mark such as Vibgyor, USP, Amanda, Golden Bells, Firewall Media, Mercury, Trinity, Laxmi appear-ing in this work are trademarks and intellectual property owned by or licensed to Laxmi Publications, its subsidiaries or affiliates. Notwithstanding this disclaimer, all other names and marks mentioned in this work are the trade names, trademarks or service marks of their respective owners.

Published in india by

113, GOLDEN HOUSE, DARYAGANJ, NEW DELHI - 110002, INDIA Telephone : 91-11-4353 2500, 4353 2501 Fax : 91-11-2325 2572, 4353 2528 C—www.laxmipublications.com [email protected] Printed at:

& Bangalore 080-26 75 69 30

& Chennai 044-24 34 47 26, 24 35 95 07

& Cochin 0484-237 70 04, 405 13 03

& Guwahati 0361-254 36 69, 251 38 81

& Hyderabad 040-27 55 53 83, 27 55 53 93

& Jalandhar 0181-222 12 72

& Kolkata 033-22 27 43 84

& Lucknow 0522-220 99 16

& Mumbai 022-24 91 54 15, 24 92 78 69

& Ranchi 0651-220 44 64

Bran

ches

Page 7: THEORY OF COMPUTATION · closure properties of Regular languages, Context free grammars, Simplification of Context free grammars and Normal forms, Properties of context free languages

Dedicated toAll Beloved Readers, Friends

and Family Members

Page 8: THEORY OF COMPUTATION · closure properties of Regular languages, Context free grammars, Simplification of Context free grammars and Normal forms, Properties of context free languages
Page 9: THEORY OF COMPUTATION · closure properties of Regular languages, Context free grammars, Simplification of Context free grammars and Normal forms, Properties of context free languages

CCCCCONTENTONTENTONTENTONTENTONTENTSSSSS

Preface viiAcknowledgements viii

Syllabuses of Various Universities ix

1. Introduction of Automata Theory ............................................................. 11.1. Formal Language ..................................................................................................... 1

1.2. Mathematics Preliminaries...................................................................................... 1

1.3. Relations and Functions........................................................................................... 2

1.4. Graphs ....................................................................................................................... 3

1.5. Trees .......................................................................................................................... 5

1.6. Alphabet .................................................................................................................... 6

1.7. Strings ....................................................................................................................... 6

1.8. Principle of Induction ............................................................................................... 7

1.9. Propositional Logic (Zero Order Logic) .................................................................... 9

1.10. Predicate Logic (First Order Logic) ....................................................................... 10

2. Automata .................................................................................................. 132.1. Automata and Definition ....................................................................................... 13

2.2. Description .............................................................................................................. 13

2.3. Finite Automata/Finite State Machine (FSM) ...................................................... 14

2.4. Equivalence of DFA and NFA ................................................................................ 18

2.5. Finite Automata with Null String or NFA with ‘ε’ Moves to NFA without ‘ε’ ..... 20

2.6. Minimisation of Finite State Machine or My-Hill-Nerode Algorithm ................. 22

2.7. FSM with Output ................................................................................................... 24

2.8. Regular Expression ................................................................................................ 27

2.9. Regular Grammar .................................................................................................. 29

2.10. Pumping Lemma for Regular Grammar ............................................................... 30

3. Formal Language .................................................................................... 333.1. Definition and Description ..................................................................................... 33

3.2. Phase Structured Grammar or Chomsky Classification of Languages/Chomsky Hierarchy ................................................................................................ 33

3.3. Properties of Families of Languages ..................................................................... 34

( vii )

Page 10: THEORY OF COMPUTATION · closure properties of Regular languages, Context free grammars, Simplification of Context free grammars and Normal forms, Properties of context free languages

4. Regular Expression ................................................................................. 384.1. Finite Automata ..................................................................................................... 38

4.2. Equivalence of Finite Automata and Regular Expression ................................... 38

4.3. Equivalence of Two-Way Finite Automata............................................................ 39

5. Context Free Grammar............................................................................ 425.1. Grammar and Context Free Language ................................................................. 42

5.2. Derivation Tree (Parse Tree) ................................................................................. 43

5.3. Unrestricted Grammar .......................................................................................... 43

5.4. Ambiguous Context Free Language ...................................................................... 45

5.5. Simplification of Context Free Grammars ............................................................ 45

5.6. Normal Form of CFG.............................................................................................. 48

6. Pushdown Automata ............................................................................... 506.1. Pushdown Automata .............................................................................................. 50

6.2. Nondeterministic Pushdown Automata ................................................................ 53

6.3. Pushdown Automata and Context Free Grammar ............................................... 54

6.4. Two-way Pushdown Automaton ............................................................................ 55

6.5. Parsing .................................................................................................................... 58

6.6. Pumping Lemma for CFG ..................................................................................... 61

6.7. Context Free Language .......................................................................................... 62

6.8. Pumping Lemma for CFL (Context Free Language) ............................................ 62

7. Turing Machine ........................................................................................ 647.1. Introduction ............................................................................................................ 64

7.2. Model of Turing Machine ....................................................................................... 64

7.3. Languages Accepted by Turing Machine............................................................... 65

7.4. Universal Turing Machine ..................................................................................... 66

7.5. Determinism in Turing Machine ........................................................................... 66

7.6. Non-determinism in Turing Machine .................................................................... 66

8. Types of Turing Machine ......................................................................... 678.1. Introduction ............................................................................................................ 67

8.2. Halting Problem of Turing Machine ...................................................................... 68

8.3. Post Correspondence Problem ............................................................................... 68

( viii )

Page 11: THEORY OF COMPUTATION · closure properties of Regular languages, Context free grammars, Simplification of Context free grammars and Normal forms, Properties of context free languages

9. Computability........................................................................................... 699.1. Introduction to Complexity Theory ....................................................................... 69

9.2. Introduction to Undecidability Recursively Enumerable Sets ............................. 71

10. Context Sensitive Language .................................................................. 7310.1. Context Sensitive Language .................................................................................. 73

10.2. Primitive Recursive Functions ............................................................................... 74

10.3. Linear Bounded Automata ..................................................................................... 74

10.4. Types of Grammar and its Hierarchy .................................................................... 76

Appendix ........................................................................................................... 77

Solved Examples ............................................................................................ 116

Important University Solved Problems......................................................... 126

Objective Type Questions.............................................................................. 137

Question Papers ............................................................................................. 146

Index ................................................................................................................ 205

( ix )

Page 12: THEORY OF COMPUTATION · closure properties of Regular languages, Context free grammars, Simplification of Context free grammars and Normal forms, Properties of context free languages
Page 13: THEORY OF COMPUTATION · closure properties of Regular languages, Context free grammars, Simplification of Context free grammars and Normal forms, Properties of context free languages

We are highly delighted to place the book title “Theory of Computation” in the hands of oneesteemed readers.

This book has been written for B.E. (IT & CS), MCA, BSc, BCA, MSc and other computerprogrammes students keeping in view the following special points :

• Conceptual clarity and practical orientation.• To learn the basic concept used in the design and analysis of Theory of Computation.• Introduces the principles of Theory of Computation.• Provides various methods and techniques suitable for a variety of applications.• Covers all aspects of automata.• Covers abundance of examples and their solutions.We have put our sincere efforts and knowledge to make you understand the subject

matter in simplest and easiest way. Valuable suggestions are always welcome.We have considered the syllabus of Barkatullah University, RGPV, Delhi University

and Devi Ahilya University and tried to simplify language of other books.

—Authors

PPPPPREFREFREFREFREFAAAAACECECECECE

( xi )

Page 14: THEORY OF COMPUTATION · closure properties of Regular languages, Context free grammars, Simplification of Context free grammars and Normal forms, Properties of context free languages

We take this opportunity to expresses our gratitude and thanks to the collegues for theirvaluable technical suggestions and constant encouragement, without which this book wouldnot come into existence.

We are grateful to our family members for inspiring us for this project.We deeply express our heartful thanks to the publishers for publishing this book in

such a beautiful get-up and well in time.

—Authors

AAAAACKNOCKNOCKNOCKNOCKNOWLEDGEMENTWLEDGEMENTWLEDGEMENTWLEDGEMENTWLEDGEMENTSSSSS

( xii )

Page 15: THEORY OF COMPUTATION · closure properties of Regular languages, Context free grammars, Simplification of Context free grammars and Normal forms, Properties of context free languages

BARKATULLAH UNIVERSITY(Theory of Computation)

Unit I

Introduction to Theory of Computation and Finite Automata. MathematicalPreliminaries and Notation : Sets, functions and relations, Graphs and Trees, Proof Techniques,Basic concepts, Languages, Grammars, automatas, deterministic finite accepters, Deterministicaccepters and Transition Graphs, Languages, Non deterministic finite accepters, definition ofa NDFA, Equivalence of DFA and NDFA, Reduction of the Number of states in finite automata.

Unit II

Grammars and Languages. Regular expression, Regular Grammar, Regular languages,closure properties of Regular languages, Context free grammars, Simplification of Contextfree grammars and Normal forms, Properties of context free languages.

Unit III

Pushdown Automata. Non deterministic pushdown automata : Definition of a pushdownautomata, The language accepted by a pushdown automata, Pushdown automata and contextfree languages, Pushdown automata for context free languages, CFG’s for PDA, DeterministicPushdown automata and Deterministic Context free languages, Grammars and Deterministiccontext free languages.

Unit IV

Turing Machines. The Standard Turing Machine : Definition of a Turing Machine, TuringMachines as language accepters, and Turing Machines as Transducers. Combining TuringMachines for complicated tasks, Turing thesis, other models of Turing Machines.

Unit V

Computability. Limits of algorithmic computation, Some Problems that can not be solved byTuring Machines, Computability and Decidability, the Turing Machine Halting Problem,Reducing one Undecidable Problem to another, Undecidable Problems for RecursivelyEnumerable languages, The post correspondence problem: Indecidable problems for contextfree languages, Recursive function, Primitives recursive functions, Ackermanris functions,recursive functions, Post Systems : Rewriting systems : Matrix grammars, Markov Algorithms.

SSSSSYLLABUSESYLLABUSESYLLABUSESYLLABUSESYLLABUSES OFOFOFOFOF V V V V VARIOUSARIOUSARIOUSARIOUSARIOUS U U U U UNIVERSITIESNIVERSITIESNIVERSITIESNIVERSITIESNIVERSITIES

( xiii )

Page 16: THEORY OF COMPUTATION · closure properties of Regular languages, Context free grammars, Simplification of Context free grammars and Normal forms, Properties of context free languages

Theory Of Computation

Publisher : Laxmi Publications ISBN : 9789383828258 Author : Poonam Sinha

Type the URL : http://www.kopykitab.com/product/11683

Get this eBook

40%OFF