Document not found! Please try again

Elements of Discrete Mathematics

140 downloads 0 Views 3MB Size Report
Sep 16, 2017 - of Mathematics, Mahatma Gandhi Kashi Vidyapith, Varanasi. ..... Since fourth and sixth column are exactly same. ...... An important application of Boolean algebra is in the analysis of ...... finite, therefore after finite number of steps, we obtain an Euler line. 2. We illustrate it by following figure: illus.pdf a b c d e.
Elements of Discrete Mathematics Akhilesh Chandra Yadav Assistant Professor Department of Mathematics M G Kashi Vidyapith, Varanasi September 16, 2017

To My Parents

Preface

This book is based on a B.Sc.III course given regularly by me at Department of Mathematics, Mahatma Gandhi Kashi Vidyapith, Varanasi. It is written specially according to the unified syllabus of U.P. to fulfil the requirements of B.A/B.Sc. III students. I have tried my best to keep the book free from misprints. I will be thankful to the readers who point out errors and give suggestions to improve the book. I am grateful to my department and the University for providing me facility up to certain extent. Since I borrowed some time of my family therefore I am grateful to my family. I dedicate this book to my parents. I will wish thank to the publisher for presenting the book in its present form. Akhilesh Chandra Yadav

iv

Contents

1 Logic 1.1 Statements . . . . . . . . . . . . . . . . . 1.1.1 Truth values . . . . . . . . . . . . 1.2 Logical Connectives . . . . . . . . . . . . 1.2.1 Conjunction . . . . . . . . . . . . 1.2.2 Disjunction . . . . . . . . . . . . 1.2.3 Negation . . . . . . . . . . . . . . 1.2.4 Conditional Statement . . . . . . 1.2.5 Implication . . . . . . . . . . . . 1.2.6 Bi-Conditional Statement . . . . 1.2.7 Equivalence . . . . . . . . . . . . 1.3 Tautology and Contradiction . . . . . . . 1.4 Arguments and Fallacy . . . . . . . . . . 1.5 Law of Duality . . . . . . . . . . . . . . 1.6 Propositional functions . . . . . . . . . . 1.6.1 Universal Quantifier . . . . . . . 1.6.2 Existential Quantifier . . . . . . . 1.6.3 Negation of quantified statements 1.7 Mathematical Proof . . . . . . . . . . . . 1.7.1 Methods of Proof . . . . . . . . . 1.8 Miscellaneous Examples . . . . . . . . . v

. . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . .

1 1 2 3 3 3 4 4 5 5 6 7 10 12 13 13 14 15 15 16 18

vi 2

CONTENTS Relations And Functions 2.1 Ordered Pair, Cartesian Product 2.2 Relations . . . . . . . . . . . . . . 2.3 Composition of Relations . . . . . 2.4 Equivalence Relations . . . . . . . 2.5 Functions . . . . . . . . . . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

21 21 22 23 26 28

3 Lattices 3.1 Partial Order relations . . . . . . . . . . . . . . . . . . 3.2 Product Sets and Order relation . . . . . . . . . . . . . 3.3 Hasse diagram of Poset . . . . . . . . . . . . . . . . . . 3.4 Isomorphic Posets . . . . . . . . . . . . . . . . . . . . . 3.5 Lattices . . . . . . . . . . . . . . . . . . . . . . . . . . 3.5.1 Properties . . . . . . . . . . . . . . . . . . . . . 3.5.2 Complete, Bounded and Complemented Lattices 3.6 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

31 31 36 36 40 40 43 44 48

4 Boolean Algebra 4.1 Properties of Boolean Algebra . . . . . . . . . . . . . . . 4.2 Subalgebras And Isomorphisms . . . . . . . . . . . . . . 4.3 Boolean algebra as a lattice . . . . . . . . . . . . . . . . 4.4 Representation theorem . . . . . . . . . . . . . . . . . . 4.5 Conjunctive and Disjunctive normal forms . . . . . . . . 4.5.1 Disjunctive normal form . . . . . . . . . . . . . . 4.5.2 Conjunctive normal form . . . . . . . . . . . . . 4.6 Logic Gates . . . . . . . . . . . . . . . . . . . . . . . . . 4.7 Logic Circuits . . . . . . . . . . . . . . . . . . . . . . . . 4.8 Minimization of Boolean expressions and Karnaugh Maps 4.9 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

49 52 56 57 58 59 62 64 66 68 70 76

5 Combinatorics 5.1 Basic counting principles . . . . . . . . . . . . . . . . . . . . . 5.2 Permutations . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.3 Combinations . . . . . . . . . . . . . . . . . . . . . . . . . . .

79 79 83 87

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

6 Numeric functions and Recurrence relations 93 6.1 Big-oh or Asymptotic dominance . . . . . . . . . . . . . . . . 95 6.1.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . 95

CONTENTS 6.2 6.3

6.4 6.5

vii

Generating functions . . . . . . . . . . . . . . . . . . . . . . Recurrence relation and its solution . . . . . . . . . . . . . . 6.3.1 Homogeneous linear recurrence relations . . . . . . . 6.3.2 Linear non-homogeneous recurrence relations with constant coefficients . . . . . . . . . . . . . . . . . . . . 6.3.3 Solution of recurrence relation by the method of generating function . . . . . . . . . . . . . . . . . . . . . Combinatorial problems And Generating functions. . . . . . Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

7 Graphs 7.1 Definition and examples . . . . . 7.1.1 Bipartite Graphs . . . . . 7.1.2 Subgraphs . . . . . . . . . 7.1.3 Edge and vertex deletion . 7.1.4 Operation on graphs . . . 7.1.5 Complementary Graph . . 7.2 Isomorphisms . . . . . . . . . . . 7.3 Walk, Paths and Circuits . . . . . 7.4 Euler Graph . . . . . . . . . . . . 7.4.1 Konigsberg bridge problem 7.4.2 Euler graph . . . . . . . . 7.5 Hamilton graphs . . . . . . . . . 7.6 Planar Graphs and Colorings . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

8 Trees 8.1 Trees and its properties . . . . . . . . . . . . . . . . . 8.2 Rooted Trees . . . . . . . . . . . . . . . . . . . . . . 8.3 Tree Traversal or Tree Searching . . . . . . . . . . . . 8.3.1 Preorder Algorithm . . . . . . . . . . . . . . . 8.3.2 Inorder Algorithm . . . . . . . . . . . . . . . 8.3.3 Postorder Algorithm . . . . . . . . . . . . . . 8.4 Representation of algebraic expression as binary tree 8.5 Binary Search Tree or Sort Tree . . . . . . . . . . . . 8.5.1 Growing the sort tree . . . . . . . . . . . . . . 8.5.2 Listing The Elements of a Sort Tree . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . .

. 96 . 99 . 100 . 102 . 103 . 105 . 107

. . . . . . . . . . . . .

111 . 111 . 119 . 121 . 122 . 122 . 123 . 124 . 124 . 128 . 128 . 128 . 131 . 132

. . . . . . . . . .

139 . 139 . 143 . 146 . 147 . 149 . 150 . 154 . 155 . 155 . 157

viii 9 Finite State Machines and Finite Automata 9.1 Machine Equivalence and Machine Minimization 9.1.1 Minimization Process . . . . . . . . . . . 9.1.2 Non-deterministic finite state machine . 9.1.3 Non-deterministic to Deterministic FSM 9.2 Machines with no output . . . . . . . . . . . . 9.2.1 Deterministic finite automata . . . . . . 9.2.2 Non-deterministic finite automata . . . . 9.2.3 NFA as Language recognizer . . . . . . . 9.2.4 Minimization process . . . . . . . . . . . 9.3 Exercises . . . . . . . . . . . . . . . . . . . . . .

CONTENTS

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

159 . 164 . 166 . 169 . 170 . 171 . 171 . 174 . 176 . 181 . 183

CHAPTER

1

Logic

This chapter is devoted to the foundation of mathematics. First we give the notion of simple and compound statements and discuss about their connectives. After that we discuss their truth values and the equivalence of two statements. We gave the notion of arguments and their validity. We also discuss the methods of proofs.

1.1

Statements

We use symbolic language to express mathematical statements. The analysis of symbolic language is termed as logic. Consider the following sentences: (1). Man is the most intelligent creature on the earth. (2). Priya is a girl and Ansh is a boy. (3). Shreya is an honest girl or Ansh is a boy. (4). Sun rises in the east. (5). Every river has an origin. 1

2

CHAPTER 1. LOGIC

(6). There exists a man who is immortal. (7). If Divyansh works hard then he will pass. (8). Ice is cold. (9) Tea is hot. (10). Ramanujan was an Indian Mathematician. (11). Can Ramji Lal be a Vice Chancellor? (12). What are you doing? (13). Who is the present President of India? (14). Who am I? (15). Bring me a glass of water. From above sentences, we see that some sentences (assertive sentence) may assert either true or false. Definition 1.1.1. A sentence which asserts either true or false, is defined as a statement or proposition. Thus, a statement asserts either true or false. From above sentences, we see that sentences from 1 to 10 are statements.

1.1.1

Truth values

As we read that every statement asserts either true or false. Being true or false is called the truth value of the statement. If a statement asserts true then its truth value is denoted by T and if it asserts false then its truth value is denoted by F . From this discussion, we observe that we assign one and only one of the truth values ‘T ’ or ‘F ’ to each statement.

1.2. LOGICAL CONNECTIVES

1.2

3

Logical Connectives

Sentences are connected by connectives namely ‘and0 , ‘or0 , ‘if.....then...0 , ‘if andonlyif 0 (briefly if f ), ‘implies0 and ‘not0 . This also determines some operations on statements. These operations or connectives are termed as Propositional or Logical Connectives. The rules which govern the formation of valid statements are called the Propositional Calculus [1]. A statement which is free from any of the propositional connectives is called a simple(atomic) statement. A statement which is not simple, is called a compound statement. Thus, a statement is either a simple statement or formed by several simple statements using propositional connectives. These simple statements are called atomic parts of the given statement. The truth value of a compound statement depends on the truth value of its atomic parts.

1.2.1

Conjunction

The conjunction of a statement P and a statement Q is given by ‘P and Q’. It is denoted by ‘P ∧ Q’ and we read it as P wedge Q (P meet Q). The truth value of the statement P ∧ Q is T if the truth value of both statements is T and otherwise is F . Thus, the truth table of P ∧ Q is P T T F F

Q T F T F

P ∧Q T F F F

Example 1.2.1. ‘Priya is a brave girl and Ansh is an honest boy’ is an example of conjunction of two statements: ‘Priya is a brave girl’ and ‘Ansh is an honest boy’.

1.2.2

Disjunction

The disjunction of two statements P and Q is given by P or Q and is denoted by P ∨ Q. We read P ∨ Q as P vee Q (P join Q). The truth value of the statement P ∨ Q is T if at least one of P and Q have the truth value T and F otherwise. Thus, the truth table of P ∨ Q is

4

CHAPTER 1. LOGIC P T T F F

Q T F T F

P ∨Q T T T F

Example 1.2.2. ‘Priya is a brave girl or Ansh is an honest boy’ is an example of disjunction of two statements: ‘Priya is a brave girl’ and ‘Ansh is an honest boy’.

1.2.3

Negation

The negation of a statement P is denoted by ‘-P ’ or ∼ P . Usually ‘not’ is used at a suitable place to obtain the negation of a statement. The truth value of the statement −P is T if the truth value of the statement P is F , and the truth value of the statement −P is F if the truth value of the statement P is T . Thus, the truth table of −P is P T F

−P F T

For example, the negation ‘-(Priya will go to school)’ of the statement ‘Priya will go to school’ is ‘Priya will not go to school’. It is also written as ‘It is not the case that Priya will go to school’. Thus, -(Priya will go to school) is ‘Priya will not go to school’.

1.2.4

Conditional Statement

A statement of the form ‘If P then Q’ where P and Q are statements is called a conditional statement. The statement P is called the antecedent or hypothesis and Q is called the consequent or the conclusion. The statement ‘If P then Q’ is expressed as Q is a necessary condition for P . It is also expressed as P is a sufficient condition for Q. The truth value of the statement ”If P then Q” is false only when P is true and Q is false.. Thus, the truth table of ‘If P then Q’ is

1.2. LOGICAL CONNECTIVES P T T F F

Q T F T F

5 If P then Q T F T T

Observe that the statement ‘If Shreya will get CGPA 10 then I will give her a watch’ is an example of a conditional statement where ‘Shreya will get CGPA 10’ is an hypothesis and ‘I will give her a watch’ is a conclusion.

1.2.5

Implication

A statement of the form P implies Q (in symbol P ⇒ Q) is called an implication. The statement P ⇒ Q is false only when P is true and Q is false. Thus, the truth table of P implies Q is P T T F F

Q P ⇒Q T T F F T T F T

Here again P is called the hypothesis and Q is called the conclusion.

1.2.6

Bi-Conditional Statement

A statement of the form ‘P if and only if Q’ where P and Q are statements is called a bi-conditional statement. The statement ‘P if and only if Q’ is expressed as P is a necessary as well as sufficient condition for Q. The truth value of the statement ‘P if and only if Q’ is true if either both are true or both are false simultaneously. Thus the truth table of ‘P if and only if Q’ is P T T F F

Q If P then Q If Q then P T T T F F T T T F F T T

P if and only if Q T F F T

One may easily observe that the truth table of P ⇔ Q is same as that of (P ⇒ Q) ∧ (Q ⇒ P ).

6

CHAPTER 1. LOGIC

Definition 1.2.3. Let ‘P ⇒ Q’ be a conditional statement. Then its converse statement is defined by the statement ‘Q ⇒ P ’. The inverse of the statement ‘P ⇒ Q’ is defined by the statement ‘−P ⇒ −Q’. The contrapositive of the statement ‘P ⇒ Q’ is defined by the statement ‘−Q ⇒ −P ’. The truth table of these statements are:

statement statement Conditional Converse P Q P ⇒Q Q⇒P T T T T T F F T F T T F F F T T

Inverse −P ⇒ −Q T F F T

Contrapositive −Q ⇒ −P T F T T

From the table it is clear that third and sixth column are exactly same. Thus the truth tables of P ⇒ Q and −Q ⇒ −P are same. Indeed these two are logically equivalent (see next section).

1.2.7

Equivalence

Two statements are said to be logically equivalent if they have identical truth tables. Observe that the truth tables ‘P implies Q’ and ‘if P then Q’ are identical. Thus these two statements are equivalent statements. If two statements P and Q are equivalent then we write P = Q. The conjunction of the statements ‘P ⇒ Q’ and ‘Q ⇒ P ’ is the statement ‘P ⇔ Q’. Example 1.2.4. Consider the following truth table for the statements ‘P ⇔ Q’ and ‘P iff Q’ : P T T F F

Q T F T F

P ⇔ Q P iff Q T T F F F F T T

