SlideShare a Scribd company logo
Elements Of Computation Theory Arindama Singh
Auth download
https://ebookbell.com/product/elements-of-computation-theory-
arindama-singh-auth-1144586
Explore and download more ebooks at ebookbell.com
Here are some recommended products that we believe you will be
interested in. You can click the link to download.
Elements Of Plasticity Theory And Computation High Performance
Structures And Materials Second I Doltsinis
https://ebookbell.com/product/elements-of-plasticity-theory-and-
computation-high-performance-structures-and-materials-second-i-
doltsinis-2444106
Finite Element Solution Of Boundary Value Problems Theory And
Computation O Axelsson
https://ebookbell.com/product/finite-element-solution-of-boundary-
value-problems-theory-and-computation-o-axelsson-4450898
Computational Elasticity Theory Of Elasticity Finite And Boundary
Element Methods Revised Edition 4th Mohammed Ameen
https://ebookbell.com/product/computational-elasticity-theory-of-
elasticity-finite-and-boundary-element-methods-revised-edition-4th-
mohammed-ameen-53598446
Elements Of Quantum Computation And Quantum Communication Pathak
https://ebookbell.com/product/elements-of-quantum-computation-and-
quantum-communication-pathak-5145140
Computation Of Nonlinear Structures Extremely Large Elements For
Frames Plates And Shells Ray
https://ebookbell.com/product/computation-of-nonlinear-structures-
extremely-large-elements-for-frames-plates-and-shells-ray-32704932
Engineering Computation Of Structures The Finite Element Method 1st
Edition Maria Augusta Neto
https://ebookbell.com/product/engineering-computation-of-structures-
the-finite-element-method-1st-edition-maria-augusta-neto-5234570
Elements Of Computational Systems Biology Wiley Series In
Bioinformatics 1st Edition Huma M Lodhi
https://ebookbell.com/product/elements-of-computational-systems-
biology-wiley-series-in-bioinformatics-1st-edition-huma-m-
lodhi-2378414
Elements Of Computational Statistics James E Gentle
https://ebookbell.com/product/elements-of-computational-statistics-
james-e-gentle-1310482
Basic Elements Of Computational Statistics Hrdle Wolfgang Okhrin
https://ebookbell.com/product/basic-elements-of-computational-
statistics-hrdle-wolfgang-okhrin-6751384
Elements Of Computation Theory Arindama Singh Auth
Elements Of Computation Theory Arindama Singh Auth
Texts in Computer Science
Editors
David Gries
Fred B. Schneider
For other titles published in this series, go to
http://www.springer.com/series/3191
Arindama Singh
Elements of Computation
Theory
ABC
Arindama Singh
Department of Mathematics
Indian Institute of Technology Madras
Sardar Patel Road
Chennai - 600036
India
asingh@iitm.ac.in
Series Editors
David Gries
Department of Computer Science
Upson Hall
Cornell University
Ithaca, NY 14853-7501, USA
Fred B. Schneider
Department of Computer Science
Upson Hall
Cornell University
Ithaca, NY 14853-7501, USA
ISSN 1868-0941 e-ISSN 1868-095X
ISBN 978-1-84882-496-6 e-ISBN 978-1-84882-497-3
DOI 10.1007/978-1-84882-497-3
Springer Dordrecht Heidelberg London New York
British Library Cataloguing in Publication Data
A catalogue record for this book is available from the British Library
Library of Congress Control Number: applied for
c
 Springer-Verlag London Limited 2009
Apart from any fair dealing for the purposes of research or private study, or criticism or review, as
permitted under the Copyright, Designs and Patents Act of 1988, this publication may only be repro-
duced, stored or transmitted, in any form or by any means, with the prior permission in writing of the
publishers, or in the case of reprographic reproduction in accordance with the terms of licences issued by
the Copyright Licensing Agency. Enquiries concerning reproduction outside those terms should be sent
to the publishers.
The use of registered names, trademarks, etc. in this publication does not imply, even in the absence of a
specific statement, that such names are exempt from the relevant laws and regulations and therefore free
for general use.
The publisher makes no representation, express or implied, with regard to the accuracy of the information
contained in this book and cannot accept any legal responsibility or liability for any errors or omissions
that may be made.
Cover design: SPi Publisher Services
Printed on acid-free paper
Springer is part of Springer Science+Business Media (www.springer.com)
Preface
The foundation of computer science is built upon the following questions:
What is an algorithm?
What can be computed and what cannot be computed?
What does it mean for a function to be computable?
How does computational power depend upon programming constructs?
Which algorithms can be considered feasible?
For more than 70 years, computer scientists are searching for answers to such ques-
tions. Their ingenious techniques used in answering these questions form the theory
of computation.
Theory of computation deals with the most fundamental ideas of computer sci-
ence in an abstract but easily understood form. The notions and techniques employed
are widely spread across various topics and are found in almost every branch of com-
puter science. It has thus become more than a necessity to revisit the foundation, learn
the techniques, and apply them with confidence.
Overview and Goals
This book is about this solid, beautiful, and pervasive foundation of computer sci-
ence. It introduces the fundamental notions, models, techniques, and results that
form the basic paradigms of computing. It gives an introduction to the concepts and
mathematics that computer scientists of our day use to model, to argue about, and
to predict the behavior of algorithms and computation. The topics chosen here have
shown remarkable persistence over the years and are very much in current use.
The book realizes the following goals:
• To introduce to the students of computer science and mathematics the elegant and
useful models and abstractions that have been created over the years for solving
foundational problems about computation
• To help the students develop the ability to form abstract models of their own and
to reason about them
• To strengthen the students’ capability for carrying out formal and rigorous
arguments about algorithms
v
vi Preface
• To equip the students with the knowledge of the computational procedures that
have hunted our predecessors, so that they can identify similar problems and struc-
tures whenever they encounter one
• To make the essential elements of the theory of computation accessible to not-
so-matured students having not much mathematical background, in a way that is
mathematically uncompromising
• To make the students realize that mathematical rigour in arguing about algorithms
can be very attractive
• To keep in touch with the foundations as computer science has become a much
more matured and established discipline
Organization
Chapter 1 reviews very briefly the mathematical preliminaries such as set theory,
relations, graphs, trees, functions, cardinality, Cantor’s diagonalization, induction,
and pigeon hole principle. The pace is not uniform. The topics supposedly unknown
to Juniors are discussed in detail.
The next three chapters talk about regular languages. Chapter 2 introduces the
four mechanisms such as regular expressions, regular grammars, deterministic fi-
nite automata, and the nondeterministic finite automata for representing languages
in their own way. The fact that all these mechanisms represent the same class of
languages is shown in Chap. 3. The closure properties of such languages, existence
of other languages, other structural properties such as almost periodicity, Myhill–
Nerode theorem, and state minimization are discussed in Chap. 4.
Chapters 5 and 6 concern the class of context-free languages. Here we discuss
context-free grammars, Pushdown automata, their equivalence, closure properties,
and existence of noncontext-free languages. We also discuss parsing, ambiguity, and
the two normal forms of Chomsky and Greibach. Deterministic pushdown automata
have been introduced, but their equivalence to LR(k) grammars are not proved.
Chapters 7 and 8 discuss the true nature of general algorithms introducing the
unrestricted grammars, Turing machines, and their equivalence. We show how to take
advantage of modularity of Turing machines for doing some complex jobs. Many
possible extensions of Turing machines are tried and shown to be equivalent to the
standard ones. Here, we show how Turing machines can be used to compute functions
and decide languages. This leads to the acceptance problem and its undecidability.
Chapter 9 discusses the jobs that can be done by algorithms and the jobs that
cannot be. We discuss decision problems about regular languages, context-free lan-
guages, and computably enumerable languages. The latter class is tackled greedily
by the use of Rice’s theorem. Other than problems from language theory, we discuss
unsolvability of Post’s correspondence problem, the validity problem of first order
logic, and of Hilbert’s tenth problem.
Chapter 10 is a concise account of both space and time complexity. The main
techniques of log space reduction, polynomial time reduction, and simulations in-
cluding Savitch’s theorem and tape compression are explained with motivation and
rigour. The important notions of N LS-completeness and NP-completeness are ex-
plained at length. After proving the Cook–Levin theorem, the modern approach of
using gadgets in problem reduction and the three versions of optimization problems
are discussed with examples.
Preface vii
Special Features
There are places where the approach has become nonconventional. For example,
transducers are in additional problems, nondeterministic automata read only sym-
bols not strings, pushdown automata require both final states and an empty stack for
acceptance, normal forms are not used for proving the pumping lemma for context-
free languages, Turing machines use tapes extended both ways having an accepting
state and a rejecting state, and acceptance problem is dealt with before talking about
halting problem. Some of the other features are the following:
• All bold-faced phrases are defined in the context; these are our definitions.
• Each definition is preceded by a motivating dialogue and succeeded by one or
more examples.
• Proofs always discuss a plan of attack and then proceed in a straightforward and
rigorous manner.
• Exercises are spread throughout the text forcing lateral thinking.
• Problems are included at the end of each section for reinforcing the notions learnt
so far.
• Each chapter ends with a summary, bibliographical remarks, and additional
problems. These problems are the unusual and hard ones; they require the guid-
ance of a teacher or browsing through the cited references.
• An unnumbered chapter titled Answers/Hints to Selected Problems contains
solutions to more than 500 out of more than 2,000 problems.
• It promotes interactive learning building the confidence of the student.
• It emphasizes the intuitive aspects and theirrealization with rigorous formalization.
Target Audience
This is a text book primarily meant for a semester course at the Juniors level. In
IIT Madras, such a course is offered to undergraduate Engineering students at their
fifth semester (third year after schooling). The course is also credited by masters
students from various disciplines. Naturally, the additional problems are tried by such
masters students and sometimes by unusually bright undergraduates. The book (in
notes form) has also been used for a course on Formal Language Theory offered to
Masters and research scholars in mathematics.
Notes to the Instructor
The book contains a bit more than that can be worked out (not just covered) in a
semester. The primary reason is: these topics form a prerequisite for undertaking
any meaningful research in computer science. The secondary reason is the variety of
syllabi followed in universities across the globe. Thus, courses on automata theory,
formal languages, computability, and complexity can be offered, giving stress on
suitable topics and mentioning others. I have taught different courses at different
levels from it sticking to the core topics.
The core topics include a quick review of the mathematical preliminaries
(Chap. 1), various mechanisms for regular languages (Chap. 2), closure proper-
ties and pumping lemma for regular languages (Sects. 4.2 and 4.3), context-free
viii Preface
languages (Sects. 5.2–5.4), pushdown automata, pumping lemma and closure prop-
erties of context-free languages (Sects. 6.2, 6.4, and 6.5), computably enumerable
languages (Chap. 7), a noncomputably enumerable language (Chap. 8), algorithmic
solvability (Sects. 9.2–9.4), and computational complexity (Chap. 10). Depending
on the stress on certain aspects, some of the proofs from these core topics can be
omitted and other topics can be added.
Chennai, Arindama Singh
January 2009
Acknowledgements
I cheerfully thank
My students for expressing their wish to see my notes in the book form,
IIT Madras for keeping me off from teaching for a semester, for putting a deadline
for early publication, and for partial financial support under the Golden Jubilee Book
Writing Scheme,
Prof. David Gries and Prof. Fred B. Schneider, series editors for Springer texts in
computer science,
Mr. Wayne Wheeler and his editorial team for painstakingly going through the
manuscript and suggesting improvements in presentation,
Prof. Chitta Baral of Arizona State University for suggesting to include the chapter
on mathematical preliminaries,
Prof. Robert I. Soare of the University of Chicago, Dr. Abhaya Nayak of Maquarie
University, and Dr. Sounaka Mishra of IIT Madras for suggesting improvements,
My family, including my father Bansidhar Singh, mother Ragalata Singh, wife
Archana, son Anindya Ambuj, daughter Ananya Asmita, for tolerating my obses-
sion with the book, and
My friends Mr. Biswa R Patnaik (in Canada) and Mr. Sankarsan Mohanty (in Orissa)
for their ever inspiring words.
Arindama Singh
ix
Contents
1 Mathematical Preliminaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.3 Relations and Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.4 Functions and Counting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.5 Proof Techniques . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
1.6 Summary and Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2 Regular Languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
2.2 Language Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
2.3 Regular Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
2.4 Regular Grammars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
2.5 Deterministic Finite Automata. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
2.6 Nondeterministic Finite Automata . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
2.7 Summary and Additional Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
3 Equivalences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
3.2 NFA to DFA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
3.3 Finite Automata and Regular Grammars . . . . . . . . . . . . . . . . . . . . . . . 76
3.4 Regular Expression to NFA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
3.5 NFA to Regular Expression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
3.6 Summary and Additional Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
4 Structure of Regular Languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
4.2 Closure Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
4.3 Nonregular Languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
4.4 Myhill–Nerode Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
4.5 State Minimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
4.6 Summary and Additional Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
xi
xii Contents
5 Context-free Languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
5.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
5.2 Context-free Grammars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
5.3 Parse Trees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
5.4 Ambiguity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
5.5 Eliminating Ugly Productions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
5.6 Normal Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
5.7 Summary and Additional Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
6 Structure of CFLs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
6.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
6.2 Pushdown Automata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
6.3 CFG and PDA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
6.4 Pumping Lemma . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
6.5 Closure Properties of CFLs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
6.6 Deterministic Pushdown Automata . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
6.7 Summary and Additional Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
7 Computably Enumerable Languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
7.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
7.2 Unrestricted Grammars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
7.3 Turing Machines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
7.4 Acceptance and Rejection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
7.5 Using Old Machines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
7.6 Multitape TMs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
7.7 Nondeterministic TMs and Grammars . . . . . . . . . . . . . . . . . . . . . . . . . 233
7.8 Summary and Additional Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . 240
8 A Noncomputably Enumerable Language . . . . . . . . . . . . . . . . . . . . . . . . . 245
8.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
8.2 Turing Machines as Computers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246
8.3 TMs as Language Deciders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
8.4 How Many Machines? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
8.5 Acceptance Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
8.6 Chomsky Hierarchy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267
8.7 Summary and Additional Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
9 Algorithmic Solvability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
9.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
9.2 Problem Reduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282
9.3 Rice’s Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
9.4 About Finite Automata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
9.5 About PDA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
9.6 Post’s Correspondence Problem. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301
9.7 About Logical Theories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307
9.8 Other Interesting Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314
9.9 Summary and Additional Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . 316
Contents xiii
10 Computational Complexity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327
10.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327
10.2 Rate of Growth of Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328
10.3 Complexity Classes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333
10.4 Space Complexity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338
10.5 Time Complexity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342
10.6 The Class NP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348
10.7 NP-Completeness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352
10.8 Some NP-Complete Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358
10.9 Dealing with NP-Complete Problems . . . . . . . . . . . . . . . . . . . . . . . . . . 369
10.10 Summary and Additional Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . 372
Answers and Hints to Selected Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415
1 Mathematical
Preliminaries
1.1 Introduction
An African explorer conversant with the language of the Hottentot tribe asks a native,
“How many children do you have?” The tribesman answers, “Many.” The determined
explorer persists on. He shows his index finger, meaning “one?” Promptly comes the
answer, “no.” He adds his middle finger, meaning “two”; the answer is “no”; “three?,”
“no”; “four,” “no.” Now all the five fingers on the explorer’s right hand are straight.
Answer comes, “yes.” The puzzled explorer experiments with another tribesman.
Over the next week, he discovers that they have only three kinds of numbers, one,
two, and many.
It is an old story, but perhaps not without morals. The Hottentot tribesman does
not have a way of naming the numbers more than two. How does he manage his
cattle?
Our mathematical tradition has gone so far and so deep that it is indeed difficult
to imagine living without it. In this small chapter, we will discuss a fragment of this
tradition so that the rituals of learning the theory of computation can be conducted
relatively easily. In the process, we will fix our notation.
1.2 Sets
A set is a collection of objects, called its members or elements. When writing a set by
showing its elements, we write it with two closing curly brackets. The curly brackets
serve two purposes: one, it shows the elements inside, and two, it says that the whole
thing put together is another object on its own right. Sometimes, we become tired of
writing out all the elements, and we put three dots. For example,
{pen, pencil, knife, scissors, paper, chalk, duster, paper weight, . . .}
is the set of names of educational stationery. It is the extensional way of representing
a set. But what about the expression, “the set of names of educational stationery?”
It is a set, nonetheless, and the same set as above. We thus agree to represent a
A. Singh, Elements of Computation Theory, Texts in Computer Science, 1
c
 Springer-Verlag London Limited 2009
2 1 Mathematical Preliminaries
set by specifying a property that may be satisfied by each of its elements. It is the
intensional way of representing a set. (Note the spelling of “intensional.”) If A is a
set and a is an element in A, we write it as a ∈ A. The fact that a is not an element
of A is written as a ∈ A.
When specifying a set by a property, we write it as {x : P(x)}, meaning that this
set has all and only those x as elements which satisfy a certain property P(·). Two sets
A, B are said to be the same set, written A = B, if each element of A is in B and each
element of B is in A. In that case, their defining properties must be logically equiv-
alent. For example, the set {2, 4, 6, 8} can be written as {x : x = 2 or x = 4 or x =
6 or x = 8}. Also, {2, 4, 6, 8} = {x : 2 divides x and x is an integer with 0  x 
10}. Further, {2, 4, 6, 8} = {4, 8, 6, 2}; the order of the elements when written down
explicitly, does not matter, and it is assumed that there are no repetitions of elements
in a set.
Two sets A, B are equal, written A = B, whenever they have precisely the same
elements. We say that A is a subset of a set B, written A ⊆ B, whenever each
element of A is in B. Similarly, we say that A is a proper subset of B, written
A  B, whenever A ⊆ B but A  B. Thus, A = B iff A ⊆ B and B ⊆ A. We
abbreviate the phrase “if and only if” to “iff.”
A mathematical discourse fixes a big set, called the universal set often denoted
by U. All other sets considered are subsets of this big set in that particular context.
As a convention, this big set is never mentioned, and if strict formal justification is
required, then this is brought into picture.
Let A, B be sets and let U be the universal set (in this context, of course). The
union of A, B is written as A ∪ B = {x : x ∈ A or x ∈ B}. The intersection of A, B
is A ∩ B = {x : x ∈ A and x ∈ B}. The difference of A, B is A − B = {x : x ∈ A
but x ∈ B}. The complement of A is A = U − A = {x : x ∈ A}.
We define the empty set ∅ as a set having no elements; ∅ = {x : x  x} = { }.
For any set A, ∅ = A − A. We find that A ∪ ∅ = A and A ∩ U = A. Moreover,
∅ is unique, whatever be the universal set. When two sets A, B have no common
elements, we say that they are disjoint and write it as A ∩ B = ∅. For example, with
the universal set as the set of all natural numbers N = {0, 1, 2, . . .}, A as the set of
all prime numbers, and B as the set of all composite numbers, we see that
A ∩ B = ∅, A ∪ B = N − {0, 1} = {0, 1}.
The power set of A, denoted by 2A
, is the set of all subsets of A. An ordered
pair of two objects a, b is denoted by (a, b), which can also be written as a set. For
example, we may define (a, b) = {{a}, {a, b}}. We see that the ordered pair satisfies
the following property:
(a, b) = (c, d) iff a = c and b = d.
In fact, it is enough for us to remember this property of the ordered pairs. The Carte-
sian product of the sets A and B is A × B = {(x, y) : x ∈ A and y ∈ B}.
The operations of union, intersection, and the (Cartesian) product can be extended
further. Suppose A = {Ai : i ∈ I} is a collection of sets Ai , where I is some set,
called an index set here. Then, we define
1.3 Relations and Graphs 3
∪A = ∪i∈I Ai = {x : x is in some Ai }.
∩A = ∩i∈I Ai = {x : x is in each Ai }.
For the product, we first define an n-tuple of objects by
(a1, a2, . . . , an) = ((a1, a2, . . . , an−1), an), when n  2.
Finally, we write
A1 × A2 × · · · × An = {(x1, x2, . . . , xn) : each xi ∈ Ai , for i = 1, . . . , n}.
When each Ai = A, we write this n-product as An
. Similarly, arbitrary Cartesian
product can be defined though we will use only a finite product such as this. Be-
cause of the above property of ordered pairs, and thus of n-tuples, the kth coordinate
becomes meaningful. The kth coordinate of the n-tuple (x1, x2, . . . , xn) is xk.
Clearly, A × ∅ = ∅ × A = ∅. In addition, we have the following identities:
Double Complement: A = A.
De Morgan : A ∪ B = A ∩ B, A ∩ B = A ∪ B.
Commutativity: A ∪ B = B ∪ A, A ∩ B = B ∩ A.
Associativity : A ∪ (B ∪ C) = (A ∪ B) ∪ C, A ∩ (B ∩ C) = (A ∩ B) ∩ C.
Distributivity : A ∪(B ∩C) = (A ∪ B)∩(A ∪C), A ∩(B ∪C) = (A ∩ B)∪(A ∩C),
A × (B ∪ C) = (A × B) ∪ (A × C), A × (B ∩ C) = (A × B) ∩ (A × C),
A × (B − C) = (A × B) − (A × C).
1.3 Relations and Graphs
We use the relations in an extensional sense. The binary relation of “is a son of”
between human beings is thus captured by the set of all ordered pairs of human
beings, where the first coordinate of each ordered pair is a son of the second coordi-
nate. A binary relation from a set A to a set B is a subset of A × B. If R is such a
relation, a typical element in R is an ordered pair (a, b), where a ∈ A and b ∈ B are
suitable elements. The fact that a and b are related by R is written as (a, b) ∈ R; we
also write it as R(a, b) or as aRb.
Any relation R ⊆ A × A is called a binary relation on the set A. Similarly,
an n-ary relation on a set A is some subset of An
. For example, take P as a line and
a, b, c as points on P. Write B(a, b, c) for “b is between a and c.” Then B is a ternary
relation, that is, B ⊆ P3
, and B(a, b, c) means the same thing as (a, b, c) ∈ B.
Unary relations on a set A are simply the subsets of A.
Binary relations on finite sets can conveniently be represented as diagrams. In
such a diagram, the elements of the set A are represented as small circles (points,
nodes, or vertices) on the plane and each ordered pair (a, b) ∈ R of elements
4 1 Mathematical Preliminaries
a, b ∈ A is represented as an arrow from a to b. We write inside each circle its name.
The diagrams are now called digraphs or directed graphs.
Example 1.1. The digraph for the relation R = {(a, a), (a, b), (a, d), (b, c), (b, d),
(c, d), (d, d)} on the set A = {a, b, c, d} is given in Fig. 1.1. 
Fig. 1.1. Digraph for R in
Example 1.1.
a b
c d
Sometimes we need to give names to the edges (arrows) in a digraph as we give
names to roads joining various places in a city. The resulting digraph is called a
labeled digraph. Labeled digraphs are objects having three components: a set of ver-
tices V , a set of edges E, and an incidence relation I ⊆ E ×V ×V, which specifies
which edge is incident from which vertex to which vertex.
Example 1.2. Figure 1.2 depicts the labeled digraph (V, E, I), where the vertex set
V = {a, b, c, d}, the edge set E = {e1, e2, e3, e4, e5, e6, e7}, and the incidence rela-
tion I = {(e1, a, a), (e2, a, b), (e3, a, d), (e4, b, c), (e5, b, d), (e6, c, d), (e7, d, d)}. 
Fig. 1.2. Labeled digraph
for Example 1.2.
a b
c d
e1
e2
e3
e4
e5
e6
e7
Sometimes we do not need to have the arrows in a digraph; just the undirected
edges suffice. In that case, the digraph is called an undirected graph or just a graph.
Usually, we redefine this new concept. We say that a graph is an object having a set
of vertices and a set of edges as components, where each edge is a two-elements set
(instead of an ordered pair) of vertices.
Example 1.3. The graph in Fig. 1.3 represents the graph G = (V, E), where V =
{a, b, c, d} and E = {{a, a}, {a, b}, {a, d}, {b, c}, {b, d}, {c, d}, {d, d}}.
1.3 Relations and Graphs 5
Fig. 1.3. Graph for
Example 1.3.
a b
c d
Two vertices in a graph are called adjacent if there is an edge between them.
A path in a graph is a sequence of vertices v1, v2, . . . , vn, such that each vi is ad-
jacent to vi+1. For example, in Fig. 1.3, the sequence a, a, b, c, d is a path, and so
are a, b, d and a, d, c. We say that the path v1, v2, . . . , vn connects the vertices v1
and vn. Moreover, the starting point of the path v1, v2, . . . , vn is v1 and its end point
is vn. Similarly, directed paths are defined in digraphs.
A graph is called connected if each vertex is connected to each other by some path
(not necessarily the same path). For example, the graph of Fig. 1.3 is a connected
graph. If you delete the edges {a, d}, {b, c}, {b, d}, then the resulting graph is not
connected. Similarly, if you remove the edges {a, b}, {a, d}, then the resulting graph
is not connected either.
A path v1, v2, . . . , vn, v1 is called a cycle when n  2 and no vertex, other than the
starting point and the end point, is repeated. A connected cycleless graph is called a
tree. By giving directions to the edges in a tree, we obtain a directed tree.
In a directed tree, if there is exactly one vertex towards which no arrow comes
but all edges incident with it are directed outward, the vertex is called the root of the
tree. Similarly, any vertex in a directed tree from which no edge is directed outward
is called a leaf. It is easy to see that there can be only one edge incident with a leaf
and that edge is directed toward the leaf. Because, otherwise, there will be a cycle
containing the leaf! A tree having a root is called a rooted tree.
Example 1.4. The graph on left side in Fig. 1.4 is a rooted tree with c as its root. It
is redrawn on the right in a different way. 
a
b
c
d
e
f
a b e
c
d f
Fig. 1.4. Trees for Example 1.4.
The trees in Fig. 1.4 are redrawn in Fig. 1.5 omitting the directions. Since the
direction of edges are always from the root toward any vertex, we simply omit the
6 1 Mathematical Preliminaries
directions. We will use the word “tree” for rooted trees and draw them without di-
rections. Sometimes, we do not put the small circles around the vertices. The tree on
left side in Fig. 1.5 uses this convention of drawing the trees in Fig. 1.4. It is further
abbreviated in the right side tree of the same figure.
In Fig. 1.5, all children of a vertex are placed below it and are joined to the parent
vertex by an undirected edge. We say that the root c has depth 0; the children of the
root are the vertices of depth 1 in the tree; the depth 2 vertices are the vertices that
have an edge from the vertices of depth 1; these are children of the children of the
root, and so on. In a tree, the depth is well defined; it shows the distance of a vertex
from the root. The depth of a tree is also called its height, and trees in computer
science grow downward!
c
a b e
d f
a b e
c
d f
Fig. 1.5. Trees for Example 1.4 redrawn.
Leaves of the tree in Fig. 1.5 are the vertices a, b, d, and f. The nonleaf vertices
are called the branch nodes (also, branch points or branch vertices).
With this short diversion on representing relations as graphs, we turn towards
various kinds of properties that a relation might satisfy. Suppose R is a binary relation
on a set A. The most common properties associated with R are
Reflexivity : for each x ∈ A, xRx.
Symmetry : for each pair of elements x, y ∈ A, if xRy, then yRx.
Antisymmetry : for each pair of elements x, y ∈ A, if xRy and yRx, then x = y.
Transitivity : for each triple of elements x, y, z ∈ A, if xRy and yRz, then xRz.
A binary relation can be both symmetric and antisymmetric, or even neither.
For example, on the set A = {a, b}, the relation R = {(a, a), (b, b)} is reflex-
ive, symmetric, transitive, and antisymmetric. On the other hand, the relation S =
{(a, b), (a, c), (c, a)} on A is neither reflexive, nor symmetric, nor antisymmetric,
nor transitive.
Given a binary relation R on a set A, we can extend it by including some more
ordered pairs of elements of A so that the resulting relation is both reflexive and
transitive. Such a minimal extension is called the reflexive and transitive closure
of R.
Example 1.5. What is the reflexive and transitive closure of R = {(a, b), (b, c),
(c, b), (c, d)} on the set A = {a, b, c, d}?
1.3 Relations and Graphs 7
Solution. Include the pairs (a, a), (b, b), (c, c), (d, d) to make it reflexive. You have
R1 = {(a, a), (a, b), (b, b), (b, c), (c, b), (c, c), (c, d), (d, d)}.
Since (a, b), (b, c) ∈ R1, include (a, c). Proceeding similarly, You arrive at
R2 = {(a, a), (a, b), (a, c), (b, b), (b, c), (b, d), (c, b), (c, c), (c, d), (d, d)}.
Since (a, b), (b, d) ∈ R2, include (a, d) to obtain
R3 = {(a, a), (a, b), (a, c), (a, d), (b, b), (b, c), (b, d), (c, b), (c, c), (c, d), (d, d)}.
You see that R3 is already reflexive and transitive; there is nothing more required to
be included. That is, the reflexive and transitive closure of R is R3. 
In Example 1.5, interpret (x, y) ∈ R to mean there is a communication link from
city x to city y, possibly, a one-way communication link. Then the reflexive and
transitive closure of R describes how messages can be transmitted from one city to
another either directly or via as many intermediate cities as possible. On the set of
human beings, if parenthood is the relation R, then its reflexive and transitive closure
gives the ancestor–descendant relationship, allowing one to be his/her own ancestor.
The inverse of a binary relation R from A to B, denoted by R−1
, is a relation
from B to A such that for each x ∈ A, y ∈ B, x R−1
y iff yRx. The inverse is also
well defined when R is a binary relation on a set A. For example, on the set of human
beings, the inverse of the relation of “teacher of” is the relation of “student of.” What
is the inverse of “father of?”
Suppose R is a binary relation on a set A. We say that R is a partial order on
A if it is reflexive, antisymmetric, and transitive. The relation of ≤ on the set of all
integers is a partial order. For another example, let S be a collection of sets. Define
the relation R on S by “for each pair of sets A, B ∈ S, ARB iff A ⊆ B.” Clearly, R
is a partial order on S.
A relation R is called an equivalence relation on A if it is reflexive, symmetric,
and transitive. The equality relation is obviously an equivalence relation, but there
can be others.
For example, in your university, two students are related by R if they are living in
the same dormitory. It is easy to see that R is an equivalence relation. You observe
that the students are now divided into as many classes as the number of dormitories.
Intuitively, the elements related by an equivalence relation share a common prop-
erty. The property divides the underlying set into many subsets, where elements of
any of these typical subsets are related to each other. Moreover, elements of one sub-
set are never related to elements of another subset. Let R be an equivalence relation
on a set A. For each x ∈ A, we define the equivalence class of x, denoted as [x], by
[x] = {y ∈ A : x Ry}.
Besides x, each element y ∈ [x] is a representative of the equivalence class [x]. We
define a partition of A as any collection A of disjoint nonempty subsets of A whose
union is A. The equivalence classes form the set, so to speak. We will see that its
converse is also true.
8 1 Mathematical Preliminaries
Theorem 1.1. Let R be a binary relation on a set A. If R is an equivalence relation,
then the equivalence classes of R form a partition of A. Conversely, if A is a partition
of A, then there is an equivalence relation R such that the elements of A are precisely
the equivalence classes of R.
Proof. Suppose R is an equivalence relation on a set A. Let A = {[x] : x ∈ A}, the
collection of all equivalence classes of elements of A. To see that A is a partition of
A, we must show two things.
(a) Each element of A is in some equivalence class.
(b) Any two distinct equivalence classes are disjoint.
The condition (a) is obvious as each x ∈ [x]. For (b), let [x] and [y] be distinct
equivalence classes. Suppose, on the contrary, that there is z ∈ [x] ∩ [y]. Now, x Rz
and yRz. By the symmetry and transitivity of R, we find that x Ry. In that case, for
each w ∈ [x], we have wRy as x Rw and yRx implies that yRw. This gives w ∈ [y].
That is, [x] ⊆ [y]. For each v ∈ [y], we have similarly vRx. This gives v ∈ [x].
That is, [y] ⊆ [x]. We arrive at [x] = [y], contradicting the fact that [x] and [y] are
distinct.
Conversely, suppose A is a partition of A. Define the binary relation R on A by
For each pair of elements x, y ∈ A, x Ry iff both x and y are elements of the
same subset B in A.
That means if a, b ∈ B1 ∈ A, then aRb, but if a ∈ B1 ∈ A and c ∈ B2 ∈ A, then
a and c are not related by R (assuming that B1  B2). Clearly, R is an equivalence
relation. To complete the proof, we show that
(i) Each equivalence class of R is an element of A.
(ii) Each element of A is an equivalence class of R.
For (i), let [x] be an equivalence class of R for some x ∈ A. This x is in some
B ∈ A. Now y ∈ [x] iff x Ry iff y ∈ B, by the very definition of R. That is, [x] = B.
Similarly for (ii), let B ∈ A. Take x ∈ B. Now y ∈ B iff yRx iff y ∈ [x]. This
shows that B = [x]. 
1.4 Functions and Counting
Intensionally, a function is a map that associates an element of a set to another, possi-
bly in a different set. For example, the square map associates a number to its square.
If the underlying sets are {1, 2, 3, 4, 5} and {1, 2, . . . , 50}, then the square map as-
sociates 1 to 1, 2 to 4, 3 to 9, 4 to 16, and 5 to 25. Extensionally, we would say
that the graph of the map (not the same graph of the last section, but the graph as
you have plotted on a graph sheet in your school days) is composed of the points
(1, 1), (2, 4), (3, 9), (4, 16), and (5, 25). We take up the extensional meaning and de-
fine a function as a special kind of a relation.
1.4 Functions and Counting 9
Let A, B be two sets. A partial function f from the set A to the set B is a relation
from A to B satisfying
for each x ∈ A, if x f y and x f z, then y = z.
This conforms to our intensional idea of a map, as no element x can be associated
with different elements by f. It is a partial function, as it is not required that each
element in A has to be taken to some element of B by f. We use the more suggestive
notation for a partial function by writing f : A → B. When x f y, we write y = f (x).
The set A is called the domain of f and the set B is called the co-domain of f.
A partial function f : A → B is called a total function if for each x ∈ A,
there is some y ∈ B such that y = f (x), that is, when f takes each element of A
to some (hence a unique, corresponding to that element of A) element of B. Note
that it does not say that all elements of A should be mapped to the same element
of B. Following tradition, we use the word function for a total function and use
the adjective “partial” for a partial function. To emphasize, a partial function is not
necessarily strictly partial.
The range of a partial or a total function is the subset of B, which are attained
by f , that is, the set {y ∈ B : y = f (x) for some x ∈ A}. If D ⊆ A, we write the
range of f as f (D) = { f (x) ∈ B : x ∈ D}.
Partial functions can be composed by following the internal arrows in succession,
as it is said. For example, if f : A → B, g : B → C are two maps, and a ∈ A, then
we can get f (a) in B, and then go to g( f (a)) in C by following the maps. This can
be done provided f (a) is defined, and also if g( f (a)) is defined. When both f, g are
total functions, this is obviously possible. The composition map is written as g ◦ f.
Notice the reverse notation; it helps in evaluation, that is, when it is defined for an
element a ∈ A, we have (g ◦ f )(a) = g( f (a)). The composition map g ◦ f : A → C.
The inverse of a partial function f : A → B is well defined; it is the relation f −1
defined from B to A. But f −1
is not necessarily a partial function. For example, the
square map on {1, −1} is a partial function (in fact, total) whose inverse is the relation
{(1, 1), (1, −1)}. This inverse, the square-root relation is not a partial function as 1
is taken to two distinct elements 1 and −1. This happens because the square map is
not one to one, it is many to one. A partial function f : A → B is called one–one if
for each x, y ∈ A, if x  y, then f (x)  f (y).
Equivalently, for each x, y ∈ A, if f (x) = f (y), then x = y. It is easy to see that the
inverse of a one–one partial function is again a one–one partial function. But inverse
of a total function (even if one–one) need not be a total function. Because, there
might be elements in its co-domain that are not attained by the map. We call a partial
function f : A → B an onto partial function (or say that f is a partial function from
A onto B) if
for each y ∈ B, there exists an x ∈ A such that y = f (x).
Equivalently, for an onto function, the range of f coincides with the co-domain of f.
It is easy to see that a one–one total function from A onto B has an inverse, which
is also a one–one total function from B onto A. A one–one total function is also
10 1 Mathematical Preliminaries
called an injection and an onto total function is called a surjection. A bijection
is a one–one onto total function. Two sets A and B are said to be in one-to-one
correspondence if there is a bijection from one to the other.
Suppose f : A → B, C ⊆ A, and D ⊆ B. The image of C under f is the set
{ f (x) : x ∈ C}, and is denote by f (C). Similarly, the inverse image of D under f
is the set {x : f (x) ∈ D} and is denoted by f −1
(D). The notation f −1
(D) should
not mislead you to think of f −1
as a partial function; as you have seen, it need not
be so. f −1
is a total function only when f is a bijection. In such a case, f ◦ f −1
is
the identity map on B and f −1
◦ f is the identity map on A. The identity map takes
each element to itself.
An arbitrary Cartesian product of sets can be defined using functions. An n-tuple
of elements from a set A can be given as a function f : {1, 2, . . ., n} → A. Here,
we simply rewrite the kth coordinate in the n-tuple as f (k). We use this observation
for an extension of the product. Suppose A = {Ai : i ∈ I} is a collection of sets Ai ,
where I is an index set. Then the product is defined as
×A = ×i∈I Ai = the set of all functions f : I → ∪A with f (i) ∈ Ai .
Recall that the Hottentot tribesman knew the meaning of one-to-one correspon-
dence; he could say that he had as many children as the fingers on the right hand of
the African explorer. The tribesman did not know the name of any number beyond
two. He could count but could not name the number he has counted. Probably, he
had a bag full of pebbles as many as the sheep he owned. This is how he used to
keep track of the sheep in his possession. The idea behind counting the elements of
a set is the same as that of the tribesman.
We say that two sets A and B have the same cardinality when there is a bijection
between them. We write cardinality of a set A as |A|. Cardinality of a set intuitively
captures the idea of the number of elements in a set. Notice that we have not defined
what |A| is; we have only defined |A| = |B|.
To make the comparison of cardinalities easier, we say |A| ≤ |B| if there is an
injection from A to B (a one–one total function from A to B). We say that |A| ≥
|B| if |B| ≤ |A|. Cantor–Schröder–Bernstein Theorem says that if |A| ≤ |B| and
|B| ≤ |A|, then |A| = |B|. (A proof is outlined in Problem 1.29.) Further, we write
|A|  |B| when |A| ≤ |B| but |A|  |B|; similarly, |A|  |B| when |A| ≥ |B| but
|A|  |B|.
Since the empty set ∅ has no elements, we define 0 = |∅|. We go a bit further and
define 1 = |{0}|. And then define inductively n + 1 = |{0, 1, . . . , n}|. These are our
natural numbers, elements of the set N = {0, 1, 2, . . .}. Then the operations of +
and × are defined on N in the usual way. Notice that + is a function that maps a pair
of natural numbers to a natural number, and so is ×. Of course, we simplify notation
by writing mn for m × n.
Once the natural numbers are defined, we define the integers by extending it to
Z = N ∪ {−1, −2, . . .} = N ∪ {−n : n ∈ N}, with the convention that −0 = 0. Notice
that −n is just a symbol, where we put a minus sign preceding a natural number.
The set of positive integers is defined as Z+ = N − {0} = Z − {−n : n ∈ N}. Then
the operations + and × are extended to Z in the usual way, n + (−n) = 0, etc. This
extension allows us to solve simple equations such as x + 5 = 2 in Z.
1.4 Functions and Counting 11
However, equations such as 5x = 2 cannot be solved in Z. We thus extend Z
by including symbols of the form m/n. We arrive at the set of rational numbers
Q = {p/q : p ∈ Z, q ∈ Z+}, with the usual conventions like (p/q) × q = p
and p/q = r/s when ps = rq, etc. We then see that each rational number can be
represented as a decimal number like m.n1n2n3 · · · with or without the minus sign,
where each ni is one of the digits 0, 1, . . . , 9 and m ∈ N. Such decimals representing
rational numbers satisfy a nice property:
Beyond some finite number of digits after the decimal point, a finite sequence of
digits keep recurring.
Further, we see that these recurring decimals uniquely represent rational numbers
with one exception: a decimal number with recurring 0’s can also be written as an-
other decimal with recurring 9’s. We agree to use the latter and discard the former if
uniqueness is at vogue. For example, the decimal 0.5 is written as 0.499999 · · · . This
guarantees a unique decimal representation of each number in Q. Also, this conven-
tion allows us to consider only the recurring infinite decimals instead of bothering
about terminating decimals.
We then extend our numbers to the real numbers. The set of real numbers, R, is
the set of all (infinite) decimals. The nonrecurring decimals are called the irrational
numbers, they form the set R−Q. This extension now allows us talking about square
roots of numbers. For example,
√
2 ∈ R, but
√
2 ∈ Q. However, we find that it is
not enough for solving polynomial equations, for example, there is no real number x
satisfying the equation x2
+ 1 = 0.
For solving polynomial equations, we would need the complex numbers. We de-
fine the set of complex numbers as C = {x + ıy : x, y ∈ R}, where ı is taken as
√
−1. Notice that ı is again a symbol which is used as
√
−1. The operations of +, ×,
taking roots, etc. are extended in the usual way to C. It can be shown that our quest
for solving polynomial equations stop with C. The Fundamental Theorem of Alge-
bra states that each polynomial of degree n with complex coefficients has exactly n
complex roots.
Besides, there are complex numbers that are not roots of any polynomial equation.
Moreover, we require to distinguish between surds like
√
2 and numbers like π. For
this purpose, we restrict our polynomials to have rational coefficients. We define
an algebraic number as a complex number, which is a solution of a polynomial
equation, where the polynomials have rational coefficients. Other complex numbers
are called transcendental numbers. In fact, there are more transcendental numbers
than the algebraic numbers (Problem 1.28), though we know a very few of them.
Further, there is a natural partial order on N, the ≤ relation. It so happens that
this relation can be extended to Z, Q, and R. However, it stops there; it cannot be
extended to C. This does not mean that there cannot be any partial order on C. For
example, define ≤ on C by a + ıb ≤ c + ıd iff a  c, or (a = c and b ≤ c), taking
the ≤ on R as the basis. You can verify that this defines a partial order on C. But this
is not an extension of the ≤ relation on R. Because our definition of the relation 
says that 0  ı, we should have 0 × 0  ı × ı = −1, which is not true.
Observe that by this process of extension, we have constructed some infinite sets,
the sets whose cardinalities cannot be written as natural numbers. Infinite sets can be
12 1 Mathematical Preliminaries
defined without using numbers. We say that a set is infinite or has infinite cardinality
if it has the same cardinality as one of its proper subsets. And a finite set is a set
which is not infinite. Naturally, a finite set has greater cardinality than any of its
proper subsets. For example, N is an infinite set as the function f : N → 2N defined
by f (n) = 2n is a bijection, where 2N denotes the set of all even natural numbers.
It can further be shown that a set is finite iff either it is ∅ or it is in one-to-one
correspondence with a set of the form {0, 1, . . ., n} for some natural number n. We
take it as our definition of a finite set. Using this, we would define an infinite set as
one which is not finite. Cardinalities of finite sets are now well defined : |∅| = 0, and
a set that is in one-to-one correspondence with {0, 1, . . ., n} has cardinality n + 1.
Can we similarly define the cardinalities of infinite sets?
Well, let us denote the cardinality of N as ℵ0; read it as aleph-null. Can we say that
all infinite sets have cardinality ℵ0? Again, let us increase our vocabulary. We call a
set denumerable (also called enumerable) if it is in one-to-one correspondence with
N, that is, having cardinality as ℵ0. The one-to-one correspondence with N gives
an enumeration of the set: if f : N → A is the bijection, then the elements of the
denumerable set A can be written as f (0), f (1), f (2), . . .. The following statement
should then be obvious.
Theorem 1.2. Each infinite subset of a denumerable set is denumerable.
Proof. Let A be an infinite subset of a denumerable set B. You then have a bijection
f : N → B. That is, elements of B are in the list: f (0), f (1), f (2), . . .. All elements
of A appear in this list exactly once. Define a function g : N → A by induction:
Take g(0) as the first element in the list, which is also in A.
Take g(k + 1) as the first element in the list occurring after g(k), which is in A.
This g is a bijection since A is infinite. 
Further, we say a set to be countable if it is either finite or denumerable. Since
each number n  ℵ0, (Why?) it follows from Theorem 1.2 that a set A is countable
iff |A| ≤ ℵ0 iff A is in one-to-one correspondence with a subset of N iff there is
a one–one function from A to N iff A is a subset of a countable set. Moreover, in
all these iff statements, N can be replaced by any other countable set. Further, A
is denumerable iff A is infinite and countable. A set that is not countable is called
uncountable.
Theorem 1.3. Z and Q are denumerable; thus countable.
Proof. For the denumerability of Z, we put all even numbers in one-to-one corre-
spondence with all natural numbers, and then put all odd natural numbers in one-to-
one correspondence with the negative integers.
To put it formally, observe that each natural number is in one of the forms 2n or
2n + 1. Define a function f : N → Z by f (2n) = n and f (2n + 1) = −(n + 1).
To visualize, f (0) = 0, f (1) = −1, f (2) = 1, f (3) = −2, . . . . It is easy to see that f
is a bijection. Therefore, Z is denumerable.
1.4 Functions and Counting 13
For the denumerability of Q, let QP denote the set of all symbols of the form p/q,
where p, q ∈ Z+. Also, denote the set of positive rational numbers by Q+. When
we look at these symbols as rational numbers, we find many repetitions. For exam-
ple, corresponding to the single element 1 in Q+, there are infinitely many elements
1/1, 2/2, 3/3, . . . in QP. We construct a one–one function from the set QP to Z+.
The elements of QP can be written in a two-dimensional array as shown below.
1
1 → 1
2
1
3 → 1
4
1
5 → 1
6 · · ·
    