Since the truth tables of these statements are same, therefore (P ⇔ Q) = (P if f Q. Indeed, a statement of the form ‘P if and only if Q’ (briefly ”P iff Q”) is called an Equivalence.

1.3. TAUTOLOGY AND CONTRADICTION

7

Theorem 1.2.5. (Negation of conjunction) −(P ∧ Q) = (−P ) ∨ (−Q) Proof: Consider the following truth table: P T T F F

Q −P T F F F T T F T

−Q F T F T

P ∧Q T F F F

−(P ∧ Q) F T T T

(−P ) ∨ (−Q) F T T T

From the table we see that −(P ∧ Q) = (−P ) ∨ (−Q) and so −(P ∧ Q) ⇔ (−P ) ∨ (−Q) is a tautology. 2 Using truth tables, we have the following: Theorem 1.2.6. Let p, q, r be any three statements. Then we have the following 1. (Involutory law). −(−p) = p. 2. (De Morgan’s law). −(p ∨ q) = (−p) ∧ (−q) and −(p ∧ q) = (−p) ∨ (−q). 3. (Associative law). (p∧q)∧r = p∧(q ∧r) and p∨(q ∨r) = (p∨q)∨r. 4. (Idempotent law). p ∧ p = p and p ∨ p = p. 5. (Commutative law). p ∧ q = q ∧ p and p ∨ q = q ∨ p. 6. (Distributive law). p ∧ (q ∨ r) = (p ∧ q) ∨ (p ∧ r) and p ∨ (q ∧ r) = (p ∨ q) ∧ (p ∨ r). Proof: It is left as an exercise for readers. 2 Exercise 1.2.7. Let p and q be any two statements. Prove that (p ⇒ q) = (−p ∨ q).

1.3

Tautology and Contradiction

Definition 1.3.1. A compound statement is called a Tautology if it’s truth value is always T irrespective of the truth values of it’s atomic parts. It is

8

CHAPTER 1. LOGIC

denoted by t. A compound statement is called a contradiction if it’s truth value is always F irrespective of the truth values of it’s atomic parts. It is denoted by f . Observe that the negation of a tautology is a contradiction and negation of a contradiction is a tautology. One may easily observe that if two statements P and Q are equivalent, that is; if P = Q then P ⇔ Q is a tautology (Prove it by using truth table). V Example 1.3.2. (Law of Syllogism) ‘[(P ⇒ Q) (Q ⇒ R)] ⇒ (P ⇒ R)’ is a tautology. Thus if P ⇒ Q and Q ⇒ R are tautologies, then P ⇒ R is also a tautology. W W Example 1.3.3. The statement (P Q) ⇔ (Q P ) is a tautology. For, W W W W P Q P Q Q P (P Q) ⇔ (Q P ) T T T T T T F T T T F T T T T F F F F T W From the table it is clear that the truth values of statement (P Q) ⇔ W (Q PW) is always TW, hence it is a tautology.WAlso observe that the columns W of (P Q) and (Q P ) are same. Thus (Q P ) = (P Q). W Example 1.3.4. The statement (P Q) ∧ −P ⇒ Q is a tautology. For, consider the following truth table:

P T T F F

W Q P Q −P T T F F T F T T T F F T

(P

W

Q) F F T F

V

−P

[(P

W

Q)

V

−P ] ⇒ Q

T T T T

W From the table it is clear that the column of (P Q) ∧ −P ⇒ Q is always T which is independent from the truth value of its atomic parts. Example 1.3.5. (Contrapositive) The statement (P ⇒ Q) ⇔ (−Q ⇒ −P ) is a tautology. For, we consider the following truth table:

1.3. TAUTOLOGY AND CONTRADICTION P T T F F

Q P ⇒ Q −Q −P T T F F F F T F T T F T F T T T

−Q ⇒ −P T F T T

9

(P ⇒ Q) ⇔ (−Q ⇒ −P ) T T T T

From the truth table it is clear that the statement (P ⇒ Q) ⇔ (−Q ⇒ −P ) has a truth value T irrespective of its atomic parts, hence it is a tautology. Observe also that (P ⇒ Q) = (−Q ⇒ −P ) (Logically equivalent). The statement [−Q ⇒ −P ] is called a contrapositive statement of the statement [P ⇒ Q]. Example 1.3.6. (De Morgan Law) The statement −(P ∨Q) ⇔ (−P ∧−Q) is a tautology and −(P ∨ Q) = (−P ∧ −Q). For, we consider the following truth table:

P T T F F

Q P ∨ Q −(P ∨ Q) −P T T F F F T F F T T F T F F T T

−Q −P ∧ −Q −(P ∨ Q) ⇔ (−P ∧ −Q) F F T T F T F F T T T T

Thus −(P ∨ Q) = (−P ∧ −Q) and the statement −(P ∨ Q) ⇔ (−P ∧ −Q) is a tautology. Similarly, −(P ∧ Q) = −P ∨ −Q. Example 1.3.7. The statement P ∨ −P is a tautology and P ∧ −P is a contradiction. For, we make the following truth table: −P F T

W

P ∧ −P F F W Since the truth value of the statement P −P is always T and the truth values of the statement P ∧ −P is always F . Hence P ∨ Q is a tautology and P ∧ −P is a contradiction. P T F

P

−P T T

10

CHAPTER 1. LOGIC

Example 1.3.8. (Negation of Implication). −(P ⇒ Q) = (P ∧ −Q) V and the statement −(P ⇒ Q) ⇔ (P −Q) is a tautology. For, consider the following truth table: P T T F F

Q P ⇒ Q −(P ⇒ Q) T T F F F T T T F F T F

−Q F T F T

P

V

−Q −(P ⇒ Q) ⇔ (P F T T T F T F T

V

−Q)

Since fourth and sixth column are exactly same. Therefore statements V −(P ⇒ Q) and −(P ⇒ Q) are logically equivalent, i.e; −(P ⇒ Q) = (P −Q). V From the seventh column, it follows that the statement −(P ⇒ Q) ⇔ (P −Q) is a tautology. W Exercise 1.3.9. Prove that ‘P =⇒ Q’ is logically equivalent to ‘−P Q’.

1.4

Arguments and Fallacy

Definition 1.4.1. If a given set of statements (propositions) p1 , p2 , . . . , pn determines a new statement q then this assertion is known as arguments. The given set of statements p1 , p2 , . . . , pn are called premises and the new statement q is called conclusion. It is denoted by p1 , p2 , . . . , pn ` q The symbol ` is known as ‘turnsile’. Thus the statement p1 , p2 , . . . , pn ` q is read as ‘p1 , p2 , . . . , pn turnsile q’. An argument is called a valid statement if q is true only when all premises are true simultaneously. Using truth table, it also follows that the argument p1 , p2 , . . . , pn ` q is a valid statement if the statement p1 ∧p2 ∧. . .∧pn ⇒ q is a tautology. An argument is called fallacy if it is not a valid argument. Thus an argument is fallacy if all premises p1 , p2 , ...pn are true simultaneously but q is false. In otherwords, the negation of a valid statement is fallacy. Since a statement p1 , p2 , . . . , pn ` q is a valid statement if the statement p1 ∧p2 ∧. . .∧pn ⇒ q is a tautology and negation of a tautology is a contradiction. Thus the

1.4. ARGUMENTS AND FALLACY

11

argument p1 , p2 , . . . , pn ` q is a fallacy if the statement p1 ∧p2 ∧. . .∧ pn ⇒ q is a contradiction. Using truth tables, One may easily observe the following: Theorem 1.4.2. Let p be a statement, t be a tautology and f be a contradiction. Then we have 1. (Identity law). p ∨ t = t, p ∨ f = p and p ∧ t = p; p ∧ f = f . 2. (Complement law). p ∨ −p = t; −(−p) = p and p ∧ −p = f ; −f = t. 3. (Absorption Law). p ∨ (p ∧ q) = p and p ∧ (p ∨ q) = p Theorem 1.4.3. (Law of Detachment or Modus Ponens) The argument [p, p ⇒ q] ` q is valid. Proof: Using truth table one may easily observe that [p ∧ (p ⇒ q)] ⇒ q is a tautology. Thus the above argument is valid. 2 Theorem 1.4.4. (Modus Tollen) The argument [−q, p ⇒ q] ` −p is valid. Proof: Using truth table one may easily observe that [−q ∧ (p ⇒ q)] ⇒ −p is a tautology. Thus the above argument is valid. 2 Theorem 1.4.5. (Law of syllogism or Law of transitivity ) The argument [(p ⇒ q) ∧ (q ⇒ r)] ` (p ⇒ r) is a valid statement. Proof: Consider the following truth table: [(p ⇒ q) ∧ (q ⇒ r)] ⇒ (p ⇒ r) T T T T T T T T T T F T F F F T T F T F T F T T T F F F T F F T F T T T T T T T F T F T F F T T F F T T T T T T F F F T T T T T From the truth table it is clear that the statement [(p ⇒ q) ∧ (q ⇒ r)] ⇒ (p ⇒ r) is a tautology. Thus the argument [(p ⇒ q) ∧ (q ⇒ r)] ` (p ⇒ r) is a valid statement. 2 p

q

r

p⇒q

q⇒r

(p ⇒ q) ∧ (q ⇒ r)

p⇒r

12

CHAPTER 1. LOGIC

Example 1.4.6. The argument [p, p ⇒ q, q ⇒ r] ` r is valid. For, using truth table, one can easily prove that the given argument is valid. We can prove it without using truth table as below p ∧ (p ⇒ q) ∧ (q ⇒ r) = [p ∧ (p ⇒ q)] ∧ (q ⇒ r) ` q ∧ (q ⇒ r) (using modus ponen) ` r (using modus ponen) Definition 1.4.7. A set C of connectives is called functionally complete if every statement can be expressed by an equivalent statement using members of C. For example; the sets {∨, −} and {∧, −} are functionally complete but the sets {∨}, {∧} and {∨, ∧} are not functionally complete. Example 1.4.8. Express the statement p ⇒ q in equivalent statement using connectives − and ∨ only. Solution: Observe that (p ⇒ q) = −p ∨ q.

1.5

Law of Duality

In this section we consider those statements which contain the connectives ∧, ∨ and − only (Every statement can be expressible as combination of connectives ∧, ∨ and − only). Definition 1.5.1. (Dual of statement) A statement q is called dual of given statement p if q is obtained from p by replacing ∧ by ∨, ∨ by ∧, t by f and f by t. We write q = p∗ , the dual of p. Thus the dual of p ∧ q is p ∨ q. Exercise 1.5.2. Find duals of the following: 1. (p ∨ q) ∧ r and (p ∧ q) ∧ t, 2. (p ∧ t) ∨ (f ∨ p) = f . 3. p ∧ (q ∨ r) = (p ∧ q) ∨ (p ∧ r). Principle of Duality: It states that if two statements are equal then their dual are also equal.

1.6. PROPOSITIONAL FUNCTIONS

1.6

13

Propositional functions

Definition 1.6.1. Let A be a given set. A propositional function (or a condition) defined on A is an expression p(x) which has the property that p(a) is true or false for each x = a ∈ A. Thus, p(x) is a statement for each x ∈ A. The set A is called the domain of p(x), and the set Tp of elements of A for which p(a) is true is called the truth set of p(x). In other words, Tp = {x|x ∈ A, p(x) is true}. A propositional function is also termed as predicate or an open sentence. Frequently, when A is some set of numbers, the condition p(x) has the form of an equation or inequality involving the variable x. Example 1.6.2. Let p(x) be propositional function defined on the set N of positive integers. (a) If p(x) is ‘x + 2 > 6’. Then Tp = {5, 6, 7, 8, ...} is the set consisting of all integers greater than 4. (b) If p(x) is x2 < 0. Then it’s truth set is the empty set ∅, i.e; p(x) is not true for any integer in N. (c) If p(x) is x + 1 > 1. Then it’s truth set is N,i.e; p(x) is true for every element in N. Remark 1.6.3. The above example shows that if p(x) is a propositional function defined on a set A then p(x) may be true for all x ∈ A, for some x ∈ A, or for no x ∈ A. The next two subsections discuss quantifiers related to such propositional functions.

1.6.1

Universal Quantifier

Definition 1.6.4. Let p(x) be a propositional function defined on a set A. Then the expression ‘ for every x ∈ A, p(x) is a true statement’ is denoted by (∀ x ∈ A) p(x) or ∀x p(x). The symbol ∀ which reads for all or for every is called the universal quantifier. Observe that the statement ∀x p(x) is equivalent to the statement Tp = {x|x ∈ A, p(x)} = A that is, that the truth set of p(x) is the entire set A.

14

CHAPTER 1. LOGIC

Thus, if {x|x ∈ A, p(x)} = A then ∀x p(x) is true; otherwise, ∀x p(x) is false. Example 1.6.5. (a) The proposition (∀n ∈ N) (n + 1 > 1) is true since {n|n + 1 > 1} = {1, 2, 3, ...} = N. (b) The proposition (∀n ∈ N) (n + 1 > 5) is false since {n|n + 1 > 5} = {5, 6, 7, 8, ...} = 6 N. (c) The symbol ∀ can be used to define the intersection of an indexed collection {Ai |i ∈ I} of sets Ai as follows: ∩{Ai |i ∈ I} = {x|∀i ∈ I, x ∈ Ai }

1.6.2

(1.6.1)

Existential Quantifier

Let p(x) be a propositional function defined on a set A. Then the expression There exists an x in A such that p(x) is a true statement or, simply, for some x, p(x) is symbolically written as (∃x ∈ A) p(x)

or ∃x, p(x).

The symbol ∃ which reads there exists or for some or for at least one is called the existential quantifier. For example, ‘There is a man who is immortal’. In other words the above statement is equivalent to Tp = {x|x ∈ A, p(x)} = 6 ∅ Thus, if {x|p(x)} 6= ∅ then ∃x p(x) is true; otherwise, ∃x p(x) is false. Example 1.6.6. (a) The proposition ∃n ∈ N (n + 1 < 4) is true since {n ∈ N|n + 1 < 4} = {1, 2} = 6 ∅. (b) The proposition ∃n ∈ N (n + 1 < 1) is false since {n ∈ N | n + 1 < 1} = ∅. (c) The symbol ∃ can be used to define the union of an indexed collection {Ai |i ∈ I} of sets Ai as follows: ∪{Ai |i ∈ I} = {x|∃i ∈ I, x ∈ Ai }.

1.7. MATHEMATICAL PROOF

1.6.3

15

Negation of quantified statements

It is noted that −[∀x(p(x))] = ∃x(−p(x)) and −[∃x(p(x))] = ∀x(−p(x)). It is illustrated by following examples: Example 1.6.7. The statements ‘For all positive integers n, n + 2 > 8’ and ‘There exists a positive integer n such that n + 2 ≤ 8 are negatives of each other.

1.7

Mathematical Proof

In this section, most of the material has been taken from [2]. The most important components of mathematical theory are the following: 1. Undefined terms. 2. Axioms. 3. Definitions. 4. Theorems. 5. Proofs. A statement about the undefined terms which serves to ”build a theory” is called an axiom. Note that axioms which contradict each other are not acceptable and the truth values of the axioms is not considered. Definitions are introduced for the convenience of not having to refer everything back to undefined terms. A statement about various terms of the system which follows from the axioms using the kind of logical reasoning is called a Theorem. Usually a theorem originates in a conjecture - a belief that a certain result holds. Suppose that we are given a system of axioms A1 , A2 , . . . , An . Then, a statement P (proposition) such that the argument A1 ∧ A2 ∧ A3 . . . ∧ An ` P is valid, is a theorem. Thus a theorem is a statement of the form p ⇒ q. Indeed, theorems are propositions which are true in every model of the axiom system. A proof is a valid argument in which the theorem is the conclusion.

16

CHAPTER 1. LOGIC

Some other theorems which have already been proved or axioms may be premises of this argument. Thus to prove a theorem P we must show that the argument (A1 ∧ A2 ∧ A3 . . . ∧ An ) ∧ (P1 ∧ P2 ∧ P3 . . . ∧ Pm ) ` P is valid, where Ai ’s are axioms and Pj ’s are theorems which have already been proved.

1.7.1

Methods of Proof

As we have discussed that the theorems are of the form p ⇒ q. Note that some theorems are of the form p ⇔ q. Since p ⇔ q is logically equivalent (equivalent) to the statement (p ⇒ q) ∧ (q ⇒ p). Thus to discuss a method of proof, it is sufficient to give the method of proof of a conditional statement p ⇒ q. Direct Proof of a conditional statement To prove a theorem p ⇒ q, we prove that the argument (A1 ∧ A2 ∧ A3 . . . ∧ An ) ∧ (P1 ∧ P2 ∧ P3 . . . ∧ Pm ) ` (p ⇒ q) is valid, where Ai ’s are axioms and Pj ’s are theorems which have already been proved. This is equivalent to (A1 ∧ A2 ∧ A3 . . . ∧ An ∧ P1 ∧ P2 ∧ P3 . . . ∧ Pm ) ⇒ (p ⇒ q) is a tautology. Since p ⇒ (q ⇒ r) is logically equivalent to (p ∧ q) ⇒ r (verify), therefore the statement (A1 ∧ A2 ∧ A3 . . . ∧ An ∧ P1 ∧ P2 ∧ P3 . . . ∧ Pm ∧ p) ⇒ q is a tautology. Thus (A1 ∧ A2 ∧ A3 . . . ∧ An ∧ P1 ∧ P2 ∧ P3 . . . ∧ Pm ∧ p) ` q is valid. Mostly we use this method to prove theorems. Exercise 1.7.1. Prove that, for every integer n, if n is even, then n2 is even.

1.7. MATHEMATICAL PROOF

17

Proof of a Conditional Proposition using the Contrapositive Since p ⇒ q is equivalent to −q ⇒ −p. Hence, if we can establish the truth of the contrapositive, we can deduce that the conditional statement p ⇒ q is also true. This constitutes an indirect proof of p ⇒ q. In this case, we assume that the statement −q is true and we establish that −p is true. Exercise 1.7.2. By using contrapositive, prove that, for every integer n, if n2 is even then n is even. Proof by Contradiction As we have observed that p ∧ −p is equivalent to contradiction f . Hence to prove a theorem p, we prove the conditional proposition −p ⇒ f (verify that p is equivalent to −p ⇒ f ). This method of indirect proof is frequently referred to as “proof by contradiction”. Exercise 1.7.3. Prove that Z+ is unbounded above. Exercise 1.7.4. Prove that



2 is irrational.

Proof by Counterexample Observe that if there exists a river which has no origin then the statement “Every river has an origin” will be false. Thus, the statement “∀x, p(x)” is false is equivalent to the statement “∃x, −p(x)” is true or, in other words, there is an element x0 with the property that p(x0 ) is false. Such an element x0 is called a counterexample to the statement “∀x, p(x)”. Example 1.7.5. (a) The statement ∀x ∈ R, |x| > 0 is false since 0 is a counterexample, that is; for x = 0, |0| > 0 is not true. (b) The statement ∀x ∈ R, x2 ≥ x is not true since 0.2 is a counterexample. (c) The statement ∀x ∈ N, x2 ≥ x is true where N is the set of positive integers. In other words, there does not exist a positive integer n for which n2 < n.

18

CHAPTER 1. LOGIC

Principle of Mathematical Induction First Principle of Induction: Let p(n) be a proposition concerning a positive integer n. If (a) p(1) is true, and (b) for every r ≥ 1, the truth of p(r) implies the truth of p(r + 1), then p(n) is true for all positive integers n. Exercise 1.7.6. Prove that n(n + 1)(2n + 1) is divisible by 6 for all n. Exercise 1.7.7. Prove that the sum of the first n odd positive integers is n2 . Second Principle of Induction : Let p(n) be a proposition concerning a positive integer n. If (a) p(1) is true, and (b) for every r ≥ 1, the truthfulness of p(r) for all r ≤ k implies the truthfulness of p(k + 1), then p(n) is true for all positive integers n. This result is frequently used in “Groups”.

1.8

Miscellaneous Examples

Example 1.8.1. Consider the following propositions: p : Mathematicians are generous. q : Spiders hate algebra. Write the compound propositions symbolized by: (i) p ∨ −q (ii) −(q ∧ p) (iii) −p ⇒ q (iv) −p ⇔ q.

Solution: (i) Mathematicians are generous or spiders dont hate algebra (or both). (ii) It is not the case that spiders hate algebra and mathematicians are generous. (iii) If mathematicians are not generous then spiders hate algebra. (iv) Mathematicians are not generous if and only if spiders dont hate algebra.

1.8. MISCELLANEOUS EXAMPLES

19

Example 1.8.2. Let p be the proposition ‘Today is Monday’ and q be ‘I’ll go to Varanasi’. Write the following propositions symbolically. (i) If today is Monday then I won’t go to Varanasi. (ii) I’ll go to Varanasi and today is not Monday. (iii) If and only if today is not Monday then Ill go to Varanasi. Solution: (i) p ⇒ −q. (ii) −p ∨ q. (iii) −p ⇔ q. Exercise 1.8.3. Using truth tables or otherwise, check that each of the following is a tautology: 1. p ⇒ (p ∨ q) 2. ((p ∧ q) ⇒ q) ⇒ (p ⇒ q) 3. p ⇒ (q ⇒ p) 4. (p ∨ (p ∧ q)) ⇔ p 5. (p ⇒ q) ⇔ (q ⇒ p) Exercise 1.8.4. Decide (and justify) whether each of the following is a tautology: 1. (p ∨ q) ⇒ (q ⇒ (p ∧ q)) 2. (p ⇒ (q ⇒ r)) ⇒ ((p ⇒ q) ⇒ (p ⇒ r)) 3. ((p ∨ q) ∧ r) ⇔ (p ∨ (q ∧ r)) Exercise 1.8.5. For each of the following, decide whether the statement is true or false, and justify your assertion: 1. If p is true and q is false, then p ∧ q is true. 2. If p is true, q is false and r is false, then p ∨ (q ∧ r) is true. 3. The sentence (p ⇔ q) ⇔ (q ⇔ p) is a tautology. 4. The sentences p ∧ (q ∨ r) and (p ∨ q) ∧ (p ∨ r) are logically equivalent.

Exercises

20

CHAPTER 1. LOGIC

Exercise 1.8.6. Represent the following arguments symbolically and check their validity: 1. If Priya works hard then she will pass Priya works hard ——————————————————– She will pass 2. If Priya works hard then she will pass She will not pass ——————————————————– Priya do not work hard 3. If it rains today then Ansh will not play football today If Ansh does not play football today then he will play football tomorrow ——————————————————————————————If it rains today then Ansh will play football tomorrow Exercise 1.8.7. Prove that (p → q) ∧ (p → r) ∧ −(q ∨ r) ∧ (s ∨ p) ` s is a valid argument. Exercise 1.8.8. Prove the validity of following argument: If Meera get the admission and work hard then she will get first division. If she will get first division then she will be happy. She will not happy. Therefore, either she will not get the admission or she will not work hard.

CHAPTER

2

Relations And Functions

For basic knowledge of set theory, we refer the reader to [1]. We now assume the familiarity of readers with sets and their basic operations.

2.1

Ordered Pair, Cartesian Product

Let X be a set. Let a, b ∈ X. Then {{a}, {a, b}} ⊆ ℘(X), where ℘(X) is the set of all subsets of X, known as power set of X. We denote the set {{a}, {a, b}} by (a, b) and call it an ordered pair. Thus (a, b) ∈ ℘(℘(X)). Proposition 2.1.1. (a, b) = (b, a) ⇔ a = b. Proof: Suppose that (a, b) = (b, a). Then {{a}, {a, b}} = {{b}, {b, a}}. Since {a, b} = {b, a}, {a} = {b}. Hence a = b. Clearly a = b implies (a, b) = (a, a) = (b, a). 2 Observe that (a, a) = {{a}, {a, a}} = {{a}, {a}} = {{a}}. Let X and Y be sets. Then the set X ×Y

= {(a, b) | a ∈ X and b ∈ Y }

which is a subset of ℘(℘(X ∪ Y )) is called the Cartesian product of X and Y. 21

22

CHAPTER 2.

RELATIONS AND FUNCTIONS

Proposition 2.1.2. Let A , B and C be sets. Then 1. (A ∪ B) × C = (A × C) ∪ (B × C). 2. (A ∩ B) × C = (A × C) ∩ (B × C). 3. (A − B) × C = (A × C) − (B × C). Proof: We have the following equivalences: (x, y) ∈ (A ∪ B) × C ⇔ ⇔ ⇔ ⇔

x ∈ A ∪ B and y ∈ C (x ∈ A and y ∈ C) or (x ∈ B and y ∈ C) (x, y) ∈ (A × C) or (x, y) ∈ (B × C) (x, y) ∈ (A × C) ∪ (B × C)

This proves (i). Similarly the rest can be proved. Proposition 2.1.3. A × B = ∅ ⇔ A = ∅ or B = ∅. Proof: If A = ∅, then (x, y) ∈ A × B ⇒ x ∈ ∅ and y ∈ B. Since x ∈ ∅ is a contradiction (x, y) ∈ ∅ × B is also a contradiction. Hence ∅ × B = ∅. Similarly A × ∅ = ∅. Conversely suppose that A 6= ∅ and B 6= ∅. Then ∃x ∈ A and ∃y ∈ B. Thus (x, y) ∈ A × B and hence A × B 6= ∅. 2

2.2

Relations

Definition 2.2.1. Let A, B be any two sets. Then a subset R of A × B is called a relation from A to B. Let (a, b) ∈ R then we write aRb and we read a is related to b. The set Dom R = {a |(a, b) ∈ R} is called the domain of R and the set Range R = {b |(a, b) ∈ R} is called the range of R respectively. Example 2.2.2. 1. ∅ and A × B are subsets of A × B. Thus these are relations from A to B. 2. If either A or B is empty then there is only one relation from A to B. This relation is called an empty relation. 3. If |A| = m and |B| = n then there are 2mn relations from A to B.

2.3. COMPOSITION OF RELATIONS

23

4. If A = {a, b, c} and B = {1, 2} then R = {(a, 1), (b, 1)} is a relation from A to B. Observe that Dom R = {a, b} and Range R = {1}. If R is a relation from A to B then R−1 = {(b, a) |(a, b) ∈ R} is a relation from B to A. This relation is known as inverse relation S of R. T Let R and S be relations from A to B. Then R S, R S and R − S are subsets of A × B and hence they are relations from A to B.

2.3

Composition of Relations

Let R and S be relations from X to Y and Y to Z respectively. We define SoR as follows: SoR = {(x, z) ∈ X × Z | ∃y ∈ Y such that (x, y) ∈ R and (y, z) ∈ S} SoR is called the composition of R and S. Clearly it is a relation from X to Z. Example 2.3.1. Consider A = {1, 2, 3}, B = {a, b, c} and C = {x, y, z}. Let R = {(1, a), (2, b), (3, c)} and S = {(a, x), (a, y), (b, z)}. Then SoR = {(1, x), (1, y), (2, z)}. Definition 2.3.2. Let X be a set. A subset R of X × X is called a relation on X. Example 2.3.3. ∅ and X × X are relations on X. If X is an empty set then there is only one relation which is ∅. Example 2.3.4. 4 = {(x, x) | x ∈ X} is a relation on X called the diagonal relation on X. Example 2.3.5. Let X = {a, b, c}. R = {(a, b), (b, a), (a, c)} is a relation on X. Example 2.3.6. Let X be a set. Let R = {(A, B) | A, B ∈ ℘(X) and A ⊆ B} is a relation on ℘(X). Proposition 2.3.7. Let R, S and T be relations on X. Then (RoS)oT = Ro(SoT ).

24

CHAPTER 2.

RELATIONS AND FUNCTIONS

Proof: We have the following equivalences: (x, y) ∈ (RoS)oT ⇔ ⇔ ⇔ ⇔

∃z ∈ X such that (x, z) ∈ T and (z, y) ∈ RoS ∃z, u ∈ X such that (x, z) ∈ T, (z, u) ∈ S and (u, y) ∈ R ∃u ∈ X such that (x, u) ∈ SoT and (u, y) ∈ R (x, y) ∈ Ro(SoT )

This proves the result.2 Proposition 2.3.8. If R is any relation on X, then Ro4 = R = 4oR. Proof: Since (x, x) ∈ 4∀ x ∈ X, therefore (x, y) ∈ Ro4 ⇔ (x, y) ∈ R. Thus Ro4 = R. Similarly R = 4oR.2 Proposition 2.3.9. Let R, S and T be relations on X. Then S S 1. Ro(S T ) = (RoS) (RoT ). T T 2. Ro(S T ) ⊆ (RoS) (RoT ). S S 3. (R S)oT = (RoT ) (SoT ). T T 4. (R S)oT ⊆ (RoT ) (SoT ). Proof: We have the following equivalences: [ [ (x, y) ∈ Ro(S T ) ⇐⇒ ∃z ∈ X such that (x, z) ∈ S T and (z, y) ∈ R ⇐⇒ ∃z ∈ X such that ((x, z) ∈ S and (z, y) ∈ R) or ((x, z) ∈ T, (z, y) ∈ R) ⇐⇒ (x, y) ∈ (RoS) or (x, y) ∈ (RoT ) [ ⇐⇒ (x, y) ∈ (RoS) (RoT ) This proves 1. Similarly one can prove the other results 2 Example 2.3.10. Let X = {a, b, c}. Let R = {(a, b), (a, c)} and S = {(b, c), (b, b)}. Then RoS = ∅ and SoR = {(a, c), (a, b)} = R. Thus, RoS need not be equal to SoR. Observe that R = SoR = 4oR but S 6= 4. Next, if T = {(a, a), (b, c), (b, b)} = 6 4, then RoT = {(a, c), (a, b)} = R = T oR but T 6= ∆. Thus RoT = R = T oR need not imply that T = 4.

2.3. COMPOSITION OF RELATIONS

25

Definition 2.3.11. Let R be a relation on X. Then the relation R−1 = {(x, y) ∈ X × X | (y, x) ∈ R} is called the inverse of R. Example 2.3.12. Let R = {(a, b), (a, c)} be a relation on X = {a, b, c}. Then R−1 = {(b, a), (c, a)}. Observe that RoR−1 = {(b, b), (c, c)} and R−1 oR = {(a, a)}. Thus, RoR−1 6= R−1 oR. Proposition 2.3.13. Let R and S be relations on X. Then (R−1 )−1 = R and (RoS)−1 = S −1 oR−1 . Proof: Clearly (x, y) ∈ R ⇔ (y, x) ∈ R−1 and (y, x) ∈ R−1 ⇔ (x, y) ∈ (R−1 )−1 . Thus R = (R−1 )−1 . Next, let (x, y) ∈ (RoS)−1 . Then (y, x) ∈ RoS. Hence ∃z ∈ X such that (y, z) ∈ S and (z, x) ∈ R. Thus ∃z ∈ X such that (x, z) ∈ R−1 and (z, y) ∈ S −1 and so (x, y) ∈ S −1 oR−1 . Similarly (x, y) ∈ S −1 oR−1 implies that (x, y) ∈ (RoS)−1 . This proves (RoS)−1 = S −1 oR−1 .2 Definition 2.3.14. A relation R on X is called 1. reflexive if (x, x) ∈ R ∀x ∈ X or equivalently 4 ⊆ R. 2. symmetric if (x, y) ∈ R ⇒ (y, x) ∈ R or equivalently R−1 = R. 3. antisymmetric if (x, y) ∈ R and (y, x) ∈ R =⇒ x = y or equivalently T −1 R R ⊆ 4. 4. transitive if (x, y) ∈ R and (y, z) ∈ R =⇒ (x, z) ∈ R or equivalently RoR ⊆ R. Example 2.3.15. Let X = {a, b, c} and R = {(a, a), (b, b), (c, c), (a, b), (b, c), (c, b)}. Then R is reflexive but none of the rest of the three. Example 2.3.16. Let X = {a, b, c} and R = {(a, b), (b, a)}. Then R is symmetric but none of the rest of the three. Example 2.3.17. Let X = {a, b, c} and R = {(c, b), (a, c)}. Then R is anti-symmetric but none of the rest of the three. Example 2.3.18. Let X = {a, b, c} and R = {(a, b), (b, a), (a, a), (b, b), (a, c), (b.c)}. Then R is transitive but none of the rest of the three.

26

CHAPTER 2.

RELATIONS AND FUNCTIONS

Example 2.3.19. Let X = {a, b, c} and R = {(a, a), (b, b), (c, c), (a, b), (b, a), (b, c), (c, b)}. Then R is reflexive , symmetric but neither anti-symmetric nor transitive. Example 2.3.20. Let X = {a, b, c} and R = {(b, c), (c, b), (b, b), (c, c)}. Then R is symmetric and transitive but neither reflexive nor anti-symmetric. Remark 2.3.21. (a). If a relation R on X is symmetric and transitive then it is reflexive. (b). The relation which is reflexive, symmetric and anti-symmetric is the diagonal relation. Thus, a reflexive, symmetric and anti-symmetric relation is also transitive.

2.4

Equivalence Relations

Definition 2.4.1. A relation R on X which is reflexive, symmetric and transitive is called an equivalence relation. Let R be an equivalence relation on X and x ∈ X. Then the subset [x] = {y ∈ X | (x, y) ∈ R} is called the equivalence class of X modulo R determined by element x. Since R is reflexive, (x, x) ∈ R∀x ∈ X and hence x ∈ [x]∀x ∈ X. In other words [x] 6= ∅. Proposition 2.4.2. Let R be an equivalence relation on X. Then (i) [x] = [y] ⇔ (x, y) ∈ R. (ii) [x] 6= [y] ⇐⇒ [x] ∩ [y] = ∅. Proof: (i). Suppose that [x] = [y]. Since R is an equivalence relation, y ∈ [y] = [x]. Hence (x, y) ∈ R. Conversely, suppose that (x, y) ∈ R. Let z ∈ [x]. Then (x, z) ∈ R. Since R is symmetric and transitive therefore (x, y), (x, z) ∈ R gives (y, z) ∈ R; that is, z ∈ [y]. This proves that [x] ⊆ [y]. Interchanging x and y, we get [y] ⊆ [x]. Thus [x] = [y]. (ii). If [x] ∩ [y] 6= ∅, then there exists z ∈ [x] ∩ [y] and so (x, z), (z, y) ∈ R. Since R is transitive, (x, y) ∈ R. It follows from (i) that [x] = [y]. Thus, [x] ∩ [y] = ∅. 2

2.4. EQUIVALENCE RELATIONS

27

Definition 2.4.3. Let X be a set. A subset ℘ of the power set of X is called a partition of X if (i) union of members of ℘ is X i.e ∪A∈℘ = X and (ii) A, B ∈ ℘, A 6= B ⇒ A ∩ B = ∅. Corollary 2.4.4. If R is an equivalence relation on X then ℘R = {[x] | x ∈ X} is a partition of X. Proof: Since x ∈ [x]∀x ∈ X (for R is reflexive), union of members of ℘R is X. Also [x] 6= [y] ⇒ [x] ∩ [y] = ∅. Thus ℘R is a partition. 2 Thus, the partition ℘R is the partition determined by the equivalence relation R. The set ℘R is also denoted by X/R and is called the quotient set of X modulo R. Proposition 2.4.5. Let ℘ be a partition of X. Define a relation R℘ = {(x, y) | ∃A ∈ ℘ such that x, y ∈ A} = ∪A∈℘ A × A. Then R℘ is an equivalences relation such that ℘R℘ = ℘. Proof: Since union of members of ℘ is X, given x ∈ X, x ∈ A for some A ∈ ℘. Hence (x, x) ∈ R℘ ∀x ∈ X. Thus R℘ is reflexive. Suppose that (x, y) ∈ R℘ . Then ∃A ∈ ℘ such that x, y ∈ A and so y, x ∈ A. Hence (y, x) ∈ R℘ . Thus R℘ is symmetric. Suppose that (x, y) ∈ R℘ and (y, z) ∈ R℘ . Then ∃A ∈ ℘ and B ∈ ℘ such that x, y ∈ A and y, z ∈ B. Since y ∈ A ∩ B, A ∩ B 6= ∅. Further since ℘ is a partition, A = B. Hence x, z ∈ A ∈ ℘. Thus (x, z) ∈ R℘ . This shows that R℘ is transitive. Next Rx℘ is the member A of ℘ such that x ∈ A. Hence ℘R℘ = ℘. 2 Proposition 2.4.6. R℘R = R for every equivalence relation R. Proof: Suppose that (x, y) ∈ R. Then x, y ∈ [x] ∈ ℘R . Hence (x, y) ∈ R℘R . Suppose that (x, y) ∈ R℘R . Then ∃Rz ∈ ℘R such that x, y ∈ Rz . Hence ∃z ∈ R such that (x, z) ∈ R and (y, z) ∈ R. But then since R is symmetric and transitive, (x, y) ∈ R. Thus R = R℘R . 2 Remark 2.4.7. Every partition ℘ of X determines an equivalence relation R℘ such that X/R℘ = ℘ and conversely. Thus every partition can be realized faithfully as an equivalence relation and every equivalence relation can be realized as a partition.

28

CHAPTER 2.

RELATIONS AND FUNCTIONS

Example 2.4.8. Let R be a relation (not necessarily equivalence) on X.Define Rx = {y ∈ X | (x, y) ∈ R}. Suppose that ℘ = {Rx | x ∈ X} is a partition of X. Can we infer that R is an equivalence relation? No. For example take X = {a, b, c}, R = {(a, b), (b, c), (c, a)}. Then Ra = {b}, Rb = {c}, Rc = {a}. Thus {Ra , Rb , Rc } is a partition of X where as R is not an equivalence relation(it is neither reflexive nor symmetric nor transitive). Example 2.4.9. Let ℘ ⊆ ℘(X) (not necessarily a partition). Define a relation R℘ on X by (x, y) ∈ R℘ ⇐⇒ ∃A ∈ ℘ such that x, y ∈ A. Suppose that R℘ is an equivalence relation. Can we infer that ℘ is a partition? Again, no. For example take ℘ = {{a, b}, {b, c}, {c, a}} ⊆ ℘(X) where X = {a, b, c}. Then clearly R℘ = X × X is an equivalence relation.

2.5

Functions

Definition 2.5.1. Let X and Y be sets. A subset f of X × Y is called a function ( or map or mapping) from X to Y if for all x ∈ X there exists unique y ∈ Y such that (x, y) ∈ f . It is denoted by f : X → Y and read as f is a function from X in to Y . The set X is called the domain of f and Y is called the codomain of f . If (x, y) ∈ f , we write y = f (x) and call it the image of the element x ∈ X under the map f . Thus, f = {(x, f (x)) | x ∈ X}. Intuitively a function f from X to Y is a rule which assigns each x ∈ X to a unique element y ∈ Y . Any two functions f and g from X to Y are equal if and only if f (x) = g(x) for all x ∈ X. Let f : X → Y and g : Y → Z be maps. Then gof = {(x, z) | (x, y) ∈ f and (y, z) ∈ g} is also a map from X to Z and is called the composite of f and g. Thus, the map gof : X → Z is given by (gof )(x) = g(f (x))∀x ∈ X. A function f from X to X defined by f (x) = x for every x ∈ X is called the identity map on X and is denoted by IX . Thus, IX (x) = x∀x ∈ X. Clearly goIX = g = IY og for every map g : X → Y . Let Y be a subset of X. Then a function iY given by iY (y) = y for all y ∈ Y } is called the inclusion map from Y to X. Let X and Y be sets and y ∈ Y . Then a function f : X → Y given by f (x) = y is called a constant map.

2.5. FUNCTIONS

29

Definition 2.5.2. A map f : X → Y is called a surjective map or an onto map if ∀y ∈ Y there exists x ∈ X such that f (x) = y. A map f : X → Y is called injective or one-one if f (x1 ) = f (x2 ) ⇒ x1 = x2 or equivalently x1 6= x2 ⇒ f (x1 ) 6= f (x2 ). A map f which is injective as well as surjective is called a bijective or one- one and onto. It is noted that f −1 is a map if and only if f is bijective and then the map f −1 is called the inverse of f and this is also bijective. Remark 2.5.3. An injective map need not be surjective. For example take X = {a, b}, Y = {x, y, z}. Define f : X → Y as f (a) = x, f (b) = y. Then f is injective but not surjective for there is no element in X whose image is z. Remark 2.5.4. A surjective map need not be injective. Take X = {a, b, c}, Y = {x, y}. Define f : X → Y as f (a) = x = f (b), f (c) = y. Then f is surjective, but not injective for f (a) = f (b) where as a 6= b. One may easily observe that Proposition 2.5.5. (i) Composite of any two injective maps is injective, (ii) Composite of two surjective maps is surjective and (iii) composite of two bijective map is bijective. EXERCISES 2

1. Find the number of relations on a set containing n elements. Ans.2n . 2. Let X = {a, b,S c}, R = {(a, S = {(a, a), (a, c), (b, b)}. T b), (b, c), (c, a)} and−1 Find out (i)R S, (ii)R S,(iii) RoS, (iv) R . 3. Find out the number of reflexive relations on a set containing n elements. S Hint. A reflexive relation on X × X can be written as ∆ S where S ⊆ X × X − ∆. 4. Find out the number of symmetric relation on a set containing n elements. 5. Let R and S be equivalence relations on X. Show that RoS is an equivalence relation if and only if RoS = SoR.

30

CHAPTER 2.

RELATIONS AND FUNCTIONS

6. Let X = {a, b, c, d} and R = {(a, a), (b, b), (c, c), (d, d), (a, b), (b, c), (a, c), (b, a), (c, b), (c, a)}. Show that R is an equivalence relation. Find ℘R . Can we find an other relation S such that ℘R = ℘S? Support.

CHAPTER

3

Lattices

This chapter is devoted to study Lattices. To introduce this, first we introduce Posets. We illustrate it by several examples to make better understanding of Posets. After discussing it we gave the notion of lattices and then studied it in details.

3.1

Partial Order relations

Definition 3.1.1. Let X be a set. A relation R on X is called a partial order relation if it is reflexive, anti-symmetric and transitive. Usually a partial order relation is denoted by ≤. A pair (X, ≤) where ≤ is a partial order relation on X, is called a Partially ordered set(Poset). Note that if a ≤ b but a 6= b then we write a < b. Example 3.1.2. Let Y be a set and X = P(Y ), the power set of Y . Then the inclusion relation ⊆= {(A, B) | A ⊆ B} is a partial order relation on X. Thus, (X, ⊆) is a partial ordered set. Note that the inverse (converse) of a partial order is also a partial order. Thus, ⊇ is also a partial order on X. Example 3.1.3. Let X = {a, b, c, d}. Then the relation R = {(a, a), (b, b), (c, c), (d, d), (a, b), (c, d)} 31

32

CHAPTER 3. LATTICES

is a partial order relation on X. Example 3.1.4. Let (X, ≤) be a partially ordered set and Y a subset of X. Then the induced relation on Y is also a partial order on Y which is denoted by ≤Y . Thus, ≤Y =≤ ∩(Y × Y ) and (Y, ≤Y ) is a Poset. Example 3.1.5. The divisibility relation ≤ on N defined by a ≤ b if and only if a divides b is a partial order relation on N. This relation is denoted by /. Thus (N, /) is a Poset. The relation ≤ defined by a ≤ b if and only if a is less than b is not a partial order relation. Definition 3.1.6. Let (X, ≤) be a Poset. Then any two elements a, b of X are said to be comparable if either a ≤ b or b ≤ a. A partial order ≤ on X is called a total order or linear order if every pair x, y of elements in X are comparable. If ≤ is a total order on X then (X, ≤) is called a totally ordered or linearly ordered or chain. A subset Y of X is called a chain in X if the induced partial order on Y is a total order or linear order on Y ; that is, (Y, ≤Y ) is linearly ordered. Example 3.1.7. Let X = {a, b, c, d} and R = {(a, a), (b, b), (c, c), (d, d), (a, b), (b, c), (a, c), (c, d), (a, d), (b, d)}. Then R is a total order on X. Example 3.1.8. Let Y = {a, b, c} and X = ℘(Y ). Then the inclusion relation is a partial order on X. The subset Z = {∅, {a}, {a, b}, {a, b, c}} is a chain in X. Definition 3.1.9. Let (X ≤) be a partially ordered set and A ⊆ X. An element u ∈ X is called an upper bound of A if a ≤ u for all a in A. Similarly, an element l ∈ X is called a lower bound of A if l ≤ a for all a in A. Remark 3.1.10. A subset of a partially ordered set need not have any upper bound (lower bound). A subset may have several upper bounds (lower bounds) too. For, let X = {a, b, c} and R = {(a, a), (b, b), (c, c), (a, b), (a, c)}. Then b, c are upper bounds of Y = {a} but {b, c} has no upper bounds. Next, consider the partial order relation S = {(a, a), (b, b), (c, c), (a, b), (c, b)}, then a, c are lower bounds of Y = {b} but Y = {a, c} has no lower bounds.

3.1. PARTIAL ORDER RELATIONS

33

Definition 3.1.11. Let (X ≤) be a partially ordered set. An element a ∈ X is called a maximal(minimal) element if a ≤ x(x ≤ a) ⇒ x = a. In example 3.1.3, b and d are maximal elements whereas a and c are minimal elements of X. Thus, there may be so many maximal or minimal elements of a partially ordered set. Similarly, a Poset may not have any maximal or minimal element (give examples to support it). Example 3.1.12. Let X = ℘(Y ) − {Y, ∅} where Y = {a, b, c}. Then X is a partially ordered set with respect to inclusion. Clearly {a, b}, {b, c}, {a, c} are maximal elements and {a}, {b}, {c} are minimal elements. Example 3.1.13. Let X = {a, b, c} and 4 = {(a, a), (b, b), (c, c)} Then 4 is a partial order on X such that each element is maximal and also each element is minimal. Example 3.1.14. Let Y be an infinite set and X the set of all finite subsets of Y . Then X is a partially ordered set with respect to inclusion which has no maximal element. If we take the set Z of infinite subsets of Y then it has no minimal elements. Definition 3.1.15. Let (X ≤) be a partially ordered set. An element a ∈ X is called the largest or last element of X if x ≤ a∀x ∈ X. An element a ∈ X is called the least or first element of X if a ≤ x ∀x ∈ X. Observe that every largest element in a Poset is maximal and every least element in a Poset is minimal. Note that a Poset may or may not have first and last element. For, (N, ≤) has first element but not has last element where as (−N, ≤) has last but not first. Also observe that Z has neither first nor last but a closed interval [1, 2] has both. Proposition 3.1.16. Largest (least) element of a Poset is unique provided it exists. Proof: Suppose that (X, ≤) has largest (least) element. If x1 and x2 are largest(least) elements of X then x1 ≤ x2 and x2 ≤ x1 . By antisymmetry of ≤, x1 = x2 . Thus, largest(least) element is unique. 2 Remark 3.1.17. It may be observed that a largest(least) element is also a maximal(minimal) but a maximal(minimal) element need not be the largest(least). In example 3.1.3, b, d are maximal and a, c are minimal, but none of them

34

CHAPTER 3. LATTICES

are largest(least). From this Poset, it may also be noticed that largest(least) need not exist in a Poset. Let (X ≤) be a partially ordered set and A ⊆ X. Let U (A)(L(A)) denote the set of upper(lower) bounds of A. (Note that U (A)(L(A)) may be empty-sets also). Then ≤ induces a partial order on U (A)(L(A)). Note that all elements of A are lower(upper) bounds of U (A)(L(A)). Thus, A ⊆ L(U (A))(A ⊆ U (L(A))). Definition 3.1.18. The least element of U (A) (if exists) is called the least upper bound of A. It is denoted by sup A or lub A. Similarly the largest element of L(A) is called the greatest lower bound of A. It is denoted by inf A or glb A. If A has the largest(least) element, then that is the lub(glb) of A. Remark 3.1.19. Least upper bound(greatest lower bound) need not exist even if A has upper(lower) bounds: Let Y = {a, b, c, d} and X = ℘(Y ) − {{a, b}}. Then ⊆ defines a partial order on X. Take A = {{a}, {b}} Then U (A) = {{a, b, c}, {a, b, d}, Y }. Clearly U (A) has no least element. Thus A has no lub. Theorem 3.1.20. Let (X ≤) be a partially ordered set. Then the following conditions are equivalent. (1). Every nonempty subset of X which has an upper bound has least upper bound in X. (2). Every nonempty subset of X which has a lower bound has greatest lower bound. Proof: (1 =⇒ 2). Assume 1. Let A be a non-empty subset of X which has a lower bound. Then L(A) 6= ∅. Clearly ∅ = 6 A ⊆ U (L(A)). Hence L(A) has an upper bound. By 1, L(A) has the least upper bound a (say). Since a is the least element of U (L(A)) (by the definition of lub) and A ⊆ U (L(A)), a ≤ x∀x ∈ A. Thus, a ∈ L(A). Further if y ∈ L(A), then y ≤ x∀x ∈ U (L(A)). In particular y ≤ a. Thus, a is the largest element of L(A). This shows that a is the glbA. The proof of (2 =⇒ 1) is similar. 2 Definition 3.1.21. A partial order ≤ on X is called a complete order if every non-empty subset of X which has an upper bound has least upper bound

3.1. PARTIAL ORDER RELATIONS

35

in X. By theorem 3.1.20, conditions (1) and (2) are equivalent. Thus, a partial order ≤ on X is called a complete order if it satisfies any one (and hence both) of the equivalent conditions of the Theorem 3.1.20. Definition 3.1.22. A partial order ≤ on X is called a well order if every non-empty subset of X has the least element. A pair (X, ≤) where ≤ is a well order is called a well ordered set. Proposition 3.1.23. Every well order is a total order. Proof: Let ≤ be a well order on X. Let x, y ∈ X. Then {x, y} is a non-empty subset of X. Since ≤ is a well order, {x, y} has a least element. If x is the least element then x ≤ y and if y is the least element then y ≤ x. This proves that every well order is a total order. 2 Remark 3.1.24. A total order need not be a well order. Finally we state two equivalents of axiom of choice (without proof) which are commonly used in mathematics. Theorem 3.1.25. (Zorn‘s Lemma): Let (X, ≤) be a non-empty partially ordered set in which every chain has an upper bound. Then (X, ≤) has a maximal element. Theorem 3.1.26. (Well ordering principle): On every set there is a well order.

EXERCISES 1. Let (X, ≤) be a partially ordered set. Let A ⊆ B. Show that U (A) ⊇ U (B) and L(A) ⊇ L(B). 2. Show that U (A) = U (L(U (A))) and L(A) = L(U (L(A))). 3. Show that glb need not exist. 4. Let A ⊆ B. Show that inf B ≤ inf A and sup A ≤ sup B. 5. Show by means of an example that sup A need not belong to A. 6. Show that (P(X), ≤) is order complete. 7. Give an example of a partially ordered set which is not complete.

36

CHAPTER 3. LATTICES 8. Prove the Poset X = {2, 3, 6, 12, 24, 36} with respect to divisibility relation ≤ given by x ≤ y if x divides y, has no least(first or zero)element and last (greatest or largest) element. Also prove that 2, 3 are its minimal and 24, 36 are its maximal elements. What will happen if (i) X = {1, 2, 3, 6, 12, 24, 36}, (ii) X = {2, 3, 6, 12, 24, 36, 72} and (iii) X = {1, 2, 3, 6, 12, 24, 36, 72}.

3.2

Product Sets and Order relation

There are a number of ways to define a partial order relation on the Cartesian product of given two partial ordered sets. Two of these ways follow: 1. (Product Order): Let S and T be two Posets. Then (S × T, ≤) is also a Poset where ≤ is given by (a, b) ≤ (a0 , b0 ) if a ≤ a0 and b ≤ b0 This order relation is known as the product order. This product relation can be extended to the Cartesian product of finite number of Posets. 2. (Lexicographical Order): Suppose S and T are linearly ordered sets. Then the order relation ≤ on the product set S × T defined by (a, b) ≤ (a0 , b0 ) if a < a0 or if a = a0 and b ≤ b0 This order relation is called the lexicographical or dictionary order. This order can be extended to Cartesian product S1 × S2 × . . . × Sn of finite number of linearly ordered sets S1 , S2 , . . . , Sn as follows: (a1 , a2 , . . . , an ) ≤ (a01 , a02 , . . . , a0n ) if ai = a0i f or i = 1, 2, ..., k − 1 and ak < a0k . Note that the lexicographical order is also linear.

3.3

Hasse diagram of Poset

Let S be a partially ordered set, and suppose a, b belong to S with a 6= b. We say that a is an immediate predecessor of b, or that b is an immediate successor of a if a < b but no element c in S such that a < c < b.

3.3. HASSE DIAGRAM OF POSET

37

The Hasse diagram of a finite partially ordered set S is a pictorial representation of Poset. It is a graph whose vertices are the elements of S and there is a edge from a to b whenever a is immediate predecessor of b with the vertex b above the vertex a. Observe that there can be no cycles in the diagram of S since the order relation is antisymmetric. Sometimes we define a partially ordered set by simply presenting its Hasse diagram. We note that the Hasse diagram of a Poset S need not be connected. It can be illustrated by following examples: Example 3.3.1. Let (A, ≤) be a Poset where A = {1, 2, 3, 4, 6, 8, 9, 12, 18, 24} and the partial order relation ≤ is defined by x ≤ y if x divides y. The Hasse diagram of Poset (A, ≤) is

24

18

12

9

4

6 2

3 1

Figure 3.1: Poset with two maximal elements and least element but not largest element From the figure it is clear that 18, 24 are maximal but none of them is largest and 1 is minimal as well as least element. This element is a first element of the Poset. Example 3.3.2. Let (A, ≤) be a poset where A = {2, 3, 4, 6, 8, 9, 12, 18} and the partial order relation ≤ is defined by x ≤ y if x divides y. The Hasse diagram of Poset (A, ≤) is given by figure 3.2. Example 3.3.3. The Hasse diagram of Poset A = {1, 2, 3, 4, 6, 9, 12, 18, 24, 36, 72} of all divisors of 72 with respect to the divisibility relation is given by figure 3.3.

38

CHAPTER 3. LATTICES

12

18

6

4

9 2

3

Figure 3.2: Poset with two maximal and two minimals but not having least and largest element

72 24

8

36

12

18 9

4 6 3

2 1

Figure 3.3: Poset with least and last element which are minimal and maximal respectively

3.3. HASSE DIAGRAM OF POSET

39

Example 3.3.4. The Hasse diagram of a Poset A = {1, 2, 3, 4} with respect to ‘less than or equal to’ relation is given by figure 3.4.

4

3

2

1

Figure 3.4: Poset which is a chain Definition 3.3.5. (Dual of a Poset) Let (X, ≤) be a Poset. Define a relation ≥ on X by x ≥ y if and only if y ≤ x. Then (X, ≥) is a poset (prove it). This Poset is called as dual Poset of (X, ≤) or dual of (X, ≤). One may easily observe that minimal, maximal, lower upper bounds of (X, ≤) are just interchanged in dual (X, ≥). Exercise 3.3.6. Find the maximal, minimal, least(first or zero) and last element of the Posets which are given by Hasse diagrams (figure 3.3).

h

4

g 3

f e

0

2

6 4

c

5

3 2

d b

a 1

40

3.4

CHAPTER 3. LATTICES

Isomorphic Posets

Definition 3.4.1. Two Posets (X, ≤1 ) and (Y, ≤2 ) are said to be isomorphic if there is a bijective correspondence f from X in to Y such that x ≤1 y if and only if f (x) ≤2 f (y). Example 3.4.2. Consider the poset X = {1, 2, 3, 4, 6, 12} with respect to divisibility relation and the Poset Y = {21, 22, 23, 24, 25, 26} with respect to ‘less than or equal to’ relation. Observe that both Posets have same number of elements. Since every elements of Y are comparable but 3, 4 ∈ X are not comparable. Let f be a bijective map from Y to X. Then there exists a, b ∈ Y such that f (a) = 2 and f (b) = 3. Since a ≤ b but f (a) ≤ f (b) because f (a) = 2 does not divide f (b) = 3. The Hasse diagrams of these Posets are given by figure 3.5.

26 25 12 24

6

4

3

2

23 22 21

1

Figure 3.5: Non-isomorphic Posets

Example 3.4.3. The Poset (X, /) where X = {1, 2, 3, 6} and the Poset (Y, ⊆) where Y = {∅, {a}, {b}, {a, b}} are isomorphic under the isomorphism f given by f (1) = ∅, f (2) = {a}, f (3) = {b}, f (6) = {a, b}. Exercise 3.4.4. Prove that the Posets given by figure 3.6 are not isomorphic:

3.5

Lattices

Definition 3.5.1. A Poset (L, ≤) in which sup{x, y} and inf{x, y} exist for every x, y ∈ L, is called a Lattice. The elements sup{x, y} and inf{x, y} are denoted by x ∨ y and x ∧ y respectively. We call x ∨ y as the join of

3.5. LATTICES

41

3

2 a

1 b

c

Figure 3.6: Non-isomorphic Posets x and y and x ∧ y as the meet of x and y. Thus x ∧ y = inf{x, y} and x ∨ y = sup{x, y}. From the definition of meet and join, it follows that x, y ≤ x ∨ y and x ∧ y ≤ x, y Some authors also denote x ∨ y by x + y and x ∧ y by x.y. Example 3.5.2. Let X be a finite set. Then the Poset (P(X), ⊆) is a lattice because for every A, B ⊆ X, we have A ∨ B = sup{A, B} = A ∪ B and A ∧ B = inf{A, B} = A ∩ B in P(X). If X = {1, 2} then L = P(X) = {{}, {1}, {2}, {1, 2}} is a lattice with respect to inclusion relation ⊆. The Hasse diagram is given by figure 3.7. {a, b

}

{a}

{b}

{}

Figure 3.7: Lattice with four elements Example 3.5.3. The Poset given by figure 3.8 is not a lattice because sup{3, 4} does not exist as 3, 4 are not comparable. Example 3.5.4. The poset A given by following Hasse diagram (Figure 3.9) is not a lattice because sup{e, d} does not exist. Note that a, b, c are lower bounds with a ≤ b and a ≤ c but greatest lower bound does not exist because b and c are not comparable.

42

CHAPTER 3. LATTICES

3

4

2

1

Figure 3.8: Poset which is not a lattice e

d

b

c

a

Figure 3.9: Poset which is not a lattice Exercise 3.5.5. Prove that the poset given by following Hasse diagram (Figure 3.10) is not a lattice because neither inf{e, d} nor sup{b, c} exist. f e

d

c

b a

Figure 3.10: Poset which is not a lattice Exercise 3.5.6. Draw the Hasse diagram of the lattice (P(X), ⊆) where X = {1, 2, 3}. Exercise 3.5.7. Prove that the set L of all divisors (factors) of 12 forms a lattice with respect to divisibility operation.

3.5. LATTICES

43

Exercise 3.5.8. Prove that the sets N, Z, Q and R with respect to less than or equal to relation ‘≤0 are lattices. Hint: sup{a, b} = max {a, b} and inf{a, b} = min {a, b} for all a, b ∈ N. Exercise 3.5.9. Prove that the poset (N, /), where / is a divisibility relation, is a lattice. Hint: sup{a, b} = [a, b], least common multiple of a and b ; and inf{a, b} = (a, b), the greatest common divisor of a and b for all a, b ∈ N. Exercise 3.5.10. Prove that the set S(G) of all subgroups of a given group G forms a lattice with respect to inclusion relation ⊆. Hint: sup{H, K} = hH ∪ Ki and inf{H, K} = H ∩ K for all H, K ∈ S(G). Exercise 3.5.11. Prove that every chain is a lattice. Hint: Let (L, ≤) be a chain. then for every a, b ∈ L we have either a ≤ b or b ≤ a. If a ≤ b then sup{a, b} = b and inf{a, b} = a. If b ≤ a then sup{a, b} = a and inf{a, b} = b.

3.5.1

Properties

(Principle of duality): Any statement involving ∧, ∨, ≤ and ≥ remains true if ∧ is replaced by ∨, ∨ is replaced by ∧, ≤ is replaced by ≥ and ≥ is replaced by ≤. If (L, ≤) is a lattice then (L, ≥) is a lattice. These two lattices are called dual to each other. Proposition 3.5.12. Let (L, ≤) be a lattice. Then (a) a ≤ b ⇔ a ∨ b = b, (b) a ≤ b ⇔ a ∧ b = a, (c) a ∧ b = a ⇔ a ∨ b = b. Proof: (a) If a ∨ b = b then b is an upper bound of {a, b} and so a ≤ b. Conversely suppose that a ≤ b. Since b ≤ b also, hence b is an upper bound of {a, b}. Since a, b ≤ u for all upper bound u of {a, b}, therefore b is least upper bound (supremum) of {a, b} and so a ∨ b = sup {a, b} = b. (b) If a ∧ b = a then a is a lower bound of {a, b} and so a ≤ b. Conversely suppose that a ≤ b. Then a is a lower bound of {a, b}. Now, if l is a lower bound of {a, b} then l ≤ a. Therefore a is a greatest lower bound, that is; a ∧ b = a. Combining (a) and (b), we get (c). 2 Theorem 3.5.13. In a lattice (L, ≤), we have the following:

44

CHAPTER 3. LATTICES

(a) . Idempotent Law: a ∧ a = a ∨ a = a for all a ∈ L. (b) . Commutative Law: a ∧ b = b ∧ a and a ∨ b = b ∨ a for all a, b ∈ L. (c) . Associative Law: (a ∧ b) ∧ c = a ∧ (b ∧ c) and (a ∨ b) ∨ c = a ∨ (b ∨ c) for all a, b, c ∈ L. (d) . Absorption Law: a ∧ (a ∨ b) = a and a ∨ (a ∧ b) = a for all a, b ∈ L. Proof: (a). Since sup{a} = inf{a} = a for all a ∈ L therefore a ∧ a = a = a ∨ a for all a ∈ L. (b). Since sup{a, b} = sup{b, a} and inf{a, b} = inf{b, a} for all a, b ∈ L, therefore a ∧ b = b ∧ a and a ∨ b = b ∨ a hold for all a, b ∈ L. (c). Let a, b, c ∈ L. We claim that a ∧ (b ∧ c) = inf{a, b, c}. Let d = b ∧ c and e = a ∧ (b ∧ c. Since b ∧ c = d therefore d = inf{b, c} and so d is a lower bound, i.e; d ≤ b and d ≤ c

(3.5.1)

Now, e = a ∧ (b ∧ c) = inf{a, d}, hence e ≤ a and e ≤ d. Using equation3.5.1, e ≤ d and transitivity relation, we have e ≤ b, c. Thus, e ≤ a, b, c, i.e; e is a lower bound of {a, b, c}. Next, if f is a lower bound of {a, b, c}. Then f ≤ b, c and so f is a lower bound of {b, c}. But d = inf{b, c} thus f ≤ d. Since f ≤ a also and hence f is a lower bound of {a, d}. But e = inf{a, d}, then f ≤ e. This proves that e = inf{a, b, c}. Similarly, (a ∧ b) ∧ c = c ∧ (a ∧ b) = inf{c, a, b} = inf{a, b, c}. Combining these two, we have (a ∧ b) ∧ c = a ∧ (b ∧ c). Using duality principle, we have (a ∨ b) ∨ c = a ∨ (b ∨ c). (d). Let a, b ∈ L. Since a ≤ sup{a, b} = a ∨ b, therefore inf{a, a ∨ b} = a, that is; a ∧ (a ∨ b) = a. By duality principle, we have a ∨ (a ∧ b) = a. 2

3.5.2

Complete, Bounded and Complemented Lattices

Definition 3.5.14. A Lattice L is called a complete lattice if every nonempty subset of L has its supremum and infimum in L. For example, every finite lattice is complete. The lattices (R, ≤), (Q, ≤), (Z, ≤) and (N, ≤) are not complete. The infinite lattice ([a, b], ≤) is complete.

3.5. LATTICES

45

Definition 3.5.15. A lattice L is said to be bounded lattice if it has both least and greatest element. The least and greatest element of a bounded lattice is denoted by 0 and 1 respectively. For example, every finite lattice is a bounded lattice with least element inf L and greatest element sup L. Example 3.5.16. Let S be a non-empty set. Then the lattice (P(S), ⊆) is a bounded lattice with least element ∅ and greatest element S. Example 3.5.17. The lattices (R, ≤), (Q, ≤), (Z, ≤) and (N, ≤) are not bounded. The infinite lattice ([a, b], ≤) is bounded with least element a and greatest element b. Proposition 3.5.18. Every complete lattice is a bounded lattice. Proof: Let L be a complete lattice. Then L has both supremum and infimum in L. Clearly inf L and sup L are least and largest element of L. 2 Example 3.5.19. The lattice given by figure 3.10 is bounded with least element a and greatest element f but it is not complete as sup {c, b} does not exist. Definition 3.5.20. A lattice is said to be a distributive lattice if the meet operation is distributive over join operation and the join operation is distributive over meet operation, that is; if it satisfies the following property: a ∧ (b ∨ c) = (a ∧ b) ∨ (a ∧ c)

(3.5.2)

a ∨ (b ∧ c) = (a ∨ b) ∧ (a ∨ c)

(3.5.3)

and

for all a, b, c in L. Example 3.5.21. The lattice (P(S), ⊆) is a distributive lattice. Example 3.5.22. The lattice given by figure 3.11 is non-distributive because b ∧ (c ∨ d) = b ∧ a = b where as (b ∧ c) ∨ (b ∧ d) = e ∨ e = e. Proposition 3.5.23. In a lattice L, the following are equivalent: (i). a ∧ (b ∨ c) = (a ∧ b) ∨ (a ∧ c) (ii). a ∨ (b ∧ c) = (a ∨ b) ∧ (a ∨ c) .

46

CHAPTER 3. LATTICES a

d

c b

e

Figure 3.11: Non-distributive lattice Proof: Assume (i). Then (a ∨ b) ∧ (a ∨ c) = [(a ∨ b) ∧ a] ∨ [(a ∨ b) ∧ c] = a ∨ [(a ∨ b) ∧ c] since (a ∨ b) ∧ a = a) = a ∨ [(a ∧ c) ∨ (b ∧ c)] since (a ∨ b) ∧ c = c ∧ (a ∨ b) = [a ∨ (a ∧ c)] ∨ (b ∧ c) = a ∨ (b ∧ c) because a ∨ (a ∧ b) = a By duality, we have (ii)⇒ (i). 2 Proposition 3.5.24. Let L be a bounded lattice with least element 0 and greatest element 1. Then a ∨ 1 = 1, a ∧ 1 = a and a ∨ 0 = a, a ∧ 0 = 0 for all a ∈ L. Proof: Let a ∈ L. Since a ≤ 1 therefore by proposition 3.5.12, we have a ∨ 1 = 1 and a ∧ 1 = a. Next, since 0 ≤ a therefore a ∧ 0 = 0 and (a ∨ 0) = a (by Proposition 3.5.12). 2 Definition 3.5.25. Let L be a bounded lattice with least element 0 and greatest element 1.Let a ∈ L. An element b ∈ L is called a complement of a if a ∨ b = 1 and a ∧ b = 0. Example 3.5.26. Consider the lattice given by figure 3.12: Clearly this is a bounded lattice with least element g and greatest element a. The elements b and e are complements of d. This shows that complement of an element is not unique. It is also noted that b and e are complements of f . From this it follows that two elements may have same complement. Similarly complements of b and e are d and f respectively. It is also noted that an element in a bounded lattice may not have complement. For example, c has no complements.

3.5. LATTICES

47 a b d c e

f

g

Figure 3.12: Complements in a bounded lattice Definition 3.5.27. A lattice is said to be a complemented lattice if its every element has a complement. For example, consider the lattice given by figure 3.13 1

b c

a

0

Figure 3.13: Complemented Lattice Complement of 0 is 1 and complement of 1 is 0. c is the complement of a and b. Conversely a and b are complements of c. This shows that this lattice is a complementary lattice. Theorem 3.5.28. In a distributive lattice, if an element has a complement then it is unique. Proof: Let L be a distributive lattice and a ∈ L has complements. Suppose that b and c are complement of a. Then a ∨ b = 1 = a ∨ c and a ∧ b = 0 = a ∧ c. Now b = = = = = = = = 2

b∧1 b ∧ (a ∨ c) (b ∧ a) ∨ (b ∧ c) (by 3.5.2) 0 ∨ (b ∧ c) (a ∧ c) ∨ (b ∧ c) (a ∨ b) ∧ c 1∧c c

48

3.6

CHAPTER 3. LATTICES

Exercises

Exercise 3.6.1. Draw the diagram of the lattice of factors of 20. Exercise 3.6.2. Prove that the poset ({1, 2, 3, 4, 5}, /) is not a lattice, where / denotes the divisibility relation. Exercise 3.6.3. Draw the Hasse diagram for the divisibility relation on each of the following sets: (a). S = {3, 6, 12, 24, 48}. (b). S = {2, 3, 6, 12, 24, 36}

CHAPTER

4

Boolean Algebra

This algebraic structure was introduced by an English mathematician George Boole. An important application of Boolean algebra is in the analysis of electronic circuits and hence in the design of a range of digital devices such as computers, telephone systems and electronic control systems. Definition 4.0.1. Let B be a non-empty set with two binary operations +and ·, a unary operation 0 , and two distinct elements 0 and 1. Then B is called a Boolean algebra if it satisfies the following 1. Commutative law: a + b = b + a and a · b = b · a for all a, b ∈ B. 2. Distributive laws: a+(b·c) = (a+b)·(a+c) and a·(b+c) = (a·b)+(a·c) for all a, b, c ∈ B. 3. Identity laws: a + 0 = a = 0 + a and a · 1 = a = 1 · a for all a ∈ B. 4. Complement laws: a + a0 = 1 and a · a0 = 0 for all a ∈ B. It is denoted by (B, +, ·, 0 , 0, 1). The additive identity 0 is called the zero element, the multiplicative identity 1 is called the unit element or unity, and a0 is called the complement of a. We frequently write bc instead of (b.c). Thus, the distributive law becomes a(b + c) = ab + ac and a + bc = (a + b)(a + c) 49

50

CHAPTER 4. BOOLEAN ALGEBRA

respectively. The operations +, ·, and respectively.

0

are called sum, product, and complement

Remark 4.0.2. Some authors use associativity axiom in the definition of Boolean algebra. But it is a redundant condition (see, Theorem 4.1.7 ). Example 4.0.3. Let B = {0, 1}, the set of bits (binary digits), with the binary operations of + and · and the unary operation 0 defined by the following composition table: + 0 1 . 0 1 0 0 1 0 0 0 and 00 = 1, 10 = 0. 1 1 1 1 0 1 From the composition tables, it is clear that associative law, commutative law, identity law and complement law hold respectively. One can easily verify the distributive law. Thus, B is a Boolean algebra. Exercise 4.0.4. Evaluate (i) (0 + 1).0, (ii) 0.10 , (iii) (1.1) + (0.00 ) (iv)10 + [(0.1).1] and (v) [(0.1).1).(10 + 1)] + 1 for Boolean algebra B = {0, 1} given in example 4.0.3. Example 4.0.5. Let B = {0, 1} be a Boolean algebra described as in above example. Let B n = B {z. . . × B}. Define binary operations + and · | ×B× n−times

component wise using 1 + 1 = 0 + 1 = 1 + 0 = 1, 0 + 0 = 0 and 0.1 = 0 = 1.0 = 0.0, 1.1 = 1 respectively; that is, (x1 , x2 . . . , xn ).(y1 , y2 . . . yn ) = (x1 .y1 , x2 .y2 , . . . , xn .yn ) (x1 , x2 . . . , xn ) + (y1 , y2 . . . yn ) = (x1 + y1 , x2 + y2 , . . . , xn + yn ). The unary operation 0 on B n is given by (x1 , x2 , . . . , xn )0 = (x01 , x02 , . . . , x0n ) where xi ∈ {0, 1}∀i and 00 = 1, 10 = 0. Using Boolean properties of B, we observe that B n is a Boolean algebra with zero element (0, 0, . . . , 0) and unity (1, 1, . . . , 1). We simply write (x1 , x2 , . . . , xn ) as x1 x2 . . . xn (string of n−bits). Clearly B n has 2n elements. Take n = 3, then 111 + 011 = 111, 111.011 = 011 and (010)0 = 101.

51 Example 4.0.6. Let D(35) = {1, 5, 7, 35} be the set of all positive divisors of 35. Define +, ·, and 0 on D(35) by a + b = [a, b] (lcm of a and b), a · b = (a, b) (Gcd of a and b) and a0 = 35 . Then a+b = b+a, ab = ba, a+1 = a, a.35 = a a and a + a0 = 35, a.1 = 1 respectively. Using composition table one may easily observe that the associative law and distributive law holds. Thus, D(35) is a Boolean algebra with 1 the zero element and 35 the unit element. Example 4.0.7. Let D(70) = {1, 2, 5, 7, 10, 14, 35, 70} be the set of all positive divisors of 70. Define +, ·, and 0 on D(70) by a + b = [a, b] (LCM of . Then a + b = b + a, a and b), a · b = (a, b) (Gcd of a and b) and a0 = 70 a 0 ab = ba, a + 1 = a, a.35 = a and a + a = 35, a.1 = 1 respectively. Using composition table one may easily observe that the associative law and distributive law holds. Thus, D(70) is a Boolean algebra whose zero element is 1 and unity element 70. Exercise 4.0.8. Show that the set of all divisors of 30 forms a Boolean algebra, where +, . and 0 are described in above examples. What about the sets B1 , the set of all divisors of 24 and B2 , the set of all divisors of 42. Also, what about the set of divisors of 45? Example 4.0.9. Let S be a non-empty set. Let P(S) be the power set of S and 0 denotes the complement operation, that is; A0 = S \ A for A ∈ P(S). Then (P(S), ∪, ∩,0 , 0, 1) is a Boolean algebra whose zero element is ∅ and unity element is S. Example 4.0.10. Let B be a set of propositions which is closed under the operations of conjunction, disjunction and negation and where equality of propositions is interpreted as their logical equivalence. In chapter 1, we observed that the operations ∨ and ∧ are associative, commutative and that each is distributive over the other. If we denote a contradiction (a proposition which is always false) by f and a tautology (a proposition which is always true) by t. For any proposition p belonging to B, p ∧ (−p) ≡ f and p∨(−p) ≡ t belong to B (by the closure properties). Thus, t, f ∈ B. Further, for any p ∈ B, we have p ∨ f ≡ f ∨ p ≡ p and p ∧ t ≡ t ∧ p ≡ p. Thus f and t are the identities for the binary operations ∨ and ∧ respectively. All contradictions are logically equivalent as are all tautologies so that t and f are unique elements of B. Therefore structure (B, ∨, ∧, −, f, t) is a Boolean algebra. The operations ∨ and ∧ correspond to + and . respectively. Here f is the zero element and t is multiplicative identity.

52

CHAPTER 4. BOOLEAN ALGEBRA

Theorem 4.0.11. (Principle of duality). It states that if a result is true then its dual is also true.

4.1

Properties of Boolean Algebra

Proposition 4.1.1. (Uniqueness of complements): In a given Boolean Algebra B, a0 is unique for each a ∈ B. Proof: Let x and y be any two complements of a ∈ B. Then a + x = 1, ax = 0 and a + y = 1, ay = 0. Now x = = = = = = = =

x+0 (because x + 0 = x) x + ay (because ay = 0) (x + a)(x + y) (by distributive law) x+y y+x (y + a)(y + x) (because y + a = 1) y + ax (by distributive law) y + 0 = y.

2 Proposition 4.1.2. (Involutory law): In a given Boolean Algebra B, (a0 )0 = a for all a ∈ B. Proof: Since a + a0 = 1 and aa0 = 0 for all a ∈ B, therefore a0 + a = 1 and a0 a = 0. By complement law, we have (a0 )0 = a. 2 Proposition 4.1.3. (Idempotent Law): In a Boolean algebra, a + a = a and aa = a for all a. Proof: Let a ∈ B. a = = = =

a+0 a + aa0 (as aa0 = 0) (a + a)(a + a0 ) (distributive law) 0 a+a (as a + a = 1 and a.1 = 1)

4.1. PROPERTIES OF BOOLEAN ALGEBRA

53

and a = = = =

a.1 a(a + a0 ) (as a + a0 = 1) aa + aa0 ) (distributive law) 0 aa (as aa = 0 and a + 0 = a)

This proves the result. 2 Proposition 4.1.4. (Boundedness law). In a Boolean algebra B, a+1 = 1 and a.0 = 0 for all a ∈ B. Proof: Let a ∈ B. Then a+1 = = = = = a.0 = = = = =

1(a + 1) (a + a0 )(a + 1) (as a + a0 = 1) a + a0 1) (distributive law) 0 a+a 1 (as a + a0 = 1) 0 + a.0 aa0 + a.0 a(a0 + 0) a.a0 0

2 Proposition 4.1.5. In a Boolean algebra B, a+a0 b = a+b and a0 +ab = a0 +b for all a, b ∈ B. Proof: Let a, b ∈ B. Then a + a0 b = (a + a0 )(a + b) (distributive law) = 1.(a + b) (complement law) = a+b Replacing a by a0 and using involutory law, we have a0 + ab = a0 + b. 2

54

CHAPTER 4. BOOLEAN ALGEBRA

Proposition 4.1.6. (Absorption Law). In a Boolean algebra B, a+ab = a and a(a + b) = a for all a, b ∈ B. Proof: Let a, b ∈ B. Then a + ab = a.1 + a.b = a(1 + b) = a, because 1 + b = b. Since a(a + b) = a + ab as aa = a, therefore a(a + b) = a. This proves the absorption law. 2 Theorem 4.1.7. (Associative law): In a given Boolean algebra B, a + (b + c) = (a + b) + c and (ab)c = a(bc) holds for all a, b, c ∈ B. Proof: Let a, b, c ∈ B. Then a + [a(bc)] = = = =

a by absorption law a(a + c) by absorption law (a + ab)(a + c) by absorption law a + (ab)c by distributive law

and a0 + [a(bc)] = = = = = =

(a0 + a)(a0 + bc) by distributive law 0 1(a + bc) (a0 + b)(a0 + c) by distributive law 0 0 0 [(a + a)(a + b)](a + c) a0 + a = 1 (a0 + ab)(a0 + c) by distributive law 0 a + (ab)c

Now (ab)c = = = = = = =

0 + (ab)c aa0 + (ab)c (a + (ab)c) + (a0 + (ab)c) (a + a(bc)) + (a0 + a(bc)) using eqns. 4.1.1, 4.1.1 0 (a + a ) + (a(bc)) by distributive law 0 + a(bc) a(bc)

Using the principle of duality, we have a + (b + c) = (a + b) + c. 2

4.1. PROPERTIES OF BOOLEAN ALGEBRA

55

Proposition 4.1.8. (De Morgans Law) (a + b)0 = a0 b0 and (ab)0 = a0 + b0 for all a, b in a given Boolean algebra B. Proof: Let a, b ∈ B. Then (a + b) + a0 b0 = = = =

(a + b + a0 )(a + b + b0 ) (1 + b)(1 + a) (by commutative and complement law) 1.1 (as a + 1 = 1∀a ∈ B) 1.

and (a + b)a0 b0 = (aa0 )b0 + a0 (bb0 ) = 0b0 + 0a0 = 0

(by distributive and associative law)

Thus, by uniqueness of complements, we have (a + b)0 = a0 b0 . Next, (ab) + (a0 + b0 ) = = = = =

(a0 + b0 ) + (ab) (by commutative law) 0 0 0 0 (a + b + a)(a + b + b) (by distributive law) 0 0 (1 + b ).(1 + a ) (as a + a0 = 1∀a ∈ B) 1.1 (a + 1 = 1 ∀a ∈ B) 1.

Thus, by uniqueness of complements, we have (ab)0 = a0 + b0 . 2 Proposition 4.1.9. In a Boolean algebra B, 00 = 1 and 10 = 0 Proof: By boundedness law, 1+0 = 1 and 1.0 = 0. Thus, by uniqueness of complements, 10 = 0 and 00 = 1. 2 Remark 4.1.10. There is no Boolean Algebra containing 3 elements. For if, B is a Boolean algebra having three elements, then a ∈ B such that a 6= 0, 1 and a0 = a. But, by complement law a + a0 = 1, that is; a + a = 1 and so by idempotent law a = 1 which is a contradiction because a 6= 1. Proposition 4.1.11. In a Boolean algebra B, the following are equivalent: (a). a + b = b, (b). ab = a, (c). a0 + b = 1, (d). ab0 = 0.

56

CHAPTER 4. BOOLEAN ALGEBRA Proof: Let a, b ∈ B. (a) ⇔ (b). Assume (a). Then a = a + ab (by absorption law) = (a + a)(a + b) (by distributive law) = ab (as a + a = a and a + b = b)

Next, if ab = a then a + b = ab + b = b, by absorption law. Thus (a) ⇔ (b) holds. (a) ⇔ (c). Assume (a). Then a0 +b = a0 +(a+b) = 1, by complement and boundedness law. Next, if a0 + b = 1 then a + b = 1(a + b) = (a0 + b)(a + b) = a0 a + b = 0 + b = b. (a) ⇔ (d). Assume that a + b = b, then ab0 = a(a + b)0 = aa0 b0 = 0 because (a + b)0 = a0 b0 and aa0 = 0. Next, if ab0 = 0 then we have a + b = (a + b)1 = (a + b)(b0 + b) = ab0 + b = 0 + b = b. This proves the result. 2

4.2

Subalgebras And Isomorphisms

Definition 4.2.1. A non-empty set C of a Boolean algebra B is called a subalgebra if it is itself a Boolean algebra with respect to induced operations on C. Observe that B and {0, 1} are subalgebras of a given Boolean algebra B. Theorem 4.2.2. A non-empty subset S of a Boolean algebra B is a subalgebra if and only if a + b, ab, a0 ∈ S for all a, b ∈ B. Proof: The proof is left as an exercise for readers.2 Theorem 4.2.3. A non-empty subset S of a Boolean algebra B is a subalgebra if and only if a + b, a0 ∈ S for all a, b ∈ B. Proof: The proof is left as an exercise for readers.2 Example 4.2.4. The subsets {1, 5, 14, 70} and {1, 2, 35, 70} are subalgebras of Boolean algebra D(70), where a + b = [a, b] (lcm of a and b), a · b = (a, b) . (Gcd of a and b) and a0 = 70 a

4.3. BOOLEAN ALGEBRA AS A LATTICE

57

Example 4.2.5. Let B be a Boolean algebra and a ∈ B. Then S = {0, 1, a, a0 } is a Boolean subalgebra of B. This subalgebra is denoted by hai and is called subalgebra generated by the element a. Proposition 4.2.6. Intersection of a family of Boolean subalgebra is a Boolean subalgebra. Definition 4.2.7. (Subalgebra generated by a subset). Let S be a non-empty subset of a Boolean algebra B. Then the intersection of all subalgebras containing S is the smallest subalgebra denoted by hSi and is called a subalgebra generated by a subset S. Definition 4.2.8. Two Boolean algebras B1 and B2 are said to be isomorphic if there is a one-one onto map f : B1 → B2 such that f (a + b) = f (a) + f (b),

f (ab) = f (a)f (b)

and f (a0 ) = f (a)0

for all a, b ∈ B1 . In this case the map f is called an isomorphism. Example 4.2.9. Subalgebras {1, 5, 14, 70} and {1, 2, 35, 70} of Boolean algebra D(70) are isomorphic under isomorphism f given by f (1) = 1, f (5) = 2, f (14) = 35, f (70) = 70. Definition 4.2.10. The dual of any expression in an Boolean algebra B is obtained by replacing + y ·, · by +, 0 by 1 and 1 by 0. Thus, dual of a + bc is a · (b + c).

4.3

Boolean algebra as a lattice

Proposition 4.3.1. Let B be a Boolean algebra. Define a relation ≤ on B by a ≤ b if and only if ab0 = 0. Then (B, ≤) is a poset. Proof: Since aa0 = 0 for every a, therefore a ≤ a for every a ∈ B. This proves the reflexivity. Next, let a ≤ b and b ≤ a. Then ab0 = 0 and ba0 = 0 and so a = a(b + b0 ) = ab + ab0 = ab + 0 = ab + ba0 = b(a + a0 ) = b. This proves that ≤ is anti-symmetric. Next, let a ≤ b and b ≤ c. Then ab0 = 0 = bc0 and so ac0 = (a1)c0 = a(b + b0 )c0 = a(bc0 ) + (ab0 )c0 = 0 + 0 = 0. Thus, a ≤ c. This proves that ≤ is transitive. Thus ≤ is a partial order relation on B. 2

58

CHAPTER 4. BOOLEAN ALGEBRA

Theorem 4.3.2. Every Boolean algebra can be treated as a lattice. Proof: Let B be a Boolean algebra. Define a relation ≤ on B as follows: a ≤ b if and only if ab0 = 0. By proposition 4.3.1, (B, ≤) is a poset. Let a, b ∈ B. To prove B is a lattice it is sufficient to prove that a + b = sup {a, b} and ab = inf{a, b}. Since a(a + b)0 = (aa0 )b0 = 0 and b(a + b)0 = a(bb0 ) = 0 thus a, b ≤ a + b. Next, let c ∈ B such that a, b ≤ c. Then ac0 = 0 = bc0 and so (a + b)c0 = ac0 + bc0 = 0, that is; a + b ≤ c. thus a + b = sup{a, b}. Similarly (ab)a0 = 0 = (ab)b0 and if d ≤ a, b then da0 = 0 = db0 and so d(ab)0 = d(a0 + b0 ) = 0. Thus ab = inf{a, b}. This proves the result. 2 Remark 4.3.3. The lattice whose Hasse diagram is given by 3.12 is not a Boolean algebra because b and e both are complements of d (Note that complements of any element in a Boolean algebra is unique). Corollary 4.3.4. (B, ≤) is a bounded, complemented and distributive lattice with least element 0 and greatest element 1.2

4.4

Representation theorem

Definition 4.4.1. A Boolean algebra B is said to be finite Boolean algebra if it has finite number of elements. Let B be a Boolean algebra. Then (B, ≤) is a lattice , where a ≤ b if and only if ab0 = 0. An element a ∈ B is said to be atom if 0 ≤ a and there is no b ∈ B such that 0 < b < a. By a little effort one may easily observe the following: Lemma 4.4.2. If B is a finite Boolean algebra, then we have the following: (1). for every non-zero element b ∈ B, there is an atom a such that a ≤ b, (2). If a and b are any two distinct atoms then ab = 0, (3). every b ∈ B is uniquely expressed as b = a1 + a2 + . . . + ak , where a1 , a2 , . . . , ak are atoms such that ai ≤ b for all 1 ≤ i ≤ k. Proof: Proof is left for readers.2 Corollary 4.4.3. The sum of all atoms in a finite Boolean algebra is 1.

4.5. CONJUNCTIVE AND DISJUNCTIVE NORMAL FORMS

59

This results motivates us to give the following: Theorem 4.4.4. (Representation theorem) Let B be a finite Boolean algebra and S be the set of all atoms in B. Then the map f : B → P(S) defined by f (a1 + a2 + . . . + ak ) = {a1 , a2 , . . . , ak }

(4.4.1)

where a0i s are atoms in B; is an isomorphism of Boolean algebras. Proof: It is left for readers.2 Corollary 4.4.5. Every finite Boolean algebra has 2n elements for some n ∈ N. Proof: The proof follows from the fact that P(S) has 2n elements, where n = |S|.2 Exercise 4.4.6. Let B be a given Boolean algebra. If a ≤ b then prove that a + bc = b(a + c) (observe that a ≤ b ⇒ a + b = b).

4.5

Conjunctive and Disjunctive normal forms

Definition 4.5.1. Let B be a Boolean algebra. Then a variable which assigns elements of B is called a Boolean variable. Throughout the chapter, we use the word ‘variable’ for Boolean variable. The complement of a Boolean variable x is denoted by x0 . Definition 4.5.2. (Literal). A literal is a Boolean variable x or its complement x0 . Thus, if x1 , x2 , . . ., xn are variables (Boolean) then x1 , x2 , . . ., xn and x01 , x02 , . . ., x0n are literals. It is noted that literals x and x0 involve the same variable x. Definition 4.5.3. Consider a set of variables (or letters or symbols), say x1 , x2 , . . ., xn . Then any variable or any expression which is formed from the variables using the Boolean operations +, ·, and 0 , is called a Boolean expression. It is noted that 0, 1 are Boolean expressions as xx0 = 0 and x+x0 = 1. One may easily observe that any Boolean expression in n variables determines a function f : B n → B called Boolean function. In other words, a Boolean function of the n variables x1 , x2 , . . . , xn is a function f : B n → B such that f (x1 , x2 , . . . , xn ) is a Boolean expression.

60

CHAPTER 4. BOOLEAN ALGEBRA

Example 4.5.4. (x + y + z 0 )0 and xyz + x0 + y are Boolean expressions in variables x, y, and z. Definition 4.5.5. (Equivalent). Two Boolean expressions are said to be equivalent (or equal) if one can be obtained from the other by a finite sequence of applications of the Boolean algebra axioms. Thus, x + x0 and 1, 0 and xx0 are equivalent Boolean expressions respectively. Similarly, x(y + z) + x + x0 and xy + xz are equivalent Boolean expressions. Thus, it follows from the definition that equivalent Boolean expressions define the same function. For example; two Boolean functions f and g given by f (x, y, z) = x(y + z) + x + x0 and g(x, y, z) = xy + xz respectively are equal. Since a particular Boolean expression may have a number of equivalent forms, there arises the question of how we can decide whether or not two Boolean expressions are equivalent and hence whether or not two Boolean functions are equal. Fortunately there is an alternative method of establishing the equivalence of two Boolean expressions but, before we can consider this, we need some more definitions. Let x be a Boolean variable and e ∈ {0, 1}. We define xe as follows  x if e = 1 e x = x0 if e = 0 Definition 4.5.6. (Minterms). Let x1 , x2 , . . . , xn be any n-variables. Then a Boolean expression of the form x1 e1 x2 e2 . . . xn en , where ei ∈ {0, 1} for all i = 1, 2, . . . , n is called a minterm or complete product in n variables x1 , x2 , . . . , xn . Thus, a minterm in n− variables is the product of each Boolean variable or its complement, i.e; minterm consists of the product of n literals, one corresponding to each Boolean variable. It is denoted by me1 e2 ...en . Thus, me1 e2 ...en = xe11 xe22 . . . xenn . For example, m1 = x, m0 = x0 are two minterms in one variable. Similarly, m11 = x1 x2 , m01 = x01 x2 , m10 = x1 x02 and m00 = x01 x02 are all minterms in two variables x1 , x2 . Observe that the total number of nonequivalent minterms in n variables is 2n . Similarly, minterm m10001 in variables x1 , x2 , x3 , x4 and x5 is given by m10001 = x1 x02 x03 x04 x5 .

4.5. CONJUNCTIVE AND DISJUNCTIVE NORMAL FORMS

61

Of these 2n minterms, no two are equivalent. This can be verified by appropriate substitution of the values 0 or 1 for each variable. Given two minterms, it is always possible to assign the value 0 or 1 to each variable so that evaluating each minterm gives a different result. For example, consider m010 = x01 x2 x03 and m111 = x1 x2 x3 . Substituting x1 = 0, x2 = 1, x3 = 0, we have m010 = 1 and m111 = 0. Thus, m010 and m111 are not equivalent Boolean expressions. Indeed, we have Theorem 4.5.7. Of the 2n minterms in the variables x1 , x2 , . . . , xn , no two are equivalent Boolean expressions. Proof: We first note that 00 = 00 = 1 and 11 = 1 so that, if xi = ei , xi ei = 1. This means that, given a minterm m = me1 e2 ...en = x1 e1 x2 e2 . . . xn en substituting xi = ei for i = 1, 2, ..., n gives the product of n terms all of which are equal to 1 and so the minterm is equal to 1. Now any other minterm contains at least one literal which is the complement of a literal contained in m and so substitution of the values xi = ei (i = 1, 2, . . . , n) as above results in a product which contains at least one zero. Hence, the product is zero. We have shown that for any two distinct minterms there is at least one set of values of the variables for which the minterms have different values. We can therefore conclude that no two distinct minterms are equivalent. 2 Definition 4.5.8. (Maxterms). A maxterm (or complete sum) in the n variables x1 , x2 , . . ., xn is a Boolean expression of the form xe11 +xe22 +. . .+xenn . Thus, a maxterm in n variables x1 , x2 , . . ., xn consists of the sum of n literals. It is denoted by Me1 e2 ...en . Thus, Me1 e2 ...en =e11 +xe22 + . . . + xenn . For example, M11 = x1 + x2 , M01 = x01 + x2 , M10 = x1 + x02 and M00 = x01 + x02 are all maxterms in two variables x1 and x2 . As with minterms, there are 2n possible maxterms in n variables and (by the duality principle) no two of these are equivalent Boolean expressions.

62

4.5.1

CHAPTER 4. BOOLEAN ALGEBRA

Disjunctive normal form

Definition 4.5.9. A Boolean expression f (x1 , x2 , . . . , xn ) is said to be a disjunctive normal form if f is a sum of some or all of 2n minterms in all n variables. It is sometimes called canonical (or complete) sum-ofproducts form Example 4.5.10. The disjunctive normal form of f (x, y, z) = x(y 0 z)0 + x is given by f (x, y, z) = = = = = = = = = =

x(y 0 z)0 + x x(y 00 + z 0 ) + x1 (by DeM organs law and x1 = x) 0 0 x(y + z ) + x(y + y ) (by involutory lawand y + y 0 = 1) xy + xz 0 + xy + xy 0 (by distributive law) 0 0 xy + xy + xz (by idempotent law) 0 xy.1 + xy .1 + x.1.z 0 xy(z + z 0 ) + xy 0 (z + z 0 ) + xz 0 (y + y 0 ) (by complement law) 0 0 0 0 0 0 0 xyz + xyz + xy z + xy z + xyz + xy z (by distributive law) xyz + xy 0 z + (xyz 0 + xyz 0 ) + (xy 0 z 0 + xy 0 z 0 ) xyz + xy 0 z + xyz 0 + xy 0 z 0 (by idempotent law)

Exercise 4.5.11. Prove that the disjunctive normal form of Boolean expression x1 x2 (x1 + x3 ) is x1 x2 x3 + x1 x2 x03 Exercise 4.5.12. Express f (x, y, z) = x(y 0 z)0 +yz into its disjunctive normal form of f (x, y, z). Theorem 4.5.13. Every non-zero Boolean expression f = f (x1 , x2 , . . . , xn ) is equivalent to a disjunctive normal form, i.e, X f (x1 , x2 , ..., xn ) = f (e1 , e2 , ..., en )xe11 xe22 , ...xenn (e)

=

X

f (e1 , e2 , ..., en )me1 e2 ...en

(e)

where (e) denotes all possible 2n n-tuples (e1 , e2 , ..., en ) where ei = 0 or 1 for all i = 1, 2, ..., n. Such representation is unique (up to reordering of the minterms in the expression).

4.5. CONJUNCTIVE AND DISJUNCTIVE NORMAL FORMS

63

Proof: The proof is given in [2] (see Theorem 9.10, page 449 and Theorem 9.11, page 452-453).2 Example 4.5.14. Using above theorem, the disjunctive normal form of x+y is f (0, 0)x0 y 0 + f (1, 0)xy 0 + f (0, 1)x0 y + f (1, 1)xy where f (e1 , e2 ) is given by e1 1 1 0 0

e2 0 1 0 1

f (e1 , e2 ) = e1 + e2 1 1 . 0 1