2
1
2
2
2
3
2
4
2
5
2
6 · · ·
↓    
3
1
3
2
3
3
3
4
3
5
3
6 · · ·
  
4
1
4
2
4
3
4
4
4
5
4
6
· · ·
↓  
5
1
5
2
5
3
5
4
5
5
5
6 · · ·

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
...
In the first row are written all the numbers of the form 1/m, varying m over Z+ ;
in the second row, all the numbers of the form 2/m; etc. Any number p/q ∈ QP is
the qth element in the pth row. Thus the array exhausts all numbers in QP.
Now, start from 1
1 and follow the arrows to get an enumeration of numbers in the
array. This means that the (enumerating) function f : QP → Z+ is defined by
f

1
1

= 1, f

1
2

= 2, f

2
1

= 3, f

3
2

= 4, f

2
2

= 5, · · ·
We see that f is a one–one function.
Let QA = QP ∪ {0} ∪ {−p/q : p/q ∈ QP}. This set contains Q in the same
way as QP contains Q+. Extend f : QP → Z+ to the function f : QA → Z by
taking f (0) = 0 and f (−p/q) = − f (p/q) for p/q ∈ QP. This extended f is
also a one–one function. (Show it.) We thus have |QA| ≤ |Z|. Since QA is infinite,
it is denumerable. Since Q is an infinite subset of QA, by Theorem 1.2, it is also
denumerable. Finally, denumerability implies countability. 
The method of proof in Theorem 1.3 proves that Z+ ×Z+ is denumerable. All you
have to do is keep the ordered pair (m, n) in place of m/n in the array. For another
alternative proof of this fact, you can search for a one–one map from Z+ × Z+ to
Z+. One such is defined by f (m, n) = 2m
3n
. Just for curiosity, try to prove that the
function g : Z+ × Z+ → Z+ given by g(m, n) = 2m
(2n − 1) is a bijection.
It is then clear that (Cartesian) product of two countable sets is countable. You
can further extend to any finite number of products, as A × B × C is simply (A ×
B) × C, etc. The proof method also shows that a countable union of countable sets
14 1 Mathematical Preliminaries
is countable. Keep on the first row, the first countable set, on the second row, the
second countable set, and so on, and then proceed as in the above proof! Similarly,
a denumerable union of finite sets is denumerable. However, a denumerable product
of denumerable sets is not countable. Check whether you can prove it following the
proof of Theorem 1.4 below!
Sometimes a result can be too counter intuitive; Theorem 1.3 is one such. Unlike
N, if you choose any two numbers from Q, you can always get another number (in
fact, infinitely many numbers) between them. But this does not qualify Q to have
more elements than N. What about R, the set of real numbers?
Theorem 1.4. R is uncountable.
Proof. Let J = {x ∈ R : 0  x  1} be the open interval with 0 and 1 as its end
points; the end points are not in J. We first show that J is uncountable.
We use the famous diagonalization method of Georg Cantor. Suppose, on the
contrary, that J is countable. Then, we have a bijection g : N → J. The elements of J
can now be listed as g(0), g(1), g(2), . . . . But each number in J is a nonterminating
decimal number. Write all these numbers in J as in the following:
g(0) = 0.a11 a12 a13 a14 · · ·
g(1) = 0.a21 a22 a23 a24 · · ·
g(2) = 0.a31 a32 a33 a34 · · ·
g(3) = 0.a41 a42 a43 a44 · · ·
.
.
.
g(n − 1) = 0.an1 an2 an3 an4 · · · ann · · ·
.
.
.
where each ai j is one of the digits 0, 1, . . . , 9. Using this array of decimals, construct
a real number d = 0.d1 d2 d3 d4 · · · , where for each i ∈ Z+,
di equals 0 when aii = 9, otherwise, di equals aii + 1.
This number d is called the diagonal number. It differs from each number in the
above list. For example, d  g(0) as d1  a11, and d  g(n − 1) as dn  ann. But
this d is in J, contradicting the fact that the list contains each and every number in J.
Therefore, J is uncountable.
Since J ⊆ R, uncountability of R is proved. Of course, a stronger fact holds:
|J| = |R|. To see this, define a function f : J → R by f (x) = (x − 1/2)/(x − x2
).
Verify that f is a bijection. 
Recall that we have agreed to write sets by specifying a defining property of the
form {x : P(x)}. Existence of an uncountable set such as R dispenses the wrong
belief that every set can be expressed by a property and each property can give rise
to a set.
1.4 Functions and Counting 15
To see this, suppose you want to express properties in English. (In fact, any other
language will do.) Each such property is a finite sequence of symbols from the Ro-
man alphabet. For any fixed n, there are clearly a finite number of properties having
n occurrences of symbols. Hence, there are only a countable number of properties.
But there are uncountable number of sets, for example, sets of the type {r}, where r
is a real number. Hence, there are sets that do not correspond to any property. For the
converse, see the following example.
Example 1.6. Consider the property of “A ∈ A.” This property is perhaps meaning-
ful when A is a set. Let S be the set of all sets A such that A ∈ A. Now, is S ∈ S or
S ∈ S?
Solution. If S ∈ S, then by the very definition of S, we see that S ∈ S. Conversely, if
S ∈ S, then S satisfies the defining property of S, and thus S ∈ S. Therefore, S ∈ S
iff S ∈ S. 
The contradiction in Example 1.6 shows that there is no set corresponding to the
property that x ∈ x. See Russells’ paradox if you are intrigued.
This is the reason why axiomatic set theory restricts the definition of new sets as
subsets of old sets. In Example 1.6, if you take the big set as the set of all sets, then
S could be a subset of that. In fact, axiomatic set theory does a clever thing so that
existence of such a big set can never be justified. Moreover, it prevents constructing
a set that may also be a member of itself. For information on axiomatic set theory,
you may search for set theories of Zermelo–Fraenkel, or of Gödel–Berneys–Von
Neuman, or of Scott–Potter.
In the proof of Theorem 1.4, we have constructed a set by changing the diagonal
elements of the array of numbers listed as g(0), g(1), . . .. Below we give a very
general result that cardinality of any set must be strictly less than the cardinality
of its power set, which was first proved by Georg Cantor using (and inventing) the
diagonalization method.
Theorem 1.5 (Cantor). No function from a set to its power set can be onto. There-
fore, |A|  |2A
|.
Proof. Let f : A → 2A
be any function. Let x ∈ A. Then f (x) ⊆ A. Thus, x is
either in f (x) or it is not. Define a subset B of A by B = {x ∈ A : x ∈ f (x)}. We
show that there is no y ∈ A such that B = f (y).
On the contrary, suppose there exists a y ∈ A such that B = f (y). Is y ∈ B? If
y ∈ B, then as per the definition of B, y ∈ f (y). That is, y ∈ B. On the other hand,
if y ∈ B, then y ∈ f (y). Again, because of the definition of B, y ∈ B. We thus
arrive at the contradiction that y ∈ B iff y ∈ B. Hence, there is no y ∈ A such that
B = f (y). That is, f is not an onto map.
Finally, take g : A → 2A
defined by g(x) = {x}, for each x ∈ A. This map is
one–one. Hence |A| ≤ |2A
|. But |A|  |2A
|, as there is no function from A onto 2A
.
Therefore, |A|  |2A
|. 
Now it is obvious that the power set of a denumerable set is uncountable. You can
derive the uncountability of the open interval J defined in the proof of Theorem 1.4
16 1 Mathematical Preliminaries
from Cantor’s theorem by using binary decimals instead of the usual decimals. This
representation will first prove the fact that |J| = |2N
|. In the last paragraph of the
proof of Theorem 1.4, we have shown that |J| = |R|. Hence, R = |2N
|. Cantor
conjectured that each infinite set in between N and R must be in one-to-one corre-
spondence with one of N or R, now known as the Continuum Hypothesis. Because
of this reason, we denote the cardinality of 2N
as ℵ1. Then, the continuum hypothesis
asserts that any subset of R is either finite or has cardinality ℵ0 or ℵ1. There are in-
teresting results about the continuum hypothesis, but you should be able to look for
them on your own.
Notice that we have only defined the cardinalities of finite sets. For infinite sets,
we know how to compare the cardinalities. Moreover, for notational convenience, we
write the cardinality of a denumerable set as ℵ0. Cardinality of the power set of a
denumerable set is written as ℵ1. We may thus extend this notation further by taking
cardinality of the power set of the power set of a denumerable set as ℵ2, etc., but we
do not have the need for it right now. The countability results discussed so far can be
summarized as:
Z, Q, and the set of algebraic numbers are countable.
R, C, R − Q, and the set of transcendental numbers are uncountable.
An infinite subset of any denumerable set is denumerable.
Subsets of countable sets are countable.
Denumerable union of finite sets is denumerable.
Denumerable union of denumerable sets is denumerable.
Countable union of countable sets is countable.
Finite product of denumerable sets is denumerable
Finite product of countable sets is countable.
Countable product of countable sets need not be countable.
Power set of a denumerable set is uncountable.
1.5 Proof Techniques
In all the theorems except Theorem 1.1, we have used the technique of proof by
contradiction. It says that statement S is considered proved when from the assump-
tion that S is not true follows a contradiction. To spell it out explicitly, suppose we
have a set of premises Ω. We want to prove that if all the statements in Ω are true,
then the statement S must be true. The method of proof by contradiction starts by
assuming the falsity of S along with the truth of every statement in Ω. It then de-
rives a contradiction. If the premises in Ω are S1, S2, . . . , Sn, then the method can
be schematically written as
Required: S1, S2, . . . , Sn. Therefore, S.
We prove: S1, S2, . . . , Sn and not S. Therefore, a contradiction.
1.5 Proof Techniques 17
Keeping the premises in Ω in the background, the method may be summarized as
not S implies a contradiction. Therefore, S.
It works because, when not S implies a contradiction, not S must be false. Therefore,
S must be true. Conversely, when S is true, not S is false, and then it must imply a
contradiction.
The method of proof by contradiction appears in many disguises. Calling the
above as the first form, the second form of the method is
S1 and not S2 implies a contradiction. Therefore, “if S1, then S2.”
This is justified due to the simple reason that by asserting the falsity of “if S1, then
S2,” we assert the truth of S1 and the falsity of S2.
The third form of proof by contradiction is proving the contraposition of a
statement. It says that for proving “if S1, then S2,” it is sufficient to prove its con-
traposition, which is “if S2 is false, then S1 is false.” In fact, a statement and its
contraposition are logically equivalent. Why is it another form of the “proof by con-
tradiction?” Suppose you have already proved the contrapositive statement “if S2 is
false, then S1 is false”. Then, not S2 and S1 together give the contradiction that S1
is true as well as false. And then the second form above takes care. The principle of
proving the contraposition can be summarized as
If not S2, then not S1. Therefore, if S1, then S2.
The contrapositive of a statement is not the same as its converse. The converse of
“if S1 then S2” is “if S2 then S1,” which is equivalent to “if not S1 then not S2”.
The fourth form does not bring a contradiction from the assumption that S is false.
Rather it derives the truth of S from the falsity of S. Then, it asserts that the proof of
S is complete. It may be summarized as
not S implies S. Therefore S.
Justification of this follows from the first form itself. Assume not S. Since you have
proved not S implies S, you also have S. That is, by assuming not S you have got
the contradiction: S and not S.
The fifth form is the so-called argument by cases. It says that to prove a statement
S, pick up any other statement P. Assume P to deduce S. Next, assume that P is
false and also deduce S. Then, you have proved S. It may be summarized as
P implies S. not P implies S. Therefore, S.
Why does it work? Since, you have proved P implies S, its contraposition holds. That
is, you have not S implies not P. But you have already proved that not P implies S.
Thus, you have proved not S implies S. Now the fourth form takes care.
All the while you are using the law of double negation, that is, not not S is equiv-
alent to S. Along with it comes the law of excluded middle that one of S or not S
must be true. For example, in the argument by cases, you use the fact that one of P
18 1 Mathematical Preliminaries
or not P must hold. There have been many objections to the law of excluded middle.
One of the most befitting example is by J. B. Bishop. It is as follows.
Example 1.7. Show that there are irrational numbers x, y such that xy
is rational.
Solution. Gelfand–Schneidertheorem states that if α ∈ {0, 1} is an algebraic number
and β is an irrational number, then αβ
is a transcendental number.
√
2 is algebraic as
it is a solution of the equation x2
= 2. We also know that
√
2 is irrational. Therefore,
√
2
√
2
is transcendental, and hence, irrational. Now, with x =
√
2
√
2
and y =
√
2, you
see that
xy
= (
√
2
√
2
)
√
2
=
√
2
(
√
2×
√
2)
= (
√
2)2
= 2,
a rational number. Hence we have an affirmative answer to the above question. You
may also use the fact that e and ln 2 are irrational but eln 2
= 2, a rational number.
However, look at another proof given below that uses the argument by cases.
The alternative proof : Either
√
2
√
2
is rational or irrational. If it is rational, we take
x = y =
√
2. If it is irrational, take x =
√
2
√
2
and y =
√
2. Then, xy
= 2, a rational
number. With argument by cases, the proof is complete. 
The alternative proof in the solution of Example 1.7 does not give us a pair x, y
of irrational numbers satisfying the requirements. However, it proves the existence
of such irrational numbers. In the mainstream mathematics, this is a well appreciated
proof. The question there is not only about accepting the law of excluded middle, but
also about appreciating the nature of existence in mathematics.
When we say that there exists an object with such and such property, what we
understand is: it is not the case that the property is false for every object in the
domain of discourse. It may or may not be always possible to construct that object
with exactitude. See the following example.
Example 1.8. Show that there exists a real number x satisfying xx5
= 5.
Solution. Let f : R → R be given by f (x) = xx5
. We see that f (1) = 1 and
f (2) = 232
. Also, f is a continuous function. Since f (1)  5  f (2), by the
intermediate value theorem, there exists an a with 1  a  2 such that f (a) = 5. 
The a is not obtained exactly, but we know that there is at least one such point
between 1 and 2. Of course, there is a better way of getting such an a. For example,
a = 51/5
does the job! However, even if we could not have got this simple a, the
solution in Example 1.8 is still valid.
Example 1.9. Show that there exists a program that reports correctly whether tomor-
row by this time, I will be alive or not.
Solution. Consider the following two programs:
Program-1 : Print “I will be alive tomorrow by this time.”
Program-2 : Print “I will not be alive tomorrow by this time.”
1.5 Proof Techniques 19
Either I will be alive tomorrow by this time or not. That is, either Program-1 correctly
reports the fact or Program-2 correctly reports the fact. Hence, we have a program
that does the job, but we do not know which one. 
What about Program-3 : Wait till tomorrow. See what happens; then report ac-
cordingly? This, of course, does the job correctly. But this is constructive, whereas
the existence in the solution of Example 1.9 is not. Looked in a different way, the
statement in Example 1.9 is ambiguous.
One meaning of it has been exploited in the example. The other meaning asks for
a program that “justifiably predicts” whether I will be alive till tomorrow or not. The
solution there does not answer this nor does Program-3. Also, none of Program-1 and
Program-2 work correctly in all cases. Program-1 can be wrong if I really die today,
and Program-2 is wrong when I do live up to day after tomorrow.
Nonetheless, the method combined with diagonalization can be used for showing
nonexistence of programs. Choose any programing language in which you can write
a program that would compute functions with domain N and co-domain {0, 1}. Com-
puting a function here means that if f : N → {0, 1} is a given function, then you
can possibly have a program Pf in your language that takes input as any n ∈ N and
outputs f (n). This program Pf computes the function f.
Example 1.10. Prove that there exists a function g : N → {0, 1} that cannot be
computed by any program in whatever language you choose.
Solution. Choose your language, say, C. Since the C-programs can be enumerated in
alphabetical order, they form a countable set. The set of all C-programs that com-
pute functions is a subset of the set of all C-programs, and hence, is countable.
Enumerate the programs that compute functions in alphabetical order. Call them
C0, C1, C2, . . . . Each Cj takes a number n ∈ N as an input, and outputs either 0
or 1. Define a function f : N → {0, 1} by
f (n) = 0, if Cn outputs 1 on input n, and f (n) = 1 if Cn outputs 0 on input n.
Now, if there exists a C-program that computes f, then it must be one of
C0, C1, C2, . . . . Suppose it is Cm. But on input m, Cm outputs a different value
than f. So, it does not compute f. Hence no C-program can compute this f. 
A nonconstructive version of the solution to Example 1.10 uses the fact that there
are uncountable number of functions from N to {0, 1}, whereas there are only a count-
able number of C-programs. It is because the set of all such functions is in one-to-one
correspondence with the power set of N. See Problem 1.16.
In the above solution, we have used a form of proof by contradiction. All the forms
of proof by contradiction are propositional in nature, that is, they simply play with the
simple propositional connectives like “and,” “or,” “not,” etc. One more proof method
that uses the propositional connectives is the so-called proof employing a conditional
hypothesis. It is summarized as
Assume S1. Prove S2. Thereby you have proved: if S1, then S2.
20 1 Mathematical Preliminaries
As P or Q is logically equivalent to (not P) implies Q, the method of conditional
hypothesis can be used to prove such a disjunction. That is, a typical proof of P or Q
starts with assuming not P and concluding Q.
Sometimes the proofs using conditional hypothesis can be confusing and mislead-
ing if it is combined with other spurious elements. See the following example.
Example 1.11 (Fallacious Proof?). Show that there is no life on earth.
Solution. Let S be the statement: If S is true, then there is no life on earth.
We first show that S is true. As S is in the form “if S1, then S2” to show it, we
assume S1 and prove S2. Here is such a proof:
Proof of “S is true” begins.
Assume S1, that is, S is true. As S is true, we have
If S is true, then there is no life on earth.
Owing to our assumption that S is true, we see that
There is no life on earth.
This is S2. So we have proved “if S1, then S2”, that is, If S is true, then there is no
life on earth. That is, S is true.
Proof of “S is true” ends.
As S is true, we have
If S is true, then there is no life on earth.
The truth of the last statement and the fact that S is true imply
There is no life on earth. 
Certainly, there is something wrong. You see that there is nothing wrong with
the proof using the technique of conditional hypothesis. It is wrong to denote the
statement
If S is true, then there is no life on earth.
by S. To further understand what is going on, see the following commercial of this
book using three seductive questions.
Example 1.12 (Trap). This is a conversation between you and me.
I : I’ll ask you three questions. Would you like to answer each with “Yes” or “No?”
You : Yes.
I : That’s my first question. Will you answer the same to the third as to the second?
You : No.
I : Will you promise me that you will read only this book on Theory of computation
and no other book on the topic throughout your life?
1.5 Proof Techniques 21
Now you are trapped. Since you have answered “No” to the second question, you
cannot answer “No” to the third question. Had you answered “Yes” to the second
question, then also you had to answer “Yes” to the third. 
Of course, had you chosen to answer “No” to my first question, you would not
have been trapped. But as it is, why does it happen? The reason is the same as in
Example 1.11, a spurious self-reference. When you give notation to a statement, it
should have both the possibilities of being true or false. The notation itself cannot
impose a truth condition. In Example 1.11, the notation S violates this, as S cannot be
false there. If S is false, then the “if . . . then . . .” statement that it stands for becomes
true, which is untenable. The same way, you are trapped in Example 1.12.
Along with the propositional methods, we had also used the diagonalization tech-
nique of Cantor. There are two more general proof methods we will use in this book.
The first is the principle of mathematical induction. It is, in fact, a deductive proce-
dure. It has two versions: one is called the strong induction and the other is called
induction, without any adjective.
Writing P(n) for a property of natural numbers, the two forms of the principle
can be stated as
Strong Induction: P(0). If P(k) holds for each k  n, then P(n).
Therefore, for each n ∈ N, P(n).
Induction: P(0). If P(n) then P(n + 1).
Therefore, for each n ∈ N, P(n).
Verification of P(0) is called the basis step of induction, and the other “if . . .
then” statement is called the induction step. In case of strong induction, the fact
that all of P(0), P(1), . . . P(n − 1) hold is called the induction hypothesis; and in
case of induction, the induction hypothesis is “P(n) holds.” Both the principles are
equivalent, and one is chosen over the other for convenience.
In the case of strong induction, the induction step involves assuming P(k) for each
k  n and then deriving P(n). While the induction step in the other case consists of
deriving P(n + 1) from the single assumption P(n). Thus it is safer to start with the
strong induction when we do not know which one of them will really succeed.
The principle is also used to prove a property that might hold for all natural num-
bers greater than a fixed m. This is a generalization of the above. The formulation of
the principle now looks like:
Strong Induction: P(m). If P(k) holds for each k with m ≤ k  n, then P(n).
Therefore, for each natural number n ≥ m, P(n).
Induction: P(m). For each n ≥ m, if P(n) then P(n + 1).
Therefore, for each natural number n ≥ m, P(n).
As earlier, verification of P(m) is the basis step of induction, and the other “if . . .
then” statement is the induction step. In case of strong induction, the fact “P(k) holds
for each k with m ≤ k  n” is the induction hypothesis; and in case of induction, the
induction hypothesis is “P(n) holds.”
22 1 Mathematical Preliminaries
Not only on N, but wherever we see the structure of N, we can use this principle.
For example, it can be used on any set via the well ordering principle, which states
that every set can be well ordered; see Problem 1.10. However, we will not require
this general kind of induction.
Example 1.13 (Hilbert’s Hotel). Hilbert has a hotel having rooms as many as num-
bers in Z+. Show that he has rooms for any number of persons arriving in groups,
where a group might contain infinite number of persons.
Solution. Naturally, we take the infinite involved in the story as ℵ0. If only one such
group asks for rooms, Hilbert just assigns one to each. Suppose he has accommo-
dated n number of such groups. The (n + 1)th group arrives. Then, he asks the in-
cumbents to move to other rooms by the formula:
Person in Room-n moves to Room-2n.
Now, all odd numbered rooms are free. And the persons in the just arrived group get
accommodated there. 
If a group of persons contains ℵ1 or more people, then certainly Hilbert fails to
meet the demands. Notice that in the solution to Hilbert’s hotel, I have used induction.
You can have a shorter solution mentioning the fact that a finite union of countable
sets is countable.
We had defined graphs with finite sets of vertices implicitly. But a graph can also
have an infinite set of vertices. For example, in Z+, take the relation of “divides,”
that is, R = {(n, mn) : m, n ∈ Z+}. In the graph of this relation, there will be edges
from 1 to every positive integer, 2 to every even number, 3 to each multiple of 3, etc.
Similarly, trees on infinite sets are defined.
A rooted tree in which each vertex has at most k number of children, for some
k ∈ N, is called a finitely generated tree. A branch in a rooted tree is a path from
the root to a leaf. An infinite branch is then a sequence of vertices v0, v1, v2, . . . such
that v0 is the root and vi+1 is a child of vi , for each i ∈ N. We demonstrate the use of
induction in an infinite tree.
Example 1.14 (König’s Lemma). Show that each finitely generated infinite tree has
an infinite branch.
Solution. Let T be a finitely generated infinite tree. We show by induction that we
have a branch v0, v1, . . . , vn, with vn as the root of an infinite subtree of T for each
n ∈ N. Notice that such a branch cannot be finite.
In the basis step, We choose v0, the root of the tree T. As T is a subtree of itself,
for n = 0, the statement holds.
For the induction step, suppose we have already a sequence v0, v1, . . . , vn of ver-
tices such that vn is the root of an infinite subtree of T. Suppose the vertex vn has
m children, where m ≤ k; this k is fixed for the tree. Consider the subtree T 
of T
having vn as the root. If we remove vn from T 
, we get m subtrees with the children
of vn as the roots of the subtrees. At least one of these subtrees has infinite number
of vertices, otherwise, T
will become finite. Take one such subtree which is infinite.
1.5 Proof Techniques 23
Choose its root as vn+1. Now, we get a sequence v0, v1, . . . , vn, vn+1 such that vn+1 is
the root of an infinite subtree of T. Here ends the induction step. 
However, there is a danger in misusing the principle of induction. See the follow-
ing example.
Example 1.15 (Fallacious Induction). In a certain tribe, each boy loves a girl. Show
that each boy loves the same girl.
Solution. In the basis step, consider any single boy. Clearly, the statement holds for
him. For the induction step, assume that if you take any group of n boys, you find that
they love the same girl. Now, take any group of n+1 boys. Call them b1, b2, . . . , bn+1.
Form two groups of n boys each. The first group has the boys b1, b2, . . . , bn and
the second group has b2, b3, . . . , bn+1. Now, by the induction hypothesis, all of
b1, b2, . . . , bn love the same girl and all of b2, b3, . . . , bn+1 love the same girl. As
b2, b3, . . . , bn are common to both the groups, we see that all of b1, b2, bn, bn+1 love
the same girl. 
For the argument of the induction step to hold, the set {b2, b3, . . . , bn} must be
nonempty. That means, the basis step is not n = 1 but n = 2. You will see plenty of
induction proofs later. Combining the principle of induction and proof by contradic-
tion, we get Fermat’s principle of finite descent. It is stated as
If P(n + 1), then P(n). But not P(0). Therefore, not P(n), for each n ∈ N.
Example 1.16 (Surprise Quiz). Your teacher (not of this course!) declares in the
class on a Friday that he will be conducting a surprise quiz some time on the next
week. When returning to the dormitory, your friend says − “so nice of him; he will
not be able to conduct the quiz this time.” He thus argues, “You see, he cannot afford
to keep the quiz on Friday, for, in that case, he does not conduct the quiz till Thursday.
Certainly then, we infer the quiz to be on Friday and it would not be a surprise quiz.
Now agreed that he has to conduct the quiz on or before Thursday, can he afford not
to conduct the quiz till Wednesday? No, for then, we infer that only on Thursday he
conducts the quiz. Continuing three more steps, you see that he cannot even conduct
the quiz on Monday.” 
This is an application of Fermat’s principle of finite descent. Of course, there has
been some rhetoric involved, coining on the ambiguous meaning of the surprise in
the quiz. But there is nothing wrong in your friend’s argument! We will not have
occasions for the use of the principle in this book. But another consequence of in-
duction will be used at many places. It is the Pigeon hole principle. It states that
if there are n pigeons and m  n pigeon holes to accommodate all the pigeons in
the pigeon holes there must be at least two pigeons in same pigeon hole. A formal
version goes as follows
Let A, B be two finite sets. If |A|  |B| and f : A → B is a total function, then
f cannot be one–one.
24 1 Mathematical Preliminaries
Even finiteness of the sets can be dropped, but that would require transfinite induction
to justify the principle. Try proving this principle by using induction on |A|. We see
an application of the principle.
Example 1.17. Show that if seven points are chosen randomly from inside a circle
of radius 1, then there are at least two points whose distance is less than 1.
Solution. Take a circle of radius 1 and divide it into six equal parts by drawing six
radii. Each of the six sectors of the circle is bounded by two radii and an arc. If seven
points are chosen at random from inside the circle, then by Pigeon hole principle, at
least two of them are from the same sector; which sector, we do not know. Now, the
distance between those two points is less than 1. 
You have already seen how induction could be used for defining certain objects.
For example, we have defined the cardinalities of finite sets as |∅| = 0, |{0}| = 1,
|{0, 1, 2, . . ., n}| = n + 1. This definition uses induction. Another common example
of definition by induction, sometimes called a recursive definition, is of the factorial
function. It is defined by 0! = 1, (n + 1)! = n! (n + 1), for each n  0. The Fibonacci
sequence is defined recursively by f0 = 1, f1 = 1, fn+1 = fn + fn−1, for each n  1.
The construction of a suitable branch in König’s lemma is by induction.
Sometimes a definition by induction does not use any number. For example, in
defining an arithmetic expression involving the variables x, y, and the only operation
as +, you would declare that each of x, y is an arithmetic expression. This is the
basis step in the definition. Next, you will declare that if E1, E2 are expressions, then
(E1 + E2) is an expression, and nothing else is an expression. In such a case, suppose
you want to prove that in every expression there is an equal number of left and right
parentheses. How do you proceed?
Obviously, the proof is by induction on the number of left parentheses, or on the
number of right parentheses, or on the number of + signs. But this has to be identified.
Suppose we pick up the later. In the basis step, if there is no + sign in an expression,
then there are no parentheses. Hence, the number of left and right parentheses are
equal, equal to 0.
Assume the induction hypothesis that if an expression has less than n number
of + signs, then the number of left and right parentheses are equal. We plan to use
strong induction to be on the safe side. Suppose E is an expression having n number
of + signs,. Then, E = (E1 + E2) for some expressions E1 and E2. Now, both of
E1, E2 satisfy the induction hypothesis. Thus they have equal number of left and
right parentheses. Then so does (E1 + E2).
In the above proof, we can avoid the parameter n, which we had chosen as
the number of + signs. Here, we verify that the statement holds in the basis case of
the inductive definition of expressions. Next, in the inductive step, we see if E1, E2
are expressions satisfying the conclusion that the left and right parentheses are equal
in number, then so does the new expression (E1 + E2). There ends the proof.
Such a use of induction without identifying a parameter is named as the prin-
ciple of structural induction. To keep the matter straight, we will rather identify a
suggestive integer parameter than using this principle.
1.6 Summary and Problems 25
1.6 Summary and Problems
As you have observed, the mathematical preliminaries are not at all tough. All that
we require is a working knowledge of set theory, the concept of cardinality, trees,
induction, and the pigeon hole principle.
A good reference on Set Theory including cardinality that covers all the topics
discussed here is [50]. For induction, see [102]. For a reference on formal derivations
and their applications to discrete mathematics, see [48]. These books also contain a
lot of exercises. For an interesting history of numbers and number systems, see [35].
The story of the Hottentot tribes is from this book; of course I have modified it a bit
to provide motivation for counting.
Unlike other chapters, I have neither included exercises nor problems in each
section; probably you do not require them. If you are really interested, here are some.
Problems for Chapter 1
1.1. Prove all the laws about set operations listed at the end of Sect. 1.2
1.2. What is wrong in the following fallacious proof of the statement that each sym-
metric and transitive binary relation on a nonempty set must also be reflexive:
Suppose aRb. By symmetry, bRa. By transitivity, aRa?
1.3. Label the edges of the graph in Fig. 1.3 as e1, . . . , e7 and then write the corre-
sponding labeled graph as a triple, now with an incidence relation.
1.4. If |A| = n, then how many binary relations on A are there? Among them, how
many are reflexive? How many of them are symmetric? How many of them are both
reflexive and symmetric?
1.5. Show that the inverse of an equivalence relation on a set is also an equivalence
relation. What relation is there between the equivalence classes of the relation and
those of its inverse?
1.6. Let A be a finite set. Let the binary relation R on 2A
be defined by x Ry if there
is a bijection between x and y. Construct a function f : 2A
→ N such that for any
x, y ∈ 2A
, f (x) = f (y) iff xRy.
1.7. Let R be an equivalence relation on any nonempty set A. Find a set B and a
function f : A → B such that for any x, y ∈ A, f (x) = f (y) iff xRy.
1.8. Let R, R
be two equivalence relations on a set A. Let P and P
be the partitions
of A consisting of equivalence classes of R and R
, respectively. Show that R ⊆ R
iff P is finer than P
, that is, each x in P is a subset of some y in P
.
1.9. Let A be a nonempty set. Suppose A denotes the empty collection of subsets of
A. What are the sets ∪A and ∩A?
26 1 Mathematical Preliminaries
1.10. An order relation R on a set A is a binary relation satisfying the following
properties:
Comparability: For any x, y ∈ A, if x  y, then either xRy or yRx.
Irreflexivity: For each x ∈ A, it is not the case that xRx.
Transitivity: For any x, y, z ∈ A, if xRy and yRz, then xRz.
An element a ∈ B ⊆ A is a smallest element of B (with respect to the order R) if
for each x ∈ B, x  a, you have a  x. A set A with an order relation R is said to
be well ordered if each nonempty subset of A has a smallest element.
The Well Ordering Principle states that given any set, there exists a binary relation
with respect to which the set A is well ordered.
The Axiom of Choice states that given a collection A of disjoint nonempty sets, there
exists a set C having exactly one element in common with each element of A.
Prove that the axiom of choice and the well ordering principle are equivalent.
[Hint: Zermelo proved it in 1904; and it startled the mathematical world.]
1.11. Let f : A → B be a (total) function. Suppose C, C
⊆ A and D, D
⊆ B.
Recall that f (C) = { f (x) : x ∈ C} and f −1
(D) = {x ∈ A : f (x) ∈ D}. Show
that
(a) If C ⊆ C
, then f (C) ⊆ f (C
).
(b) If D ⊆ D
, then f −1
(D) ⊆ f −1
(D
).
(c) C ⊆ f −1
( f (C)). Equality holds if f is injective.
(d) f ( f −1
(D)) ⊆ D. Equality holds if f is surjective.
(e) f (C ∪ C
) = f (C) ∪ f (C
).
(f) f (C ∩ C
) ⊆ f (C) ∩ f (C
). Give an example, where equality fails.
(g) f (C) − f (C
) ⊆ f (C − C
). Give an example, where equality fails.
(h) f −1
(D ∪ D
) = f −1
(D) ∪ f −1
(D
).
(i) f −1
(D ∩ D
) = f −1
(D) ∩ f −1
(D
).
(j) f −1
(D − D
) = f −1
(D) − f −1
(D
).
(k) Statements (e), (f), (h), and (i) hold for arbitrary unions and intersections.
1.12. Suppose f : A → B and g : B → A are such functions that the compositions
g ◦ f : A → A and f ◦ g : B → B are identity maps. Show that f is a bijection.
1.13. Let f : A → B, g : B → C be functions, and let D ⊆ C.
(a) Show that (g ◦ f )−1
(D) = f −1
(g−1
(D)).
(b) If f, g are injective, then show that g ◦ f is injective.
(c) If f, g are surjective, then show that g ◦ f is surjective.
(d) If g ◦ f is injective, what can you say about injectivity of f and g?
(e) If g ◦ f is surjective, what can you say about surjectivity of f and g?
1.14. Let A, B be any sets. Prove that there exists a on-one function from A to B
iff there exists a function from B onto A. [Hint: For the “if” part, you may need the
axiom of choice.]
1.15. Let A = {1, 2, 3, . . ., n}. With O = {B ⊆ A : |B| is odd } and E = {B ⊆ A :
|B| is even }, define a map f : O → E by f (B) = B − {1}, if 1 ∈ B; else f (B) =
B ∪ {1}. Show that f is a bijection.
1.6 Summary and Problems 27
1.16. For sets A, B, define BA
as the set of all functions from A to B. Prove that
for any set C, there is a one–one correspondence between {0, 1}C
and the power set
2C
. This is the reason we write the power set of C as 2C
. [Hint: For D ⊆ C, define
its characteristic function, also called the indical function, χD : C → {0, 1} by “if
x ∈ D, then χD(x) = 1; else, χD(x) = 0.”]
1.17. Show that no partial order on C can be an extension of the ≤ on R.
1.18. Recall that a nonempty set A is finite iff there is a bijection between A and
{0, 1, . . ., n} for some n ∈ N. Here, we show how cardinality of a finite set is well
defined. Let A be a set; a ∈ A; B  A; and let n ∈ N. Prove the following without
using cardinality:
(a) There is a bijection between A and {0, 1, . . ., n+1} iff there is a bijection between
A − {a} and {0, 1, . . ., n}.
(b) Suppose there is a bijection between A and {0, 1, . . . , n+1}. Then, there exists no
bijection between B and {0, 1, . . . , n + 1}. If B  ∅, then there exists a bijection
between B and {0, 1, . . ., m}, for some m  n.
1.19. Show that N is not a finite set.
1.20. Prove: If A is a nonempty set and n ∈ N, then the following are equivalent:
(a) There is a one–one function from A to {0, 1, . . ., n}.
(b) There is a function from {0, 1, . . ., n} onto A.
(c) A is finite and has at most n + 1 elements.
1.21. Let A, B, C be finite sets. Prove that
|A ∪ B ∪ C| = |A| + |B| + |C| − |A ∩ B| − |B ∩ C| − |C ∩ A| + |A ∩ B ∩ C|.
Generalize this formula for n number of sets A1, . . . , An.
1.22. Let B ⊆ A. Show that if there is an injection f : A → B, then |A| = |B|.
1.23. Prove that a denumerable union of finite sets is denumerable.
1.24. Using Cantor’s theorem, show that the collection of all sets is, infact, not a set.
1.25. Prove that each infinite set contains a denumerable subset.
1.26. Show that if f : N → A is a surjection and A is infinite, then A is denumerable.
1.27. Show that for each n ∈ Z+, |Qn
| = |Q| and |Rn
| = |R|.
1.28. Show that the set of algebraic numbers is denumerable. Then deduce that there
are more transcendental numbers than the algebraic numbers.
1.29. Let f : A → B and g : B → A be two injections. Prove the following:
(a) Write A0 = A − g(B), A1 = g(B) − g( f (A)), B0 = B − f (A), B1 = f (A) −
f (g(B)). Then A0 ∪ A1 = A − g( f (A)) and B0 ∪ B1 = B − f (g(B)). Further,
A0 ∩ A1 = ∅ = B0 ∩ B1.
(b) The relation g−1
from g(A) to A is a function.
28 1 Mathematical Preliminaries
(c) Define h : A0 ∪ A1 → B0 ∪ B1 by h(x) = f (x) for x ∈ A0, and h(x) = g−1
(x)
for x ∈ A1. Then h is a bijection. Further, h(A0) = B1 and h(A1) = B0.
(d) Write A2 = g( f (A)) − g( f (g(B))), A3 = g( f (g(B))) − g( f (g( f (A)))),
B2 = f (g(B))− f (g( f (A))), B3 = f (g( f (A)))− f (g( f (g(B)))). Now define, by
induction, the sets Ai , Bi , for each i ∈ N. Then A2m ∩ A2m+1 = ∅ = B2m ∩ B2m+1.
(e) Define φ : ∪i∈N Ai → ∪i∈N Bi by φ(x) = f (x) if x ∈ Ai , i even, and φ(x) =
g−1
(x) for x ∈ Ai , i odd. Then φ is a bijection.
(f) Restrict the domain of f to the set A − ∪i∈N Ai . Then f : A − ∪i∈N Ai →
B − ∪i∈N Bi is a bijection.
(g) Define ψ : A → B by ψ(x) = φ(x) if x ∈ ∪i∈N Ai , and ψ(x) = f (x) if x ∈
A − ∪i∈N Ai . Then ψ is a bijection.
(h) Cantor–Schröder–Bernstein Theorem: If |A| ≤ |B| and |B| ≤ |A|, then |A| =
|B|.
1.30. Let A, B be sets. Is it true that there is an injection from A to B iff there is a
surjection from B to A? [Hint: Does axiom of choice help? See Problem 1.10]
1.31. Define |A| + |B| = |A ∪ B| provided A ∩ B = ∅; |A| − |B| = |A − B| provided
B ⊆ A; |A| × |B| = |A × B|; and |A||B|
= |AB
|. Let α, β be cardinalities of infinite
sets with α  β. Show that α + β = β, β − α = β, α × β = β, 2α
 α. Further,
show that α − α is not well defined.
1.32. Show that a denumerable product of denumerable sets is uncountable. [Hint:
You may need the axiom of choice.]
1.33. Let a ∈ R. Simplify the sets ∪r1{x ∈ R : a − r ≤ x ≤ a + r} and ∩r0{x ∈
R : a − r  x  a + r}.
1.34. Let S denote the sentence: This sentence has no proof. Show that S is true.
Conclude that there is a true sentence having no proof. [Gödel’s proof of his incom-
pleteness theorem expresses S in the system of natural numbers.]
1.35. Let S be the sentence: This sentence has no short proof. Show that if S is true,
then there exists a sentence whose proof is not short, but the fact that it is provable
has a short proof. [A formal version of this S expressed in the system of natural
numbers is called Parikh’s sentence.]
1.36. Let P(m, n) denote a property involving two natural numbers. Suppose we
prove that P(0, 0) is true. We also prove that if P(i, j) is true, then both P(i, j + 1)
and P(i + 1, j) are true. Does it follow that P(m, n) is true for any m, n ∈ N?
1.37. Show that for each integer n  1, 1/
√
1 + 1/
√
2 + 1/
√
3 + · · · + 1/
√
n 
√
n.
1.38. Deduce the pigeon hole principle from the principle of induction.
1.39. Show that among any n + 2 positive integers, either there are two whose sum is
divisible by 2n or there are two whose difference is divisible by 2n.
1.40. Use the pigeon hole principle to show that each rational number has a recurring
decimal representation.
1.6 Summary and Problems 29
1.41. Show that among any n + 1 numbers randomly chosen from {1, 2, . . ., 2n},
there are at least two such that one divides the other.
1.42. Let A = {m + n
√
2 : m, n ∈ Z}. Show that for each k ∈ Z+, there is xk ∈ A
such that 0  xk  1/k.
2 Regular Languages
2.1 Introduction
It is said that human intelligence is mainly the capability to represent a problem, its
solution, or related facts in many seemingly different ways. You must have encoun-
tered it in several problem-solving situations. You first represent the problem in a
known language, where you might like to eliminate or omit the irrelevant aspects
and consider only the appropriate ones. The methodology is followed throughout
mathematics starting from solving first arithmetic problems such as “if you already
had five candies and your friend offers you one more, then how many candies do you
have now?”.
To give another example, the memory in a computer is only an assembly of
switches which, at any moment, may be off or on. If there is a trillion of them, then
it may be represented as a trillion digited binary number, when, say, off corresponds
to 0 and on to 1. In some situations, we may not be interested in all possible bi-
nary numbers, but only those having a few number of digits out of the trillion, or
only those having a particular pattern, such as “there is at least one 0 following ev-
ery occurrence of a 1.” There might arise a situation where we would like to have a
representational scheme having more than two symbols. We will, however, consider
only a finite number of symbols at a time, and in parallel with the existing natural
languages, we will develop formal languages out of these symbols.
In this book, we will introduce a hierarchy of formal languages. To represent
formal languages, we will study grammars. Each such type in the hierarchy will
have its own type of mechanical device, which may recognize the language but not
any other language from another type. In the sequel, we will have to introduce many
technicalities. The technical words or phrases, as usually are, will either be defined
clearly or will be left completely undefined. In the latter case, I will attempt at a
description of such undefined or primitive notions so that you will be able to think
about them in a certain well-intended way.
A. Singh, Elements of Computation Theory, Texts in Computer Science, 31
c
 Springer-Verlag London Limited 2009
32 2 Regular Languages
2.2 Language Basics
We start with the primitive notion of a symbol. A symbol is any written sign. We
adhere to the written scripts as communication between you and me. Of course, you
can even consider “spoken signs” or even “body language” or any piece in any other
sign language. The implicit assumption here is that we will be able to represent other
types of symbols or signs in terms of the written ones, in terms of our symbols.
An alphabet is then a nonempty finite set of symbols, where no symbol is a part
of another. Notice that the phrase is a part of is again a primitive notion here. We
will not allow the blank symbol to be in our alphabets for some technical reasons.
If the blank symbol has to be used in some situation, then we will rather have some
rewriting of it, say, b