Thus, the corresponding disjunctive normal form is given by x + y = 0.x0 y 0 + 1.xy 0 + 1.xy + 1.x0 y = = xy 0 + xy + x0 y . Example 4.5.15. Consider the Boolean expression f (x, y, z) = yz + xz. Then its disjunctive normal form is f (x, y, z) = f (0, 0, 0)x0 y 0 z 0 + f (0, 1, 0)x0 yz 0 + f (0, 1, 1)x0 y 0 z 0 + f (0, 0, 1)x0 y 0 z +f (1, 0, 0)xy 0 z 0 + f (1, 1, 0)xyz 0 + f (1, 1, 1)xyz + f (1, 0, 1)xy 0 z, where the value of f (e1 , e2 , e3 ) is given by following table: e1 1 1 1 1 0 0 0 0

e2 1 1 0 0 1 1 0 0

e3 1 0 1 0 1 0 1 0

f (e1 , e2 , e3 ) = e2 e3 + e1 e3 1.1 + 1.1 = 1 + 1 = 1 1.0 + 1.0 = 0 + 0 = 0 1.1 + 0.1 = 1 + 0 = 1 1.0 + 0.0 = 0 1.1 + 0.1 = 1 1.0 + 0.0 = 0 0.1 + 0.1 = 0 0.0 + 0.0 = 0

From the table, it is clear that f (e1 , e2 , e3 ) = 1 for (e1 , e2 , e3 ) = (1, 1, 1), (1, 0, 1) and (0, 1, 1) and so minterms xe1 y e2 z e3 corresponding to these are xyz, xy 0 z and x0 yz respectively. Thus, disjunctive normal form is xyz + xy 0 z + x0 yz.

64

CHAPTER 4. BOOLEAN ALGEBRA

Definition 4.5.16. Two or more Boolean functions are equal if and only if they have the same disjunctive normal form. Example 4.5.17. Show that f (x1 , x2 ) = x1 + x2 and g(x1 , x2 ) = x01 x2 + x1 are equal functions. Solution: Consider the following table: e1 1 1 0 0

e2 0 1 0 1

e01 0 0 1 1

e02 1 0 1 0

e1 + e2 1+0=1 1+1=1 0+0=0 0+1=1

e01 e2 + e1 0.0 + 1 = 1 0.1 + 1 = 1 1.0 + 0 = 0 1.1 + 0 = 1

Since f = g for all (e1 , e2 ) therefore their disjunctive normal forms will be same, i.e; f (x1 , x2 ) = g(x1 , x2 ) = x1 x02 +x1 x2 +x01 x2 . Hence the two functions are equal. Example 4.5.18. The Boolean function f (x1 , x2 ) for which f (0, 0) = 1 = f (0, 1) = f (1, 0) and f (1, 1) = 0 is f (x1 , x2 ) = x01 x02 + x01 x2 + x1 x02 and so f (x1 , x2 ) = x01 x2 + x02 .

4.5.2

Conjunctive normal form

Definition 4.5.19. A Boolean expression f (x1 , x2 , . . . , xn ) is said to be a conjunctive normal form or complete product of sums expression if f is expressed as product of maxterms in n variables. Observe that the maximum number of maxterms in a complete product of sums expression in n variables is 2n .. By duality principle, dual of Theorem 4.5.13 will be Theorem 4.5.20. Every non-identity Boolean expression f = f (x1 , x2 , . . . , xn ) is equivalent to a conjunctive normal form and such a representation is unique up to order and arrangement; i.e; Y 0 e0 e0 f (x1 , x2 , . . . , xn ) = [f (e1 , e2 , . . . , en ) + x11 + x22 + . . . + xenn ] (e)

=

Y

 f (e1 , e2 , . . . , en ) + Me01 e02 ...e0n ,

(e)

where (e) denotes all possible n− tuples (e1 , e2 , . . . , en ) with ei ∈ {0, 1} for all i = 1, 2, . . . , n.

4.5. CONJUNCTIVE AND DISJUNCTIVE NORMAL FORMS

65

Proof: The proof is left for readers.2 Since ei = 0 or 1, therefore f (e1 , e2 , . . . , en ) is either 0 or 1. Now, 0+x = x and 1 + x = x for all x ∈ B. Thus, conjunctive normal form will be the e0 e0 e0 product of only those maxterms Me01 e02 ...e0n = x11 + x22 + . . . + xnn for which f (e1 , e2 , . . . , en ) = 0. It is illustrated by following examples: Example 4.5.21. The conjunctive normal form of f (x, y) = xy 0 is [f (0, 0) + x + y][f (0, 1) + x + y 0 ] + [f (1, 0) + x0 + y] + [f (1, 1) + x0 + y 0 ] where f (e1 , e2 ) is given by the following table: e1 1 1 0 0

e2 1 0 1 0

f (e1 , e2 ) = e1 e02 1.0 = 0 1.1 = 1 0.1 = 0 0.1 = 0

Thus, conjunctive normal form is (0+x0 +y 0 )(1+x0 +y)(0+x+y 0 )(0+x+y) = (x0 + y 0 )(x + y 0 )(x + y). Exercise 4.5.22. Prove that the conjunctive normal form of f (x1 , x2 , x3 ) = (x1 + x2 )(x1 + x03 ) is (x01 + x2 + x3 )(x01 + x2 + x03 )(x01 + x02 + x03 ). Exercise 4.5.23. Express each of the following Boolean functions in disjunctive normal form and hence state which of the functions are equal: 1. f (x1 , x2 ) = x01 x2 + x1 x2 , 2. f (x1 , x2 ) = x1 , 3. f (x1 , x2 ) = x1 (x01 + x2 ), 4. f (x1 , x2 ) = x1 x2 , 5. f (x1 , x2 ) = (x1 + x2 )(x1 + x2 ), 6. f (x1 , x2 , x3 ) = x2 (x1 x3 + x1 ), 7. f (x1 , x2 , x3 ) = x1 + x2 + x3 ,

66

CHAPTER 4. BOOLEAN ALGEBRA 8. f (x1 , x2 , x3 ) = x2 (x1 + x3 ).

Exercise 4.5.24. Express each of the following Boolean functions f (x1 , x2 , x3 ) in both disjunctive and conjunctive normal forms: 1. x1 + x2 + x03 , 2. x1 x2 + x03 + x1 , 3. (x2 + x3 )x1 , 4. x01 x2 + x1 x3 .

4.6

Logic Gates

Definition 4.6.1. An electronic component, incorporated within a circuit, which operates on one or more inputs to produce one output is called a logic gate. There are mainly three types of logic gates: (1). OR gate (2). AND gate and (3) NOT gate (Inverter). Definition 4.6.2. The OR gate is a circuit that receives two inputs and produces one output as shown in the figure 4.1(a). If x, y are inputs of OR z =x+y

x

x

z =x+y

1

1

1

0

1

1

1

0 y

y

0

0

1

0

(b)

(a)

Figure 4.1: OR gate gate, then its output is denoted by x + y (or x ∨ y) and is given by the truth table 4.1(b). Thus,  x+y =

0 if x = y = 0 1 otherwise

4.6. LOGIC GATES

67

x xy

x

y

xy

1

1

1

0

1 0

0

1

0

0

0

y

0

(a) (b)

Figure 4.2: AND gate Definition 4.6.3. The AND gate is a circuit that receives two inputs and produces one output as shown in the figure 4.2(a). If x, y are inputs of AND gate, then its output is denoted by xy (x ∧ y) and is given by the truth table 4.2(b). Thus,  1 if x = y = 1 xy = 0 otherwise It is noted that AND and OR gates may use more than two inputs also. Definition 4.6.4. The NOT gate (inverter) is a circuit that receives one input x and produces one output x0 as shown in the figure 4.3(a) where x0

x x0

1

0

x 0

1

(a) (b)

Figure 4.3: NOT gate

0

x =



0 if x = 1 1 if x = 0

Thus, if x is an input of NOT gate, then its output is denoted by x0 (−x) and is given by the truth table 4.3(b). Definition 4.6.5. The NAND-gate is shown symbolically as the following:

68

CHAPTER 4. BOOLEAN ALGEBRA

x x

y

(xy)0

1

0

1 0

0

0

1

0

1

0

0

1 (xy)0 = x0 + y 0

y

xy

1

0

1

1

(a) (b)

The Boolean expression for its output is (xy)0 . By De Morgans law (xy)0 = x0 + y 0 . Definition 4.6.6. The NOR-gate is shown symbolically as the following: (x + y)0

x y

The output is given by the following table: x y 1 0 1 1 0 0 0 1

(x + y)0 0 0 1 0

The Boolean expression for its output is (x + y)0 . By De Morgan’s law (x + y)0 = x0 y 0 .

4.7

Logic Circuits

A circuit L which is constructed using a combination of inverters (NOT gates), OR gates and AND gates is called a logic gate. The combination given by figure 4.4 is a logic circuit. From the figure it is clear that if inputs are Boolean variables then output is a Boolean expression. Thus, every Boolean expression determines a logic circuit. It is also noted that every Boolean expression determines a logic circuit. For example, the logic circuit corresponding to Boolean expression xyz + xz 0 + yz 0 is given by figure 4.5 Indeed, we have:

4.7. LOGIC CIRCUITS

69

x+y

x y

x

(x + y)(x0 + z)

(x + y)(x0 + z) y

x0

x

x+y

z

x0

or

x0 + z

z

x0 + z

Figure 4.4: Same logic circuit with different representations x xyz y z

xyz + yz 0 + xz 0 yz

0

z0 z0 xz 0

Figure 4.5: Logic circuit for xyz + xz 0 + yz 0 Theorem 4.7.1. Logic circuits form a Boolean Algebra. Exercise 4.7.2. Give a Boolean expression describing the output of each of the following logic networks:

x y z x y z Exercise 4.7.3. Design a logic network for each of the following so that the output is described by the following Boolean expression: 1. (x + y + z 0 )y 0 z + x, 2. xy(z + x0 ) + y 0 .

70

CHAPTER 4. BOOLEAN ALGEBRA

4.8

Minimization of Boolean expressions and Karnaugh Maps

As we know that a non-zero Boolean expression can be expressed in disjunctive normal forms and be reduced to a Boolean expression which involves minimal number of variables and minimal number of terms (by successive use of absorption law and distributive law). Such Boolean expression is said to be in minimal form. A Karnaugh map is a diagrammatic representation of a Boolean expression in disjunctive normal form. It consists of a rectangle divided into subrectangles referred to as cells where each cell may be taken to represent a minterm. For a given number of variables, the cells within the Karnaugh map represent all the possible minterms which may appear in the disjunctive normal form of a Boolean expression. The minterms are allocated to the cells in such a way that adjacent cells represent minterms in which all the literals are identical except for one which is complemented in one cell but not in an adjacent one. Thus, movement around the map from cell to cell (up or down, to left or right, but not diagonally) gives a sequence of minterms where each is different by just one literal from the last. It is noted that the requirement that adjacent cells differ by just one literal also applies at the edges of the map if we view the rightmost column of cells as being adjacent to the left-hand column and also the top and bottom rows as being adjacent. The minterms represented by the cells in a Karnaugh map for a Boolean expression in the two variables x1 and x2 are shown in the diagram below. x1

x01

x02

x2

x2

x1 x2

x01 x2

x1

x02

x1 x02

x01 x02

x01

x1 x2

x01 x2

x1 x02

x01 x02

Figure 4.6: Karnaugh map in two variables The following is a layout for a Karnaugh map for three variables x, y and z:

4.8. MINIMIZATION OF BOOLEAN EXPRESSIONS AND KARNAUGH MAPS71 y

yz

yz

y0z

y 0 z 0 yz 0

xz

y

y0

x

x

x0

xyz xy 0 z xy 0 z 0

x0 yz x0 y 0 z x0 y 0 z 0

xz

xyz

xy 0 z

xz 0

xyz 0

xy 0 z 0

x0 z 0

x0 yz 0

x0 y 0 z 0

x0 z

x0 yz

x0 y 0 z

xyz 0

x0 yz 0

Figure 4.7: Karnaugh map with three variables

A Boolean expression given as the sum of minterms (i.e. in disjunctive normal form) is represented on the Karnaugh map by placing a one in each cell corresponding to a minterm which is present. The Boolean expression xyzw+xyzw0 +x0 y 0 z 0 w0 +x0 yz 0 w0 in four variables x, y, z, w is represented by

xy xy zw zw 1

xy 0

x0 y 0

x0 y

zw0 1 z 0w 0

1

1

z 0w

Figure 4.8: xyzw + xyzw0 + x0 y 0 z 0 w0 + x0 yz 0 w0

We now illustrate the grouping by following figures:

72

CHAPTER 4. BOOLEAN ALGEBRA

x0 1

x y 1

x0

y

1

y

1

x0 1

y0

1

y0 1

1

x

y0

x0

xy + x0y = y 1 1 1

xy z 1

1

1 minterms are not adjacent so one's can not be grouped

x0y x0y 0 xy 0 1

z0

1

xy xy 0 x0y 0 x0y 1 1 z z0

xyz + xy 0z = xz 0 0 0 xy xy 0 x y x y z 1 z0 1

x

1 1

1

x0y 0z + x0yz = x0z, x0yz + x0yz 0 = x0y xy(z + z 0) + x0y(z + z 0) = y(x + x0) = y

4.8. MINIMIZATION OF BOOLEAN EXPRESSIONS AND KARNAUGH MAPS73 xy z

xy

xy 0

x0y 0 x0y zw

1

1

z y 0 z + x0 y 0 + x 0 z

1

xy

zw 1

xy 0 x0y 0

x0 y 1

1 zw0 z 0w 0 z 0w 1

1

xyw(z + z 0 ) + x0 yw(z + z 0 ) = yw(x + x0 ) = yw

Indeed, these four cells are adjacent in which literals x and z are complemented so variables x; z vanish. Thus, grouped of these four cells will give the simplified term yw

From above figures it follows that two adjacent ones (horizontally or vertically) in the map imply that the Boolean expression contains the sum of two minterms in which all the literals are identical except for one which is complemented in one cell but not in an adjacent one. Where this is the case, this variable can be eliminated. Similarly, it also follows that a group of four ones arranged in a rectangular block (either 2 × 2, 1 × 4 or 4 × 1) allows replacement of four terms by one and the elimination of two variables. In a similar way we can show that a group of eight ones arranged in any rectangular block indicates that the eight corresponding minterms can be replaced by a single term in which three variables have been eliminated. In all these cases the variable or variables which remain are those which appear unchanged in all cells constituting the block. It is important to note that only blocks of 2, 4, 8, . . . cells lead to replacement of the appropriate number of minterms by a single term, so it is these blocks that we must look for in a Karnaugh map. Further, the larger the rectangular block, the greater the reduction in terms and so we must utilize the larger blocks where we have a choice. (In practice Karnaugh maps become too unwieldy for Boolean expressions in more than about four variables and other techniques for obtaining the minimal form, such as the QuineMcCluskey algorithm, are more appropriate. See, for instance, Gersting (1999).) Given a Karnaugh map, the following sequence of steps normally enables identification of a minimal representation of a Boolean expression (Although the method usually gives the minimal form, it is not absolutely foolproof and, having

74

CHAPTER 4. BOOLEAN ALGEBRA

applied it, it is wise to check that there is no other way of grouping the ones, which results in fewer terms or in the same number of terms but fewer literals). 1. Isolate any ones in the map which are not adjacent to any other ones. The terms corresponding to these cells cannot be reduced and will therefore appear unchanged in the minimal form. 2. Locate any ones that are adjacent to only one other cell containing a one and circle the pair. For each of these pairs, the two minterms corresponding to the cells can be represented by a single term consisting of the literals common to both. 3. Locate any ones which can be allocated to a block of four in only one way and circle that block. The corresponding four terms can be represented by one term consisting of the common literals. 4. Locate any ones which can be allocated to a block of eight and circle that block. The corresponding eight terms can be represented by one term consisting of the common literals. 5. For any cells containing a one that remain, form the largest possible rectangular groups so that there are as few groups as possible and so that all cells containing a one are enclosed in at least one block. Note that the process allows for a one to be included in more than one block. This simply means that the term corresponding to that cell is considered as being repeated in the original Boolean expression (since b + b = b for all b ∈ B). Example 4.8.1. Consider the Boolean expression x1 x2 x3 +x1 x02 x3 +x1 x02 x03 + x01 x02 x03 + x01 x2 x03 . The karnaugh map corresponding to given Boolean expression is given by

x2 x3 x1 1 x01

x02x3 x02x03 x2x03 1 1 1

1

4.8. MINIMIZATION OF BOOLEAN EXPRESSIONS AND KARNAUGH MAPS75 The corresponding minimal form is given by x1 x3 + x1 x02 + x01 x03 . It can also be grouped as

x2 x3 x1 1

x02x3 x02x03 x2x03 1 1

x01

1

1

Another minimal form is x1 x3 + x03 x02 + x01 x03 . This shows that minimal form of a Boolean expression is not unique. Remark 4.8.2. It can also be grouped as

x2 x3 x1 1

x02x3 x02x03 x2x03 1 1

x01

1

1

The corresponding reduced form is x1 x3 + x1 x02 + x03 x02 + x01 x03 . Clearly this is not minimal form because it can be reduced to fewer number of terms. Example 4.8.3. Consider the Boolean expression x1 x2 x03 x4 + x1 x2 x3 x04 + x01 x2 x03 x04 + x01 x02 x3 x4 + x01 x02 x03 x4 + x1 x02 x3 x4 + x1 x02 x03 x4 + x1 x02 x3 x04 . The corresponding Karnaugh map is given by x1 x2 x3 x4 x x 1 2

1

x3 x4 x3x04

x1x02

1

x01x02 1

1

1

x03x04 x03x4

x01x2

1

1

The corresponding minimal form is x4 x02 + x1 x3 x04 + x1 x2 x03 x04 .

76

CHAPTER 4. BOOLEAN ALGEBRA

4.9

Exercises

Exercise 4.9.1. Draw Karnaugh map and find a minimal form of the following Boolean expressions: 1. x1 x2 x03 x4 + x01 x2 x03 x4 + x01 x2 x03 x04 + x01 x2 x3 x04 + x01 x2 x3 x4 + x01 x2 x03 x4 + x01 x02 x03 x04 + x1 x2 x03 x04 . 2. x1 x2 x3 x4 + x1 x2 x03 x4 + x01 x2 x03 x4 + x1 x2 x03 x04 + x01 x02 x03 x04 + x1 x02 x03 x4 + x1 x02 x03 x04 + x1 x02 x3 x04 . 3. Draw Karnaugh map and simplify the expressions: (a). xy 0 + x0 y, (b). xy 0 + x0 y 0 and xy 0 + x0 y 0 + xy. 4. Is it possible to reduce the Boolean function x0 y 0 + xy with the help of Karnaugh map? Support your answer. 5. Reduce the following Boolean functions with the help of Karnaugh map: (a). A0 B 0 C + A0 BC + ABC + ABC 0 , (Ans. A0 C + AB) (b). A0 B 0 C + A0 BC 0 + ABC 0 + AB 0 C, (Ans. A0 C + AB 0 C + BC 0 ) (c). A0 B 0 C 0 + A0 B 0 C + A0 BC + A0 BC 0 + AB 0 C + ABC, (Ans. A0 + C) (d). A0 B 0 C + A0 B 0 C + A0 BC + ABC 0 + AB 0 C + ABC, (Ans. A0 B 0 + AB + C).

Exercise 4.9.2. Draw a Karnaugh map to represent the Boolean function AC 0 + A0 C + B. Hint:

BC BC

B 0C B 0C 0 BC 0

1

1

A A

A0 1

1

1 1

Exercise 4.9.3. Write the Boolean function represented by the Karnaugh map:

4.9. EXERCISES

77

BC A BC

BC 0

B 0C 0

A

1

1

1

A0

1

1

1

B 0C

Also simplify it.

Exercise 4.9.4. Draw a Karnaugh map to represent the following Boolean functions: (a). A0 B 0 C 0 D + ACD + BD0 + AB + BC, (b). A + B 0 D0 .

Exercise 4.9.5. Draw a logic circuit to satisfy the truth table given below:

INPUT

OUTPUT

A 0

B 0

C 0

0 0

0 1

1 0

0

1

1

0

0

0

1

0

0

0

1

0 0

1 1 1

1 1

1

1 1 1

1

Solution: The Boolean expression corresponding to given truth table of logic network is A0 B 0 C 0 + A0 B 0 C + A0 BC 0 + ABC. It’s Karnaugh map, minimal form and corresponding logic circuit (network) is given by

78

CHAPTER 4. BOOLEAN ALGEBRA B 0C

BC

A

1

B 0C 0

BC 0

1

A0

1

1

1

minimal form is ABC + A0B 0 + A0C 0. The corresponding logic network is C0 A0C 0 A B C

A0

A0B 0 B

0

ABC

ABC + A0B 0 + A0C 0

CHAPTER

5

Combinatorics

This chapter is devoted to study basic counting principles, factorial notation, permutations, combinations, Pigeon hole principle and Inclusion-Exclusion principle.

5.1

Basic counting principles

It is divided into two parts, that are described below: (a). The multiplication principle: Assume that an activity has n stages. If ith stage can be carried out in mi different ways irrespective of how the other stages carried out, for each 1 ≤ i ≤ n, then the whole activity can be carried out in m1 × m2 × . . . × mn different ways. In other words, if there are n finite sets A1 , A2 , . . . , An having m1 , m2 , . . . , mn elements respectively, then the Cartesian product A1 × A2 × . . . × An has m1 .m2 . . . . .mn elements. m1 -choices m2 -choices

m3 -choices . . .

. . mn -choices

(b) The addition principle: If there are n activities and assume that i-th activity can be carried out in mi different ways independent from other 79

80

CHAPTER 5. COMBINATORICS activities. Then either activity can be carried out in to m1 + m2 + . . . + mn different ways. In other words, if there are n pairwise disjoint sets A1 , A2 , . . . , An having m1 , m2 , . . . , mn elements respectively, then their union ∪i Ai has m1 + m2 + . . . + mn elements. These rules can be illustrated by following examples:

Example 5.1.1. Suppose the science faculty of M G Kashi Vidyapith offers 5 Maths courses, 2 Bio courses and 2 Diploma courses. Then 1. total number of ways a student can choose one kind of each course is 5 × 3 × 2 = 30. 2. total number of ways a student can choose one course is 5 + 3 + 2 = 10. Example 5.1.2. A concert hall has 11 gates. Then total number of ways of entering through one gate and exit through another gate will be 11.10 = 110. Example 5.1.3. Four persons entered the lift cabin on the ground floor of a 10 floor building. Suppose each of them can leave the cabin independently at any floor beginning with the second floor. Find the total number of ways in which each of the four persons can leave the cabin: (i) at any one of 8 floors. (ii) at different floors. Solution: Observe that the given activity has four persons (stages). In case (i), each person can leave the cabin in 8 ways independently. Thus each stage can be carried out in 8 ways irrespective of others and hence required number of ways will be 8 × 8 × 8 × 8 = 4096. In case (ii), one person can leave the cabin in 8 ways, then second one can leave in 8 − 1 = 7 ways, third one can leave in 8 − 2 = 6 ways and the last one can leave in 8 − 3 = 5 ways. Thus, the required number of ways will be 8 × 7 × 6 × 5 = 1680. Exercise 5.1.4. Ten persons entered the lift cabin on the ground floor of a 10 floor building. Suppose each of them can leave the cabin independently at any floor beginning with the sixth floor. Find the total number of ways in which each of the ten persons can leave the cabin: (i) at any one of 5 floors. Hint: 105 . (ii) at different floors. Hint: 10.9.8.7.6

5.1. BASIC COUNTING PRINCIPLES

81

Exercise 5.1.5. There are 10 multiple choice questions in B.Sc. examination. If the first five questions have 4 choices, and rest has 5 choices each, then find the number of all possible sequences of answers. Hint:45 × 55 . Exercise 5.1.6. There are 35 male students and 20 female students in B.Sc. − III. Maths teacher wants to select a male or female student for monitor of the class. In how many ways he/she can select a monitor. Hint: 35 + 20 = 55. Exercise 5.1.7. A restaurant serves five types of starter, six main courses and two desserts. Then: (a) . in how many ways a man can select one course meal? (Hint: 5 + 6 + 2 = 13.) (b). in how many ways a man can select two course meal? (Hint: 5 × 6 + 6 × 2 + 2 × 5 = 42.) (c). in how many ways a man can select three course meal? (Hint: 5 × 6 × 2 = 60.) Exercise 5.1.8. There are 5 students for Maths, 6 students for Statistics and 3 students for Computer-Gold medal. In how many ways a gold medal can be awarded to these students. Hint: 5 + 6 + 3 = 14. Exercise 5.1.9. How many five digit odd numbers can be formed by using digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, if (a) Repetitions of digits is not allowed. (Hint: 8.8.7.6.5 = 13440). (b) Repetitions of digits is allowed.(Hint: 9.103 .5). Definition 5.1.10. The continued product 1.2.3 . . . .n of first n natural numbers is denoted by n! and is called n-factorial. It is also denoted by bn. We define 0! = 1. From the definition one may easily observe that (n + 1).n! = (n + 1)!. Example 5.1.11. The number of three digit numbers formed by digits 1, 2, 3 is 3! = 6. These are 123, 132, 231, 213 and 312, 321 respectively. Similarly, the number of ways of placing English alphabets in a row is (26)!. In general, the number of ways of placing n objects in order is n!. Exercise 5.1.12. Four people A, B, C, D form a committee. One is to be president, one is secretary, one is treasurer and one social convener. In how many ways can the post be assigned? Hint: 4.3.2.1 = 4! = 24.

82

CHAPTER 5. COMBINATORICS

Exercise 5.1.13. Suppose a bookcase shelf has 5 History texts, 3 Sociology texts, 6 Anthropology texts, and 4 Psychology texts. Find the number of ways a student can choose: (a) one of the texts; (b) one of each type of text. Hint: (a) By Sum Rule, we have 5 + 3 + 6 + 4 = 18 ways. (b) By Product Rule , we have 5364 = 360 ways. Exercise 5.1.14. A history class contains 8 male students and 6 female students. Find the number n of ways that the class can elect: (a) 1 class representative; (b) 2 class representatives, 1 male and 1 female; (c) 1 president and 1 vice president. Hint: (a) Here the Sum Rule is used; hence, n = 8 + 6 = 14. (b) Here the Product Rule is used; hence, n = 86 = 48. (c) There are 14 ways to elect the president, and then 13 ways to elect the vice president. Thus, n = 1413 = 182. Exercise 5.1.15. There are four bus lines between A and B, and three bus lines between B and C. Find the number m of ways that a man can travel by bus: (a) from A to C by way of B; (b) round trip from A to C by way of B; (c) round trip from A to C by way of B but without using a bus line more than once. Hint: (a) There are 4 ways to go from A to B and 3 ways from B to C; hence n = 43 = 12. (b) There are 12 ways to go from A to C by way of B, and 12 ways to return. Thus n = 1212 = 144. (c) The man will travel from A to B to C to B to A. Enter these letters with connecting arrows as follows: A→B→C→B→A The man can travel four ways from A to B and three ways from B to C, but he can only travel two ways from C to B and three ways from B to A since he does not want to use a bus line more than once. Thus, by the Product Rule, n = 4323 = 72. Exercise 5.1.16. In How many ways 5 rings of different types can be worn in 4 fingers? Here observe that each ring has 4 choices and so required number of ways is 45 . Exercise 5.1.17. Find the total number of 4 digit numbers in decimal number system. Hint: 9 × 103 = 9000.

5.2. PERMUTATIONS

5.2

83

Permutations

Definition 5.2.1. Any arrangement of a set of n different objects taking all at a time in a definite order is called a permutation of the given objects. We also call it as a permutation of degree n. Any arrangements of any r distinct objects taken from given n objects in a definite order, is called an r-permutation. We also call it a permutation of n objects taken r at a time. The total number of such r- permutations is denoted by n Pr . n! . In particular, Proposition 5.2.2. If n ∈ N and r ≤ n, then n Pr = (n−r)! n Pr = n!. Proof: Let x1 x2 . . . xr be any arrangements of r objects taken from given n objects. Observe that x1 has n choices. After selecting object for x1 , x2 will have n − 1 choices. Similarly x3 will have n − 2 choices, . . ., xr will have n − r + 1 choices. Since arrangement x1 x2 . . . xn has r stages, therefore the total number of arrangements of r objects taken from n objects will be

i.e;

n

Pr

n.(n − 1). . . . .(n − r + 1) n! = (n − r)!

In particular, n Pn = n.(n − 1) . . . 3.2.1 = n!. 2 Suppose that there are three objects A, B, C. Then all possible arrangements are ABC, ACB, BAC, BCA, CAB and CBA. The total number of these arrangements is 3! = 6. If B = A, say, then arrangements ABC and BAC reduces to AAC; ACB and BCA reduces to ACA; and arrangements CAB and CBA reduces to CAA. In this case, we have only three permutations of three objects, where two objects are alike. This asserts that if two objects are same then 2 = 2! permutations reduced to a single permutation and so the all the six permutations of three objects, when two objects are 3! = 3 permutations. Next, if B = C = A then alike; will be reduced to 2! 3! all the 3! = 6 permutations reduced to a 1 = 3! (single) permutation AAA. Thus, we have the following: Proposition 5.2.3. The number of permutations of n objects, where p objects are alike, is equal to n! . In general, the number of permutations of n p! objects, where p1 objects are alike of one kind, p2 objects are alike of second kind, . . . , pk objects are alike of k-th kind; is equal to p1 !.p2n!!.....pk ! .2

84

CHAPTER 5. COMBINATORICS

Suppose we consider all r− permutations of n objects, where a specified object is to be included in each arrangements. Since the number of r − 1permutations of n − 1 objects (excluding specified objects) will be n−1 Pr−1 and specified object may appear at anyone place of r places of arrangement. Thus, we have : Proposition 5.2.4. The number of r-permutations of n distinct objects, when a particular object to be included in each arrangement is r.n−1 Pr−1 . If we exclude a specified object from n objects, then total number of available objects for arrangements will be n − 1 and so we have: Proposition 5.2.5. The number of r-permutations of n distinct objects, when a particular object is never taken (included) in each arrangement, is n−1 Pr . If we wish to find all permutations of n objects, when m specified objects come together in each arrangement. In this case, all m specified objects will be grouped as one object and so the number of objects will be reduced to n − m + 1 objects. Since the number of permutations of degree n − m + 1 is (n − m + 1)! and also the m specified objects can be arranged into m! ways. Therefore, we have: Proposition 5.2.6. The number of permutations of n distinct objects taken all at a time, when m specified objects come together in each arrangement, is m!.(n − m + 1)!. Corollary 5.2.7. The number of permutations of n distinct objects taken all at a time, when m specified objects never come together in each arrangement, is n! − m!.(n − m + 1)!. If we arrange r objects x1 , x2 , . . . , xr on a cycle, then such arrangements are called cyclic permutations. Since all r permutations x1 x2 . . . xr , x2 x3 . . . xr x1 , . . . , xi xi+1 . . . xr x1 . . . xi−1 , . . . , xr x1 x2 . . . xr−1 determines a single cyclic permutation x1 x2 . . . xr . Thus, we have: Proposition 5.2.8. (Circular permutations or arrangements round a circular table). If clockwise and anti-clock wise orders are taken as different, then the number of circular permutations of n distinct objects taken r at n a time is Pr r . In particular, if clockwise and anti-clock wise orders are taken as different, then the number of circular permutations of n distinct objects n taken all at a time is Pnn = (n − 1)!.

5.2. PERMUTATIONS

85

Proposition 5.2.9. (Circular permutations or arrangements round a circular table). If clockwise and anti-clock wise orders are taken as same, then the number of circular permutations of n distinct objects taken r at a nP r time is 2r . In particular, if clockwise and anti-clock wise orders are taken as same, then the number of circular permutations of n distinct objects taken nP n = (n − 1)!/2. all at a time is 2n Example 5.2.10. There are 8 letters A, A, A, I, N, R, S and V in word “VARANASI”. Out of 8 letters, 3 letters are alike (3 A’s). Thus, the number of permutations of letters of word “VARANASI” is 8!/3! = 6720. Example 5.2.11. There are 9 letters A, A, A, A, B, D, H, L and L in word “ALLAHABAD”. Out of these 9 letters, there are 4 A’s and 2 L’s. Thus, the 9! = 7560. number of permutations of letters of word “ALLAHABAD” is 4!.2! Example 5.2.12. The number of permutations of letters of word “VIDYAPITH” starting with T and ending with H, is equal to 7!/2!. Exercise 5.2.13. Find the number of permutations of letters of word “TRIANGLE” (Hint: 8!). Also find the total number of permutations beginning with T and ending with E (Hint: 6!). Exercise 5.2.14. In how many ways 6 boys and 5 girls can be seated in a row so that no two girls are together? Solution: The 6 boys can be seated in 6! = 720 ways. In each of these arrangements, if girls can be seated in a row so that no two girls are together then we may arrange these 5 girls on 6 + 1 = 7 places. Indeed, the places of girls may be any three of blank spaces in −B − B − B − B − B − B−, here B stands for boy. Thus, girls can be seated in 7 P5 = 42 ways. Hence total number of seating arrangements will be 720 × 42 = 30240. Exercise 5.2.15. How many words can be formed from the letters of word “LAUGHTER” so that (a) the vowels always come together?, (b) the vowels never come together? Also find the number of 3 letter words formed from letters a, b, c, d, e, f and g? Hint: (a) 3!.6!, (b) 8! − 3!.6! and 7 P3 . Exercise 5.2.16. How many arrangements of 9 exam papers can be formed so that best and worst are never together. (Hint: 9! − 2!.8!). Exercise 5.2.17. When a group photograph of Maths students is taken in fresher party, all the seven teachers in first row and twenty five students in

86

CHAPTER 5. COMBINATORICS

second row so that both ends are reserved for two tallest students that can interchange their positions. If middle seat of first row is reserved for Head, department of mathematics, then how many arrangements are possible? Hint: 6! × 2! × 23!. Exercise 5.2.18. A coding of exam papers consists two distinct English alphabets and two distinct digits from 0 to 9. Then (a) How many codes can be formed? (b) How many codes can end with even number? Hint: (a) 26.25.10.9 (b) 26.25.9.5. Exercise 5.2.19. How many arrangements can be made with the letters of word “MATHEMATICS”? In how many of them vowels come altogether? 8! 4! 11! , 2!.2! × 2! . Hint: 2!.2!.2! Exercise 5.2.20. How many arrangements greater than two thousand can be formed with digits 1, 2, 3, 1.Hint: 2.4.4.4 = 64. 2! Exercise 5.2.21. How many arrangements greater than a million can be 7! 6! formed with the digits 2, 3, 0, 3, 4, 2, 3.Hint: 6.6.5.4.3.2.1 = 360 or 2!.3! − 2!.3! . 2!.3! Exercise 5.2.22. Find: (a) 7 P3 ; (b) 1 4P3 . Exercise 5.2.23. Find the number m of ways that 7 people can arrange themselves: (a) in a row of chairs; (b) around a circular table.Hint: m = 7! ways (b) m = 6!. Exercise 5.2.24. Find the number n of distinct permutations that can be formed from all the letters of each word: (a) T HOSE; (b) U N U SU AL; (c) SOCIOLOGICAL. Hint: (a) n = 5! = 120, since there are 5 letters and no repetitions. 7! = 840, since there are 7 letters of which 3 are U and no other (b) n = 3! letter is repeated. 12! (c) n = 3!.2!.2!.2! , since there are 12 letters in which 3 O’s, 2 C’s, 2 I’s, and 2 L’s. Exercise 5.2.25. If twenty persons are invited in a party, then how many ways can guest and host be seated at a circular table? In how many of these ways will two particular persons be seated on either side of the host? Hint: In first case, it will be (21 − 1)! = 20!. Consider the second case. The number of arrangements of two particular persons on either side of host will be 2 (P1 HP2 and P2 HP1 ). Taking them as one group. Then the required

5.3. COMBINATIONS

87

number of ways in second case will be the arrangement of 19 people around the circular table, and so it will be (19 − 1)! = 18!. But in the second case, 18 people can be arranged into 18! ways, it will be (21 − 3)! × 2 = 2 × 18!. Exercise 5.2.26. How many ways can 20 persons be seated on a round table so that two particular persons (a) always together? (b) never together? Hint:(a) 18! × 2, (b) 19! − 2 × 18! = 17 × 18!. Exercise 5.2.27. Three boys and three girls are to be seated around a circular table so that a particular boy does not want any girl neighbor and a particular girl does not a boy in neighbor. How many such arrangements are possible? Hint: From the figure, it is clear that total number of arrangements will be G girl

girl boy

boy B

Figure 5.1: 2! × 2! = 4.

5.3

Combinations