. For example, {0, 1}, {a, b, c, . . ., z}, {@, $, !, 1, a, z, 5, } are
alphabets, but {0, 10}, {ab, c, a} are not alphabets as 0 is a part of 10 and a is a part
of ab.
A word or a string over an alphabet is a finite sequence of symbols from the
alphabet. For example, each word in an English dictionary is a string over the Roman
alphabet. Each natural number is a string over the alphabet {0, 1, 2, . . ., 9}. Thus a
string is written as a sequence of symbols followed one after another without any
punctuation marks. This way of writing a string is referred to as the operation of
concatenation of symbols.
The operation can be defined for strings also. For example, concatenation of
strings alpha and bet is alphabet, and concatenation of bet and alpha is betalpha.
If s and t are strings (over an alphabet), then concatenation of s and t is the string
st (over the same alphabet). There is a special string, the string containing no occur-
rence of any symbol whatsoever, called the empty string. The empty string is indeed
unique, and it is a string over every alphabet. We will denote the empty string by the
symbol ε. It serves as an identity of concatenation as for any string u, uε = εu = u.
The number of occurrences of symbols in a string is called its length. The length
of alpha is 5 and the length of bet is 3. The empty string ε has length 0. Note that
the length of a string depends upon the underlying alphabet as the string itself needs
an alphabet, first of all. For example, the length of the string 1001 over the alphabet
{0, 1} is 4, while its length over the alphabet {10, 01} is 2.
The vagueness in the definition of a symbol and an alphabet is removed by follow-
ing a strict mathematical formalism. In this formalism, an alphabet is taken as any
finite set and a string over the alphabet is taken as a map from {1, 2, . . ., n} to the
alphabet, where n is some natural number. The natural number n is again the length
of the string. For example, the string 101 over the alphabet {0, 1} is simply the map
f : {1, 2, 3} → {0, 1}, where f (1) = 1, f (2) = 0, f (3) = 1. This string has length
3 as usual. Note that the map f here can be completely determined by its values at
the integers 1, 2, 3. That is, the map can be rewritten by noting down its values at
1, 2, 3 one after another, and, in that order. That is how the formal definition would
be connected to the informal.
When the natural number n is taken as 0, we have an empty domain for the map,
and then, by convention, we will have the empty map, the empty string ε, having
length 0. Moreover, the length function can be defined inductively over an alphabet
Σ as in the following:
2.2 Language Basics 33
1. (ε) = 0.
2. If σ ∈ Σ and u is a string over Σ, then (uσ) = (u) + 1.
The reversal of a string s over an alphabet Σ is denoted by sR
and is defined induc-
tively by the following:
1. εR
= ε.
2. If σ ∈ Σ and u is a string over Σ, then (σu)R
= uR
σ.
See that the above definition of the reversal does really capture the notion of the
reversal; for example, (reverse)R
= esrever. It follows that the length of the reversal
of a string is same as the length of the string. It also follows that (uv)R
= vR
uR
for
strings u and v. Show these by induction (see Sect. 1.5.) on the length of the string!
Exercise 2.1. Define the operation of concatenation inductively and then show that
this operation is associative but not commutative.
Exercise 2.2. Write (ab)0
= ε, (ab)1
= ab, (ab)2
= abab, . . . for the string ab.
Define (ab)n
inductively for every n ∈ N. Show that ((ab)n
) = n (ab).
A string u is a prefix of a string w iff there is a string v such that w = uv. Similarly,
if for some string v, we have w = vu, then u is called a suffix of w. In general, u is a
substring of w iff there are strings x, y such that w = xuy.
For example, pre is a prefix of prefix and fix is a suffix of suffix (and also of prefix).
The string ref is a substring of prefix. Vacuously, both pre and fix are substrings of
prefix. As the strings x, y in w = xuy can be taken as the empty string ε, every string
is a substring of itself. Also, every string is both a prefix and a suffix of itself.
Observe that all of ε, p, pr, pre, pref, prefi, prefix are prefixes of prefix. Out of
these if you take any two, can you find any relation between them? Easy, one of them
has to be a prefix of the other! If both u and v are prefixes of the same string w, then u
is matching with a part of w from the left and so is v. So, the one with smaller length
must be a prefix of the other. But this is not a proof!
Lemma 2.1 (Prefix Lemma). If u and v are prefixes of a string w over an alphabet
Σ, then u is a prefix of v or v is a prefix of u.
Proof. We prove it by induction on the length of w. If (w) = 0, then w = ε, and then
u = v = ε. This shows that u is a prefix of v. Assume the induction hypothesis that
for all strings w of length n, the statement holds. Let (w) = n + 1. Write w = zσ,
where σ ∈ Σ is the last symbol of w, and then (z) = n. Let u and v be prefixes of
w. If one of u, v equals w, then the other is a prefix of it. So, suppose that neither u
nor v is equal to w. Then both u and v are prefixes of z. (Why?) As (z) = n, by the
induction hypothesis, u is a prefix of v or v is a prefix of u. 
Exercise 2.3. Formulate and prove Lemma 2.1 with suffixes instead of prefixes.
What about mixing prefixes and suffixes?
A language over an alphabet Σ is any set of strings over Σ. In particular, ∅, the
empty set (of strings) is a language over every alphabet. So are the sets {ε}, the set
Σ itself, and the set of all strings over Σ, which we denote by Σ∗
.
34 2 Regular Languages
Thus, any book written in English may be thought of as a language over the Ro-
man alphabet. The set of all binary numbers starting with 1 and of length 2, that is,
the set {10, 11} is a language over {0, 1}. The binary palindromes (the strings that
are same when read from right to left) form a language as this can be written as
{w ∈ {0, 1}∗
: wR
= w}, a subset of {0, 1}∗
.
Theorem 2.1. Let Σ be any alphabet. Then Σ∗
is denumerable. Therefore, there are
uncountable number of languages over Σ.
Proof. Write Σ0 = {ε} and Σn = the set of all strings of length n over Σ, for any n ∈
Z+. If |Σ| = m, then there are mn
strings in Σn. As Σ∗
= ∪n∈NΣn, a denumerable
union of finite sets, it is denumerable. Each language over Σ is a subset of Σ∗
.
Thus, the number of such languages is the cardinality of the power set 2Σ∗
, which is
uncountable by Theorem 1.5. 
The question is how to name all these languages? Obviously, whatever way we try
to name them, the names themselves will be strings over some alphabet, and there
can only be a countable number of them at the most, unless we choose to supply
names from another uncountable set such as R. So, before even attempting to name
the languages, we see that any such attempt is bound to fail. But then, can we name
certain interesting languages? It, of course, depends upon what our interest is and
what is our naming scheme. Note that naming schemes are only finitary ways of
representing the languages.
We start with some natural naming schemes. As languages are sets, we can use set
operations such as union, intersection, complementation (in Σ∗
) etc. We also have
the operation of concatenation for strings, which can be adopted or extended to lan-
guages. Let L, L1, L2 be languages over an alphabet Σ. Then
L1 L2 = {uv : u ∈ L1 and v ∈ L2} is the concatenation of the languages L1 and L2.
Note the asymmetry in this and.
L1 ∪ L2 = {w : w ∈ L1 or w ∈ L2} is the union of L1 and L2.
L1 ∩ L2 = {w : w ∈ L1 and w ∈ L2} is the intersection of L1 and L2.
L1 − L2 = {w : w ∈ L1 but w ∈ L2} is the difference of L2 from L1.
L = {w ∈ Σ∗
: w ∈ L} is the complement of the language L.
The powers of L , denoted by Lm
, for m ∈ N, are defined inductively by L0
= {ε}
and Ln+1
= LLn
.
The Kleene star (or the closure or the asterate) of the language L is defined as
L∗
= ∪m∈N Lm
. Read it as L star. Notice that it goes along well with our earlier nota-
tion Σ∗
, the set of all strings over the alphabet Σ.
The Kleene plus of L is L+
= LL∗
= {u1u2 · · · uk : k  0 and ui ∈ L}. Read it as L
plus. L+
is also referred to as the positive closure of L.
Similarly other set operations will give rise to respective definitions of new lan-
guages using the old ones. Our aim is to use these symbolism for writing many
interesting languages in a compact way. See the following examples.
2.2 Language Basics 35
Example 2.1. Can we represent the language L = {w ∈ {a, b, c}∗
: w does not end
with c} using the symbolism we have developed so far?
Solution. Will it be easy if we first try representing all strings over Σ that end with
one c? Any such string will be a string from Σ∗
followed by the symbol c. That is,
L = {uc : u ∈ Σ∗
} = Σ∗
{c} = {a, b, c}∗
{c}. Thus, L = {a, b, c}∗{c}. 
To develop a shorthand, we might write {a, b, c} = {a}∪{b}∪{c} just as a ∪b∪c.
Here, we are dispensing with braces } and {, though we know that a ∪ b ∪ c does
not make sense at all. However, we can still use it as a shorthand, a name, with an
obvious interpretation. For such an expression a∪b∪c, we will associate the language
{a} ∪ {b} ∪ {c}.
To put it formally, we would like to use the phrase: the language represented
by the expression so and so. Thus a ∪ b ∪ c will be regarded as an expression and
{a} ∪ {b} ∪ {c} will be the language represented by this expression. In symbols, we
will write it as L(a ∪ b ∪ c) = {a} ∪ {b} ∪ {c}.
There will not be any confusion between the “string ab” and the “expression ab”,
as the former is only a string and the L of the latter is the language {ab}.
We will use, mostly in the exercises, the symbol # as a shorthand for “number of.”
If w is a string and σ is a symbol, we write #σ(w) to denote the number of occurrences
of σ in w. For example, #a(babaabc) = 3.
Problems for Section 2.2
2.1. What languages do the expressions (∅∗
)∗
and 0∅ denote?
2.2. Find all strings in (a ∪ b)∗
b(a ∪ ab)∗
of length less than four.
2.3. When does LL∗
= L − {ε} happen?
2.4. Let L = {ab, aa, baa}. Which of the strings bbbbaa, aaabbaa, abaabaaa-
baa, baaaaabaaaab, and baaaaabaa are in L∗
?
2.5. Let Σ be any alphabet. Prove that (uv)R
= vR
uR
, for all strings u, v ∈ Σ+
.
2.6. Let Σ = {a, b}. Find strings in, and not in, L ⊆ Σ∗
, where L is
(a) {wwR
w : w ∈ ΣΣ}.
(b) {w ∈ Σ∗
: w2
= w3
}.
(c) {w ∈ Σ∗
: w3
= v2
for some v ∈ Σ∗
}.
(d) {w ∈ Σ∗
: uvw = wuv for some u, v ∈ Σ∗
}.
2.7. Let a, b, c be different symbols. Are the following true? Justify.
(a) (a ∪ b)∗
= a∗
∪ b∗
.
(b) a∗
b∗
∩ b∗
a∗
= a∗
∪ b∗
.
(c) ∅∗
= ε∗
.
(d) {a, b}∗
= a∗
(ba∗
)∗
.
(e) a∗
b∗
∩ b∗
c∗
= ∅.
(f) (a∗
b∗
)∗
= (a∗
b)∗
.
36 2 Regular Languages
(g) (a ∪ ab)∗
a = a(a ∪ ba)∗
.
(h) a(bca)∗
bc = ab(cab)∗
c.
(i) (b ∪ a+
b)(b ∪ a+
b)(a ∪ ba∗
b)+
= a∗
b(a ∪ ba∗
b)∗
.
(j) aa(a ∪ b)∗
∪ (bb)∗
a∗
= (a ∪ ab ∪ ba)∗
.
2.8. Let w ∈ {a, b}∗
be such that abw = wab. Show that (w) is even.
2.9. Does L = L∗
hold for the following languages:
(a) L = {an
bn+1
: n ∈ N}?
(b) L = {w ∈ {a, b}∗
: #a(w) = #b(w)}?
2.10. Are there languages for which (L∗) = (L)∗
?
2.11. Use induction to show that (un
) = n (u) for all strings u and all n ∈ N.
2.12. Prove that for all languages L1, L2, we have (L1 L2)R
= LR
2 LR
1 .
2.13. Prove or disprove the following claims:
(a) (L1 ∪ L2)R
= LR
1 ∪ LR
2 for all languages L1 and L2.
(b) (LR
)∗
= (L∗
)R
for all languages L.
(c) If L∗
1 = L∗
2 then L1 = L2 for all languages L1 and L2.
(d) There exists a finite language L such that L∗
= L.
(e) If ε ∈ L ⊆ Σ∗
and ε ∈ L
⊆ Σ∗
, then (LΣ∗
L
)∗
= Σ∗
.
2.14. Let A be a language over an alphabet Σ. Call A reflexive if ε ∈ A, and call A
transitive if A2
⊆ A. Let B ⊇ A. Show that if B is both reflexive and transitive, then
B ⊇ A∗
.
2.15. Give a rigorous proof that L((a ∪ba)∗
(b ∪ε)) is the set of all strings over {a, b}
having no pair of consecutive b’s.
2.16. Let A, B, C be languages over an alphabet Σ. Show the following properties
of union, concatenation, and Kleene star:
(a) A{ε} = {ε}A = A.
(b) A∅ = ∅A = ∅.
(c) A(B ∪ C) = AB ∪ AC. (What about arbitrary union?)
(d) A∗
A∗
= (A∗
)∗
= A∗
= {ε} ∪ AA∗
= {ε} ∪ A∗
A.
(e) ∅∗
= {ε}.
(f) (A ∪ B)∗
= (A∗
B∗
)∗
.
(g) A(B ∩ C) = AB ∩ AC does not hold, in general.
(h) AB = A B does not hold, in general.
2.3 Regular Expressions
For the time being, we only consider the operations of concatenation, union, and
the Kleene star starting from the symbols of an alphabet and the empty language
∅. We begin with such a definition of a class of expressions and the corresponding
languages they represent.
2.3 Regular Expressions 37
A regular expression over an alphabet Σ and the language it represents are defined
inductively by the following rules:
1. ∅ is a regular expression. L(∅) = ∅.
2. Each σ ∈ Σ is a regular expression. L(σ) = {σ}.
3. If α is a regular expression, then α∗
is a regular expression. L(α∗
) = (L(α))∗
.
4. If α, β are regular expressions, then both (αβ) and (α∪β) are regular expressions.
L((αβ)) = L(α)L(β) and L((α ∪ β)) = L(α) ∪ L(β).
5. All regular expressions and the languages they represent are obtained by applying
the rules 1–4 above.
The parentheses above are used to remove possible ambiguities such as those that
occur in the expression αβ∪γ , which may be read as α(β∪γ ) or as (αβ)∪γ . However,
we will dispense with many parentheses by using the following precedence rules:
The operation ∗ will have the highest precedence.
The operation of concatenation will have the next precedence.
The operation of union will have the least precedence.
We will also dispense with the outermost parentheses from a regular expression.
This means that the regular expression ((αβ) ∪ γ ∗
) will be rewritten (or abbreviated)
as αβ ∪ γ ∗
. Instead of writing L((αβ)), L((α ∪ β)), (L(α))∗
, we will simply write
L(αβ), L(α ∪ β), L(α)∗
, respectively.
A language is called a regular language iff it can be represented by a regular
expression, that is, when L = L(α) for some regular expression α.
Example 2.2. Let Σ be any alphabet. Then ∅, {ε}, Σ, Σ∗
, Σ+
, Σn
for any n ∈ N are
regular languages. Note that ∅0
= {ε} and ∅n
= ∅ for n  0. Thus, ∅∗
= {ε}, Σ+
=
ΣΣ∗
, and Σn
= Σ · · · Σ concatenated n times. Similarly, L = {am
bn
: m, n ∈ N} is
regular as L = L(a∗
b∗
). 
Sometimes, we give a description of a language in terms of its elements.
Example 2.3. Let L be the set of all strings over {a, b} having exactly two occur-
rences of b, which are consecutive. Is L regular?
Solution. If two b’s are consecutive in a string u, then bb is a substring of u. That
is, u = xbby for some strings x and y. If x has a b in it, then u will have more than
two b’s, similarly for y. Thus both x and y have only a’s in them or they may equal
the empty string ε. Hence x, y ∈ {a}∗
. Therefore, L = L(a∗
bba∗
), and it is a regular
language. 
Example 2.4. Let L be the language over {a, b} having exactly two nonconsecutive
b’s. Is L a regular language?
38 2 Regular Languages
Solution. You can write L as L(a∗
ba∗
ba∗
) − L(a∗
bba∗
). But this does not help as
difference or complementation is not allowed in a regular expression. Any typical
string in L has one b in its middle, followed by some a’s and then another b. It
may look something like aa · · · aba · · · aba · · · a. Note that, before the first b (first
from the left) there may not be an a and similarly there may not be an a after the
second b. But there must be an a in between the two b’s. Thus, L = L(a∗
ba+
ba∗
) =
L(a∗
baa∗
ba∗
), a regular language. 
Exercise 2.4. See that L(a∗
ba∗
baa∗
ba∗
(ba∗
∪ ∅∗
)) = {w ∈ {a, b}∗
: w has
three or four occurrences of b’s in which the second and third occurrences are not
consecutive}.
Example 2.5. Is the complement of the language in Example 2.3 regular?
Solution. With Σ = {a, b}, this language L contains all the strings of the language in
Example 2.4 and the strings that do not contain exactly two consecutive b’s. Thus L =
L(a∗
baa∗
ba∗
) ∪ L(a∗
) ∪ L(a∗
ba∗
) ∪ Σ∗
{b}Σ∗
{b}Σ∗
{b}Σ∗
. The regular expression
for L is a∗
∪ a∗
ba∗
∪ a∗
baa∗
ba∗
∪ (a ∪ b)∗
b(a ∪ b)∗
b(a ∪ b)∗
b(a ∪ b)∗
. 
Example 2.6. What is L(a∗
((b ∪ bb)aa∗
(b ∪ bb))∗
a∗
)?
Solution. Clearly, any string of a’s is in the language. What else? There are also
strings with 0 or more a’s followed by one or two b’s, then at least one a, and
then 0 or more of b or bb, and then a string of a’s. What is the middle aa∗
do-
ing? It prevents occurrences of three or more consecutive b’s. The language is
L((a ∪ b)∗bbb(a ∪ b)∗). 
Hence forward, we will make the overline short; for example, we will write
L((a ∪ b)∗
bbb(a ∪ b)∗
) instead of L((a ∪ b)∗bbb(a ∪ b)∗).
Exercise 2.5. Does the regular expression a∗
∪ ((a∗
(b ∪ bb))(aa∗
(b ∪ bb))∗
)a∗
rep-
resent the language L(bbb)?
We will also write the regular expression itself for the language it represents. This
will simplify our notation a bit. For example, instead of writing L(a∗
b∗
), we will
simply write the language a∗
b∗
. Use of the phrase “the language” will clarify the
meaning.
Exercise 2.6. Does the equality L(bbb) = (∅∗
∪ b ∪ bb)(a ∪ bb ∪ abb)∗
hold?
We will also say that two regular expressions are equivalent when they represent
the same language. Moreover, in accordance with the last section, two equivalent
regular expressions can also be written as equal. This means, for regular expressions
R, E, we will use any one of the notations R = E (sloppy), L(R) = L(E) (precise),
or R ≡ E (R is equivalent to E, technical) to express the one and the same thing.
2.3 Regular Expressions 39
Problems for Section 2.3
2.17. Give regular expressions for the following languages over {a}:
(a) {a2n+1
: n ∈ N}.
(b) {an
: n is divisible by 2 or 3, or n = 5}.
(c) {a2
, a5
, a8
, . . .}.
2.18. Give a simpler regular expression for each of the following:
(a) ∅∗
∪ b∗
∪ a∗
∪ (a ∪ b)∗
.
(b) (a∗
b)∗
∪ (b∗
a)∗
.
(c) ((a∗
b∗
)∗
(b∗
a∗
)∗
)∗
.
(d) (a ∪ b)∗
b(a ∪ b)∗
.
2.19. Find regular expressions for the following languages over {0, 1}:
(a) {w : w does not contain 0}.
(b) {w : w does not contain the substring 01}.
(c) Set of all strings having at least one pair of consecutive zeros.
(d) Set of all strings having no pair of consecutive zeros.
(e) Set of all strings having at least two occurrences of 1’s between any two occur-
rences of 0’s.
(f) {0m
1n
: m + n is even, m, n ∈ N}.
(g) {0m
1n
: m ≥ 4, n ≤ 3, m, n ∈ N}.
(h) {0m
1n
: m ≤ 4, n ≤ 3, m, n ∈ N}.
(i) Complement of {0m
1n
: m ≥ 4, n ≤ 3, m, n ∈ N}.
(j) Complement of {0m
1n
: m ≤ 4, n ≤ 3, m, n ∈ N}.
(k) Complement of {w ∈ (0 ∪ 1)∗
1(0 ∪ 01)∗
: (w) ≤ 3}.
(l) {0m
1n
: m ≥ 1, n ≥ 1, mn ≥ 3}.
(m) {01n
w : w ∈ {0, 1}+
, n ∈ N}.
(n) Complement of {02m
12n+1
: m, n ∈ N}.
(o) {uwu : (u) = 2}.
(p) Set of all strings having exactly one pair of consecutive zeros.
(q) Set of all strings ending with 01.
(r) Set of all strings not ending in 01.
(s) Set of all strings containing an even number of zeros.
(t) Set of all strings with at most two occurrences of the substring 00.
(u) Set of all strings having at least two occurrences of the substring 00. [Note: 000
contains two such occurrences.]
2.20. Write the languages of the following regular expressions in set notation, and
also give verbal descriptions:
(a) a∗
(a ∪ b).
(b) (a ∪ b)∗
(a ∪ bb).
(c) ((0 ∪ 1)∗
(0 ∪ 1)∗
)∗
00(0 ∪ 1)∗
.
(d) (aa)∗
(bb)∗
b.
(e) (1 ∪ 01)∗
.
(f) (aa)∗
b(aa)∗
∪ a(aa)∗
ba(aa)∗
.
Other documents randomly have
different content
cultivated in the north of England. Sedburgh, for many years, was a
sort of nursery or rural chapel-of-ease to Cambridge. Dawson of
Sedburgh was a luminary better known than ever Dr. Watson was,
by mathematicians both foreign and domestic. Gough, the blind
mathematician and botanist of Kendal, is known to this day; but
many others in that town had accomplishments equal to his; and,
indeed, so widely has mathematical knowledge extended itself
throughout Northern England that, even amongst the poor
Lancashire weavers, mechanic labourers for their daily bread, the
cultivation of pure geometry, in the most refined shape, has long
prevailed; of which some accounts have been recently published.
Local pique, therefore, must have been at the bottom of Dr.
Whittaker's sneer. At all events, it was ludicrously contrasted with
the true state of the case, as brought out by the meeting between
Coleridge and the Bishop.
Coleridge was armed, at all points, with the scholastic erudition
which bore upon all questions that could arise in polemic divinity.
The philosophy of ancient Greece, through all its schools, the
philosophy of the schoolmen technically so called, Church history,
c., Coleridge had within his call. Having been personally
acquainted, or connected as a pupil, with Eichhorn and Michaelis, he
knew the whole cycle of schisms and audacious speculations through
which Biblical criticism or Christian philosophy has revolved in
Modern Germany. All this was ground upon which the Bishop of
Llandaff trod with the infirm footing of a child. He listened to what
Coleridge reported with the same sort of pleasurable surprise,
alternating with starts of doubt or incredulity, as would naturally
attend a detailed report from Laputa—which aërial region of
speculation does but too often recur to a sober-minded person in
reading of the endless freaks in philosophy of Modern Germany,
where the sceptre of Mutability, that potentate celebrated by
Spenser, gathers more trophies in a year than elsewhere in a
century; the anarchy of dreams presides in her philosophy; and
the restless elements of opinion, throughout every region of debate,
mould themselves eternally, like the billowy sands of the desert as
beheld by Bruce, into towering columns, soar upwards to a giddy
altitude, then stalk about for a minute, all aglow with fiery colour,
and finally unmould and dislimn, with a collapse as sudden as the
motions of that eddying breeze under which their vapoury
architecture had arisen. Hartley and Locke, both of whom the bishop
made into idols, were discussed; especially the former, against
whom Coleridge alleged some of those arguments which he has
used in his Biographia Literaria. The bishop made but a feeble
defence; and upon some points none at all. He seemed, I remember,
much struck with one remark of Coleridge's, to this effect:—That,
whereas Hartley fancied that our very reasoning was an aggregation,
collected together under the law of association, on the contrary, we
reason by counteracting that law: just, said he, as, in leaping, the
law of gravitation concurs to that act in its latter part; but no leap
could take place were it not by a counteraction of the law. One
remark of the bishop's let me into the secret of his very limited
reading. Coleridge had used the word apperception, apparently
without intention; for, on hearing some objection to the word, as
being surely not a word that Addison would have used, he
substituted transcendental consciousness. Some months afterwards,
going with Charles Lloyd to call at Calgarth, during the time when
The Friend was appearing, the bishop again noticed this obnoxious
word, and in the very same terms:—Now, this word apperception,
which Mr. Coleridge uses in the last number of 'The Friend,' surely,
surely it would not have been approved by Addison; no, Mr. Lloyd,
nor by Swift; nor even, I think, by Arbuthnot. Somebody suggested
that the word was a new word of German mintage, and most
probably due to Kant—of whom the bishop seemed never to have
heard. Meantime the fact was, and to me an amusing one, that the
word had been commonly used by Leibnitz, a classical author on
such subjects, 120 years before.
In the autumn of 1810, Coleridge left the Lakes; and, so far as I am
aware, for ever. I once, indeed, heard a rumour of his having passed
through with some party of tourists—some reason struck me at the
time for believing it untrue—but, at all events, he never returned to
them as a resident. What might be his reason for this eternal self-
banishment from scenes which he so well understood in all their
shifting forms of beauty, I can only guess. Perhaps it was the very
opposite reason to that which is most obvious: not, possibly,
because he had become indifferent to their attractions, but because
his undecaying sensibility to their commanding power had become
associated with too afflicting remembrances, and flashes of personal
recollections, suddenly restored and illuminated—recollections which
will
Sometimes leap
From hiding-places ten years deep,
and bring into collision the present with some long-forgotten past, in
a form too trying and too painful for endurance. I have a brilliant
Scotch friend, who cannot walk on the seashore—within sight of its
ανηριθμον γελασμα (anêrithmon gelasma), the multitudinous
laughter of its waves, or within hearing of its resounding uproar,
because they bring up, by links of old association, too insupportably
to his mind the agitations of his glittering, but too fervid youth.
There is a feeling—morbid, it may be, but for which no anodyne is
found in all the schools from Plato to Kant—to which the human
mind is liable at times: it is best described in a little piece by Henry
More, the Platonist. He there represents himself as a martyr to his
own too passionate sense of beauty, and his consequent too pathetic
sense of its decay. Everywhere—above, below, around him, in the
earth, in the clouds, in the fields, and in their garniture of
flowers—he beholds a beauty carried to excess; and this beauty
becomes a source of endless affliction to him, because everywhere
he sees it liable to the touch of decay and mortal change. During
one paroxysm of this sad passion, an angel appears to comfort him;
and, by the sudden revelation of her immortal beauty, does, in fact,
suspend his grief. But it is only a suspension; for the sudden
recollection that her privileged condition, and her exemption from
the general fate of beauty, is only by way of exception to a universal
rule, restores his grief: And thou thyself, he says to the angel—
And thou thyself, that com'st to comfort me,
Wouldst strong occasion of deep sorrow bring,
If thou wert subject to mortality!
Every man who has ever dwelt with passionate love upon the fair
face of some female companion through life must have had the
same feeling, and must often, in the exquisite language of
Shakspere's sonnets, have commanded and adjured all-conquering
Time, there, at least, and upon that one tablet of his adoration,
To write no wrinkle with his antique hand.
Vain prayer! Empty adjuration! Profitless rebellion against the laws
which season all things for the inexorable grave! Yet not the less we
rebel again and again; and, though wisdom counsels resignation, yet
our human passions, still cleaving to their object, force us into
endless rebellion. Feelings the same in kind as these attach
themselves to our mental power, and our vital energies. Phantoms of
lost power, sudden intuitions, and shadowy restorations of forgotten
feelings, sometimes dim and perplexing, sometimes by bright but
furtive glimpses, sometimes by a full and steady revelation,
overcharged with light—throw us back in a moment upon scenes
and remembrances that we have left full thirty years behind us. In
solitude, and chiefly in the solitudes of nature, and, above all,
amongst the great and enduring features of nature, such as
mountains, and quiet dells, and the lawny recesses of forests, and
the silent shores of lakes, features with which (as being themselves
less liable to change) our feelings have a more abiding association—
under these circumstances it is that such evanescent hauntings of
our past and forgotten selves are most apt to startle and to waylay
us. These are positive torments from which the agitated mind
shrinks in fear; but there are others negative in their nature—that is,
blank mementoes of powers extinct, and of faculties burnt out within
us. And from both forms of anguish—from this twofold scourge—
poor Coleridge fled, perhaps, in flying from the beauty of external
nature. In alluding to this latter, or negative form of suffering—that
form, I mean, which presents not the too fugitive glimpses of past
power, but its blank annihilation—Coleridge himself most beautifully
insists upon and illustrates the truth that all which we find in Nature
must be created by ourselves; and that alike whether Nature is so
gorgeous in her beauty as to seem apparelled in her wedding-
garment or so powerless and extinct as to seem palled in her
shroud. In either case,
O, Lady, we receive but what we give,
And in our life alone does nature live;
Ours is her wedding-garment, ours her shroud.
It were a vain endeavour,
Though I should gaze for ever
On that green light that lingers in the west:
I may not hope from outward forms to win
The passion and the life whose fountains are within.
This was one, and the most common, shape of extinguished power
from which Coleridge fled to the great city. But sometimes the same
decay came back upon his heart in the more poignant shape of
intimations and vanishing glimpses, recovered for one moment from
the paradise of youth, and from fields of joy and power, over which,
for him, too certainly, he felt that the cloud of night was settling for
ever. Both modes of the same torment exiled him from nature; and
for the same reasons he fled from poetry and all commerce with his
own soul; burying himself in the profoundest abstractions from life
and human sensibilities.
For not to think of what I needs must feel,
But to be still and patient all I can;
And haply by abstruse research to steal,
From my own nature, all the natural man;
This was my sole resource, my only plan;
Till that, which suits a part, infects the whole,
And now is almost grown the habit of my soul.
Such were, doubtless, the true and radical causes which, for the final
twenty-four years of Coleridge's life, drew him away from those
scenes of natural beauty in which only, at an earlier stage of life, he
found strength and restoration. These scenes still survived; but their
power was gone, because that had been derived from himself, and
his ancient self had altered. Such were the causes; but the
immediate occasion of his departure from the Lakes, in the autumn
of 1810, was the favourable opportunity then presented to him of
migrating in a pleasant way. Mr. Basil Montagu, the Chancery
barrister, happened at that time to be returning to London, with Mrs.
Montagu, from a visit to the Lakes, or to Wordsworth.[81]
His
travelling carriage was roomy enough to allow of his offering
Coleridge a seat in it; and his admiration of Coleridge was just then
fervent enough to prompt a friendly wish for that sort of close
connexion (viz. by domestication as a guest under Mr. Basil
Montagu's roof) which is the most trying to friendship, and which in
this instance led to a perpetual rupture of it. The domestic habits of
eccentric men of genius, much more those of a man so irreclaimably
irregular as Coleridge, can hardly be supposed to promise very
auspiciously for any connexion so close as this. A very extensive
house and household, together with the unlimited licence of action
which belongs to the ménage of some great Dons amongst the
nobility, could alone have made Coleridge an inmate perfectly
desirable. Probably many little jealousies and offences had been
mutually suppressed; but the particular spark which at length fell
amongst the combustible materials already prepared, and thus
produced the final explosion, took the following shape:—Mr. Montagu
had published a book against the use of wine and intoxicating
liquors of every sort.[82]
Not out of parsimony or under any suspicion
of inhospitality, but in mere self-consistency and obedience to his
own conscientious scruples, Mr. Montagu would not countenance the
use of wine at his own table. So far all was right. But doubtless, on
such a system, under the known habits of modern life, it should
have been made a rule to ask no man to dinner: for to force men,
without warning, to a single (and, therefore, thoroughly useless) act
of painful abstinence, is what neither I nor any man can have a right
to do. In point of sense, it is, in fact, precisely the freak of Sir Roger
de Coverley, who drenches his friend the Spectator with a hideous
decoction: not, as his confiding visitor had supposed, for some
certain and immediate benefit to follow, but simply as having a
tendency (if well supported by many years' continuance of similar
drenches) to abate the remote contingency of the stone. Hear this,
ye Gods of the Future! I am required to perform a most difficult
sacrifice; and forty years hence I may, by persisting so long, have
some dim chance of reward. One day's abstinence could do no good
on any scheme: and no man was likely to offer himself for a second.
However, such being the law of the castle, and that law well known
to Coleridge, he nevertheless, thought fit to ask to dinner Colonel
(then Captain) Pasley, of the Engineers, well known in those days for
his book on the Military Policy of England, and since for his
System of Professional Instruction. Now, where or in what land
abides that
Captain, or Colonel, or Knight-in-arms,
to whom wine in the analysis of dinner is a neutral or indifferent
element? Wine, therefore, as it was not of a nature to be omitted,
Coleridge took care to furnish at his own private cost. And so far,
again, all was right. But why must Coleridge give his dinner to the
captain in Mr. Montagu's house? There lay the affront; and,
doubtless, it was a very inconsiderate action on the part of
Coleridge. I report the case simply as it was then generally borne
upon the breath, not of scandal, but of jest and merriment. The
result, however, was no jest; for bitter words ensued—words that
festered in the remembrance; and a rupture between the parties
followed, which no reconciliation has ever healed.
Meantime, on reviewing this story, as generally adopted by the
learned in literary scandal, one demur rises up. Dr. Parr, a lisping
Whig pedant, without personal dignity or conspicuous power of
mind, was a frequent and privileged inmate at Mr. Montagu's. Him
now—this Parr—there was no conceivable motive for enduring; that
point is satisfactorily settled by the pompous inanities of his works.
Yet, on the other hand, his habits were in their own nature far less
endurable than Samuel Taylor Coleridge's; for the monster smoked;
—and how? How did the Birmingham Doctor[83]
smoke? Not as
you, or I, or other civilized people smoke, with a gentle cigar—but
with the very coarsest tobacco. And those who know how that
abomination lodges and nestles in the draperies of window-curtains
will guess the horror and detestation in which the old Whig's
memory is held by all enlightened women. Surely, in a house where
the Doctor had any toleration at all, Samuel Taylor Coleridge might
have enjoyed an unlimited toleration.[84]
From Mr. Montagu's Coleridge passed, by favour of what introduction
I never heard, into a family as amiable in manners and as benign in
disposition as I remember to have ever met with. On this excellent
family I look back with threefold affection, on account of their
goodness to Coleridge, and because they were then unfortunate,
and because their union has long since been dissolved by death. The
family was composed of three members: of Mr. M——, once a
lawyer, who had, however, ceased to practise; of Mrs. M——, his
wife, a blooming young woman, distinguished for her fine person;
and a young lady, her unmarried sister.[85]
Here, for some years, I
used to visit Coleridge; and, doubtless, as far as situation merely,
and the most delicate attentions from the most amiable women,
could make a man happy, he must have been so at this time; for
both the ladies treated him as an elder brother, or as a father. At
length, however, the cloud of misfortune, which had long settled
upon the prospects of this excellent family, thickened; and I found,
upon one of my visits to London, that they had given up their house
in Berners Street, and had retired to a cottage in Wiltshire. Coleridge
had accompanied them; and there I visited them myself, and, as it
eventually proved, for the last time. Some time after this, I heard
from Coleridge, with the deepest sorrow, that poor M—— had been
thrown into prison, and had sunk under the pressure of his
misfortunes. The gentle ladies of his family had retired to remote
friends; and I saw them no more, though often vainly making
inquiries about them.
Coleridge, during this part of his London life, I saw constantly—
generally once a day, during my own stay in London; and sometimes
we were jointly engaged to dinner parties. In particular, I remember
one party at which we met Lady Hamilton—Lord Nelson's Lady
Hamilton—the beautiful, the accomplished, the enchantress!
Coleridge admired her, as who would not have done, prodigiously;
and she, in her turn, was fascinated with Coleridge. He was
unusually effective in his display; and she, by way of expressing her
acknowledgments appropriately, performed a scene in Lady Macbeth
—how splendidly, I cannot better express than by saying that all of
us who then witnessed her performance were familiar with Mrs.
Siddons's matchless execution of that scene, and yet, with such a
model filling our imaginations, we could not but acknowledge the
possibility of another, and a different perfection, without a trace of
imitation, equally original, and equally astonishing. The word
magnificent is, in this day, most lavishly abused: daily I hear or
read in the newspapers of magnificent objects, as though scattered
more thickly than blackberries; but for my part I have seen few
objects really deserving that epithet. Lady Hamilton was one of
them. She had Medea's beauty, and Medea's power of enchantment.
But let not the reader too credulously suppose her the unprincipled
woman she has been described. I know of no sound reason for
supposing the connexion between Lord Nelson and her to have been
other than perfectly virtuous. Her public services, I am sure, were
most eminent—for that we have indisputable authority; and equally
sure I am that they were requited with rank ingratitude.
After the household of the poor M—— s had been dissolved, I know
not whither Coleridge went immediately: for I did not visit London
until some years had elapsed. In 1823-24 I first understood that he
had taken up his residence as a guest with Mr. Gillman, a surgeon, in
Highgate. He had then probably resided for some time at that
gentleman's: there he continued to reside on the same terms, I
believe, of affectionate friendship with the members of Mr. Gillman's
family as had made life endurable to him in the time of the M—— s;
and there he died in July of the present year. If, generally speaking,
poor Coleridge had but a small share of earthly prosperity, in one
respect at least he was eminently favoured by Providence: beyond
all men who ever perhaps have lived, he found means to engage a
constant succession of most faithful friends; and he levied the
services of sisters, brothers, daughters, sons, from the hands of
strangers—attracted to him by no possible impulses but those of
reverence for his intellect, and love for his gracious nature. How,
says Wordsworth—
----How can he expect that others should
Sow for him, reap for him, and at his call
Love him, who for himself will take no thought at all?
How can he, indeed? It is most unreasonable to do so: yet this
expectation, if Coleridge ought not to have entertained, at all events
he realized. Fast as one friend dropped off, another, and another,
succeeded: perpetual relays were laid along his path in life, of
judicious and zealous supporters, who comforted his days, and
smoothed the pillow for his declining age, even when it was beyond
all human power to take away the thorns which stuffed it.
And what were those thorns?—and whence derived? That is a
question on which I ought to decline speaking, unless I could speak
fully. Not, however, to make any mystery of what requires none, the
reader will understand that originally his sufferings, and the death
within him of all hope—the palsy, as it were, of that which is the life
of life, and the heart within the heart—came from opium. But two
things I must add—one to explain Coleridge's case, and the other to
bring it within the indulgent allowance of equitable judges:—First,
the sufferings from morbid derangements, originally produced by
opium, had very possibly lost that simple character, and had
themselves re-acted in producing secondary states of disease and
irritation, not any longer dependent upon the opium, so as to
disappear with its disuse: hence, a more than mortal
discouragement to accomplish this disuse, when the pains of self-
sacrifice were balanced by no gleams of restorative feeling. Yet,
secondly, Coleridge did make prodigious efforts to deliver himself
from this thraldom; and he went so far at one time in Bristol, to my
knowledge, as to hire a man for the express purpose, and armed
with the power of resolutely interposing between himself and the
door of any druggist's shop. It is true that an authority derived only
from Coleridge's will could not be valid against Coleridge's own
counter-determination: he could resume as easily as he could
delegate the power. But the scheme did not entirely fail; a man
shrinks from exposing to another that infirmity of will which he
might else have but a feeble motive for disguising to himself; and
the delegated man, the external conscience, as it were, of Coleridge,
though destined—in the final resort, if matters came to absolute
rupture, and to an obstinate duel, as it were, between himself and
his principal—in that extremity to give way, yet might have long
protracted the struggle before coming to that sort of dignus vindice
nodus: and in fact, I know, upon absolute proof, that, before
reaching that crisis, the man showed fight, and, faithful to his trust,
and comprehending the reasons for it, declared that, if he must
yield, he would know the reason why.
Opium, therefore, subject to the explanation I have made, was
certainly the original source of Coleridge's morbid feelings, of his
debility, and of his remorse. His pecuniary embarrassments pressed
as lightly as could well be expected upon him. I have mentioned the
annuity of £150 made to him by the two Wedgwoods. One half, I
believe, could not be withdrawn, having been left by a regular
testamentary bequest. But the other moiety, coming from the
surviving brother, was withdrawn on the plea of commercial losses,
somewhere, I think, about 1815. That would have been a heavy
blow to Coleridge; and assuredly the generosity is not very
conspicuous of having ever suffered an allowance of that nature to
be left to the mercy of accident. Either it ought not to have been
granted in that shape—viz. as an annual allowance, giving ground
for expecting its periodical recurrence—or it ought not to have been
withdrawn. However, this blow was broken to Coleridge by the
bounty of George IV, who placed Coleridge's name in the list of
twelve to whom he granted an annuity of 100 guineas per annum.
This he enjoyed so long as that Prince reigned. But at length came a
heavier blow than that from Mr. Wedgwood: a new King arose, who
knew not Joseph. Yet surely he was not a King who could so easily
resolve to turn adrift twelve men of letters, many of them most
accomplished men, for the sake of appropriating a sum no larger to
himself than 1200 guineas—no less to some of them than the total
freight of their earthly hopes?—No matter: let the deed have been
from whose hand it might, it was done: ἑιργασται (heirgastai), it was
perpetrated, as saith the Medea of Euripides; and it will be
mentioned hereafter, more than either once or twice. It fell with
weight, and with effect upon the latter days of Coleridge; it took
from him as much heart and hope as at his years, and with his
unworldly prospects, remained for man to blight: and, if it did not
utterly crush him, the reason was—because for himself he had never
needed much, and was now continually drawing near to that haven
in which, for himself, he would need nothing; secondly, because his
children were now independent of his aid; and, finally, because in
this land there are men to be found always of minds large enough to
comprehend the claims of genius, and with hearts, by good luck,
more generous, by infinite degrees, than the hearts of Princes.
Coleridge, as I now understand, was somewhere about sixty-two
years of age when he died.[86]
This, however, I take upon the report
of the public newspapers; for I do not, of my own knowledge, know
anything accurately upon that point.
It can hardly be necessary to inform any reader of discernment or of
much practice in composition that the whole of this article upon Mr.
Coleridge, though carried through at intervals, and (as it has
unexpectedly happened) with time sufficient to have made it a very
careful one, has, in fact, been written in a desultory and
unpremeditated style. It was originally undertaken on the sudden
but profound impulse communicated to the writer's feelings by the
unexpected news of this great man's death; partly, therefore, to
relieve, by expressing, his own deep sentiments of reverential
affection to his memory, and partly, in however imperfect a way, to
meet the public feeling of interest or curiosity about a man who had
long taken his place amongst the intellectual potentates of the age.
Both purposes required that it should be written almost extempore:
the greater part was really and unaffectedly written in that way, and
under circumstances of such extreme haste as would justify the
writer in pleading the very amplest privilege of licence and indulgent
construction which custom concedes to such cases. Hence it had
occurred to the writer, as a judicious principle, to create a sort of
merit out of his own necessity, and rather to seek after the graces
which belong to the epistolary form, or to other modes of
composition professedly careless, than after those which grow out of
preconceived biographies, which, having originally settled their plan
upon a regular foundation, are able to pursue a course of orderly
development, such as his slight sketch had voluntarily renounced
from the beginning. That mode of composition having been once
adopted, it seemed proper to sustain it, even after delays and
interruption had allowed time for throwing the narrative into a more
orderly movement, and modulating it, as it were, into a key of the
usual solemnity. The qualis ab incepto processerit—the ordo
prescribed by the first bars of the music predominated over all other
considerations, and to such an extent that he had purposed to leave
the article without any regular termination or summing up—as, on
the one hand, scarcely demanded by the character of a sketch so
rapid and indigested, whilst, on the other, he was sensible that
anything of so much pretension as a formal peroration challenged a
sort of consideration to the paper which it was the author's chief
wish to disclaim. That effect, however, is sufficiently parried by the
implied protest now offered; and, on other reasons, it is certainly
desirable that a general glance, however cursory, should be thrown
over the intellectual claims of Mr. Coleridge by one who knew him so
well, and especially in a case where those very claims constitute the
entire and sole justification of the preceding personal memoir. That
which furnishes the whole moving reason for any separate notice at
all, and forms its whole latent interest, ought not, in mere logic, to
be left without some notice itself, though as rapidly executed as the
previous biographical sketch, and, from the necessity of the subject,
by many times over more imperfect.
To this task, therefore, the writer now addresses himself; and by
way of gaining greater freedom of movement and of resuming his
conversational tone, he will here again take the liberty of speaking in
the first person.
If Mr. Coleridge had been merely a scholar—merely a philologist—or
merely a man of science—there would be no reason apparent for
travelling in our survey beyond the field of his intellect, rigorously
and narrowly so called. But, because he was a poet, and because he
was a philosopher in a comprehensive and a most human sense,
with whose functions the moral nature is so largely interwoven, I
shall feel myself entitled to notice the most striking aspects of his
character (using that word in its common limited meaning), of his
disposition, and his manners, as so many reflex indications of his
intellectual constitution. But let it be well understood that I design
nothing elaborate, nothing comprehensive or ambitious: my purpose
is merely to supply a few hints and suggestions drawn from a very
hasty retrospect, by way of adding a few traits to any outline which
the reader may have framed to himself, either from some personal
knowledge, or from more full and lively memorials.
One character in which Mr. Coleridge most often came before the
public was that of politician. In this age of fervent partisanship, it
will, therefore, naturally occur as a first question to inquire after his
party and political connexions: was he Whig, Tory, or Radical? Or,
under a new classification, were his propensities Conservative or
Reforming? I answer that, in any exclusive or emphatic sense, he
was none of these; because, as a philosopher, he was, according to
circumstances, and according to the object concerned, all of these
by turns. These are distinctions upon which a cloud of delusion
rests. It would not be difficult to show that in the speculations built
upon the distinction of Whig and Tory, even by as philosophic a
politician as Edmund Burke, there is an oversight of the largest
practical importance. But the general and partisan use of these
terms superadds to this πρωτον ψευδος (prôton pseudos) a second
which is much more flagrant. It is this: the terms Whig or Tory, used
by partisans, are taken extra gradum, as expressing the ideal or
extreme cases of the several creeds; whereas, in actual life, few
such cases are found realized, by far the major part of those who
answer to either one or the other denomination making only an
approximation (differing by infinite degrees) to the ideal or abstract
type. A third error there is, relating to the actual extent of the
several denominations, even after every allowance made for the
faintest approximations. Listen to a Whig, or to a Tory, and you will
suppose that the great bulk of society range under his banner: all, at
least, who have any property at stake. Listen to a Radical, and you
will suppose that all are marshalled in the same ranks with himself,
unless those who have some private interest in existing abuses, or
have aristocratic privileges to defend. Yet, upon going extensively
into society as it is, you find that a vast majority of good citizens are
of no party whatsoever, own no party designation, care for no party
interest, but carry their good wishes by turns to men of every party,
according to the momentary purpose they are pursuing. As to Whig
and Tory, it is pretty clear that only two classes of men, both of
limited extent, acknowledge these as their distinctions: first, those
who make politics in some measure their profession or trade—
whether by standing forward habitually in public meetings as leaders
or as assistants, or by writing books and pamphlets in the same
cause; secondly, those whose rank, or birth, or position in a city, or a
rural district, almost pledges them to a share in the political
struggles of the day, under the penalty of being held fainéans,
truants, or even malignant recusants, if they should decline a
warfare which often, perhaps, they do not love in secret. These
classes, which, after all, are not numerous, and not entirely sincere,
compose the whole extent of professing Whigs and Tories who make
any approach to the standards of their two churches; and, generally
speaking, these persons have succeeded to their politics and their
party ties, as they have to their estates, viz. by inheritance. Not their
way of thinking in politics has dictated their party connexions; but
these connexions, traditionally bequeathed from one generation to
another, have dictated their politics. With respect to the Radical or
the Reformer, the case is otherwise; for it is certain that in this, as in
every great and enlightened nation, enjoying an intense and fervid
communication of thought through the press, there is, and must be,
a tendency widely diffused to the principles of sane reform—an
anxiety to probe and examine all the institutions of the land by the
increasing lights of the age—and a salutary determination that no
acknowledged abuse shall be sheltered by prescription, or privileged
by its antiquity. In saying, therefore, that his principles are spread
over the length and breadth of the land, the Reformer says no more
than the truth. Whig and Tory, as usually understood, express only
two modes of aristocratic partisanship: and it is strange, indeed, to
find people deluded by the notion that the reforming principle has
any more natural connexion with the first than the last. Reformer, on
the other hand, to a certain extent expresses the political creed and
aspect of almost every enlightened citizen: but, then, how? Not, as
the Radical would insinuate, as pledging a man to a specific set of
objects, or to any visible and apparent party, having known leaders
and settled modes of action. British society, in its large majority, may
be fairly described as Reformers, in the sense of being favourably
disposed to a general spirit of ventilation and reform carried through
all departments of public business, political or judicial; but it is so far
from being, therefore, true that men in general are favourably
disposed to any known party, in or out of Parliament, united for
certain objects and by certain leaders, that, on the contrary, this
reforming party itself has no fixed unity, and no generally
acknowledged heads. It is divided both as to persons and as to
things: the ends to be pursued create as many schisms as the
course of means proper for the pursuit, and the choice of agents for
conducting the public wishes. In fact, it would be even more difficult
to lay down the ideal standard of a Reformer, or his abstract creed,
than of a Tory: and, supposing this done, it would be found, in
practice, that the imperfect approximations to the pure faith would
differ by even broader shades as regarded the reforming creed than
as regarded that of the rigorous or ultra Tory.
With respect to Mr. Coleridge: he was certainly a friend to all
enlightened reforms; he was a friend, for example, to Reform in
Parliament. Sensible as he was of the prodigious diffusion of
knowledge and good sense amongst the classes immediately below
the gentry in British society, he could not but acknowledge their right
to a larger and a less indirect share of political influence. As to the
plan, and its extent, and its particular provisions,—upon those he
hesitated and wavered; as other friends to the same views have
done, and will continue to do. The only avowed objects of modern
Reformers which he would strenuously have opposed, nay, would
have opposed with the zeal of an ancient martyr, are those which
respect the Church of England, and, therefore, most of those which
respect the two Universities of Oxford and Cambridge. There he
would have been found in the first ranks of the Anti-Reformers. He
would also have supported the House of Peers, as the tried bulwark
of our social interests in many a famous struggle, and sometimes, in
the hour of need, the sole barrier against despotic aggressions on
the one hand, and servile submissions on the other. Moreover, he
looked with favour upon many modes of aristocratic influence as
balances to new-made commercial wealth, and to a far baser
tyranny likely to arise from that quarter when unbalanced. But,
allowing for these points of difference, I know of little else stamped
with the general seal of modern reform, and claiming to be a
privileged object for a national effort, which would not have had his
countenance. It is true,—and this I am sensible will be objected,—
that his party connexions were chiefly with the Tories; and it adds a
seeming strength to this objection, that these connexions were not
those of accident, nor those which he inherited, nor those of his
youthful choice. They were sought out by himself, and in his maturer
years; or else they were such as sought him for the sake of his
political principles; and equally, in either case, they argued some
affinity in his political creed. This much cannot be denied. But one
consideration will serve greatly to qualify the inference from these
facts. In those years when Mr. Coleridge became connected with
Tories, what was the predominating and cardinal principle of
Toryism, in comparison with which all else was willingly slighted?
Circumstances of position had thrown upon the Tories the onus of a
great national struggle, the greatest which History anywhere
records, and with an enemy the most deadly. The Whigs were then
out of power: they were therefore in opposition; and that one fact,
the simple fact, of holding an anti-ministerial position, they allowed,
by a most fatal blunder, to determine the course of their foreign
politics. Napoleon was to be cherished simply because he was a
thorn in Mr. Pitt's side. So began their foreign policy—and in that
pettiest of personal views. Because they were anti-ministerial, they
allowed themselves passively to become anti-national. To be a Whig,
therefore, in those days, implied little more than a strenuous
opposition to foreign war; to be a Tory pledged a man to little more
than war with Napoleon Bonaparte. And this view of our foreign
relations it was that connected Coleridge with Tories,—a view which
arose upon no motives of selfish interest (as too often has been said
in reproach), but upon the changes wrought in the spirit of the
French Republic, which gradually transmuted its defensive warfare
(framed originally to meet a conspiracy of kings crusading against
the new-born democracy of French institutions, whilst yet in their
cradle) into a warfare of aggression and sanguinary ambition. The
military strength evoked in France by the madness of European
kings had taught her the secret of her own power—a secret too
dangerous for a nation of vanity so infinite, and so feeble in all
means of moral self-restraint. The temptation to foreign conquest
was too strong for the national principles; and, in this way, all that
had been grand and pure in the early pretensions of French
Republicanism rapidly melted away before the common bribes of
vulgar ambition. Unoffending states, such as Switzerland, were the
first to be trampled under foot; no voice was heard any more but the
brazen throat of war; and, after all that had been vaunted of a
golden age, and a long career opened to the sceptre of pure political
justice, the clouds gathered more gloomily than ever; and the sword
was once more reinstated, as the sole arbiter of right, with less
disguise and less reserve than under the vilest despotism of kings.
The change was in the French Republicans, not in their foreign
admirers; they, in mere consistency, were compelled into
corresponding changes, and into final alienation of sympathy, as
they beheld, one after one, all titles forfeited by which that grand
explosion of pure democracy had originally challenged and sustained
their veneration. The mighty Republic had now begun to revolve
through those fierce transmigrations foreseen by Burke, to every one
of which, by turns, he had denounced an inevitable purification by
fire and blood: no trace remained of her primitive character: and of
that awful outbreak of popular might which once had made France
the land of hope and promise to the whole human race, and had
sounded a knell to every form of oppression or abuse, no record was
to be found, except in the stupendous power which cemented its
martial oligarchy. Of the people, of the democracy—or that it had
ever for an hour been roused from its slumbers—one sole evidence
remained; and that lay in the blank power of destruction, and its
perfect organization, which none but a popular movement, no power
short of that, could have created. The people, having been
unchained, and as if for the single purpose of creating a vast system
of destroying energies, had then immediately recoiled within their
old limits, and themselves become the earliest victim of their own
stratocracy. In this way France had become an object of jealousy
and alarm. It remained to see to what purpose she would apply her
new energies. That was soon settled; her new-born power was
wielded from the first by unprincipled and by ambitious men; and, in
1800, it fell under the permanent control of an autocrat, whose unity
of purpose, and iron will, left no room for any hope of change.
Under these circumstances, under these prospects, coupled with this
retrospect, what became the duty of all foreign politicians? of the
English above all, as natural leaders in any hopeful scheme of
resistance? The question can scarcely be put with decency. Time and
season, place or considerations of party, all alike vanished before an
elementary duty to the human race, which much transcended any
duty of exclusive patriotism. Plant it, however, on that narrower
basis, and the answer would have been the same for all centuries,
and for every land under a corresponding state of circumstances. Of
Napoleon's real purposes there cannot now be any reasonable
doubt. His confessions—and, in particular, his indirect revelations at
St. Helena—have long since removed all demurs or scruples of
scepticism. For England, therefore, as in relation to a man bent upon
her ruin, all distinctions of party were annihilated—Whig and Tory
were merged and swallowed up in the transcendent duties of
patriots, Englishmen, lovers of liberty. Tories, as Tories, had here no
peculiar or separate duties—none which belonged to their separate
creed in politics. Their duties were paramount; and their partisanship
had here no application—was perfectly indifferent, and spoke neither
this way nor that. In one respect only they had peculiar duties, and
a peculiar responsibility; peculiar, however, not by any difference of
quality, but in its supreme degree; the same duties which belonged
to all, belonged to them by a heavier responsibility. And how, or
why? Not as Tories had they, or could they have, any functions at all
applying to this occasion; it was as being then the ministerial party,
as the party accidentally in power at the particular crisis: in that
character it was that they had any separate or higher degree of
responsibility; otherwise, and as to the kind of their duty apart from
this degree, the Tories stood in the same circumstances as men of
all other parties. To the Tories, however, as accidentally in
possession of the supreme power, and wielding the national forces at
that time, and directing their application—to them it was that the
honour belonged of making a beginning: on them had devolved the
privilege of opening and authorizing the dread crusade. How and in
what spirit they acquitted themselves of that most enviable task—
enviable for its sanctity, fearful for the difficulty of its adequate
fulfilment—how they persevered, and whether, at any crisis, the
direst and most ominous to the righteous cause, they faltered or
gave sign of retreating—History will tell—History has already told. To
the Whigs belonged the duty of seconding their old antagonists: and
no wise man could have doubted that, in a case of transcendent
patriotism, where none of those principles could possibly apply by
which the two parties were divided and distinguished, the Whigs
would be anxious to show that, for the interests of their common
country, they could cheerfully lay aside all those party distinctions,
and forget those feuds which now had no pertinence or meaning.
Simply as Whigs, had they stood in no other relation, they probably
would have done so. Unfortunately, however, for their own good
name and popularity in after times, they were divided from the other
party, not merely as Whigs opposed to Tories, but also upon another
and a more mortifying distinction, which was not, like the first, a
mere inert question of speculation or theory, but involved a vast
practical difference of honours and emoluments:—they were divided,
I say, on another and more vexatious principle, as the Outs opposed
to the Ins. Simply as Whigs, they might have coalesced with the
Tories quoad hoc, and merely for this one purpose. But, as men out
of power, they could not coalesce with those who were in. They
constituted his Majesty's Opposition; and, in a fatal hour, they
determined that it was fitting to carry their general scheme of
hostility even into this sacred and privileged ground. That resolution
once taken, they found it necessary to pursue it with zeal. The case
itself was too weighty and too interesting to allow of any moderate
tone for the abetters or opposers. Passion and personal bitterness
soon animated the contest: violent and rash predictions were
hazarded—prophecies of utter ruin and of captivity for our whole
army were solemnly delivered: and it soon became evident, as
indeed mere human infirmity made it beforehand but too probable,
that, where so much personal credit was at stake upon the side of
our own national dishonour, the wishes of the prophet had been
pledged to the same result as the credit of his political sagacity.
Many were the melancholy illustrations of the same general case.
Men were seen fighting against the evidences of some great British
victory with all the bitterness and fierce incredulity which usually
meet the first rumours of some private calamity: that was in effect
the aspect in their eyes of each national triumph in its turn. Their
position, connected with the unfortunate election made by the Whig
leaders of their tone, from the very opening of the contest, gave the
character of a calamity for them and for their party to that which to
every other heart in Britain was the noblest of triumphs in the
noblest of causes; and, as a party, the Whigs mourned for years
over those events which quickened the pulses of pleasure and
sacred exultation in every other heart. God forbid that all Whigs
should have felt in this unnatural way! I speak only of the tone set
by the Parliamentary leaders. The few who were in Parliament, and
exposed to daily taunts from the just exultation of their irritated
opponents, had their natural feelings poisoned and envenomed. The
many who were out of Parliament, and not personally interested in
this warfare of the Houses, were left open to natural influences of
Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.
More than just a book-buying platform, we strive to be a bridge
connecting you with timeless cultural and intellectual values. With an
elegant, user-friendly interface and a smart search system, you can
quickly find the books that best suit your interests. Additionally,
our special promotions and home delivery services help you save time
and fully enjoy the joy of reading.
Join us on a journey of knowledge exploration, passion nurturing, and
personal growth every day!
ebookbell.com

More Related Content

PDF
Lessons in Enumerative Combinatorics 2021st Edition Ömer Eğecioğlu
PDF
Analysis Of Algorithms An Active Learning Approach 1st Edition Jeffrey J Mcco...
PPTX
Lecture 0 CSE322 updated LPU 5th SEM.pptx
PDF
Multiprocessor scheduling Theory and applications Levner E. (Ed.)
PDF
New books dec 2012
PDF
Multiprocessor scheduling Theory and applications Levner E. (Ed.)
DOC
4th sem
PDF
PDF Multiprocessor scheduling Theory and applications Levner E. (Ed.) download
Lessons in Enumerative Combinatorics 2021st Edition Ömer Eğecioğlu
Analysis Of Algorithms An Active Learning Approach 1st Edition Jeffrey J Mcco...
Lecture 0 CSE322 updated LPU 5th SEM.pptx
Multiprocessor scheduling Theory and applications Levner E. (Ed.)
New books dec 2012
Multiprocessor scheduling Theory and applications Levner E. (Ed.)
4th sem
PDF Multiprocessor scheduling Theory and applications Levner E. (Ed.) download

Similar to Elements Of Computation Theory Arindama Singh Auth (20)

PDF
Multiprocessor scheduling Theory and applications Levner E. (Ed.)
PDF
An Introduction to the Analysis of Algorithms (2nd_Edition_Robert_Sedgewick,_...
PDF
Data stuctures
PDF
Data structures and algorisms
PPTX
LN-01-Intoductio DSSSSSSSSSSSSSSSSSSSSSSSSn.pptx
DOCX
PDF
Multiprocessor scheduling Theory and applications Levner E. (Ed.)
PDF
STRUCTURAL ANALYSIS NINTH EDITION R. C. HIBBELER
DOCX
Course outlin for to c
PDF
The Design and Analysis of Computer Algorithms [Aho, Hopcroft & Ullman 1974-0...
PDF
Towards Responsible Machine Translation Ethical And Legal Considerations In M...
PDF
Applications Of Process Algebra J C M Baeten
PDF
C Plus Data Structures Subsequent Dale Nell B
PDF
Lectures On Factorization Homology Categories And Topological Field Theories ...
PDF
Robot And Multibody Dynamics Analysis And Algorithms 1st Edition Abhinandan J...
PDF
A Modern Introduction To Probability And Statistics Understanding Why And How...
PDF
C++ plus data structures, 3rd edition (2003)
 
PPTX
Computer Educational Theories Technology .pptx
PDF
Functional Equations And Inequalities With Applications 1st Edition Palaniapp...
Multiprocessor scheduling Theory and applications Levner E. (Ed.)
An Introduction to the Analysis of Algorithms (2nd_Edition_Robert_Sedgewick,_...
Data stuctures
Data structures and algorisms
LN-01-Intoductio DSSSSSSSSSSSSSSSSSSSSSSSSn.pptx
Multiprocessor scheduling Theory and applications Levner E. (Ed.)
STRUCTURAL ANALYSIS NINTH EDITION R. C. HIBBELER
Course outlin for to c
The Design and Analysis of Computer Algorithms [Aho, Hopcroft & Ullman 1974-0...
Towards Responsible Machine Translation Ethical And Legal Considerations In M...
Applications Of Process Algebra J C M Baeten
C Plus Data Structures Subsequent Dale Nell B
Lectures On Factorization Homology Categories And Topological Field Theories ...
Robot And Multibody Dynamics Analysis And Algorithms 1st Edition Abhinandan J...
A Modern Introduction To Probability And Statistics Understanding Why And How...
C++ plus data structures, 3rd edition (2003)
 
Computer Educational Theories Technology .pptx
Functional Equations And Inequalities With Applications 1st Edition Palaniapp...
Ad

Recently uploaded (20)

PPTX
master seminar digital applications in india
PDF
Basic Mud Logging Guide for educational purpose
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Computing-Curriculum for Schools in Ghana
PDF
TR - Agricultural Crops Production NC III.pdf
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
Cell Types and Its function , kingdom of life
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
Complications of Minimal Access Surgery at WLH
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
Classroom Observation Tools for Teachers
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
Insiders guide to clinical Medicine.pdf
master seminar digital applications in india
Basic Mud Logging Guide for educational purpose
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
VCE English Exam - Section C Student Revision Booklet
Computing-Curriculum for Schools in Ghana
TR - Agricultural Crops Production NC III.pdf
Module 4: Burden of Disease Tutorial Slides S2 2025
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Cell Types and Its function , kingdom of life
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Complications of Minimal Access Surgery at WLH
Abdominal Access Techniques with Prof. Dr. R K Mishra
Supply Chain Operations Speaking Notes -ICLT Program
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
O7-L3 Supply Chain Operations - ICLT Program
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Classroom Observation Tools for Teachers
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
102 student loan defaulters named and shamed – Is someone you know on the list?
Insiders guide to clinical Medicine.pdf
Ad

Elements Of Computation Theory Arindama Singh Auth

  • 1. Elements Of Computation Theory Arindama Singh Auth download https://ebookbell.com/product/elements-of-computation-theory- arindama-singh-auth-1144586 Explore and download more ebooks at ebookbell.com
  • 2. Here are some recommended products that we believe you will be interested in. You can click the link to download. Elements Of Plasticity Theory And Computation High Performance Structures And Materials Second I Doltsinis https://ebookbell.com/product/elements-of-plasticity-theory-and- computation-high-performance-structures-and-materials-second-i- doltsinis-2444106 Finite Element Solution Of Boundary Value Problems Theory And Computation O Axelsson https://ebookbell.com/product/finite-element-solution-of-boundary- value-problems-theory-and-computation-o-axelsson-4450898 Computational Elasticity Theory Of Elasticity Finite And Boundary Element Methods Revised Edition 4th Mohammed Ameen https://ebookbell.com/product/computational-elasticity-theory-of- elasticity-finite-and-boundary-element-methods-revised-edition-4th- mohammed-ameen-53598446 Elements Of Quantum Computation And Quantum Communication Pathak https://ebookbell.com/product/elements-of-quantum-computation-and- quantum-communication-pathak-5145140
  • 3. Computation Of Nonlinear Structures Extremely Large Elements For Frames Plates And Shells Ray https://ebookbell.com/product/computation-of-nonlinear-structures- extremely-large-elements-for-frames-plates-and-shells-ray-32704932 Engineering Computation Of Structures The Finite Element Method 1st Edition Maria Augusta Neto https://ebookbell.com/product/engineering-computation-of-structures- the-finite-element-method-1st-edition-maria-augusta-neto-5234570 Elements Of Computational Systems Biology Wiley Series In Bioinformatics 1st Edition Huma M Lodhi https://ebookbell.com/product/elements-of-computational-systems- biology-wiley-series-in-bioinformatics-1st-edition-huma-m- lodhi-2378414 Elements Of Computational Statistics James E Gentle https://ebookbell.com/product/elements-of-computational-statistics- james-e-gentle-1310482 Basic Elements Of Computational Statistics Hrdle Wolfgang Okhrin https://ebookbell.com/product/basic-elements-of-computational- statistics-hrdle-wolfgang-okhrin-6751384
  • 6. Texts in Computer Science Editors David Gries Fred B. Schneider For other titles published in this series, go to http://www.springer.com/series/3191
  • 7. Arindama Singh Elements of Computation Theory ABC
  • 8. Arindama Singh Department of Mathematics Indian Institute of Technology Madras Sardar Patel Road Chennai - 600036 India asingh@iitm.ac.in Series Editors David Gries Department of Computer Science Upson Hall Cornell University Ithaca, NY 14853-7501, USA Fred B. Schneider Department of Computer Science Upson Hall Cornell University Ithaca, NY 14853-7501, USA ISSN 1868-0941 e-ISSN 1868-095X ISBN 978-1-84882-496-6 e-ISBN 978-1-84882-497-3 DOI 10.1007/978-1-84882-497-3 Springer Dordrecht Heidelberg London New York British Library Cataloguing in Publication Data A catalogue record for this book is available from the British Library Library of Congress Control Number: applied for c Springer-Verlag London Limited 2009 Apart from any fair dealing for the purposes of research or private study, or criticism or review, as permitted under the Copyright, Designs and Patents Act of 1988, this publication may only be repro- duced, stored or transmitted, in any form or by any means, with the prior permission in writing of the publishers, or in the case of reprographic reproduction in accordance with the terms of licences issued by the Copyright Licensing Agency. Enquiries concerning reproduction outside those terms should be sent to the publishers. The use of registered names, trademarks, etc. in this publication does not imply, even in the absence of a specific statement, that such names are exempt from the relevant laws and regulations and therefore free for general use. The publisher makes no representation, express or implied, with regard to the accuracy of the information contained in this book and cannot accept any legal responsibility or liability for any errors or omissions that may be made. Cover design: SPi Publisher Services Printed on acid-free paper Springer is part of Springer Science+Business Media (www.springer.com)
  • 9. Preface The foundation of computer science is built upon the following questions: What is an algorithm? What can be computed and what cannot be computed? What does it mean for a function to be computable? How does computational power depend upon programming constructs? Which algorithms can be considered feasible? For more than 70 years, computer scientists are searching for answers to such ques- tions. Their ingenious techniques used in answering these questions form the theory of computation. Theory of computation deals with the most fundamental ideas of computer sci- ence in an abstract but easily understood form. The notions and techniques employed are widely spread across various topics and are found in almost every branch of com- puter science. It has thus become more than a necessity to revisit the foundation, learn the techniques, and apply them with confidence. Overview and Goals This book is about this solid, beautiful, and pervasive foundation of computer sci- ence. It introduces the fundamental notions, models, techniques, and results that form the basic paradigms of computing. It gives an introduction to the concepts and mathematics that computer scientists of our day use to model, to argue about, and to predict the behavior of algorithms and computation. The topics chosen here have shown remarkable persistence over the years and are very much in current use. The book realizes the following goals: • To introduce to the students of computer science and mathematics the elegant and useful models and abstractions that have been created over the years for solving foundational problems about computation • To help the students develop the ability to form abstract models of their own and to reason about them • To strengthen the students’ capability for carrying out formal and rigorous arguments about algorithms v
  • 10. vi Preface • To equip the students with the knowledge of the computational procedures that have hunted our predecessors, so that they can identify similar problems and struc- tures whenever they encounter one • To make the essential elements of the theory of computation accessible to not- so-matured students having not much mathematical background, in a way that is mathematically uncompromising • To make the students realize that mathematical rigour in arguing about algorithms can be very attractive • To keep in touch with the foundations as computer science has become a much more matured and established discipline Organization Chapter 1 reviews very briefly the mathematical preliminaries such as set theory, relations, graphs, trees, functions, cardinality, Cantor’s diagonalization, induction, and pigeon hole principle. The pace is not uniform. The topics supposedly unknown to Juniors are discussed in detail. The next three chapters talk about regular languages. Chapter 2 introduces the four mechanisms such as regular expressions, regular grammars, deterministic fi- nite automata, and the nondeterministic finite automata for representing languages in their own way. The fact that all these mechanisms represent the same class of languages is shown in Chap. 3. The closure properties of such languages, existence of other languages, other structural properties such as almost periodicity, Myhill– Nerode theorem, and state minimization are discussed in Chap. 4. Chapters 5 and 6 concern the class of context-free languages. Here we discuss context-free grammars, Pushdown automata, their equivalence, closure properties, and existence of noncontext-free languages. We also discuss parsing, ambiguity, and the two normal forms of Chomsky and Greibach. Deterministic pushdown automata have been introduced, but their equivalence to LR(k) grammars are not proved. Chapters 7 and 8 discuss the true nature of general algorithms introducing the unrestricted grammars, Turing machines, and their equivalence. We show how to take advantage of modularity of Turing machines for doing some complex jobs. Many possible extensions of Turing machines are tried and shown to be equivalent to the standard ones. Here, we show how Turing machines can be used to compute functions and decide languages. This leads to the acceptance problem and its undecidability. Chapter 9 discusses the jobs that can be done by algorithms and the jobs that cannot be. We discuss decision problems about regular languages, context-free lan- guages, and computably enumerable languages. The latter class is tackled greedily by the use of Rice’s theorem. Other than problems from language theory, we discuss unsolvability of Post’s correspondence problem, the validity problem of first order logic, and of Hilbert’s tenth problem. Chapter 10 is a concise account of both space and time complexity. The main techniques of log space reduction, polynomial time reduction, and simulations in- cluding Savitch’s theorem and tape compression are explained with motivation and rigour. The important notions of N LS-completeness and NP-completeness are ex- plained at length. After proving the Cook–Levin theorem, the modern approach of using gadgets in problem reduction and the three versions of optimization problems are discussed with examples.
  • 11. Preface vii Special Features There are places where the approach has become nonconventional. For example, transducers are in additional problems, nondeterministic automata read only sym- bols not strings, pushdown automata require both final states and an empty stack for acceptance, normal forms are not used for proving the pumping lemma for context- free languages, Turing machines use tapes extended both ways having an accepting state and a rejecting state, and acceptance problem is dealt with before talking about halting problem. Some of the other features are the following: • All bold-faced phrases are defined in the context; these are our definitions. • Each definition is preceded by a motivating dialogue and succeeded by one or more examples. • Proofs always discuss a plan of attack and then proceed in a straightforward and rigorous manner. • Exercises are spread throughout the text forcing lateral thinking. • Problems are included at the end of each section for reinforcing the notions learnt so far. • Each chapter ends with a summary, bibliographical remarks, and additional problems. These problems are the unusual and hard ones; they require the guid- ance of a teacher or browsing through the cited references. • An unnumbered chapter titled Answers/Hints to Selected Problems contains solutions to more than 500 out of more than 2,000 problems. • It promotes interactive learning building the confidence of the student. • It emphasizes the intuitive aspects and theirrealization with rigorous formalization. Target Audience This is a text book primarily meant for a semester course at the Juniors level. In IIT Madras, such a course is offered to undergraduate Engineering students at their fifth semester (third year after schooling). The course is also credited by masters students from various disciplines. Naturally, the additional problems are tried by such masters students and sometimes by unusually bright undergraduates. The book (in notes form) has also been used for a course on Formal Language Theory offered to Masters and research scholars in mathematics. Notes to the Instructor The book contains a bit more than that can be worked out (not just covered) in a semester. The primary reason is: these topics form a prerequisite for undertaking any meaningful research in computer science. The secondary reason is the variety of syllabi followed in universities across the globe. Thus, courses on automata theory, formal languages, computability, and complexity can be offered, giving stress on suitable topics and mentioning others. I have taught different courses at different levels from it sticking to the core topics. The core topics include a quick review of the mathematical preliminaries (Chap. 1), various mechanisms for regular languages (Chap. 2), closure proper- ties and pumping lemma for regular languages (Sects. 4.2 and 4.3), context-free
  • 12. viii Preface languages (Sects. 5.2–5.4), pushdown automata, pumping lemma and closure prop- erties of context-free languages (Sects. 6.2, 6.4, and 6.5), computably enumerable languages (Chap. 7), a noncomputably enumerable language (Chap. 8), algorithmic solvability (Sects. 9.2–9.4), and computational complexity (Chap. 10). Depending on the stress on certain aspects, some of the proofs from these core topics can be omitted and other topics can be added. Chennai, Arindama Singh January 2009
  • 13. Acknowledgements I cheerfully thank My students for expressing their wish to see my notes in the book form, IIT Madras for keeping me off from teaching for a semester, for putting a deadline for early publication, and for partial financial support under the Golden Jubilee Book Writing Scheme, Prof. David Gries and Prof. Fred B. Schneider, series editors for Springer texts in computer science, Mr. Wayne Wheeler and his editorial team for painstakingly going through the manuscript and suggesting improvements in presentation, Prof. Chitta Baral of Arizona State University for suggesting to include the chapter on mathematical preliminaries, Prof. Robert I. Soare of the University of Chicago, Dr. Abhaya Nayak of Maquarie University, and Dr. Sounaka Mishra of IIT Madras for suggesting improvements, My family, including my father Bansidhar Singh, mother Ragalata Singh, wife Archana, son Anindya Ambuj, daughter Ananya Asmita, for tolerating my obses- sion with the book, and My friends Mr. Biswa R Patnaik (in Canada) and Mr. Sankarsan Mohanty (in Orissa) for their ever inspiring words. Arindama Singh ix
  • 14. Contents 1 Mathematical Preliminaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.2 Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.3 Relations and Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.4 Functions and Counting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 1.5 Proof Techniques . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 1.6 Summary and Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 2 Regular Languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 2.2 Language Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 2.3 Regular Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 2.4 Regular Grammars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 2.5 Deterministic Finite Automata. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 2.6 Nondeterministic Finite Automata . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 2.7 Summary and Additional Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 3 Equivalences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 3.2 NFA to DFA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 3.3 Finite Automata and Regular Grammars . . . . . . . . . . . . . . . . . . . . . . . 76 3.4 Regular Expression to NFA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 3.5 NFA to Regular Expression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 3.6 Summary and Additional Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 4 Structure of Regular Languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 4.2 Closure Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 4.3 Nonregular Languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 4.4 Myhill–Nerode Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 4.5 State Minimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 4.6 Summary and Additional Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 xi
  • 15. xii Contents 5 Context-free Languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 5.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 5.2 Context-free Grammars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 5.3 Parse Trees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132 5.4 Ambiguity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137 5.5 Eliminating Ugly Productions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141 5.6 Normal Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 5.7 Summary and Additional Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . 155 6 Structure of CFLs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 6.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 6.2 Pushdown Automata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 6.3 CFG and PDA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 6.4 Pumping Lemma . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 6.5 Closure Properties of CFLs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182 6.6 Deterministic Pushdown Automata . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186 6.7 Summary and Additional Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 7 Computably Enumerable Languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201 7.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201 7.2 Unrestricted Grammars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201 7.3 Turing Machines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205 7.4 Acceptance and Rejection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210 7.5 Using Old Machines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217 7.6 Multitape TMs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228 7.7 Nondeterministic TMs and Grammars . . . . . . . . . . . . . . . . . . . . . . . . . 233 7.8 Summary and Additional Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . 240 8 A Noncomputably Enumerable Language . . . . . . . . . . . . . . . . . . . . . . . . . 245 8.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245 8.2 Turing Machines as Computers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246 8.3 TMs as Language Deciders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251 8.4 How Many Machines? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257 8.5 Acceptance Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261 8.6 Chomsky Hierarchy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267 8.7 Summary and Additional Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . 272 9 Algorithmic Solvability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281 9.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281 9.2 Problem Reduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282 9.3 Rice’s Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287 9.4 About Finite Automata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293 9.5 About PDA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295 9.6 Post’s Correspondence Problem. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301 9.7 About Logical Theories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307 9.8 Other Interesting Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314 9.9 Summary and Additional Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . 316
  • 16. Contents xiii 10 Computational Complexity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327 10.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327 10.2 Rate of Growth of Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328 10.3 Complexity Classes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333 10.4 Space Complexity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338 10.5 Time Complexity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342 10.6 The Class NP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348 10.7 NP-Completeness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352 10.8 Some NP-Complete Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358 10.9 Dealing with NP-Complete Problems . . . . . . . . . . . . . . . . . . . . . . . . . . 369 10.10 Summary and Additional Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . 372 Answers and Hints to Selected Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415
  • 17. 1 Mathematical Preliminaries 1.1 Introduction An African explorer conversant with the language of the Hottentot tribe asks a native, “How many children do you have?” The tribesman answers, “Many.” The determined explorer persists on. He shows his index finger, meaning “one?” Promptly comes the answer, “no.” He adds his middle finger, meaning “two”; the answer is “no”; “three?,” “no”; “four,” “no.” Now all the five fingers on the explorer’s right hand are straight. Answer comes, “yes.” The puzzled explorer experiments with another tribesman. Over the next week, he discovers that they have only three kinds of numbers, one, two, and many. It is an old story, but perhaps not without morals. The Hottentot tribesman does not have a way of naming the numbers more than two. How does he manage his cattle? Our mathematical tradition has gone so far and so deep that it is indeed difficult to imagine living without it. In this small chapter, we will discuss a fragment of this tradition so that the rituals of learning the theory of computation can be conducted relatively easily. In the process, we will fix our notation. 1.2 Sets A set is a collection of objects, called its members or elements. When writing a set by showing its elements, we write it with two closing curly brackets. The curly brackets serve two purposes: one, it shows the elements inside, and two, it says that the whole thing put together is another object on its own right. Sometimes, we become tired of writing out all the elements, and we put three dots. For example, {pen, pencil, knife, scissors, paper, chalk, duster, paper weight, . . .} is the set of names of educational stationery. It is the extensional way of representing a set. But what about the expression, “the set of names of educational stationery?” It is a set, nonetheless, and the same set as above. We thus agree to represent a A. Singh, Elements of Computation Theory, Texts in Computer Science, 1 c Springer-Verlag London Limited 2009
  • 18. 2 1 Mathematical Preliminaries set by specifying a property that may be satisfied by each of its elements. It is the intensional way of representing a set. (Note the spelling of “intensional.”) If A is a set and a is an element in A, we write it as a ∈ A. The fact that a is not an element of A is written as a ∈ A. When specifying a set by a property, we write it as {x : P(x)}, meaning that this set has all and only those x as elements which satisfy a certain property P(·). Two sets A, B are said to be the same set, written A = B, if each element of A is in B and each element of B is in A. In that case, their defining properties must be logically equiv- alent. For example, the set {2, 4, 6, 8} can be written as {x : x = 2 or x = 4 or x = 6 or x = 8}. Also, {2, 4, 6, 8} = {x : 2 divides x and x is an integer with 0 x 10}. Further, {2, 4, 6, 8} = {4, 8, 6, 2}; the order of the elements when written down explicitly, does not matter, and it is assumed that there are no repetitions of elements in a set. Two sets A, B are equal, written A = B, whenever they have precisely the same elements. We say that A is a subset of a set B, written A ⊆ B, whenever each element of A is in B. Similarly, we say that A is a proper subset of B, written A B, whenever A ⊆ B but A B. Thus, A = B iff A ⊆ B and B ⊆ A. We abbreviate the phrase “if and only if” to “iff.” A mathematical discourse fixes a big set, called the universal set often denoted by U. All other sets considered are subsets of this big set in that particular context. As a convention, this big set is never mentioned, and if strict formal justification is required, then this is brought into picture. Let A, B be sets and let U be the universal set (in this context, of course). The union of A, B is written as A ∪ B = {x : x ∈ A or x ∈ B}. The intersection of A, B is A ∩ B = {x : x ∈ A and x ∈ B}. The difference of A, B is A − B = {x : x ∈ A but x ∈ B}. The complement of A is A = U − A = {x : x ∈ A}. We define the empty set ∅ as a set having no elements; ∅ = {x : x x} = { }. For any set A, ∅ = A − A. We find that A ∪ ∅ = A and A ∩ U = A. Moreover, ∅ is unique, whatever be the universal set. When two sets A, B have no common elements, we say that they are disjoint and write it as A ∩ B = ∅. For example, with the universal set as the set of all natural numbers N = {0, 1, 2, . . .}, A as the set of all prime numbers, and B as the set of all composite numbers, we see that A ∩ B = ∅, A ∪ B = N − {0, 1} = {0, 1}. The power set of A, denoted by 2A , is the set of all subsets of A. An ordered pair of two objects a, b is denoted by (a, b), which can also be written as a set. For example, we may define (a, b) = {{a}, {a, b}}. We see that the ordered pair satisfies the following property: (a, b) = (c, d) iff a = c and b = d. In fact, it is enough for us to remember this property of the ordered pairs. The Carte- sian product of the sets A and B is A × B = {(x, y) : x ∈ A and y ∈ B}. The operations of union, intersection, and the (Cartesian) product can be extended further. Suppose A = {Ai : i ∈ I} is a collection of sets Ai , where I is some set, called an index set here. Then, we define
  • 19. 1.3 Relations and Graphs 3 ∪A = ∪i∈I Ai = {x : x is in some Ai }. ∩A = ∩i∈I Ai = {x : x is in each Ai }. For the product, we first define an n-tuple of objects by (a1, a2, . . . , an) = ((a1, a2, . . . , an−1), an), when n 2. Finally, we write A1 × A2 × · · · × An = {(x1, x2, . . . , xn) : each xi ∈ Ai , for i = 1, . . . , n}. When each Ai = A, we write this n-product as An . Similarly, arbitrary Cartesian product can be defined though we will use only a finite product such as this. Be- cause of the above property of ordered pairs, and thus of n-tuples, the kth coordinate becomes meaningful. The kth coordinate of the n-tuple (x1, x2, . . . , xn) is xk. Clearly, A × ∅ = ∅ × A = ∅. In addition, we have the following identities: Double Complement: A = A. De Morgan : A ∪ B = A ∩ B, A ∩ B = A ∪ B. Commutativity: A ∪ B = B ∪ A, A ∩ B = B ∩ A. Associativity : A ∪ (B ∪ C) = (A ∪ B) ∪ C, A ∩ (B ∩ C) = (A ∩ B) ∩ C. Distributivity : A ∪(B ∩C) = (A ∪ B)∩(A ∪C), A ∩(B ∪C) = (A ∩ B)∪(A ∩C), A × (B ∪ C) = (A × B) ∪ (A × C), A × (B ∩ C) = (A × B) ∩ (A × C), A × (B − C) = (A × B) − (A × C). 1.3 Relations and Graphs We use the relations in an extensional sense. The binary relation of “is a son of” between human beings is thus captured by the set of all ordered pairs of human beings, where the first coordinate of each ordered pair is a son of the second coordi- nate. A binary relation from a set A to a set B is a subset of A × B. If R is such a relation, a typical element in R is an ordered pair (a, b), where a ∈ A and b ∈ B are suitable elements. The fact that a and b are related by R is written as (a, b) ∈ R; we also write it as R(a, b) or as aRb. Any relation R ⊆ A × A is called a binary relation on the set A. Similarly, an n-ary relation on a set A is some subset of An . For example, take P as a line and a, b, c as points on P. Write B(a, b, c) for “b is between a and c.” Then B is a ternary relation, that is, B ⊆ P3 , and B(a, b, c) means the same thing as (a, b, c) ∈ B. Unary relations on a set A are simply the subsets of A. Binary relations on finite sets can conveniently be represented as diagrams. In such a diagram, the elements of the set A are represented as small circles (points, nodes, or vertices) on the plane and each ordered pair (a, b) ∈ R of elements
  • 20. 4 1 Mathematical Preliminaries a, b ∈ A is represented as an arrow from a to b. We write inside each circle its name. The diagrams are now called digraphs or directed graphs. Example 1.1. The digraph for the relation R = {(a, a), (a, b), (a, d), (b, c), (b, d), (c, d), (d, d)} on the set A = {a, b, c, d} is given in Fig. 1.1. Fig. 1.1. Digraph for R in Example 1.1. a b c d Sometimes we need to give names to the edges (arrows) in a digraph as we give names to roads joining various places in a city. The resulting digraph is called a labeled digraph. Labeled digraphs are objects having three components: a set of ver- tices V , a set of edges E, and an incidence relation I ⊆ E ×V ×V, which specifies which edge is incident from which vertex to which vertex. Example 1.2. Figure 1.2 depicts the labeled digraph (V, E, I), where the vertex set V = {a, b, c, d}, the edge set E = {e1, e2, e3, e4, e5, e6, e7}, and the incidence rela- tion I = {(e1, a, a), (e2, a, b), (e3, a, d), (e4, b, c), (e5, b, d), (e6, c, d), (e7, d, d)}. Fig. 1.2. Labeled digraph for Example 1.2. a b c d e1 e2 e3 e4 e5 e6 e7 Sometimes we do not need to have the arrows in a digraph; just the undirected edges suffice. In that case, the digraph is called an undirected graph or just a graph. Usually, we redefine this new concept. We say that a graph is an object having a set of vertices and a set of edges as components, where each edge is a two-elements set (instead of an ordered pair) of vertices. Example 1.3. The graph in Fig. 1.3 represents the graph G = (V, E), where V = {a, b, c, d} and E = {{a, a}, {a, b}, {a, d}, {b, c}, {b, d}, {c, d}, {d, d}}.
  • 21. 1.3 Relations and Graphs 5 Fig. 1.3. Graph for Example 1.3. a b c d Two vertices in a graph are called adjacent if there is an edge between them. A path in a graph is a sequence of vertices v1, v2, . . . , vn, such that each vi is ad- jacent to vi+1. For example, in Fig. 1.3, the sequence a, a, b, c, d is a path, and so are a, b, d and a, d, c. We say that the path v1, v2, . . . , vn connects the vertices v1 and vn. Moreover, the starting point of the path v1, v2, . . . , vn is v1 and its end point is vn. Similarly, directed paths are defined in digraphs. A graph is called connected if each vertex is connected to each other by some path (not necessarily the same path). For example, the graph of Fig. 1.3 is a connected graph. If you delete the edges {a, d}, {b, c}, {b, d}, then the resulting graph is not connected. Similarly, if you remove the edges {a, b}, {a, d}, then the resulting graph is not connected either. A path v1, v2, . . . , vn, v1 is called a cycle when n 2 and no vertex, other than the starting point and the end point, is repeated. A connected cycleless graph is called a tree. By giving directions to the edges in a tree, we obtain a directed tree. In a directed tree, if there is exactly one vertex towards which no arrow comes but all edges incident with it are directed outward, the vertex is called the root of the tree. Similarly, any vertex in a directed tree from which no edge is directed outward is called a leaf. It is easy to see that there can be only one edge incident with a leaf and that edge is directed toward the leaf. Because, otherwise, there will be a cycle containing the leaf! A tree having a root is called a rooted tree. Example 1.4. The graph on left side in Fig. 1.4 is a rooted tree with c as its root. It is redrawn on the right in a different way. a b c d e f a b e c d f Fig. 1.4. Trees for Example 1.4. The trees in Fig. 1.4 are redrawn in Fig. 1.5 omitting the directions. Since the direction of edges are always from the root toward any vertex, we simply omit the
  • 22. 6 1 Mathematical Preliminaries directions. We will use the word “tree” for rooted trees and draw them without di- rections. Sometimes, we do not put the small circles around the vertices. The tree on left side in Fig. 1.5 uses this convention of drawing the trees in Fig. 1.4. It is further abbreviated in the right side tree of the same figure. In Fig. 1.5, all children of a vertex are placed below it and are joined to the parent vertex by an undirected edge. We say that the root c has depth 0; the children of the root are the vertices of depth 1 in the tree; the depth 2 vertices are the vertices that have an edge from the vertices of depth 1; these are children of the children of the root, and so on. In a tree, the depth is well defined; it shows the distance of a vertex from the root. The depth of a tree is also called its height, and trees in computer science grow downward! c a b e d f a b e c d f Fig. 1.5. Trees for Example 1.4 redrawn. Leaves of the tree in Fig. 1.5 are the vertices a, b, d, and f. The nonleaf vertices are called the branch nodes (also, branch points or branch vertices). With this short diversion on representing relations as graphs, we turn towards various kinds of properties that a relation might satisfy. Suppose R is a binary relation on a set A. The most common properties associated with R are Reflexivity : for each x ∈ A, xRx. Symmetry : for each pair of elements x, y ∈ A, if xRy, then yRx. Antisymmetry : for each pair of elements x, y ∈ A, if xRy and yRx, then x = y. Transitivity : for each triple of elements x, y, z ∈ A, if xRy and yRz, then xRz. A binary relation can be both symmetric and antisymmetric, or even neither. For example, on the set A = {a, b}, the relation R = {(a, a), (b, b)} is reflex- ive, symmetric, transitive, and antisymmetric. On the other hand, the relation S = {(a, b), (a, c), (c, a)} on A is neither reflexive, nor symmetric, nor antisymmetric, nor transitive. Given a binary relation R on a set A, we can extend it by including some more ordered pairs of elements of A so that the resulting relation is both reflexive and transitive. Such a minimal extension is called the reflexive and transitive closure of R. Example 1.5. What is the reflexive and transitive closure of R = {(a, b), (b, c), (c, b), (c, d)} on the set A = {a, b, c, d}?
  • 23. 1.3 Relations and Graphs 7 Solution. Include the pairs (a, a), (b, b), (c, c), (d, d) to make it reflexive. You have R1 = {(a, a), (a, b), (b, b), (b, c), (c, b), (c, c), (c, d), (d, d)}. Since (a, b), (b, c) ∈ R1, include (a, c). Proceeding similarly, You arrive at R2 = {(a, a), (a, b), (a, c), (b, b), (b, c), (b, d), (c, b), (c, c), (c, d), (d, d)}. Since (a, b), (b, d) ∈ R2, include (a, d) to obtain R3 = {(a, a), (a, b), (a, c), (a, d), (b, b), (b, c), (b, d), (c, b), (c, c), (c, d), (d, d)}. You see that R3 is already reflexive and transitive; there is nothing more required to be included. That is, the reflexive and transitive closure of R is R3. In Example 1.5, interpret (x, y) ∈ R to mean there is a communication link from city x to city y, possibly, a one-way communication link. Then the reflexive and transitive closure of R describes how messages can be transmitted from one city to another either directly or via as many intermediate cities as possible. On the set of human beings, if parenthood is the relation R, then its reflexive and transitive closure gives the ancestor–descendant relationship, allowing one to be his/her own ancestor. The inverse of a binary relation R from A to B, denoted by R−1 , is a relation from B to A such that for each x ∈ A, y ∈ B, x R−1 y iff yRx. The inverse is also well defined when R is a binary relation on a set A. For example, on the set of human beings, the inverse of the relation of “teacher of” is the relation of “student of.” What is the inverse of “father of?” Suppose R is a binary relation on a set A. We say that R is a partial order on A if it is reflexive, antisymmetric, and transitive. The relation of ≤ on the set of all integers is a partial order. For another example, let S be a collection of sets. Define the relation R on S by “for each pair of sets A, B ∈ S, ARB iff A ⊆ B.” Clearly, R is a partial order on S. A relation R is called an equivalence relation on A if it is reflexive, symmetric, and transitive. The equality relation is obviously an equivalence relation, but there can be others. For example, in your university, two students are related by R if they are living in the same dormitory. It is easy to see that R is an equivalence relation. You observe that the students are now divided into as many classes as the number of dormitories. Intuitively, the elements related by an equivalence relation share a common prop- erty. The property divides the underlying set into many subsets, where elements of any of these typical subsets are related to each other. Moreover, elements of one sub- set are never related to elements of another subset. Let R be an equivalence relation on a set A. For each x ∈ A, we define the equivalence class of x, denoted as [x], by [x] = {y ∈ A : x Ry}. Besides x, each element y ∈ [x] is a representative of the equivalence class [x]. We define a partition of A as any collection A of disjoint nonempty subsets of A whose union is A. The equivalence classes form the set, so to speak. We will see that its converse is also true.
  • 24. 8 1 Mathematical Preliminaries Theorem 1.1. Let R be a binary relation on a set A. If R is an equivalence relation, then the equivalence classes of R form a partition of A. Conversely, if A is a partition of A, then there is an equivalence relation R such that the elements of A are precisely the equivalence classes of R. Proof. Suppose R is an equivalence relation on a set A. Let A = {[x] : x ∈ A}, the collection of all equivalence classes of elements of A. To see that A is a partition of A, we must show two things. (a) Each element of A is in some equivalence class. (b) Any two distinct equivalence classes are disjoint. The condition (a) is obvious as each x ∈ [x]. For (b), let [x] and [y] be distinct equivalence classes. Suppose, on the contrary, that there is z ∈ [x] ∩ [y]. Now, x Rz and yRz. By the symmetry and transitivity of R, we find that x Ry. In that case, for each w ∈ [x], we have wRy as x Rw and yRx implies that yRw. This gives w ∈ [y]. That is, [x] ⊆ [y]. For each v ∈ [y], we have similarly vRx. This gives v ∈ [x]. That is, [y] ⊆ [x]. We arrive at [x] = [y], contradicting the fact that [x] and [y] are distinct. Conversely, suppose A is a partition of A. Define the binary relation R on A by For each pair of elements x, y ∈ A, x Ry iff both x and y are elements of the same subset B in A. That means if a, b ∈ B1 ∈ A, then aRb, but if a ∈ B1 ∈ A and c ∈ B2 ∈ A, then a and c are not related by R (assuming that B1 B2). Clearly, R is an equivalence relation. To complete the proof, we show that (i) Each equivalence class of R is an element of A. (ii) Each element of A is an equivalence class of R. For (i), let [x] be an equivalence class of R for some x ∈ A. This x is in some B ∈ A. Now y ∈ [x] iff x Ry iff y ∈ B, by the very definition of R. That is, [x] = B. Similarly for (ii), let B ∈ A. Take x ∈ B. Now y ∈ B iff yRx iff y ∈ [x]. This shows that B = [x]. 1.4 Functions and Counting Intensionally, a function is a map that associates an element of a set to another, possi- bly in a different set. For example, the square map associates a number to its square. If the underlying sets are {1, 2, 3, 4, 5} and {1, 2, . . . , 50}, then the square map as- sociates 1 to 1, 2 to 4, 3 to 9, 4 to 16, and 5 to 25. Extensionally, we would say that the graph of the map (not the same graph of the last section, but the graph as you have plotted on a graph sheet in your school days) is composed of the points (1, 1), (2, 4), (3, 9), (4, 16), and (5, 25). We take up the extensional meaning and de- fine a function as a special kind of a relation.
  • 25. 1.4 Functions and Counting 9 Let A, B be two sets. A partial function f from the set A to the set B is a relation from A to B satisfying for each x ∈ A, if x f y and x f z, then y = z. This conforms to our intensional idea of a map, as no element x can be associated with different elements by f. It is a partial function, as it is not required that each element in A has to be taken to some element of B by f. We use the more suggestive notation for a partial function by writing f : A → B. When x f y, we write y = f (x). The set A is called the domain of f and the set B is called the co-domain of f. A partial function f : A → B is called a total function if for each x ∈ A, there is some y ∈ B such that y = f (x), that is, when f takes each element of A to some (hence a unique, corresponding to that element of A) element of B. Note that it does not say that all elements of A should be mapped to the same element of B. Following tradition, we use the word function for a total function and use the adjective “partial” for a partial function. To emphasize, a partial function is not necessarily strictly partial. The range of a partial or a total function is the subset of B, which are attained by f , that is, the set {y ∈ B : y = f (x) for some x ∈ A}. If D ⊆ A, we write the range of f as f (D) = { f (x) ∈ B : x ∈ D}. Partial functions can be composed by following the internal arrows in succession, as it is said. For example, if f : A → B, g : B → C are two maps, and a ∈ A, then we can get f (a) in B, and then go to g( f (a)) in C by following the maps. This can be done provided f (a) is defined, and also if g( f (a)) is defined. When both f, g are total functions, this is obviously possible. The composition map is written as g ◦ f. Notice the reverse notation; it helps in evaluation, that is, when it is defined for an element a ∈ A, we have (g ◦ f )(a) = g( f (a)). The composition map g ◦ f : A → C. The inverse of a partial function f : A → B is well defined; it is the relation f −1 defined from B to A. But f −1 is not necessarily a partial function. For example, the square map on {1, −1} is a partial function (in fact, total) whose inverse is the relation {(1, 1), (1, −1)}. This inverse, the square-root relation is not a partial function as 1 is taken to two distinct elements 1 and −1. This happens because the square map is not one to one, it is many to one. A partial function f : A → B is called one–one if for each x, y ∈ A, if x y, then f (x) f (y). Equivalently, for each x, y ∈ A, if f (x) = f (y), then x = y. It is easy to see that the inverse of a one–one partial function is again a one–one partial function. But inverse of a total function (even if one–one) need not be a total function. Because, there might be elements in its co-domain that are not attained by the map. We call a partial function f : A → B an onto partial function (or say that f is a partial function from A onto B) if for each y ∈ B, there exists an x ∈ A such that y = f (x). Equivalently, for an onto function, the range of f coincides with the co-domain of f. It is easy to see that a one–one total function from A onto B has an inverse, which is also a one–one total function from B onto A. A one–one total function is also
  • 26. 10 1 Mathematical Preliminaries called an injection and an onto total function is called a surjection. A bijection is a one–one onto total function. Two sets A and B are said to be in one-to-one correspondence if there is a bijection from one to the other. Suppose f : A → B, C ⊆ A, and D ⊆ B. The image of C under f is the set { f (x) : x ∈ C}, and is denote by f (C). Similarly, the inverse image of D under f is the set {x : f (x) ∈ D} and is denoted by f −1 (D). The notation f −1 (D) should not mislead you to think of f −1 as a partial function; as you have seen, it need not be so. f −1 is a total function only when f is a bijection. In such a case, f ◦ f −1 is the identity map on B and f −1 ◦ f is the identity map on A. The identity map takes each element to itself. An arbitrary Cartesian product of sets can be defined using functions. An n-tuple of elements from a set A can be given as a function f : {1, 2, . . ., n} → A. Here, we simply rewrite the kth coordinate in the n-tuple as f (k). We use this observation for an extension of the product. Suppose A = {Ai : i ∈ I} is a collection of sets Ai , where I is an index set. Then the product is defined as ×A = ×i∈I Ai = the set of all functions f : I → ∪A with f (i) ∈ Ai . Recall that the Hottentot tribesman knew the meaning of one-to-one correspon- dence; he could say that he had as many children as the fingers on the right hand of the African explorer. The tribesman did not know the name of any number beyond two. He could count but could not name the number he has counted. Probably, he had a bag full of pebbles as many as the sheep he owned. This is how he used to keep track of the sheep in his possession. The idea behind counting the elements of a set is the same as that of the tribesman. We say that two sets A and B have the same cardinality when there is a bijection between them. We write cardinality of a set A as |A|. Cardinality of a set intuitively captures the idea of the number of elements in a set. Notice that we have not defined what |A| is; we have only defined |A| = |B|. To make the comparison of cardinalities easier, we say |A| ≤ |B| if there is an injection from A to B (a one–one total function from A to B). We say that |A| ≥ |B| if |B| ≤ |A|. Cantor–Schröder–Bernstein Theorem says that if |A| ≤ |B| and |B| ≤ |A|, then |A| = |B|. (A proof is outlined in Problem 1.29.) Further, we write |A| |B| when |A| ≤ |B| but |A| |B|; similarly, |A| |B| when |A| ≥ |B| but |A| |B|. Since the empty set ∅ has no elements, we define 0 = |∅|. We go a bit further and define 1 = |{0}|. And then define inductively n + 1 = |{0, 1, . . . , n}|. These are our natural numbers, elements of the set N = {0, 1, 2, . . .}. Then the operations of + and × are defined on N in the usual way. Notice that + is a function that maps a pair of natural numbers to a natural number, and so is ×. Of course, we simplify notation by writing mn for m × n. Once the natural numbers are defined, we define the integers by extending it to Z = N ∪ {−1, −2, . . .} = N ∪ {−n : n ∈ N}, with the convention that −0 = 0. Notice that −n is just a symbol, where we put a minus sign preceding a natural number. The set of positive integers is defined as Z+ = N − {0} = Z − {−n : n ∈ N}. Then the operations + and × are extended to Z in the usual way, n + (−n) = 0, etc. This extension allows us to solve simple equations such as x + 5 = 2 in Z.
  • 27. 1.4 Functions and Counting 11 However, equations such as 5x = 2 cannot be solved in Z. We thus extend Z by including symbols of the form m/n. We arrive at the set of rational numbers Q = {p/q : p ∈ Z, q ∈ Z+}, with the usual conventions like (p/q) × q = p and p/q = r/s when ps = rq, etc. We then see that each rational number can be represented as a decimal number like m.n1n2n3 · · · with or without the minus sign, where each ni is one of the digits 0, 1, . . . , 9 and m ∈ N. Such decimals representing rational numbers satisfy a nice property: Beyond some finite number of digits after the decimal point, a finite sequence of digits keep recurring. Further, we see that these recurring decimals uniquely represent rational numbers with one exception: a decimal number with recurring 0’s can also be written as an- other decimal with recurring 9’s. We agree to use the latter and discard the former if uniqueness is at vogue. For example, the decimal 0.5 is written as 0.499999 · · · . This guarantees a unique decimal representation of each number in Q. Also, this conven- tion allows us to consider only the recurring infinite decimals instead of bothering about terminating decimals. We then extend our numbers to the real numbers. The set of real numbers, R, is the set of all (infinite) decimals. The nonrecurring decimals are called the irrational numbers, they form the set R−Q. This extension now allows us talking about square roots of numbers. For example, √ 2 ∈ R, but √ 2 ∈ Q. However, we find that it is not enough for solving polynomial equations, for example, there is no real number x satisfying the equation x2 + 1 = 0. For solving polynomial equations, we would need the complex numbers. We de- fine the set of complex numbers as C = {x + ıy : x, y ∈ R}, where ı is taken as √ −1. Notice that ı is again a symbol which is used as √ −1. The operations of +, ×, taking roots, etc. are extended in the usual way to C. It can be shown that our quest for solving polynomial equations stop with C. The Fundamental Theorem of Alge- bra states that each polynomial of degree n with complex coefficients has exactly n complex roots. Besides, there are complex numbers that are not roots of any polynomial equation. Moreover, we require to distinguish between surds like √ 2 and numbers like π. For this purpose, we restrict our polynomials to have rational coefficients. We define an algebraic number as a complex number, which is a solution of a polynomial equation, where the polynomials have rational coefficients. Other complex numbers are called transcendental numbers. In fact, there are more transcendental numbers than the algebraic numbers (Problem 1.28), though we know a very few of them. Further, there is a natural partial order on N, the ≤ relation. It so happens that this relation can be extended to Z, Q, and R. However, it stops there; it cannot be extended to C. This does not mean that there cannot be any partial order on C. For example, define ≤ on C by a + ıb ≤ c + ıd iff a c, or (a = c and b ≤ c), taking the ≤ on R as the basis. You can verify that this defines a partial order on C. But this is not an extension of the ≤ relation on R. Because our definition of the relation says that 0 ı, we should have 0 × 0 ı × ı = −1, which is not true. Observe that by this process of extension, we have constructed some infinite sets, the sets whose cardinalities cannot be written as natural numbers. Infinite sets can be
  • 28. 12 1 Mathematical Preliminaries defined without using numbers. We say that a set is infinite or has infinite cardinality if it has the same cardinality as one of its proper subsets. And a finite set is a set which is not infinite. Naturally, a finite set has greater cardinality than any of its proper subsets. For example, N is an infinite set as the function f : N → 2N defined by f (n) = 2n is a bijection, where 2N denotes the set of all even natural numbers. It can further be shown that a set is finite iff either it is ∅ or it is in one-to-one correspondence with a set of the form {0, 1, . . ., n} for some natural number n. We take it as our definition of a finite set. Using this, we would define an infinite set as one which is not finite. Cardinalities of finite sets are now well defined : |∅| = 0, and a set that is in one-to-one correspondence with {0, 1, . . ., n} has cardinality n + 1. Can we similarly define the cardinalities of infinite sets? Well, let us denote the cardinality of N as ℵ0; read it as aleph-null. Can we say that all infinite sets have cardinality ℵ0? Again, let us increase our vocabulary. We call a set denumerable (also called enumerable) if it is in one-to-one correspondence with N, that is, having cardinality as ℵ0. The one-to-one correspondence with N gives an enumeration of the set: if f : N → A is the bijection, then the elements of the denumerable set A can be written as f (0), f (1), f (2), . . .. The following statement should then be obvious. Theorem 1.2. Each infinite subset of a denumerable set is denumerable. Proof. Let A be an infinite subset of a denumerable set B. You then have a bijection f : N → B. That is, elements of B are in the list: f (0), f (1), f (2), . . .. All elements of A appear in this list exactly once. Define a function g : N → A by induction: Take g(0) as the first element in the list, which is also in A. Take g(k + 1) as the first element in the list occurring after g(k), which is in A. This g is a bijection since A is infinite. Further, we say a set to be countable if it is either finite or denumerable. Since each number n ℵ0, (Why?) it follows from Theorem 1.2 that a set A is countable iff |A| ≤ ℵ0 iff A is in one-to-one correspondence with a subset of N iff there is a one–one function from A to N iff A is a subset of a countable set. Moreover, in all these iff statements, N can be replaced by any other countable set. Further, A is denumerable iff A is infinite and countable. A set that is not countable is called uncountable. Theorem 1.3. Z and Q are denumerable; thus countable. Proof. For the denumerability of Z, we put all even numbers in one-to-one corre- spondence with all natural numbers, and then put all odd natural numbers in one-to- one correspondence with the negative integers. To put it formally, observe that each natural number is in one of the forms 2n or 2n + 1. Define a function f : N → Z by f (2n) = n and f (2n + 1) = −(n + 1). To visualize, f (0) = 0, f (1) = −1, f (2) = 1, f (3) = −2, . . . . It is easy to see that f is a bijection. Therefore, Z is denumerable.
  • 29. 1.4 Functions and Counting 13 For the denumerability of Q, let QP denote the set of all symbols of the form p/q, where p, q ∈ Z+. Also, denote the set of positive rational numbers by Q+. When we look at these symbols as rational numbers, we find many repetitions. For exam- ple, corresponding to the single element 1 in Q+, there are infinitely many elements 1/1, 2/2, 3/3, . . . in QP. We construct a one–one function from the set QP to Z+. The elements of QP can be written in a two-dimensional array as shown below. 1 1 → 1 2 1 3 → 1 4 1 5 → 1 6 · · · 2 1 2 2 2 3 2 4 2 5 2 6 · · · ↓ 3 1 3 2 3 3 3 4 3 5 3 6 · · · 4 1 4 2 4 3 4 4 4 5 4 6 · · · ↓ 5 1 5 2 5 3 5 4 5 5 5 6 · · · . . . . . . . . . . . . . . . . . . ... In the first row are written all the numbers of the form 1/m, varying m over Z+ ; in the second row, all the numbers of the form 2/m; etc. Any number p/q ∈ QP is the qth element in the pth row. Thus the array exhausts all numbers in QP. Now, start from 1 1 and follow the arrows to get an enumeration of numbers in the array. This means that the (enumerating) function f : QP → Z+ is defined by f 1 1 = 1, f 1 2 = 2, f 2 1 = 3, f 3 2 = 4, f 2 2 = 5, · · · We see that f is a one–one function. Let QA = QP ∪ {0} ∪ {−p/q : p/q ∈ QP}. This set contains Q in the same way as QP contains Q+. Extend f : QP → Z+ to the function f : QA → Z by taking f (0) = 0 and f (−p/q) = − f (p/q) for p/q ∈ QP. This extended f is also a one–one function. (Show it.) We thus have |QA| ≤ |Z|. Since QA is infinite, it is denumerable. Since Q is an infinite subset of QA, by Theorem 1.2, it is also denumerable. Finally, denumerability implies countability. The method of proof in Theorem 1.3 proves that Z+ ×Z+ is denumerable. All you have to do is keep the ordered pair (m, n) in place of m/n in the array. For another alternative proof of this fact, you can search for a one–one map from Z+ × Z+ to Z+. One such is defined by f (m, n) = 2m 3n . Just for curiosity, try to prove that the function g : Z+ × Z+ → Z+ given by g(m, n) = 2m (2n − 1) is a bijection. It is then clear that (Cartesian) product of two countable sets is countable. You can further extend to any finite number of products, as A × B × C is simply (A × B) × C, etc. The proof method also shows that a countable union of countable sets
  • 30. 14 1 Mathematical Preliminaries is countable. Keep on the first row, the first countable set, on the second row, the second countable set, and so on, and then proceed as in the above proof! Similarly, a denumerable union of finite sets is denumerable. However, a denumerable product of denumerable sets is not countable. Check whether you can prove it following the proof of Theorem 1.4 below! Sometimes a result can be too counter intuitive; Theorem 1.3 is one such. Unlike N, if you choose any two numbers from Q, you can always get another number (in fact, infinitely many numbers) between them. But this does not qualify Q to have more elements than N. What about R, the set of real numbers? Theorem 1.4. R is uncountable. Proof. Let J = {x ∈ R : 0 x 1} be the open interval with 0 and 1 as its end points; the end points are not in J. We first show that J is uncountable. We use the famous diagonalization method of Georg Cantor. Suppose, on the contrary, that J is countable. Then, we have a bijection g : N → J. The elements of J can now be listed as g(0), g(1), g(2), . . . . But each number in J is a nonterminating decimal number. Write all these numbers in J as in the following: g(0) = 0.a11 a12 a13 a14 · · · g(1) = 0.a21 a22 a23 a24 · · · g(2) = 0.a31 a32 a33 a34 · · · g(3) = 0.a41 a42 a43 a44 · · · . . . g(n − 1) = 0.an1 an2 an3 an4 · · · ann · · · . . . where each ai j is one of the digits 0, 1, . . . , 9. Using this array of decimals, construct a real number d = 0.d1 d2 d3 d4 · · · , where for each i ∈ Z+, di equals 0 when aii = 9, otherwise, di equals aii + 1. This number d is called the diagonal number. It differs from each number in the above list. For example, d g(0) as d1 a11, and d g(n − 1) as dn ann. But this d is in J, contradicting the fact that the list contains each and every number in J. Therefore, J is uncountable. Since J ⊆ R, uncountability of R is proved. Of course, a stronger fact holds: |J| = |R|. To see this, define a function f : J → R by f (x) = (x − 1/2)/(x − x2 ). Verify that f is a bijection. Recall that we have agreed to write sets by specifying a defining property of the form {x : P(x)}. Existence of an uncountable set such as R dispenses the wrong belief that every set can be expressed by a property and each property can give rise to a set.
  • 31. 1.4 Functions and Counting 15 To see this, suppose you want to express properties in English. (In fact, any other language will do.) Each such property is a finite sequence of symbols from the Ro- man alphabet. For any fixed n, there are clearly a finite number of properties having n occurrences of symbols. Hence, there are only a countable number of properties. But there are uncountable number of sets, for example, sets of the type {r}, where r is a real number. Hence, there are sets that do not correspond to any property. For the converse, see the following example. Example 1.6. Consider the property of “A ∈ A.” This property is perhaps meaning- ful when A is a set. Let S be the set of all sets A such that A ∈ A. Now, is S ∈ S or S ∈ S? Solution. If S ∈ S, then by the very definition of S, we see that S ∈ S. Conversely, if S ∈ S, then S satisfies the defining property of S, and thus S ∈ S. Therefore, S ∈ S iff S ∈ S. The contradiction in Example 1.6 shows that there is no set corresponding to the property that x ∈ x. See Russells’ paradox if you are intrigued. This is the reason why axiomatic set theory restricts the definition of new sets as subsets of old sets. In Example 1.6, if you take the big set as the set of all sets, then S could be a subset of that. In fact, axiomatic set theory does a clever thing so that existence of such a big set can never be justified. Moreover, it prevents constructing a set that may also be a member of itself. For information on axiomatic set theory, you may search for set theories of Zermelo–Fraenkel, or of Gödel–Berneys–Von Neuman, or of Scott–Potter. In the proof of Theorem 1.4, we have constructed a set by changing the diagonal elements of the array of numbers listed as g(0), g(1), . . .. Below we give a very general result that cardinality of any set must be strictly less than the cardinality of its power set, which was first proved by Georg Cantor using (and inventing) the diagonalization method. Theorem 1.5 (Cantor). No function from a set to its power set can be onto. There- fore, |A| |2A |. Proof. Let f : A → 2A be any function. Let x ∈ A. Then f (x) ⊆ A. Thus, x is either in f (x) or it is not. Define a subset B of A by B = {x ∈ A : x ∈ f (x)}. We show that there is no y ∈ A such that B = f (y). On the contrary, suppose there exists a y ∈ A such that B = f (y). Is y ∈ B? If y ∈ B, then as per the definition of B, y ∈ f (y). That is, y ∈ B. On the other hand, if y ∈ B, then y ∈ f (y). Again, because of the definition of B, y ∈ B. We thus arrive at the contradiction that y ∈ B iff y ∈ B. Hence, there is no y ∈ A such that B = f (y). That is, f is not an onto map. Finally, take g : A → 2A defined by g(x) = {x}, for each x ∈ A. This map is one–one. Hence |A| ≤ |2A |. But |A| |2A |, as there is no function from A onto 2A . Therefore, |A| |2A |. Now it is obvious that the power set of a denumerable set is uncountable. You can derive the uncountability of the open interval J defined in the proof of Theorem 1.4
  • 32. 16 1 Mathematical Preliminaries from Cantor’s theorem by using binary decimals instead of the usual decimals. This representation will first prove the fact that |J| = |2N |. In the last paragraph of the proof of Theorem 1.4, we have shown that |J| = |R|. Hence, R = |2N |. Cantor conjectured that each infinite set in between N and R must be in one-to-one corre- spondence with one of N or R, now known as the Continuum Hypothesis. Because of this reason, we denote the cardinality of 2N as ℵ1. Then, the continuum hypothesis asserts that any subset of R is either finite or has cardinality ℵ0 or ℵ1. There are in- teresting results about the continuum hypothesis, but you should be able to look for them on your own. Notice that we have only defined the cardinalities of finite sets. For infinite sets, we know how to compare the cardinalities. Moreover, for notational convenience, we write the cardinality of a denumerable set as ℵ0. Cardinality of the power set of a denumerable set is written as ℵ1. We may thus extend this notation further by taking cardinality of the power set of the power set of a denumerable set as ℵ2, etc., but we do not have the need for it right now. The countability results discussed so far can be summarized as: Z, Q, and the set of algebraic numbers are countable. R, C, R − Q, and the set of transcendental numbers are uncountable. An infinite subset of any denumerable set is denumerable. Subsets of countable sets are countable. Denumerable union of finite sets is denumerable. Denumerable union of denumerable sets is denumerable. Countable union of countable sets is countable. Finite product of denumerable sets is denumerable Finite product of countable sets is countable. Countable product of countable sets need not be countable. Power set of a denumerable set is uncountable. 1.5 Proof Techniques In all the theorems except Theorem 1.1, we have used the technique of proof by contradiction. It says that statement S is considered proved when from the assump- tion that S is not true follows a contradiction. To spell it out explicitly, suppose we have a set of premises Ω. We want to prove that if all the statements in Ω are true, then the statement S must be true. The method of proof by contradiction starts by assuming the falsity of S along with the truth of every statement in Ω. It then de- rives a contradiction. If the premises in Ω are S1, S2, . . . , Sn, then the method can be schematically written as Required: S1, S2, . . . , Sn. Therefore, S. We prove: S1, S2, . . . , Sn and not S. Therefore, a contradiction.
  • 33. 1.5 Proof Techniques 17 Keeping the premises in Ω in the background, the method may be summarized as not S implies a contradiction. Therefore, S. It works because, when not S implies a contradiction, not S must be false. Therefore, S must be true. Conversely, when S is true, not S is false, and then it must imply a contradiction. The method of proof by contradiction appears in many disguises. Calling the above as the first form, the second form of the method is S1 and not S2 implies a contradiction. Therefore, “if S1, then S2.” This is justified due to the simple reason that by asserting the falsity of “if S1, then S2,” we assert the truth of S1 and the falsity of S2. The third form of proof by contradiction is proving the contraposition of a statement. It says that for proving “if S1, then S2,” it is sufficient to prove its con- traposition, which is “if S2 is false, then S1 is false.” In fact, a statement and its contraposition are logically equivalent. Why is it another form of the “proof by con- tradiction?” Suppose you have already proved the contrapositive statement “if S2 is false, then S1 is false”. Then, not S2 and S1 together give the contradiction that S1 is true as well as false. And then the second form above takes care. The principle of proving the contraposition can be summarized as If not S2, then not S1. Therefore, if S1, then S2. The contrapositive of a statement is not the same as its converse. The converse of “if S1 then S2” is “if S2 then S1,” which is equivalent to “if not S1 then not S2”. The fourth form does not bring a contradiction from the assumption that S is false. Rather it derives the truth of S from the falsity of S. Then, it asserts that the proof of S is complete. It may be summarized as not S implies S. Therefore S. Justification of this follows from the first form itself. Assume not S. Since you have proved not S implies S, you also have S. That is, by assuming not S you have got the contradiction: S and not S. The fifth form is the so-called argument by cases. It says that to prove a statement S, pick up any other statement P. Assume P to deduce S. Next, assume that P is false and also deduce S. Then, you have proved S. It may be summarized as P implies S. not P implies S. Therefore, S. Why does it work? Since, you have proved P implies S, its contraposition holds. That is, you have not S implies not P. But you have already proved that not P implies S. Thus, you have proved not S implies S. Now the fourth form takes care. All the while you are using the law of double negation, that is, not not S is equiv- alent to S. Along with it comes the law of excluded middle that one of S or not S must be true. For example, in the argument by cases, you use the fact that one of P
  • 34. 18 1 Mathematical Preliminaries or not P must hold. There have been many objections to the law of excluded middle. One of the most befitting example is by J. B. Bishop. It is as follows. Example 1.7. Show that there are irrational numbers x, y such that xy is rational. Solution. Gelfand–Schneidertheorem states that if α ∈ {0, 1} is an algebraic number and β is an irrational number, then αβ is a transcendental number. √ 2 is algebraic as it is a solution of the equation x2 = 2. We also know that √ 2 is irrational. Therefore, √ 2 √ 2 is transcendental, and hence, irrational. Now, with x = √ 2 √ 2 and y = √ 2, you see that xy = ( √ 2 √ 2 ) √ 2 = √ 2 ( √ 2× √ 2) = ( √ 2)2 = 2, a rational number. Hence we have an affirmative answer to the above question. You may also use the fact that e and ln 2 are irrational but eln 2 = 2, a rational number. However, look at another proof given below that uses the argument by cases. The alternative proof : Either √ 2 √ 2 is rational or irrational. If it is rational, we take x = y = √ 2. If it is irrational, take x = √ 2 √ 2 and y = √ 2. Then, xy = 2, a rational number. With argument by cases, the proof is complete. The alternative proof in the solution of Example 1.7 does not give us a pair x, y of irrational numbers satisfying the requirements. However, it proves the existence of such irrational numbers. In the mainstream mathematics, this is a well appreciated proof. The question there is not only about accepting the law of excluded middle, but also about appreciating the nature of existence in mathematics. When we say that there exists an object with such and such property, what we understand is: it is not the case that the property is false for every object in the domain of discourse. It may or may not be always possible to construct that object with exactitude. See the following example. Example 1.8. Show that there exists a real number x satisfying xx5 = 5. Solution. Let f : R → R be given by f (x) = xx5 . We see that f (1) = 1 and f (2) = 232 . Also, f is a continuous function. Since f (1) 5 f (2), by the intermediate value theorem, there exists an a with 1 a 2 such that f (a) = 5. The a is not obtained exactly, but we know that there is at least one such point between 1 and 2. Of course, there is a better way of getting such an a. For example, a = 51/5 does the job! However, even if we could not have got this simple a, the solution in Example 1.8 is still valid. Example 1.9. Show that there exists a program that reports correctly whether tomor- row by this time, I will be alive or not. Solution. Consider the following two programs: Program-1 : Print “I will be alive tomorrow by this time.” Program-2 : Print “I will not be alive tomorrow by this time.”
  • 35. 1.5 Proof Techniques 19 Either I will be alive tomorrow by this time or not. That is, either Program-1 correctly reports the fact or Program-2 correctly reports the fact. Hence, we have a program that does the job, but we do not know which one. What about Program-3 : Wait till tomorrow. See what happens; then report ac- cordingly? This, of course, does the job correctly. But this is constructive, whereas the existence in the solution of Example 1.9 is not. Looked in a different way, the statement in Example 1.9 is ambiguous. One meaning of it has been exploited in the example. The other meaning asks for a program that “justifiably predicts” whether I will be alive till tomorrow or not. The solution there does not answer this nor does Program-3. Also, none of Program-1 and Program-2 work correctly in all cases. Program-1 can be wrong if I really die today, and Program-2 is wrong when I do live up to day after tomorrow. Nonetheless, the method combined with diagonalization can be used for showing nonexistence of programs. Choose any programing language in which you can write a program that would compute functions with domain N and co-domain {0, 1}. Com- puting a function here means that if f : N → {0, 1} is a given function, then you can possibly have a program Pf in your language that takes input as any n ∈ N and outputs f (n). This program Pf computes the function f. Example 1.10. Prove that there exists a function g : N → {0, 1} that cannot be computed by any program in whatever language you choose. Solution. Choose your language, say, C. Since the C-programs can be enumerated in alphabetical order, they form a countable set. The set of all C-programs that com- pute functions is a subset of the set of all C-programs, and hence, is countable. Enumerate the programs that compute functions in alphabetical order. Call them C0, C1, C2, . . . . Each Cj takes a number n ∈ N as an input, and outputs either 0 or 1. Define a function f : N → {0, 1} by f (n) = 0, if Cn outputs 1 on input n, and f (n) = 1 if Cn outputs 0 on input n. Now, if there exists a C-program that computes f, then it must be one of C0, C1, C2, . . . . Suppose it is Cm. But on input m, Cm outputs a different value than f. So, it does not compute f. Hence no C-program can compute this f. A nonconstructive version of the solution to Example 1.10 uses the fact that there are uncountable number of functions from N to {0, 1}, whereas there are only a count- able number of C-programs. It is because the set of all such functions is in one-to-one correspondence with the power set of N. See Problem 1.16. In the above solution, we have used a form of proof by contradiction. All the forms of proof by contradiction are propositional in nature, that is, they simply play with the simple propositional connectives like “and,” “or,” “not,” etc. One more proof method that uses the propositional connectives is the so-called proof employing a conditional hypothesis. It is summarized as Assume S1. Prove S2. Thereby you have proved: if S1, then S2.
  • 36. 20 1 Mathematical Preliminaries As P or Q is logically equivalent to (not P) implies Q, the method of conditional hypothesis can be used to prove such a disjunction. That is, a typical proof of P or Q starts with assuming not P and concluding Q. Sometimes the proofs using conditional hypothesis can be confusing and mislead- ing if it is combined with other spurious elements. See the following example. Example 1.11 (Fallacious Proof?). Show that there is no life on earth. Solution. Let S be the statement: If S is true, then there is no life on earth. We first show that S is true. As S is in the form “if S1, then S2” to show it, we assume S1 and prove S2. Here is such a proof: Proof of “S is true” begins. Assume S1, that is, S is true. As S is true, we have If S is true, then there is no life on earth. Owing to our assumption that S is true, we see that There is no life on earth. This is S2. So we have proved “if S1, then S2”, that is, If S is true, then there is no life on earth. That is, S is true. Proof of “S is true” ends. As S is true, we have If S is true, then there is no life on earth. The truth of the last statement and the fact that S is true imply There is no life on earth. Certainly, there is something wrong. You see that there is nothing wrong with the proof using the technique of conditional hypothesis. It is wrong to denote the statement If S is true, then there is no life on earth. by S. To further understand what is going on, see the following commercial of this book using three seductive questions. Example 1.12 (Trap). This is a conversation between you and me. I : I’ll ask you three questions. Would you like to answer each with “Yes” or “No?” You : Yes. I : That’s my first question. Will you answer the same to the third as to the second? You : No. I : Will you promise me that you will read only this book on Theory of computation and no other book on the topic throughout your life?
  • 37. 1.5 Proof Techniques 21 Now you are trapped. Since you have answered “No” to the second question, you cannot answer “No” to the third question. Had you answered “Yes” to the second question, then also you had to answer “Yes” to the third. Of course, had you chosen to answer “No” to my first question, you would not have been trapped. But as it is, why does it happen? The reason is the same as in Example 1.11, a spurious self-reference. When you give notation to a statement, it should have both the possibilities of being true or false. The notation itself cannot impose a truth condition. In Example 1.11, the notation S violates this, as S cannot be false there. If S is false, then the “if . . . then . . .” statement that it stands for becomes true, which is untenable. The same way, you are trapped in Example 1.12. Along with the propositional methods, we had also used the diagonalization tech- nique of Cantor. There are two more general proof methods we will use in this book. The first is the principle of mathematical induction. It is, in fact, a deductive proce- dure. It has two versions: one is called the strong induction and the other is called induction, without any adjective. Writing P(n) for a property of natural numbers, the two forms of the principle can be stated as Strong Induction: P(0). If P(k) holds for each k n, then P(n). Therefore, for each n ∈ N, P(n). Induction: P(0). If P(n) then P(n + 1). Therefore, for each n ∈ N, P(n). Verification of P(0) is called the basis step of induction, and the other “if . . . then” statement is called the induction step. In case of strong induction, the fact that all of P(0), P(1), . . . P(n − 1) hold is called the induction hypothesis; and in case of induction, the induction hypothesis is “P(n) holds.” Both the principles are equivalent, and one is chosen over the other for convenience. In the case of strong induction, the induction step involves assuming P(k) for each k n and then deriving P(n). While the induction step in the other case consists of deriving P(n + 1) from the single assumption P(n). Thus it is safer to start with the strong induction when we do not know which one of them will really succeed. The principle is also used to prove a property that might hold for all natural num- bers greater than a fixed m. This is a generalization of the above. The formulation of the principle now looks like: Strong Induction: P(m). If P(k) holds for each k with m ≤ k n, then P(n). Therefore, for each natural number n ≥ m, P(n). Induction: P(m). For each n ≥ m, if P(n) then P(n + 1). Therefore, for each natural number n ≥ m, P(n). As earlier, verification of P(m) is the basis step of induction, and the other “if . . . then” statement is the induction step. In case of strong induction, the fact “P(k) holds for each k with m ≤ k n” is the induction hypothesis; and in case of induction, the induction hypothesis is “P(n) holds.”
  • 38. 22 1 Mathematical Preliminaries Not only on N, but wherever we see the structure of N, we can use this principle. For example, it can be used on any set via the well ordering principle, which states that every set can be well ordered; see Problem 1.10. However, we will not require this general kind of induction. Example 1.13 (Hilbert’s Hotel). Hilbert has a hotel having rooms as many as num- bers in Z+. Show that he has rooms for any number of persons arriving in groups, where a group might contain infinite number of persons. Solution. Naturally, we take the infinite involved in the story as ℵ0. If only one such group asks for rooms, Hilbert just assigns one to each. Suppose he has accommo- dated n number of such groups. The (n + 1)th group arrives. Then, he asks the in- cumbents to move to other rooms by the formula: Person in Room-n moves to Room-2n. Now, all odd numbered rooms are free. And the persons in the just arrived group get accommodated there. If a group of persons contains ℵ1 or more people, then certainly Hilbert fails to meet the demands. Notice that in the solution to Hilbert’s hotel, I have used induction. You can have a shorter solution mentioning the fact that a finite union of countable sets is countable. We had defined graphs with finite sets of vertices implicitly. But a graph can also have an infinite set of vertices. For example, in Z+, take the relation of “divides,” that is, R = {(n, mn) : m, n ∈ Z+}. In the graph of this relation, there will be edges from 1 to every positive integer, 2 to every even number, 3 to each multiple of 3, etc. Similarly, trees on infinite sets are defined. A rooted tree in which each vertex has at most k number of children, for some k ∈ N, is called a finitely generated tree. A branch in a rooted tree is a path from the root to a leaf. An infinite branch is then a sequence of vertices v0, v1, v2, . . . such that v0 is the root and vi+1 is a child of vi , for each i ∈ N. We demonstrate the use of induction in an infinite tree. Example 1.14 (König’s Lemma). Show that each finitely generated infinite tree has an infinite branch. Solution. Let T be a finitely generated infinite tree. We show by induction that we have a branch v0, v1, . . . , vn, with vn as the root of an infinite subtree of T for each n ∈ N. Notice that such a branch cannot be finite. In the basis step, We choose v0, the root of the tree T. As T is a subtree of itself, for n = 0, the statement holds. For the induction step, suppose we have already a sequence v0, v1, . . . , vn of ver- tices such that vn is the root of an infinite subtree of T. Suppose the vertex vn has m children, where m ≤ k; this k is fixed for the tree. Consider the subtree T of T having vn as the root. If we remove vn from T , we get m subtrees with the children of vn as the roots of the subtrees. At least one of these subtrees has infinite number of vertices, otherwise, T will become finite. Take one such subtree which is infinite.
  • 39. 1.5 Proof Techniques 23 Choose its root as vn+1. Now, we get a sequence v0, v1, . . . , vn, vn+1 such that vn+1 is the root of an infinite subtree of T. Here ends the induction step. However, there is a danger in misusing the principle of induction. See the follow- ing example. Example 1.15 (Fallacious Induction). In a certain tribe, each boy loves a girl. Show that each boy loves the same girl. Solution. In the basis step, consider any single boy. Clearly, the statement holds for him. For the induction step, assume that if you take any group of n boys, you find that they love the same girl. Now, take any group of n+1 boys. Call them b1, b2, . . . , bn+1. Form two groups of n boys each. The first group has the boys b1, b2, . . . , bn and the second group has b2, b3, . . . , bn+1. Now, by the induction hypothesis, all of b1, b2, . . . , bn love the same girl and all of b2, b3, . . . , bn+1 love the same girl. As b2, b3, . . . , bn are common to both the groups, we see that all of b1, b2, bn, bn+1 love the same girl. For the argument of the induction step to hold, the set {b2, b3, . . . , bn} must be nonempty. That means, the basis step is not n = 1 but n = 2. You will see plenty of induction proofs later. Combining the principle of induction and proof by contradic- tion, we get Fermat’s principle of finite descent. It is stated as If P(n + 1), then P(n). But not P(0). Therefore, not P(n), for each n ∈ N. Example 1.16 (Surprise Quiz). Your teacher (not of this course!) declares in the class on a Friday that he will be conducting a surprise quiz some time on the next week. When returning to the dormitory, your friend says − “so nice of him; he will not be able to conduct the quiz this time.” He thus argues, “You see, he cannot afford to keep the quiz on Friday, for, in that case, he does not conduct the quiz till Thursday. Certainly then, we infer the quiz to be on Friday and it would not be a surprise quiz. Now agreed that he has to conduct the quiz on or before Thursday, can he afford not to conduct the quiz till Wednesday? No, for then, we infer that only on Thursday he conducts the quiz. Continuing three more steps, you see that he cannot even conduct the quiz on Monday.” This is an application of Fermat’s principle of finite descent. Of course, there has been some rhetoric involved, coining on the ambiguous meaning of the surprise in the quiz. But there is nothing wrong in your friend’s argument! We will not have occasions for the use of the principle in this book. But another consequence of in- duction will be used at many places. It is the Pigeon hole principle. It states that if there are n pigeons and m n pigeon holes to accommodate all the pigeons in the pigeon holes there must be at least two pigeons in same pigeon hole. A formal version goes as follows Let A, B be two finite sets. If |A| |B| and f : A → B is a total function, then f cannot be one–one.
  • 40. 24 1 Mathematical Preliminaries Even finiteness of the sets can be dropped, but that would require transfinite induction to justify the principle. Try proving this principle by using induction on |A|. We see an application of the principle. Example 1.17. Show that if seven points are chosen randomly from inside a circle of radius 1, then there are at least two points whose distance is less than 1. Solution. Take a circle of radius 1 and divide it into six equal parts by drawing six radii. Each of the six sectors of the circle is bounded by two radii and an arc. If seven points are chosen at random from inside the circle, then by Pigeon hole principle, at least two of them are from the same sector; which sector, we do not know. Now, the distance between those two points is less than 1. You have already seen how induction could be used for defining certain objects. For example, we have defined the cardinalities of finite sets as |∅| = 0, |{0}| = 1, |{0, 1, 2, . . ., n}| = n + 1. This definition uses induction. Another common example of definition by induction, sometimes called a recursive definition, is of the factorial function. It is defined by 0! = 1, (n + 1)! = n! (n + 1), for each n 0. The Fibonacci sequence is defined recursively by f0 = 1, f1 = 1, fn+1 = fn + fn−1, for each n 1. The construction of a suitable branch in König’s lemma is by induction. Sometimes a definition by induction does not use any number. For example, in defining an arithmetic expression involving the variables x, y, and the only operation as +, you would declare that each of x, y is an arithmetic expression. This is the basis step in the definition. Next, you will declare that if E1, E2 are expressions, then (E1 + E2) is an expression, and nothing else is an expression. In such a case, suppose you want to prove that in every expression there is an equal number of left and right parentheses. How do you proceed? Obviously, the proof is by induction on the number of left parentheses, or on the number of right parentheses, or on the number of + signs. But this has to be identified. Suppose we pick up the later. In the basis step, if there is no + sign in an expression, then there are no parentheses. Hence, the number of left and right parentheses are equal, equal to 0. Assume the induction hypothesis that if an expression has less than n number of + signs, then the number of left and right parentheses are equal. We plan to use strong induction to be on the safe side. Suppose E is an expression having n number of + signs,. Then, E = (E1 + E2) for some expressions E1 and E2. Now, both of E1, E2 satisfy the induction hypothesis. Thus they have equal number of left and right parentheses. Then so does (E1 + E2). In the above proof, we can avoid the parameter n, which we had chosen as the number of + signs. Here, we verify that the statement holds in the basis case of the inductive definition of expressions. Next, in the inductive step, we see if E1, E2 are expressions satisfying the conclusion that the left and right parentheses are equal in number, then so does the new expression (E1 + E2). There ends the proof. Such a use of induction without identifying a parameter is named as the prin- ciple of structural induction. To keep the matter straight, we will rather identify a suggestive integer parameter than using this principle.
  • 41. 1.6 Summary and Problems 25 1.6 Summary and Problems As you have observed, the mathematical preliminaries are not at all tough. All that we require is a working knowledge of set theory, the concept of cardinality, trees, induction, and the pigeon hole principle. A good reference on Set Theory including cardinality that covers all the topics discussed here is [50]. For induction, see [102]. For a reference on formal derivations and their applications to discrete mathematics, see [48]. These books also contain a lot of exercises. For an interesting history of numbers and number systems, see [35]. The story of the Hottentot tribes is from this book; of course I have modified it a bit to provide motivation for counting. Unlike other chapters, I have neither included exercises nor problems in each section; probably you do not require them. If you are really interested, here are some. Problems for Chapter 1 1.1. Prove all the laws about set operations listed at the end of Sect. 1.2 1.2. What is wrong in the following fallacious proof of the statement that each sym- metric and transitive binary relation on a nonempty set must also be reflexive: Suppose aRb. By symmetry, bRa. By transitivity, aRa? 1.3. Label the edges of the graph in Fig. 1.3 as e1, . . . , e7 and then write the corre- sponding labeled graph as a triple, now with an incidence relation. 1.4. If |A| = n, then how many binary relations on A are there? Among them, how many are reflexive? How many of them are symmetric? How many of them are both reflexive and symmetric? 1.5. Show that the inverse of an equivalence relation on a set is also an equivalence relation. What relation is there between the equivalence classes of the relation and those of its inverse? 1.6. Let A be a finite set. Let the binary relation R on 2A be defined by x Ry if there is a bijection between x and y. Construct a function f : 2A → N such that for any x, y ∈ 2A , f (x) = f (y) iff xRy. 1.7. Let R be an equivalence relation on any nonempty set A. Find a set B and a function f : A → B such that for any x, y ∈ A, f (x) = f (y) iff xRy. 1.8. Let R, R be two equivalence relations on a set A. Let P and P be the partitions of A consisting of equivalence classes of R and R , respectively. Show that R ⊆ R iff P is finer than P , that is, each x in P is a subset of some y in P . 1.9. Let A be a nonempty set. Suppose A denotes the empty collection of subsets of A. What are the sets ∪A and ∩A?
  • 42. 26 1 Mathematical Preliminaries 1.10. An order relation R on a set A is a binary relation satisfying the following properties: Comparability: For any x, y ∈ A, if x y, then either xRy or yRx. Irreflexivity: For each x ∈ A, it is not the case that xRx. Transitivity: For any x, y, z ∈ A, if xRy and yRz, then xRz. An element a ∈ B ⊆ A is a smallest element of B (with respect to the order R) if for each x ∈ B, x a, you have a x. A set A with an order relation R is said to be well ordered if each nonempty subset of A has a smallest element. The Well Ordering Principle states that given any set, there exists a binary relation with respect to which the set A is well ordered. The Axiom of Choice states that given a collection A of disjoint nonempty sets, there exists a set C having exactly one element in common with each element of A. Prove that the axiom of choice and the well ordering principle are equivalent. [Hint: Zermelo proved it in 1904; and it startled the mathematical world.] 1.11. Let f : A → B be a (total) function. Suppose C, C ⊆ A and D, D ⊆ B. Recall that f (C) = { f (x) : x ∈ C} and f −1 (D) = {x ∈ A : f (x) ∈ D}. Show that (a) If C ⊆ C , then f (C) ⊆ f (C ). (b) If D ⊆ D , then f −1 (D) ⊆ f −1 (D ). (c) C ⊆ f −1 ( f (C)). Equality holds if f is injective. (d) f ( f −1 (D)) ⊆ D. Equality holds if f is surjective. (e) f (C ∪ C ) = f (C) ∪ f (C ). (f) f (C ∩ C ) ⊆ f (C) ∩ f (C ). Give an example, where equality fails. (g) f (C) − f (C ) ⊆ f (C − C ). Give an example, where equality fails. (h) f −1 (D ∪ D ) = f −1 (D) ∪ f −1 (D ). (i) f −1 (D ∩ D ) = f −1 (D) ∩ f −1 (D ). (j) f −1 (D − D ) = f −1 (D) − f −1 (D ). (k) Statements (e), (f), (h), and (i) hold for arbitrary unions and intersections. 1.12. Suppose f : A → B and g : B → A are such functions that the compositions g ◦ f : A → A and f ◦ g : B → B are identity maps. Show that f is a bijection. 1.13. Let f : A → B, g : B → C be functions, and let D ⊆ C. (a) Show that (g ◦ f )−1 (D) = f −1 (g−1 (D)). (b) If f, g are injective, then show that g ◦ f is injective. (c) If f, g are surjective, then show that g ◦ f is surjective. (d) If g ◦ f is injective, what can you say about injectivity of f and g? (e) If g ◦ f is surjective, what can you say about surjectivity of f and g? 1.14. Let A, B be any sets. Prove that there exists a on-one function from A to B iff there exists a function from B onto A. [Hint: For the “if” part, you may need the axiom of choice.] 1.15. Let A = {1, 2, 3, . . ., n}. With O = {B ⊆ A : |B| is odd } and E = {B ⊆ A : |B| is even }, define a map f : O → E by f (B) = B − {1}, if 1 ∈ B; else f (B) = B ∪ {1}. Show that f is a bijection.
  • 43. 1.6 Summary and Problems 27 1.16. For sets A, B, define BA as the set of all functions from A to B. Prove that for any set C, there is a one–one correspondence between {0, 1}C and the power set 2C . This is the reason we write the power set of C as 2C . [Hint: For D ⊆ C, define its characteristic function, also called the indical function, χD : C → {0, 1} by “if x ∈ D, then χD(x) = 1; else, χD(x) = 0.”] 1.17. Show that no partial order on C can be an extension of the ≤ on R. 1.18. Recall that a nonempty set A is finite iff there is a bijection between A and {0, 1, . . ., n} for some n ∈ N. Here, we show how cardinality of a finite set is well defined. Let A be a set; a ∈ A; B A; and let n ∈ N. Prove the following without using cardinality: (a) There is a bijection between A and {0, 1, . . ., n+1} iff there is a bijection between A − {a} and {0, 1, . . ., n}. (b) Suppose there is a bijection between A and {0, 1, . . . , n+1}. Then, there exists no bijection between B and {0, 1, . . . , n + 1}. If B ∅, then there exists a bijection between B and {0, 1, . . ., m}, for some m n. 1.19. Show that N is not a finite set. 1.20. Prove: If A is a nonempty set and n ∈ N, then the following are equivalent: (a) There is a one–one function from A to {0, 1, . . ., n}. (b) There is a function from {0, 1, . . ., n} onto A. (c) A is finite and has at most n + 1 elements. 1.21. Let A, B, C be finite sets. Prove that |A ∪ B ∪ C| = |A| + |B| + |C| − |A ∩ B| − |B ∩ C| − |C ∩ A| + |A ∩ B ∩ C|. Generalize this formula for n number of sets A1, . . . , An. 1.22. Let B ⊆ A. Show that if there is an injection f : A → B, then |A| = |B|. 1.23. Prove that a denumerable union of finite sets is denumerable. 1.24. Using Cantor’s theorem, show that the collection of all sets is, infact, not a set. 1.25. Prove that each infinite set contains a denumerable subset. 1.26. Show that if f : N → A is a surjection and A is infinite, then A is denumerable. 1.27. Show that for each n ∈ Z+, |Qn | = |Q| and |Rn | = |R|. 1.28. Show that the set of algebraic numbers is denumerable. Then deduce that there are more transcendental numbers than the algebraic numbers. 1.29. Let f : A → B and g : B → A be two injections. Prove the following: (a) Write A0 = A − g(B), A1 = g(B) − g( f (A)), B0 = B − f (A), B1 = f (A) − f (g(B)). Then A0 ∪ A1 = A − g( f (A)) and B0 ∪ B1 = B − f (g(B)). Further, A0 ∩ A1 = ∅ = B0 ∩ B1. (b) The relation g−1 from g(A) to A is a function.
  • 44. 28 1 Mathematical Preliminaries (c) Define h : A0 ∪ A1 → B0 ∪ B1 by h(x) = f (x) for x ∈ A0, and h(x) = g−1 (x) for x ∈ A1. Then h is a bijection. Further, h(A0) = B1 and h(A1) = B0. (d) Write A2 = g( f (A)) − g( f (g(B))), A3 = g( f (g(B))) − g( f (g( f (A)))), B2 = f (g(B))− f (g( f (A))), B3 = f (g( f (A)))− f (g( f (g(B)))). Now define, by induction, the sets Ai , Bi , for each i ∈ N. Then A2m ∩ A2m+1 = ∅ = B2m ∩ B2m+1. (e) Define φ : ∪i∈N Ai → ∪i∈N Bi by φ(x) = f (x) if x ∈ Ai , i even, and φ(x) = g−1 (x) for x ∈ Ai , i odd. Then φ is a bijection. (f) Restrict the domain of f to the set A − ∪i∈N Ai . Then f : A − ∪i∈N Ai → B − ∪i∈N Bi is a bijection. (g) Define ψ : A → B by ψ(x) = φ(x) if x ∈ ∪i∈N Ai , and ψ(x) = f (x) if x ∈ A − ∪i∈N Ai . Then ψ is a bijection. (h) Cantor–Schröder–Bernstein Theorem: If |A| ≤ |B| and |B| ≤ |A|, then |A| = |B|. 1.30. Let A, B be sets. Is it true that there is an injection from A to B iff there is a surjection from B to A? [Hint: Does axiom of choice help? See Problem 1.10] 1.31. Define |A| + |B| = |A ∪ B| provided A ∩ B = ∅; |A| − |B| = |A − B| provided B ⊆ A; |A| × |B| = |A × B|; and |A||B| = |AB |. Let α, β be cardinalities of infinite sets with α β. Show that α + β = β, β − α = β, α × β = β, 2α α. Further, show that α − α is not well defined. 1.32. Show that a denumerable product of denumerable sets is uncountable. [Hint: You may need the axiom of choice.] 1.33. Let a ∈ R. Simplify the sets ∪r1{x ∈ R : a − r ≤ x ≤ a + r} and ∩r0{x ∈ R : a − r x a + r}. 1.34. Let S denote the sentence: This sentence has no proof. Show that S is true. Conclude that there is a true sentence having no proof. [Gödel’s proof of his incom- pleteness theorem expresses S in the system of natural numbers.] 1.35. Let S be the sentence: This sentence has no short proof. Show that if S is true, then there exists a sentence whose proof is not short, but the fact that it is provable has a short proof. [A formal version of this S expressed in the system of natural numbers is called Parikh’s sentence.] 1.36. Let P(m, n) denote a property involving two natural numbers. Suppose we prove that P(0, 0) is true. We also prove that if P(i, j) is true, then both P(i, j + 1) and P(i + 1, j) are true. Does it follow that P(m, n) is true for any m, n ∈ N? 1.37. Show that for each integer n 1, 1/ √ 1 + 1/ √ 2 + 1/ √ 3 + · · · + 1/ √ n √ n. 1.38. Deduce the pigeon hole principle from the principle of induction. 1.39. Show that among any n + 2 positive integers, either there are two whose sum is divisible by 2n or there are two whose difference is divisible by 2n. 1.40. Use the pigeon hole principle to show that each rational number has a recurring decimal representation.
  • 45. 1.6 Summary and Problems 29 1.41. Show that among any n + 1 numbers randomly chosen from {1, 2, . . ., 2n}, there are at least two such that one divides the other. 1.42. Let A = {m + n √ 2 : m, n ∈ Z}. Show that for each k ∈ Z+, there is xk ∈ A such that 0 xk 1/k.
  • 46. 2 Regular Languages 2.1 Introduction It is said that human intelligence is mainly the capability to represent a problem, its solution, or related facts in many seemingly different ways. You must have encoun- tered it in several problem-solving situations. You first represent the problem in a known language, where you might like to eliminate or omit the irrelevant aspects and consider only the appropriate ones. The methodology is followed throughout mathematics starting from solving first arithmetic problems such as “if you already had five candies and your friend offers you one more, then how many candies do you have now?”. To give another example, the memory in a computer is only an assembly of switches which, at any moment, may be off or on. If there is a trillion of them, then it may be represented as a trillion digited binary number, when, say, off corresponds to 0 and on to 1. In some situations, we may not be interested in all possible bi- nary numbers, but only those having a few number of digits out of the trillion, or only those having a particular pattern, such as “there is at least one 0 following ev- ery occurrence of a 1.” There might arise a situation where we would like to have a representational scheme having more than two symbols. We will, however, consider only a finite number of symbols at a time, and in parallel with the existing natural languages, we will develop formal languages out of these symbols. In this book, we will introduce a hierarchy of formal languages. To represent formal languages, we will study grammars. Each such type in the hierarchy will have its own type of mechanical device, which may recognize the language but not any other language from another type. In the sequel, we will have to introduce many technicalities. The technical words or phrases, as usually are, will either be defined clearly or will be left completely undefined. In the latter case, I will attempt at a description of such undefined or primitive notions so that you will be able to think about them in a certain well-intended way. A. Singh, Elements of Computation Theory, Texts in Computer Science, 31 c Springer-Verlag London Limited 2009
  • 47. 32 2 Regular Languages 2.2 Language Basics We start with the primitive notion of a symbol. A symbol is any written sign. We adhere to the written scripts as communication between you and me. Of course, you can even consider “spoken signs” or even “body language” or any piece in any other sign language. The implicit assumption here is that we will be able to represent other types of symbols or signs in terms of the written ones, in terms of our symbols. An alphabet is then a nonempty finite set of symbols, where no symbol is a part of another. Notice that the phrase is a part of is again a primitive notion here. We will not allow the blank symbol to be in our alphabets for some technical reasons. If the blank symbol has to be used in some situation, then we will rather have some rewriting of it, say, b . For example, {0, 1}, {a, b, c, . . ., z}, {@, $, !, 1, a, z, 5, } are alphabets, but {0, 10}, {ab, c, a} are not alphabets as 0 is a part of 10 and a is a part of ab. A word or a string over an alphabet is a finite sequence of symbols from the alphabet. For example, each word in an English dictionary is a string over the Roman alphabet. Each natural number is a string over the alphabet {0, 1, 2, . . ., 9}. Thus a string is written as a sequence of symbols followed one after another without any punctuation marks. This way of writing a string is referred to as the operation of concatenation of symbols. The operation can be defined for strings also. For example, concatenation of strings alpha and bet is alphabet, and concatenation of bet and alpha is betalpha. If s and t are strings (over an alphabet), then concatenation of s and t is the string st (over the same alphabet). There is a special string, the string containing no occur- rence of any symbol whatsoever, called the empty string. The empty string is indeed unique, and it is a string over every alphabet. We will denote the empty string by the symbol ε. It serves as an identity of concatenation as for any string u, uε = εu = u. The number of occurrences of symbols in a string is called its length. The length of alpha is 5 and the length of bet is 3. The empty string ε has length 0. Note that the length of a string depends upon the underlying alphabet as the string itself needs an alphabet, first of all. For example, the length of the string 1001 over the alphabet {0, 1} is 4, while its length over the alphabet {10, 01} is 2. The vagueness in the definition of a symbol and an alphabet is removed by follow- ing a strict mathematical formalism. In this formalism, an alphabet is taken as any finite set and a string over the alphabet is taken as a map from {1, 2, . . ., n} to the alphabet, where n is some natural number. The natural number n is again the length of the string. For example, the string 101 over the alphabet {0, 1} is simply the map f : {1, 2, 3} → {0, 1}, where f (1) = 1, f (2) = 0, f (3) = 1. This string has length 3 as usual. Note that the map f here can be completely determined by its values at the integers 1, 2, 3. That is, the map can be rewritten by noting down its values at 1, 2, 3 one after another, and, in that order. That is how the formal definition would be connected to the informal. When the natural number n is taken as 0, we have an empty domain for the map, and then, by convention, we will have the empty map, the empty string ε, having length 0. Moreover, the length function can be defined inductively over an alphabet Σ as in the following:
  • 48. 2.2 Language Basics 33 1. (ε) = 0. 2. If σ ∈ Σ and u is a string over Σ, then (uσ) = (u) + 1. The reversal of a string s over an alphabet Σ is denoted by sR and is defined induc- tively by the following: 1. εR = ε. 2. If σ ∈ Σ and u is a string over Σ, then (σu)R = uR σ. See that the above definition of the reversal does really capture the notion of the reversal; for example, (reverse)R = esrever. It follows that the length of the reversal of a string is same as the length of the string. It also follows that (uv)R = vR uR for strings u and v. Show these by induction (see Sect. 1.5.) on the length of the string! Exercise 2.1. Define the operation of concatenation inductively and then show that this operation is associative but not commutative. Exercise 2.2. Write (ab)0 = ε, (ab)1 = ab, (ab)2 = abab, . . . for the string ab. Define (ab)n inductively for every n ∈ N. Show that ((ab)n ) = n (ab). A string u is a prefix of a string w iff there is a string v such that w = uv. Similarly, if for some string v, we have w = vu, then u is called a suffix of w. In general, u is a substring of w iff there are strings x, y such that w = xuy. For example, pre is a prefix of prefix and fix is a suffix of suffix (and also of prefix). The string ref is a substring of prefix. Vacuously, both pre and fix are substrings of prefix. As the strings x, y in w = xuy can be taken as the empty string ε, every string is a substring of itself. Also, every string is both a prefix and a suffix of itself. Observe that all of ε, p, pr, pre, pref, prefi, prefix are prefixes of prefix. Out of these if you take any two, can you find any relation between them? Easy, one of them has to be a prefix of the other! If both u and v are prefixes of the same string w, then u is matching with a part of w from the left and so is v. So, the one with smaller length must be a prefix of the other. But this is not a proof! Lemma 2.1 (Prefix Lemma). If u and v are prefixes of a string w over an alphabet Σ, then u is a prefix of v or v is a prefix of u. Proof. We prove it by induction on the length of w. If (w) = 0, then w = ε, and then u = v = ε. This shows that u is a prefix of v. Assume the induction hypothesis that for all strings w of length n, the statement holds. Let (w) = n + 1. Write w = zσ, where σ ∈ Σ is the last symbol of w, and then (z) = n. Let u and v be prefixes of w. If one of u, v equals w, then the other is a prefix of it. So, suppose that neither u nor v is equal to w. Then both u and v are prefixes of z. (Why?) As (z) = n, by the induction hypothesis, u is a prefix of v or v is a prefix of u. Exercise 2.3. Formulate and prove Lemma 2.1 with suffixes instead of prefixes. What about mixing prefixes and suffixes? A language over an alphabet Σ is any set of strings over Σ. In particular, ∅, the empty set (of strings) is a language over every alphabet. So are the sets {ε}, the set Σ itself, and the set of all strings over Σ, which we denote by Σ∗ .
  • 49. 34 2 Regular Languages Thus, any book written in English may be thought of as a language over the Ro- man alphabet. The set of all binary numbers starting with 1 and of length 2, that is, the set {10, 11} is a language over {0, 1}. The binary palindromes (the strings that are same when read from right to left) form a language as this can be written as {w ∈ {0, 1}∗ : wR = w}, a subset of {0, 1}∗ . Theorem 2.1. Let Σ be any alphabet. Then Σ∗ is denumerable. Therefore, there are uncountable number of languages over Σ. Proof. Write Σ0 = {ε} and Σn = the set of all strings of length n over Σ, for any n ∈ Z+. If |Σ| = m, then there are mn strings in Σn. As Σ∗ = ∪n∈NΣn, a denumerable union of finite sets, it is denumerable. Each language over Σ is a subset of Σ∗ . Thus, the number of such languages is the cardinality of the power set 2Σ∗ , which is uncountable by Theorem 1.5. The question is how to name all these languages? Obviously, whatever way we try to name them, the names themselves will be strings over some alphabet, and there can only be a countable number of them at the most, unless we choose to supply names from another uncountable set such as R. So, before even attempting to name the languages, we see that any such attempt is bound to fail. But then, can we name certain interesting languages? It, of course, depends upon what our interest is and what is our naming scheme. Note that naming schemes are only finitary ways of representing the languages. We start with some natural naming schemes. As languages are sets, we can use set operations such as union, intersection, complementation (in Σ∗ ) etc. We also have the operation of concatenation for strings, which can be adopted or extended to lan- guages. Let L, L1, L2 be languages over an alphabet Σ. Then L1 L2 = {uv : u ∈ L1 and v ∈ L2} is the concatenation of the languages L1 and L2. Note the asymmetry in this and. L1 ∪ L2 = {w : w ∈ L1 or w ∈ L2} is the union of L1 and L2. L1 ∩ L2 = {w : w ∈ L1 and w ∈ L2} is the intersection of L1 and L2. L1 − L2 = {w : w ∈ L1 but w ∈ L2} is the difference of L2 from L1. L = {w ∈ Σ∗ : w ∈ L} is the complement of the language L. The powers of L , denoted by Lm , for m ∈ N, are defined inductively by L0 = {ε} and Ln+1 = LLn . The Kleene star (or the closure or the asterate) of the language L is defined as L∗ = ∪m∈N Lm . Read it as L star. Notice that it goes along well with our earlier nota- tion Σ∗ , the set of all strings over the alphabet Σ. The Kleene plus of L is L+ = LL∗ = {u1u2 · · · uk : k 0 and ui ∈ L}. Read it as L plus. L+ is also referred to as the positive closure of L. Similarly other set operations will give rise to respective definitions of new lan- guages using the old ones. Our aim is to use these symbolism for writing many interesting languages in a compact way. See the following examples.
  • 50. 2.2 Language Basics 35 Example 2.1. Can we represent the language L = {w ∈ {a, b, c}∗ : w does not end with c} using the symbolism we have developed so far? Solution. Will it be easy if we first try representing all strings over Σ that end with one c? Any such string will be a string from Σ∗ followed by the symbol c. That is, L = {uc : u ∈ Σ∗ } = Σ∗ {c} = {a, b, c}∗ {c}. Thus, L = {a, b, c}∗{c}. To develop a shorthand, we might write {a, b, c} = {a}∪{b}∪{c} just as a ∪b∪c. Here, we are dispensing with braces } and {, though we know that a ∪ b ∪ c does not make sense at all. However, we can still use it as a shorthand, a name, with an obvious interpretation. For such an expression a∪b∪c, we will associate the language {a} ∪ {b} ∪ {c}. To put it formally, we would like to use the phrase: the language represented by the expression so and so. Thus a ∪ b ∪ c will be regarded as an expression and {a} ∪ {b} ∪ {c} will be the language represented by this expression. In symbols, we will write it as L(a ∪ b ∪ c) = {a} ∪ {b} ∪ {c}. There will not be any confusion between the “string ab” and the “expression ab”, as the former is only a string and the L of the latter is the language {ab}. We will use, mostly in the exercises, the symbol # as a shorthand for “number of.” If w is a string and σ is a symbol, we write #σ(w) to denote the number of occurrences of σ in w. For example, #a(babaabc) = 3. Problems for Section 2.2 2.1. What languages do the expressions (∅∗ )∗ and 0∅ denote? 2.2. Find all strings in (a ∪ b)∗ b(a ∪ ab)∗ of length less than four. 2.3. When does LL∗ = L − {ε} happen? 2.4. Let L = {ab, aa, baa}. Which of the strings bbbbaa, aaabbaa, abaabaaa- baa, baaaaabaaaab, and baaaaabaa are in L∗ ? 2.5. Let Σ be any alphabet. Prove that (uv)R = vR uR , for all strings u, v ∈ Σ+ . 2.6. Let Σ = {a, b}. Find strings in, and not in, L ⊆ Σ∗ , where L is (a) {wwR w : w ∈ ΣΣ}. (b) {w ∈ Σ∗ : w2 = w3 }. (c) {w ∈ Σ∗ : w3 = v2 for some v ∈ Σ∗ }. (d) {w ∈ Σ∗ : uvw = wuv for some u, v ∈ Σ∗ }. 2.7. Let a, b, c be different symbols. Are the following true? Justify. (a) (a ∪ b)∗ = a∗ ∪ b∗ . (b) a∗ b∗ ∩ b∗ a∗ = a∗ ∪ b∗ . (c) ∅∗ = ε∗ . (d) {a, b}∗ = a∗ (ba∗ )∗ . (e) a∗ b∗ ∩ b∗ c∗ = ∅. (f) (a∗ b∗ )∗ = (a∗ b)∗ .
  • 51. 36 2 Regular Languages (g) (a ∪ ab)∗ a = a(a ∪ ba)∗ . (h) a(bca)∗ bc = ab(cab)∗ c. (i) (b ∪ a+ b)(b ∪ a+ b)(a ∪ ba∗ b)+ = a∗ b(a ∪ ba∗ b)∗ . (j) aa(a ∪ b)∗ ∪ (bb)∗ a∗ = (a ∪ ab ∪ ba)∗ . 2.8. Let w ∈ {a, b}∗ be such that abw = wab. Show that (w) is even. 2.9. Does L = L∗ hold for the following languages: (a) L = {an bn+1 : n ∈ N}? (b) L = {w ∈ {a, b}∗ : #a(w) = #b(w)}? 2.10. Are there languages for which (L∗) = (L)∗ ? 2.11. Use induction to show that (un ) = n (u) for all strings u and all n ∈ N. 2.12. Prove that for all languages L1, L2, we have (L1 L2)R = LR 2 LR 1 . 2.13. Prove or disprove the following claims: (a) (L1 ∪ L2)R = LR 1 ∪ LR 2 for all languages L1 and L2. (b) (LR )∗ = (L∗ )R for all languages L. (c) If L∗ 1 = L∗ 2 then L1 = L2 for all languages L1 and L2. (d) There exists a finite language L such that L∗ = L. (e) If ε ∈ L ⊆ Σ∗ and ε ∈ L ⊆ Σ∗ , then (LΣ∗ L )∗ = Σ∗ . 2.14. Let A be a language over an alphabet Σ. Call A reflexive if ε ∈ A, and call A transitive if A2 ⊆ A. Let B ⊇ A. Show that if B is both reflexive and transitive, then B ⊇ A∗ . 2.15. Give a rigorous proof that L((a ∪ba)∗ (b ∪ε)) is the set of all strings over {a, b} having no pair of consecutive b’s. 2.16. Let A, B, C be languages over an alphabet Σ. Show the following properties of union, concatenation, and Kleene star: (a) A{ε} = {ε}A = A. (b) A∅ = ∅A = ∅. (c) A(B ∪ C) = AB ∪ AC. (What about arbitrary union?) (d) A∗ A∗ = (A∗ )∗ = A∗ = {ε} ∪ AA∗ = {ε} ∪ A∗ A. (e) ∅∗ = {ε}. (f) (A ∪ B)∗ = (A∗ B∗ )∗ . (g) A(B ∩ C) = AB ∩ AC does not hold, in general. (h) AB = A B does not hold, in general. 2.3 Regular Expressions For the time being, we only consider the operations of concatenation, union, and the Kleene star starting from the symbols of an alphabet and the empty language ∅. We begin with such a definition of a class of expressions and the corresponding languages they represent.
  • 52. 2.3 Regular Expressions 37 A regular expression over an alphabet Σ and the language it represents are defined inductively by the following rules: 1. ∅ is a regular expression. L(∅) = ∅. 2. Each σ ∈ Σ is a regular expression. L(σ) = {σ}. 3. If α is a regular expression, then α∗ is a regular expression. L(α∗ ) = (L(α))∗ . 4. If α, β are regular expressions, then both (αβ) and (α∪β) are regular expressions. L((αβ)) = L(α)L(β) and L((α ∪ β)) = L(α) ∪ L(β). 5. All regular expressions and the languages they represent are obtained by applying the rules 1–4 above. The parentheses above are used to remove possible ambiguities such as those that occur in the expression αβ∪γ , which may be read as α(β∪γ ) or as (αβ)∪γ . However, we will dispense with many parentheses by using the following precedence rules: The operation ∗ will have the highest precedence. The operation of concatenation will have the next precedence. The operation of union will have the least precedence. We will also dispense with the outermost parentheses from a regular expression. This means that the regular expression ((αβ) ∪ γ ∗ ) will be rewritten (or abbreviated) as αβ ∪ γ ∗ . Instead of writing L((αβ)), L((α ∪ β)), (L(α))∗ , we will simply write L(αβ), L(α ∪ β), L(α)∗ , respectively. A language is called a regular language iff it can be represented by a regular expression, that is, when L = L(α) for some regular expression α. Example 2.2. Let Σ be any alphabet. Then ∅, {ε}, Σ, Σ∗ , Σ+ , Σn for any n ∈ N are regular languages. Note that ∅0 = {ε} and ∅n = ∅ for n 0. Thus, ∅∗ = {ε}, Σ+ = ΣΣ∗ , and Σn = Σ · · · Σ concatenated n times. Similarly, L = {am bn : m, n ∈ N} is regular as L = L(a∗ b∗ ). Sometimes, we give a description of a language in terms of its elements. Example 2.3. Let L be the set of all strings over {a, b} having exactly two occur- rences of b, which are consecutive. Is L regular? Solution. If two b’s are consecutive in a string u, then bb is a substring of u. That is, u = xbby for some strings x and y. If x has a b in it, then u will have more than two b’s, similarly for y. Thus both x and y have only a’s in them or they may equal the empty string ε. Hence x, y ∈ {a}∗ . Therefore, L = L(a∗ bba∗ ), and it is a regular language. Example 2.4. Let L be the language over {a, b} having exactly two nonconsecutive b’s. Is L a regular language?
  • 53. 38 2 Regular Languages Solution. You can write L as L(a∗ ba∗ ba∗ ) − L(a∗ bba∗ ). But this does not help as difference or complementation is not allowed in a regular expression. Any typical string in L has one b in its middle, followed by some a’s and then another b. It may look something like aa · · · aba · · · aba · · · a. Note that, before the first b (first from the left) there may not be an a and similarly there may not be an a after the second b. But there must be an a in between the two b’s. Thus, L = L(a∗ ba+ ba∗ ) = L(a∗ baa∗ ba∗ ), a regular language. Exercise 2.4. See that L(a∗ ba∗ baa∗ ba∗ (ba∗ ∪ ∅∗ )) = {w ∈ {a, b}∗ : w has three or four occurrences of b’s in which the second and third occurrences are not consecutive}. Example 2.5. Is the complement of the language in Example 2.3 regular? Solution. With Σ = {a, b}, this language L contains all the strings of the language in Example 2.4 and the strings that do not contain exactly two consecutive b’s. Thus L = L(a∗ baa∗ ba∗ ) ∪ L(a∗ ) ∪ L(a∗ ba∗ ) ∪ Σ∗ {b}Σ∗ {b}Σ∗ {b}Σ∗ . The regular expression for L is a∗ ∪ a∗ ba∗ ∪ a∗ baa∗ ba∗ ∪ (a ∪ b)∗ b(a ∪ b)∗ b(a ∪ b)∗ b(a ∪ b)∗ . Example 2.6. What is L(a∗ ((b ∪ bb)aa∗ (b ∪ bb))∗ a∗ )? Solution. Clearly, any string of a’s is in the language. What else? There are also strings with 0 or more a’s followed by one or two b’s, then at least one a, and then 0 or more of b or bb, and then a string of a’s. What is the middle aa∗ do- ing? It prevents occurrences of three or more consecutive b’s. The language is L((a ∪ b)∗bbb(a ∪ b)∗). Hence forward, we will make the overline short; for example, we will write L((a ∪ b)∗ bbb(a ∪ b)∗ ) instead of L((a ∪ b)∗bbb(a ∪ b)∗). Exercise 2.5. Does the regular expression a∗ ∪ ((a∗ (b ∪ bb))(aa∗ (b ∪ bb))∗ )a∗ rep- resent the language L(bbb)? We will also write the regular expression itself for the language it represents. This will simplify our notation a bit. For example, instead of writing L(a∗ b∗ ), we will simply write the language a∗ b∗ . Use of the phrase “the language” will clarify the meaning. Exercise 2.6. Does the equality L(bbb) = (∅∗ ∪ b ∪ bb)(a ∪ bb ∪ abb)∗ hold? We will also say that two regular expressions are equivalent when they represent the same language. Moreover, in accordance with the last section, two equivalent regular expressions can also be written as equal. This means, for regular expressions R, E, we will use any one of the notations R = E (sloppy), L(R) = L(E) (precise), or R ≡ E (R is equivalent to E, technical) to express the one and the same thing.
  • 54. 2.3 Regular Expressions 39 Problems for Section 2.3 2.17. Give regular expressions for the following languages over {a}: (a) {a2n+1 : n ∈ N}. (b) {an : n is divisible by 2 or 3, or n = 5}. (c) {a2 , a5 , a8 , . . .}. 2.18. Give a simpler regular expression for each of the following: (a) ∅∗ ∪ b∗ ∪ a∗ ∪ (a ∪ b)∗ . (b) (a∗ b)∗ ∪ (b∗ a)∗ . (c) ((a∗ b∗ )∗ (b∗ a∗ )∗ )∗ . (d) (a ∪ b)∗ b(a ∪ b)∗ . 2.19. Find regular expressions for the following languages over {0, 1}: (a) {w : w does not contain 0}. (b) {w : w does not contain the substring 01}. (c) Set of all strings having at least one pair of consecutive zeros. (d) Set of all strings having no pair of consecutive zeros. (e) Set of all strings having at least two occurrences of 1’s between any two occur- rences of 0’s. (f) {0m 1n : m + n is even, m, n ∈ N}. (g) {0m 1n : m ≥ 4, n ≤ 3, m, n ∈ N}. (h) {0m 1n : m ≤ 4, n ≤ 3, m, n ∈ N}. (i) Complement of {0m 1n : m ≥ 4, n ≤ 3, m, n ∈ N}. (j) Complement of {0m 1n : m ≤ 4, n ≤ 3, m, n ∈ N}. (k) Complement of {w ∈ (0 ∪ 1)∗ 1(0 ∪ 01)∗ : (w) ≤ 3}. (l) {0m 1n : m ≥ 1, n ≥ 1, mn ≥ 3}. (m) {01n w : w ∈ {0, 1}+ , n ∈ N}. (n) Complement of {02m 12n+1 : m, n ∈ N}. (o) {uwu : (u) = 2}. (p) Set of all strings having exactly one pair of consecutive zeros. (q) Set of all strings ending with 01. (r) Set of all strings not ending in 01. (s) Set of all strings containing an even number of zeros. (t) Set of all strings with at most two occurrences of the substring 00. (u) Set of all strings having at least two occurrences of the substring 00. [Note: 000 contains two such occurrences.] 2.20. Write the languages of the following regular expressions in set notation, and also give verbal descriptions: (a) a∗ (a ∪ b). (b) (a ∪ b)∗ (a ∪ bb). (c) ((0 ∪ 1)∗ (0 ∪ 1)∗ )∗ 00(0 ∪ 1)∗ . (d) (aa)∗ (bb)∗ b. (e) (1 ∪ 01)∗ . (f) (aa)∗ b(aa)∗ ∪ a(aa)∗ ba(aa)∗ .
  • 55. Other documents randomly have different content
  • 56. cultivated in the north of England. Sedburgh, for many years, was a sort of nursery or rural chapel-of-ease to Cambridge. Dawson of Sedburgh was a luminary better known than ever Dr. Watson was, by mathematicians both foreign and domestic. Gough, the blind mathematician and botanist of Kendal, is known to this day; but many others in that town had accomplishments equal to his; and, indeed, so widely has mathematical knowledge extended itself throughout Northern England that, even amongst the poor Lancashire weavers, mechanic labourers for their daily bread, the cultivation of pure geometry, in the most refined shape, has long prevailed; of which some accounts have been recently published. Local pique, therefore, must have been at the bottom of Dr. Whittaker's sneer. At all events, it was ludicrously contrasted with the true state of the case, as brought out by the meeting between Coleridge and the Bishop. Coleridge was armed, at all points, with the scholastic erudition which bore upon all questions that could arise in polemic divinity. The philosophy of ancient Greece, through all its schools, the philosophy of the schoolmen technically so called, Church history, c., Coleridge had within his call. Having been personally acquainted, or connected as a pupil, with Eichhorn and Michaelis, he knew the whole cycle of schisms and audacious speculations through which Biblical criticism or Christian philosophy has revolved in Modern Germany. All this was ground upon which the Bishop of Llandaff trod with the infirm footing of a child. He listened to what Coleridge reported with the same sort of pleasurable surprise, alternating with starts of doubt or incredulity, as would naturally attend a detailed report from Laputa—which aërial region of speculation does but too often recur to a sober-minded person in reading of the endless freaks in philosophy of Modern Germany, where the sceptre of Mutability, that potentate celebrated by Spenser, gathers more trophies in a year than elsewhere in a century; the anarchy of dreams presides in her philosophy; and the restless elements of opinion, throughout every region of debate, mould themselves eternally, like the billowy sands of the desert as
  • 57. beheld by Bruce, into towering columns, soar upwards to a giddy altitude, then stalk about for a minute, all aglow with fiery colour, and finally unmould and dislimn, with a collapse as sudden as the motions of that eddying breeze under which their vapoury architecture had arisen. Hartley and Locke, both of whom the bishop made into idols, were discussed; especially the former, against whom Coleridge alleged some of those arguments which he has used in his Biographia Literaria. The bishop made but a feeble defence; and upon some points none at all. He seemed, I remember, much struck with one remark of Coleridge's, to this effect:—That, whereas Hartley fancied that our very reasoning was an aggregation, collected together under the law of association, on the contrary, we reason by counteracting that law: just, said he, as, in leaping, the law of gravitation concurs to that act in its latter part; but no leap could take place were it not by a counteraction of the law. One remark of the bishop's let me into the secret of his very limited reading. Coleridge had used the word apperception, apparently without intention; for, on hearing some objection to the word, as being surely not a word that Addison would have used, he substituted transcendental consciousness. Some months afterwards, going with Charles Lloyd to call at Calgarth, during the time when The Friend was appearing, the bishop again noticed this obnoxious word, and in the very same terms:—Now, this word apperception, which Mr. Coleridge uses in the last number of 'The Friend,' surely, surely it would not have been approved by Addison; no, Mr. Lloyd, nor by Swift; nor even, I think, by Arbuthnot. Somebody suggested that the word was a new word of German mintage, and most probably due to Kant—of whom the bishop seemed never to have heard. Meantime the fact was, and to me an amusing one, that the word had been commonly used by Leibnitz, a classical author on such subjects, 120 years before. In the autumn of 1810, Coleridge left the Lakes; and, so far as I am aware, for ever. I once, indeed, heard a rumour of his having passed through with some party of tourists—some reason struck me at the
  • 58. time for believing it untrue—but, at all events, he never returned to them as a resident. What might be his reason for this eternal self- banishment from scenes which he so well understood in all their shifting forms of beauty, I can only guess. Perhaps it was the very opposite reason to that which is most obvious: not, possibly, because he had become indifferent to their attractions, but because his undecaying sensibility to their commanding power had become associated with too afflicting remembrances, and flashes of personal recollections, suddenly restored and illuminated—recollections which will Sometimes leap From hiding-places ten years deep, and bring into collision the present with some long-forgotten past, in a form too trying and too painful for endurance. I have a brilliant Scotch friend, who cannot walk on the seashore—within sight of its ανηριθμον γελασμα (anêrithmon gelasma), the multitudinous laughter of its waves, or within hearing of its resounding uproar, because they bring up, by links of old association, too insupportably to his mind the agitations of his glittering, but too fervid youth. There is a feeling—morbid, it may be, but for which no anodyne is found in all the schools from Plato to Kant—to which the human mind is liable at times: it is best described in a little piece by Henry More, the Platonist. He there represents himself as a martyr to his own too passionate sense of beauty, and his consequent too pathetic sense of its decay. Everywhere—above, below, around him, in the earth, in the clouds, in the fields, and in their garniture of flowers—he beholds a beauty carried to excess; and this beauty becomes a source of endless affliction to him, because everywhere he sees it liable to the touch of decay and mortal change. During one paroxysm of this sad passion, an angel appears to comfort him; and, by the sudden revelation of her immortal beauty, does, in fact, suspend his grief. But it is only a suspension; for the sudden recollection that her privileged condition, and her exemption from
  • 59. the general fate of beauty, is only by way of exception to a universal rule, restores his grief: And thou thyself, he says to the angel— And thou thyself, that com'st to comfort me, Wouldst strong occasion of deep sorrow bring, If thou wert subject to mortality! Every man who has ever dwelt with passionate love upon the fair face of some female companion through life must have had the same feeling, and must often, in the exquisite language of Shakspere's sonnets, have commanded and adjured all-conquering Time, there, at least, and upon that one tablet of his adoration, To write no wrinkle with his antique hand. Vain prayer! Empty adjuration! Profitless rebellion against the laws which season all things for the inexorable grave! Yet not the less we rebel again and again; and, though wisdom counsels resignation, yet our human passions, still cleaving to their object, force us into endless rebellion. Feelings the same in kind as these attach themselves to our mental power, and our vital energies. Phantoms of lost power, sudden intuitions, and shadowy restorations of forgotten feelings, sometimes dim and perplexing, sometimes by bright but furtive glimpses, sometimes by a full and steady revelation, overcharged with light—throw us back in a moment upon scenes and remembrances that we have left full thirty years behind us. In solitude, and chiefly in the solitudes of nature, and, above all, amongst the great and enduring features of nature, such as mountains, and quiet dells, and the lawny recesses of forests, and the silent shores of lakes, features with which (as being themselves less liable to change) our feelings have a more abiding association— under these circumstances it is that such evanescent hauntings of our past and forgotten selves are most apt to startle and to waylay us. These are positive torments from which the agitated mind shrinks in fear; but there are others negative in their nature—that is, blank mementoes of powers extinct, and of faculties burnt out within
  • 60. us. And from both forms of anguish—from this twofold scourge— poor Coleridge fled, perhaps, in flying from the beauty of external nature. In alluding to this latter, or negative form of suffering—that form, I mean, which presents not the too fugitive glimpses of past power, but its blank annihilation—Coleridge himself most beautifully insists upon and illustrates the truth that all which we find in Nature must be created by ourselves; and that alike whether Nature is so gorgeous in her beauty as to seem apparelled in her wedding- garment or so powerless and extinct as to seem palled in her shroud. In either case, O, Lady, we receive but what we give, And in our life alone does nature live; Ours is her wedding-garment, ours her shroud. It were a vain endeavour, Though I should gaze for ever On that green light that lingers in the west: I may not hope from outward forms to win The passion and the life whose fountains are within. This was one, and the most common, shape of extinguished power from which Coleridge fled to the great city. But sometimes the same decay came back upon his heart in the more poignant shape of intimations and vanishing glimpses, recovered for one moment from the paradise of youth, and from fields of joy and power, over which, for him, too certainly, he felt that the cloud of night was settling for ever. Both modes of the same torment exiled him from nature; and for the same reasons he fled from poetry and all commerce with his own soul; burying himself in the profoundest abstractions from life and human sensibilities. For not to think of what I needs must feel, But to be still and patient all I can; And haply by abstruse research to steal, From my own nature, all the natural man;
  • 61. This was my sole resource, my only plan; Till that, which suits a part, infects the whole, And now is almost grown the habit of my soul. Such were, doubtless, the true and radical causes which, for the final twenty-four years of Coleridge's life, drew him away from those scenes of natural beauty in which only, at an earlier stage of life, he found strength and restoration. These scenes still survived; but their power was gone, because that had been derived from himself, and his ancient self had altered. Such were the causes; but the immediate occasion of his departure from the Lakes, in the autumn of 1810, was the favourable opportunity then presented to him of migrating in a pleasant way. Mr. Basil Montagu, the Chancery barrister, happened at that time to be returning to London, with Mrs. Montagu, from a visit to the Lakes, or to Wordsworth.[81] His travelling carriage was roomy enough to allow of his offering Coleridge a seat in it; and his admiration of Coleridge was just then fervent enough to prompt a friendly wish for that sort of close connexion (viz. by domestication as a guest under Mr. Basil Montagu's roof) which is the most trying to friendship, and which in this instance led to a perpetual rupture of it. The domestic habits of eccentric men of genius, much more those of a man so irreclaimably irregular as Coleridge, can hardly be supposed to promise very auspiciously for any connexion so close as this. A very extensive house and household, together with the unlimited licence of action which belongs to the ménage of some great Dons amongst the nobility, could alone have made Coleridge an inmate perfectly desirable. Probably many little jealousies and offences had been mutually suppressed; but the particular spark which at length fell amongst the combustible materials already prepared, and thus produced the final explosion, took the following shape:—Mr. Montagu had published a book against the use of wine and intoxicating liquors of every sort.[82] Not out of parsimony or under any suspicion of inhospitality, but in mere self-consistency and obedience to his own conscientious scruples, Mr. Montagu would not countenance the use of wine at his own table. So far all was right. But doubtless, on
  • 62. such a system, under the known habits of modern life, it should have been made a rule to ask no man to dinner: for to force men, without warning, to a single (and, therefore, thoroughly useless) act of painful abstinence, is what neither I nor any man can have a right to do. In point of sense, it is, in fact, precisely the freak of Sir Roger de Coverley, who drenches his friend the Spectator with a hideous decoction: not, as his confiding visitor had supposed, for some certain and immediate benefit to follow, but simply as having a tendency (if well supported by many years' continuance of similar drenches) to abate the remote contingency of the stone. Hear this, ye Gods of the Future! I am required to perform a most difficult sacrifice; and forty years hence I may, by persisting so long, have some dim chance of reward. One day's abstinence could do no good on any scheme: and no man was likely to offer himself for a second. However, such being the law of the castle, and that law well known to Coleridge, he nevertheless, thought fit to ask to dinner Colonel (then Captain) Pasley, of the Engineers, well known in those days for his book on the Military Policy of England, and since for his System of Professional Instruction. Now, where or in what land abides that Captain, or Colonel, or Knight-in-arms, to whom wine in the analysis of dinner is a neutral or indifferent element? Wine, therefore, as it was not of a nature to be omitted, Coleridge took care to furnish at his own private cost. And so far, again, all was right. But why must Coleridge give his dinner to the captain in Mr. Montagu's house? There lay the affront; and, doubtless, it was a very inconsiderate action on the part of Coleridge. I report the case simply as it was then generally borne upon the breath, not of scandal, but of jest and merriment. The result, however, was no jest; for bitter words ensued—words that festered in the remembrance; and a rupture between the parties followed, which no reconciliation has ever healed.
  • 63. Meantime, on reviewing this story, as generally adopted by the learned in literary scandal, one demur rises up. Dr. Parr, a lisping Whig pedant, without personal dignity or conspicuous power of mind, was a frequent and privileged inmate at Mr. Montagu's. Him now—this Parr—there was no conceivable motive for enduring; that point is satisfactorily settled by the pompous inanities of his works. Yet, on the other hand, his habits were in their own nature far less endurable than Samuel Taylor Coleridge's; for the monster smoked; —and how? How did the Birmingham Doctor[83] smoke? Not as you, or I, or other civilized people smoke, with a gentle cigar—but with the very coarsest tobacco. And those who know how that abomination lodges and nestles in the draperies of window-curtains will guess the horror and detestation in which the old Whig's memory is held by all enlightened women. Surely, in a house where the Doctor had any toleration at all, Samuel Taylor Coleridge might have enjoyed an unlimited toleration.[84] From Mr. Montagu's Coleridge passed, by favour of what introduction I never heard, into a family as amiable in manners and as benign in disposition as I remember to have ever met with. On this excellent family I look back with threefold affection, on account of their goodness to Coleridge, and because they were then unfortunate, and because their union has long since been dissolved by death. The family was composed of three members: of Mr. M——, once a lawyer, who had, however, ceased to practise; of Mrs. M——, his wife, a blooming young woman, distinguished for her fine person; and a young lady, her unmarried sister.[85] Here, for some years, I used to visit Coleridge; and, doubtless, as far as situation merely, and the most delicate attentions from the most amiable women, could make a man happy, he must have been so at this time; for both the ladies treated him as an elder brother, or as a father. At length, however, the cloud of misfortune, which had long settled upon the prospects of this excellent family, thickened; and I found, upon one of my visits to London, that they had given up their house in Berners Street, and had retired to a cottage in Wiltshire. Coleridge
  • 64. had accompanied them; and there I visited them myself, and, as it eventually proved, for the last time. Some time after this, I heard from Coleridge, with the deepest sorrow, that poor M—— had been thrown into prison, and had sunk under the pressure of his misfortunes. The gentle ladies of his family had retired to remote friends; and I saw them no more, though often vainly making inquiries about them. Coleridge, during this part of his London life, I saw constantly— generally once a day, during my own stay in London; and sometimes we were jointly engaged to dinner parties. In particular, I remember one party at which we met Lady Hamilton—Lord Nelson's Lady Hamilton—the beautiful, the accomplished, the enchantress! Coleridge admired her, as who would not have done, prodigiously; and she, in her turn, was fascinated with Coleridge. He was unusually effective in his display; and she, by way of expressing her acknowledgments appropriately, performed a scene in Lady Macbeth —how splendidly, I cannot better express than by saying that all of us who then witnessed her performance were familiar with Mrs. Siddons's matchless execution of that scene, and yet, with such a model filling our imaginations, we could not but acknowledge the possibility of another, and a different perfection, without a trace of imitation, equally original, and equally astonishing. The word magnificent is, in this day, most lavishly abused: daily I hear or read in the newspapers of magnificent objects, as though scattered more thickly than blackberries; but for my part I have seen few objects really deserving that epithet. Lady Hamilton was one of them. She had Medea's beauty, and Medea's power of enchantment. But let not the reader too credulously suppose her the unprincipled woman she has been described. I know of no sound reason for supposing the connexion between Lord Nelson and her to have been other than perfectly virtuous. Her public services, I am sure, were most eminent—for that we have indisputable authority; and equally sure I am that they were requited with rank ingratitude.
  • 65. After the household of the poor M—— s had been dissolved, I know not whither Coleridge went immediately: for I did not visit London until some years had elapsed. In 1823-24 I first understood that he had taken up his residence as a guest with Mr. Gillman, a surgeon, in Highgate. He had then probably resided for some time at that gentleman's: there he continued to reside on the same terms, I believe, of affectionate friendship with the members of Mr. Gillman's family as had made life endurable to him in the time of the M—— s; and there he died in July of the present year. If, generally speaking, poor Coleridge had but a small share of earthly prosperity, in one respect at least he was eminently favoured by Providence: beyond all men who ever perhaps have lived, he found means to engage a constant succession of most faithful friends; and he levied the services of sisters, brothers, daughters, sons, from the hands of strangers—attracted to him by no possible impulses but those of reverence for his intellect, and love for his gracious nature. How, says Wordsworth—
  • 66. ----How can he expect that others should Sow for him, reap for him, and at his call Love him, who for himself will take no thought at all? How can he, indeed? It is most unreasonable to do so: yet this expectation, if Coleridge ought not to have entertained, at all events he realized. Fast as one friend dropped off, another, and another, succeeded: perpetual relays were laid along his path in life, of judicious and zealous supporters, who comforted his days, and smoothed the pillow for his declining age, even when it was beyond all human power to take away the thorns which stuffed it. And what were those thorns?—and whence derived? That is a question on which I ought to decline speaking, unless I could speak fully. Not, however, to make any mystery of what requires none, the reader will understand that originally his sufferings, and the death within him of all hope—the palsy, as it were, of that which is the life of life, and the heart within the heart—came from opium. But two things I must add—one to explain Coleridge's case, and the other to bring it within the indulgent allowance of equitable judges:—First, the sufferings from morbid derangements, originally produced by opium, had very possibly lost that simple character, and had themselves re-acted in producing secondary states of disease and irritation, not any longer dependent upon the opium, so as to disappear with its disuse: hence, a more than mortal discouragement to accomplish this disuse, when the pains of self- sacrifice were balanced by no gleams of restorative feeling. Yet, secondly, Coleridge did make prodigious efforts to deliver himself from this thraldom; and he went so far at one time in Bristol, to my knowledge, as to hire a man for the express purpose, and armed with the power of resolutely interposing between himself and the door of any druggist's shop. It is true that an authority derived only from Coleridge's will could not be valid against Coleridge's own counter-determination: he could resume as easily as he could delegate the power. But the scheme did not entirely fail; a man
  • 67. shrinks from exposing to another that infirmity of will which he might else have but a feeble motive for disguising to himself; and the delegated man, the external conscience, as it were, of Coleridge, though destined—in the final resort, if matters came to absolute rupture, and to an obstinate duel, as it were, between himself and his principal—in that extremity to give way, yet might have long protracted the struggle before coming to that sort of dignus vindice nodus: and in fact, I know, upon absolute proof, that, before reaching that crisis, the man showed fight, and, faithful to his trust, and comprehending the reasons for it, declared that, if he must yield, he would know the reason why. Opium, therefore, subject to the explanation I have made, was certainly the original source of Coleridge's morbid feelings, of his debility, and of his remorse. His pecuniary embarrassments pressed as lightly as could well be expected upon him. I have mentioned the annuity of £150 made to him by the two Wedgwoods. One half, I believe, could not be withdrawn, having been left by a regular testamentary bequest. But the other moiety, coming from the surviving brother, was withdrawn on the plea of commercial losses, somewhere, I think, about 1815. That would have been a heavy blow to Coleridge; and assuredly the generosity is not very conspicuous of having ever suffered an allowance of that nature to be left to the mercy of accident. Either it ought not to have been granted in that shape—viz. as an annual allowance, giving ground for expecting its periodical recurrence—or it ought not to have been withdrawn. However, this blow was broken to Coleridge by the bounty of George IV, who placed Coleridge's name in the list of twelve to whom he granted an annuity of 100 guineas per annum. This he enjoyed so long as that Prince reigned. But at length came a heavier blow than that from Mr. Wedgwood: a new King arose, who knew not Joseph. Yet surely he was not a King who could so easily resolve to turn adrift twelve men of letters, many of them most accomplished men, for the sake of appropriating a sum no larger to himself than 1200 guineas—no less to some of them than the total freight of their earthly hopes?—No matter: let the deed have been
  • 68. from whose hand it might, it was done: ἑιργασται (heirgastai), it was perpetrated, as saith the Medea of Euripides; and it will be mentioned hereafter, more than either once or twice. It fell with weight, and with effect upon the latter days of Coleridge; it took from him as much heart and hope as at his years, and with his unworldly prospects, remained for man to blight: and, if it did not utterly crush him, the reason was—because for himself he had never needed much, and was now continually drawing near to that haven in which, for himself, he would need nothing; secondly, because his children were now independent of his aid; and, finally, because in this land there are men to be found always of minds large enough to comprehend the claims of genius, and with hearts, by good luck, more generous, by infinite degrees, than the hearts of Princes. Coleridge, as I now understand, was somewhere about sixty-two years of age when he died.[86] This, however, I take upon the report of the public newspapers; for I do not, of my own knowledge, know anything accurately upon that point. It can hardly be necessary to inform any reader of discernment or of much practice in composition that the whole of this article upon Mr. Coleridge, though carried through at intervals, and (as it has unexpectedly happened) with time sufficient to have made it a very careful one, has, in fact, been written in a desultory and unpremeditated style. It was originally undertaken on the sudden but profound impulse communicated to the writer's feelings by the unexpected news of this great man's death; partly, therefore, to relieve, by expressing, his own deep sentiments of reverential affection to his memory, and partly, in however imperfect a way, to meet the public feeling of interest or curiosity about a man who had long taken his place amongst the intellectual potentates of the age. Both purposes required that it should be written almost extempore: the greater part was really and unaffectedly written in that way, and under circumstances of such extreme haste as would justify the writer in pleading the very amplest privilege of licence and indulgent
  • 69. construction which custom concedes to such cases. Hence it had occurred to the writer, as a judicious principle, to create a sort of merit out of his own necessity, and rather to seek after the graces which belong to the epistolary form, or to other modes of composition professedly careless, than after those which grow out of preconceived biographies, which, having originally settled their plan upon a regular foundation, are able to pursue a course of orderly development, such as his slight sketch had voluntarily renounced from the beginning. That mode of composition having been once adopted, it seemed proper to sustain it, even after delays and interruption had allowed time for throwing the narrative into a more orderly movement, and modulating it, as it were, into a key of the usual solemnity. The qualis ab incepto processerit—the ordo prescribed by the first bars of the music predominated over all other considerations, and to such an extent that he had purposed to leave the article without any regular termination or summing up—as, on the one hand, scarcely demanded by the character of a sketch so rapid and indigested, whilst, on the other, he was sensible that anything of so much pretension as a formal peroration challenged a sort of consideration to the paper which it was the author's chief wish to disclaim. That effect, however, is sufficiently parried by the implied protest now offered; and, on other reasons, it is certainly desirable that a general glance, however cursory, should be thrown over the intellectual claims of Mr. Coleridge by one who knew him so well, and especially in a case where those very claims constitute the entire and sole justification of the preceding personal memoir. That which furnishes the whole moving reason for any separate notice at all, and forms its whole latent interest, ought not, in mere logic, to be left without some notice itself, though as rapidly executed as the previous biographical sketch, and, from the necessity of the subject, by many times over more imperfect. To this task, therefore, the writer now addresses himself; and by way of gaining greater freedom of movement and of resuming his conversational tone, he will here again take the liberty of speaking in the first person.
  • 70. If Mr. Coleridge had been merely a scholar—merely a philologist—or merely a man of science—there would be no reason apparent for travelling in our survey beyond the field of his intellect, rigorously and narrowly so called. But, because he was a poet, and because he was a philosopher in a comprehensive and a most human sense, with whose functions the moral nature is so largely interwoven, I shall feel myself entitled to notice the most striking aspects of his character (using that word in its common limited meaning), of his disposition, and his manners, as so many reflex indications of his intellectual constitution. But let it be well understood that I design nothing elaborate, nothing comprehensive or ambitious: my purpose is merely to supply a few hints and suggestions drawn from a very hasty retrospect, by way of adding a few traits to any outline which the reader may have framed to himself, either from some personal knowledge, or from more full and lively memorials. One character in which Mr. Coleridge most often came before the public was that of politician. In this age of fervent partisanship, it will, therefore, naturally occur as a first question to inquire after his party and political connexions: was he Whig, Tory, or Radical? Or, under a new classification, were his propensities Conservative or Reforming? I answer that, in any exclusive or emphatic sense, he was none of these; because, as a philosopher, he was, according to circumstances, and according to the object concerned, all of these by turns. These are distinctions upon which a cloud of delusion rests. It would not be difficult to show that in the speculations built upon the distinction of Whig and Tory, even by as philosophic a politician as Edmund Burke, there is an oversight of the largest practical importance. But the general and partisan use of these terms superadds to this πρωτον ψευδος (prôton pseudos) a second which is much more flagrant. It is this: the terms Whig or Tory, used by partisans, are taken extra gradum, as expressing the ideal or extreme cases of the several creeds; whereas, in actual life, few such cases are found realized, by far the major part of those who answer to either one or the other denomination making only an approximation (differing by infinite degrees) to the ideal or abstract
  • 71. type. A third error there is, relating to the actual extent of the several denominations, even after every allowance made for the faintest approximations. Listen to a Whig, or to a Tory, and you will suppose that the great bulk of society range under his banner: all, at least, who have any property at stake. Listen to a Radical, and you will suppose that all are marshalled in the same ranks with himself, unless those who have some private interest in existing abuses, or have aristocratic privileges to defend. Yet, upon going extensively into society as it is, you find that a vast majority of good citizens are of no party whatsoever, own no party designation, care for no party interest, but carry their good wishes by turns to men of every party, according to the momentary purpose they are pursuing. As to Whig and Tory, it is pretty clear that only two classes of men, both of limited extent, acknowledge these as their distinctions: first, those who make politics in some measure their profession or trade— whether by standing forward habitually in public meetings as leaders or as assistants, or by writing books and pamphlets in the same cause; secondly, those whose rank, or birth, or position in a city, or a rural district, almost pledges them to a share in the political struggles of the day, under the penalty of being held fainéans, truants, or even malignant recusants, if they should decline a warfare which often, perhaps, they do not love in secret. These classes, which, after all, are not numerous, and not entirely sincere, compose the whole extent of professing Whigs and Tories who make any approach to the standards of their two churches; and, generally speaking, these persons have succeeded to their politics and their party ties, as they have to their estates, viz. by inheritance. Not their way of thinking in politics has dictated their party connexions; but these connexions, traditionally bequeathed from one generation to another, have dictated their politics. With respect to the Radical or the Reformer, the case is otherwise; for it is certain that in this, as in every great and enlightened nation, enjoying an intense and fervid communication of thought through the press, there is, and must be, a tendency widely diffused to the principles of sane reform—an anxiety to probe and examine all the institutions of the land by the increasing lights of the age—and a salutary determination that no
  • 72. acknowledged abuse shall be sheltered by prescription, or privileged by its antiquity. In saying, therefore, that his principles are spread over the length and breadth of the land, the Reformer says no more than the truth. Whig and Tory, as usually understood, express only two modes of aristocratic partisanship: and it is strange, indeed, to find people deluded by the notion that the reforming principle has any more natural connexion with the first than the last. Reformer, on the other hand, to a certain extent expresses the political creed and aspect of almost every enlightened citizen: but, then, how? Not, as the Radical would insinuate, as pledging a man to a specific set of objects, or to any visible and apparent party, having known leaders and settled modes of action. British society, in its large majority, may be fairly described as Reformers, in the sense of being favourably disposed to a general spirit of ventilation and reform carried through all departments of public business, political or judicial; but it is so far from being, therefore, true that men in general are favourably disposed to any known party, in or out of Parliament, united for certain objects and by certain leaders, that, on the contrary, this reforming party itself has no fixed unity, and no generally acknowledged heads. It is divided both as to persons and as to things: the ends to be pursued create as many schisms as the course of means proper for the pursuit, and the choice of agents for conducting the public wishes. In fact, it would be even more difficult to lay down the ideal standard of a Reformer, or his abstract creed, than of a Tory: and, supposing this done, it would be found, in practice, that the imperfect approximations to the pure faith would differ by even broader shades as regarded the reforming creed than as regarded that of the rigorous or ultra Tory. With respect to Mr. Coleridge: he was certainly a friend to all enlightened reforms; he was a friend, for example, to Reform in Parliament. Sensible as he was of the prodigious diffusion of knowledge and good sense amongst the classes immediately below the gentry in British society, he could not but acknowledge their right to a larger and a less indirect share of political influence. As to the plan, and its extent, and its particular provisions,—upon those he
  • 73. hesitated and wavered; as other friends to the same views have done, and will continue to do. The only avowed objects of modern Reformers which he would strenuously have opposed, nay, would have opposed with the zeal of an ancient martyr, are those which respect the Church of England, and, therefore, most of those which respect the two Universities of Oxford and Cambridge. There he would have been found in the first ranks of the Anti-Reformers. He would also have supported the House of Peers, as the tried bulwark of our social interests in many a famous struggle, and sometimes, in the hour of need, the sole barrier against despotic aggressions on the one hand, and servile submissions on the other. Moreover, he looked with favour upon many modes of aristocratic influence as balances to new-made commercial wealth, and to a far baser tyranny likely to arise from that quarter when unbalanced. But, allowing for these points of difference, I know of little else stamped with the general seal of modern reform, and claiming to be a privileged object for a national effort, which would not have had his countenance. It is true,—and this I am sensible will be objected,— that his party connexions were chiefly with the Tories; and it adds a seeming strength to this objection, that these connexions were not those of accident, nor those which he inherited, nor those of his youthful choice. They were sought out by himself, and in his maturer years; or else they were such as sought him for the sake of his political principles; and equally, in either case, they argued some affinity in his political creed. This much cannot be denied. But one consideration will serve greatly to qualify the inference from these facts. In those years when Mr. Coleridge became connected with Tories, what was the predominating and cardinal principle of Toryism, in comparison with which all else was willingly slighted? Circumstances of position had thrown upon the Tories the onus of a great national struggle, the greatest which History anywhere records, and with an enemy the most deadly. The Whigs were then out of power: they were therefore in opposition; and that one fact, the simple fact, of holding an anti-ministerial position, they allowed, by a most fatal blunder, to determine the course of their foreign politics. Napoleon was to be cherished simply because he was a
  • 74. thorn in Mr. Pitt's side. So began their foreign policy—and in that pettiest of personal views. Because they were anti-ministerial, they allowed themselves passively to become anti-national. To be a Whig, therefore, in those days, implied little more than a strenuous opposition to foreign war; to be a Tory pledged a man to little more than war with Napoleon Bonaparte. And this view of our foreign relations it was that connected Coleridge with Tories,—a view which arose upon no motives of selfish interest (as too often has been said in reproach), but upon the changes wrought in the spirit of the French Republic, which gradually transmuted its defensive warfare (framed originally to meet a conspiracy of kings crusading against the new-born democracy of French institutions, whilst yet in their cradle) into a warfare of aggression and sanguinary ambition. The military strength evoked in France by the madness of European kings had taught her the secret of her own power—a secret too dangerous for a nation of vanity so infinite, and so feeble in all means of moral self-restraint. The temptation to foreign conquest was too strong for the national principles; and, in this way, all that had been grand and pure in the early pretensions of French Republicanism rapidly melted away before the common bribes of vulgar ambition. Unoffending states, such as Switzerland, were the first to be trampled under foot; no voice was heard any more but the brazen throat of war; and, after all that had been vaunted of a golden age, and a long career opened to the sceptre of pure political justice, the clouds gathered more gloomily than ever; and the sword was once more reinstated, as the sole arbiter of right, with less disguise and less reserve than under the vilest despotism of kings. The change was in the French Republicans, not in their foreign admirers; they, in mere consistency, were compelled into corresponding changes, and into final alienation of sympathy, as they beheld, one after one, all titles forfeited by which that grand explosion of pure democracy had originally challenged and sustained their veneration. The mighty Republic had now begun to revolve through those fierce transmigrations foreseen by Burke, to every one of which, by turns, he had denounced an inevitable purification by fire and blood: no trace remained of her primitive character: and of
  • 75. that awful outbreak of popular might which once had made France the land of hope and promise to the whole human race, and had sounded a knell to every form of oppression or abuse, no record was to be found, except in the stupendous power which cemented its martial oligarchy. Of the people, of the democracy—or that it had ever for an hour been roused from its slumbers—one sole evidence remained; and that lay in the blank power of destruction, and its perfect organization, which none but a popular movement, no power short of that, could have created. The people, having been unchained, and as if for the single purpose of creating a vast system of destroying energies, had then immediately recoiled within their old limits, and themselves become the earliest victim of their own stratocracy. In this way France had become an object of jealousy and alarm. It remained to see to what purpose she would apply her new energies. That was soon settled; her new-born power was wielded from the first by unprincipled and by ambitious men; and, in 1800, it fell under the permanent control of an autocrat, whose unity of purpose, and iron will, left no room for any hope of change. Under these circumstances, under these prospects, coupled with this retrospect, what became the duty of all foreign politicians? of the English above all, as natural leaders in any hopeful scheme of resistance? The question can scarcely be put with decency. Time and season, place or considerations of party, all alike vanished before an elementary duty to the human race, which much transcended any duty of exclusive patriotism. Plant it, however, on that narrower basis, and the answer would have been the same for all centuries, and for every land under a corresponding state of circumstances. Of Napoleon's real purposes there cannot now be any reasonable doubt. His confessions—and, in particular, his indirect revelations at St. Helena—have long since removed all demurs or scruples of scepticism. For England, therefore, as in relation to a man bent upon her ruin, all distinctions of party were annihilated—Whig and Tory were merged and swallowed up in the transcendent duties of patriots, Englishmen, lovers of liberty. Tories, as Tories, had here no peculiar or separate duties—none which belonged to their separate
  • 76. creed in politics. Their duties were paramount; and their partisanship had here no application—was perfectly indifferent, and spoke neither this way nor that. In one respect only they had peculiar duties, and a peculiar responsibility; peculiar, however, not by any difference of quality, but in its supreme degree; the same duties which belonged to all, belonged to them by a heavier responsibility. And how, or why? Not as Tories had they, or could they have, any functions at all applying to this occasion; it was as being then the ministerial party, as the party accidentally in power at the particular crisis: in that character it was that they had any separate or higher degree of responsibility; otherwise, and as to the kind of their duty apart from this degree, the Tories stood in the same circumstances as men of all other parties. To the Tories, however, as accidentally in possession of the supreme power, and wielding the national forces at that time, and directing their application—to them it was that the honour belonged of making a beginning: on them had devolved the privilege of opening and authorizing the dread crusade. How and in what spirit they acquitted themselves of that most enviable task— enviable for its sanctity, fearful for the difficulty of its adequate fulfilment—how they persevered, and whether, at any crisis, the direst and most ominous to the righteous cause, they faltered or gave sign of retreating—History will tell—History has already told. To the Whigs belonged the duty of seconding their old antagonists: and no wise man could have doubted that, in a case of transcendent patriotism, where none of those principles could possibly apply by which the two parties were divided and distinguished, the Whigs would be anxious to show that, for the interests of their common country, they could cheerfully lay aside all those party distinctions, and forget those feuds which now had no pertinence or meaning. Simply as Whigs, had they stood in no other relation, they probably would have done so. Unfortunately, however, for their own good name and popularity in after times, they were divided from the other party, not merely as Whigs opposed to Tories, but also upon another and a more mortifying distinction, which was not, like the first, a mere inert question of speculation or theory, but involved a vast practical difference of honours and emoluments:—they were divided,
  • 77. I say, on another and more vexatious principle, as the Outs opposed to the Ins. Simply as Whigs, they might have coalesced with the Tories quoad hoc, and merely for this one purpose. But, as men out of power, they could not coalesce with those who were in. They constituted his Majesty's Opposition; and, in a fatal hour, they determined that it was fitting to carry their general scheme of hostility even into this sacred and privileged ground. That resolution once taken, they found it necessary to pursue it with zeal. The case itself was too weighty and too interesting to allow of any moderate tone for the abetters or opposers. Passion and personal bitterness soon animated the contest: violent and rash predictions were hazarded—prophecies of utter ruin and of captivity for our whole army were solemnly delivered: and it soon became evident, as indeed mere human infirmity made it beforehand but too probable, that, where so much personal credit was at stake upon the side of our own national dishonour, the wishes of the prophet had been pledged to the same result as the credit of his political sagacity. Many were the melancholy illustrations of the same general case. Men were seen fighting against the evidences of some great British victory with all the bitterness and fierce incredulity which usually meet the first rumours of some private calamity: that was in effect the aspect in their eyes of each national triumph in its turn. Their position, connected with the unfortunate election made by the Whig leaders of their tone, from the very opening of the contest, gave the character of a calamity for them and for their party to that which to every other heart in Britain was the noblest of triumphs in the noblest of causes; and, as a party, the Whigs mourned for years over those events which quickened the pulses of pleasure and sacred exultation in every other heart. God forbid that all Whigs should have felt in this unnatural way! I speak only of the tone set by the Parliamentary leaders. The few who were in Parliament, and exposed to daily taunts from the just exultation of their irritated opponents, had their natural feelings poisoned and envenomed. The many who were out of Parliament, and not personally interested in this warfare of the Houses, were left open to natural influences of
  • 78. Welcome to our website – the perfect destination for book lovers and knowledge seekers. We believe that every book holds a new world, offering opportunities for learning, discovery, and personal growth. That’s why we are dedicated to bringing you a diverse collection of books, ranging from classic literature and specialized publications to self-development guides and children's books. More than just a book-buying platform, we strive to be a bridge connecting you with timeless cultural and intellectual values. With an elegant, user-friendly interface and a smart search system, you can quickly find the books that best suit your interests. Additionally, our special promotions and home delivery services help you save time and fully enjoy the joy of reading. Join us on a journey of knowledge exploration, passion nurturing, and personal growth every day! ebookbell.com