Let a, b, c and d are given four distinct objects. Our all possible unordered selections of one object are a, b, c and d respectively. Total number of such selections are 4. Next, all possible unordered selections of two objects are ab, ac, ad, bc, bd and cd respectively. Total number of such selections are 6. If we consider all possible arrangements of two objects, then they are ab, ba, ac, ca, ad, da, bc, cb, bd, db and cd, dc respectively. The total number of such arrangements are 12 = 4 P2 . Observe that we can arrange these arrangements so that each two (2!) arrangements determines a single selection, therefore the number of all such selections will be 4 P2 /2!. Thus, an unordered selection is different from an arrangement. and so we give the following: Definition 5.3.1. Any unordered selection of objects, taking some or all at a time, from given distinct n objects (repetition is not allowed), is called a combination. An unordered selection of n objects taken r at a time, is called a r-combination. The total number of such selections (unordered selections

88

CHAPTER 5. COMBINATORICS

of r distinct objects from n distinct objects or r-combinations) is denoted by Cr . We define n C0 = 1. If r > n, then we have no selections and so we define n Cr = 0 for r > n. n

Proposition 5.3.2. n Cr =

nP

r

r!

n! , r!(n−r)!

=

0 ≤ r ≤ n.

Proof: Since any selection of r distinct objects can be arranged into r! ways and total number of arrangements of r distinct objects from n distinct object is n Pr . Therefore, total number of selections of r distinct objects from n distinct n object will be r!Pr . Thus, we have n n

Cr =

n! Pr = r! r!(n − r)!

2 One may easily observe that the selection of r distinct objects from n objects X1 , x2 , X3 . . ., Xn is given by the number of r-th degree terms in the expansion of (1 + X1 + X2 + . . . + Xn )n . Also this number will be the coefficient of X r in the expansion of (1 + X)n . By the definition of n Cr , we have the following: 1. n Cr is a non-negative integer. 2. n C0 = n Cn = 1. 3. n Cr = n Cn−r . 4. n Cr + n Cr−1 = n+1 Cr . 5. n Cx = n Cy if and only if x = y or x + y = n 6. n.n−1 Cr−1 = (n − r + 1).n Cr−1 . 7. If n is even then the greatest value of n Cr is n Cn/2 . 8. If n is even then the greatest value of n Cr is n C(n+1)/2 or n C(n−1)/2 . 9.

nC r nC r−1

=

n−r+1 . r

Proposition 5.3.3. The number of combinations of n distinct objects taken r at a time (i.e; r- combinations), when k particular objects occur is n−k Cr−k . If k particular objects never occur, then the number of combinations of n distinct objects taken r at a time is n−k Cr .2

5.3. COMBINATIONS

89

We now give some guiding examples and exercises to illustrate it and its application. Example 5.3.4. Let N = pk11 pk22 . . . pkl l , where pi ’s are distinct primes. Then the number of pairs s, t such that N = s.t and s, t are relatively primes; is 2l−1 . Example 5.3.5. There are three male and three female to form a twomember committees. Then, to form a two member committee we will have to select any two from six (three male and three female) and so total number of all possible committees will be 6 C2 = 15. Next, suppose we have to form a two-member committee so that one member is male and the other is female. Then, total number of all possible committees will be 3 C1 × 3 C1 = 9. Example 5.3.6. Suppose that a question paper is divided into two parts A and B. Suppose that part A contains 10 questions and part B contains 8 questions. If student have to choose all questions from part A and have to choose only 4 questions from part B. Observe that this activity has two stages. Therefore the total number of all possible combinations will be 1 × 8 C4 = 8 C4 . If Board of Studies committee decided that students will have to choose 8 parts from A and 6 parts from B, then the required number of selections of questions will be 10 C8 × 8 C6 . Exercise 5.3.7. A committee of 12 is to form from 9 women and 8 men. In how many ways, this can be done if at least five women have to be included in a committee? In how many of these committees (i) the women are in majority, (ii) the men are in majority. Solution: If committees has at least five women, then committee may contain : (i) 5 women and 7 men, (ii) 6 women and 6 men, (iii) 7 women and 5 men, (iv) 8 women and 4 men and (v) 9 women and 3 men. Thus, total no of required selection will be 9

C5 × 8 C7 + 9 C6 × 8 C6 + 9 C7 × 8 C4 + 9 C8 × 8 C4 + 9 C9 × 8 C3 .

Observe that women will be in majority only in cases (iii), (iv) and (v). Thus, the number of above committees with women in majority, is equal to 9 C7 × 8 C5 + 9 C8 × 8 C4 + 9 C9 × 8 C3 . Similarly, the number of above committees with men in majority, is equal to 9 C5 × 8 C7 .

90

CHAPTER 5. COMBINATORICS

Exercise 5.3.8. A cricket team be selected from a group of 20 players containing 9 batsman, 6 bowlers, 3 all rounders and 2 wicket keepers. In how many ways can a team containing 5 batsman, 2 all rounders, 3 bowlers and 1 wicket keeper, be selected? Hint: 9 C5 × 3 C2 × 6 C3 × 1 C1 . Exercise 5.3.9. There are 20 applicants for the post of 5 associate professors in which two posts are fixed for Mathematics. If there are 7 applicants in Mathematics, then how many ways of selections can be made? Answer: 7 C2 × 13 C3 . Example 5.3.10. There are 8 points in a given plane so that no three of which are in the same straight line excepting four points which are collinear. Thus, the number of straight lines formed by these points taken 2 at a time will be 8 C2 = 28. Also, the number of lines formed by 4 points, taken 2 at a time, will be 4 C2 = 6. If these 4 points are collinear, then it will contribute only one line. Thus, the required number of lines will be 28 − 6 + 1 = 23. Next, suppose that we have to form triangle by above points. First observe that total number of all possible triangle will be 10 C3 = 120. Next, number of possible triangles formed from 4 points taken 3 at a time will be 4 C3 = 4. Since four points are collinear, therefore they will not form any triangle. Thus, the total number of triangles formed by ten points, in which only four points are collinear, will be 120 − 4 = 116. Exercise 5.3.11. From a class of 20 students, only 10 students are to be choosen for competition. There are two students who decide that either all them will join or none of them will join . In how many ways can 10 students be chosen? Solution: First suppose that two specified students has been chosen, then to select 10 students, we have to select only 8 students from the remaining 18 students. Thus, total number of such selections will be 18 C8 . Next, suppose that will not join the competition. Then, we will have to select 10 students from remaining 18 students. Thus, total number of such selections will be 18 C1 0. Combining these two cases, we have 18 C8 + 18 C10 ways (by sum rule) of selecting 10 students from 20 with given condition. Theorem 5.3.12. Pigeonhole Principle: If n pigeon holes are occupied by n + 1 or more pigeons, then at least one pigeon hole is occupied by more than one pigeon. More generally, if n pigeon holes are occupied by kn + 1 or

5.3. COMBINATIONS

91

more pigeons, where k is a positive integer, then at least one pigeon hole is occupied by k + 1 or more pigeons. Example 5.3.13. 1. If faculty of science has 15 professors, then at least two professors were born in the same month. 2. The minimum number of students in a class to be sure that five of them are born in the same month is 12 × 4 + 1 = 49 (Here k + 1 = 5). Theorem 5.3.14. (Inclusion-Exclusion principle): Let A and B be any two finite sets.Then |A ∪ B| = |A| + |B| − |A ∩ B|. Similarly, if A, B, C be any three finite sets. Then |A ∪ B ∪ C| = |A| + |B| + |C| − |A ∩ B| − |B ∩ C| − |A ∩ C| + |A ∩ B ∩ C| (5.3.1). If these sets are pairwise disjoint, then it will be reduced to |A ∪ B ∪ C| = |A| + |B| + |C|. More generally, if A1 , A2 , . . . Am be m finite sets. Let sk be the sum of the cardinalities |Ai1 ∩ Ai2 ∩ . . . ∩ Aik | of all possible k-tuple intersections of the given m sets. Then m [ (5.3.2) Ai = s1 − s2 + s3 − . . . + (1)m−1 sm . i=1

Example 5.3.15. Find the number of Mathematics students at a university taking at least one of the languages French, German, and Russian, given the following data: 65 study French, 45 study German, 42 study Russian, 20 study French and German, 25 study French and Russian, 15 study German and Russian, and 8 study all three languages. Solution: Let F , G and R denotes the number of Maths students studying French, German and Russian respectively. Then |F | = 65, |G| = 45, |R| = 42, |F ∩ G| = 20, |F ∩ R| = 25, |G ∩ R| = 15 and |F ∩ G ∩ R| = 8. Thus, by Theorem 5.3.1 (Inclusion- Exclusion principle), we have |F ∪ G ∪ R| = 65 + 45 + 42 − 20 − 25 − 15 + 8 = 100.

92

CHAPTER 5. COMBINATORICS

CHAPTER

6

Numeric functions and Recurrence relations

In this chapter first we introduce the notion of numeric functions and the algebra of numeric functions. Definition 6.0.1. A function f : N ∪ {0} → R is called a numeric function. The image of n under f is denoted by fn . We frequently say that fn is a numeric function instead of f . fn = 2n and 2n − 1 are examples of numeric function where n ∈ N ∪ {0}. Let a and b be any two numeric functions then the sum a+b of a and b is defined by (a+b)n = an +bn for all n = 0, 1, 2, ...... The product a.b is defined (a.b)n = an bn . The convolution a ∗ b of a and Pby n b is defined by (a ∗ b)n = i=1 ai bn−i . Thus the value of a ∗ b at n is given by (a ∗ b)n = a0 bn + a1 bn−1 + . . . an b0 . Exercise 6.0.2. Find the sum, product and convolution of numeric functions a and b, where  0 if 0 ≤ n ≤ 7 an = 2n if n>7 and  bn =

3n if 0 ≤ n ≤ 3 2n − 3n + 4 if n>3 93

94CHAPTER 6. NUMERIC FUNCTIONS AND RECURRENCE RELATIONS Solution: The sum of two numeric functions  n  3 2n − 3n + 4 an + bn =  n 2 + 3n − 3n + 4

an and bn is given by if 0 ≤ n ≤ 3 if 3 < n ≤ 7 if n>7

The product of two numeric functions an and bn is given by  0 if 0 ≤ n ≤ 7 an .bn = n n 3 (2 − 3n + 4) if n>7 The convolution of two numeric functions an and bn is given by an ∗ bn = a0 bn + a1 bn−1 + a2 bn−2 + . . . + an b0 n X = ai bn−i i=8 n−4 X = [2i (2n−i − 3(n − i) + 4)] + 2n−3 33 + 2n−2 32 + 3.2n−1 + 2n i=8

Definition 6.0.3. The modulus of a numeric function an is a numeric function denoted and defined by |an |. Thus the value of |a| at n is |an | for all n. by PnIf a is a numeric function then its accumulated sum at n is given k a . Let k be a fixed natural number then the numeric functions S a and i=0 i S −k a are defined by  0 if 0 ≤ n < k k (S a)n = an−k if n≥k and (S −k a)n = an+k respectively. Exercise 6.0.4. Find the numeric function b if a ∗ b = c, where a and c are given numeric functions. Exercise 6.0.5. Rahul deposits Rs. 1 lakh in his GPF account at an interest rate 8 percent per annum compounded annually. Evaluate his amount after n years. Solution: Let an be the amount after n years. Then an = Rs. (1.08)n lakh.

6.1. BIG-OH OR ASYMPTOTIC DOMINANCE

6.1

95

Big-oh or Asymptotic dominance

Definition 6.1.1. Let a be a numeric function. Then the behavior of limn→∞ an is known as the asymptotic behavior of a. Let b be another numeric function. If there exists n0 ∈ N such that |an | ≤ kbn for n ≥ n0 then we say b asymptotically dominates a or a is asymptotically dominated by b. We also say that |an |/bn is bounded on [n, ∞]. Observe that if a is dominated by b then ka is also dominated by b for any fixed constant k. Exercise 6.1.2. The numeric function an = 2−n is asymptotically dominated by bn = 1. Definition 6.1.3. Let a be a numeric function. Then Order a is the set of all numeric functions that are asymptotically dominated by a. It is denoted by O(a) or ‘big -oh of a’. Thus, b ∈ O(a) if b is asymptotically dominated by a. Observe that the numeric function n is dominated by n2 . Thus n ∈ O(n2 ). Similarly 15n2 , n2 + 340, n, n − 5 ∈ O(n2 ). Exercise 6.1.4. Prove that an = 21 n2 log n − n2 is not dominated by bn = n2 . In other words an ∈ / O(bn ). Solution: For if, let k > 0 and n0 ∈ N such that |an | ≤ kbn for all n ≥ n0 . Then 21 n2 log n − n2 ≤ kn2 for all n ≥ n0 . This gives log n ≤ 2(k + 1) for all n ≥ n0 . This is a contradiction. Thus proved. Definition 6.1.5. Let A and B be any two sets and k is any constant. Then the sets A + B, kA and A.B are given by A + B = {a + b | a ∈ A, b ∈ B} k.A = {k.a | a ∈ A} A.B = {a.b | a ∈ A, b ∈ B}.

6.1.1

Properties

Theorem 6.1.6. For numeric functions a, b, c, we have following:

96CHAPTER 6. NUMERIC FUNCTIONS AND RECURRENCE RELATIONS (i). a is O(|a|). (ii). if a ∈ O(b) then ka ∈ O(b), where k is constant. (iii). if b ∈ O(a) then S i (b) ∈ O(S i (a)) for all i. (iv). if b, c ∈ O(a) then b + c ∈ O(a). (v). if a ∈ O(b) and b ∈ O(c) then a ∈ O(c). (vi). if a ∈ O(b) then O(a) ⊆ O(b). Thus, if a ∈ O(b) and b ∈ O(a) then O(a) = O(b). (vii) O(a) + O(a) = O(a) for every numeric function a. If a ∈ O(b) then O(a) + O(b) = O(b). (viii). kO(a) = O(ka) = O(a) for every positive constant k and numeric function a. (ix). O(a).O(b) = O(ab) for any numeric function a and b.

6.2

Generating functions

Definition 6.2.1. Let an be aPnumeric function then the sum function A(x) n of the infinite series A(x) = ∞ n=0 an x is called a generating function in x corresponding to numeric function an . Observe numeric function P∞that each n an corresponds a generating function A(x) = n=0 an x and conversely. To obtain the generating function, first we note the following formulae:

(1 − x)−1 =

r=0 n

xr

= x + nC 1 a.xn−1 + . . . + nC r ar xn−r + . . . + nC n an (ax)r ax (ax)2 + + ... + + ... exp(ax) = 1 + 1! 2! r! n(n + 1) 2 n(n + 1)(n + 2) 3 (1 + x)−n = 1 − nx + x − x + ... 2! 3! n(n + 1) 2 n(n + 1)(n + 2) 3 (1 − x)−n = 1 + nx + x + x + .... 2! 3! (x + a)

n

∞ X

6.2. GENERATING FUNCTIONS

97

In particular, for n = 2, we have −2

2

3

∞ X

(−1)r (r + 1)xr .

(1 + x)

= 1 − 2x + 3x − 4x + . . . =

(1 − x)−2

∞ X 2 3 = 1 + 2x + 3x + 4x + . . . = (r + 1)xr .

r=0

r=0

Example 6.2.2. The generating function corresponding to numeric function an = an is ∞ ∞ X X 1 n . A(x) = an x = an x n = 1 − ax n=0 n=0 Example 6.2.3. The generating function corresponding to numeric function 1 2n is 1−2x . The following table gives generating functions corresponding to some simple numeric functions. numeric functions ar = 1 ar = r!1 ar = r ar = r(r + 1)

generating functions 1 1−x

exp(x) x (1−x)2 2x (1−x)3

By a little effort, one may easily observe the following: Theorem 6.2.4. Let A(x), B(x) and C(x) denote the generating functions corresponding to numeric functions an , bn and cn . Then 1. B(x) = kA(x) if bn = kan . 2. C(x) = A(x) + B(x) if cn = an + bn . 3. C(x) = A(x)B(x) if cn is the convolution of an and bn . 4. B(x) = A(kx) if bn = k n an Exercise 6.2.5. Find the generating functions of following functions: 1. 2, 4, 8, 16, . . .

98CHAPTER 6. NUMERIC FUNCTIONS AND RECURRENCE RELATIONS 2. 0, 1, −2, 4, −8, . . .   r+4 3. ar = for all r = 0, 1, 2, 3 . . . . r 4. ar =

1 (r+1)!

for all r = 0, 1, 2, 3, . . ..

5. ar = 2r + 4r for all r = 0, 1, 2, 3, . . .. Example 6.2.6. Prove that the generating functions corresponding to nu7 9 meric functions ar = 7.2r and ar = r+1 are 1−2x and (3−x) 2 respectively. 3r Solution: The generating function corresponding to numeric function 7.2r is ∞ ∞ ∞ X X X 7 r r r . f (x) = ar x = (7.2 )x = 7 (2x)r = 1 − 2x r=0 r=0 r=0 Similarly, the generating function corresponding to numeric function given by f (x) =

Xr+1 r

3r

r+1 3r

is

xr

 x 2  x 3  x r x +4 + . . . + (r + 1) + ... = 1+2 +3 3 3 3 3 1 = (1 − x3 )2 Exercise 6.2.7. Find the numeric functions corresponding to following generating functions: 1. (1 + x)n + (1 − x)n . 2.

(1+x)2 . (1−x)3 f (x) , 1+x

P∞

ar x r . P r 4. (1 + x)f (x), where f (x) = ∞ r=0 ar x . 3.

where f (x) =

r=0

Solution: Since numeric functions of (1 + x)n and (1 − x)n are  n Cr if 0 ≤ r ≤ n ar = 0 otherwise

6.3. RECURRENCE RELATION AND ITS SOLUTION

99

and  br =

(−1)r n Cr if 0 ≤ r ≤ n 0 otherwise

respectively. Thus, the numeric function of function (1 + x)n + (1 − x)n is given by  n  2 Cr if 0 ≤ r ≤ n and ris even. 0 if 1 ≤ r ≤ n and r is odd. cr =  0 if r > n 2

(1+x) r Similarly, the numeric function of (1−x) 3 is given by the coefficeint of x in the expansion (1 + 2x + x2 )(1 + 3x + (3.4/2!)x2 + . . . + (3.4 . . . (r + 2)/r!)xr + . . .) for r ≥ 0. The numeric function of (1 + x)−1 f (x)is given by ∞ X f (x) ar xr .(1 + x)−1 = 1+x r=0

= (a0 + a1 x + a2 x2 + . . . + ar xr + . . .).(1 − x + x2 + . . . + (−1)r xr + . . .) Then, the coefficient of xr is equal to (−1)r a0 + (−1)r−1 a1 + . . . − ar−1 + ar . (x) Therefore the numeric function of f1+x is ar − ar−1 + . . . + (−1)r a0 . 2

(1+x) r Similarly, the numeric function br of (1−x) 3 is given by the coefficient of x P in the expansion (1 + x) ar xr and is  a0 if r = 0 br = ar + ar+1 if r > 0

6.3

Recurrence relation and its solution

Definition 6.3.1. An equation of the form F (n, an , an+1 , ..., an+k ) = 0, where k ∈ N is fixed, is called a recurrence relation. The difference between the greatest and lowest subscripts of the terms of the sequence in the equation is called the order of a recurrence relation. Example 6.3.2. The equations an+1 = 5an , a2n+1 + a3n = n , an+3 + 5an+2 + 1 4an+1 +an = sin n and an+2 +5(a2n+1 +an ) 2 = 0 are recurrence relations of orders 1, 1, 3 and 2 respectively. The recurrence relation F (n, an , an−1 , ..., an−k ) = 0, where k ∈ N is fixed, is a recurrence relation of order k.

100CHAPTER 6. NUMERIC FUNCTIONS AND RECURRENCE RELATIONS P Definition 6.3.3. A recurrence relation of the form ki=1 ci (n)an+i = f (n), where ci (n)0 s are functions, is called a linear recurrence relation of order k . A recurrence relation which is not linear is called non-linear. If ci (n)0 s, say ci , are constants then it is called a linear recurrence relation with constant coefficients. If f (n) = 0 then linear recurrence relation is called homogeneous linear otherwise it is called non-homogeneous linear. Example 6.3.4. (a). The recurrence relation an = 5an−1 − 4an−2 + n2 is a second-order non-homogeneous recurrence relation with constant coefficients. If a1 = 1 and a2 = 2 then we have a3 = 5 × 2 − 4 × 1 + 32 = 15, a4 = 5 × 15 − 4 × 2 + 42 = 83 and so on. (b) The equation an = 2an−1 an−2 + n2 is a non-homogeneous and nonlinear recurrence relation because the product an1 an2 is not linear. If initial conditions are a1 = 1 and a2 = 2, then we have a3 = 13, a4 = 68 and so on. (c) The equation an = nan1 + 3an2 is a homogeneous linear second-order recurrence relation but it does not have constant coefficients because the coefficient of an1 is n, not a constant. (d) The equation an = 2an−1 +5an−2 −6an−3 is a third-order homogeneous linear recurrence relation with constant coefficients. Thus, we need three, not two, initial conditions to yield a unique solution of the recurrence relation. Suppose we are given the initial conditions a1 = 1, a2 = 2 and a3 = 1. Then, by given recurrence relation, we have a4 = 6, a5 = −37, a6 = 254.

6.3.1

Homogeneous linear recurrence relations

Let k X

ci an+i = 0

(6.3.1)

i=1

be a homogeneous linear recurrence relation of order k (k-th order difference equation) with constant coefficient. Let an = P Aαn be its solution, where A is a constant. Then Eqn. (6.3.1) reduces to Aαn ( ki=1 ci αi = 0). This gives k X

ci α i = 0

(6.3.2)

i=1

This k th degree equation is known as auxiliary or characteristic equation for the homogeneous linear equation (6.3.1) of order k. From above it is clear

6.3. RECURRENCE RELATION AND ITS SOLUTION

101

that an is a solution if and only if an = Aαn , where A is a constant. Clearly this equation has k-roots, say α1 , α2 , . . . , αk . Then there are following cases: Case I. If all roots are real and distinct then the general solution of equation (6.3.1) is given by k X an = Ai αin . i=1

Case II If α1 = α2 = αm = α and remaining k − m roots are distinct then the general solution of equation (6.3.1) is given by ! m k X X i−1 n an = Ai n α + Ai αin , i=1

i=m+1

that is; an = (A1 + A2 n + . . . Am nm−1 )αn +

k X

Ai αin .

i=m+1

For more details we prefer the book [5]. Example 6.3.5. Take an = Aαn , where A is a constant. Then the characteristic equation of recurrence relation an+2 − 3an+1 + 2an = 0 is given by α2 − 3α + 2 = 0. Since its roots are α = 1, 2 (real and distinct). Therefore the general solution < an > of the recurrence relation is given by an = A1 .1n + A2 .2n = A1 + A2 2n . It is noted that the characteristic equation of an −3an−1 −2an−2 = 0 is given by substituting an−2 = Aαn−2 . Thus, its general solution is an−2 = A1 + A2 2n−2 for n ≥ 2. It may be written as an = A1 + A2 2n for n ≥ 0. Thus, general solution of either form are same. Example 6.3.6. Solve an = an−1 + an−2 , with a0 = 0, a1 = 1 (Fibonacci sequence). Solution: The first 10 terms of the Fibonacci sequence are 0, 1, 1, 2, 3, 5, 8, 13, 21 and 34. Observe that the Fibonacci sequence is a homogeneous linear second-order recurrence relation. Its characteristic equation is given√ by x2 − x − 1 = 0. By Shridharacharya formula, its roots are given by α = 1±2 5 . Thus, its general solution is √ !n √ !n 1+ 5 1− 5 an = c 1 + c2 . 2 2

102CHAPTER 6. NUMERIC FUNCTIONS AND RECURRENCE RELATIONS √



Using initial conditions, we have c1 + c2 = 0 and c1 ( 1+2 5 ) + c2 ( 1−2 5 ) = 1. Solving this, we get c1 − c2 = √25 and c1 + c2 = 0. Thus, c1 = −c2 = √15 and so its general solution is given by √ !n √ !n 1 1+ 5 1− 5 1 an = √ −√ . 2 2 5 5 Example 6.3.7. Solve the recurrence relation an = 6an−1 − 9an−2 , where a0 = 1 and a1 = 1. Solution: The characteristic equation of recurrence relation an = 6an−1 − 9an−2 is x2 − 6x + 9 = 0. It’s roots are x = 3, 3. Thus, it’s general solution is an = (A1 +nA2 )3n . Using initial conditions, we have 1 = A1 and 1 = (A1 +A2 )3. . Then an = (1 − 2n )3n . Thus, A1 = 1 and A2 = −2 3 3 Example 6.3.8. The characteristic equation of recurrence relation an = 11an−1 − 39an−2 + 45an−3 is x3 − 11x2 + 39x − 45 = 0 and it’s general solution is an = (A + Bn)3n + C5n . If the initial conditions are a0 = 5, a1 = 11, a3 = 25 then it’s general solution is an = (4 − 2n)3n + 5n . Example 6.3.9. The characteristic equation of homogeneous part of recurrence relation an − 3an−1 = 2n is x − 3 = 0 and so general solution of homogeneous part an − 3an−1 = 0 is an = C.3n . Let an = An + B be it’s particular solution. Using recurrence relation, we have An + B − 3(A(n − 1) + B) = 2n. This gives −2A = 2 and 3A − 2B = 0. Thus, A = −1 and B = −3/2 and so particular solution is an = −n − 3/2. Thus, the general solution of given recurrence relation is an = C.3n − n − 3/2. Exercise 6.3.10. Solve the following recurrence relations: (i). 4an − 20an−1 + 17an−2 − 4an−3 = 0. (ii). an + 6an−1 + 12an−2 + 8an−3 = 0. (iii). an+4 + 4an+3 + 8an+2 + 8an+1 + 4an =0. (iv). an = an−1 + 6an−2 with initial conditions a0 = 3, a1 = 6.

6.3.2

Linear non-homogeneous recurrence relations with constant coefficients

P Let ki=1 ci an+i = f (n) be a non-homogeneous linear equation with constant coefficients. Then its solution is given by

6.3. RECURRENCE RELATION AND ITS SOLUTION

103

an = ahn + apn P where ahn is the solution of its homogeneous part ki=1 ci an+i = 0 and apn is any its particular solution. There is no general method to determine its particular solution. Let f (n) = (br nr + br−1 nr−1 + . . . + b0 )k n , where bi ’s and k are real numbers. Then a particular solution is given by

apn =

 (pr nr + pr−1 nr−1 + . . . + p1 n + p0 )k n     

if k is not a root of characteristic equation

  nm (pr nr + pr−1 nr−1 + . . . + p1 n + p0 )k n if k is a root of characteristic    equation with multiplicity m

Exercise 6.3.11. Find the particular solution of following recurrence relations: (i). an − 5an−1 + 6an−2 = 7n . (ii). an + an−1 = 5n.2n . (iii). an − an−1 = 6.

6.3.3

Solution of recurrence relation by the method of generating function

This method is illustrated by solved examples. Example 6.3.12. Solve the recurrence relation an = 8an−1 + 10n−1 by using generating function, where a0 = 1. Solution: Let ∞ X an x n = a0 + a1 x + a2 x 2 + . . . (6.3.3) A(x) = n=0

be a generating function corresponding to numeric function an . But a0 = 1. Thus A(x) = 1 + a1 x + a2 x2 + . . .

(6.3.4)

Since an = 8an−1 + 10n−1 , thus it does not hold for n = 0. Multiplying both sides this equation by xn and then taking summation from n = 1 to ∞, we have ∞ ∞ ∞ X X X an x n = 8 an−1 xn + 10n−1 xn n=1

n=1

n=1

104CHAPTER 6. NUMERIC FUNCTIONS AND RECURRENCE RELATIONS Using Eq. 6.3.4, we have   A(x) − 1 = 8x a0 + a1 x + a2 x2 + . . . + x 1 + 10x + (10x)2 + . . . x = 8xA(x) + 1 − 10x Solving this, we get 1 − 9x 1.(1 − 10x) + x = . (1 − 10x)(1 − 8x) (1 − 10x)(1 − 8x)

A(x) =

Using method of partial fractions, we get   1 1 + A(x) = (1/2). 1 − 10x 1 − 8x ! ∞ ∞ X X (8x)n = (1/2). (10x)n + n=0

n=0

i.e;

∞ X

an x n =

n=0

∞  X n=0

n

10 + 8 2

n



xn .

Comparing the coefficients of xn , we get an = [10n + 8n ]/2. Exercise 6.3.13. Solve the recurrence relation an = 2an−1 + 3 with initial condition a0 = 1, by the method of generating function. Solution: Let A(x) =

∞ X

an x n = a0 + a1 x + a2 x 2 + . . .

(6.3.5)

n=0

be a generating function corresponding to numeric function an . But a0 = 1. Thus A(x) = 1 + a1 x + a2 x2 + . . .

(6.3.6)

Since an = 2an−1 + 3, thus it does not hold for n = 0. Multiplying both sides this equation by xn and then taking summation from n = 1 to ∞, we have ∞ X n=1

an x n = 2

∞ X n=1

an−1 xn +

∞ X n=1

3xn

6.4.

COMBINATORIAL PROBLEMS AND GENERATING FUNCTIONS.105

Using Eq. 6.3.4, we have   A(x) − 1 = 2x a0 + a1 x + a2 x2 + . . . + 3 x + x2 + x3 . . . 3x = 2xA(x) + 1−x Solving this, we get A(x) = fractions, we get

1.(1−x)+3x (1−x)(1−2x)

=

1+2x . (1−x)(1−2x)

Using method of partial

 3 4 − A(x) = 1 − 2x 1 − x ! ∞ ∞ X X xn = 4. (2x)n − 3. 

n=0

i.e;

∞ X n=0

an x n =

∞ X

n=0

(4.2n − 3) xn .

n=0

Comparing the coefficients of xn , we get an = 4.2n − 3.

6.4

Combinatorial problems And Generating functions.

As we know that (1 + x)n = nC0 + nC1 x + nC2 x2 + . . . + nCn xn for fixed natural number n. Thus, (1 + x)n is the generating function for numeric function ar = n Cr . Note that n Cr = 0 for r > n. Observe that to make the term xr , exactly r of the n factors 1 + x contribute x each and remaining n − r factors contribute 1 each, in the expansion (1 + x)n . Thus, the coefficient of xr will be the number of ways of selecting r factors out of n factors and so it will be n Cr . Indeed, each factor (1 + x) of (1 + x)n contains two terms 1 = x0 and x corresponding to selecting an object zero times and once. Hence, if an object may be selected k times then it corresponds a factor 1 + x + x2 + . . . + xk instead of 1 + x. In other words the generating function corresponding to an object selecting at most k times is 1 + x + x2 + . . . + xk = (1 − xk+1 )(1 − x)−1 . Similarly, we have:

106CHAPTER 6. NUMERIC FUNCTIONS AND RECURRENCE RELATIONS (i) . the generating function corresponding to an object selecting at least k times is xk + xk+1 + . . ., i.e; xk (1 − x)−1 . (ii) . the generating function corresponding to an object selecting with unlimited repetitions is 1 + x + x2 + . . . = (1 − x)−1 . (iii) . the generating function corresponding to an object selecting at least k times but at most r ≥ k times is xk + xk+1 + . . . + xr , that is; xk (1 − xr−k+1 )(1 − x)−1 . We now illustrate it by following exercises: Exercise 6.4.1. Find a generating function for the numeric function ar , where ar is the number of ways to select r objects from 10 objects x1 , x2 ,. . . , x10 among which x1 can be selected at most twice, x2 can be selected at most thrice and others can be selected only once. Solution: Let A(x) be its generating function. Since we can select the object x1 zero times, once or twice, therefore A(x) will contain the factor 1 + x + x2 . Similarly, A(x) will contain the factor 1 + x + x2 + x3 corresponding to x2 and will contain 1 + x corresponding to each xi , ≤ i ≤ 10. Thus, A(x) will be A(x) = (1 + x + x2 )(1 + x + x2 + x3 )(1 + x)8 . Exercise 6.4.2. Let ar be the number of ways to select r balls from a pile of three green, three blue, three white, three pink balls. Prove that the generating function corresponding to numeric function ar is (1 + x + x2 + x3 )4 . Exercise 6.4.3. Let ar be the number of ways of selecting r objects from n objects with unlimited repetitions. Find generating function and ar . Solution: Since each objects can be selected with unlimited repetitions. Therefore 1 + x + x2 + . . . + xr + . . . will be the factor of required generating function. But total number of objects are n, therefore the required generating function will be n 1 + x + x2 + . . . + xr + . . . = (1 − x)−n . Thus ar = coefficient of xr in the expansion of (1 − x)−n n(n + 1) . . . (n + r − 1) = r!   n+r−1 = (we read “n + r − 1 choose r 00 ) r

6.5. EXERCISES

107

Exercise 6.4.4. Let ar be the number of ways of selecting r objects from three types of objects with repetition up to four objects of each type. Prove that the generating function of ar will be  3 1 − x5 2 3 4 3 (1 + x + x + x + x ) = . 1−x Also find a6 . Solution: The factor of generating function corresponding to selecting an object at most four times will be 1 + x + x2 + x3 + x4 . Since total number of types of object is 3. Therefore the generating function of ar will be 3  1 − x5 2 3 4 3 (1 + x + x + x + x ) = 1−x = (1 − 3x5 + 3x10 − x15 )(1 − x)−3 Thus, a6 = coeff. of x6 in the generating function = coeff. of x6 in (1 − x)−3 − 3 × coeff. of x in (1 − x)−3 3.4.5.6.7.8 −3×3 = 6! = 28 − 9 = 19

6.5

Exercises

Exercise 6.5.1. Find the degree of following recurrence relations. Determine which of the following are linear homogeneous recurrence relations with constant coefficients. a. an = 5an−1 + 4an−2 . b. an = nan−1 + an−2 . c. an = an−1 + an−3 . d. an+1 = nan−1 + an−2 + 7. Exercise 6.5.2. Solve the following recurrence relations together with the initial conditions given:

108CHAPTER 6. NUMERIC FUNCTIONS AND RECURRENCE RELATIONS i). an = 3an−1 for n ≥ 1 with a0 = 3. ii). an − 5an−1 + 6an−2 = 0 for n ≥ 2 with a0 = 2 and a1 = 8. iii). an = 2an−1 + an−2 − 2an−3 for n ≥ 3 with a0 = 3, a1 = 6 and a2 = 0. Exercise 6.5.3. Using generating function, find the number of distributions of 10 identical objects in to : (a) . Five different boxes with at most four objects in each box. (b) . Seven different boxes with at least one object in each box. (c) . Three different boxes with at most five objects in first box. Hint- (a). Generating function is (1+x+x2 +x3 +x4 )5 = (1−x5 )5 (1−x)−5 and evaluate the coeff. of x10 ). (b). Generating function is (x + x2 + x3 + . . .)7 = x7 (1 − x)−7 and then evaluate the coeff. of x10 ). (c). Generating function is (1+x+x2 +x3 +x4 +x5 )(1+x+x2 +x3 +. . .)2 = (1 − x6 )(1 − x)−3 and then evaluate the coefficient of x10 ). Exercise 6.5.4. Using generating function, find the number of ways of selecting 6 balls from a large pile of green, red, blue and pink balls if: (a) the selection has at least two balls of each color. (b) the selection has at most two green balls. (c) the selection has an even number of green and red balls each but at most two blue and pink balls each. Hint: Evaluate the coefficient of x6 in the expansion of following generating functions: (a) (x2 + x3 + . . .)4 . (b) (1 + x + x2 )(1 + x + x2 + . . .)3 . (c) (1 + x2 + x4 + . . .)2 (1 + x + x2 )2 . Pr m n Exercise 6.5.5. Use generating functions, prove that k=0 Ck Cr−k = m+n Cr . The solution follows from A(x).B(x) = (1 + x)m+n , where A(x) = (1 + x)m and B(x) = (1 + x)n .

6.5. EXERCISES

109

Exercise 6.5.6. Using generating function, solve the following recurrence relations: (i). an − 5an−1 + 6an−2 = 2n + n (n ≥ 2) with initial conditions a0 = 1, a1 = 1. (ii). an − an−1 − 2an−2 = 0 with a0 = 2 and a1 = 10. (iii). an = 3an−1 + 2 with a0 = 1. (iv). an = an−1 + n with a0 = 1. Exercise 6.5.7. Let A(x) be a generating function corresponding to numeric function an . Prove that the generating function of accumulated sum bn = Pn . a of an is A(x) r=1 r 1−x

110CHAPTER 6. NUMERIC FUNCTIONS AND RECURRENCE RELATIONS

CHAPTER

7

Graphs

This chapter is devoted to study graphs. Its basic idea were introduced in eighteenth century by great mathematician Leonhard Euler. He used graphs to solve the famous problem Konigsberg bridge problem. It has many applications in transportation network, computer network, circuit analysis etc.

7.1

Definition and examples

Definition 7.1.1. Let V be a non-empty set and E is a set. If each element e ∈ E is assigned with a pair of elements u, v ∈ V , i.e; if each e =: {u, v} for some u, v ∈ V , then the ordered pair G = (V, E) is called a graph. Note that u and v may be either disjoint or identical. If each e ∈ E is assigned with ordered pair (u, v), then ordered pair (V, E) is called a directed graph or digraph. If both V and E are finite sets, then the graph (V, E) is called a finite graph otherwise it is called an infinite graph. The elements of V in a graph G = (V, E) are called vertices (or nodes or points) of graph and elements of E are called edges of graph G. If e is an edge assigned with a pair of elements u, v ∈ V , then we write e =: {u, v} and call u and v as end vertices of edge e. In this case, we also call “e is an edge 111

112

CHAPTER 7. GRAPHS

joining the vertices u and v”. In case of digraph G = (V, E), the elements of E are called directed edges. If e =: (u, v) in digraph G then e is called an edge from u to v. In this case, u is called an initial vertex of edge e and v is called terminal vertex of e. Graphs G = (V, E) are usually represented by labeled diagrams in which elements of V (each vertices) are represented by big “dots” or “small circles” and each element e =: {u, v} of E is represented by a labeled curved line joining vertices u and v together with label e, so that no two edges of G = (V, E) overlap each other. Example 7.1.2. Let V = {v0 , v1 , v2 } and E = {e1 , e2 }. Suppose that e1 ∈ E is assigned with the collection {v0 , v0 } of elements v0 ∈ V and e2 ∈ E is assigned with the collection {v1 , v2 } of elements v1 , v2 ∈ V , that is; e1 = {v0 , v0 } and e2 = {v1 , v2 }. Then (V, E) is a graph. It is represented by the following labeled diagram (figure 7.1) e1 v0

e2 v1

v2

Figure 7.1: graph Some more examples of graphs are given by figure 7.2: e3

d c e4

c e1 e =: {a, b}

e1

e2

e2

e2 a

b

d

c

e1 e3

a b

3 c

a

b

e b

a

0

2 a b f 1

Figure 7.2: Examples of graphs

7.1. DEFINITION AND EXAMPLES

113

Definition 7.1.3. Any two vertices u and v of a graph G = (V, E) are called adjacent vertices if there is an edge e ∈ E joining u and v. If e is an edge joining u and v in a graph G = (V, E), then we say e is incident on vertices u and v. Any two edges are called adjacent edges if they have a common end vertex. In the graph given by figure 7.1, observe that edge e1 is incident on v0 , v0 . Thus, v0 is adjacent to v0 itself. Similarly, v1 is adjacent to v2 because edge e2 is incident on vertices v1 and v2 . Edges e1 , e2 and e7 , e8 are adjacent edges in figure 7.3 because they have common end vertices 1 and 5 respectively. 6 e8

3

e3

2 e5

e9

5 e7

4 e4

e2 e6 1

0

e1

Figure 7.3: graph with self loops and parallel edge Edges e1 and e8 in figure 7.3 are not adjacent because they have no common end vertex. Definition 7.1.4. An edge e ∈ E whose end vertices are same, is called a self loop. In other words, an edge e joining the vertex to itself is called a self loop or loop. Thus, edge e1 in the figure 7.1 is a self loop. Observe that a self loop is incident twice on its end vertex because its end vertices are same. Any two edges are called parallel edges if they have common end vertices. Since edges e8 and e9 in the figure 7.3 have same common end vertices therefore these are parallel edges. Definition 7.1.5. Let G = (V, E) be a graph and v ∈ V be a given vertex. Then, the total number of edges incident on v is called the degree or valency of the vertex v in the graph G. The degree of vertex v is denoted by d(v) or |v|. It is noted that a self -loop incident on a vertex v counted twice for evaluating the degree of v. If d(v) = 0 for a vertex v in the graph G = (V, E) then there is no edge incident on v. Such vertex is called an isolated vertex

114

CHAPTER 7. GRAPHS

of the graph. If d(v) = 1 then v is called a pendant vertex of the graph. In a directed graph, the incoming degree or in degree of a vertex is the number of edges that are incident into it, and the outgoing degree or out degree of a vertex is the number of edges that are incident from it. Consider the following graph (figure 7.4) 6 e8

e3

3

2 e5

e9

5 e7

4 e4

e2 e6 1

0

e1

Figure 7.4: graph with self loops and parallel edge One may easily observe that d(0) = d(2) = d(4) = d(5) and d(1) = d(3) = d(6) = 2. Thus, this graph has neither a pendant vertex nor an isolated vertex. The graph given by figure 7.1 has pendant vertices v1 and v2 but not has an isolated vertex. Definition 7.1.6. A finite graph G = (V, E) in which every vertex has same degree, say r, is called a regular graph of degree r or simply r− regular. Graphs given by figure 7.5 are regular graphs (verify).

G2

G1

G4

G3

G5

Figure 7.5: Regular Graphs Definition 7.1.7. A graph G = (V, E) is called a null graph if E = ∅, i.e; if d(v) = 0 for all v ∈ V . Thus, all the vertices of null graphs are isolated. A null graph is called a trivial graph if V contains exactly one element.

7.1. DEFINITION AND EXAMPLES

115

The following is a diagram of null graph with six vertices. •v1 •v2 •v3 •v4 •v5 •v6 Example 7.1.8. G = (V, E) is a trivial graph where V = {0} and edge set E = ∅. It is represented by the following diagram. •v Example 7.1.9. The graph (V, E) is a null graph where V = {v1 , v2 , . . . , vn } contains n-elements and E = ∅. Definition 7.1.10. A graph is called a Multigraph if it has either parallel edges or self-loops. A graph without self-loops and parallel edges, is called a simple graph. A simple graph with n vertices is called a complete graph if every pair of distinct vertices is joined by a unique edge, i.e; every pair of distinct vertices are adjacent by a unique edge. It is denoted by Kn . Thus, complete graphs Kn for n = 1, 2, 3, 4 are given by :

K2

K3

K4

K4

K1

Figure 7.6: complete graphs From the above figure, it is clear that Kn has

n(n−1) . 2

edges.

Exercise 7.1.11. Find the degree of vertex v0 in the graph G = (V, E), where V = {v0 , v1 , v2 }, E = {e1 , e2 , e3 , e4 } with e1 = {v0 , v1 }, e2 = {v1 , v2 }, e3 = {v1 , v2 } and e4 = {v0 , v2 }. The diagram of G is given by figure 7.7 Lemma 7.1.12. Handshaking lemma: For any finite graph G = (V, E), the sum of degrees of vertices is twice the number of edges in that graph, i.e; X d(v) = 2|E|, v∈V

116

CHAPTER 7. GRAPHS e4

v2 e3 e2

v0 e4

v1

Figure 7.7: where |E| denotes the number of elements in E (cardinality of E). Proof: Let G = (V, E) be a finite graph. Since each edge is incident on two vertices which are its end vertices. Therefore, each edge will be counted twice in the sum of degrees of vertices and so we have X d(v) = 2|E|. v∈V

2 Definition 7.1.13. A vertex whose degree is even is called an even vertex. A vertex whose degree is odd is called an odd vertex. Corollary 7.1.14. The sum of degrees of odd vertices in a finite graph is even. Proof: Let G be a finite graph with n vertices v1 , v2 , . . . , vn . Without loss of generality, assume that v1 , v2 , . . . , vr (r ≤ n) be odd vertices and rest n − r vertices vr+1 , vr+2P , . . ., vn are even vertices. Then, each d(vj ), r + 1 ≤ j ≤ n is even and so ni=r+1 d(vj ) is an even number. By Lemma 7.1.12 (Handshaking lemma), we have r X

n X

d(vi ) +

i=1

d(vj ) =

j=r+1

X

d(v) = 2|E|.

v∈V

This gives r X i=1

d(vi ) = 2|E| −

n X

d(vj )

i=r+1

= even number − even number = even number.

(each d(vj ) is even)

2 From this, it follows that the number of odd vertices in any graph is even.

7.1. DEFINITION AND EXAMPLES

117

Proposition 7.1.15. The number of edges in Kn is equal to n C2 =

n(n−1) . 2

Proof: Let q be the total number of edges P in the graph Kn . Since each vertices have degree n − 1, therefore v∈Kn d(v) = n(n − 1). But P v∈Kn d(v) = 2|E| (handshaking lemma). Thus, 2q = n(n − 1) and so n(n − 1) n q= = C2 . 2 2 Definition 7.1.16. A simple graph G = (V, E) with n-vertices and n-edges, where n ≥ 3, is called an n-cycle if its vertices are arranged in a sequence v1 , v2 , . . . , vn such that each set {vi , vi+1 } for 1 ≤ i < n and {vn , v1 } is assigned with a unique edge. It is denoted by Cn . The cycles C3 , C4 , C5 and C6 are displayed in the figure 7.8

C5 C3

C4

C6

Figure 7.8: Cyclic graphs One may easily observe that a 2-regular simple graph with n-vertices (n ≥ 3) is an n − cycle. Definition 7.1.17. When we add an additional vertex to the cycle Cn (n ≥ 3) and connect it to each vertices of Cn by unique edges, then the resulting graph is called a wheel. It is denoted by Wn . The wheels W3 , W4 , W5 and W6 are displayed in the figure 7.9

W6 W3 W4

W5

Figure 7.9: Wheels

118

CHAPTER 7. GRAPHS

Definition 7.1.18. The n − cube, denoted by Qn , is the graph that has 2n bit strings of length n. Two vertices are adjacent if and only if their corresponding bit strings are differ in exactly one bit position. The cubes Q1 , Q2 and Q3 are displayed in figure 7.10 10

11 001

Q1 0

Q2 1

011

101

111

01 00

000

010

100 Q3

110

Figure 7.10: Cubes Exercise 7.1.19. Let G = (V, E) be a graph with v vertices and e edges. Let M and m be the maximum and minimum degree of vertices respectively. 2e 2e Then, prove that m ≤ and M ≥ . v v Solution: Since m ≤ d(k) for each vertex k of G. Taking sum over all vertices of G, we get . . . + m} ≤ |m + m{z v−times

X

d(k) = 2e

(by handshaking lemma).

k∈V

2e This gives mv ≤ 2e and so m ≤ . Similarly, M ≥ d(k) for each vertex v 2e k of G gives M ≥ . v Exercise 7.1.20. What is the maximum number of vertices in a graph with 35 edges and all vertices of degree at least 3. Hint: Let n be the number of vertices in the given graph (V, E). Since each P vertex is of degree 3, therefore sum of degrees will be at least 3n. But v∈V d(v) = 2|E|. Given that |E| = 35. Thus, 3n ≤ 70 and so maximum number of vertices will be 23.

7.1. DEFINITION AND EXAMPLES

119

Exercise 7.1.21. Is it possible to have a group of nine people such that each person is acquainted with exactly five of the other people? Solution: Let G = (V, E) be a corresponding graph where each person is treated as vertex of the graph and two persons are joined by an edge if they are acquainted. Since each person is acquainted with P exactly five of the other people therefore d(v) = 5 for each P v ∈ V and so v∈V d(v) = 9 × 5 = 45. Since by handshaking lemma, v∈V d(v) is even. Thus, it is not possible to have a group of nine people such that each person is acquainted with exactly five of the other people.

7.1.1

Bipartite Graphs

Definition 7.1.22. A simple graph G = (V, E) is called a bipartite graph if the vertex set V has a partition {V1 , V2 } such that every edge in G joins a vertex of V1 to a vertex of V2 . We denote it by {V1 , V2 }. Thus, no edge in G connects either two vertices of V1 or two vertices of V2 . A bipartite graph {V1 , V2 } is called a complete bipartite graph if every vertex of V1 is joined to every vertex of V2 by a unique edge. If V1 has m elements and V2 has n elements, then it is denoted by Km,n . Observe that Km,n has m + n vertices and mn edges. Some bipartite graphs are given by figure 7.11. v3

c a

b

d v4

d a

e

e

b G1

b

v1

c

v0 v4

f G2

K2,3

c a

K3

Figure 7.11: bipartite graphs From the figure 7.11, it is clear that G1 is bipartite with partition {V1 , V2 }, where V1 = {a, b}, V2 = {c, d, e}. Similarly G2 is bipartite with partition {V1 , V2 } where V1 = {a, c, e}, V2 = {b, d, f }. It is also noted that G1 and G2 are not completely bipartite. The graph K2,3 is completely bipartite. The graph K3 is not bipartite because if we divide the vertex set of K3 in to two disjoint subsets V1 and V2 such that V = V1 ∪ V2 , then either V1 or V2 will contain two elements and there is an edge joining these two vertices.

120

CHAPTER 7. GRAPHS

Example 7.1.23. The graph G1 in the figure 7.12 is bipartite with V1 = {a, b, d} and V2 = {c, e, f, g} but the graph G2 in the figure 7.12 is not bipartite because it can not be partitioned into two subsets so that edges do not connect two vertices from the same subset. a

a

b

b g c

f

c

f e

d

e

G1

d G2

Figure 7.12:

Exercise 7.1.24. Determine whether the following graph is bipartite? b a c

e

b

d f

a

c a

d

e

c d

e b

Exercise 7.1.25. Show that the maximum number of edges in a complete v2 bipartite graph with v vertices is . 4 Solution: Let G = Km,n where m + n = v. Let e be the the total number v2 of edges in Km,n . Then e = mn. But maximum value of e = mn is at the 4 2 v v stationary point given by m = n = . Thus, maximum value of e is . 2 4 Exercise 7.1.26. Show that if G is a bipartite simple graph with v vertices v2 and e edges, then e ≤ . 4 Solution: Let G = (V, E) and {V1 , V2 } be a partition of V . Let |V1 | = m and |V2 | = n. Then m + n = v. Since G is simple therefore e ≤ mn. Since

7.1. DEFINITION AND EXAMPLES

121

maximum value of mn with m + n = v is

v2 at the stationary point given by 4

v2 v m = n = and e ≤ mn. Therefore e ≤ . 2 4

7.1.2

Subgraphs

Definition 7.1.27. A graph G1 = (V1 , E1 ) is called a subgraph of the graph G = (V, E) if V1 ⊆ V and E1 ⊆ E with the property that e ∈ E1 is an edge joining end vertices u, v ∈ V1 only if it is an edge joining them in graph G = (V, E). A subgraph (V1 , E1 ) of a graph (V, E) is called a spanning subgraph of (V, E) if V1 = V , i.e; V1 contains all the vertices of the graph. Any two subgraphs G1 = (V1 , E1 ) and G2 = (V2 , E2 ) of a given graph G = (V, E) are called edge disjoint if E1 ∩ E2 = ∅; i.e, edges are disjoint. Any two subgraphs G1 = (V1 , E1 ) and G2 = (V2 , E2 ) of a given graph G = (V, E) will be called vertex disjoint if V1 ∩ V2 = ∅. Observe that H = (V1 , E1 ), where V1 = {v0 , v1 , v2 }, E1 = {e1 , e2 } with e1 = {v0 , v1 }, e2 = {v1 , v2 }, is a subgraph of the graph G = (V, E) where V = {v0 , v1 , v2 , v3 }, E = {e1 , e2 , e3 , e4 } with e1 = {v0 , v1 }, e2 = {v1 , v2 } and e3 = {v2 , v3 } = e4 . It is shown in the figure 7.13: v1 v1

v1

e1

e2 e2 v2

v0

e1

e2

e1

v2

v0

H

K

e4

v2 e3

e4

v0

v2

e3 v3

G

v3

e3 v3

e1 L

v1 M

v0

Figure 7.13: Subgraphs From the figure 7.13, it is also clear that K is a spanning subgraph of graph G and H, L are edge disjoint subgraphs of graph G. Subgraphs L and M are vertex disjoint subgraphs of graph G.

122

7.1.3

CHAPTER 7. GRAPHS

Edge and vertex deletion

Let G = (V, E) is a graph and v ∈ V . Then G − v is a subgraph obtained by deleting v from G and deleting all edges of G containing v. The process of deleting a vertex from graph is known as vertex deletion. Let e ∈ E. Then G − e is a subgraph obtained by deleting e from G. The process of deleting an edge from a given graph is known as edge deletion. From the figure 7.13, it is clear that G − v3 = H and G − e4 = K.

7.1.4

Operation on graphs

Let G1 = (V1 , E1 ) and G2 = (V2 , E2 ) be any two graphs. Then union of two graphs G1 and G2 is a graph (V, E), where V = V1 ∪ V2 and E = E1 ∪ E2 . It is illustrated by the figure 7.14: b

c

c =

e1 H U

b

K e2

HU K

e1

e2 c

a

d

a

d

b U K a

H

HU K = a

b

b

c

Figure 7.14: Union of two graphs Similarly, intersection of two graphs (V1 , E1 ) and (V2 , E2 ) is the graph (V1 ∩ V2 , E1 ∩ E2 ). The intersection of two graphs H and K is illustrated by the figure 7.15: c c

c H ∩K

e1

K

e2

H b

b

b

a

Figure 7.15: Intersection of two graphs

7.1. DEFINITION AND EXAMPLES

7.1.5

123

Complementary Graph

Definition 7.1.28. The complement or complementary graph of a simple graph G = (V, E) is a graph (V, E 0 ) in which two vertices u, v are adjacent in (V, E 0 ) if and only if u, v are not adjacent in (V, E). It is denoted by G. Thus, if G is a simple graph with n vertices, then G ∪ G = Kn (Prove it). In other words G is a graph obtained by deleting all the edges of G from Kn . A simple graph G is called self complementary if G is isomorphic to G. One may easily observe that a 2−regular graph with 5 vertices is self complementary. The complement of G is H which is shown in figure 7.16: e e

d

a

a b G

d

b

c

c H

Figure 7.16: Complement of a graph Similarly, the complement of Kn is a null graph. Exercise 7.1.29. If G is a simple graph with 15 edges and G has 13 edges, how many vertices does G have? n(n − 1) = 15+13 and so (n−7)(n+8) = Hint: Since G∪G = Kn , therefore 2 0. This gives n = 7. Exercise 7.1.30. If a simple graph G is self complementary then prove that it has either 4k or 4k + 1 vertices. Solution: Suppose that G has n vertices. Let e be the number of edges in G. Since G is self complementary therefore G is isomorphic to G (hence number of edges in G and G will be same) and G ∪ G = Kn . Thus, e + e = n(n − 1) n(n − 1) , i.e; e = . This shows that either n or n − 1 is a multiple 2 4 of 4. Hence either n = 4k or n = 4k + 1 for some natural number k.

124

7.2

CHAPTER 7. GRAPHS

Isomorphisms

Definition 7.2.1. Two graphs G1 = (V1 , E1 ) and G2 = (V2 , E2 ) are said to be isomorphic if there exists bijective maps f : V1 → V2 and g : E1 → E2 such that e ∈ E1 is an edge joining end vertices u and v if and only if g(e) ∈ E2 is an edge joining end vertices f (u) and f (v). In other words, two graphs G1 = (V1 , E1 ) and G2 = (V2 , E2 ) are said to be isomorphic if there exists a bijective map from G1 to G2 which preserves incidence structure. Example 7.2.2. Graphs G and H are isomorphic through an isomorphism (f, g) given by f (a) = 1, f (b) = 2, f (c) = 3, f (d) = 4, f (e) = 5 and g(e1 ) = f1 , g(e2 ) = f2 , g(e3 ) = f3 , g(e4 ) = f4 and g(e5 ) = f5 respectively. These are given by figure 7.17: a

e

2

4 f2

c e1

e3

e4

f1

f3

f4

e2 b

1

d

3

G

5

H

Figure 7.17: Isomorphic Graphs Exercise 7.2.3. Prove that the following graphs are isomorphic: 1 d

c

4

a

3 b

7.3

2

Walk, Paths and Circuits

Definition 7.3.1. A finite alternating sequence of vertices and edges v0 , e1 , v2 , e2 , v3 , . . . , vk−1 , ek , vk , . . . , vn−1 , en , vn

7.3. WALK, PATHS AND CIRCUITS

125

in a graph G = (V, E), where ei =: {vi−1 , vi } for all 1 ≤ i ≤ n and all the edges are distinct, is called a walk. Vertices v0 and vn are called end or terminal vertices of the walk. The number n of edges in a walk is called the length of walk. All the other vertices of walk different from end vertices are called internal vertices. If end vertices of a walk are distinct, then it is called open walk. If end vertices of a walk are same, then it is called a closed walk. An open walk in which all the vertices are distinct (i.e, vertex appears exactly once) is called a path. The number of edges in path is called the length of path. A closed walk in which all vertices are distinct except end vertices is called a closed path or a circuit or a cycle. The length of the walk is called the length of circuit. For example, γ := ae1 be2 c is a walk of length 2, joining end vertices a and c in the graph(figure 7.18) e4

c

d e7

e3 e1

y

e5

e2 e6

a

b

x

Figure 7.18: but ae1 be2 ce2 b is not a walk because edge e2 is repeated in the alternating sequence of vertices and edges. Indeed, γ is a path from a to b. We also say γ is a path joining vertices a and b. The graph 7.18 contains a circuit ce3 xe5 de4 c of length 3. Definition 7.3.2. A graph is called connected if every pair of vertices are joined by a path. A graph which is not connected is called disconnected. A connected subgraph H of a graph G is called a maximal connected subgraph (component) if K is a connected subgraph of G with H ⊂ K implies H = K. Thus, a graph is called connected if it has exactly one component. Proposition 7.3.3. A graph G = (V, E) is disconnected if and only if the vertex set V can be partitioned in to two non-empty disjoint subsets V1 and V2 such that no edge in G whose one end vertex in V1 and the other in V2 . Proof: Let G = (V, E) be a disconnected graph. Let v be any vertex in V . Let V1 = {a ∈ V |there is a path joining a and v}. Since G is not

126

CHAPTER 7. GRAPHS

connected therefore V1 6= V . Take V2 = V \ V1 . Then no vertex of V2 is joined by a vertex in V1 . Hence {V1 , V2 } is a required partition of V . Conversely suppose that V has a partition {V1 , V2 } such that no edge has one end vertex in V1 and the other in V2 . Choose a ∈ V1 and b ∈ V2 . Clearly it has no path joining a and b otherwise there exists an edge whose one end vertex in V1 and the other in V2 , which is a contradiction. Thus G is not connected. 2

Proposition 7.3.4. If a graph has exactly two vertices of odd degree, then they belongs to the same component (i.e; there exists a path joining these two vertices). Proof: Let G be a graph with exactly two vertices of odd degree. If G is connected then nothing to do. Suppose that G is disconnected and so it has at least two components. Let a, b be the vertices of odd degree. Since each componentsPare subgraphs and so handshaking lemma holds for each component, i.e; d(v) is even for each components. This suggests us that a and b belongs to the same connected component and so there will be a path joining these two vertices. 2 Lemma 7.3.5. If ni , 1 ≤ i ≤ k are natural numbers such that P then ki=1 n2i ≤ n2 − (k − 1)(2n − k).

Pk

i=1

ni = n

P P Proof: Since ki=1 (ni −1) = n−k and so { ki=1 (ni −1)}2 = (n−k)2 gives Pk P Pk 2 2 2 2 (n − 1)(n − 1) = n − 2nk + k , i.e; (n − 1) + 2 i i j i=1 i6=j i=1 (ni − 1) ≤ 2 2 n − 2nk + k . Solving this we get the required inequality. 2

Theorem 7.3.6. A simple graph with n vertices and k components has at (n − k)(n − k + 1) most edges. 2 Proof: Let G be a graph with n vertices and k components GP 1 , G2 . . ., Gk . Suppose that Gi has ni vertices for each i. Then ni > 0 and ki=1 ni = n. Since a simple graph with n vertices has at most n(n−1) edges. Thus, 2

7.3. WALK, PATHS AND CIRCUITS maximum number of edges will be k X ni (ni − 1) i=1

2

Pk =

i=1

n2i − 2

Pk

Pk

i=1

i=1

127 ni (ni −1) . 2

ni

[n2 − (k − 1)(2n − k) − n] ≤ 2 =

But

(by lemma 7.3.5 and

k X

ni = n)

i=1

(n − k)(n − k + 1) 2

2 A graph with exactly one component is connected. Thus, a connected graph with n vertices has at most n(n − 1)/2 edges. A graph having at least two components is disconnected and so a simple disconnected graph with n edges. Thus, we have vertices has at most (n−1)(n−2) 2 Corollary 7.3.7. A simple graph with n vertices and having more than (n−1)(n−2) edges, is connected. 2 Proof: Immediate.2 Example 7.3.8. A simple graph with 5 vertices and 9 edges will be connected because a disconnected graph with 5 vertices has at most (5−1)(5−2) = 6. 2 Proposition 7.3.9. A graph is bipartite if and only if every circuit is of even length. Proof: Let G be a bipartite graph with partition {V1 , V2 }. Let γ := v0 e1 v1 e2 v3 . . . vn−1 en vn be a circuit where vn = v0 . Without loss of generality, assume that v0 ∈ V1 . Then all vertices with even indices belong to V1 and all vertices with odd indices belong to V2 . Since vn = v0 ∈ V1 , therefore n is even. Conversely suppose that every circuit is of even length. Choose arbitrarily one vertex from each component and paint each of them with color 1. We now successively paint all the vertices of graph as follows: If a vertex has color 1 then any vertex adjacent to it will be painted with color 2. Next, if a a vertex has color 2 then any vertex adjacent to it will be painted with color 1.

128

CHAPTER 7. GRAPHS

Continue this process till every vertex in the graph has been painted. Since every circuit is of even length therefore no two adjacent vertices will have the same color. Let V1 be the set of all vertices which have color 1 and V2 be the set of all vertices which have color 2. Clearly {V1 , V2 } is a partition such that no two vertices in V1 or V2 are adjacent. Clearly every edge joins a vertex of V1 to a vertex of V2 . Hence the graph is bipartite.2

7.4 7.4.1

Euler Graph Konigsberg bridge problem

This problem can be stated as follows: Two islands A and B lying in the Pregel river in Konigsberg town, Russia were connected to each other and to the river banks C and D with seven bridges as shown in figure 7.4.1: C

B A

D

Figure 7.19: Konigsberg brige problem The problem is to start at any of the four land areas A, B, C or D, walk over each of the seven bridges exactly once, and return to the starting point. The graph corresponding to above is Konigsberg’s people asked the solution from Euler. Euler proved that the solution is impossible 7.4.2.

7.4.2

Euler graph

Definition 7.4.1. A closed walk in a graph which contains all the edges of a graph is called an Euler line or Euler circuit. A graph which contains an Euler line is called an Euler graph. Observe that the graph 7.4.1 is not an Euler graph.

7.4. EULER GRAPH

129 C

A

B

D

.

Figure 7.20: Konigsberg brige problem For each n, Cn and G are Euler graphs where G is given by b d e4 e1

e2

e5

e3 a

c

e6

e

Observe that ae1 be2 ce4 de5 ee6 ce3 a is an Euler line in G but ae1 be2 ce3 a is not an Euler line because this circuit does not contain all the edges of graph G. Indeed, we have the following: Theorem 7.4.2. A connected graph G is an Euler graph if and only if every vertex in G is of even degree. Proof: Let G be an Euler graph. Then it has an Euler line v0 e1 v1 e2 v2 . . . vi−1 ei vi . . . en vn+1 with vn+1 = v0 , say. Clearly each pair of edges ei , ei+1 contribute 2 to the degree of vertex vi for all 0 ≤ i ≤ n − 1. Also e1 and en contribute 2 to the degree of vertex v0 = vn+1 . Thus, degree of each vi is 2 and so even. Since some of the vertex is repeated in Euler line and sum of even numbers is even, therefore d(v) is even for each vertex v in G. Conversely suppose that d(v) is even for each vertex v in G. Choose any vertex v in G. We now construct a walk starting at v and going through the edges of G so that no edge is traversed more than once (Euler line). Since degree of every vertex is even therefore we can exit from every vertex to which we enter. Now, v is also of even degree and so eventually, we shall arrive at v when the traversing comes to an end. Let H be the traversed closed walk. If it contains all the edges of G then it will be an Euler line and so nothing

130

CHAPTER 7. GRAPHS

to do. If H does not contain all the edges of H then we remove all the edges of H from G and consider the subgraph H1 = G \ H formed by remaining edges of G. Clearly degree of every vertex in H1 will be even. Suppose that H1 has k connected components C1 , C2 , . . . Ck . Since G is connected therefore H1 and H will have k common vertices. Let it be w1 , w2 , . . . , wk . Starting from wi , we again construct a new closed walk Ki terminating at wi , in graph Ci for each 1 ≤ i ≤ k by above process. Consider H ∪ki=1 Ki . Then it will be a closed walk with starting and ending at v. If it contains all the edges of G then it will be an Euler line. If not, continuing the above process. Since G is finite, therefore after finite number of steps, we obtain an Euler line. 2 We illustrate it by following figure: Choose a as starting vertex. Traverse a closed walk H := ae1 be2 a starting and ending at a e

e

We have e8

e2

e3

e2

c

e8

c

e1 e7

e4 a

illus.pdf

e6 f

G

e1

a

e3 b

e7

e4 e6

H

b e5

a

C1 d

b C 2 e5

f

d

Figure 7.21: Illustration for Euler line Here G\H = C1 ∩C2 where C1 and C2 are connected components of G\H having common vertices a and b with H respectively. Clearly C1 , C2 and H are closed walks. Combining these, we get an Euler line ae1 be3 ce4 de5 be2 ae6 f e7 ee8 a.

graph.pdf Figure 7.22: non-Euler graph Example 7.4.3. The graph 7.4.3 is not an Euler line because it has some vertices of odd degree. The graph of Konigsberg bridge problem is not an Euler line because degree of C is not even. Similarly a complete bipartite graph Km,n is an Euler line if and only if both m and n are even. Theorem 7.4.4. A connected graph is an Euler graph if and only if it is union of edge disjoint circuits.

7.5. HAMILTON GRAPHS

131

Proof: Let G be a connected graph. If it is union of some edge disjoint circuits then degree of every vertices is even. By theorem 7.4.2, G is an euler graph. Conversely, suppose that G is an Euler graph. Then, degree of every vertex in G is even. Let v be any vertex. Then d(v) ≥ 2 and so at least two vertices will be adjacent to v. Let v1 be any vertex adjacent to v. Since degree of v1 is also even, therefore there exists a vertex v2 adjacent to v1 different from v. Continuing this process, we finally arrive at a vertex which has been traversed previously. Let it be vi . Then part of the walk beginning and ending at vi will be a circuit C. Remove C from the graph G and consider the graph G \ C. Since every vertex in the circuit C is of degree 2 and so every vertex in G \ C is of even degree. Since degree of every vertex in G \ C is even hence we have another circuit C1 in G \ C. Remove this from G C and continue the process until every edge has been traversed. By above process it is clear that all the circuits are edge disjoint. Thus G is union of some edge disjoint circuits. 2 The graph given by figure 7.4.1 is not union of edge disjoint circuits. Thus, it is not an Euler line. It is also noted that a disconnected graph is not an Euler line although every vertices have even degree. For example: the degree of every vertices in the disconnected graph

graph.pdf are even but it is not an Euler graph.

7.5

Hamilton graphs

Definition 7.5.1. A closed walk in a graph that traverses every vertex exactly once except the starting vertex, is called a Hamilton circuit. A path which contains every vertex of a graph exactly once is called a Hamilton path. A graph which contains a Hamilton circuit is called a Hamilton graph. It

132

CHAPTER 7. GRAPHS

is noted that every Hamilton graph has a Hamilton path and corresponding Hamilton path is obtained by removing any one edge from the circuit.

(a)

(b)

(c)

(d)

Figure 7.23: Example 7.5.2. From the figure 7.5.2, it is clear that graphs 7.5.2 (a), (b), (c) are Hamilton graphs but graph 7.5.2 (d) is not a Hamilton graph.

7.6

Planar Graphs and Colorings

Definition 7.6.1. A graph is called planar if it can be drawn in a plane so that no edges cross except at vertices. Such a drawing is called a planar representation of the graph. Example 7.6.2. K4 is a planar graph because it can be drawn in a plane with no crossing. It is illustrated by following figures 7.6.2: Graph K4 with no crossing

Graph K4

Example 7.6.3. The cube Q3 is planar because it can be drawn in a plane with no crossing. It is illustrated by following figures 7.6.3: A planar representation of a graph splits the plane in to regions, including an unbounded region. To explain regions of a planar graph, we take a sharp knife and cut it along the edges, then plane will be divided into pieces. The pieces are called the regions of graph. Indeed, a region of a planar graph is defined to be an area of the plane that is bounded by edges and is not further divided into subareas. For example, K3 (figure ??a) splits the plane in to two regions, one is inside and the other is outside. Consider another

7.6. PLANAR GRAPHS AND COLORINGS

Q3

133

Q3 in plane with no crossing

Figure 7.24: planar graph 7.6 b. Observe that it has only 3 regions. Note that cutting along the edges e and f does not further divide region. A region is said to be finite(bounded) if its area is finite and is said to be unbounded(infinite) if its area is infinite. e

f K3 (a)

(b)

Figure 7.25: Regions of a planar graph Let v, e and r denote the number of vertices, edges and regions in a graph respectively. For K3 , we have v = 3, e = 3 and r = 2. Then, we have v − e + r = 2 or r = e − v + 2. Indeed, we have: Theorem 7.6.4. Euler’s Formula [page 504 [5]]: Let G be a connected planar graph. Then v − e + r = 2. Remark 7.6.5. But the result is not true for disconnected graph. For example, consider G (figure ??) is disjoint union of K3 and K3 . Then v = 6, e = 6 and r = 3 but v − e + r = 3 6= 2. v3

v1

v6

v2 Here v = 6, e = 6, r = 3

v4

v5

but v − e + r = 3 which is not equal to 2

Figure 7.26: Failure of Euler Theorem for disconnected graph

134

CHAPTER 7. GRAPHS

Example 7.6.6. Let G be a connected simple planar graph with 20 vertices so that degree of each vertices are 3. Then, by Handshaking lemma, 2e = 3 × 20 = 60. Thus, e = 30 and so r = e − v + 2 = 30 − 20 + 2 = 12. This shows that planar representation of the graph splits the plane into 12 regions. To prove the following, first we note that when an edge occurs twice on the boundary, it will counted twice on that boundary. It is also noted that an unbounded region contains at least three edges if there are three vertices in the graph. The number of edges on the boundary of a region R is called the degree of region and is denoted by deg(R). Since each edge occurs on the boundary of a region exactly twice (either in two different regions or twice in the same region), therefore we have: X 2e = deg(R) (7.6.1) all region R

Note that K2 7.6 has only one region R whose boundary is ef but count of edges in boundary of R is 4 and so deg(R) = 4. f e

Figure 7.27: Boundary of unbounded region Corollary 7.6.7. If G is a connected planar simple graph with v vertices, e edges and r regions together with v ≥ 3 then e ≤ 3v − 6. Proof: Let G be a connected planar simple graph with v vertices and e edges together with v ≥ 3. Then boundary of each region contains at least three edges. Therefore total P count of edges for all regions will be greater than or equal to 3r, that is; all regions Rdeg(R) ≥ 3r. Using equation 7.6.1, we get X 2e = all regions Rdeg(R) ≥ 3r and so r ≤

2e 3

Using Euler’s theorem for connected planar graph and Eq. 7.6.2, we get: v − e + 2e ≥ v − e + r = 2. This gives v − 3e ≥ 2, i.e; e ≤ 3v − 6. 2 3

7.6. PLANAR GRAPHS AND COLORINGS

135

Example 7.6.8. The graph K5 is non-planar because it is a connected graph with v = 5 ≥ 3 and e = 10 but 3v − 6 = 3 × 5 − 6 = 9 < e. Corollary 7.6.9. Let G be a connected planar simple graph with v vertices and e edges together with v ≥ 3. If it has no circuit of length 3 then e ≤ 2v−4. Proof: Let G be a connected planar simple graph with v vertices and e edges together with v ≥ 3. Since no circuit has length 3, therefore every region has degree at least 4, i.e; deg(R) ≥ 4 for all regions R. Thus, by Eq. e e 7.6.1, we have 2e ≥ 4r, that is; r ≤ and so v − e + ≥ v − e + r = 2 (by 2 2 Euler’s theorem for connected planar graph), i.e; e ≤ 2v − 4. 2 Example 7.6.10. The graph K3,3 is non-planar because it is a connected simple graph with v = 5 ≥ 3, e = 9 and having no circuit of length 3 (indeed, deg(R) ≥ 4 for all regions R) but 2v − 4 = 2 × 6 − 4 = 8 < e. In 1930, Polish mathematician Kazimierz Kuratowski established the following: Definition 7.6.11. Two graphs G1 and G2 are said to be isomorphic to within vertices of degree 2 if they are isomorphic or if they can be transformed into isomorphic graphs by repeated insertion and/or removal of vertices of degree 2. It can be illustrated by following figure 7.6.11:

−→ −→

−→ (c) (b)

(a)

Figure 7.28: Isomorphic to within vertices of degree 2

Theorem 7.6.12 (Kuratowski). A graph is non-planar if and only if it does not contains a subgraph that is isomorphic to within vertices of degree 2 to either K3,3 or K5 .

136

CHAPTER 7. GRAPHS

K5

K3,3

Figure 7.29: Kuratowski graphs The proof of this theorem is given in [4] The non-planar graphs K5 and K3,3 are also known as Kuratowski graphs. Figures of these graphs are given in ?? Example 7.6.13. The graph G is non-planar because it has a subgraph H isomorphic to within vertices of degree 2. It is illustrated by figure ??

b

a

−→

i

c k h f

isomorphic to within vertices of degree 2

d

K5

e subgraph H of G

g G

Figure 7.30: Illustration of Kuratowski theorem Exercise 7.6.14. Prove that Peterson graph is non-planar. Hint: e a

f f

d

j

d

j

f e

b j

a

−→

g

g e

h

i

h e

i Subgraph H d

i

h

Kuratowski GraphK3,3

c

Petersen graph G

Figure 7.31: Illustration of Kuratowski Theorem Definition 7.6.15. A coloring of a simple graph is the assignment of a color to each vertex of a graph so that no two adjacent vertices are assigned the same color. The least (minimum) number of colors needed for a coloring of a graph is called the chromatic number of the graph.

7.6. PLANAR GRAPHS AND COLORINGS

137

green the coloring is

red

red Hence chromatic number is 2. green red blue green

coloring is

chromatic number is 4 yellow

red red green

blue

Figure 7.32: illustration of coloring Example 7.6.16. In 1976, American mathematicians Kenneth Appel and Wolfgang Haken proved that the following: Theorem 7.6.17. (Four colur Theorem) The chromatic number of a planar graph is less than or equal to 4. Note that the chromatic number of a non-planar graph may be greater than 4.

138

CHAPTER 7. GRAPHS

CHAPTER

8

Trees

This chapter is devoted to study particular type of graphs known as trees.

8.1

Trees and its properties

Definition 8.1.1. A connected graph is called a tree if it has no cycles(circuit). We denote it by T . A collection of disjoint trees is called a forest. A vertex of degree 1 in a tree is called a leaf or a terminal node. A vertex of degree greater than 1 is called a branch node or an internal node. Consider the following figure: v6 v7

v5

v4

v3 (b) (a)

(e) v0

v1 (c)

(d)

Figure 8.1: 139

140

CHAPTER 8. TREES

Figures 8.1 (a), 8.1(b) and 8.1(c) are trees because these are connected graphs without circuits. Figures 8.1(d) and 8.1(e) are not trees because they have circuit respectively. Observe that v0 , v1 , v5 , v6 and v7 are leaves and v3 , v4 are internal vertices (node) or branch nodes of tree 8.1(c). Proposition 8.1.2. A graph without self loops is a tree if and only if there is a unique path between every two vertices. Proof: Let G be a graph without self loops. If G is tree then it is connected and so there will be a path between every two vertices. If P and Q be two paths joining any two vertices v and w of G then P ∪ Q will be a circuit and so G will not be tree, which is a contradiction. Thus, there is a unique path between every two vertices in a tree. Conversely suppose that there is a unique path between every two vertices of the graph G. Then G will be connected. We have to prove that G has no circuits. Suppose not, then there exists a circuit with two or more vertices (Note that G has no loops). Let a, b be any two vertices of the circuit then we have two distinct paths joining a and b, which is a contradiction. Thus our assumption is wrong. Hence G is a connected graph without circuit, i.e; G is a tree. 2 Proposition 8.1.3. A tree with n vertices has n − 1 edges. Proof: Let T be a tree with n vertices. We prove it by induction on the n. Clearly the result is true for n = 1 and n = 2. Assume that the result is true for all tree having n − 1 vertices. Let ek be any edge joining end vertices vi and vj . If any one of them is a leave then T − ek is a tree with n − 1 vertices (see, figure 8.2) and so by induction, it has (n − 1) − 1 = n − 2 edges. Thus, T has n − 2 + 1 = n − 1 edges. Next, suppose that both end vertices are branch node. By uniqueness of path, T − ek will be disconnected and have two connected components, say T1 and T2 (figure 8.2). Clearly these are trees. Let n1 , n2 be the number of vertices in T1 and T2 . Then n1 , n2 < n and n1 + n2 = n and so by induction hypothesis, T1 and T2 have n1 − 1 and n2 − 1 edges. Thus, total number of edges in T1 ∪ T2 will be (n1 − 1) + (n2 − 1) = (n1 + n2 ) − 2 = n − 2 and so T has n − 1 edges. 2 Proposition 8.1.4. A tree with two or more vertices has at least two leaves.

8.1. TREES AND ITS PROPERTIES v4

v4

e4 e5

v5

v4 e4

v3 e3

v5 v3

v3

v2

v2

T2

e3

v2 e2

e2 v1

v1 e1

v1 T1

e1 v0

v0 T

141

v0 T n e2 = T1 [ T2

T n e5

Figure 8.2: Edge deletion from tree Proof: Let T be a tree with two or more vertices. If degree of every vertices is greater than 1, then it will contain a circuit. Since T is without circuit therefore there exists a leaf v0 (vertex of degree 1). Removing v0 from T , let it be T1 . Since v0 is a leaf therefore T1 will be tree. By above arguement, T1 will contain a leaf and so T will contain at least two leaves. 2 Proposition 8.1.5. A connected graph with n vertices and n − 1 edges is a tree. Proof: Let G be a connected graph with n vertices and n − 1 edges. Suppose that G is not a tree then it will have at least one circuit. Let C1 , C2 . . ., Ck be k ≥ 1 circuits in G. Since removing an edge from circuit does not disconnect a graph and removal of an edge from a circuit does not remove its end vertices. We remove one - one edge from each circuit Ck . Then the resulting graph will be connected graph and circuit free, i.e; a tree with n vertices and (n − 1) − k < n − 1 edges, which is a contradiction. Thus, G is a tree. 2 Proposition 8.1.6. A graph with n vertices and n − 1 edges is a tree if it has no circuit . Proof: Let G be a graph with n vertices and n − 1 edges. Suppose that it has no circuit. Let Ci be connected components with ni vertices for all 1 ≤ i ≤ k. Then k X i=1

ni = n

(8.1.1)

142

CHAPTER 8. TREES

Clearly these are circuit free also and hence each will be tree. Thus Ci has ni − 1 edges for all i. Thus, by eq. 8.1.1 we have: n−1=

k X

(ni − 1) = n − k

i=1

which gives k = 1, i.e; G has only one connected components and so G is connected. Since G has no circuit therefore G is a tree. 2 Definition 8.1.7. A subgraph H of a connected graph G is called a spanning tree if H is a tree containing all the vertices of G. From the figure 8.3, it is clear that T is a tree which is a subgraph of G containing all the vertices. Therefore T is a spanning tree. Note that spanning tree of a connected graph may not be unique. Since tree is a connected graph therefore notion of spanning tree is defined only for a connected graph.

spanning tree T K5

Figure 8.3: spanning tree of a graph

Proposition 8.1.8. Every connected graph has at least one spanning tree. Proof: Let G be a connected graph. If it has no circuit, then it will itself be a spanning tree. If if contains a circuit, then remove an edge from the circuit. The resulting graph is connected without circuit and contains all the vertices. Hence it will be a spanning tree. If it contains more than one circuit, repeat the removal process until we get a connected graph without circuit and contains all the vertices of G. The resulting graph is a spanning tree. 2

8.2. ROOTED TREES

8.2

143

Rooted Trees

Many of the applications of graph theory, particularly in computing, use a certain kind of tree, called a rooted tree. This is simply a tree where a particular vertex has been distinguished or singled out from the rest. Some particular types of trees are given in the figures 8.4 and 8.5: Pabbar

Subash

Neha Naveen

Akhilesh

Swati Kishan

Umesh

Durgesh

Priya Shreya Bhuvanesh

Naresh

Brijesh

Avaneesh

Reena

Varsha

Figure 8.4: My Father’s Family Tree

Main Directory

Priya directory

A’s file Previous year

B’ file

Shreya directory

C’s file

Bhuvanesh Directory

D’s file

F’s file

G’s file

Current year

Figure 8.5: Directory tree

Definition 8.2.1. A digraph (directed graph) is called a directed tree if it is a tree when the directions of edges are ignored. A directed tree is called a rooted tree if there is exactly one vertex whose incoming degree is 0 and incoming degrees of all other vertices are 1. Figures 8.4 and 8.5 are examples of rooted tree. The vertex with incoming degree 0 in a rooted tree is called a root and a vertex whose outgoing degree 0 is called a leaf or terminal node. A vertex whose outgoing degree is non-zero is called a branch node or an internal node or parent node. If v0 is the root (distinguished vertex) of a rooted tree T , then the rooted tree is frequently denoted by (T, v0 ) and we

144

CHAPTER 8. TREES

read ”T is a rooted tree with root v0 ”. It is also noted that every tree can be treated as a rooted tree with any vertex as a root. Definition 8.2.2. Let a be a branch node in a rooted tree (T, v0 ). A vertex b of T is called a child of a if there is an edge from a to b. In this case, a is called parent of b. Two vertices are called siblings if they are child of same vertex (parent). A vertex c is said to be descendant of a if there is a directed path from a to c. In this case a is said to be an ancester of c. Pabbar is the root; Priya, Shreya, Bhuvanesh are leaves and Akhilesh, Umesh are branch nodes of the rooted tree given in figure 8.4. Definition 8.2.3. Let (T, v0 ) be a rooted tree. The level of a vertex a of T is defined as the length of the (unique) path in T from v0 to a. The height of T is the maximum of the levels of its vertices. Example 8.2.4. Consider the rooted tree: v0 is the root of level 0. v0 is v0 level 0

b

a

level 1

c

d

level 2

Figure 8.6: Rooted tree with levels parent of a, b and so a, b are siblings. Vertex c is not a child of v0 but descendant of v0 . Note that a, b are of level 1 because there is an edge from v0 to a and an edge from v0 to b. Vertices c, d are of level 2 because paths from v0 to c and v0 to d are of length 2. Since maximum level is 2, therefore height of rooted tree is 2. Definition 8.2.5. An m-ary tree (or m-tree) is a rooted tree in which every branch node (internal node or parent vertex) has at most m children and some branch node has exactly m children. It is called binary tree when m = 2 and is called ternary tree when m = 3. If every branch node of an m − ary tree has exactly m children, we say the tree is full or regular or complete m-tree. Thus, a binary tree is said to be complete binary tree if every branch node has exactly two children. It is noted that the level r of a binary tree (m − ary tree) has at most 2r (mr ) nodes. A rooted tree of height h is called complete at height h if all the leaf vertices are at level h.

8.2. ROOTED TREES

145

The rooted tree given in figure 8.6 is a complete binary tree because every branch node has exactly two children. But it is not complete at height 2 because it has a leaf a at level 1. It is also illustrated by following figures 8.7:

(c) complete binary tree of height 3

(b) full binary tree (a) binary tree

Figure 8.7: Illustration Exercise 8.2.6. Prove the following: 1. A full m − ary tree with i internal vertices has mi + 1 vertices and (m − 1)i + 1 leaves. 2. A full m−ary tree with n vertices has leaves.

n−1 m

3. A full m−ary tree with l leaves contains vertices.

internal vertices and

(m−1)n+1 m

(l−1) m−1

internal

ml−1 m−1

vertices and

4. An m − ary tree of height h contains at most mh leaves. Solution: Proof uses mathematical induction on height h of tree T . The result is true for h = 1 because root will have m leaves. Suppose that the result is true for all m−ary trees with height less than or equal to h−1. Leaves of T are leaves of each subtrees. Since there are at most m subtrees and each has height less than or equal to h − 1. Therefore, by induction hypothesis, each subtree has at most mh−1 leaves and so the tree has m.mh−1 = mh leaves. Definition 8.2.7. Let a be a branch node in the rooted tree (T, v0 ). Then a subgraph (V, E) of T in which V contains a and all of its descendants and E contains all the edges in directed path emanating from a, is called a subtree with root a denoted by T (a).

146

CHAPTER 8. TREES

Definition 8.2.8. Let (T, v0 ) be an n − ary tree. Then each branch node has at most n children and so children of each vertex can be labeled with distinct numbers from the set {1, 2, . . . , n}. A rooted tree in which children of each branch node are labeled with integers from the set {1, 2, . . . , n}, is called a positional tree (or an ordered tree). A binary tree is called a positional binary tree (ordered binary tree) if children of each branch node are labeled with L for left and R for right instead of 1 and 2. It is illustrated by figure 8.8.

1

L

2 2

3

1

3

L

R R

L 1

2

3

R L

R

Positional binary tree

Positional 3-ary tree

Figure 8.8: Rooted tree with levels

8.3

Tree Traversal or Tree Searching

Let (T, v) be a positional binary tree with root v of height greater than zero. Deleting v and its two incident edges produces two disjoint binary trees whose roots are the two level 1 vertices of T . These are called the left subtree T (vL ) and right subtree T (vR ) of the root v. The roots vL and vR of these subtrees are called the left child and right child of v and the edges which were deleted are called the left branch and right branch of v respectively. For each of these subtrees, if the subtree has height 1 at least, its left and right subtrees can be defined, and so on throughout the tree. If T is not a complete positional binary tree, a left or right subtree may be empty (may not exist). In the following figure 8.9: T (v1 ) is a left subtree with root v1 and T (v2 ) is a right subtree with root v2 of rooted tree (T, v0 ). v1 has no left subtree because left child v3 is a leaf but has a right subtree T (v4 ).

8.3. TREE TRAVERSAL OR TREE SEARCHING

147

Root v0 v1 v3

v2 v4

v4

v5

v7

v6

T (v4 ) v7 Left Subtree T (v1 ) of v0

v8

v6 v8

v9

T (v6 )

v9

Right subtree T (v2 ) of v0

Figure 8.9: Definition 8.3.1. The process of visiting each vertex of a tree in some specified order is called Tree traversal or searching the tree (walking the tree or tree search). There are three methods of searching a positional binary tree known as Preorder search, Inorder search and Postorder search.

8.3.1

Preorder Algorithm

Let (T, v) be a positional binary tree. The Preorder algorithm is described as below: Step1. Visit the root v. Step2. If vL exists, then apply the algorithm to (T (vL ), vL ). Step3. If vR exists, then apply the algorithm to (T (vR ), vR ). It is illustrated by the following example: Example 8.3.2. Consider the preorder search of the tree given by figure 8.10. First we visit the root A of positional binary tree and record A(or print the label A). Since A has a left subtree (T (B), B). Thus, apply the algorithm for subtree (T (B), B). Now we visit the root B and record B. The subtree T (B) has a left subtree (T (C), C) and right subtree (T (E), E). Thus, apply preorder algorithm to left subtree (T (C), C). Visit the root C and record C. Since T (C) has no left subtree but has a right subtree (T (D), D), therefore visit D and record it. Since searching of left subtree T (C) of T (B) have completed, therefore apply the preorder algorithm to right subtree (T (E), E) of T (B). Visit E and record it. T (E) has a left subtree (T (F ), F ), so record F .

148

CHAPTER 8. TREES A

H

B

C

I

E

J

8 D 3

2

F5

6G

G

9

4

10

K

7

1

PREORDER ALGORITHM

Figure 8.10: T (F ) has no subtree. Searching of left subtree T (F ) of T (E) has completed, so apply preorder algorithm to right subtree (T (G), G). Visit G and record it. Since searching of left subtree T (B) has completed and (T (A), A) has a right subtree (T (H), H). Apply the preorder algorithm to right subtree (T (H), H). Visit and record H. Process its left subtree (T (I), I) and visit I. (T (I), I) has no subtrees. Since left subtree of T (H) is processed therefore apply preorder algorithm to its right subtree (T (I), I). Visit I and record it. T (I) has no left subtree but has a right subtree (T (J), J). By preorder algorithm to (T (J), J), visit J and record it. Now apply preorder algorithm to its subtree (T (K), K). Visit it’s root K and record it. Since all the vertices has been visited therefore searching process of tree has completed by preorder algorithm. The corresponding search order is ABCDEF GHIJK. Example 8.3.3. The preorder searching of the following tree (figure 8.11):

6 2 a b

4

1 5

Figure 8.11: is 62b1a45c.

c

8.3. TREE TRAVERSAL OR TREE SEARCHING

8.3.2

149

Inorder Algorithm

Let (T, v) be a positional binary tree. The Inorder algorithm is described as below: Step1. If vL exists, then apply the inorder algorithm to (T (vL ), vL ) (Search left subtree in inorder if it exists). Step2. Visit the root v. Step3. If vR exists, then apply the inorder algorithm to (T (vR ), vR ) (Search right subtree in inorder if it exists). It is illustrated by following example: Example 8.3.4. Consider the positional binary tree given in figure 8.12: A 7

B

C

3

9

2

5

I

E

H

10

J

8 D 1

F4

6G

G

11

K

INORDER ALGORITHM

Figure 8.12: Consider the tree (T, A). Since it has a left subtree (T (B), B). Thus first we search T (B) and then visit A. But T (B) has a left subtree (T (C), C). T (C) has no left subtree so visit C and record it. T (C) has a right subtree (T (D), D) which has no left subtree so visit its root D and record it. Searching of left subtree T (C) of (T (B), B) has completed so visit its root B and record it. Tree T (B) has a right subtree (T (E), E). Thus, we proceed the searching of tree T (E). T (E) has a left subtree T (F ) which has no subtree therefore visit F and record it. After visiting F visit the root E and record it. Since T (E) has right subtree (T (G), G). T (G) has no subtrees hence visit G and record it. Thus, searching of left tree T (B) is CDBF EG. Since left subtree T (B)

150

CHAPTER 8. TREES

has searched and so visit its root A and then start searching it’s right subtree (T (H), H) by inorder algorithm. Proceed it as above, the inorder search of T (H) is IHJK. Thus, inorder search of given tree is CDBF EGAIHJK. Example 8.3.5. The inorder searching of the tree given in figure 8.11 is b216a54c.

8.3.3

Postorder Algorithm

Let (T, v) be a positional binary tree. The Postorder algorithm is described as below: Step1. If vL exists, then apply the algorithm to (T (vL ), vL ) (Search left subtree in postorder if it exists). Step2. If vR exists, then apply the algorithm to (T (vR ), vR ) (Search right subtree in postorder if it exists). Step3. Visit the root v. Example 8.3.6. Consider the positional binary tree given in figure 8.13:

A 11

B

C

6

10

2

5

I

E

H

9

J

7 D 1

F3

4G

G

8

K

POSTORDER ALGORITHM

Figure 8.13: From the figure it is clear that Postorder search is DCF GEBIKJHA.

8.3. TREE TRAVERSAL OR TREE SEARCHING

151

Example 8.3.7. The postorder searching of the tree given in figure 8.11 is b125c4a6. It is noted there are so many binary trees corresponding to given any one kind tree search. It is unique if two types of tree search is known in which one of them is inorder and other is either preorder or post order. Binary tree whose inorder and preorder search is known To draw a unique binary tree corresponding to given preorder and inorder traversal, we use following steps: Step 1: Root v is obtained by choosing the first vertex in preorder. Step 2: Find all the vertices in left subtree of binary tree by using inorder traversal (these vertices lies in left to the root v in inorder). Then left child vL of root v is obtained by selecting the first vertex in preorder search (traversal) of left subtree. Draw the left child. Step 3: Find all the vertices in right subtree of binary tree by using inorder traversal (these vertices lies in right to the root v in inorder). Then right child vR of root v is obtained by selecting the first vertex in preorder search (traversal) of right subtree. Draw the right child. Repeat these steps until every vertex is not visited in preorder. Example 8.3.8. Given the preorder and inorder searching of a binary tree, draw a unique tree: Preorder Inorder

6 2 b 1 b 2 3 1

3 a 4 5 c 6 a 5 4 c

Solution: It is illustrated point wise as: 1. First vertex in preorder is 6. Thus, 6 is a root of the given tree. 2. From Inorder, all the vertices are left subtree are b, 2, 3, 1. The left child of 6 is that vertex of left subtree which appears first in preorder. Hence 2 is left child of 6. We draw it.

152

CHAPTER 8. TREES

3. From Inorder, all the vertices in right subtree are a, 5, 4, c (vertices right to the root in inorder search). The right child of 6 is that vertex of its right subtree which appears first in preorder. Hence a is the right child of 6. We draw it. 4. Consider the left subtree T (2). From inorder search, b is the vertex of its left subtree and 3, 1 is vertex of its right subtree. Since left subtree of tree T (2) contains only one vertex, therefore it will be left child of 2. We draw it. The right child of 2 is that vertex of its right subtree which appears first in preorder search. Therefore 1 is the right child of 2. We draw it. Consider the right subtree T (1) of tree T (2). Since the vertices of left subtree of T (1) is 3 (by inorder search). Thus, 3 is the left child of 1. We draw it. Since all the vertices of left subtree has been traversed, we move to the right subtree T (a) of binary tree (T, 6). From inorder search it is clear that its left subtree has no vertices, i.e; left subtree of T (a) is empty. From inorder search it is clear that vertices of its right subtree are 5, 4, c. By preorder, 4 is the right child of a. We draw it. Consider the subtree T (4) with root 4. From inorder and preorder it is clear that 5 is the left child and c is the right child of 4. We draw them. Since all vertices of right subtree of (T, 6) has traversed. The figure of corresponding binary tree is figure 8.14:

6

Root vertices of right subtree are a, 5, 4, c

vertices of left subtree are b, 2, 3, 1 2 is left child 2

a is the right child of 6

vertices of right subtree of T (a) are 5, 4, c

a

vertices of right subtree of T (2) are 3, 1 b vertices of left subtree of T (2) is b

3

right 1 T (2)

child

of 4

vertex of left subtree of T (4) is 5 vertex of left subtree of T (1) is 3

5

4 is right child of 4 by preorder vertex of right subtree is c c

Figure 8.14: Binary tree corresponding to given preorder and inorder

8.3. TREE TRAVERSAL OR TREE SEARCHING

153

Binary tree whose inorder and postorder search is known To draw a unique binary tree corresponding to given postorder and inorder traversal, we use following steps: Step 1: Root v is obtained by choosing the last vertex in postorder. Step 2: Find all the vertices in right subtree of binary tree by using inorder traversal (these vertices lies in right to the root v in inorder). Then right child vR of root v is obtained by selecting the last vertex in postorder search (traversal) of right subtree. Draw the right child. Step 3: Find all the vertices in left subtree of binary tree by using inorder traversal (these vertices lies in left to the root v in inorder). Then left child vL of root v is obtained by selecting the last vertex in postorder search (traversal) of left subtree. Draw the left child. Repeat these steps until every vertex is not visited in postorder. Exercise 8.3.9. Given the postorder and inorder searching of a binary tree, draw a unique tree: Postorder Inorder

p p

q n r m n q m r

t u l t

s s

l u

Solution: The last vertex in postorder is l. Thus, l is the root. From inorder, all the vertices of left subtree are p, n, q, m, r and all the vertices of right subtree (right to l) are t, s, u. From postorder, last vertex m will be left child of l and last vertex s will be right child of l. We draw them. Consider left subtree T (m). From inorder, p, n, q are vertices of left subtree of T (m) and r is the vertex of right subtree of T (m). From postorder, the last vertex n is left child of T (m) and the right child of m is r. We draw them. Consider the subtree T (n). From inorder, vertex of its left subtree is p and vertex of its right subtree is q. We draw them. Since all vertices of left subtree of tree (T, 6) are visited. Hence, we consider the subtree T (s). From inorder, t is the left child of s and u is the right child of s. Now we have visited all the vertices of binary tree, therefore corresponding binary tree is given in figure 8.15:

154

CHAPTER 8. TREES Root l m

s

n

t

r

p

u

q

Figure 8.15: Tree corresponding to postorder and inorder . Exercise 8.3.10. Construct a binary tree corresponding to following preorder and inorder: Inorder Preorder

5 1 3 11 6 6 1 5 11 3

8 2 4 7 4 8 7 2

Exercise 8.3.11. Construct a binary tree corresponding to following postorder and inorder: Inorder Preorder

8.4

d g a b

b e d g

i e

h j h i

a j

c f c f

Representation of algebraic expression as binary tree

Every algebraic expression can be represented as a binary tree. The tree corresponding to expressions x + y, x − y, (x ∗ y), x/y and x5 is given by figure 8.16: ∗ /

+ − y x

y

x

x x∗y

5 y

x x5

y

x

x+y

x/y x−y

Figure 8.16: Consider the algebraic expression (a + b) ∗ [(c − d)/(x + 5 ∗ y)]. Then corresponding tree is

8.5. BINARY SEARCH TREE OR SORT TREE

155

∗ /

+

a

b



c

+

d



x

5

y

Exercise 8.4.1. Draw binary trees for expressions (3a + b) ∗ (2x − 6y)3 and [(a + b)/c] ∗ [a − 2 ∗ c].

8.5

Binary Search Tree or Sort Tree

A common and important operation in data processing is the sorting of data into an appropriate order. Let (A, ≤) be a totally ordered finite set. Suppose that the elements of A are given as an unsorted list a1 , a2 , . . . , aN . Then, we wish to obtain a sorted list s1 , s2 , . . . , sN of the same elements, i.e. a list such that s1 ≤ s2 ≤ . . . , sN ( Note that if A is a partially but not totally-ordered set, it would not be possible to produce such a list). There are so many techniques like selection sort, bubble sort, insertion sort, quick sort etc for obtaining the desired sorted list. Here, we shall discuss a particular type of sorting procedure which uses a special kind of binary tree known as tree sort or binary search tree in the sense of following: Definition 8.5.1. A binary search tree (sort tree) is a binary tree T whose vertex set V is totally ordered (with order relation denoted by ≤ ), and for each v ∈ V , wL ≤ v for every vertex wL in the left subtree of v, and v ≤ wR for every vertex wR in the right subtree of v. The tree given in figure 8.17 is a binary search tree. The tree sort procedure contains two steps: (1) Growing the binary search tree, (2) Sorted list from binary search tree.

8.5.1

Growing the sort tree

Suppose that a1 , a2 , . . . , aN is an unsorted list (with order relation ≤). Working through the list, the binary search tree is grown one branch at a time.

156

CHAPTER 8. TREES 38 14

8

56

23

18

43

58

25

Figure 8.17: Binary Search Tree Each time an element is processed, it is added to the tree as a leaf vertex, although it may subsequently become a branch node (parent). To begin, the first element a1 is defined to be the root vertex v0 . We now have a binary search tree T1 whose root has empty left and right subtrees. To add a branch with element x at its end, we proceed it as: Compare x with the root v0 ; if x ≤ v0 proceed to the root of the left subtree and if v0 ≤ x proceed to the root of the right subtree. Then we compare x with the root of the appropriate subtree and repeat. Eventually one of the following two possibilities occurs when comparing x with the current root v: either x ≤ v and v has empty left subtree or v ≤ x and v has empty right subtree. In the first case we add x as a left child of v and in the second we add x as a right child of v. Example 8.5.2. Consider the list 7, 2, 1, 4, 5, 9. Take 7 as the root. Since 2 ≤ 7, hence 2 is the left child. We draw it. Consider 1. Since 1 ≤ 2 hence 1 is the left child of 2. We draw it. Take next element 4 of the list. Since 4 ≤ 7, hence 4 will be the vertex of left subtree of 7. But 2 ≤ 4, therefore 4 will be the right child of 2. Similarly, 5 ≤ 7 but 4 ≤ 5, therefore it will be right child of 4. Next, 7 ≤ 9, therefore it will be right child of 7. Thus, corresponding binary search tree is: 7 2 1

9 4 5

Figure 8.18: Binary Tree corresponding to a given list Example 8.5.3. The binary search tree corresponding to unsorted list Ram,

8.5. BINARY SEARCH TREE OR SORT TREE

157

Ganesh, Shiv, Kashi, Tryambakeshwar, Nashik, Ganga, Brahma, Mathura, Vishnu and Gayatri under alphabetical ordering is figure 8.19. RAM GANESH BRAHMA

SHIV KASHI

GANGA

TRYAMBAKESHWAR NASHIK

GAYATRI

VISHNU

MATHURA

Figure 8.19: Binary Search Tree Exercise 8.5.4. Grow (construct) a binary search tree from the list ‘ Hawk, Raven, Wren, Falcon, Dove, Eagle, Pelican, Robin, Osprey, Egret, Rook’ under alphabetical ordering. Solution: The binary search tree corresponding to unsorted list ‘ Hawk, Raven, Wren, Falcon, Dove, Eagle, Pelican, Robin, Osprey, Egret, Rook’ is figure 8.20 HAWK FALCON DOVE

RAVEN PELICAN

EAGLE

OSPREY

EGRET

WREN ROBIN

ROOK

Figure 8.20: Binary search tree

8.5.2

Listing The Elements of a Sort Tree

Let T be the binary search tree grown from the unsorted list a1 , a2 , . . . , aN according to growing tree procedure (Subsection 8.5.1). Then, to list the vertices of the binary search tree in the appropriate order, we apply the following three steps: (1). Process left subtree. (2). List the root.

158

CHAPTER 8. TREES

(3). Process right subtree. To process a subtree we repeat each of the three steps with the proviso that an empty tree needs no processing! Example 8.5.5. The sorted list from the binary search tree T given in figure 8.18 is 1, 2, 4, 5, 7, 9. Similarly, the sorted list from the binary search tree T given in figure 8.19 is BRAHMA, GANESH, GANGA, GAYATRI, KASHI, MATHURA, NASHIK, RAM, SHIV, TRYAMBAKESHWAR, VISHNU. Exercise 8.5.6. Find the sorted list from the given binary search tree (figure 8.21) RAM GANESH BRAHMA GANGA GAYATRI

SHIV KASHI

TRAYAMBAKESHWAR NASHIK

VISHNU

MATHURA

KRISHNA

Figure 8.21: Exercise 8.5.7. Construct the binary search tree and find the sorted list from the unsorted list maths, chemistry, statistics, computer, zoology, botany, physics, home science, geography Exercise 8.5.8. Construct binary search tree and find the sorted lists from each of the following unsorted lists: 1. 7, 3, 15, 4, 12, 14, 6, 8, 2, 5, 13, 19 ordered by ≤. 2. when, shall, we, three, meet, again, in, thunder, lightning, or, in, rain ordered alphabetically, 3. 8, 64, 1, 4, 256, 512, 2, 32, 128, 16 ordered by divisibility. 4. 17, 31, 5, 23, 2, 7, 19, 29, 11, 3, 13 with order relation ≤ . 5. bca, cbc, acb, bcb, bac, cac, abc, aca, bab, aba, cba, cab with alphabetical orderings of strings.

CHAPTER

9

Finite State Machines and Finite Automata

This chapter is devoted to study finite state machines (FSM). We study it in to two parts, one is FSM with output (Mealey and Moore machine) and the other is FSM without output (Finite Automata). We discuss machine minimization also. Definition 9.0.1. A finite state machine (FSM) M is a 6-tuple (S, I, O; f, g; s0 ) where 1. S is a non-empty finite set of states, 2. I is a non-empty finite set of input symbols, 3. V is a non-empty finite set of output symbols, 4. f is a function f : S × I → S called next state function or transition function , 5. g is a function g : S × I → O called output function, 6. s0 ∈ S is an initial state . Such machines are also called as deterministic finite state machine because next state function determines a unique state corresponding to each pair (s, a) ∈ S × I. A FSM M = (S, I, O; f, g; s0 ) can be represented in two 159

160CHAPTER 9. FINITE STATE MACHINES AND FINITE AUTOMATA different ways, one of them is a table and other is a directed labeled graph. These are described as below: Definition 9.0.2. A table which represents the values of transition function and output function for each pair of states and inputs (i.e; for each element (s, a) in S × I) of M = (S, I, O; f, g; s0 ) is called a state table or transition table of the FSM. The initial state is represented by incoming arrow in the table. Definition 9.0.3. A directed graph in which each state of F SM is represented by a circle as node and each directed arrow from state si to sj = f (si , a) corresponding to input a ∈ I is labeled by pair a, o , where o = g(si , a); is called a state diagram or transition diagram of the F SM . The initial state s0 is represented by a circle with incoming arrow. Example 9.0.4. Consider the finite state machine M = (S, I, O; f, g; s0 ), where S = {s0 , s1 }, I = {a, b}, O = {0, 1}, f (s0 , a) = f (s0 , b) = s0 , f (s1 , a) = s0 , f (s1 , b) = s1 and g(s0 , a) = g(s1 , b) = 0, g(s0 , b) = 1 = g(s1 , a). Then the state table and the state diagram are given by figure 9.1 b; 0 f

g

b; 1 a; 0

S

a

b

a

b s0

s0

s0

s0

0

1

s1

s0

s1

1

0

s1 a; 1

Figure 9.1: State table and state diagram

Definition 9.0.5. A finite state machine M = (S, I, O; f, g; s0 ) is called a Mealey Machine if the value of g depends on state and input both, i.e; g is not constant on the set {s} × I for some s ∈ S. This machine was first studied by G. H. Mealey in 1955. Thus, machine given by figure 9.1 is an example of Mealey . A finite state machine M is called a Moore Machine

161 if for each s ∈ S the output function g is constant on the set {s} × I, i.e; the value of g depends only by its states ( but not on input). This machine was introduced by E. F. Moore in 1956. Example 9.0.6. Consider the Moore machine M = (S, I, O; f, g; s0 ), where S = {s0 , s1 }, I = {a, b}, O = {0, 1}, f (s0 , a) = f (s0 , b) = s0 , f (s1 , a) = s0 , f (s1 , b) = s1 and g(s0 , a) = g(s0 , b) = 0, g(s1 , b) = 1 = g(s1 , a). Then the state table and the state diagram are given by figure 9.2 b; 1 f

g

b; 0 a; 0

S I

a

b

I s0

s0

s0

s0

s1

0

a; 1

a; b

OR s1

s0

s1

s0 0

1

s1 1

b

a

Figure 9.2: State table and State Diagram of Moore machine

Exercise 9.0.7. Construct the state diagram of the finite state machine given by the following state table f S → s0 s1 s2 s3

a s1 s3 s1 s2

g b s0 s0 s2 s1

a 1 1 0 0

b 0 0 1 0

Exercise 9.0.8. Construct the state table of the Mealey machine given by the following state diagram

162CHAPTER 9. FINITE STATE MACHINES AND FINITE AUTOMATA 0; 1 s1

s2

1; 1 0; 1 0; 0

1; 0

1; 0

0; 0

s0 s3

s4

1; 0

0; 0 1; 0

Let M be a FSM and x1 x2 . . . xn be a finite string of inputs x1 , x2 , . . ., xn in I. Then, we can determine a finite sequence < sk > of states given by x1 ,y1

x2 ,y2

x3 ,y3

s0 −→ s1 −→ s3 −→ . . .

xn−1 ,yn−1

−→

xn ,yn

sn−1 −→ sn

where states sk = f (sk−1 , xk ) and output yk = g(sk−1 , xk ) for k = 1, 2, .., n. Thus, each input string determines a finite string y1 y2 . . . yn of outputs. For example, the output corresponding to input abaaab for Exercise 9.0.6 is 000000 and for Exercise 9.0.7 is 101101 respectively. It can be observed by the following diagrams a,0

b,0

a,0

a,0

a,0

b,0

a,1

b,0

a,1

a,1

a,0

b,1

s0 −→ s0 −→ s0 −→ s0 −→ s0 −→ s0 −→ s0 and s0 −→ s1 −→ s0 −→ s1 −→ s3 −→ s2 −→ s2 respectively. Exercise 9.0.9. Construct the state table of following F SM : 0; 1 s1

s2

1; 1 0; 1 0; 0

1; 0

1; 0

0; 0

s0 s3

s4

1; 0

and also obtain the output string corresponding to input string 101011. (Hint: 001000.) 0; 0

1; 0

Example 9.0.10. We now construct a finite state machine (FSM) for addition of two integers using their binary expansions. Let (xn xn−1 . . . x1 x0 )2 and (yn yn−1 . . . y1 y0 )2 be binary expansions of two integers x and y, where each xi , yi ∈ {0, 1}. Note that the binary expansion (xn xn−1 . . . x1 x0 )2 represent the integer xn 2n + xn−1 2n−1 + . . . + x1 21 + x0 20 . For example, (101)2 represents the integer 1.22 + 0.21 + 1.20 = 5. Let z0 = x0 + y0 with carry c0 and zi = xi + yi + ci−1 with carry ci for each i ≥ 1. Then zi , ci ∈ {0, 1}. The addition process is illustrated as:

163 cn + cn

cn−1 xn yn zn

cn−2 xn−1 yn−1 zn−1

... ... ... ...

c1 x2 y2 z2

c0 x1 y1 z1

x0 y0 z0

Since each string xi yi of xi and yi determines an output zi with carry ci , therefore all possible inputs will be 00, 01, 10 and 11 together with corresponding outputs 0, 1, 1, 0 and carry 0, 0, 0 and 1 respectively. Let carry 0 be stored at state s0 (the initial state) and carry 1 is stored at state s1 . Then, the finite state machine which produces the sum of binary expressions of two given integers is given by figure 9.3

10; 0

01; 0

01; 0

10; 0

00; 0

11; 0

11; 1

s1

s0 00; 1

Figure 9.3: Finite state machine for addition of two binary numbers

If we apply input 00 to the state s0 then it will return to state s0 with output 0 + 0 = 0 because it has carry 0. But if we apply input 00 to state s1 then output will be 0 + 0 + 1 = 1 (because s1 stores carry 1) with carry 0 and so it moves to next state s0 . Similarly, 11 at s0 carries it to next state s1 with output 0 and has carry 1 because 1 + 1 = 2 = (10)2 . Since 5 = (101)2 and 4 = (100)2 , therefore 5 + 4 is 1 + 1

0 1 1 0

0 carry 0 1 0 0 0 1

But (1001)2 = 23 + 20 = 9, hence 5 + 4 = 9. For more details and exercises, we would like to refer some excellent books [3, 5].

164CHAPTER 9. FINITE STATE MACHINES AND FINITE AUTOMATA

9.1

Machine Equivalence and Machine Minimization

Definition 9.1.1. Let M = (S, I, O; f, g; s0 ) be a FSM. Then any two states si and sj of M are said to be 1-equivalent if g(si , a) = g(sj , a) for all a ∈ I, i.e; if both si and sj have same output corresponding to each input symbol a ∈ I. We denote it by si ≡1 sj . Observe that it is an equivalence relation. Similarly for every n ∈ N, two states si and sj of M are said to be n-equivalent if g(si , x) = g(sj , x) for all input strings x1 x2 . . . xn ∈ I n of inputs x1 , x2 , . . ., xn in I. Here g(s, x1 x2 . . . xn ) denotes the output string corresponding to input string x1 x2 . . . xn . It can be obtained inductively by g(si , x1 ) = g(si , x1 ), g(si , x1 x2 ) = g(si , x1 )g (f (si , x1 ), x2 ) , g(si , x1 x2 x3 ) = g(si , x1 )g (f (si , x1 ), x2 ) g (f (f (si , x1 ), x2 ) , x3 ) and so on. Indeed, g(si , x1 x2 . . . xn ) = g(si , x1 )g(f (si , x1 ), x2 x3 . . . xn ). Let f (si , x1 x2 . . . xn ) denotes the state f (f (si , x1 ), x2 x3 . . . xn ) for all n ≥ 2. Then, one may easily observe that g(s, x1 x2 . . . xn ) = g(s, x1 x2 . . . xn−1 )g(f (s, x1 x2 . . . xn−1 ), xn )(9.1.1) g(s, x1 x2 . . . xn ) = g(s, x1 )g(f (s, x1 ), x2 . . . xn−1 xn )

(9.1.2)

If states si , sj in S are n − equivalent then we write si ≡n sj . Two states si and sj of M are said to be equivalent if si ≡n sj for every n ∈ N. Observe that ≡n is an equivalence relation on S for every n ∈ N (verify). Let Pn denotes the partition of S corresponding to equivalence relation ≡n and equivalence class of s ∈ S is denoted by [s]. Proposition 9.1.2. Let M = (S, I, O; f, g; s0 ) be a FSM and n ≥ 2. Then (si ≡n sj ) ⇒ (si ≡n−1 sj ). Proof: Suppose that si ≡n sj and the result si ≡n−1 sj is not true. Then there exists a string x1 x2 . . . xn−1 ∈ I n−1 such that g(si , x1 x2 . . . xn−1 ) 6= g(sj , x1 x2 . . . xn−1 )

(9.1.3)

9.1. MACHINE EQUIVALENCE AND MACHINE MINIMIZATION 165 Let a ∈ I. By Eq. 9.1.1, we have g(si , x1 x2 . . . xn−1 a) = g(si , x1 x2 . . . xn−1 )g(f (si , x1 x2 . . . xn−1 ), a) (9.1.4) and g(sj , x1 x2 . . . xn−1 a) = g(sj , x1 x2 . . . xn−1 )g(f (sj , x1 x2 . . . xn−1 ), a) (9.1.5) By Equations 9.1.3,9.1.4, 9.1.5, we have g(si , x1 x2 . . . xn−1 a) 6= g(sj , x1 x2 . . . xn−1 a) for x1 x2 . . . xn−1 a in I n which is a contradiction because si ≡n sj . Thus, (si ≡n sj ) ⇒ (si ≡n−1 sj ). 2 Proposition 9.1.3. Let M = (S, I, O; f, g; s0 ) be a FSM. Then, si ≡n sj if and only if si ≡n−1 sj and f (si , a) ≡n−1 f (sj , a) for every a ∈ I. Proof: Suppose that si ≡n−1 sj and f (si , a) ≡n−1 f (sj , a) for every a ∈ I. Let x1 x2 . . . xn be any input string of n inputs. Then g(si , x1 x2 . . . xn ) = g(si , x1 )g(f (si , x1 ), x2 . . . xn−1 xn )

(9.1.6)

g(sj , x1 x2 . . . xn ) = g(sj , x1 )g(f (sj , x1 ), x2 . . . xn−1 xn )

(9.1.7)

Since si ≡n−1 sj therefore si ≡1 sj and so g(si , x1 ) = g(sj , x1 ).

(9.1.8)

Similarly f (si , x1 ) ≡n−1 f (sj , x1 ) gives g(f (si , x1 ), x2 . . . xn−1 xn ) = g(f (sj , x1 ), x2 . . . xn−1 xn )

(9.1.9)

because x2 . . . xn−1 xn ∈ I n−1 . Combining Equations 9.1.8 and 9.1.9 and using equations 9.1.6 and 9.1.7, we have g(si , x1 x2 . . . xn ) = g(sj , x1 x2 . . . xn ) Thus, si ≡n sj . Conversely suppose that si ≡n sj . Then si ≡1 sj and so g(si , x1 ) = g(sj , x1 ) for all x1 ∈ I. Let x1 x2 . . . xn−1 xn in I n . Since si ≡n sj therefore g(si , x1 x2 . . . xn ) = g(sj , x1 x2 . . . xn ). Using Eq. 9.1.6, 9.1.7 and g(si , x1 ) = g(sj , x1 ), we have g(f (si , x1 ), x2 . . . xn−1 xn ) = g(f (sj , x1 ), x2 . . . xn−1 xn ) (by equality of two strings). But x2 . . . xn−1 xn in I n−1 is arbitrary, therefore f (si , x1 ) ≡n−1 f (sj , x1 ). This proves the result. 2

166CHAPTER 9. FINITE STATE MACHINES AND FINITE AUTOMATA Remark 9.1.4. si ≡n−1 sj does not imply si ≡n sj . Definition 9.1.5. Two machines M1 and M2 are said to be equivalent if starting from their respective initial states, they will produce the same output string corresponding to same input string.

9.1.1

Minimization Process

Let M = (S, I, O; f, g; s0 ) be a FSM. Start with n = 1. Note that Si and sj will be 1 − equivalent if their corresponding rows of outputs in the transition table are same. Thus, by examining the rows of the transition table, we determine 1 − equivalent states and write P1 . Using Proposition 9.1.3, we obtain Pn for n ≥ 2. If Pn = Pn−1 , then we stop the process (Note that Pn−1 = Pn+k−1 for all k ∈ N (Verify)) otherwise we calculate Pn+1 by using Proposition 9.1.3. Repeat the above process till Pn = Pn−1 . Since S is finite therefore the above process will be completed after finite number of steps, ¯ will be i.e; we have Pn = Pn−1 for some n. Then minimized machine M ¯ ¯ (Pn , I, O, f , g¯, [s0 ]), where f ([s], a) = [f (s, a)] and g¯([s], a) = g(s, a) for all ¯ are a ∈ I. From the above process it is clear that machines M and M ¯ equivalent machines. Since |Pn | ≤ |S|, i.e; machine M has fewer states than M . Therefore this process is known as machine minimization. It can be illustrated by following examples: Example 9.1.6. Let M be a FSM with initial state s0 given by the following transition table: f g S 0 1 0 1 → s0 s3 s2 0 1 s1 s4 s1 1 0 s2 s1 s3 0 0 s3 s4 s2 0 0 s4 s1 s4 1 0 s5 s0 s5 1 0 From the transition table, it is clear that the output rows of s1 , s4 and s5 are same, hence these are 1 − equivalent. Similarly, the output rows of s2 and s3 are same, hence these are 1 − equivalent . Thus, P1 = {{s0 }, {s1 , s4 , s5 }, {s2 , s3 }}.

9.1. MACHINE EQUIVALENCE AND MACHINE MINIMIZATION 167 We now examine the 1 − equivalence classes {s1 , s4 , s5 } and {s2 , s3 } separately to determine the possibility of 2 − equivalence. Note that two states from different 1 − equivalence classes cannot be 2 − equivalent, in view of Proposition 9.1.2. Now consider the class {s1 , s4 , s5 }. Consider states s1 and s4 of 1 − equivalence class {s1 , s4 , s5 }. Since next states f (s1 , 0) = s2 and f (s4 , 0) = s1 are 1 − equivalent, and next states f (s1 , 1) = s1 and f (s4 , 1) = s1 are 1 − equivalent, therefore f (s1 , a) ≡1 f (s4 , a) for all a ∈ {0, 1}. Thus, s1 ≡2 s4 . Next, consider the states s1 and s5 of the class {s1 , s4 , s5 }. Since next states f (s1 , 0) = s2 and f (s5 , 0) = s0 belong to different 1 − equivalence classes, therefore f (s1 , 0) is not 1 − equivalent to f (s5 , 0), i.e; s1 is not 2 − equivalent to s5 . Thus, 1 − equivalence class {s1 , s4 , s5 } is divided into two 2 − equivalence classes {s1 , s4 } and {s5 }. Next, consider the class {s2 , s3 }. Since s2 ≡1 s3 and f (s2 , a) ≡1 f (s3 , a) for each a in I = {0, 1}. Therefore s2 ≡2 s3 . Thus, we have P2 = {{s0 }, {s1 , s4 }, {s2 , s3 }, {s5 }} Similarly, we have P3 = P2 . Thus, the minimization process is complete. The transition table of the equivalent machine is given by

f P2 0 → [s0 ] [s3 ] [s1 ] [s4 ] [s2 ] [s1 ] [s5 ] [s0 ]

1 [s2 ] [s1 ] [s3 ] [s5 ]

0 0 1 0 1

g 1 1 0 0 0

where [s0 ] = {s0 }, [s1 ] = [s4 ] = {s1 , s4 }, [s2 ] = [s3 ]] = {s2 , s3 } and [s5 ] = {s5 }.

Roughly we can say that we replace s4 by s1 , s3 by s2 in the transition table of given machine and delete the redundant row from that table. The state diagram of machine M and M is given by the following figure 9.4

168CHAPTER 9. FINITE STATE MACHINES AND FINITE AUTOMATA 0; 1

1; 0 0; 0

s1

s2

[s0 ]

1; 1

0; 1 1; 0

0; 1 s4

0; 0

0; 0 1; 1 0; 0

[s2 ]

0; 1

1; 0

s0

0; 1

[s1 ]

1; 0

1; 0

s3

1; 0

[s5 ] 1; 0

0; 0

1; 0

Equivalent Machine

s5

Figure 9.4: Example 9.1.7. The machine M M f S 0 →A B B A C G D H E A F H G A H A

1 F F A B G C D C

g 0 0 0 0 0 1 1 1

M f P3 0 1 g → [A] [B] [F ] 0 [C] [G] [A] 0 [E] [A] [G] 0 [F ] [H] [C] 1 [G] [A] [D] 1

is equivalent to

where [A] = [B] = {A, B}, [C] = [D] = {C, D}, [E] = {E}, [F ] = {F } and [G] = [H] = {G, H}. For convenience, the equivalent machine can be given by the transition table f¯ S 0 →A A C G E A F H G A

1 F A G C D

g¯ 0 0 0 1 1

where the set S = {A, C, E, F, G} of states is the set obtained by selecting

9.1. MACHINE EQUIVALENCE AND MACHINE MINIMIZATION 169 one and only one element from the each equivalence classes of P3 . Here it is noted that A = B, C = D and G = H up to the equivalence relation. Exercise 9.1.8. Prove that Moore Machines M = (S, I, O; f, g, s0 ) and M 0 = (S 0 , I, O; f 0 , g 0 , s00 ) are equivalent machines where M and M 0 are given by M S →A B C D E F G H

9.1.2

f 1 B F G H B D E B

2 C D E B F H B C

g I 0 0 0 0 1 0 0 1

M0 f0 S 1 →A B B C C D D E E B 0

and

2 C D E B C

g0 I 0 0 0 0 1

Non-deterministic finite state machine

Definition 9.1.9. A Non-deterministic finite state machine (FSM) M is a 6-tuple (S, I, O; f, g; s0 ) where 1. S is a non-empty finite set of states, 2. I a non-empty finite set of input symbols, 3. O a non-empty finite set of output symbols, 4. f is function f : S × I → P(S) called next state function, 5. g is function g : S × I → O called an output function, 6. s0 ∈ S is an initial state . Here next state function f determines several states for each pair (s, a) ∈ S × I. Such machines are more powerful than deterministic finite state machine in the the sense that there are languages that can be recognized by a non-deterministic FSM but can not be recognized by a deterministic FSM. Example 9.1.10. A non-deterministic finite state machine is given by the following figure 9.5

170CHAPTER 9. FINITE STATE MACHINES AND FINITE AUTOMATA 0 B 0

1 A 0

S

f I

0

0; 1

g 1

1

1 0

0

1 C 1

A B B A; C C A

B; C

0

C

0

B; C

1

Figure 9.5: State diagram and state table of non-deterministic FSM

9.1.3

Non-deterministic to Deterministic FSM

Let M = (S, I, O; f, g; s0 ) be a non-deterministic FSM where O = {0, 1} and g is constant on s × I for all s ∈ S, i.e; g depends only on states not on the input symbol. We construct a corresponding deterministic finite state machine M 0 (equivalent to M ) as follows: Let 1. P(S) be the set of states, 2. I be the set of input symbols(letters), 3. O = {0, 1} be the set of output symbols(letters), 4. a next state (transition) function f 0 : P(S) × I → P(S) given by f 0 ({}, a) = {} and f 0 (X, a) = ∪s∈X f (s, a) for a ∈ I. 5. an output function g 0 : P(S) × I → O given by g 0 (X × I) = 1 if a nonempty subset X ⊆ S contains a state s ∈ X for which g({s} × I) = 1, and is equal to 0 otherwise. Example 9.1.11. The non-deterministic finite state machine and corresponding deterministic finite state machine are given by

9.2. MACHINES WITH NO OUTPUT

States S →A B C

0 B A, C A

f 1 B, C {} B, C

S0 → {A} g B {C} 0 and {A, B} 0 {A, C} 1 {B, C} {A, B, C} {}

171

f0 0 1 {B} {B, C} {A, C} {} {A} {B, C} {A, B, C} {B, C} {A, B} {B, C} {A, C} {B, C} {A, B, C} {B, C} {} {}

g0 I 0 1 1 0

(A has output 0) (B has output 0) (C has output 1)

(both A, B have output 0)

1 ( C has output 0) 0 (C has output 1) 1 (C has output 1) 0 ({} has no states

respectively. Exercise 9.1.12. Draw state diagrams of above two finite state machines.

9.2

Machines with no output

One of the the most important application of FSM is in language recognition. This application plays an important role in the design and construction of compilers for programming language. Here we shall discuss another type of FSM which are specially designed for language recognition. Instead of producing output, these machines have some final states. Such machines are termed as finite state automata or finite automata. Note that the plural of automaton is automata. Like the FSM, finite automata are of two types: 1. Deterministic finite automata (DFA), 2. Non-deterministic finite automata (NFA). As we have discussed that a non-deterministic FSM can be converted in to deterministic FSM. We also observe a DFA equivalent to NFA .

9.2.1

Deterministic finite automata

Definition 9.2.1. A deterministic finite state automata M (DFA) consists the following: 1. a non-empty finite set S of states,

172CHAPTER 9. FINITE STATE MACHINES AND FINITE AUTOMATA 2. a non-empty finite set I of inputs, 3. a function f : S × I → S called a transition function (or next state function), 4. a non-empty subset A of S called accepting or final states, 5. an initial state s0 in S. It is denoted by the 5-tuple (S, I, f, s0 , A). It is noted that f determines a unique state corresponding to each pair of state and input. This is the reason to call this automata as deterministic finite state automata. The state diagrams of DFA is same as that of FSM. The starting state will be equipped by incoming arrow, accepting (final) states will be encircle by double circles and edges will be labeled only by input symbols. State table of DFA is same as that of FSM together with initial state and accepting states. Example 9.2.2. The state diagram of the DFA M = (S, I; f, s0 , A) given by state table

S → s0 s1 s2 s3

0 s0 s0 s0 s2

f 1 s1 s2 s0 s1

A = {s0 , s3 } is

Let X be a given non-empty finite set. Then any string x1 x2 . . . xk , where xi ’s in X, is called a word over X. k is called the length of word x1 x2 . . . xk . A word of length 0, i.e; a string which contains no symbols in X, is called an empty word. It is denoted by λ or φ. The set of all words in X is denoted by X ? . Let M = (S, I, f, s0 , A) be any DFA. Then each word w = x1 x2 . . . xk determines a finite sequence < sn > of states, where sn = f (sn−1 , xn ) for all n = 1, 2, . . . , k. The state sk is final state obtained by applying input string x1 x − 2 . . . xk and we write sk = f (s0 , x1 x2 . . . xk ). It is illustrated by the

9.2. MACHINES WITH NO OUTPUT

173

following diagram

Definition 9.2.3. A word w = x1 x2 . . . xk is called recognized or accepted DFA M = (S, I, f, s0 , A) if it takes initial state s0 to the state sk = f (s0 , x1 x2 . . . xk ) in A. If sk ∈ / A, then we say w = x1 x2 . . . xk is rejected by the machine. The set of all words accepted by DFA M is denoted by L(M ) and L(M ) is called the language recognized or accepted by M . Roughly we say L(M ) is the language over M . Example 9.2.4. The language L(M ) recognized by DFA M = (S, I, f, s0 , A), where S = {s0 , s1 }, I = {0, 1}, A = {s0 } and f (s0 , 1) = s0 , f (s0 , 0) = f (s1 , 0) = f (s1 , 1) = s1 is {1n | n = 0, 1, 2, . . .} because any word containing 0 carries s0 to s1 which is not an accepting state. The state diagram of this DFA is

Example 9.2.5. The language recognized by DFA (S, I, f, s0 , A) given by following state diagram

is 1 and 01 because only string(word) which takes s0 to s2 are 1 and 01. Exercise 9.2.6. Prove that the language recognized by DFA M = (S, I, f, s0 , A) given by following state diagram

174CHAPTER 9. FINITE STATE MACHINES AND FINITE AUTOMATA

is L(M ) = {0n , 0n 10x| x ∈ {0, 1}, n = 0, 1, 2, . . .}. Exercise 9.2.7. Find the language recognized by the following DFA

9.2.2

Non-deterministic finite automata

Definition 9.2.8. A non-deterministic finite state automata M (NFA) consists the following: 1. a non-empty finite set S of states, 2. a non-empty finite set I of inputs, 3. a function f : S × I → P(S) called a transition function (or next state function), 4. a non-empty subset A of S called accepting or final states, 5. an initial state s0 in S.

9.2. MACHINES WITH NO OUTPUT

175

It is denoted by 5-tuple (S, I, f, s0 , A).

It is noted that f determines several states corresponding to each pair of state and input, i.e, each input carries a state to several states. This is the reason to call this automata as non-deterministic finite state automata. The state diagrams of NFA is same as that of DFA.

Example 9.2.9. The state diagram of the NFA (S, I; f, s0 , A) given by the following state table

S → s0 s1 s2 s3

0 s0 , s1 s0 s0 , s1 , s2

f 1 s3 s1 , s3 s0 , s2 s1

A = {s0 , s3 }

is

Example 9.2.10. The state table of the NFA (S, I; f, s0 , A) given by following state diagram

176CHAPTER 9. FINITE STATE MACHINES AND FINITE AUTOMATA

is

9.2.3

S → s0 s1 s2 s3 s4

0 s0 , s2 s3 s3 s3

f 1 s1 s4 s4

A = {s0 , s4 }

s3

NFA as Language recognizer

Let (S, I; f, s0 , A) be a given NFA. Let x1 x2 . . . xk be an input string. Then, first input symbols x1 takes s0 to the set S1 = f (s0 , x1 ) of states. We define Sn inductively as follows: S1 = f (s0 , x1 ) Suppose Sn (n < k) is defined, then Sn+1 = ∪s∈Sn f (s, xn+1 ). Thus, input string x1 x2 . . . xk takes s0 to the the set Sk of states. If Sk contains some accepted states (A ∩ Sk 6= ∅), i.e; some accepted states belong to Sk , then we say x1 x2 . . . xk is recognized or accepted. If Sk ∩ A = ∅, then we call input string x1 x2 . . . xk is rejected (not recognized). The language recognized by NFA is the set of all finite input strings recognized by this automaton. It is denoted by L(M ). Consider the NFA given in example 9.2.10. Since input 0 takes s0 to itself which is an accepting state, therefore 0n , n = 0, 1, 2, ..., is recognized. Next, input strings 01 and 11 carries s0 to an accepting state s4 , therefore all input strings of the form 0n 01 (concatenation of 0n and 01) and 0n 11 are recognized. Thus, L(M ) = {0n , 0n 01, 0n 11| n ∈ N ∩ {0}}.

9.2. MACHINES WITH NO OUTPUT

177

Exercise 9.2.11. Prove that the language recognized by NFA

is {101, 100(01)n }, where n ≥ 0. One can also write it as {101, 100(01)∗ } DFA equivalent to NFA As we have discussed earlier in FSM that a non-deterministic finite state machine is equivalent to a deterministic finite state machine. On the same line, we construct a DFA such that the language of NFA is the language of DFA. The conversion procedure is described as follows: Let M = (S, I; f, s0 , A) be a given NFA. Then, we consider the following procedure:

1. Each state in Md will be made up of a set of states in M . 2. Take {s0 } as initial state of DF A Md . 3. Input set of Md is I, the input set of M . 4. Given a state {si1 , si2 , . . . , sik } of Md the next state corresponding to k input symbol a ∈ I will be obtained by ∪in=i f (sn , a).. This set will be 1 considered as a state of Md . Indeed, the states of Md are the set of subsets of S that are obtained in this way starting with {s0 }. This is denoted by Sd . Note that maximum number of states in Md will be 2n , where |S| = n. 5. The accepting state Ad of Md is {B ∈ Sd | A ∩ B 6= ∅. It can be illustrated by following example:

178CHAPTER 9. FINITE STATE MACHINES AND FINITE AUTOMATA Example 9.2.12. The DFA corresponding to NFA S → s0 s1 s2 s3

0 s0 , s1 s0 s0 , s1 , s2

f 1 s3 s1 , s3 s0 , s2 s1

A = {s0 , s3 }

is fd Sd

0

1

→ {s0 } {s0 , s1 } {s3 } {s1 } {s1 , s3 } {s0 , s1 , s2 } {s0 , s1 , s2 , s3 } ∅

{s0 , s1 } {s0 , s1 } {s0 , s1 , s2 } {s0 } {s0 , s1 , s2 } {s0 , s1 } {s0 , s1 , s2 } ∅

{s3 } {s1 , s3 } {s1 } {s1 , s3 } {s1 , s3 } {s0 , s1 , s2 , s3 } {s0 , s1 , s2 , s3 } ∅

Ad {{s0 }, {s3 }, {s1 , s3 }, {s0 , s1 }, {s0 , s1 , s2 }, {s0 , s1 , s2 , s3 }} f (s0 , 0) = {s0 , s1 }, f (s0 , 1) = {s3 } union of rows of s0 and s1

union of rows of s1 and s3 union of rows of s0 , s1 and s2 union of rows of s0 , s1 , s2 and s3

Example 9.2.13. The DFA corresponding to NFA given in example 9.2.10 is given by fd Sd

0

1

→ {s0 } {s0 , s2 } {s1 } {s1 } {s3 } {s4 } {s3 } {s3 } ∅ {s4 } {s3 } {s3 } {s0 , s2 } {s0 , s2 } {s1 , s4 } {s1 , s4 } {s3 } {s3 , s4 } {s3 , s4 } {s3 } {s3 } ∅ ∅ ∅ The state diagram of this DFA is

Ad {{s0 }, {s4 }, {s0 , s2 }, {s1 , s4 }, {s3 , s4 }} f (s0 , 0) = {s0 , s2 }, f (s0 , 1) = {s1 }

union of rows of {s0 } and {s2 } union of rows of s1 and s4 union of rows of s3 and s4

9.2. MACHINES WITH NO OUTPUT

179

Definition 9.2.14. A language L is called regular if there exists a DFA M such that L(M ) = L.

Example 9.2.15. The language L = {an bn |n ∈ N} is not regular. We prove it by method of contradiction. Suppose there exists a DF A M = (S, I, f, s0 , A) such that L = L(M ). Let |S| = k. Since {an bn |n ∈ N} is the language of this machine, therefore it will recognize ak bk .Then, it determines a sequence < sn > given by recurrence relation sn = f (sn−1 , xn ) for all n = 1, 2, . . . , 2k, where xn is the nth - term of the input string ak bk . Since it recognizes ak bk , therefore s2k will be accepting state. Since automata has only k states, therefore by pigeon hole principle, at least two of first k + 1 states s0 , s1 , . . . and sk , will be same . Let it be si and sj with 0 ≤ i < j ≤ k. This suggests us that sj = f (si , aj−i ), i.e; it has a loop starting from si to sj containing j − i. This suggests that input string aj−i at state si carries si to itself and so input string ak−j+i bk will carry s0 to accepting state s2k , i.e; ak−j+i bk will be recognized by automata. This is a contradiction. Thus, the language L = {an bn |n ∈ N} is not regular. It is illustrated by the following figure with i = 3

180CHAPTER 9. FINITE STATE MACHINES AND FINITE AUTOMATA a

a

a s4

sj−2 a

a

a

s3 = sj

a

sj−1 a

a

s1

a

a

s0

sj+1

a

sk

a

sj+2

sj+3

s2

b sk+1 b sk+2 b s2k−1

s2k

b

Example 9.2.16. Prove that the language L = {an |n = i2 , i ∈ N} is not regular.

Solution: Suppose not. Then there exists a DFA (S, I, f, s0 , A) recognizing L = {an |n = i2 , i ∈ N}. Let |S| = k. Let sn = f (sn−1 , a) for n ∈ N. Choose i so large such that (i + 1)2 − i2 > k. Then at least two states of the sequence < sn > between states s(i+1)2 and si2 will be same (pigeon hole principle). Let these states be sl and sm with sl = sm , where i2 ≤ l < m ≤ (i + 1)2 . Then string am−l will carry state sl to sm = sl . 2 Since ai+1 carries s0 to an accepting state si+12 and am−l carries state sl 2 to sl itself, therefore a(i+1) −(m−l) will carry s0 to accepting state si+12 . But i2 < (i + 1)2 − (m − l) < (i + 1)2 because i2 ≤ l < m ≤ (i + 1)2 and so (i + 1)2 − (m − l) 6= t2 for all t ∈ N. This shows that DFA recognizes the 2 word a(i+1) −(m−l) ∈ / L. This is a contradiction. Thus, there does not exist a DFA recognizing the language L. It may be observed by the following s0 as1 a . . . si2 −1 asi2 as(i+1)2 . . . asl asl+1 a . . . asm−1 asl asm+1 a . . . s(i+1)2 −1 as(i+1)2 . {z } | {z } | m−l terms i2 terms | {z } (i+1)2 terms

Thus, in general we observe the following: Lemma 9.2.17. (Pumping Lemma): Let L be a language recognized by a DFA with k states. Every language α = x1 x2 . . . xn ∈ L whose length is k or larger than k, can be expressed as uvw, where u, v, w are input strings, such that v is nonempty and each uv i w ∈ L, i ≥ 0.

9.2. MACHINES WITH NO OUTPUT

181

Proof: Without loss of generality, let the length of α be k and α = x1 x2 . . . xk ∈ L. Let sj0 , sj1 , sj2 . . ., sjk denote the states the DFA visits, where sj0 is the initial state and sjk is the accepting state. By pigeon hole principle, among k + 1 states sj0 , sj1 , sj2 . . ., sjk , there are two of them that are same. Let it be sjl and sjm with sjl = sjm , where 0 ≤ jl < jm ≤ jk . Consider the following sj0 x1 sj1 x2 . . . xl sjl xl+1 sjl+1 . . . xm sjm xm+1 sjm+1 xm+2 . . . xk sjk {z }| | {z } {z }| l−input strings

m−l input strings

k−m input strings

Take u = x1 x2 . . . xl , v = xl+1 . . . xm , w = xm+1 . . . xk . Then α = uvw with v non-empty (length of v is (m − l) > 1) From above we see that each language uv i w, i ≥ 0 is recognizable. 2 Definition 9.2.18. Suppose that M = (S, I, f, s0 , A) is a deterministic finite state automaton. Then two states si , sj in S are said to be 0-equivalent if either both si , sj ∈ A or both si , sj ∈ / A. It is denoted by si ≡0 sj . Let k ∈ N, two states si , sj in S are said to be k-equivalent if si ≡k−1 sj and f (si , x) ≡0 f (sj , x). It is denoted by denoted si ≡k sj . One may easily verify that ≡k is an equivalence relation on S for every k. The set of all equivalence classes modulo ≡k is denoted by Pk . Two states si , sj ∈ S are said to be equivalent if si ≡k sj for every k ∈ N ∪ {0}. It is denoted by si ≡ sj . Indeed, we have the following: Proposition 9.2.19.

1. If si ≡k sj then si ≡k−1 sj .

2. si ≡k sj if and only if si ≡k−1 sj and f (si , x) ≡k−1 f (sj , x) for all x ∈ I. 3. If Pk = Pk+1 then Pk = Pn+k for all n ∈ N.

9.2.4

Minimization process

Let (S, I, f, s0 , A) be a given DFA. Step 1 . Compute P0 . Clearly P0 = {A, S \ A}. Step 2 . After computing Pk , we calculate Pk+1 .

182CHAPTER 9. FINITE STATE MACHINES AND FINITE AUTOMATA Step 3 . If Pk+1 = Pk , then process is completed. Step 4 . If Pk+1 6= Pk , then we repeat the step 2 till Pk+1 = Pk (Step 3 is attained). Since S is finite therefore the process will be completed after finitely many steps. It can be illustrated by the following example: Example 9.2.20. S → s0 s1 s2 s3 s4 s5 s6 s7 s8 s9

f 0 s9 s2 s9 s4 s5 s9 s9 s9 s9 s9

A = {s7 , s8 } 1 s1 s3 s1 s6 s8 s3 s7 s9 s9 s9

P0 = {s0 s1 s2 s3 s4 s5 s6 s9 , s7 s8 } P1 = {s0 s1 s2 s3 s5 s9 , s4 s6 , s7 s8 } P2 = {s0 s1 s2 s5 s9 , s3 , s4 s6 , s7 s8 } P3 = {s0 s2 s9 , s3 , s1 s5 , s4 s6 , s7 s8 } P4 = {s0 s2 , s9 , s3 , s1 s5 , s4 , s6 , s7 s8 } P5 = {s0 s2 , s9 , s3 , s1 , s5 , s4 , s6 , s7 s8 } P6 = P5

Clearly P0 = {s0 s1 s2 s3 s4 s5 s6 s9 , s7 s8 }. Note that two states of different 0equivalence classes may not be 1−equivalent. Thus to compute 1−equivalence classes, first we consider the class s0 s1 s2 s3 s4 s5 s6 s9 , the set of all non-accepted states. Take two states s0 , s1 of the same 0 − equivalence class. Since f (s0 , 0) ≡0 f (s1 , 0) and f (s0 , 1) ≡0 f (s1 , 1). Therefore s0 ≡1 s1 . Similarly s0 ≡1 si for i = 2, 3, 5, 9. Since next states f (s0 , 1) = s1 and f (s4 , 1) = s8 belong to different 0 − equivalence classes, therefore s4 is not 1 − equivalent to s0 . Indeed, we have s4 ≡1 s6 and s7 ≡1 s8 . Thus, P1 = {s0 s1 s2 s3 s5 s9 , s4 s6 , s7 s8 }. Using P1 , we have P2 = {s0 s1 s2 s5 s9 , s3 , s4 s6 , s7 s8 } Similarly, we have P3 = {s0 s2 s9 , s3 , s1 s5 , s4 s6 , s7 s8 }

9.3. EXERCISES

183 P4 = {s0 s2 , s9 , s3 , s1 s5 , s4 , s6 , s7 s8 } P5 = {s0 s2 , s9 , s3 , s1 , s5 , s4 , s6 , s7 s8 }

and P6 = P5 . Thus, minimization process is complete. Note that a, b ∈ x if and only if a = b. Here ab denotes the equivalence class {a, b}. Thus, the minimized machine is f¯ A¯ = {[s7 ]} 0 1 S¯ → [s0 ] [s9 ] [s1 ] [s1 ] [s0 ] [s3 ] since [s0 ] = [s2 ] [s3 ] [s4 ] [s6 ] [s4 ] [s5 ] [s7 ] since [s7 ] = [s8 ] [s5 ] [s9 ] [s3 ] [s6 ] [s9 ] [s7 ] [s7 ] [s9 ] [s9 ] [s9 ] [s9 ] [s9 ]

9.3

Exercises

Exercise 9.3.1. Draw the state diagram of the finite state machine given by the following state table: INPUT STATE

OUTPUT

a s0

s3

b s1

s1

s4

s1

s2

s3

s0

0 1

s3

s2

s3

0

s4

s1

s0

1

1

Also, minimize it. Exercise 9.3.2. Draw state tables of finite state machines given by following state diagrams:

184CHAPTER 9. FINITE STATE MACHINES AND FINITE AUTOMATA 1; 0

s1

a; 0

0, 0 1; 0

b; 1

1; 1 s2

0; 1

a; 0

a; 0 s2 b; 1

s0

0; 1

s0

s1

b; 0

b; 0 s3

s4 a; 1 b; 1

a; 1

a; 0 s0

b; 1 b; 1

s1

a; 0

Bibliography

[1]

P J Cohen, Set Theory And Continuum Hypothesis, Dover Publications, 2008.

[2]

R Garnier, and J W Taylor, Discrete Mathematics for New Technology, Second Edition, IOP Publishing Limited, 2002.

[3]

C L Liu, Elements of Discrete Mathematics, Tata McGraw Hill Publishing Company Limited, Second Edition, 2000.

[4]

C L Liu, Introduction to Combinatorial Mathematics, McGraw-Hill Book Company, New York, 1968.

[5]

K H Rosen, Discrete Mathematics and its Applications, McGraw Hill Company Limited, international Edition, 1999.

185

Index

accepted, 171 addition principle, 79 adjacent, 112 adjacent edges, 113 antecedent, hypothesis, 4 atom, 58 atomic, 3 axiom, 15 binary search tree, 152 bipartite graph, 118 bounded lattice, 44 chain, 32 characteristic equation, 100 chromatic number, 134 coloring, 134 combination, 87 comparable elements, 32 complement, 45 complemented lattice, 46 complete graph, 115 complete lattice, 44 complete order, 35 conclusion, 10 consequent, conclusion, 4

contradiction, 8 contrapositive of conditional statement, 6 converse of conditional statement, 6 counterexample, 17 definitions, 15 DFA, 169, 171 dictionary order, 36 digraph, 111 directed tree, 141 distributive lattice, 44 dual of a poset, 39 dual of statement, 12 edges, 111 equivalence of statements, 6 fallacy, 10 finite automata, 169 fsm, 157, 167 graph, 111 greatest lower bound, 34 Handshaking lemma, 115 inverse of conditional statement, 6 186

INDEX isomorphism of Boolean algebra, 57 largest element, 33 Law of syllogism, 11 least element, 33 least upper bound, 34 linear recurrence relation, 100 literal, 59 logic gates, 66 lower bound, 32 Mealey Machine, 158 Modus Ponens, 11 Modus Tollen, 11 Moore Machine, 158 multigraph, 115 multiplication principle, 79 n-equivalent, 162 NFA, 171 null graph, 114 Order a, 95 partial order relation, 31 permutation, 83 Pigeonhole Principle, 90 Poset, 31 premises, 10 Principle of Duality, 12 Pumping Lemma, 177 regular graph, 114 rejected, 171 self complementary, 122 simple graph, 115 sort tree, 152 spanning subgraph, 120 state diagram, 158

187 state table, 158 statement or proposition, 2 subgraph, 120 theorem, 15 total order, linear order, 32 tree, 137 trivial graph, 114 truth value, 2 universal quantifier, 13 upper bound, 32 valid statement, 10 vertex disjoint, 120 walk, 123 well order, 35 Well ordering principle, 35 well ordered set, 35 wheel, 117 Zorn’s Lemma, 35 Zorn‘s Lemma, 35