logic, discrete mathematical structuresjnujprdistance.com/assets/lms/lms jnu/b.sc.(it)/sem...

145
Logic, Discrete Mathematical Structures

Upload: others

Post on 18-Jul-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

Page 2: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Board of Studies

Prof. H. N. Verma Prof. M. K. GhadoliyaVice- Chancellor Director, Jaipur National University, Jaipur School of Distance Education and Learning Jaipur National University, JaipurDr. Rajendra Takale Prof. and Head AcademicsSBPIM, Pune

___________________________________________________________________________________________

Subject Expert Panel

Dr. Ramchandra G. Pawar Ashwini PanditDirector, SIBACA, Lonavala Subject Matter ExpertPune

___________________________________________________________________________________________

Content Review Panel

Gaurav Modi Shubhada PawarSubject Matter Expert Subject Matter Expert

___________________________________________________________________________________________Copyright ©

This book contains the course content for Logic, Discrete Mathematical Structures.

First Edition 2013

Printed byUniversal Training Solutions Private Limited

Address05th Floor, I-Space, Bavdhan, Pune 411021.

All rights reserved. This book or any portion thereof may not, in any form or by any means including electronic or mechanical or photocopying or recording, be reproduced or distributed or transmitted or stored in a retrieval system or be broadcasted or transmitted.

___________________________________________________________________________________________

Page 3: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

I

Index

ContentI. ...................................................................... II

List of FiguresII. .......................................................VIII

List of TablesIII. ...........................................................IX

AbbreviationsIV. .......................................................... X

ApplicationV. ............................................................. 126

BibliographyVI. ......................................................... 129

Self Assessment AnswersVII. ................................... 131

Book at a Glance

Page 4: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

II

Contents

Chapter I ....................................................................................................................................................... 1Set Theory ..................................................................................................................................................... 1Aim ................................................................................................................................................................ 1Objectives ...................................................................................................................................................... 1Learning outcome .......................................................................................................................................... 11.1 Introduction .............................................................................................................................................. 21.2 Sets and Operations on Sets ..................................................................................................................... 2 1.2.1 Notation ................................................................................................................................... 2 1.2.2 Specifying Sets ....................................................................................................................... 21.3 Subsets .................................................................................................................................................... 3 1.3.1 Proper Subset ........................................................................................................................... 3 1.3.2 Equal Sets ................................................................................................................................ 3 1.3.3 Super Set .................................................................................................................................. 3 1.3.4 Null Set .................................................................................................................................... 31.4 Singleton .................................................................................................................................................. 41.5 Finite Set .................................................................................................................................................. 41.6 Infinite Set ................................................................................................................................................ 41.7 Universal Set ............................................................................................................................................ 41.8 Power Set ................................................................................................................................................. 51.9 Disjoint Set............................................................................................................................................... 51.10 Cardinality of a Set ................................................................................................................................ 5 1.10.1 Equivalent Sets ...................................................................................................................... 51.11 Operations On Sets: Union of Sets ........................................................................................................ 5 1.11.1 Union ..................................................................................................................................... 5 1.11.2 Intersection ............................................................................................................................. 6 1.11.3 Difference ............................................................................................................................... 6 1.11.4 Symmetry Difference ............................................................................................................. 7 1.11.5 Complement of a Set .............................................................................................................. 7Summary ....................................................................................................................................................... 9References ..................................................................................................................................................... 9Recommended Reading ............................................................................................................................... 9Self Assessment ........................................................................................................................................... 10

Chapter II ................................................................................................................................................... 12Mathematical Logic ................................................................................................................................... 12Aim .............................................................................................................................................................. 12Objectives .................................................................................................................................................... 12Learning outcome ........................................................................................................................................ 122.1 Statement (Proposition) ......................................................................................................................... 132.2 Logical Connectives/Operations ............................................................................................................ 13 2.2.1 Negation ................................................................................................................................. 13 2.2.2 Conjunction ............................................................................................................................ 13 2.2.3 Disjunction ............................................................................................................................. 142.3 Conditional ............................................................................................................................................. 142.4 Bi-Conditional........................................................................................................................................ 152.5 Converse ................................................................................................................................................ 162.6 Inverse .................................................................................................................................................... 162.7 Exclusive OR ......................................................................................................................................... 162.8 NAND .................................................................................................................................................... 172.9 NOR ....................................................................................................................................................... 172.10 Tautology ............................................................................................................................................. 172.11 Contradiction ........................................................................................................................................ 182.12 Duality Law ......................................................................................................................................... 18

Page 5: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

III

2.13 Algebra of Propositions ........................................................................................................................ 18 2.13.1 De Morgan’s Laws ............................................................................................................... 192.14 Mathematical Induction ....................................................................................................................... 19Summary ..................................................................................................................................................... 20References ................................................................................................................................................... 20Recommended Reading ............................................................................................................................. 20Self Assessment ........................................................................................................................................... 21

Chapter III .................................................................................................................................................. 23Techniques of Counting ............................................................................................................................. 23Aim .............................................................................................................................................................. 23Objectives .................................................................................................................................................... 23Learning outcome ........................................................................................................................................ 233.1 Introduction ............................................................................................................................................ 243.2 Basic Counting Principles ...................................................................................................................... 243.3 Mathematical Functions ......................................................................................................................... 24 3.3.1 Factorial Functions ................................................................................................................ 24 3.3.2 Binomial Coefficients ............................................................................................................ 25 3.3.3 Binomial Coefficients and Pascal’s Triangle ......................................................................... 253.4 Permutations .......................................................................................................................................... 25 3.4.1 Permutation with Repetitions ................................................................................................. 263.5 Combinations ......................................................................................................................................... 273.6 The Pigeonhole Principle ....................................................................................................................... 283.7 Recurrence Relations ............................................................................................................................. 283.8 Linear Recurrence Relations with Constant coefficients ....................................................................... 29Summary ..................................................................................................................................................... 30References ................................................................................................................................................... 30Recommended Reading ............................................................................................................................. 30Self Assessment ........................................................................................................................................... 31

Chapter IV .................................................................................................................................................. 33Relations and Diagraph ............................................................................................................................. 33Aim .............................................................................................................................................................. 33Objectives .................................................................................................................................................... 33Learning outcome ........................................................................................................................................ 334.1 Concept of Relation ............................................................................................................................... 344.2 Properties of Relations ........................................................................................................................... 34 4.2.1 Reflexive Relation ................................................................................................................. 34 4.2.2 Symmetric Relation ............................................................................................................... 35 4.2.3 Transitive Relation ................................................................................................................. 35 4.2.4 Equivalence Relation ............................................................................................................. 35 4.2.5 Anti-Symmetric Relation ....................................................................................................... 35 4.2.6 Inverse Relation ..................................................................................................................... 354.3 Pictorial Representatives of Relations ................................................................................................... 36 4.3.1 Relations on R ........................................................................................................................ 36 4.3.2 Directed Graphs of Relations in Sets ..................................................................................... 36 4.3.3 Pictures of Relations on Finite Sets ....................................................................................... 364.4 Composition of Relations ...................................................................................................................... 374.5 Relations and Digraphs .......................................................................................................................... 374.6 Paths in Relations and Digraph .............................................................................................................. 384.7 Equivalence Relations ............................................................................................................................ 39 4.7.1 Equivalence Relations and Partitions .................................................................................... 404.8 Transitive Extensions ............................................................................................................................. 414.9 Transition Closure .................................................................................................................................. 414.10 Matrix Representation of Relations ..................................................................................................... 42

Page 6: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

IV

Summary ..................................................................................................................................................... 45References ................................................................................................................................................... 45Recommended Reading ............................................................................................................................. 45Self Assessment ........................................................................................................................................... 46

Chapter V .................................................................................................................................................... 48Functions and Recurrence Relations........................................................................................................ 48Aim .............................................................................................................................................................. 48Objectives .................................................................................................................................................... 48Learning outcome ........................................................................................................................................ 485.1 Introduction ............................................................................................................................................ 495.2 Function ................................................................................................................................................. 49 5.2.1 Restriction and Extension ...................................................................................................... 505.3 One-To-One Mapping (Injection One-To-One Function) ...................................................................... 505.4 Onto-Mapping (Surjection) .................................................................................................................... 515.5 One-To-One, Onto (Bijection) ............................................................................................................... 515.6 Identity Mapping .................................................................................................................................... 515.7 Composition of Function ....................................................................................................................... 515.8 Associative Mapping .............................................................................................................................. 525.9 Constant Function .................................................................................................................................. 525.10 Inverse Mapping .................................................................................................................................. 525.11 Mathematical Functions, Exponential and Logarithmic Functions ..................................................... 53 5.11.1 Floor and Ceiling Function .................................................................................................. 53 5.11.2 Integer and Absolute Value Functions ................................................................................. 53 5.11.3 Remainder Function and Modular Arithmetic ..................................................................... 54 5.11.4 Logarithmic Functions ......................................................................................................... 545.12 Sequences, Indexed Classes of Sets ..................................................................................................... 55 5.12.1 Sequences ............................................................................................................................. 55 5.12.2 Summation Symbol, Sums ................................................................................................... 55 5.12.3 Indexed Classes of Sets ........................................................................................................ 555.13 Algorithms and Functions .................................................................................................................... 565.14 Complexity of Algorithm ..................................................................................................................... 57 5.14.1 Complexity of Well-known Algorithms ............................................................................... 57Summary ..................................................................................................................................................... 59References ................................................................................................................................................... 59Recommended Reading ............................................................................................................................. 59Self Assessment ........................................................................................................................................... 60

Chapter VI .................................................................................................................................................. 62Graph Theory ............................................................................................................................................. 62Aim .............................................................................................................................................................. 62Objectives .................................................................................................................................................... 62Learning outcome ........................................................................................................................................ 626.1 Introduction ........................................................................................................................................... 63 6.1.1 Linked Lists and Pointers ...................................................................................................... 63 6.1.2 Stacks, Queues and Priority Queues ...................................................................................... 64 6.1.2.1 Stack ........................................................................................................................ 65 6.1.2.2 Queue ...................................................................................................................... 65 6.1.2.3 Priority Queue ......................................................................................................... 656.2 Graphs and Multigraphs ......................................................................................................................... 66 6.2.1 Multigraphs ............................................................................................................................ 66 6.2.2 Degree of a Vertex ................................................................................................................. 66 6.2.3 Finite Graphs, Trivial Graphs ................................................................................................ 676.3 Subgraphs, Isomorphic and Homeomorphic Graphs ............................................................................. 67 6.3.1 Subgraphs ............................................................................................................................... 67

Page 7: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

V

6.3.2 Isomorphic Graphs ................................................................................................................. 67 6.3.3 Homeomorphic Graphs .......................................................................................................... 676.4 Paths, Connectivity ................................................................................................................................ 68 6.4.1 Connectivity, Connected Components ................................................................................... 68 6.4.2 Distance and Diameter ........................................................................................................... 68 6.4.3 Cutpoints and Bridges ............................................................................................................ 686.5 Traversable and Eulerian Graphs, Bridges of Königsberg ..................................................................... 69 6.5.1 Hamiltonian Graphs ............................................................................................................... 696.6 Labelled and Weighted Graphs .............................................................................................................. 706.7 Complete, Regular and Bipartite Graphs ............................................................................................... 70 6.7.1 Complete Graphs ................................................................................................................... 70 6.7.2 Regular Graphs ...................................................................................................................... 71 6.7.3 Bipartite Graphs ..................................................................................................................... 726.8 Graphs Colourings ................................................................................................................................. 72 6.8.1 Dual Maps and the Four Colour Theorem ............................................................................. 73Summary ..................................................................................................................................................... 74References ................................................................................................................................................... 74Recommended Reading ............................................................................................................................. 74Self Assessment ........................................................................................................................................... 75

Chapter VII ................................................................................................................................................ 77Ordered Sets, Lattices and Boolean Algebra ........................................................................................... 77Aim .............................................................................................................................................................. 77Objectives .................................................................................................................................................... 77Learning outcome ........................................................................................................................................ 777.1 Ordered Sets ........................................................................................................................................... 78 7.1.1 Dual Order ............................................................................................................................. 78 7.1.2 Ordered Subsets ..................................................................................................................... 78 7.1.3 Quasi-Order ........................................................................................................................... 78 7.1.4 Comparability, Linearly Ordered Sets ................................................................................... 797.2 Hasse Diagrams of Partially Ordered Sets ............................................................................................. 79 7.2.1 Minimal and Maximal and First and Last Elements .............................................................. 807.3 Lattices ................................................................................................................................................... 80 7.3.1 Axioms Defining Lattice ........................................................................................................ 80 7.3.2 Duality and the Idempotent Law ........................................................................................... 81 7.3.3 Lattices and Order .................................................................................................................. 81 7.3.4 Sub-Lattices, Isomorphic Lattices ......................................................................................... 817.4 Bounded Lattices ................................................................................................................................... 817.5 Distributive Lattices ............................................................................................................................... 827.6 Complements, Complemented Lattices ................................................................................................. 82 7.6.1 Complemented Lattices ......................................................................................................... 837.7 Boolean Algebra ..................................................................................................................................... 83 7.7.1 Subalgebras, Isomorphic Boolean Algebras .......................................................................... 837.8 Duality .................................................................................................................................................... 847.9 Boolean Algebras as Lattices ................................................................................................................. 847.10 Sum-Of-Products Form for Sets .......................................................................................................... 847.11 Sum-Of-Products Form for Boolean Algebras ..................................................................................... 857.12 Logic Gates and Circuits ...................................................................................................................... 86 7.12.1 Logic Gates .......................................................................................................................... 86 7.12.1.1 OR Gate ................................................................................................................. 86 7.12.1.2 AND Gate .............................................................................................................. 86 7.12.1.3 NOT Gate .............................................................................................................. 87 7.12.2 Logic Circuits ...................................................................................................................... 87 7.12.2.1 AND-OR Circuits ................................................................................................. 88 7.12.2.2 NAND and NOR Gates ......................................................................................... 88

Page 8: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

VI

7.13 Truth Tables, Boolean Functions ......................................................................................................... 89 7.13.1 Boolean Functions ............................................................................................................... 89Summary ..................................................................................................................................................... 90References ................................................................................................................................................... 90Recommended Reading ............................................................................................................................. 90Self Assessment ........................................................................................................................................... 91

Chapter VIII ............................................................................................................................................... 93Binary Trees ................................................................................................................................................ 93Aim .............................................................................................................................................................. 93Objectives .................................................................................................................................................... 93Learning outcome ........................................................................................................................................ 938.1 Introduction ............................................................................................................................................ 948.2 Binary Trees ........................................................................................................................................... 94 8.2.1 Picture of Binary Tree ............................................................................................................ 94 8.2.2 Similar Binary Trees .............................................................................................................. 958.3 Complete and Extended Binary Trees .................................................................................................... 95 8.3.1 Complete Binary Trees .......................................................................................................... 95 8.3.2 Extended Binary Trees: 2-Trees ............................................................................................. 958.4 Representing Binary Trees in Memory .................................................................................................. 96 8.4.1 Linked Representation of Binary Trees ................................................................................. 96 8.4.2 Sequential Representation of Binary Trees ............................................................................ 968.5 Traversing Binary Trees ......................................................................................................................... 978.6 Binary Search Trees ............................................................................................................................... 988.7 General Trees and Binary Trees ............................................................................................................. 988.8 Spanning Tree ........................................................................................................................................ 988.9 Prim’s Algorithm .................................................................................................................................... 988.10 Kruskal’s Algorithm ............................................................................................................................. 99Summary ................................................................................................................................................... 101References ................................................................................................................................................. 101Recommended Reading ........................................................................................................................... 101Self Assessment ......................................................................................................................................... 102

Chapter IX ................................................................................................................................................ 104Group Theory, Languages and Finite State Machines ......................................................................... 104Aim ............................................................................................................................................................ 104Objectives .................................................................................................................................................. 104Learning outcome ...................................................................................................................................... 1049.1 Binary Operations ................................................................................................................................ 1059.2 General Properties ................................................................................................................................ 1059.3 Algebraic Structures (Algebraic Systems) ........................................................................................... 105 9.3.1 Groupoid .............................................................................................................................. 1069.4 Semi-Group .......................................................................................................................................... 1069.5 Homomorphism of Semi-Groups ......................................................................................................... 1079.6 Isomorphism of Semi-Groups .............................................................................................................. 1079.7 Monoid ................................................................................................................................................. 1079.8 Groups .................................................................................................................................................. 1089.9 Sub-Group ............................................................................................................................................ 1099.10 Centre of a Group ............................................................................................................................... 1099.11 Index of a Sub-Group ......................................................................................................................... 1099.12 Cosets ................................................................................................................................................. 1099.13 Normal Sub-Groups ............................................................................................................................110 9.13.1 Simple Group ......................................................................................................................110 9.13.2 Quotient Group ...................................................................................................................1109.14 Alphabet, Words, Free Semi-Group ....................................................................................................110

Page 9: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

VII

9.15 Languages ...........................................................................................................................................111 9.15.1 Operations on Languages ....................................................................................................1119.16 Regular Expressions, Regular Languages ...........................................................................................1129.17 Grammars ............................................................................................................................................112 9.17.1 Language L (G) of a Grammar G........................................................................................113 9.17.2 Types of Grammars .............................................................................................................114 9.17.3 Machines and Grammars ....................................................................................................1149.18 Finite State Machines ..........................................................................................................................115Summary ....................................................................................................................................................116References ..................................................................................................................................................116Recommended Reading ............................................................................................................................116Self Assessment ..........................................................................................................................................117

Chapter X ..................................................................................................................................................119Codes and Group Codes ...........................................................................................................................119Aim .............................................................................................................................................................119Objectives ...................................................................................................................................................119Learning outcome .......................................................................................................................................11910.1 Introduction ........................................................................................................................................ 12010.2 Terminologies ..................................................................................................................................... 12010.3 Error Correction ................................................................................................................................. 12010.4 Group Codes ...................................................................................................................................... 12110.5 Weight of Code Word ......................................................................................................................... 12110.6 Distance Between the Code Words .................................................................................................... 12110.7 Error Correction for Block Code ....................................................................................................... 121 10.7.1 Maximum Likelihood Criterion ......................................................................................... 122 10.7.2 Minimum Distance Decoding Criterion ............................................................................ 122Summary ................................................................................................................................................... 123References ................................................................................................................................................. 123Recommended Reading ........................................................................................................................... 123Self Assessment ......................................................................................................................................... 124

Page 10: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

VIII

List of Figures

Fig. 1.1 Venn diagram of union...................................................................................................................... 6Fig. 1.2 Venn diagram of intersection ............................................................................................................ 6Fig. 1.3 Venn diagram of difference .............................................................................................................. 7Fig. 1.4 Venn diagram of symmetric difference ............................................................................................. 7Fig. 1.5 Venn diagram of complement of a set .............................................................................................. 8Fig. 4.1 Relations on finite sets .................................................................................................................... 36Fig. 4.2 Transition extension ........................................................................................................................ 41Fig. 5.1 Representation of a function ........................................................................................................... 49Fig. 6.1 Linked list with 6 nodes.................................................................................................................. 64Fig. 6.2 Use of linked lists ........................................................................................................................... 64Fig. 6.3 Algorithm ........................................................................................................................................ 65Fig. 6.4 Stack and queue .............................................................................................................................. 65Fig. 6.5 Graph and multigraph ..................................................................................................................... 66Fig. 6.6 Isomorphic graphs .......................................................................................................................... 67Fig. 6.7 Homeomorphic graphs ................................................................................................................... 68Fig. 6.8 Cutpoints and bridges ..................................................................................................................... 69Fig. 6.9 Traversable and Eulerian graphs, bridges of Königsberg ............................................................... 69Fig. 6.10 Hamiltonian graphs ....................................................................................................................... 70Fig. 6.11 Labelled and weighted graphs ...................................................................................................... 70Fig. 6.12 Complete graphs ........................................................................................................................... 71Fig. 6.13 Regular graphs .............................................................................................................................. 71Fig. 6.14 Regular graphs .............................................................................................................................. 71Fig. 6.15 Bipartite graphs ............................................................................................................................. 72Fig. 6.16 Welch-Powell algorithm ............................................................................................................... 72Fig. 6.17 Dual maps and the four colour theorem ....................................................................................... 73Fig. 7.1 Distributive lattices ......................................................................................................................... 82Fig. 7.2 Sum-of-products form for sets ........................................................................................................ 85Fig. 7.3 OR gate ........................................................................................................................................... 86Fig. 7.4 AND gate ........................................................................................................................................ 87Fig. 7.5 NOT gate ........................................................................................................................................ 87Fig. 7.6 Logic circuits .................................................................................................................................. 88Fig. 7.7 NAND and NOR gates ................................................................................................................... 88Fig. 8.1 Picture of binary tree ...................................................................................................................... 94Fig. 8.2 Complete binary trees ..................................................................................................................... 95Fig. 8.3 Extended binary trees: 2-trees ........................................................................................................ 96Fig. 8.4 Sequential representation of binary tree ......................................................................................... 97Fig. 8.5 Prim’s algorithm ............................................................................................................................. 99Fig. 8.6 Prim’s algorithm ............................................................................................................................. 99Fig. 8.7 Kruskal’s algorithm ...................................................................................................................... 100Fig. 9.1 Grammars ......................................................................................................................................113Fig. 10.1 Communication channel with noise ........................................................................................... 120

Page 11: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

IX

List of Tables

Table 2.1 Truth table (Negation) .................................................................................................................. 13Table 2.2 Truth table (Conjunction) ............................................................................................................. 14Table 2.3 Truth table (Disjunction) .............................................................................................................. 14Table 2.4 Truth table (Conditional) .............................................................................................................. 15Table 2.5 Truth table (Bi-conditional) ......................................................................................................... 15Table 2.6 Truth table (Exclusive OR) .......................................................................................................... 17Table 2.7 Truth table (Nand) ........................................................................................................................ 17Table 2.8 Truth table (NOR) ........................................................................................................................ 17Table 2.9 Truth table (Tautology) ................................................................................................................ 18Table 2.10 Truth table (Contradiction) ......................................................................................................... 18Table 6.1 Linked lists and pointers .............................................................................................................. 63

Page 12: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

X

Abbreviations

FIFO - First-In-First-OutLIFO - Last-In-First-OutLNR - Left-Node-RightLRN - Left-Right-NodeNLR - Node-Left-Right

Page 13: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

1

Chapter I

Set Theory

Aim

The aim of this chapter is to:

introduce set•

explain the operation on set•

describe singleton•

Objectives

The objectives of this chapter are to:

introduce universal set•

discuss subset•

explainfiniteset•

Learning outcome

At the end of this chapter, the students will be able to:

explaininfiniteset•

understand power set•

discuss disjoint set•

Page 14: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

2

1.1 IntroductionThe notion of a set is elementary to all of mathematics and every branch of mathematics can be considered as a study of sets of objects of one kind or another. Cantor was the founder of the theory of sets. The word set is a primitive termandisregardedasoneofthebasicundefinedideasofmathematics.

1.2 Sets and Operations on SetsAsetisdefinedas“asetisacollectionofwelldefinedobjects”.Inthisdefinition,thewordssetandcollectionforall practical purposes are synonymous.

1.2.1 NotationEach of the objects in the set is called a member or an element of the set. The objects can be almost anything. Books, cities, numbers, letters, etc.

Elements of a set are denoted by lower-case letters. On the other hand, sets are denoted by upper-case letters of English language.

The symbol • indicates the membership in a set.If“• a is an element of the set A”,thenwewritea A.The symbol • isread“isamemberof”or“isanelementof”.The symbol • is used to indicate that n object is not in the given set.The symbol • isread“isnotamemberof”or“isnotanelementof”.If, • x is not an element of the set A then we write x A.

1.2.2 Specifying SetsTherearefivedifferentwaysofspecifyingsets:One method of specifying a set is to list all the members of the set between a pair of braces. Thus, {1, 2, 3} represents aset.Thismethodiscalled“Thelistingmethod”.

Example: {3, 6, 9, 12, 15}•{• a, b, c, d}

This method of listing the elements of the set is also known as ‘Tabulation’. In this method the order in which the elements are listed is immaterial and is used for small sets.

Anothermethodofdefiningparticularsetsisbyadescriptionofsomeattributeorcharacteristicsoftheelements•of the set. This method is more general and involves a description of the set property.A• = {x | x has the property P},designates“thesetA of all objects ‘a’ such that the property P”.Thisnotationis called Set-Builder notation.Theverticalbar|isreadas“suchthat”.•

Example:A• = {x | a is a positive Integer greater than 100}

Thisisreadas“thesetofallxisapositiveIntegerlessthen25”.B• = {x | x is a complex number}

Note that repetition of objects is not allowed in asset and a set is collection of objects without ordering.We can describe a set by its characteristic function.•

( )1 if0 if

µ =∈∉Axx Ax A

Page 15: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

3

In another method, we describe the set by a recursive formula:•

Example:Let = 2, = 1 and = + ; i 1 A = { : i o}We can also describe a set by an operation on some other sets.•

1.3 Subsets A set A is a subset of the set B if and only if every element of A is also an element of B. We also say that A is contained in B and use the notation A B.

Symbolically, if x A x B, then A B.If A B, it is possible that A = B, to emphasise this fact we write A B.If A is contained in B, then we may also state that B contains A and write B A.

1.3.1 Proper SubsetA set A is called proper subset of the set B if,

A• is subset of BB• is not a subset A

i.e., A is said to be proper subset of B if every element of A belongs to the set B, but there is at least one element of B, which is not in A. If A is a subset of B, then we denote it by A B.

Note that every set is a subset to itself. If every element A is an element of B but some element of B is not an element of A, then A is called a.

1.3.2 Equal Sets If A and B are sets such that every element of A is an element of B and every element of B is an element of A and A and Bareequal(identically)thenwewrite“A = B”andisreadasA and B are identical.

1.3.3 Super SetIf A is subset of B, then B is called a superset of A.

Example:If • A = A {0, 2, 9}, B = {0, 2, 7, 9, 11} then A B (A is a proper subset of B)If • A = {a, a, b}, B = {a, b}, then A and B denoted the same set, i.e., A = BIf • A = {1, 2, 4}, B = {2, 4, 6, 8} A is proper subset of B and B is a superset of A.

1.3.4 Null SetThe set with no elements is called an empty set or null set. A null set is designated by the symbol A.

Example:The set of real roots of the polynomial • + 9 = 0{• x | 5x + 2}

Page 16: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

4

1.4 SingletonA set having only one element is called a singleton.

Example:A• = {8}{• }

Theorem:•Two sets A and B are equal if and only if A B and B A.

Proof:If A = B, every member of A is a member of B and every member of B is a member of A.

A B and B A

Conversely let us suppose that A B, then there is either an element of A that is not in B or there is an element of B that is not in A. But A B, so every element of A is in B and B A, so every element of B is in A. Therefore, our assumption that A B leads to a contradiction, hence A = B.

Theorem:If and are empty sets, then =

Proof:Suppose = , then one of the following statements must be true:

There is an element � x , such that x There is an element � x , such that x .

But both these statements are false, since neither nor has any elements. It proves that = .

1.5 Finite SetAsetissaidtobefiniteifithasfinitenumberofelements.

Example:{1, 2, 3, 5}•The letters of the English alphabet.•

1.6InfiniteSetAsetisinfinite,ifitisnotfinite.

Example:The set of all real numbers.•The points on a line.•

1.7 Universal SetIn many discussions all the sets are considered to be subsets of one particular set. This set is called the universal set for that discussion. The universal set is often designated by the script letter U (or by X). Universal set is not unique and it may change from one discussion to another.

Example:If A = {0, 2, 7}, B = {3, 5, 6}, C = {1, 8, 9, 10} then the universal set can be taken as the set, U = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}

Page 17: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

5

1.8 Power SetThe set of all subsets of a set A is called the power set of A. The power set of A is denoted by P(A). If A has n elements in it, then P(A) has elements.

P(A) = {x | x A}

The power set of A is sometimes also denoted by 2A.

Example:If A = {a, b} thenP(A) = { , {a}, {b}, {a, b}}

Note that a set is never equal to its power set. In the programming language Pascal, the notion power set is used to definedatatypeinthelanguage.

1.9 Disjoint SetTwo sets are said to be disjoint if they have no element in common.

Example:The sets, A = {1, 4, 7, 9} and B = {3, 6, 10} are disjoint. 1.10 Cardinality of a SetIf A is a set, then the number of elements present in the set A is known as cardinality of A and is denoted by |A|. Mathematically if A = , , ......... }, then |A| = n; n B.

Example:If, A = {2, 4, 8, 16, 32, 64, 128, 256} |A| = 8

1.10.1 Equivalent SetsTwo sets A and B are said to be equivalent if they contains equal number of elements. In other words A and B are said to be equivalent if they have same cardinality i.e., |A| = |B|. The equivalent sets are known as a similar set, denoted as A B.

Example:A = {a, e, i, o, u}B = {7, 9, 11, 13, 15}Here, |A| = 5 |B|. Thus, A and B are similar.

1.11 Operations On Sets: Union of SetsThe set theory is a tool to solve many real life problems. In order to solve problems, it is essential to study different set operations.

1.11.1 Union The union of two sets A and B is the set whose elements are all of the elements in A or in B or in both. The union of sets A and B denoted by A Bisreadas“A union B”.Symbolically: A B = {x | x A or x B}

Example:If • A = {5, 7, 8}, B = {2, 7, 9, 11},Then, A B = {2, 5, 7, 8, 9, 10, 11}

Page 18: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

6

If • A = {x | x Z and x≥3}andB = {x | x Z and x≥8},Then, A B = {x | x Z, x≥3}Where, Z denoted the set of integers.

A ∪ BA B

Fig. 1.1 Venn diagram of union 1.11.2 IntersectionIf A and B are two sets, then the intersection (A B)isdefinedasasetofallthoseelementswhicharecommontoboth the sets.

Symbolically: A B = {x : x A and x B}

Example:A = {a,b,c,d,e}B = {a,e,i,ou}

A B = {a,e}

A BA ∩ B

Fig. 1.2 Venn diagram of intersection

1.11.3 DifferenceIf A and B are two sets, then the difference (A–B)isdefinedasasetofalltheelementsofA which are not in B.Symbolically: A–B = {x|x A and x B}

Example:A = {a,b,c,d,e,f}B = {a,c,i,o,u,k}

A–B = {b,d,e,f}

Page 19: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

7

A BA – B

Fig. 1.3 Venn diagram of difference

1.11.4 Symmetry DifferenceIf A and B are two sets, then the symmetric difference (A B)isdefinedasasetofallthoseelementswhichareeither in A or in B but not in both.

Symbolically: (A B) = (A–B) (B–A)

Example:A = {a,b,c,k,p,q,r,s}B = {b,k,q,m,n,o,t}So, (A–B) = {a,c,p,r,s} and (B–A) = {m,n,o,t}

(A B) = (A–B) (B–A) = {a,c,p,r,s,m,n,o,t}

AB

A ⊕ B

Fig. 1.4 Venn diagram of symmetric difference

1.11.5 Complement of a SetIf A is a set, then the complement of A is given as A′ or andisdefinedasasetofallthoseelementsoftheuniversalset U which are not in A.

Symbolically: = {x|x U and x A}

Example:A = {b,c,k,d,i,p,q,r,s,t}So, we can take the universal set U = {a,b,c,......,x,y,z}

= U – A = {a,e,f,g,h,j,l,m,n,o,u,v,w,x,y,z}

Page 20: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

8

A'U

A

Fig. 1.5 Venn diagram of complement of a set

Page 21: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

9

SummaryAsetisacollectionofwelldefinedobjects.•Each of the objects in the set is called a member or on element of the set.•A set • A is a subset of the set B if and only if every element of A is also an element of B.If • A is subset of B, then B is called a superset of A.The set with no elements is called an empty set or a null set.•A set having only one element is called a singleton.•Asetissaidtobefiniteifithasfinitenumberofelements.•The set of all subsets of a set • A is called the power set of A.Two sets are said to be disjoint if they have no element in common.•The union of two sets • A and B is the set whose elements are all of the elements in A or in B or in both.

ReferencesShankar Rao G., 2009.• DiscreteMathematicalStructure. New Age International.Acharjya & Sreekumar. D. P., 2009. • Fundamental Approach to DiscreteMathematics. New Age International. Lipschutz. S., 1997. • Schaum’sOutlineofDiscreteMathematics, 2nd ed., McGraw-Hill.Kolman B., 2008. • DiscreteMathematicalStructures, 6th ed., Prentice Hall.

Recommended ReadingNanda., 2002. • DiscreteMathematics. Allied Publishers.SetTheory• . Available at: <http://tedsider.org/teaching/st/st_notes.pdf>. [Accessed 5 April 2011].SetTheoryandVennDiagram• . Available at: <http://www.saskschools.ca/curr_content/mathb30/prob/les2/notes.html>. [Accessed 6 April 2011].Johnsonbaugh. Richard, 2008. • DiscreteMathematics, 7th ed., Prentice Hall.

Page 22: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

10

Self AssessmentA__________isacollectionofwelldefinedobjects.1.

subseta. finitesetb. singletonc. setd.

Elements of a set are denoted by __________.2. lower-case lettersa.

b. upper-case lettersc.

d.

Which symbol indicates the membership in a set?3. a. b. c. d.

Which of the following is true?4. If“a. a is an element of the set A”,thenwewritea A.If“b. a is an element of the set A”,thenwewritea A.If“c. a is an element of the set A”,thenwewritea A.If“d. a is an element of the set A”,thenwewritea A.

The symbol __________5. isreadas“isnotamemberof”or“isnotanelementof”.a. b. c. d.

If 6. x A x B, then __________. a. B A b. A B c. B A d. A B

Which of the following is false?7. A set a. A is called subset of the set B. If, A is set of B.A set b. A is called singleton of the set B. If, A is subset of B.A set c. A is called proper subset of the set B. If, A is subset of B.A set d. AisfinitesubsetofthesetB. If, A is subset of B.

Page 23: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

11

What is the set with no elements called?8. Empty set or null seta. Singleton b. Subsetc. Proper setd.

A set having only one element is called a ___________.9. empty set or null seta. singleton b. subsetc. universal setd.

Which of the following is true?10. Asetissaidtobefiniteifithasfinitenumberofelements.a. Asetisinfinite,ifitisnotfinite.b. The set of all subsets of a set c. A is called the power set of A.Asetisfinite,ifitisnotinfinite.d.

Page 24: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

12

Chapter II

Mathematical Logic

Aim

The aim of this chapter is to:

definestatement•

elaborate logical connectives/operations•

discuss conditional statement•

introduce duality law•

Objectives

The objectives of this chapter are to:

explain bi-conditional statement•

describe converse and inverse•

evaluate exclusive-or•

elaborate algebra of propositions•

Learning outcome

At the end of this chapter, the student will be able to:

describe NAND, NOR•

identify the use of tautology•

state De Morgan’s law•

Page 25: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

13

2.1 Statement (Proposition)A statement is a declarative sentence which is either true or false but not both. The statement is also known as proposition. The truth value True (T) and False (F) are denoted by the symbols T and F respectively. Sometimes it is also denoted by 1 and 0, where 1 stands for true and 0 stands for false. As it depends on only two possible truth values, we call it as two-valued logic or bi-valued logic.

Example:Sun rises in the east.i. May God bless you!ii. It is too hot today.iii.

Fromtheaboveexamples,itisobservedthat(i)isastatementasitdeclaresadefinitetruthvalueTorF.Theotherexample, (ii) and (iii) are not statements as they do not declare any truth value T or F. 2.2 Logical Connectives/OperationsAnother important aspect is logical connectives. Some logical connectives are used to connect several statements into a single statement. The most basic and fundamental connectives are Negation, Conjunction and Disjunction.

2.2.1 NegationIt is observed that the negation of a statement is also a statement. The connectives Not is used for negation. Usually the statements are denoted by single letters P, Q, R, etc. if P is a statement, then the negation of P is denoted as ¬P.

Example:P• : California is the capital of Australia.¬P• : California is not the capital of Australia.

Here, the truth value of statement P is false (F) and ¬P is true (T). From the above example, it is observed that P and ¬P has opposite truth values. ¬P can also be written as,

¬P: It is not true that California is the capital of Australia. Rule: If P is true, then ¬P is false and if P is false, then ¬P is true.

P ¬ P

TF

FT

Table 2.1 Truth table (Negation)

2.2.2 ConjunctionThe conjunction of two statements P and Q is also a statement denoted by (P Q). The connective And is used for conjunction.

Example:If • P and Q are two statements,P: 2 + 3 = 5Q: 5 is a composite number.

So, (P ˄ Q): 2 + 3 = 5 and 5 is a composite number.

Page 26: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

14

If • P: Max went to the college and Q: Sam went to the college,Then, (P ˄ Q): Max and Sam went to the college.

It is clear that (P˄ Q) stand for P and Q. In order to make (P˄ Q) true, P and Q have to be simultaneously true.

Rule: (P˄Q) is true if both P and Q are true, otherwise false.

P Q (P ˄ Q)

TTFF

TFTF

TFFF

Table 2.2 Truth table (Conjunction)

2.2.3 DisjunctionThe disjunction of two statements P and Q is also a statement denoted by (P Q). The connectives Or is used for disjunction.

Example:P: 2 + 3 is not equal to 5Q: 5 is a prime number

So, (P˅Q): 2 + 3 is not equal to 5 or 5 is a prime number.

It is observed that (P˅ Q) is true when P may be true or Q may be true and this also includes the case when both are true, that is the truth value of one statement is not assumed in exclusive of the truth value of the other statement.

Rule: (P˅Q) is true, if either P or Q is true and it is false when both P and Q are false.

P Q (P ˅Q)

TTFF

TFTF

TTTF

Table 2.3 Truth table (Disjunction)

2.3 ConditionalLet P and Q be any two statements. Then the statement P→Q is called a conditional statement. This can be put in any one of the following forms:

If • P, then QP• only if QP• implies QQ• if PIn an implication • P→Q is called the hypothesis (antecedent) and Q is called the consequent (conclusion).

Page 27: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

15

Example:Aboypromisesagirl,“IwilltakeyouforlunchonSaturday,ifitisnotraining”.Let us break the above conditional statement to symbolic form:

P: It is not raining.Q: I will take you for lunch on Saturday.

So, the above statement reduces to P→Q.

From the above discussion, it is observed that if P is false, then P→Q is true, whatever is the truth value of Q. The conditional P→Q is false, if P is true and Q is false.

Rule: An implication (conditional) P→Q is false only when the hypothesis (P) is true and conclusion (Q) is false, otherwise true.

P Q P → Q

TTFF

TFTF

TFTT

Table 2.4 Truth table (Conditional)

2.4 Bi-ConditionalLet P and Q be any two statements. Then the statement P Q is called a bi-conditional statement. This P Q can be put in any one of the following forms:

P• if and only if QP• isnecessaryandsufficientofQP• isnecessaryandsufficientforQP• implies and is implied by Q

The bi-conditional (double implication) P Qisdefinedas:(P Q): (P→Q) (Q→P)

P Q P → Q Q → P P ↔ Q

TTFF

TFTF

TFTT

TTFT

TFFT

Table 2.5 Truth table (Bi-conditional)

From the truth table discussed above, it is observed that P↔Q has the truth value T whenever both P and Q have identical truth values.

Rule: (P↔Q) is true only when P and Q have identical truth values, otherwise false.

Page 28: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

16

2.5 ConverseLet P and Q be any two statements. The converse statement of the conditional P→Q is given as Q→P.

Example:“Allconcurrenttrianglesaresimilar”.

Theabovestatementcanbewrittenas“iftrianglesaresimilar,thentheyareconcurrent”orallsimilartriangles•are concurrent.Let,•P: Triangles are concurrent.Q: Triangles are similar.

So, the statement becomes P→Q.Theconversestatementisgivenas“iftrianglesaresimilar,thentheyareconcurrentor all similar triangles are concurrent.

2.6 InverseLet P and Q be any two statements. The inverse statement of the conditional (P→Q) is given as (¬P→¬Q).

Example:“Allconcurrenttrianglesaresimilar”.

Theabovestatementcanalsobewrittenas“iftrianglesareconcurrent,thentheyaresimilar”.•Let,•P: Triangles are concurrent.Q: Triangles are similar.

So, the statement becomes P→Q.Theinversestatementisgivenas“iftrianglesarenotconcurrent,thentheyarenotsimilar”.

2.7 Exclusive ORLet P and Q be any two statements. The exclusive OR of two statements P and Q is denoted by (P –˅ Q). The connective XOR is used for exclusive OR. The exclusive OR (P –˅Q) is true if either P or Q is true but not both. The exclusive OR is also termed as exclusive disjunction.

Example:P and Q be two statements such that,

P 2 + 3 = 5Q 5 – 3 = 2

Here, both the statements are true.

(P–˅ Q) is false.

Rule: (P–˅Q) is true if either P or Q is true but not both, otherwise false.

Page 29: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

17

P Q (P –˅ Q)TTFF

TFTF

FTTF

Table 2.6 Truth table (Exclusive OR)

2.8 NANDThe word NAND stands for NOT and AND. The connective NAND is denoted by the symbol ↑. If P and Q are two statements, then NAND of P and Q is given as (P↑ Q)definedas:

(P↑ Q) ¬ (P Q)

Rule: (P↑ Q) is true if either P or Q is false, otherwise false.

P Q (P ↑ Q)

TTFF

TFTF

FTTT

Table 2.7 Truth table (Nand)

2.9 NORNORstandsforNOTandOR.TheconnectiveNORisdenotedbythesymbol↓.IfP and Q are two statements, then Nor OF P AND Q is given as (P↓Q)definedby,

(P↓Q) ¬ (P Q)

Rule: (P Q) is true only when both P and Q are false, otherwise false.

P Q (P ↓Q)

T T FT F FF T FF F T

Table 2.8 Truth table (NOR)

2.10 TautologyIf the truth values of a composite statement are always true irrespective of the truth values of the atomic (individual) statements, then it is called a tautology.

Example:The composite statement (P (P→Q))→Q is a tautology. To verify this, the truth table is drawn with composite statement as (P (P→Q))→Q.

Therefore, (P (P→Q))→Q is a tautology.

Page 30: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

18

P Q (P→Q) P ˄ (P → Q) (P ˄ (P → Q)) → Q

TTFF

TFTF

TFTT

TFFF

TTTT

Table 2.9 Truth table (Tautology)

2.11 ContradictionIf the truth values of a composite statement are always false irrespective of the truth values of the atomic statements, then it is called a contradiction.

Example:The composite statement ¬ (P→(Q→(P Q))) is a contradiction.Toverifythis,thetruthtableisdrawnof¬(P→(Q→(P Q))).

Let,R P→(Q→(P Q))So, ¬ R ¬ (P→(Q→(P Q))) is a contradiction.

P Q (P ˄ Q) Q → (P ˄ Q) (P → (Q →(P ˄ Q))) ¬ R

T T T T T FT F F T T FF T F F T FF F F T T F

Table 2.10 Truth table (Contradiction)

2.12 Duality LawTwo formulae P and P* are said to be duals of each other if either one can be obtained from the other by interchanging

by and by . The two connectives and are called dual to each other.

Consider the formulae,P (P Q) R and P* (P Q) R, are dual to each other.

2.13 Algebra of PropositionsIf P, Q, R are three statements, then,

Commutative Laws: • P Q Q P and P Q Q P

Associative Laws: • P (Q R) (P Q) R and P (Q R) (P Q) R

Distributive Laws: • P (Q R) (P Q) (P R) and P (Q R) (P Q) (P R)

Idempotent Laws: • P P P and P P P

Absorption Laws: • P (P Q) P and P (P Q) P

Page 31: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

19

2.13.1 De Morgan’s LawsIf P and Q are two statements, then

¬ (• P Q) (¬ P) (¬ Q) and¬ (• P Q) (¬ P) (¬ Q)

2.14 Mathematical Induction

Generallydirectmethods are adopted forproving theoremsandpropositions.Sometimes it is toodifficult•and tedious. As a result the other methods are developed for proving theorems and propositions. These are as follows:

Method of contra positive �Method of contradiction �Method of induction �

Here, we will discuss method of induction.

The method of induction is otherwise known as mathematical induction.Suppose that n is a natural number. Our aim is to show that some statement P(n) involving n is true for any n. The following steps are followed in mathematical induction.

Suppose that • P(n) be a statement.Show that • P(1) and P(2) are true i.e., P(n) is true for n = 1 and n = 2.Assume that • P(k) is true i.e., P(n) is true for n = k.Show that • P(k + 1) follows from P(k).

Example:1 + 2 + 3 + ............... + n =

Suppose that P(n) 1 + 2 + 3 + ........... + n =

So, P(1) 1 =

And P(2) 1 + 2 + 3 =

So, P(1) and P(2) are true.

Assume that P(k) is true, so,

1 + 2 + 3 + ............ + k =

So, P(k + 1) 1 + 2 + 3 + ........... + k + (k + 1)

= + (k + 1) [ P(k) is true.]

= (k + 2) =

Which shows that P(k + 1) is also true.

Hence, P(n) is true for all n.

Page 32: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

20

SummaryThe truth value True and False are denoted by the symbols T and F respectively.•The most basic and fundamental connectives are Negation, Conjunction and Disjunction.•It is observed that the negation of a statement is also a statement.•The connectives • Not is used for negation.The conjunction of two statements • P and Q is also a statement denoted by (P Q). The connective And is used for conjunction.The disjunction of two statements • P and Q is also a statement denoted by (P Q). The connectives Or is used for disjunction.The converse statement of the conditional • P→Q is given as Q→P.The inverse statement of the conditional (• P→Q) is given as (¬P→¬Q).The exclusive • OR of two statements P and Q is denoted by (P Q).The word • NAND stands for NOT and AND.NOR stands for NOT and OR. The connective NOR is denoted by the symbol• .

ReferencesShankar Rao G., 2009.• DiscreteMathematicalStructure. New Age International.Acharjya & Sreekumar. D. P., 2009. • Fundamental Approach to DiscreteMathematics. New Age International. Lipschutz. S., 1997. • Schaum’sOutlineofDiscreteMathematics, 2nd Edition, McGraw-Hill.Kolman B., 2008. • DiscreteMathematicalStructures, 6th Edition, Prentice Hall.

Recommended ReadingRosen Kenneth, 2006. • DiscreteMathematicsandItsApplications, 6th Edition, McGraw-Hill.Mathematical Logic• . Available at: <http://www.math.umn.edu/~jodeit/course/ACaRA01.pdf> [Accessed 6 April 2011].MathematicalLogic• . Available at: <http://www.algebraworkbench.net/download/n41main.pdf> [Accessed 7 April 2011].MathematicalLogic• . Available at: <http://www.mathgoodies.com/lessons/toc_vol9.html> [Accessed 7 April 2011].

Page 33: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

21

Self AssessmentA __________ is a declarative sentence which is either true or false but not both.1.

finiteseta. statementb. setc. subsetd.

The statement is also known as __________.2. propositiona. statementb. setc. subsetd.

What is the connective 3. Not used for?Conjunction a. Disjunction b. Bi-conditional statement c. Negationd.

Which of the following is true?4. If a. P is false, then ¬P is also false and if P is true, then ¬P is also true.If b. P is true, then ¬P is false and if P is false, then ¬P is false.If c. P is true, then ¬P is false and if P is false, then ¬P is true.If d. P is true, then ¬P is true and if P is false, then ¬P is true.

How is the conjunction of two statements 5. A and B denoted by?(a. P Q)(b. P Q)(c. P Q)(d. P Q)

Which of the following is false?6. (a. P Q) is true if both P and Q are true, otherwise false.(b. P Q) is false if both P and Q are true.(c. P Q) is true, if either P or Q is true and it is false when both P and Q are false.An implication (conditional) d. P→Q is false only when the hypothesis (P) is true and conclusion (Q) is false, otherwise true.

Which of the following is true?7. (a. P Q) is false only when P and Q have identical truth values, otherwise true.(b. P Q) is true only when P and Q have identical truth values, otherwise false.(c. P Q) is true only when P and Q have identical truth values, otherwise false.(d. P Q) is true only when P and Q have identical truth values, otherwise false.

Page 34: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

22

How is the inverse statement of the conditional (8. P→Q) given?(¬a. P→¬Q)(b. P Q)(c. P Q)(d. P Q)

Which of the following is false?9. The word a. NAND stands for NOT and AND.The connective b. NAND is denoted by the symbol .The connective c. NAND is denoted by the symbol .(d. P Q) is true if either P or Q is false, otherwise false.

If 10. P and Q are two statements, then NAND of P and Q is given as (P Q)definedby,____________.(a. P Q) (P Q)(b. P Q) (P Q)(c. P Q) ¬ (P Q)(d. P Q) ¬ (P Q)

Page 35: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

23

Chapter III

Techniques of Counting

Aim

The aim of this chapter is to:

determine basic counting principles•

introduce the mathematical functions•

discussbinomialcoefficient•

Objectives

The objectives of this chapter are to:

describebinomialcoefficientsandPascal’striangle•

discuss permutation•

introduce the Pigeonhole Principle•

Learning outcome

At the end of this chapter, the students will be able to:

learn about combination •

discuss recurrence relations in detail•

explainlinearrecurrencerelationswithConstantcoefficients•

Page 36: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

24

3.1 IntroductionThis chapter develops some techniques for determining, without direct enumeration, the number of possible outcomes of a particular event or the number of elements in a set. Such sophisticated counting is sometimes called combinatorial analysis. It includes the study of permutations and combinations.

3.2 Basic Counting PrinciplesTherearetwobasiccountingprinciples.Thefirstoneinvolvesadditionandthesecondonemultiplication.

Sum Rule Principle

Suppose some event E can occur in m ways and a second event F can occur in n ways and suppose both events cannot occur simultaneously, then E or F can occur in m + n ways.

Product Rule Principle

Suppose there is an event E which can occur in m ways and, independence of this event, there is a second event F which can occur in n ways. Then combinations of E and F can occur in mn ways.

The above principles can be extended to three or more event. That is, suppose an event • can occur in ways, a second event can occur in ways, and, following ; a third event can occur in ways and so on. Then:Sum Rule: If no two events can occur at the same time, then one of the events can occur in:•

+ + + ........ waysProduct Rule: If the events occur one after the other, then all the events can occur in the order indicated in:•

∙ ∙ ∙............ways

3.3 Mathematical FunctionsDifferent mathematical functions are discussed below:

3.3.1 Factorial Functions

The product of the positive integers from 1 to • n inclusive is denoted by n!,read“nfactorial.”Namely:n!=1∙2∙3∙.............∙(n – 2)(n – 1)n = n(n – 1)(n-2)∙.............∙3∙2∙1

Accordingly, 1! = 1 and • n! = n(n–1)!.Itisalsoconvenienttodefine0!=1.

Example:3!=3∙2∙1=6,4!=4∙3∙2∙1=24,5=5∙4!=5(24)=120.i.

ii. = = and, more generally,

= =

For large n, one uses Stirling’s approximation (where iii. e = 2.7128...):

N! =

Page 37: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

25

3.3.2BinomialCoefficients

The symbol• , read“nCr”or“n Choose r”,wherer and n are positive integers with r≤n, isdefinedasfollows:

= or equivalently

Lemma 5.1:•

= or equivalent, = where a + b = n.

Motivatedbythatfactthatwedefined0!=1,wedefine:

= = 1 and = = 1

Example:

• = = 28; = 126; = = 792

Note that has exactly r factors in both the numerators and the denominators.Suppose we want to compute• . There will be 7 factors in both the numerator and the denominator.However, 10 – 7 = 3. Thus, we use Lemma 5.1 to compute.•

3.3.3BinomialCoefficientsandPascal’sTriangleThe numbers arecalledbinomialcoefficients,sincetheyappearasthecoefficientsintheexpansionof .Binomial Theorem: =

Thecoefficientsofthesuccessivepowersofa + b can be arranged in a triangular array of numbers, called Pascal’s triangle. The numbers in Pascal’s triangle have the following interesting properties:

Thefirstandlastnumberineachrowis1.•Every other number can be obtained by adding the two numbers appearing above it.•

Example:10 = 4 + 6, 15 = 5 + 10, 20 = 10 + 10Sincethesenumbersarebinomialcoefficients,westatetheabovepropertynormally.

3.4 PermutationsAny arrangement of a set of n objects in a given order is called a permutation of the object. Any arrangement of any r≤noftheobjectsinagivenorderiscalledan“r-permutation”or“apermutationofthen objects taken r at atime.”

Example:For the set of letters A, B, C, D:

BDCA, DCBA and ACDB are permutations of the four letters (taken all at a time). �BAD, ACB, DBC are permutations of the four letters taken three at a time. �AD, BC, CA are permutations of the four letters taken two at a time. �

We usually are interested in the number of such permutations without listing them. the number of permutations •of n objects taken r at a time will be denoted by,P(n , r)

Page 38: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

26

The following theorem applies:•Theorem:P(n , r) = n(n – 1)(n – 2) ... (n – r + 1) =

We emphasise that there are r factors in n(n – 1)(n – 2) ... (n – r + 1)

Example:Findthenumbernofpermutationsofsixobjects,say,A,B,C,D,E,F,takenthreeatatime.Inotherwords,findthenumberof“three-letterwords”usingonlythegivensixletterswithoutrepetition.Letsusrepresentthegeneralthree-letter word by following three positions:

_______, _______, _______

Thefirstlettercanbechosenin6ways;followingthisthesecondlettercanbechosenin5ways;and,finally,thethird letter can be chosen in 4 ways. Write each number in its appropriate position as follows:

6, 5, 4

By the Product Rule, there are m=6∙5∙4=120possiblethree-letterwordswithoutrepletionfromthesixletters.Namely, there are 120 permutations of 6 objects taken 3 at a time. This agrees with the formula in the theorem given below:

Theorem:P(6,3)=6∙5∙4=120In fact, this theorem is proven in the same manner as it is done for this particular case.Consider the special case of P(n , r) when r = n. We get the following result.

Corollary: There are n! permutations of n objects.

Example:There are 3! = 6 permutations of the three letters A, B, C, these are:ABC, ACB, BAC, BCA, CAB, CBA

3.4.1 Permutation with RepetitionsFrequently we want to know the number of permutations of a mutiset, that is, a set of objects some of which are alike. We will let, P(n; , , ...., ) denote the number of permutations of n objects of which are alike, are alike,..., are alike. The general formula follows:

Theorem:P(n; , , ...., ) =

Weindicatetheproofoftheabovetheorembyaparticularexample.Supposewewanttoformallpossiblefive-letter“words”usingthelettersfromtheword“BABBY”.Nowthereare5!=120permutationsoftheobjects , A, , , Y, where the three B’s are distinguished. Observe that the following six permutations:

, AY, AY,

These permutations produce the same word when the subscripts are removed. The 6 comes from the fact that these are3!=3∙2∙1=6differentwaysofplacingthethreeB’sinthefirstthreepositionsinthepermutation.Thisistruefor each set of three positions in which B’scanappear.Accordingly,thenumberofdifferentfive-letterwordsthatcanbeformedusingthelettersfromtheword“BABBY”is:

P(5; 3) = = 20

Page 39: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

27

Example:Find the number mofseven-letterwordsthatcanbeformedusingthelettersoftheword“BENZENE”We seek the number of permutations of 7 objects of which 3 are alike (the three E’s) and 2 are alike (the two N’s). By theorem given above,

m = P(7; 3, 2) = = = 420

3.5 CombinationsLet S be a set with n elements. A combination of these n elements taken r at a time is any selection of r of the elements where order does not count. Such a selection is called an r-connection; it is simply a subset of S with r elements. The number of such combinations will be denoted by:

C(n,r)

Before we give the general formula for C(n,r), we consider a special case.

Example:Find the number of combinations of 4 objects, A, B, C, D, taken 3 at a time. Each combination of three objects determines 3! = 6 permutations of the objects as follows: ABC: ABC, ACB, BAC, BCA, CAB, CBA ABD: ABD, ADB, BAD, BDA, DAB, DBA ACD: ACD, ADC, CAD, CDA, DAC, DCA BCD: BDC, BCC, CBD, CDB, DBC, DCB

Thus, the number of combinations multiplied by 3! Gives us the number of permutations; that is,

C(4,3)∙3!=P(4, 3) or C(4, 3) =

But P(4,3)=4∙3∙2=24and3!=6;Hence C(4, 3) = 4 as noted above.

As indicated above, any combination of n objects taken r at a time determines r! Permutations of the objects in the combination; that is,

P(n,r) = r! C(n,r)

Accordingly, we obtain the following formula for C(n,r) which we formally state as a theorem.

Theorem:C(n,r) =

Recallthatthebinomialcoefficient wasdefinedtobe ; hence,

C(r,n) =

We shall use C(n,r) and interchangeably.

Page 40: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

28

Example:A farmer buys 3 cows, 2 pigs and 4 hens from a man who has 6 cows, 5 pigs and 8 hens. Find the number m of choices that the farmer has.

The farmer can choose the cows in C(6, 3) ways, the pigs in C(5, 2) ways and the hens in C(8, 4) ways. Thus, the number m of choices follows:

m = = = 20

3.6 The Pigeonhole PrincipleMany results in combinational theory come from the following statement:

Pigeonhole principle: If n pigeonholes are occupied by n + 1 or more pigeons, then at least one pigeonhole is occupied by more than one pigeon.

This principle can be applied to many problems where we want to know that a given situation can occur.

Example:Suppose a department contains 13 professors, then two of the professors (pigeons) were born in the same month •(pigeonholes).Find the maximum number of elements that one needs to take from the set • S = {1, 2, 3,.......,9} to be sure that two of the numbers add up to 10.

Here,thepigeonholesarethefivesets{1,9},{2,8},{3,7},{4,6},{5}.Thus,anychoiceofsixelements(pigeons)of S will guarantee that two of the numbers add up to ten.

Generalised Pigeonhole principle: If n pigeonholes are occupied by kn + 1 or more pigeons, where k is a positive integer, then at least one pigeonhole is occupied by k + 1 or more pigeons.

Example:Find the maximum number of students in a class to be sure that three of them are born in the same month.

Here, the n = 12 months are the pigeonholes and k + 1 = 3 so k = 2. Hence among any kn + 1 = 25 students (pigeons), three of them are born in the same month.

3.7 Recurrence RelationsFactorialfunctions,FibonaccisequenceandAckermannfunctionarerecursivelydefinedfunctions.

Herewediscusscertainkindsofrecursivelydefinedsequences{ } and their solutions. We note that a sequence is simply a function whose domain is,

N = {1, 2, 3, ....} or = N {0} = {0, 1, 2, 3, ...}

Example:Consider the following sequence which begins with the number 3 and for which each of the following terms is found by multiplying the previous term by 2;

3, 6, 12, 24, 48, ........

Page 41: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

29

Itcanbedefinedrecursivelyby: = 3, = 2 for k≥1 or = 3, = 2 for k≥0

Theseconddefinitionmaybeobtainedfromthefirstbysettingk = k + 1. Clearly, the formula = 3( ) gives us the nth term of the sequence without calculating any previous term.

The following remarks about the above example are in order:The equation • = 2 or, equivalently, = 2 ,whereonetermofthesequenceisdefinedintermsofprevioustermsofthesequence,iscalleda“recurrencerelation”.The equation • =3,whichgivesaspecificvaluetooneoftheterms,iscalledan“initialcondition”.The function • = 3( , which gives a formula for as a function of n, not of previous terms, is called a “solution”oftherecurrencerelation.There may be many sequences which satisfy a given recurrence relation.•Ontheotherhand,theremaybeonlyauniquesolutiontoarecurrencerelationwhichalsosatisfiesgiveninitial•conditions.

3.8LinearRecurrenceRelationswithConstantcoefficientsA recurrence relation of order k is a function of the form,

= ( , ,......., , n)

that is, where the nth term of a sequence is a function of the preceding k terms , ,......., . In particular, a linear kth-orderrecurrencerelationwithConstantcoefficientsisarecurrencerelationoftheform,

= + + ....... + + f(n)

where , , ....., are constants with 0 and f(n) is a function of n. The meanings of the names linear and Constantcoefficientsfollow:

Linear: There are no powers or products of the • ’s.Constantcoefficients:The• , , ....., are constants (do not depend on n).If • f (n) = 0, then the ratios are also said to be homogenous.Clearly, we can uniquely solve for • if we know the values of , ,..... . Accordingly, by mathematical induction, there is a unique sequence satisfying the recurrence relation if we are given initial valuesforthefirstk elements of the sequence.

Page 42: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

30

SummarySum Rule Principle: Suppose some event • E can occur in m ways and a second event F can occur in n ways and suppose both events cannot occur simultaneously, then E or F can occur in m + n ways.Product Rule Principle: Suppose there is an event • E which can occur in m ways and, independence of this event, there is a second event F which can occur in n ways. Then combinations of E and F can occur in mn ways.The product of the positive integers from 1 to • n inclusive is denoted by n!,read“nfactorial.”The numbers • arecalledbinomialcoefficients,sincetheyappearasthecoefficientsintheexpansionof

.Pigeonhole Principle: If • n pigeonholes are occupied by n + 1 or more pigeons, then at least one pigeonhole is occupied by more than one pigeon.

ReferencesShankar Rao G., 2009.• DiscreteMathematicalStructure. New Age International.Acharjya & Sreekumar. D. P., 2009. • Fundamental Approach to DiscreteMathematics. New Age International. Lipschutz. S., 1997. • Schaum’sOutlineofDiscreteMathematics, 2nd Edition, McGraw-Hill.Kolman B., 2008. • DiscreteMathematicalStructures, 6th Edition, Prentice Hall.

Recommended ReadingNanda, 2002. • DiscreteMathematics. Allied Publishers.CountingMethods• . Available at: <http://hanlonmath.com/pdfFiles/281Ch.8CountingMethods.pdf> [Accessed 7 April 2011].Stats:Counting Techniques• . Available at: <http://people.richland.edu/james/lecture/m170/ch04-not.html> [Accessed 8 April 2011].ProbabilitiesUsingCountingTechniques• . Available at: <http://mdm4u1.wetpaint.com/page/6.3+Probabilities+Using+Counting+Techniques> [Accessed 7 April 2011].

Page 43: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

31

Self AssessmentWhich of the following is true?1.

If no two events can occur at the same time, then one of the events can occur in: a. + + + ........ ways; this is known as sum rule.If no two events can occur at the same time, then one of the events can occur in: b. + + + ........ ways; this is known as product rule.If no two events can occur at the same time, then one of the events can occur in: c. + + + ........ ways; this is known as division rule.If no two events can occur at the same time, then one of the events can occur in: d. + + + ........ ways;thisisknownasbinomialcoefficientrule.

Binomial theorem is ____________.2.

a. =

b. =

c. =

d. =

Which of the following is false?3. Thecoefficientsofthesuccessivepowersofa. a + b can be arranged in a triangular array of numbers, called Pascal’s triangle.InPascal’striangle,firstandlastnumberineachrowis1.b. InPascal’striangle,firstandlastnumberineachrowis0.c. In Pascal’s triangle, other number can be obtained by adding the two numbers appearing above it.d.

Which of the following is true?4. Any arrangement of a set of a. n objects in a given order is called a permutation of the object.Any arrangement of any b. r noftheobjectsinagivenorderiscalledan“r-permutation”or“apermutationof the n objects taken ratatime.”Any arrangement of any c. r noftheobjectsinagivenorderiscalledan“r-permutation”or“apermutationof the n objects taken ratatime.”Any arrangement of any d. r noftheobjectsinagivenorderiscalledan“r-permutation”or“apermutationof the n objects taken ratatime.”

Which of the following is true?5.

Any arrangement of any a. r noftheobjectsinagivenorderiscalledan“r-permutation”or“apermutationof the n objects taken ratatime.”Any arrangement of any b. r≤noftheobjectsinagivenorderiscalledan“r-permutation”or“apermutationof the n objects taken ratatime.”Any arrangement of any c. r noftheobjectsinagivenorderiscalledan“r-permutation”or“apermutationof the n objects taken ratatime.”Any arrangement of any d. r noftheobjectsinagivenorderiscalledan“r-permutation”or“apermutationof the n objects taken ratatime.”

Page 44: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

32

Which of the following is false?6. If a. n pigeonholes are occupied by n + 1 or more pigeons, then at least one pigeonhole is occupied by more than one pigeon.If b. n pigeonholes are occupied by kn + 1 or more pigeons, where k is a positive integer, then at least one pigeonhole is occupied by k + 1 or more pigeons.Factorialfunctions,FibonaccisequenceandAckermannfunctionarerecursivelydefinedfunctions.c. If d. n pigeonholes are occupied by k + 1 or more pigeons, where k is a positive integer, then at least one pigeonhole is occupied by kn + 1 or more pigeons.

The equation 7. = 2 or, equivalently, = 2 ,whereonetermofthesequenceisdefinedintermsofprevious terms of the sequence, is called ___________.

initial conditiona. solution of the recurrence relationb. recurrence relationc. pigeonholed.

The equation 8. =3,whichgivesaspecificvaluetooneoftheterms,iscalled____________.recurrence relationa. initial conditionb. solution of the recurrence relationc. pigeonholed.

The function 9. = 3( , which gives a formula for as a function of n, not of previous terms, is called a ___________.

solution of the recurrence relationa. pigeonholeb. recurrence relationc. initial conditiond.

There may be many sequences which satisfy a given _____________.10. solution of the recurrence relationa. pigeonholeb. recurrence relationc. initial conditiond.

Page 45: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

33

Chapter IV

Relations and Diagraph

Aim

The aim of this chapter is to:

introduce the concept of relation•

elaborate properties of relations•

discuss pictorial representatives of relations•

Objectives

The objectives of this chapter are to:

describe relations on • r

discusspicturesofrelationsonfinitesets•

explain relations and digraphs•

illustrate matrix representation of relations•

Learning outcome

At the end of this chapter, the students will be able to:

determine paths in relations and digraph•

explain equivalence relations•

describe transitive extensions•

Page 46: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

34

4.1 Concept of RelationA relation may involve equality or inequality. The mathematical concept of a relation deals with the way the variables arerelatedorpaired.Arelationmaysignifyafamilytiebetween,suchas“isthesonof”,“isthebrotherof”,“isthesisterof”.Inmathematicstheexpressionslike,“islessthan”,“isgreaterthan”,“isperpendicularto”,“isparallelto”arerelations.

Definition:LetA and B be non-empty sets, then any subset of R of the Cartesian product A B is called a relation from A to B.

Example:Let • A = {3, 6, 9}, B = {4, 8, 12}Then R = {(3, 4), (3, 8), (4, 12)} is a relation from A to B.

If • A = {1, 2, 3}, B = {a,b}Then A B = {(1, a), (1, b), (2, a), (2, b), (3, a), (3, b)}If R = {(1, a), (3, b)}, then R A B and R is a relation from A to B.

Let • Adenotethesetofrealnumbersdefining:R = {(a, b): 4 + 25 ≤100}clearlyR is a relation on A.If (a, b) R,weoftenwriteaRbandstate“a is related to B”.If R A A, then R is a relation from A to A and R is called a relation in A.

If R is a relation from A to B,thenthesetofallfirstelementsoftheorderedpairs(a, b), which belong to R is called the domain of R. The range of R is the set of all second coordinates of the ordered pairs (a, b) which belong to R. FromthedefinitionitisclearthatrelationR is also a set and many operations can be applied to relation R to obtain a new relation.

If and are two relations with the same domain Dandsamerangethenwecandefinetherelationas .

Null set isasubsettoeveryset.Thereforeforanyspecifiednon-emptydomainandrange, is a relation, called null relation or empty relation.

4.2 Properties of RelationsThere are six properties of relation, namely:

Reflexiverelation•Symmetric relation•Transitive relation•Equivalence relation•Anti-symmetric relation•Inverse relation•

4.2.1ReflexiveRelationLet RbearelationdefinedinasetA; then RisreflexiveifaRa holds for all a A i.e., if (a, a) R for all a A.

Example:Let A = {a, b, c} and R = {(a, a), (b, b), (c, c)} then RisareflexiverelationinA.

Page 47: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

35

Example:‘Equality’isareflexiverelation,sinceanelementequalsitself.

4.2.2 Symmetric RelationA relation RdefinedinsetA is said to be ‘symmetric’ if bRa holds whenever aRb holds for b A, i.e., R is symmetric in A if,

(a, b) R (b, a) R

Example:Let Rberotation“isperpendicularto”inthesetofallstraightlines,thenR is a symmetric relation.

4.2.3 Transitive RelationDefinition:ArelationRinsetAissaidtobetransitiveif,

(a, b) R (b, c) R (a, c) Ri.e., if aRb and bRc aRc, a, b, c R

Example:Let A denote the set of straight lines in a plane and R be a relation in Adefinedby“isparallelto”thenR is a transitive relation in A.

Example:Let A = {1, 2, 3} and R = {(1, 1), (2, 2), (2, 3), (3, 2), (3, 3)} then R is transitive.

4.2.4 Equivalence RelationArelationRinasetAissaidtobeanequivalencerelationinA,ifRisreflexivesymmetricandtransitive.

Example:Let • A be the set of all triangle in plane and let R be a relation in Adefinedby“iscongruentto”,thenRisreflexive,symmetric and transitive.

R is an Equivalence relation in A.

Let • A = {a, b, c} and R = {(a, a), (a, b), (b, a), (b, b), (b, c), (c, a), (c, c)} then R is an equivalence relation in A.

4.2.5 Anti-Symmetric RelationLet R be a relation in a set A, then R is called anti-symmetric.

(a, b) R, (b, a) R a = b a, b Ri.e., aRb and bRb a=b

Example:Let N denote the set of natural numbers R be a relation in N,definedby“aisadivisor”ofb, i.e., aRb if a divides b then R is anti-symmetric since a divided b and b divided a a=b.

4.2.6 Inverse Relation

Let R be a relation from A to B. Then the relation = {(b, a): (a, b) R} from B to A is called the inverse of R.

Example:Let A = {1, 2, 3}, B = {4, 5} and R = {(1, 4), (2, 5), (3, 5)} be a relation from A to B.Then, = {(4, 1), (5, 2), (5, 3)}

Page 48: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

36

4.3 Pictorial Representatives of RelationsVarious ways of picturing relations are as described below.

4.3.1 Relations on RLet S be a relation on the set R of real numbers; that is, S is a subset of = R R. Frequently, S consists of all ordered pairs of real numbers which satisfy some given equation E(x, y) = 0 (such as, + = 25).

Since can be represented by the set of points in the plane, we can picture S by emphasising those points in the plane which belong to S. The pictorial representation of the relation is sometimes called the graph of the relation.

Example: The graph of the relation + = 25 is a circle having its centre at the origin and radius 5. Refer to the following figure(a)forinstance.

1

3 4

2

y

x

5

50

x2 + y2 = 25(a) (b)

–5

–5

4.3.2 Directed Graphs of Relations in SetsThere is an important way of picturing a relation Ronafiniteset.Firstwewritedowntheelementsofthesetandthen we draw an arrow from each element x to each element y whenever x is related to y. This diagram is called the “directedgraph”oftherelation.

Example:Theabovefigure(b),whichshowsthedirectedgraphofthefollowingrelationR on the set A = {1, 2, 3, 4}.R = {(1, 2), (2, 2), (2, 4), (3, 2), (3, 4), (4, 1), (4, 3)}Observe that there is an arrow from 2 to itself, since 2 is related to 2 under R. 4.3.3 Pictures of Relations on Finite SetsSuppose A and Barefinitesets.TherearetwowaysofpicturingarelationR from A to B.

Form a rectangular array (matrix) whose rows are labelled by the elements of • A and whose columns are labelled by the elements of B. Put 1 or 0 in each position of the array accordingly as, a A is or is not related to b B. Thisarrayiscalledthe“matrixoftherelation”.Write down the elements of • A and the elements of B in two disjoint disks and then draw an arrow from a A to b B whenever a is related to b.Thispicturewillbecalledthe“arrowdiagram”oftherelation.

Fig.4.1Relationsonfinitesets

Page 49: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

37

4.4 Composition of RelationsLet A, B and C be sets and let R be a relation from A to B and let S be a relation from B to C. That is, R is a subset of A

B and S is a subset of B C. Then R and S give rise to a relation from A to C denoted by R Sanddefinedby:

A(R S)c if for some b B we have aRb and bSc.

That is, R S = {(a, c) | there exists b B for which (a, b) R and (b, c) S}

The relation R S,iscalledthe“composition”ofR and S; it is sometimes denoted simply by RS.

Suppose R is a relation on a set A. That is, R is a relation from a set A to itself. Then R R, the composition of R with itself,isalwaysdefined.Also,R R is sometimes denoted by . Similarly, = R = R R R and so on. Thus,

isdefinedforallpositiven.

4.5 Relations and DigraphsA relation can be represented pictorially by drawing its graph.

Let R be a relation on the set A = { , ,..., }. The element of A are represented by points (or circles) called nodes (or vertices). If ( , ) then we connect the vertices and by means of an arc and put an arrow in the direction from to . If ( , ) R and ( , ) R then we draw two arcs between and starts from node and relatives to node . When all the nodes corresponding to the ordered pairs in R are connected by arcs with proper arrows, we get a graph of the relation R. If Risreflexive,thentheremustbealoopateachnodeinthegraph of R. If R is symmetric, then ( , ) implies ( , ) R and the nodes and will be connected by two arcs (edges) one from to and the other from to .

Example:Let A = {a, b, d} and R be a relation on A given by, R = {(a, b), (a, d), (b, d), (d, a), (d, d)}. Construct the digraph of R.

Solution:SeethefigurewhichisgivenbelowforthedigraphofR.

Example:Let A = {1, 2, 3, 4}, R = {(1, 1), (1, 2), (2, 1), (2, 2), (2, 3), (2, 4), (3, 4), (4, 1), (4, 4)}. Construct the digraph of R.

Solution:ReferthefollowingfigureforthedigraphofR.

Page 50: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

38

Example:Findtherelationdeterminedbythegivenfigure.

Solution: The relation R of the digraph is, R = {(a, a), (a, c), (b, c), (c, b), (c, c), (d, c)}

4.6 Paths in Relations and DigraphIf R is a relation on a set A, a path of length n in R from to isafinitesequenceP: , , ,....., , , beginning with and ending with such that:

R , R ,..........., R

A path in a digraph of the relation R is succession of edges, where the indicated directions of the edges are followed. The length of a path in a digraph is the number of edges in the path. If n is a positive integer then the relation on the set Acanbedefinedasfollows:

( , ) ,

means there is a path of length n from to in R.

The relation canbedefinedonA, by letting ( , ) means, that there is some path in R from to .

Definition: A cycle in a digraph is a path of length n≥1fromavertextoitself.

Example:Let A = {1, 2, 3, 4, 5} and R = {(1, 2), (1, 2), (2, 3), (3, 5), (3, 4), (4, 5)}Compute (a) , (b)

Page 51: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

39

Solution: The digraph of Risshowninthefollowingfigure:

2

3

1

4

5

(1, 1) R and (1, 1) R (1, 1) (1, 1) R and (1, 2) R (1, 1) (1, 2) R and (2, 3) R (1, 1) (2, 3) R and (3, 5) R (1, 1) (2, 3) R and (3, 4) R (1, 1) (3, 4) R and (4, 5) R (1, 1)

Hence = {(1, 1), (1, 2), (1, 3), (2, 5), (2, 4), (3, 5)}

(b) There is a path from 1 to 4 (1, 4) , whose length is 3.There is a path from 1 to 5 , whose length is 3 andThere is a path from 1 to 5 whose length is 5.

Hence = {(1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (2, 3), (2, 4), (2, 5), (3, 4), (3, 5), (4, 5)}

4.7 Equivalence RelationsConsider a nonempty set S. A relation R on S is an equivalence relation if Risreflexive,symmetricandtransitive.That is, R is an equivalence relation on S if it has the following three properties:

For every • a S, aRaIf • aRb, then bRaIf • aRb and bRc, then aRc

Thegeneralideabehindanequivalencerelationisthatitisaclassificationofobjectswhichareinsomeway“alike”.Infact,therelation“=”ofequityonanysetSisanequivalencerelation;thatis:

A• = a for every a SIf • a=b, then b=aIf • a=b, b=c, then a=c

Example:Let • L be the set of line and let T be the set of triangles in the Euclidean plane.

Therelation“isparalleltooridenticalto”isanequivalencerelationon � L.The relations of congruence and similarity are equivalence relations on � T.

The relation • ofsetinclusionisnotanequivalencerelation.Itisreflexiveandtransitive,butitisnotsymmetricsince A B does not imply B A.

Page 52: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

40

Let • mbeafixedpositiveinteger.Twointegersa and b are said to be congruentmodulom, written, A b (mod m), If m divides a–b.

Example:For the modulus m = 4, we have,

11 3 (mod 4) and 22 6 (mod 4)

Since 4 divides 11 – 3 = 8 and 4 divides 22 – 6 = 16. This relation of congruence modulo m is an important equivalence relation.

4.7.1 Equivalence Relations and PartitionsThis section explores the relationship between equivalence relations and partitions on a non-empty set S.Recallfirstthat a partition R of S is a collection { } of nonempty subsets of S with the following two properties:

Each • a S belongs to some .If • then = .

In other words, a partition R of S is a subdivision of S into disjoint nonempty sets.

Suppose R is an equivalence relation on a set S. For each a S, let [a] denote the set of elements of S to which a is related under R; that is:

[a] = {x | (a, x) R}

We call [a] the equivalenceclass of a in S; any b [a] is called a representative of the equivalence class.

The collection of all equivalence classes of elements of S under an equivalence relation R is denoted by S/R, that is,

S/R = {[a] | a S}

It is called the quotientset of S by R. The fundamental property of a quotient set is contained in the following theorem.

Theorem:Let R be an equivalence relation on a set S. Then S/R is a partition of S. Specially:

For each • a in S, we have a [a][• a] = [b] if and only if (a,b) R.If [• a] [b], then [a] and [b] are disjoint.

Conversely, given a partition { } of the set S, there is an equivalence relation R on S such that the set are the equivalence classes.

Example:Consider the relation • R = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 3)} on S = {1, 2, 3}.

One can show that Risreflexive,symmetricandtransitive,thatis,R is an equivalence relation. Also:

[1] = {1, 2}, [2] = {1, 2}, [3] = {3}

Observe that [1] = [2] and that S/R and that S/R = {[1], [3]} is a partition of S. One can choose either {1, 3} or {2, 3} as a set of representatives of the equivalence classes.

Page 53: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

41

4.8 Transitive ExtensionsLet R be a relation on the set A. Another relation definedonA is called the transitive extension of R if contains R and (a, b) R, (b, c) R (a, c) .

Example:Let A = {1, 2, 3, 4} R = {(1, 2), (2, 3), (3, 2), (2, 4)} and = {(1, 2), (1, 3), (2, 2), (2, 3), (2, 4), (3, 2), (3, 3), (3, 4)}Clearly contains R and (a, b) R, (b, c) R (a, c)

(a) Relation R (b) Relation R 1

Fig. 4.2 Transition extension

4.9 Transition ClosureLet R be a relation on the set A. denotes the transitive extension of R. denotes the transitive extension of and in general denote the transitive extension of , then the transitive closure of Risdefinedasthesetunionof R, , ,............, , ...... It is denoted by .

Thus, = R ... ........

is the smallest transitive relation containing R.

Example:Let A = {1, 2, 3, 4} and R = {(1, 2), (2, 3), (3, 4), (2, 1)}Then = {(1, 1), (1, 2), (1, 3), (1, 4), (2, 1), (2, 2), (2, 3), (2, 4), (3, 4)} is the transitive closure of R.

Theorem:Let R be a relation from A to B and let and be two subsets of A, then,

i. R( R (

ii. ) = R ( ) R ( )

iii. ) = R ( ) R ( )Proof:

Let i. y R( y R( xRy for some x x [Since ] R ( ) R ( )

Page 54: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

42

Let ii. y R ( ) then xRy for some x in now x x or

x , if x , then xRy y R ( ) by the same argument; if x then y R( ) in either case y R ( ) R ( )

R ( ) R ( ) R ( )

Conversely, R ( ) R ( ) .....[by (i)]

Similarly, R ( ) R ( )

R ( ) R ( ) R ( )

Thus, (ii) is true.

Let i. y R ( ) then xRy for some x in now x x

and x y R ( ) and y R ( y R ( ) (

Thus ii. ) = R ( ) R ( )

4.10 Matrix Representation of RelationsSuppose A and BarebothfinitesetsandR is a relation from A to B, then R may be represented as a matrix called the relation matrix of R. It is denoted by .

If A = { , ,........, } and B = { , ,........, }aretwofinitesetscontainingm and n elements respectively and R is relation from A to B, then the Relation Matrix of R is the m n, matrix,

= isdefinedby,

=

Where, , is the element in the ith row and jth column. canbefirstobtainedbyfirstconstitutingatable,whose columns are preceded by a column consisting of successive elements of A and where rows are headed by a row consisting of successive elements of B. If , then we enter 1 in the ith row and jth column and if

, then we enter zero in the kth row and ith column.

Example:Let A = {1, 2, 3} and R = {(x, y) | x < y},find .

Solution: We have, R = {(1, 2), (1, 3), (2, 3)}The table and corresponding relation Matrix for the R are given below:

1 2 3

1 0 1 1

2 0 0 1

3 0 0 0

0 1 1= 0 0 1

0 0 0RM

Page 55: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

43

Example:Let A={1,4,5}and{(1,4),(1,5),(4,1),(4,4),(5,5)},find .

Solution: Given that R = {(1, 4), (1, 5), (4, 1), (4, 4), (5, 5)}The relation Matrix of R is,

0 1 11 1 00 0 1

RM =

Note: If A and Baretwofinitesetswith|A| = m; and |B| = n, then am nmatrix, whose entries are zeros and ones determine a relation from A to B.

If R is symmetric relation on a set A and denotes the matrix of relation R, then,

= 1 = 1

and = 0 = 0 in = [ ]

i.e., = , where denotes the transpose of .

If R is an anti-symmetric relation on A, then = 0 or = 0 for all i j in and if R is a transitive relation on A then,

= 1 and = 1 = 1,

issatisfiedby . Moreover, if R is a relation from A to B and S is a relation from B to C, where A, B and C are finitesetsm, n and p elements respectively, then . can be computed. Provided is m n matrix and is a n p matrix. The Matrices . and are equal.

Example:Let A = {1, 2, 3}R and SbetworelationsdefinedA as follows:

R = {(1, 1), (1, 3), (2, 1), (2, 2), (2, 3), (3, 2)} S = {(1, 1), (2, 2), (2, 3), (3, 1), (3, 3)}

Then, SoR = {(1, 1), (1, 3), (2, 1), (2, 2), (2, 3), (3, 2), (3, 3)}

We get, = ; =

And = = caneasilybeverified

If, and =

Page 56: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

44

And the relational matrices of the relation R and AdefinedonasetA = {1, 2, 3, 4} for which,We know that, = ∙

Therefore, = =

Hence, = {(1, 1), (1, 3), (1, 4), (3, 3)}

Page 57: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

45

SummaryLet • A and B be non-empty sets, then any subset of R of the Cartesian product A B is called a relation from A to B.Null set • is a subset to every set.Let • RbearelationdefinedinasetA; then RisreflexiveifaRa holds for all a A, i.e., if (a, a) R for all a

A.A relation • RdefinedinsetA is said to be ‘symmetric’ if bRa holds whenever aRb holds for b A i.e., R is symmetric in A if, (a, b) R (b, a) RLet • R be a relation from A to B. Then the relation = {(b, a): (a, b) R} from B to A is called the inverse of R.A relation can be represented pictorially by drawing its graph.•A cycle in a digraph is a path of length • n≥1fromavertextoitself.Thegeneralideabehindanequivalencerelationisthatitisaclassificationofobjectswhichareinsomeway•“alike”.Let • R be a relation on the set A. Another relation definedonA is called the transitive extension of R if contains R and (a, b) R, (b, c) R (a, c) .

ReferencesShankar Rao G., 2009.• DiscreteMathematicalStructure. New Age International.Acharjya & Sreekumar. D. P., 2009. • Fundamental Approach to DiscreteMathematics. New Age International. Lipschutz. S., 1997. • Schaum’sOutlineofDiscreteMathematics, 2nd ed., McGraw-Hill.Kolman B., 2008. • DiscreteMathematicalStructures, 6th ed., Prentice Hall.

Recommended ReadingRepresentingRelations• . Available at: <http://www.wiziq.com/tutorial/694-Representing-Relations> [Accessed 8 April 2011].Relations andDigraph• . Available at: <http://www.londoninternational.ac.uk/current_students/programme_resources/cis/pdfs/subject_guides/level_1/cis102_vol2/cis_102_volume_2_ch_1.pdf> [Accessed 8 April 2011].Digraphsandtypesofrelations• . Available at: <http://www.facweb.iitkgp.ernet.in/~niloy/COURSE/Autumn2008/DiscreetStructure/scribe/Lecture07CS3028.pdf> [Accessed 9 April 2011].

Page 58: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

46

Self AssessmentWhich of the following is true?1.

Let a. A and B be empty sets, then any subset of R of the Cartesian product A B is called a relation from A to B.Let b. A and B be non-empty sets, then any subset of R of the Cartesian product A B is called a relation from A to B.Let c. A and B be empty sets, then any subset of R of the Cartesian product A B is called a relation from B to A.Let d. A and B be non-empty sets, then any subset of R of the Cartesian product A B is called a relation from B to A.

If 2. R is a relation from A to B,thenthesetofallfirstelementsoftheorderedpairs(a, b), which belong to R is called the ___________ of R.

domaina. relationb. recurrence relationc. subsetd.

Null set _________ is a subset to every set.3. a. b. c. d.

Which of the following is true?4. Let a. RbearelationdefinedinasetA; then RisreflexiveifaRa holds for all a A, i.e., if (a, a) R for all a A.Let b. RbearelationdefinedinasetA; then RisreflexiveifaRa holds for all a A, i.e., if (a, a) R for all a A.Let c. RbearelationdefinedinasetA; then RisreflexiveifaRa holds for all a A, i.e., if (a, a) R for all a A.Let d. RbearelationdefinedinasetA; then RisreflexiveifaRa holds for all a A, i.e., if (a, a) R for all a A.

Which of the following is true?5. Foranyspecifiednon-emptydomainandrange,a. is a relation, called null relation or empty relation.Foranyspecifiedemptydomainandrange,b. is a relation, called null relation or empty relation.Foranyspecifiednon-emptydomainandrange,c. is a relation, called subset.Foranyspecifiednon-emptydomainandrange,d. is a relation, called null relation or empty relation.

A relation 6. RdefinedinsetA is said to be ‘___________’ if bRa holds whenever aRb holds for b A, i.e., R is symmetric in A if, (a, b) R (b, a) R.

asymmetrica. symmetricb. empty setc. non empty setd.

Page 59: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

47

ArelationRinasetAissaidtobea/an____________inA,ifRisreflexivesymmetricandtransitive.7. equivalence relationa. recurrence relationb. symmetric relationc. inverse relationd.

Let 8. R be a relation from A to B. Then the relation = {(b, a): (a, b) R} from B to A is called the _________ of R.

recurrenta. inverseb. infinitec. finited.

A cycle in a digraph is a path of length 9. _______ from a vertex to itself.na. > 1nb. < 1nc. = 1nd. ≥1

Which of the following is false?10. Thegeneralideabehindanequivalencerelationisthatitisaclassificationofobjectswhichareinsomewaya. “alike”.Infact,therelation“=”ofequityonanysetSisanequivalencerelation.The collection of all equivalence classes of elements of b. S under an equivalence relation R is denoted by S/R, that is, S/R = {[a] | a S}A relation can be represented pictorially by drawing its graph.c. Symmetry can be represented pictorially by drawing its graph.d.

Page 60: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

48

Chapter V

Functions and Recurrence Relations

Aim

The aim of this chapter is to:

definefunctions•

state the restriction and extension of functions•

explain one-to-one mapping•

discuss about sequences, indexed classes of sets•

Objectives

The objectives of this chapter are to:

explain onto-mapping•

definebijection•

explain identity mapping•

Learning outcome

At the end of this chapter, the students will be able to:

understand composition of function•

defineAssociativemapping•

explain mathematical functions,• exponential and logarithmic functions

Page 61: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

49

5.1 IntroductionInmathematics,arecurrencerelationisanequationthatrecursivelydefinesasequence.Eachtermofthesequenceisdefinedasafunctionoftheprecedingterms.Somesimplydefinedrecurrencerelationscanhaveverycomplexbehaviours,andtheyareapartofthefieldofmathematicsknownasnonlinearanalysis.Solvingarecurrencerelationmeans obtaining a closed-form solution.

A function, in a mathematical sense, expresses the idea that one quantity (the argument of the function, also known as the input) completely determines another quantity (the value, or the output). A function assigns exactly one value toeachinputofaspecifiedtype.Theargumentandthevaluemayberealnumbers,buttheycanalsobeelementsfrom any given sets: the domain and the co-domain of the function. Functions are widely used in mathematics and the concept is basic to the idea of computation. 5.2 FunctionLet A and B be any two sets. A relation f from A to B is called function if for every a A there is a unique element b B, such that (a, b) f.

If f is a function from A to B, then f is a function from A to B such thatDomain • f = AWhenever (• a, b) f and (a, c) f, then b = c

The notation f: A→B, means f is a function from A to B.

FunctionsarealsocalledmappingsorTransformations.Thetermssuchas“correspondence”and“operation”areusedassynonymsfor“function”.

Given any function f: A→B, the notation f (a) = b means (a, b) f. It is customary to write b = f (a). The element a A is called an argument of the function f and f (a) is called the value of the function for the argument a or the image of a under f.

Fig. 5.1 Representation of a function

Example:Let A = {(1, 2, 3}, B = {p, q, r} andF = {(1, p), (2, q), (3, r)}. Then f (1) = p, f (2) = q, f (3) = r, clearly is a function from A to B.

Example:Consider the sets A = { , , } and B = { , .Let f = {( , ), ( , ), ( , )} every element of A is related to exactly one element of B.Hence f is function.

Page 62: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

50

If f: A→B is a function, then A is called the Domain of f and the set B is called the co-domain of f. The range of f isdefinedasthesetofallimagesunderf.

It is denoted by f (A) = {b | for some a in A, f (a) = b} and is called the image of A in B. The Range f is also denoted by .

If denotes the domain of f: A→B and denotes the Range of f, then = A and B.

Afunctionneednotbedefinedbyaformula.Whiledefiningtheproperty,itiscustomarytoidentifythefunctionby a formula, for example f (x) = for x R represents the function f = {(x, ): x R}.

Where, R is the set of real numbers.

5.2.1 Restriction and ExtensionIf f: A→B and P A, then f (P B) is a function from P→B, called the Restriction of f to P. Restriction of f to P is written as f | P: P→B is such that (f | P) = f (a) a P.

If g is a restriction of f, then f is called the extension of g.

The domain of f | P is P.

If g is a restriction of f, then and g (a) a and g f.

Example:Let f: R R,bedefinedbyf (x) = .

If N is the set of Natural numbers = {0, 1, 2,...} then N R and f|N = {(0, 0), (1, 1), (2, 2)...}

5.3 One-To-One Mapping (Injection One-To-One Function)A mapping f: A→B is called one-to-one mapping if distinct elements of A are mapped into distinct elements of B, i.e., f is one-to-one if,

f ( ) f ( )

Or equivalently f ( ) = f ( =

Example:f: R→Rdefinedbyf (x) = 3x x R is one-one since,

f ( ) = f ( ) 3 = 3 = , R.

Page 63: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

51

5.4 Onto-Mapping (Surjection)A mapping f: A→B is called onto-mapping if the range set = B.If f: A→B is onto, then each element of B is f-image of at least one element of A.i.e., {f (a): a A} = BIf f is not onto, then it is said to be into mapping.

Example:f: R→R, given by f (x) = 2x x R is onto.

5.5 One-To-One, Onto (Bijection)A mapping f: A B is called one-to-one, onto if it is both one-to-one and onto.

Example:f: R→R,definedbyf (x) = 3x + 2 is a bijection.

5.6 Identity MappingIf f: A→A is a function such that every element of A is mapped onto itself then fis called an Identity mapping it is denoted by .i.e., f (a) = a a A then f: A→A is an Identity mapping.We have, = {(a, a) : a A}

5.7 Composition of FunctionLet f: A B and g: B→C be two mappings. Then the composition of two mapping f and g denoted by gof is the mapping from A into Cdefinedbygof = {(a, c) | for some b, (a, b) f some (b, c) g}.i.e., gof:A→Cisamappingdefinedby,

(gof) (a) = g (f (a)) where a A

Note:Intheabovedefinitionitisassumedthattherangeofthefunctionf is a subset of B (the Domain of g), i.e., If , then gof is empty.

The composition of functions is not commutative, i.e., • fog gof where f and g are two functions.gof• is called the left composition g with f.

Example:Let f: R→R; g: R→Rbedefinedbyf (x) = x + 1, g (x) = 2 + 3, then (gof) (x) = g [f (x) = g [f (x) = g [(x + 1)] = 2 + 3 (fog) (x) = f [g (x)] = f ( + 3 ) = + 3 + 1 = + 4

gof and fogarebothdefinedgof fog

Theorem:•Let f: A→B, then g: B→C be both one-to-one and onto functions, then gof: A→C is also one-one and onto.

Proof:Let , A, then (gof) ( ) = (gof) ( ) g [f ( )] = g [f ( )] f ( ) = f( ) ( g is one-one) = ( f is one-one)

Hence, gof is one-to-one.

Page 64: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

52

Now,fromthedefinition,gof: A→C is a function g: B→C is onto, then c C there is some elements b B such that c=g (b) and f: A→Bisonto,thenbydefinitionthereexistsanelementa A, such that f (a) = b

We have c=g (b) = g [f (a)] = (gof) (a) (gof): A→C is onto

Hence gof is both one-one and onto.

5.8 Associative MappingIf f: A B, g: B→C and h: C→D are three functions, then gof: A→C, hog: C→D and (hog) of: A→D, can also be formed assuming that a A,

We have, (hog) of (a) = (hog) [f (a)] = h [gf (a)] = h [gof (a)] = hof (gof) (a)

Thus the composition of functions is associative.

5.9 Constant FunctionLet f: A→B, f said to be a constant function if every element of A is mapped on to the same element of B.i.e., If the Range of f has only one element then f is called a constant mapping.

Example:f: R→R,definedbyf (x) = 5 x R is a constant mapping we have = {5}

5.10 Inverse MappingLet f, A→B, be one-one, onto mapping (bijection), then : B→A is called the inverse mapping of f.

isthesetdefinedas,

= {(b, a) | (a, b) f}

Note:In general the inverse • of a function f: A→B need not be a function. It may be a relation.If • f: A→B is a bijection and f(a) = b, then a = (b) where a A and b B

Example:Let • A = {a, b, c}, B = {1, 2, 3} and f = {(a, 1), (b, 3), (c, 2)} clearly f is both one-to-one and onto.

= {(1, a), (2, c), (3, b)} is a function from Bto A.

Let • R be a set of real numbers and f: R→R be given by,

f (x) = x + 5 x R, i.e., f = {(x, x + 5) | x R}

Then = {(x + 5, x) | x R} is a function from R to R.Theorem:If f: A→B be both one-one and onto then, : B→A is both one-one and onto.

Proof:Let f: A→B be both one-one and onto. Then there exist elements , A and elements , B such that,

Page 65: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

53

f ( ) = b and f ( ) =

or = ( = and - ( )

now, let ( ) = ( ) then,

( ) = ( ) = f ( ) = f ( ) =

Thus, is one-one.

Again since f is onto, for b B, there is some element a A, such that f (a) = b.

Now, f (a) = b = ( ) is onto

Hence is both one-one and onto.

5.11 Mathematical Functions, Exponential and Logarithmic FunctionsThis section presents various mathematical functions which appear often in the analysis of algorithms and in computer science in general, together with their notation.

5.11.1 Floor and Ceiling FunctionLet x be any real number. Then xliesbetweentwointegerscalledtheflowandtheceilingofx.Specifically, x⌋ = ⌈x⌉; otherwise x⌋ + 1 = ⌈x⌉.

Example: ⌊3.14⌋ = 3, ⌊ ⌋ = 2, ⌊-8.5 = -9, 7⌋ = 7 ⌈3.14⌉ = 4, ⌈ ⌉ = 3, ⌈-8.5⌉ = -8, ⌈7⌉ = 7

5.11.2 Integer and Absolute Value FunctionsLet xbeanyrealnumber.The“integervalue”ofx, written INT (x), converts x into an integer by deleting (truncating) the functional part of the number. Thus,

INT (3.14) = 3, INT ( ) = 2, INT (-8.5) = -8, INT (7) = 7

Observe that INT (x) = x⌋ or INT (x) = ⌈x⌉ according to whether s is positive or negative.

The“absolutevalue”oftherealnumberx, written ABS (x) or |x|,isdefinedasthegreaterofx or –x. Hence, ABS (0) and for x 0, ABS (x) = x – x, depending on whether x is positive or negative.

Thus | - 15 | = 15, | 7 | = 7, | -3.33 | = 3.33, | 4.44 | = 4.44

We note that | x | = | - x | and, for x 0, | x | is positive.

Page 66: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

54

5.11.3 Remainder Function and Modular ArithmeticLet K be any integer and let M be a positive integer.

Then, k (mod M) will denote the integer remainder when k is divided by M. More exactly, k (mod M) is the unique integer r such that,

K = Mq+rwhere,0≤r < M

Where k is positive, simply divide k by M to obtain the remainder r.Thus, 25 (mod 7) = 4, 25 (mod 5) = 0, 35 (mod 11) = 2

If k is negative, divide |k| by M to obtain a remainder r′;thenk (mod M) = M - r′whenr′ ).Thus, -26 (mod 7) = 7 -5 = 2, -371 (mod 8) = 8 – 3 = 5, -39 (mod 3) = 0

Theterm“mod”isalsousedforthemathematicalcongruencerelation,whichisdenotedanddefinedasfollows: a b (mod M) if any only if M divides b – a

M is called the modulus and a b (mod M)isread“a is congruent to b modulo M”.Thefollowingaspectsofthecongruence relation are frequently useful:

0 M (mod M) and a M a (mod M)

Arithmetic modulo M refers to the arithmetic operations of addition, multiplication and subtraction where the arithmetic value is replaced by its equivalent value in the set,

{0, 1, 2,...., M -1} or in the set {1, 2, 3,..., M}

Example:In arithmetic modulo 12, sometimes called 'clock arithmetic',

6 + 9 3, 7 5 11, 1 – 5 8, 2 + 10 0 12

(The use of 0 or M depends on the application.)

5.11.4 Logarithmic FunctionsLogarithms are related to exponents as follows. Let b be a positive number. The logarithm of any positive number x to be the base b, written, x represents the exponent to which b must be raised to obtain x.

That is, y = x and = x

are equivalent statements. Accordingly,

8 = 3 since = 8; 100 = 2 since = 100 64 = 6 since = 64; 0.001 = -3 since = 0.001

Furthermore, for any base b, we have = 1 and = b; hence

1 = 0 and b = 1

Thelogarithmofanegativenumberandthelogarithmof0arenotdefined.

Frequently, logarithms are expressed using approximate values.

Page 67: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

55

Threeclassesoflogarithmsareofspecialimportance:Logarithmstobase10,called“commonlogarithms”;logarithmsto base e,called“naturallogarithms”;andlogarithmstobase2,called“binarylogarithms”.Sometextswrite,

In x for x and log x or log x for x

The term log x, by itself, usually means x; but it is also used for x in advance mathematical texts and for x in computer science texts.

Frequently,wewillrequireonlythefloorortheceilingofabinarylogarithm.Thiscanbeobtainedbylookingatthe powers of 2.

Example: ⌊ 100⌋ = 6 since = 64 and = 128 ⌈ 1000⌉ = 9 since = 51 2 and = 1024And so on.

5.12 Sequences, Indexed Classes of SetsSequences and indexed classes of sets are special types of functions with their own notation.

5.12.1 SequencesA sequence is a function from the set N = {1, 2, 3...} of positive integers into set A. The notation is used to denote the image of the integer n. Thus, a sequence is usually denoted by,

, ,......... or { : n N} or simply {

Sometimes the domain of a sequence is the set {0, 1, 2,....} of nonnegative integers rather than N. In such a ease we say n begins with 0 rather that 1.

A“finitesequence”overasetA is a function from {1, 2,..., m} into A and it is usually denoted by, , ,...........,

Suchafinitesequenceissometimescalleda“list”oran“m-tuple”.

5.12.2 Summation Symbol, SumsHere we introduce the summation symbol (the Greek letter sigma). Consider a sequence , , ,....... Then wedefinethefollowing:

= + + .......... + and = + + ............. +

The letter jintheaboveexpressionsiscalleda“dummyindexordummyvariable”.Otherlettersfrequentlyusedas dummy variables are i, k, s, t.

5.12.3 Indexed Classes of SetsLet I be any nonempty set and let S be a collection of sets. An indexing function from I to S is a function f: I→S. For any i I, we denote the image f (i) by . Thus the indexing function f is usually denoted by,

{ | i I} or or simply { }

The set I is called the indexing set and the elements of I are called indices. If f is one-to-one and onto, we say that S is indexed by I.

Theconceptofunionandintersectionaredefinedforindexedclassesofsetsasfollows:

Page 68: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

56

= {x | x for some i I} and = {x | x for all i I}

In the case that Iisafiniteset,thisisjustthesameasourpreviousdefinitionofunionandintersection.IfI is N, we may denote the union and intersection, respectively, as follows:

............ and .........

5.13 Algorithms and FunctionsAn algorithm Misafinitestep-by-steplistofwell-definedinstructionsforsolvingaparticularproblem,say,tofindthe output f (X) for a given function f with input X. Frequently, there may be more than one way to obtain f (X).

Example:(Polynomial Evaluation) Suppose, for a given polynomial f (x) and value x = a,wewanttofindf (a), say, f (x) = - + 4x – 15 and a = 5

This can be done in the following two ways:

(Direct Method): • Here we substitute a = 5 directly in the polynomial to obtain,

f (5) = 2(125) – 7(25) + 4(5) – 7 = 250 – 175 + 20 – 15 = 80

Observe that there are 3 + 2 + 1 = 6 multiplications and 3 additions. In general, evaluating a polynomial of degree n directly would require approximately.

N + (n – 1) +........... + 1 = multiplications and n additions.

(Horner’s Method or Synthetic Division):• Here we rewrite the polynomial by successively factoring out x (on the right) as follows:

f (x) = ( - 7x + 4)x – 15 = ((2x – 7)x + 4) – 15 = 80

For those familiar with synthetic division, the above arithmetic is equivalent to the following synthetic division:

5 2 7 + 4 1510 + 15 + 95

2 + 3 + 19 + 80

Observe that here; there are 3 multiplications and 3 additions. In general, evaluating a polynomial of degree n by Horner’s method would require approximately,

n multiplications and n additions

ClearlyHorner’smethod(b)ismoreefficientlythanthedirectmethod(a).

Page 69: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

57

5.14 Complexity of AlgorithmThe analysis of algorithms is a major task in computer science. In order to compare algorithms, we must have some criteriatomeasuretheefficiencyofouralgorithms.

Suppose M is an algorithm and suppose n is the size of the input data. The time and space used by the algorithm are twomainmeasuresfortheefficiencyofM.Thetimeismeasuredbycountingthenumberofkeyoperations.”

Example:In sorting and searching, one counts the number of comparisons.•In arithmetic, one counts multiplications and neglects additions.•

Keyoperationsaresodefinedwhenthetimefortheotheroperationsismuchlessthanoratmostproportionalto the time for the key operations. The space is measured by counting the maximum of memory needed by the algorithm.

The complexity of an algorithm M is the function f (n) which gives the running time and/or storage space requirement of the algorithm in terms of the size n of the input data. Frequently, the storage space required by an algorithm is simplyamultipleofthedatasize.Accordingly,unlessotherwisestatedorimplied,theterm“complexity”shallreferto the running time of the algorithm.

The complexity function f (n), which we assume gives the running time of an algorithm, usually depends not only on the size n of the input data but also on the particular data.

Example:Suppose,wewanttosearchthroughanEnglishshortstoryTEXTforthefirstoccurrenceofagiven3-letterwordW.Clearly,ifWisthe3-letterword“the,”thenW likely occurs near the beginning of TEXT, so f (n) will be small. On the other hand, if Wisthe23-letterword“zoo,”thenW may not appear in TEXT at all, so f (n) will be large.

Theabovediscussionleadsustothequestionoffindingthecomplexityf (n) for certain cases. The two cases one usually investigates in complexity theory are as follows:Worst case: The maximum value of f (n) for any possible input.Average case: The expected value of f (n).

The analysis of the average case assumes a certain probabilistic distribution for the input data; one possible assumption might be that the possible permutations of a data set are equally likely. The average case also uses the following concept in probability theory. Suppose the numbers , ,............, occur with respective probabilities ,

,......, . Thenthe“expectation”or“averagevalue”E is given by,

E = + + ............ +

5.14.1 Complexity of Well-known AlgorithmsAssuming f (n) and g (n)arefunctionsdefinedonthepositiveintegers,then

f (n) = O (g (n))

Means that f (n) is bounded by a constant multiple of g (n) for almost all n.

Page 70: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

58

To indicate the convenience of this notation, we give the complexity of certain well-known searching and sorting algorithms in computer science:

Linear search: • O (n)Binary search: • O (log n)Bubble sort: • O ( )Merge-sort: • O (n log n)

Page 71: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

59

SummaryLet • A and B be any two sets. A relation f from A to B is called function if for every a A there is a unique element b B, such that (a, b) f.If • f: A→B is a function, then A is called the Domain of f and the set B is called the co-domain of f. The range of fisdefinedasthesetofallimagesunderf.If • f: A→B and P A, then f (P B) is a function from P→B, called the Restriction of f to P. Restriction of f to P is written as f | P: P→B is such that (f | P) = f (a) a P.A mapping • f: A→B is called onto-mapping if the range set = B.If • f: A→B is onto, then each element of B is f-image of at least one element of A.A mapping • f: A→B is called one-to-one mapping if distinct elements of A are mapped into distinct elements of B.A mapping • f: A B is called one-to-one, onto if it is both one-to-one and onto.Let • f, A→B, be one-one, onto mapping (bijection), then : B→A is called the inverse mapping of f.

• isthesetdefinedas, = {(b, a) | (a, b) f}Worst case: The maximum value of • f (n) for any possible input.Average case: The expected value of • f (n).

ReferencesShankar Rao G., 2009.• DiscreteMathematicalStructure. New Age International.Acharjya & Sreekumar. D. P., 2009. • Fundamental Approach to DiscreteMathematics. New Age International. Lipschutz. S., 1997. • Schaum’sOutlineofDiscreteMathematics, 2nd ed., McGraw-Hill.Kolman B., 2008. • DiscreteMathematicalStructures, 6th ed., Prentice Hall.

Recommended ReadingGeneratingFunctionsandRecurrenceRelation.• [Online] Available at: http://www.math.cmu.edu/~af1p/Teaching/Combinatorics/Slides/Ch10.pdf [Accessed 9 April 2011].Recurrence relations and generating functions• . Available at: <http://www.britannica.com/EBchecked/topic/127341/combinatorics/21881/Recurrence-relations-and-generating-functions> [Accessed 9 April 2011].Recurrence relations andgenerating functions• . Available at: <http://www.mathpages.com/home/kmath646/kmath646.htm> [Accessed 10 April 2011].

Page 72: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

60

Self AssessmentA relation 1. f from A to B is called function if for every a A there is a unique element b B, such that (a, b) __________ f.a. b. c. d.

Which of the following is false?2. The notation a. f: A→B, means f is a function from B to A.The notation b. f: A→B, means f is a function from A to B.Functions are also called mappings or Transformations.c. Thetermssuchas“correspondence”and“operation”areusedassynonymsfor“function”.d.

Which of the following is false?3. The element a. a A is called an argument of the function f and f (a) is called the value of the function for the argument a or the image of a under f.If b. f: A→B is a function, then A is called the co-domain of f and the set B is called the domain of f.If c. f: A→B is a function, then A is called the Domain of f and the set B is called the co-domain of f.The range of d. fisdefinedasthesetofallimagesunderf.

If 4. denotes the domain of f: A→B and denotes the Range of f, then = A and _________.a. Bb. Bc. Bd. B

If 5. f: A→B and P A, then __________ is a function from P→B, called the Restriction of f to P. a. f (P B) b. f (P B) c. f (P B) d. f (P B)

A mapping 6. f: A→B is called ___________ if distinct elements of A are mapped into distinct elements of B.

one-to-one mappinga. onto mappingb. one-to-one, ontoc. identity mappingd.

A mapping 7. f: A→B is called ____________ if the range set = B.one-to-one mappinga. one-to-one, ontob. identity mappingc. onto mappingd.

Page 73: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

61

If 8. f: A→A is a function such that every element of A is mapped onto itself then fis called ___________ and it is denoted by .

one-to-one mappinga. one-to-one, ontob. identity mappingc. onto mappingd.

Which of the following is false?9. The composition of functions is not commutative, i.e., a. fog gof where f and g are two functions. b. gofis called the left composition g with f. c. fog is called the left composition g with f. A sequence is a function from the set d. N = {1, 2, 3...} of positive integers into set A.

Which of the following is false?10. The logarithm of any positive number a. x to be the base b, written, x represents the exponent to which b must be raised to obtain x.Sequences and indexed classes of sets are special types of functions with their own notation.b. The notation c. is used to denote the image of the integer n.Ainfinitesequenceoverasetd. A is a function from {1, 2,..., m} into A and it is usually denoted by, ,

,..........., .

Page 74: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

62

Chapter VI

Graph Theory

Aim

The aim of this chapter is to:

introduce the students to data structures•

describe linked lists and pointers•

explain stacks, queues and priority queues•

discuss graphs and multigraphs•

Objectives

The objectives of this chapter are to:

determine subgraphs, isomorphic and homeomorphic graphs•

discuss paths and connectivity•

elaborate on traversable and Eulerian graphs, bridges of Königsberg•

explain graph colourings•

Learning outcome

At the end of this chapter, the students will be able to:

explain isomorphic graphs in detail•

describe connectivity and its connected components•

discuss labelled and weighted graphs•

identify complete, regula• r and bipartite graphs

Page 75: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

63

6.1 Introduction Graphs, directed graphs, trees and binary trees appear in many areas of mathematics and computer science. In order to understand how these objects may be stored in memory and to understand algorithm on them, we need to know a little about certain data structures.

6.1.1 Linked Lists and PointersLinkedlistsandpointerswillbeintroducedbymeansofanexample.Supposeabrokeragefirmmaintainsafileinwhicheachrecordcontainsacustomer’snameandsalesman;saythefilecontainsthefollowingdata:

Customer Adams Brown Clark Drew Evans Farmer Geller Hiller Infeld

Salesman Smith Ray Ray Jones Smith Ray Jones Ray Smith

Table 6.1 Linked lists and pointers

There are two basic operations that one would want to perform on the data:

Operation A:Giventhenameofacustomer,findhissalesman.Operation B:Giventhenameofasalesman,findthelistofhiscustomers.

We discuss a number of ways the data may be stored in the computer by an array with two rows (or columns) of nine names. Since the customers are listed alphabetically, one could easily perform operation A. However, in order to perform operation B one must search through the entire array.

One can easily store the data in memory using a two-dimensional array where, say, the rows correspond to an alphabetical listing of the customers and the columns correspond to an alphabetical listing of the salesman and where there is a 1 in the matrix indicating the salesman of a customer and there are 0’s elsewhere. The main drawback of such a representation is that there may be a waste of a lot of memory because many o’s may be in the matrix.

Example:Ifafirmhas1000customersand20salesmen,onewouldneed20,000memorylocationsforthedata,butonly1000of them would be useful.

Below we discuss a way of sorting the data in memory which uses linked lists and pointers. By a linked list, we mean alinearcollectionofdataelements,callednodes,wherethelinearorderisgivenbymeansofafieldofpointers.

Fig.6.1isaschematicdiagramofalinkedlistwithsixnodes.Thatis,eachnodeisdividedintotwoparts:thefirstpartcontains the informationof theelement(e.g.NAME,ADDRESS,....)and thesecondpart,called the“linkfield”or“nextpointerfield”,containstheaddressofthenextnodeinthelist.Thispointerfieldisindicatedbyanarrowdrawnfromonenodetothenextnodeinthelist.Thereisalsoavariablepointer,calledSTARTinthefigure,whichgivestheaddressofthefirstnodeinthelist.Furthermore,thepointerfiledofthelastnosecontainsaninvalidaddress,calleda“nullpointer”,whichindicatestheendofthelist.

Page 76: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

64

Fig. 6.1 Linked list with 6 nodes

Onemainwayofstoringtheoriginaldatapicturedinfig.6.2,useslinkedlists.Observethatthereareseparate(sorted alphabetically) arrays for the customers and the salesman. Also, there is a pointer array SLSM parallel to CUSTOMER which gives the location of the salesman of a customer, hence operation A can be performed very easily andquickly.Furthermore,thelistofcustomersofeachsalesmanisalinkedlistasdiscussedabove.Specifically,thereisapointerarraySTARTparalleltoSALESMANwhichpointstothefirstcustomerofasalesmanandthereis an array NEXT which points to the location of the next customer in the salesman’s list (or contains a 0 to indicate theendofthelist).Thisprocessisindicatedbythearrowsinfig.6.2forthesalesmanRay.

Fig. 6.2 Use of linked lists

Operation B can now be performed easily and quickly; that is, one does not need to search through the list of all customers in order to obtain the list of customers of a given salesman. Fig. 6.3 gives such an algorithm (which is written in pseudo-code).

6.1.2 Stacks, Queues and Priority QueuesThere are data structures other than arrays and linked lists which occur in our graph algorithm. These structures, stacks,queuesandpriorityqueuesarebrieflydescribedbelow:

Page 77: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

65

Algorithm The name of salesman is read and the list of his customers is printed

Step1 Read XXX

Step 2 Find K such that SALESMAN (K) = XXX. [ Use Binary Search]

Step 3 Set PTR: = START [K]. [Initializes Pointer PTR.]

Step 4 Repeat while PTR ≠ Null

(a) Print CUSTOMER[ PTR]

(b) Set PTR: = NEXT [PTR]. [Update PTR]

[ End of Loop]

Step 5 Exit

Fig. 6.3 Algorithm

6.1.2.1 StackAstackalsocalledalast-in-first-out(LIFO)systemisalinearlistinwhichinsertionsanddeletionscantakeplaceonlyatoneend,calledthe“top”ofthelist.Thisstructureissimilarinitsoperationtoastackofdishesonaspringsystem,aspicturedinfig.6.4(a).Notethatnewdishesareinsertedonlyattopofthestackanddishescanbedeletedonly from the top of the stack.

BUS STOP

(b) Queue waiting for a bus(a) Stack of dishes

Fig. 6.4 Stack and queue

6.1.2.2 QueueAqueue,alsocalledafirst-in-first-out(FIFO)system,isalinearlistinwhichdeletionscanonlytakeplaceatoneendofthelist,the“front”ofthelistandinsertionscanonlytakeplaceattheotherendofthelist,the“rear”ofthelist.Thestructureoperatesinmuchthesamewayasalineofpeoplewaitingatabusstop,aspicturesinfig.6.4(b).Thatis,thepersoninlineisthefirstpersontoboardthebusandanewpersongoestotheendoftheline.

6.1.2.3 Priority QueueLet S be a set of elements where new elements may be periodically inserted, but where the current largest element (elementwiththe“highestpriority”)isalwaysdeleted.ThenSiscalledapriorityqueue.Therules“womenandchildrenfirst”and“agebeforebeauty”areexamplesofpriorityqueues.Stacksandordinaryqueuesarespecialkindsofpriorityqueues.Specifically,theelementwiththehighestpriorityinastackisthelastelementinserted,buttheelementwiththehighestpriorityinaqueueisthefirstelementinserted.

Page 78: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

66

6.2 Graphs and MultigraphsA group G consists of two things:

A set • V = V (G) whose elements are called vertices, points, or nodes of G.A set • E = E (G) of unordered pairs of distinct vertices called edges of G.

We denote such a graph by g (V, E) when we want to emphasise the two parts of G.

Vertices u and v are said to be adjacent or neighbours if there is an edge e = {u, v}. In such a case, u and v are called the endpoints of e and e is said to connect u and v. Also, the edge e is said to be incident on each of its endpoints u and v.Graphsarepicturedbydiagramintheplaneinanaturalway.Specifically,eachvertexv in V is represented by a dot (or small circle) and each edge e = { , } is represented by a circle which connects its endpoints and .

Example:Fig. 6.5(a) represents the graph G (V, E) where:

V• consists of vertices A, B, C, D.E• consists of edges = {A, B}, = {B, C}, = {C, D}, = {A, D}, = {B, D}

In fact, we will usually denote a graph by drawing its diagram rather than explicitly listing its vertices and edges.

A Ae4

e4

e5

e6e1

e2 e3

e2

e3

e5e1

B BC C

D D

(a) Graph (b) Multi graph

Fig. 6.5 Graph and multigraph

6.2.1 MultigraphsConsiderthediagraminfig.6.5(b).Theedges and are called multiple edges since they connect the same endpoints and the edge is called a loop since its endpoints are the same vertex. Such a diagram is called a multigraph;theformaldefinitionofagraphpermitsneithermultipleedgesnorloops.Thusagraphmaybedefinedto be a multigraph edges or loops.

6.2.2 Degree of a VertexThe degree of a vertex v in a graph G, written deg (v), is equal to the number of edges in G which contains v, that is, which are incident on v. Since each edge is counted twice in counting the degrees of the vertices of G, we have the following simple but important result.

Theorem:The sum of the degrees of the vertices of a graph G is equal to twice the number of edges in G.

Considering,thegraphinfig.6.5(a)asanexample,wehave:

deg (A) = 2, deg (B) = 3, deg (C) = 3, deg (D) = 2

The sum of the degrees equals 10 which, as expected, is twice the number of edges. A vertex is said to be even or odd according as its degree is an even or odd number. Thus A and D are even vertices whereas B and C are odd vertices.

Page 79: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

67

This theorem also holds for multigraphs where a loop is counting twice towards the degree of its endpoints.

Example:Infig.6.5(b)wehavedeg (D) = 4 since the edge is counting twice; hence D is an even vertex.

A vertex of degree zero is called an isolated vertex.

6.2.3 Finite Graphs, Trivial GraphsAmultigraphissaidtobefiniteifithasafinitenumberofverticesandafinitenumberofedgesandsomustbefinite.Thefinitegraphisgraphwithonevertexandnoedges,i.e.,asinglepoint,thetrivialgraph.Unlessotherwisespecified,themultigraphsinshallbefinite.

6.3 Subgraphs, Isomorphic and Homeomorphic GraphsThis section will discuss the important relations between graphs.

6.3.1 SubgraphsConsider a graph G = G (V, E). A graph H = H (V′,E′)iscalledasubgraphofG if the vertices and edges of H are contained in the vertices and edges of G, that is, if V′ V and E′ E. In particular:

A subgraph • H (V′,E′)ofG (V, E) is called the subgraph induced by its vertices V′ifitsedgessetE′containsalledges in G endpoints belong to vertices in H.If • v is a vertex in G, then G – v is the subgraph of G obtained by deleting v from G and deleting all edges in G which contains v.If • e is an edge in G, then G – e is the subgraph of G obtained by simply deleting the edge e from G.

6.3.2 Isomorphic GraphsGraphs G (V, E) and G (V*, E*) are said to be isomorphic if there exists a one-to-one correspondence f: V→V* such that {u, v} is an edge of G if and only if {f (u), f (v)} is an edge of G*. Normally, we do not distinguish between isomorphic graphs. Fig. 6.6 gives ten graphs pictured as letters. We note that A and R is isometric graphs. Also, F and T are isomorphic graphs, K and X are isomorphic graphs and M, S, V and Z are isomorphic graphs.

Fig. 6.6 Isomorphic graphs

6.3.3 Homeomorphic GraphsGiven any graph G, we can obtain a new graph by dividing an edge of G with additional vertices. Two graphs G and G* are said to be homeographic if they can be obtained from the same graph or isomorphic graphs by this method. Thegraphs(a)and(b)infig.6.7arenotisomorphic,buttheyarehomeographicsincetheycanbeobtainedfromthe graph (c) by adding appropriate vertices.

Page 80: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

68

(a) (b) (c)

Fig. 6.7 Homeomorphic graphs

6.4 Paths, ConnectivityA path in a multigraph G consists of an alternating sequence of vertices and edges of the form, , , , , ,..........., , , ,

Where, each edge contains the vertices and . The number n of edges is called the length of the path. When there is no ambiguity, we denote a path by its sequence of vertices (, ,........., ). The path is said to be closed if

= . Otherwise, we say the path is from , to or between and , or connects to .

A simple path is a path in which all vertices are distinct. A cycle is a closed path of length 3 or more in which all vertices are distinct except = . A cycle of length k is called a k-cycle.

6.4.1 Connectivity, Connected ComponentsA graph Gisconnectedifthereisapathbetweenanytwoofitsvertices.Thegraphinfig.6.8(a)isconnected,butthegraphinfig.6.8(b)isnotconnectedsincethereisnopathbetweenverticesD and E.

Suppose G is a graph. A connected subgraph H of G is called a connected component of G if H is not contained in any larger connected subgraph of G. It is intuitively clear that any graph G can be partitioned into its connected components.

Example:The graph Ginfig.6.8(b)hasthreeconnectedcomponents,thesubgraphsinducedbythevertexsets{A, C, D}, {E, F} and {B}.

The vertex Binfig.6.8(b)iscalledanisolatedvertexsinceB does not belong to any edge or, in other words, deg (D) = 0. Therefore, as noted, B itself forms a connected component of the graph.

6.4.2 Distance and DiameterConsider a connected graph G. The distance between vertices u and v in G, written d (u, v) is the length of the shortest path between u and v. The diameter of G, written diam (G), is the maximum distance between any two points in G.

Example:Infig.6.9(a),d (A, F) = 2 and diam (G)=3,whereasinfig.6.9(b),d (A, F) = 3 and diam (G) = 4.

6.4.3 Cutpoints and BridgesLet G be a connected graph. A vertex v in G is called a cutpoint if G – v is disconnected. (Recall that G – v is the graph obtained from G by deleting v and all edges containing v). An edge e of G is called a bridge if G – e is disconnected. (Recall that G – e is the graph obtained from G by simply deleting the edge e).Infig.6.9(a),thevertex Disacutpointsandtherearenobridges.Infig.6.9(b),theedge={D, F} is a bridge. (Its endpoints D and F are necessarily cutpoints).

Page 81: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

69

Fig. 6.8 Cutpoints and bridges

6.5 Traversable and Eulerian Graphs, Bridges of KönigsbergTheeighteenthcenturyEastPrussiantownofKönigsbergincludedtwoislandsandsevenbridgesasshowninfig.6.10 (a).

Question: Beginning anywhere and ending anywhere, can a person walk through two crossing all seven bridges but not crossing any bridge twice? The people of Königsberg wrote to the celebrated Swiss mathematician L. Euler about this question. Euler proved in 1736 that such a walk is impossible. He replaced the islands and the two sides oftheriverbypointsandthebridgesbycurves,obtainingfig.6.10(b).

Observethatfig.6.10(b)isamultigraph.Amultigraphissaidtobetraversableifit“canbedrawnwithoutanybreaksinthecurveandwithoutrepeatinganyedges,”thatis,ifthereisapathwhichincludesallverticesanduseseach edge exactly once. Such a path must be a trial (since no edge is used twice) and will be called a traversable trail.Clearlyatraversablemultigraphmustbefiniteandconnected.

A A

C C

B B

DD

(a) Konigsberg in 1736 (b) Euler’s graphical representation

Fig. 6.9 Traversable and Eulerian graphs, bridges of Königsberg

WenowshowhowEulerprovedthatthemultigraphinfig.6.10(b)isnottraversableandhencethatthewalkinKönigsbergispossible.Recallfirstthatavertexisevenoroddaccordingasitsdegreeisanevenoranoddnumber.Suppose a multigraph is a traversable and that a traversable trail does not begin or end at a vertex P. We claim that P is an even vertex. For whenever the traversable trail enters P by an edge, there must always be an edge not previously used by which the trail can leave P. Thus, the edge in the trail incident with P must appear in pairs and so P is an even vertex. Therefore if a vertex Q is odd, the traversable trail must begin or end at Q. Consequently, a multigraph with more than two odd vertices cannot be traversable. Observe that the multigraph corresponding to the Königsberg bridge problem has four odd vertices. Thus one cannot walk through Königsberg so that each bridge is crossed exactly once.

6.5.1 Hamiltonian GraphsThe above discussion of Eulerian graphs emphasised travelling edges; here we concentrate on visiting vertices. A Hamiltonian circuit in graph G, named after the nineteenth century Irish mathematician William Hamilton, is a closed path that visits every vertex in G exactly once. If G does admit a Hamiltonian circuit, then G is called a Hamiltonian graph. Note that an Eulerian circuit traverses every edge exactly once, but may repeat vertices, while a Hamiltonian circuit visits each vertex exactly once but may repeat edges. Fig. 6.11 gives an example of a graph which is Hamiltonian but not Eularian and vice versa.

Page 82: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

70

(a) Hamiltonian and non- Eulerian (b) Eulerian and non- Hamiltonian

Fig. 6.10 Hamiltonian graphs

Although it is clear that only connected graphs can be Hamiltonian, there is no criterion to tell us whether or not agraphisHamiltonianasthereisforEuleriangraphs.Wedohavethefollowingsufficientconditionwhichisdueto G. A. Dirac.

Theorem:Let G be a connected graph with n vertices. Then G is Hamilton if n≥3andn≤deg (v) for each vertex v in G.

6.6 Labelled and Weighted GraphsA graph is called a labelled graph if its edges and/or vertices are assigned data of one kind or another. In particular, G is called a weighted graph if each edge e of G is assigned a nonnegative w (e) called the weight or length of V. Fig. 6.12 shows a weighted graph where the weight of each edge in the obvious way. The weight (or length) of a path in such a weighted graph Gisdefinedtobethesumoftheweightsoftheedgesinthepath.Oneimportantproblemingraphtheoryistofindashortestpath,thatis,apathofminimumweight(length),betweenanytwogivenanytwogiven vertices. The length of a shortest path between P and Qinfig.6.12is14;onesuchpathis,

(P, , , , , , Q}

Thereadercantrytofindanothershortestpath.

P

3

3

2

2

12

4

7

32

6

6

4

4

A1

A4 A5

A2 A3

A6

Q

Fig. 6.11 Labelled and weighted graphs

6.7 Complete, Regular and Bipartite GraphsThere are many different types of graphs. This section considers three of them; complete, regular and bipartite graphs.

6.7.1 Complete GraphsA graph G is said to be complete if every vertex in G is connected to every other vertex in G. Thus, a complete graph G must be connected. The complete graph with n vertices is denoted by . Fig. 6.12 shows the graphs through .

Page 83: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

71

K1= isolated vertex K2= Line Segment K3= Triangle Line Segment

Fig. 6.12 Complete graphs

6.7.2 Regular GraphsA graph G is regular of degree k or k-regular if every vertex has degree k. In other words, a graph is regular if every vertex has the same degree.

The connected regular graphs of degrees 0, 1, or 2 are easily described. The connected 0-regular graph is the trivial graph with one vertex and no edges. The connected 1-regular graph is the graph with two vertices and one edge connected the. The connected 2-regular graph with n vertices is the graph consists of a single n-cycle.Refertofig.6.14.

(i) 0- regular (ii) 1- regular (iii) 2- regular

Fig. 6.13 Regular graphs

The 3-regular graphs must have an even number of vertices since the sum of the degree of the vertices is an even number. Fig. 6.15 shows two connected 3-regular graphs with six vertices. In general, regular graphs can be quite complicated.

Fig. 6.14 Regular graphs

Example:There are nineteen 3-regular graphs with ten vertices. We note that the complete graph with n vertices is regular of degree n – 1.

Page 84: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

72

6.7.3 Bipartite GraphsA graph G is said to be bipartite if its vertices V can be partitioned into two subsets M and N such that each edge of G connects a vertex of M to a vertex of N. By a complete bipartite graph, we mean that each vertex of M is connected to each vertex of N; this graph is denoted by where m is the number of vertices in M and n is the number of vertices in N and for standardised, we will assume m≤n. Fig. 6.16 shows the graphs , and , clearly the graph had mn edges.

K2, 4K3, 3K2, 3

Fig. 6.15 Bipartite graphs

6.8 Graphs ColouringsConsider a graph G. A vertex colouring or simply a colouring of G is an assigning of colours to the vertices of G such that adjacent vertices have different colours. We say that G is n-colourable if there exists a colouring of G which uses n colours. The minimum number of colours needed to paint G is called the chromatic number of G and is denoted by (G).

Fig. 6.17 gives an algorithm by Welch and Powell for a colouring of a graph G. We emphasise that this algorithm does not always yield a minimal colouring of G.

Algorithm ( Welch Powell): The input is a Graph GStep 1. Order the vertices of G according to decreasing degreesStep 2. AssignthefirstcolorC1tothefirstvertexandthen,insequentialorder,assignC1 to each

vertex which is not adjacent to a previous vertex which was assigned C1

Step 3. Repeat step 2 with a second color C2 and the subsequence of noncolored verticesStep 4. Repeat step 3 with a third color C3, then a fourth color C4, and so on until all vertices are

coloredStep 5. Exit

Fig. 6.16 Welch-Powell algorithm

Theorem:The following are equivalent for a graph G:

G• is 2-colourableG• is bipartiteEvery cycle of • G has even length.

There is no limit on the number of colours that may be required for a colouring of an arbitrary graph since, for example, the complete graph requires n colours. However, if we restrict ourselves to planar graphs, regardless ofthenumberofvertices,fivecolours,fivecolourssuffice.

Page 85: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

73

Theorem:Any planar graph is 5-colourable.

Actually, since the 1850’s mathematicians have conjectured that planar graphs are 4-colourable since every known planar graph is 4-colourable. Kenneth Appel and Wolfgang Haken proved this conjecture to be true in 1976. That is:

6.8.1 Dual Maps and the Four Colour TheoremConsider a map M, say the map Minfig.6.18(a).Inotherwords,M is a planar representation of a planar multigraph. Two regions of M are said to be adjacent if they have an edge in common. Thus, the region and infig.6.18(a)are adjacent, but the regions and are not. By a colouring of M we mean an assignment of a colour to each region of M such that adjacent regions have different colours. A map M is n-colourable if there exists a colouring of M which uses n colours. Thus, the map Minfig.6.18(a)is3-colourablesincetheregionscanbeassignedthefollowing colours:

red, white, red, white, red, blue

Observe the similarity between this discussion on colouring maps and the previous discussion on colouring graphs. Infact,usingtheconceptofthedualmapdefinedbelow,thecolouringofamapcanbeequivalenttothevertexcolouring of a planar graph.

Consider a map M. In each region of M we chose a point and if two regions have an edge in common then we connect the corresponding points with a curve through the common edge. These curves can be drawn so that they are noncrossing. Thus we obtain a new map M*, called the dual of M, such that each vertex of M* corresponds to exactly one region of M.Fig.6.18(b)showsthedualofthemapoffig.6.18(a).OnecanprovethateachregionofM* will exactly one vertex of M and that each edge of M* will intersect exactly one edge of M and vice versa. Thus, M will be the dual of the map M*.

r1

(a) (b)

r2

r3

r4

r5

r6

Fig. 6.17 Dual maps and the four colour theorem

Observe that any colouring of the regions of a map M will correspond to a cooking of the vertices of the dual map M*. Thus M is n-colourable if and only if the planar graphs of the dual map M* is vertex n-colourable.

Page 86: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

74

SummaryThere are data structures other than arrays and linked lists which occur in our graph algorithm.•Astack,alsocalledalast-in-first-out(LIFO)systemisalinearlistinwhichinsertionsanddeletionscantake•placeonlyatoneend,calledthe“top”ofthelist.Aqueue,alsocalledafirst-in-first-out(FIFO)system,isalinearlistinwhichdeletionscanonlytakeplaceat•oneendofthelist,the“front”ofthelistandinsertionscanonlytakeplaceattheotherendofthelist,the“rear”of the list.The degree of a vertex • v in a graph G, written deg (v), is equal to the number of edges in G which contains v, that is, which are incident on v.Amultigraphisaidtobefiniteifithasafinitenumberofverticesandafinitenumberofedgesandsomustbe•finite.A graph is called a labelled graph is its edges and/or vertices are assigned data of one kind or another.•A graph • G is regular of degree k or k-regular if every vertex has degree k. In other words, a graph is regular if every vertex has the same degree.A graph • G is said to be bipartite if its vertices V can be partitioned into two subsets M and N such that each edge of G connects a vertex of M to a vertex of N.

ReferencesShankar Rao G., 2009.• DiscreteMathematicalStructure. New Age International.Acharjya & Sreekumar. D. P., 2009. • Fundamental Approach to DiscreteMathematics. New Age International. Lipschutz. S., 1997. • Schaum’sOutlineofDiscreteMathematics, 2nd ed., McGraw-Hill.Kolman B., 2008. • DiscreteMathematicalStructures, 6th ed., Prentice Hall.

Recommended ReadingBasicConceptsinGraphTheory• . Available at: <http://math.ucsd.edu/~ebender/DiscreteText2/GT.pdf> [Accessed 10 April 2011].GraphTheory• .Availableat:<http://math.tut.fi/~ruohonen/GT_English.pdf>[Accessed11April2011].IntroductiontoGraphTheory• .Availableat:<http://www.southernct.edu/~fields/TeX-PDF/GraphTheory.pdf>[Accessed 11 April 2011].

Page 87: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

75

Self AssessmentThere are data structures other than _________ and linked lists which occur in our graph algorithm.1.

sets a. arraysb. structuresc. subsetsd.

A stack, also called as a __________, is a linear list in which insertions and deletions can take place only at 2. oneend,calledthe“top”ofthelist.

last-in-first-out(LIFO)systema. data structureb. first-in-first-out(FIFO)systemc. subsetd.

Aqueue,alsocalledafirst-in-first-out(FIFO)system,isalinearlistinwhichdeletionscanonlytakeplaceat3. oneendofthelist,the“front”ofthelistandinsertionscanonlytakeplaceattheotherendofthelist,the“rear”of the list.

last-in-first-out(LIFO)systema. data structureb. first-in-first-out(FIFO)systemc. subsetd.

A__________issaidtobefiniteifithasafinitenumberofverticesandafinitenumberofedgesandsomust4. befinite.

finitegrapha. multigraphb. infinitegraphc. homeographd.

The ____________ is graph with one vertex and no edges, i.e., a single point, the trivial graph.5. multigrapha. infinitegraphb. homeographc. finitegraphd.

Which of the following is false?6. Two graphs a. G and G* are said to be homeographic if they can be obtained from the same graph or isomorphic graphs.A Hamiltonian circuit in graph b. G, named after the nineteenth century Irish mathematician William Hamilton, is a closed path that visits every vertex in G exactly once.A graph is called a labelled graph if its edges and/or vertices are assigned data of one kind or another.c. A graph is called a multigraph if its edges and/or vertices are assigned data of one kind or another.d.

Page 88: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

76

Which of the following is true?7. A path in a multigraph a. G consists of an alternating sequence of vertices and edges of the form, , ,

, , ,..........., , , , .In particular, b. G is called a multigraph if each edge e of G is assigned a nonnegative w (e) called the weight or length of V.In particular, c. G is called a labelled graph if each edge e of G is assigned a nonnegative w (e) called the weight or length of V.In particular, d. Giscalledafinitegraphifeachedgee of G is assigned a nonnegative w (e) called the weight or length of V.

Which of the following is false?8. A simple path is a path in which all vertices are distinct.a. A cycle is a closed path of length 3 or more in which all vertices are distinct except b. = .A path is a closed cycle of length 3 or more in which all vertices are distinct except c. = .A cycle of length d. k is called a k-cycle.

Which of the following is false?9. A graph a. G is connected if there is a path between any two of its vertices.An edge b. e of G is called a bridge if G – e is disconnected.A vertex c. e of G is called a bridge if G – e is disconnected.A graph d. G is said to be complete if every vertex in G is connected to every other vertex in G.

A graph is regular if every _________ has the same degree.10. segment a. vertexb. pathc. setd.

Page 89: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

77

Chapter VII

Ordered Sets, Lattices and Boolean Algebra

Aim

The aim of this chapter is to:

explain ordered sets•

describe Hasse diagrams of partially ordered sets•

introduce lattices•

explain the use of sum-of-products form for sets•

Objectives

The objectives of this chapter are to:

discuss duality and the idempotent law•

explain bounded lattices•

determine distributive lattices•

introduce boolean algebras as lattices•

discuss truth tables and boolean function•

Learning outcome

At the end of this chapter, the students will be able to:

describe complements, complemented lattices•

explain boolean algebra in detail•

determine duality•

discuss logic gates and circuits•

Page 90: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

78

7.1 Ordered SetsSuppose R is a relation on a set S satisfying the following three properties:

[ ](Reflective) Foranya S, we have aRa.

[ ] (Antisymmetric) If aRb and bRa, then a = b.

[ ] (Transitive) If aRb and bRc, then aRc.

Then R is called a partial order or simply an order relation and RissaidtodefineapartialorderingofS. The set S with the partial order is called a partially ordered set or, simply an ordered set or poset. We write (S, R) when we want to specify the relation R.

Themostfamiliarorderrelation,calledtheusualorder,istherelation≤onthepositiveintegersN or more generally, on any subset of the real numbers R. For this reason, a partial order relation is usually denoted by ; and

a b

isread“a precedes b”.Inthiscasewealsowrite:

a b means a b a b; read“a strictly precedes b” b a means a b; read“b succeeds a” b a means a ; read“b strictly succeeds a”

Whenthereisnoambiguity,thesymbols≤, , , are frequently used instead of , , and , respectively.

7.1.1 Dual OrderLet be any partial ordering of a set S. The relation , that is, a succeeds b, is also a partial ordering of S; it is called the dual order. Observe that a b if and only if b a; hence the dual order is the inverse of the relation

, that is = .

7.1.2 Ordered SubsetsLet A be a subset of an ordered set S and suppose a, b A.Definea b as elements of A whenever a b as elements of S.ThisdefinesapartialorderingofA called the induced order on A. The subset A with the induced order is called an ordered subset of S. Unless otherwise stated or implied, any subset of an ordered set S will be treated as an ordered subset of S.

7.1.3 Quasi-OrderSuppose is a relation on a set S satisfying the following two properties:

[ ](Irreflective) Foranya A, we have a a.

[ ] (Transitive) If a b, b c, then a c.

Then is called a quasi-order on S.

Thereisacloserelationshipbetweenpartialordersandquasi-orders.Specifically,if is a partial order on a set S andwedefinea b to mean a b but a b, then is a quasi-order on S. Conversely, if is a quasi-order on a set Sandwedefinea b to mean a b or a = b, then is a partial order on S. This allows us to switch back and forth between a partial order and its corresponding quasi-orders using whichever is more convenient.

Page 91: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

79

7.1.4 Comparability, Linearly Ordered SetsSuppose a and b are elements in a partially ordered set S. We say a and b are comparable if

a b or b a

that is, if one of them precedes the other. Thus, a and b are non-comparable, written

a b

if neither a b nor b a.

Theword“partial”isusedindefiningapartiallyorderedsetS since some of the elements of S need not be comparable. Suppose, on the other hand, that every pair of elements of S is comparable. Then S is said to be totally ordered or linearly ordered and S is called a chain. Although an ordered set S may not be linearly ordered, it is still possible for a subset A of S to be linearly ordered. Clearly, every subset of a linearly ordered set S must also be linearly ordered.

Product Sets and OrderThereareanumberofwaystodefineanorderrelationontheCartesianproductofgivenorderedsets.Twooftheseways are as follows:Product orderSuppose S and T are ordered sets. Then the following is an order relation on the product set S T, called the product order.

(a, b) (a′,b′) if a≤a′ and b≤b′

Lexicographical orderSuppose S and T are linearly ordered sets. Then the following is an order relation on the product set S T, called the lexicographical or dictionary order:

(a, b) (a′,b′) if a < b or if a = a′ and b < b′

This order can be extended to ........... as follows:

( , ,...., ) ( ′, ′,...., ) if = ′fori=1,2,....,k – 1 and < ′

Note that the lexicological order is also linear.

7.2 Hasse Diagrams of Partially Ordered SetsLet S be a partially ordered set and suppose a, b, belong to S. We say that a is an immediate predecessor of b, or that b is an immediate successor of a, or that b is a cover of a, written, a b

if a < b but no element in S lies between a and b, that is there exists no element c in S such that a < c < b.

Suppose Sisafinitepartiallyorderedset.ThentheorderonS is completely known once we know all pairs a, b in S such that a b, that is, once we know the reaction on S. This follows from the fact that x < y if and only if x

y or there exists elements , ,........., in S such that,

x ........... y

Page 92: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

80

TheHassediagramofafinitepartiallyorderedsetS is the directed graph whose vertices are the elements of S and there is a directed edge from a to b whenever a b in S. (Instead of drawing an arrow from a to b, we sometimes place b higher than a and draw a line between them. It is then understood that movement upwards indicates succession.) In the diagram thus created, there is a directed edge from vertex x to vertex y if and only if x y. Also, there can be no (directed) cycles in the diagram of S since the order relation is antisymmetric.

The Hasse diagram of a poset S is a picture of S; hence it is very useful in describing types of elements in S. Sometimes wedefineapartiallyorderedsetbysimplypresentingitsHassediagram.WenotethattheHassediagramofaposetS need not be connected.

7.2.1 Minimal and Maximal and First and Last ElementsLet S be a partially ordered set. An element a in S is called a minimal element if no other elements of S strictly precedes (is less than) a. Similarly, an element b in S is called a maximal element if no element of S strictly succeeds (is larger than) b. Geometrically speaking, a is a minimal element if no edge enters a (from below) and b is a maximal element if no edge leaves b (in the upward direction). We note that S can have more than one minimal and more than one maximal element.

If Sisinfinite,thenS may have no minimal and no maximal element. For instance, the set Z of integers with the usualorder≤hasnominimalandnomaximalelement.Ontheotherhand,ifSisfinite,thenS must have at least one minimal element and at least one maximal element.

An element a in Siscalledafirstelementifforeveryelementx in S,

a x

that is, if a precedes every other element in S. Similarly, an element b in S is called a last element if for every element y in S,

y b

that is, if b succeeds every other element in S. We note that Scanhaveatmostonefirstelement,whichmustbeaminimal element and S can have at most one last element, which must be a maximal element. Generally speaking, Smayhaveneitherafirstnoralastelement,evenwhenSisfinite.

7.3 LatticesTherearetwowaystodefinealatticeL.OnewayistodefineLintermsofapartiallyorderedset.Specifically,alattice Lmaybedefinedasapartiallyorderedsetinwhichinf(a, b) and sup (a, b) exist for any pairs of elements a, b L.AnotherwayistodefinealatticeL axiomatically. This we do below:

7.3.1AxiomsDefiningLatticeLet L be a nonempty set closed under two binary operations called meet and join, denoted respectively by and .

Then L is called lattice if the following axioms hold where a, b, c, are elements in L:

[ ] Commutative law: (1a) a b = b a (1b) a b = b a

[ ] Associative law: (2a) (a b) c = a (b c) (2b) (a b) c = a (b c)

[ ] Absorption law: (a) a (a b) = a (3b) a (a b) = a

We will sometimes denote the lattice by (L, , ) when we want to show which operations are involved.

Page 93: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

81

7.3.2 Duality and the Idempotent LawThe dual of any statement in a lattice (L, , )isdefinedtobethestatementthatisobtainedbyinterchanging and .

Example:The dual of –

a (b a) = a a is a (b a) = a a

Notice that the dual of each axiom of a lattice is also an axiom.

7.3.3 Lattices and OrderGiven a lattice L,wecandefineapartialorderonL as follows:

a b if a b = a

Analogously,wecoulddefine,

a b if a b = b

We state these results in a theorem.

Theorem:Let L be a lattice. Then:

a• b = a if and only if a b = b.The relation • a b(definedbya b = a or a b = b) is a partial order on L.

Now that we have a partial order on any lattice L, we can picture L by a diagram as was done for partially ordered sets in general.

7.3.4 Sub-Lattices, Isomorphic LatticesSuppose M is a nonempty subset of a lattice L. We say M is a sub-lattice of L if M itself is a lattice (with respect to the operations of L). We note that M is a sub-lattice of L if and only if M is closed under the operations of and of L.

Two lattices L and L′aresaidtobeisomorphicifthereisaone-to-onecorrespondencef: L→L′suchthat,

f (a b) = f (a) f (b) and f (a b) = f (a) f (b)

for any elements a, b in L.

7.4 Bounded LatticesA lattice L is said to have a lower bound 0 if for any element x in L we have 0 x. Analogously, L is said to have an upper bound Iif for any x in L we have x I. we say L is bounded if L has both a lower bound 0 and an upper bound I. In such a lattice we have the identities,

a I = I, a I = a, a 0 = a, a 0 = 0

for any element a in L.

Page 94: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

82

The nonempty integers with the usual ordering,

0 < 1 < 2 < 3 < 4 < ..........

Have 0 as a lower bound but have no upper bound. On the other hand, the lattice P (U) of all subsets of any universal set U is a bounded lattice with U as an upper bound and the empty set as a lower bound.

Suppose L = { .......... and ..........

are upper and lower bounds for L, respectively.

7.5 Distributive LatticesA lattice L is said to be distributive if for any elements a, b, c in L we have the following:

[ ] Distributive law:

(4a) a (b c) = (a b) (a c) (4a) a (b c) = (a b) (a c)

Otherwise, L is said to be non-distributive. We note that by the principle of duality the condition (4a) holds if and only if (4a) holds. Fig. 7.1 (a) is a non-distributive lattice since,

a (b c) = a 0 = a but (a b) (a c) = I c=c

Fig. 7.1 (b) is also a non-distributive lattice. In fact, we have the following characterisation of such lattices.

II

c

ca

ab b

0 0

(a) (b)

Fig. 7.1 Distributive lattices

7.6 Complements, Complemented LatticesLet L be a bounded lattice with lower bound 0 and upper bound I. Let a be an element of L. An element x in L is called a complement of a if,

a x=I and a x = 0

Complements need not exist and need not be unique.

Theorem:Let L be a bounded distributive lattice. Then complements are unique if they exist.

Proof:Suppose x and y are complements of any element a in L. Then,

a x=I, a y=I, a x = 0, a y = 0

Page 95: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

83

Using distributivity,

x=x 0=x (a y) = (x a) (x y) = I (x y) = x y

Similarly,

y=y 0=y (a x) = (y a) (y x) = I (y x) = y x

Thus,

x=x y=y x=y

and the theorem is proved.

7.6.1 Complemented LatticesA lattice L is said to be complemented if L is bounded and every element in L has complement. Fig. 7.1 (b) shows a complemented lattice where complements are not unique. On the other hand, the lattice P (U) of all subsets of a universal set U is complemented and each subset A of U has the unique complement = U A.

7.7 Boolean AlgebraLet B be a nonempty set with two binary operations + and ,aunaryoperation′andtwodistinctelements0and1.Then B is called a Boolean algebra if the following axioms hold where a, b, c are any elements in B:

[ ] Commutative laws: (1a) a + b = b + a (2a) a b = b a[ ] Distributive laws: (2a) a + (b c) = (a + b) (a + c) (2b) a (b + c) = (a b) + (a c)[ ] Identity laws: (3a) a + 0 = a (3b) a 1 = a[ ] Complement laws: (4a) a + a′=1 (4b) a a′=0

We will sometimes designate a Boolean algebra by ⟨B, +, ,′,0,1⟩ when we want to emphasise its six parts. We say 0 is the zero element, 1, is the unit element and a′isthecomplementofa. We will usually drop the symbol and use juxtaposition instead. Then (2b) is written a(b+c) = ab+ac which is the familiar algebraic identity of rings andfields.However,(2b)becomesa+bc= (a+b)(a+c), which is certainly not a usual identity in algebra.

The operations +, and′arecalledsum,productandcomplement,respectively.Weadopttheusualconventionthat,unlessweareguidedbyparentheses,′hasprecedenceover and has precedence over +.

Example:A+b c means a+ (b c) and not (a+b) c; a b′meansa (b′)andnot(a b)′

Of course when a+b c is written a+bc then the meaning is clear.

7.7.1 Subalgebras, Isomorphic Boolean AlgebrasSuppose C is a nonempty subset of a Boolean algebra B. We say C is subalgebra of B if C itself is a Boolean algebra (with respect to the operations of B). We note that C is a subalgebra of B if and only if C is closed under the three operations of B, i.e., +, and′.

Two Boolean algebras B and B′aresaidtobeisomorphicifthereisaone-to-onecorrespondencef: B→B′whichpreserves the three operations, i.e., such that, for any elements a, b in B,

Page 96: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

84

f (a + b) = f (a) + f (b), f (a b) = f (a) f (b) and f (a′)=f (a)′

7.8 DualityThe dual of any statement in a Boolean algebra B is the statement obtained by interchanging the operations + and

and interchanging their identity elements 0 and 1 in the original statement.

Example:The dual of,

(1 + a) (b + 0) = b is (0 a) + (b + 1+ b)

Observe the symmetry in the axioms of a Boolean algebra B. That is, the dual of the set of axioms of B is the same as the original set of axioms. Accordingly, the important principle of duality holds in B.

Theorem: (Principle of Duality)The dual of any theorem in a Boolean algebra is also a theorem.

In other words, if any statement is a consequence of the axioms of a Boolean algebra, then the dual is also a consequence of those axioms since the dual statement can be proven by using the dual of each step of the proof of the original statement. 7.9 Boolean Algebras as LatticesEvery Boolean algebra Bsatisfiestheassociative,commutativeandabsorptionlawsandhenceisalatticewhere+and are the join and meet operations, respectively. With respect to this lattice, a + 1 = 1 implies a≤1anda 0 =0implies0≤a, for any elements a B. Thus B is a bounded lattice. Furthermore, axioms [ ] and [ ] shows that is also distributive and complemented. Conversely, every bounded, distributive and complemented lattice L satisfiestheaxioms[ ] through [ ]. Accordingly, we have the following:

Theorem:The following are equivalent in a Boolean algebra:

a+b=b, (2) a b=a, (3) a′+b = 1 (4) a b′=0

Thus, in a Boolean algebra we can write a≤b whenever any of the above four conditions is known to be true.

7.10 Sum-Of-Products Form for SetsThis section motivates the concept of the sum-of-products form in Boolean algebra by an example of set theory. ConsidertheVenndiagraminfig.7.2ofthreesetsA, B and C. Observe that these sets partition the rectangle (universal set) into eight numbered sets which can be represented as follows:

A1. B CA2. B A3. C

4. B CA5.

6. B 7. C8.

Each of these eight sets is of the form A* B* C*where:

A*=A or , B*=B or , C*=C or

Page 97: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

85

Consider any nonempty set expression E involving the sets A, B and C, say,

E = [ ( )] [ (A )]

A

5 2 6

7

3 41

B

8C

Fig. 7.2 Sum-of-products form for sets

Then Ewillrepresentsomeareainfig.7.2andhencewilluniquelyequaltheunionofoneormoreoftheeightsets.

Suppose we now interpret a union as a sum and an intersection as a product. Then the above eight sets are products and the unique representation of E will be a sum (union) of products. This unique representation of E is the same as the complete sum-of-products expansion in Boolean algebras.

7.11 Sum-Of-Products Form for Boolean AlgebrasConsider a set of variables (or letters or symbols), say , ,.......... . A Boolean expression E in these variables, sometimes written E ( ,.........., ), is any variable or any expression built up from the variables using the Boolean operations +, and′.

= (x+y′z)′+(xyz′+x′y)′ and = ((xy′z′+y)′+x′z)′

are Boolean expressions in x, y and z.

A literal is a variable or complemented variable, such as x, x′,y, y′andsoon.afundamentalproductisaliteralora product of two or more literals in which no two literals involve the same variable. Thus,

xz′,xy′z, x, y′,x′yz

are fundamental products, but xyx′z and xyzy are not. Note that any product of literals can be reduced to either 9 or a fundamental product.

A fundamental product is said to be contained in (or included in) another fundamental product if the literals of are also literals of .

Example:x′z is contained in x′yz is contained in x′yz, but x′z is not contained in xy′z since x′isnotaliteralofxy′z. Observe that if is contained in , say = Q, then, by the absorption law,

+ = + Q =

Thus, for instance, x′z+x′yz=x′z

Page 98: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

86

Definition: A Boolean expression E is called a sum-of-products expression if E is a fundamental product or the sum of two or more fundamental products none of which is contained in another.

Definition: Let E be any Boolean expression. A sum-of-products form of E is an equivalent Boolean sum-of-products expression.

7.12 Logic Gates and CircuitsLogic circuits are structures which are built up from certain elementary circuits called logic gates. Each logic circuit may be viewed as a machine L which contains one or more input devices and exactly one output devices. Each input device in Lsendsasignal,specifically,abit(binarydigit),

0 or 1

to the circuit L and L processes the set of bits to yield on output bit. Accordingly, an n-bit sequence may be assigned to each input device and L processes the input sequences one bit at a time to produce an n-bit output sequence. First wedefinethelogicgatesandthenweinvestigatethelogiccircuits.

7.12.1 Logic GatesThere are three basic logic gates as described below. We adopt the convention that the lines entering the gate symbol from the left are input lines and the single line on the right is the output line.

7.12.1.1 OR GateFig. 7.3 (a) shows an OR gate with input A and B and output Y=A+Bwhere“addition”isdefinedbythe“truthtable”infig.7.3(b).ThustheoutputY = 0 only when inputs A = 0 and B = 0. Such an OR gate may, have more than two inputs. Fig. 7.3 (c) shows an OR gate with four inputs, A, B, C, D and output Y=A+B+C+D. The output Y = 0 if and only if all the inputs are 0.

AY=A+B

(a) OR gate (b) (c)

Y=A+B+C+D

A B A+B

1100

1010

1110

BOR

OR

A

B

C

D

Fig. 7.3 OR gate

The OR gate only yields 0 when all input bits are 0. This occurs in the 2nd, 5th and 7th positions. Thus the output is the sequence Y = 10110101.

7.12.1.2 AND GateFig. 7.4 (a) shows an AND gate with inputs A and B and output Y=A∙B (or simply Y=AB)where“multiplication”isdefinedbythe“truthtable”infig.7.4(b).ThustheoutputY = 1 when inputs A = 1 and B = 1; otherwise Y = 0. Such an AND gate may have more than two inputs. Fig. 7.4(c) shows an AND gate with four inputs, A, B, C, D and output Y=A∙B∙C∙D. The output Y = 1 if and only if all the inputs are 1.

Suppose,forinstance,theinputdatafortheANDgateinfig.7.4(c)arethefollowing8-bitsequences:

A = 11100111, B = 01111011, C = 01110011, D = 11101110

The AND gate only yields 1 when all input bits are 1. This occurs only in the 2nd, 3rd and 7th positions. Thus, the output is the sequence Y = 01100010.

Page 99: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

87

AY=A∙B

(a) AND gate (b) (c)

Y=A∙B∙C∙D

A B A∙B

1100

1010

1000

BAND

A

B

C

D

AND

Fig. 7.4 AND gate

7.12.1.3 NOT GateFig. 7.5(a) shows a NOT gate, also called an inverter, with input A and output Y = A′where“inversion”,denotedbytheprime,isdefinedbythe“truthtable”infig.7.5(b).ThevalueoftheoutputY = A′istheoppositeoftheinputA; that is, A′=1whenA = 0 and A′=0whenA = 1. We emphasise that a NOT gate can have only one input, whereas the OR and AND gates may have two or more inputs.

Fig. 7.5 NOT gate

Suppose, for instance, a NOT gate is asked to process the following three sequences:

= 110001, = 01110000, = 101100111000

The NOT gate changes 0 to 1 and 1 to 0. Thus,

= 001110, = 01110000, = 010011000111

are the three corresponding outputs.

7.12.2 Logic CircuitsA logic circuit L is a well-formed structure whose elementary components are the above OR, AND and NOT gates. Fig. 7.6 is an example of a logic circuit with inputs A, B, C and output Y. A dot indicates a place where the input line splits so that its bit signal is sent in more than one direction. Working from left to right, we express Y in terms of the inputs A, B, C as follows. The output of the AND gate is A∙B, which is then negated to yield (A∙B)′.Theoutput of the lower OR gate is A′+C, which is then negated to yield (A′+C)′.TheoutputoftheORgateontheright, with input (A∙B)′and(A′+C)′,givesusourdesiredrepresentation,thatis,

Y = (A∙B)′+(A′+C)′

Page 100: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

88

A

B

C

Y

Fig. 7.6 Logic circuits

7.12.2.1 AND-OR CircuitsThe logic circuit L which corresponds to a Boolean sum-of-products expression is called an AND-OR circuit. Such a circuit L has several input, where:

Some of the inputs or their complements are fed into each AND gate.•The outputs of all the AND gates are fed into a single OR gate.•The output of the OR gate is the output for the circuit L.•

The following illustrates this type of a logic circuit.

7.12.2.2 NAND and NOR GatesThere are two additional gates which are equivalent to combinations of the above basic gates.

ANANDgate,picturedinfig.7.7(a),isequivalenttoanANDgatefollowedbyaNOTgate.•ANORgate,picturedinfig.7.7(b),isequivalenttoanORgatefollowedbyaNOTgate.•

Thetruthtablesforthesegates(usingtwoinputsAandB)appearinfig.7.7(c).TheNANDandNORgatescanactually have two or more inputs just like the corresponding AND and OR gates. Furthermore, the output of a NAND gate is 0 if and only if all the inputs are 1 and the output of a NOR gate is 1 if and only if all the inputs are 0.

A A

B

(a) NAND gate (b) NOR gate (c)

BY Y

A B NAND NOR

1100

1010

0111

0001

Fig. 7.7 NAND and NOR gates

Observe that, the only difference between the AND and NAND gates between the OR and NOR gates is that the NAMD and NOR gates are each followed by a circle. Some texts also use such a small circle to indicate a complement before a gate.

Example:TheBooleanexpressionscorrespondingtotwologiccircuitsinfig.7.8areasfollows:

Y = (A′B)′, (b)Y = (A′+B′+C)′

Page 101: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

89

YABC

(b)

A

BY

(a)

7.13 Truth Tables, Boolean FunctionsConsider a logic circuit L with n = 3 input devices A, B, C and output Y, say

Y=A∙B∙C+A∙B′∙C+A′∙B

Each assignment of a set of three bits to the inputs A, B, C yields an output bit for Y. All together there are = = 8 possible ways to assign bits to the inputs as follows:

000, 001, 010, 011, 100, 101, 110, 111

We emphasise that these three = 8-bit sequence contain the eight possible combinations of the input bits.

The truth table T = T (L) of the circuit L consists of the output sequence Y that corresponds to the input sequence A<B, C. This truth table T may be expressed using fractional or relational notation, that is, T may be written in the form,

T (A, B, C) = Y or T (L) = [A, B, C; Y]

Consider a logic circuit L with n input devices. There are many ways to form n input sequences , ,......., so that they contain the different combinations of the input bits.

: Assign bits which are 0’s followed by bits which are 1’s.: Repeatedly assign bits which are 0’s followed by bits which are 1’s.: Repeatedly assign bits which are 0’s followed by bits which are 1’s.

And so on. The sequences obtained in this way will be called special sequences. Replacing 0 by 1 and 1 by 0 in the special sequences yields the complements of the special sequences.

7.13.1 Boolean FunctionsLet E be a Boolean expression with n variables , ,............, . The entire discussion above can also be applied to E where now the special sequences are assigned to the variables , ,............ instead of the input devices

, ,..........., . The truth table T = T (E) of EisdefinedinthesamewayasthetruthtableT = T (L) for a logic circuit L.

Example:The Boolean expression,

E = xyz+xy′z+x′y

it yields the truth table,

T (00001111, 00110011, 01010101) = 00110101

or simple T (E) = 00110101. Where we assume the input consists of the special sequences.

Page 102: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

90

SummaryThemostfamiliarorderrelation,calledtheusualorder,istherelation≤onthepositiveintegers• N or more generally, on any subset of the real numbers R.Theword“partial”isusedindefiningapartiallyorderedset• S since some of the elements of S need not be comparable.TheHassediagramofafinitepartiallyorderedset• S is the directed graph whose vertices are the elements of S and there is a directed edge from a to b whenever a b in S.Therearetwowaystodefinealattice• L.OnewayistodefineLintermsofapartiallyorderedset.Specifically,alattice Lmaybedefinedasapartiallyorderedsetinwhichinf(a, b) and sup (a, b) exist for any pairs of elements a, b L.AnotherwayistodefinealatticeL axiomatically.The dual of any statement in a lattice (• L, , )isdefinedtobethestatementthatisobtainedbyinterchanging

and .A lattice • L is aid to have a lower bound 0 if for any element x in L we have 0 x.The dual of any statement in a Boolean algebra • B is the statement obtained by interchanging the operations + and and interchanging their identity elements 0 and 1 in the original statement.A Boolean expression • E is called a sum-of-products expression if E is a fundamental product or the sum of two or more fundamental products none of which is contained in another.Logic circuits are structures which are built up from certain elementary circuits called logic gates. Each •logic circuit may be viewed as a machine L which contains one or more input devices and exactly one output devices.A logic circuit • L is a well-formed structure whose elementary components are the above OR, AND and NOT gates.

ReferencesShankar Rao G., 2009.• DiscreteMathematicalStructure. New Age International.Acharjya & Sreekumar. D. P., 2009. • Fundamental Approach to DiscreteMathematics. New Age International. Lipschutz. S., 1997. • Schaum’sOutlineofDiscreteMathematics, 2nd ed., McGraw-Hill.Kolman B., 2008. • DiscreteMathematicalStructures, 6th ed., Prentice Hall.

Recommended ReadingMonoids,BooleanAlgebras,MateriallyOrderedSets.• Available at: <http://www.math.cmu.edu/~wn0g/noll/MBM.pdf> [Accessed 11 April 2011].Booleanalgebrasoverpartiallyorderedset• . Available at: <http://spot.colorado.edu/~szendrei/BLAST2010/bekkali.pdf> [Accessed 13 April 2011].LatticesandBooleanalgebra• . Available at: <http://www.math.hawaii.edu/~tom/612notes5.pdf> [Accessed 13 April 2011].

Page 103: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

91

Self AssessmentThe set 1. S with the partial order is called a partially ordered set or, simply an ordered set or ___________.

poseta. cosetb. arrayc. subsetd.

Themostfamiliarorderrelation,calledthe__________,istherelation≤onthepositiveintegers2. N or more generally, on any subset of the real numbers R.

induced order a. partial order b. usual orderc. ordered setd.

Which of the following is false?3. When there is no ambiguity, the symbols≤,a. , , are frequently used instead of , , and , respectively.When there is no ambiguity, the symbols b. , , and , are frequently used insteadof≤, , , respectively. The relation c. , that is, a succeeds b, is also a partial ordering of S; it is called the dual order.Theword“partial”isusedindefiningapartiallyorderedsetd. S since some of the elements of S need not be comparable.

The subset 4. A with the ___________ is called an ordered subset of S.induced order a. partial order b. usual orderc. ordered subsetd.

There is a close relationship between partial orders and ____________.5. usual ordera. ordered subsetb. induced orderc. quasi-ordersd.

Which of the following is true?6. A Boolean expression a. E is called a product-of-products expression if E is a fundamental product or the sum of two or more fundamental products none of which is contained in another.A Boolean expression b. E is called a product-of-sums expression if E is a fundamental product or the sum of two or more fundamental products none of which is contained in another.A Boolean expression c. E is called a sum-of-products expression if E is a fundamental product or the sum of two or more fundamental products none of which is contained in another.A Boolean expression d. E is called a sum-of-differences expression if E is a fundamental product or the sum of two or more fundamental products none of which is contained in another.

Page 104: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

92

Which of the following is false?7. An element a. a in S is called a minimal element if no other elements of S strictly precedes (is less than) a.We will sometimes denote the lattice by (b. L, , ) when we want to show which operations are involved.We will sometimes denote the lattice by (c. L, , ) when we want to show which operations are involved.Md. is closed under the operations of and of L.

The dual of any statement in a __________ (8. L, , )isdefinedtobethestatementthatisobtainedbyinterchanging and .

latticea. arrayb. subsetc. ordered subsetd.

Which of the following is false?9. A lattice a. L is said to have a lower bound 0 if for any element x in L we have 0 x.A lattice b. L is said to be complemented if L is bounded and every element in L has complement.The dual of any statement in a Boolean algebra c. B is the statement obtained by interchanging the operations + and and interchanging their identity elements 0 and 1 in the original statement.A lattice d. L is said to have a lower bound 0 if for any element x in L we have 0 x.

Two Boolean algebras 10. B and B′aresaidtobe___________ifthereisaone-to-onecorrespondencef: B→B′which preserves the three operations.

homeographica. isomorphicb. finitegraphc. infinitegraphd.

Page 105: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

93

Chapter VIII

Binary Trees

Aim

The aim of this chapter is to:

introduce the concept of binary tree•

explain complete and extended binary trees•

determine how to represent binary trees in memory•

Objectives

The objectives of this chapter are to:

discuss how to traverse binary trees•

describe binary search trees•

distinguish general trees from binary trees•

Learning outcome

At the end of this chapter, the students will be able to:

explain the concept of spanning tree•

understand Prim’s algorithm•

discuss Kruskal’s algorithm•

Page 106: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

94

8.1 IntroductionThe binary tree is a fundamental structure in mathematics and computer science. Some of the terminology of rooted trees, such as, edge, path, branch, leaf, depth and level number, will also be used for binary trees. However, we will use term node, rather than vertex, with binary trees. We emphasise that a binary tree is not a special case of a rooted tree; they are different mathematical objects.

8.2 Binary TreesA binary tree Tisdefinedasafinitesetofelements,callednodes,suchthat:

T• is empty (called the null tree or empty tree), orT• contains a distinguished node R, called the root of T and the remaining node of T form an ordered pair of disjoint trees and .

If T does contain a root R, then the two trees and are called, respectively, the left and right subtrees of R. If is nonempty its root is called the left successor of R; similarly, if is nonempty, then its root is called the right

successor of R.

TheabovedefinitionofabinarytreeT is recursive, since Tisdefinedintermsofthebinarysubtrees and . This means, in particular, that every node N of T contains a left and right sub tree and either sub tree or both sub trees may be empty. Thus every node N in T has 0, 1, or 2 successors. A node with no successors is called a terminal node. Thus both sub trees of a terminal node are empty.

8.2.1 Picture of Binary TreeA binary tree T is frequently presented by a diagram in the plane called a picture of T.Specifically,thediagraminfig.8.1(a)representsabinarytreeasfollows:

T• consists of 11 nodes, represented by the letters A through L, excluding I.The root • T is the node A at the top of the diagram.A left-downward slanted line at a node • N indicates a left successor of N; and a right-downward slanted line at N indicates a right successor of N.

Accordingly,infig.8.1(a)B• is a left successor and C is a right successor of the root A.The left sub tree of the root • A consists of the nodes B, D, E and F and the right sub tree of A consists of the nodes C, G, H, J, K and L.The nodes • A, B, C and H have two successors, the nodes E and J have only one successor and the nodes D, F, G, L and K have no successors i.e., they are terminal nodes.

Fig. 8.1 Picture of binary tree

Page 107: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

95

8.2.2 Similar Binary TreesBinary trees T and T′aresaidtobesimilariftheyhavethesamestructureor,inotherwords,iftheyhavesameshape.The trees are said to be copies if they are similar and if they have the same contents at corresponding nodes.

8.3 Complete and Extended Binary TreesThis section considers two special kinds of binary trees.

8.3.1 Complete Binary TreesConsider any binary tree T. Each node of T can have at most two children. Accordingly, one can show that level r of T can have at most nodes. The tree T is said to be complete if all its levels, except possibly the last, have the maximum number of possible nodes at the last level appear as far as possible. Thus there is a unique complete tree

with exactly n nodes (where we ignore the contents of the nodes). The complete tree with 26 nodes appears infig.8.2below.

1

2 3

4 65 7

8 9 10 12 1411 13 15

16 18 20 22 2417 19 21 23 25 26

Fig. 8.2 Complete binary trees The nodes of the complete binary tree infig.8.2havebeenpurposelylabelledbytheintegers1,2,..........,26,left to right, generation by generation. With this labelling, one can easily determine the children and parent of any node K in any complete tree .Specifically,theleftandrightchildrenofnode9arethenodes2*K and 2*k + 1 and the parent of K is the node [K / 2].

8.3.2 Extended Binary Trees: 2-TreesA binary tree T is said to be a 2-tree or an extended binary tree if each node N has either 0 or 2 children. In such a case, the nodes with two children are called internal nodes and the nodes with 0 children are called external nodes. Sometimes the nodes are distinguished in diagrams by using circles for internal nodes and squares for external nodes.

Theterm“extendedbinarytree”comesfromthefollowingoperation.ConsideranybinarytreeT, such as the tree in fig.8.3.ThenTmaybe“converted”intoa2-treebyreplacingeachemptysubtreebyanewnode.Observethatthenew tree is, indeed a 2-tree. Furthermore, the nodes in the original tree T are now the internal nodes in the extended tree and the new nodes are the external nodes in the extended tree. We note that if a 2-tree has n internal nodes, then it will have n + 1 external nodes.

Page 108: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

96

(a) Binary tree T. (b) Extended 2-tree.

Fig. 8.3 Extended binary trees: 2-trees

8.4 Representing Binary Trees in MemoryLet T be a binary tree. This section discusses two ways of representing Tinmemory.Thefirstandusualwayiscalledthe linked representation of T and is analogous to the way linked, lists are represented in memory. The second way, which uses a single array, is called the sequential representation of T. The main requirement of any representation of T is that one should have direct access to the root R of T and, given any node N of T, one should have direct access to the children of N.

8.4.1 Linked Representation of Binary TreesConsider a binary tree T. Unless otherwise stated or implied, T will be maintained in memory by means of a linked representation which uses three parallel arrays, INFO, LEFT and RIGHT and a pointer variable ROOT as follows. First of all, each node N of T will correspond to a location K such that:

INFO[K] contains the data at the node • N.LEFT[K] contains the location of the left child of node • N.RIGHT[K] contains the location of the right child of node • N.

Furthermore, ROOT will contain the location of the root R of T. If any sub tree is empty, then the corresponding pointer will contain the null value; if the tree T itself is empty , then ROOT will contain the null value.

8.4.2 Sequential Representation of Binary TreesSuppose Tisabinarytreethatiscompleteornearlycomplete.ThenthereisanefficientwayofmaintainingT in memory called the sequential representation of T. This representation uses only a single linear array TREE together with a pointer variable END as follows:

The root • R of T is stored in TREE[1].If a node • N occupies TREE[K], then its left child is stored in TREE[2*K] and its right child stored in TREE [2*K + 1].END contains the location of the last node of • T.

Page 109: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

97

Fig. 8.4 Sequential representation of binary tree

Furthermore, the node N at TREE[K] contains an empty left subtree or an empty right according as 2*K or 2*K + 1 exceeds END or according as TREE[2*K] or TREE [2*K + 1] contains NULL value.

The sequential representation of the binary tree Tinfig.8.4(a)appearsinfig.8.4(b).Observethatwerequire14locations in the array TREE even though T has only 9 nodes. Generally speaking, the sequential representation of a tree with depth d will require an array with approximately elements. Accordingly, this sequential representation isusuallyinefficientunless,asstatedabove,thebinarytreeT is complete or nearly complete.

8.5 Traversing Binary TreesThere are three standard ways of traversing a binary tree T with root R. These three algorithms, called preorder, inorder and postorder, are as follows:

Preorder•Process the root � R.Traverse the left sub tree of � R in preorder.Traverse the right sub tree of � R in preorder.

Inorder•Traverse the left sub tree of � R in inorder.Prcess the root � R.Traverse the right sub tree of � R in inorder.

Postorder•Traverse the left sub tree of � R in postorder.Traverse the right sub tree of � R in postorder.Process the root � R.

Observe that each algorithm contains the same three steps and that the left subtree of R is always traversed before the right subtree. The difference between the algorithms is the time at which the root Risprocessed.Specifically,inthe“pre”algorithm,therootRisprocessedbeforethesubtreearetraversed;inthe“in”algorithm,therootR is processedbetweenthetraversalsofthesubtrees;andinthe“post”algorithm,therootR is processed after the sub trees are traversed.

The three algorithms are sometimes called, respectively, the node-left-right (NLR) traversal, the left-node-right (LNR) traversal and the left-right-node (LRN) traversal.

Page 110: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

98

8.6 Binary Search TreesThis section discusses one of the most important data structure in computer science, a binary search tree. This structureenablesustosearchforandfindanelementwithanaveragerunningtimef (n) = 0 ( n), where n is the number of data items. It also enables us to easily insert and delete elements. This structure contracts with the following structures:

Sorted linear array• :Hereonecansearchforandfindanelementwithrunningtimef (n) = 0 ( n). However, inserting and deleting elements is expensive since, on the average, it involves moving 0 (n) elements.Linked list• :Hereonecaneasilyinsertanddeleteelements.However,itisexpensivetosearchandfindanelement, since one must use a linear search with running time f(n) = 0 (n).

Althougheachnodeinabinarysearchtreemaycontainanentirerecordofdata,thedefinitionofthetreedependsonagivenfieldwhosevaluesaredistinctandmatbeordered.

Definition: Suppose T is a binary tree. Then T is called search tree if each node N of T has the following property.

The value of N is greater than every value in the left sub tree of N and is less than every value in the right sub tree of N.

ItisnotdifficulttoseetheabovepropertyguaranteesthattheinordertraversalsofT will yield a sorted listing of the elements of T.

8.7 General Trees and Binary TreesSuppose T is a general tree. Then we may assign a unique binary tree T′toT as follows. First of all, the nodes of the binary tree T′willbethesameasthenodesofthegeneraltreeT and the root of T′willbetherootofT. Let N be an arbitrary node of the binary tree T′.ThentheleftchildofN in T′willbethefirstchildofthenodeN in the general tree T and the right child of N in T′willbethenextsiblingofN in the general tree T.

8.8 Spanning TreeSuppose G = (V, E) be a graph. A sub graph H of G is said to be a spanning sub graph of G if both H and G has same vertex set. A spanning tree of a graph G is a tree which is spanning sub graph of G.

8.9 Prim’s AlgorithmThefollowingstepsareusedinPrim’salgorithmforfindingaminimumspanningtreeofagraphG. Assume that the graph G has n vertices.

Choose any vertex • of G.Choose an edge • = of G such that and has smallest weight among the edges of G incident with .If edges • , ,........., have been chosen involving vertices , ,......, , then choose an edge = u v with u { , ,........, } and v { , ,........, } such that has smallest weight among the edges of G.The third step is repeated until we are getting the total (• n – 1) edges.

Consider the following connected weighted graph G. Here the number of vertices are n = 7.

Page 111: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

99

G:

A

D

EC

F

64 4

7

511 5G

8

3

9

B

7

10 10

A

D

EC

F

64 4

7

511 6G

5

3

9

B

7

10 10

A

D

EC

F

64 4

7

511 5G

8

3

9

B

7

10 10

A

D

EC

F

64 4

7

511 5G

8

3

9

B

7

10 10

(V1= A; One Can Choose any other Vertex)

(e2= BG; so that v3= G; An alternative choice is AG)

(e3= GD; so that v4= D; No alternative choice)

(e 1= AB, So that v2=B)

Fig. 8.5 Prim’s algorithm

A

D

EC

F

64 4

7

511 5G

8

3

9

B

7

10 10

A

D

EC

F

64 4

7

511 5G

8

3

9

B

7

10 10

A

D

EC

F

64 4

7

511 5G

8

3

9

B

7

10 10

A

D

EC

F

6

4

7

5G

3

B

7

10

(e4= AF; So that v4= F; No alternative Choice)

(e6 = GC; So that v6= C; No alternative choice)

(e5= FE; So that v5= E; An alternative choice is GC)

w(T)= 32

Fig. 8.6 Prim’s algorithm

Since the total edges are 6 = (7 – 1), the process terminates. Hence, the minimum spanning tree T is given as shown inthefig.8.5andfig.8.6.

8.10 Kruskal’s AlgorithmThefollowingstepsareusedinKruskal’salgorithmforfindingaminimumspanningtreeofagraphG. Assume that the graph G has n vertices.

Choose an edge • of G, which is a small as possible and must not be a loop.Suppose the edges • , ,.........., have been chosen. Then the edge can be chosen such that,

The induces sub graph � G [ , ,.........., ] is acyclic and Weight of � is as small as possible.

The second step is to be repeated until we are getting the total (• n – 1) edges.

Page 112: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

100

Consider the following connected weighted graph G. Here the number of vertices n = 5. On applying Kruskal’s algorithm we have the following stages.

G:

A

E B

CD2 1 2

3 33

3

34

A

E B

CD2 1 2

3 33

3

34

A

E B

CD2 1 2

3 33

3

34

A

E B

CD2 1 2

3 33

3

34

A

E B

CD2 1 2

3 33

3

34

T:

A

E B

CD2 1 2

3

(e1= BD: w(e1) =1; No alternative choice)

(e3= BC; w(e3) = 2; No alternative choice)

(e2 = DE: w(e2) = 2; An alternative choice is BC)

(e4 = AC; w(e4) = 3; Alternative choices are AE and AD)

w(T) = 1 + 2 + 2 + 3 = 8

Fig. 8.7 Kruskal’s algorithm

Since the total edges are 4 = (5 – 1), the process terminates. Hence, the minimum spanning tree T is given as shown infig.8.7

Page 113: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

101

SummaryThe binary tree is a fundamental structure in mathematics and computer science. Some of the terminology of •rooted trees, such as, edge, path, branch, leaf, depth and level number, will also be used for binary trees.A binary tree • T is frequently presented by a diagram in the plane called a picture of T.Binary trees • T and T′aresaidtobesimilariftheyhavethesamestructureor,inotherwords,ifthehavethesame shape.A binary tree • T is said to be a 2-tree or an extended binary tree if each node N has either 0 or 2 children.There are three standard ways of traversing a binary tree • T with root R. These three algorithms, called preorder, inorder and postorder.The three algorithms are sometimes called, respectively, the node-left-right (NLR) traversal, the left-node-right •(LNR) traversal and the left-right-node (LRN) traversal.The value of • N is greater than every value in the left sub tree of N and is less than every value in the right sub tree of N.

ReferencesShankar Rao G., 2009.• DiscreteMathematicalStructure. New Age International.Acharjya & Sreekumar. D. P., 2009. • Fundamental Approach to DiscreteMathematics. New Age International. Lipschutz. S., 1997. • Schaum’sOutlineofDiscreteMathematics, 2nd ed., McGraw-Hill.Kolman B., 2008. • DiscreteMathematicalStructures, 6th ed., Prentice Hall.

Recommended Reading

BinaryTrees• . Available at: <http://cslibrary.stanford.edu/110/BinaryTrees.pdf> [Accessed 14 April 2011].BinaryTree• . Available at: <http://oz.nthu.edu.tw/~d947207/chap9_tree.pdf> [Accessed 15 April 2011]. Complete Binary Tree. Available at: <http://www.cs.colorado.edu/~main/supplements/pdf/notes10a.pdf> •[Accessed 15 April 2011].BinaryTrees.• Available at: <http://www.cs.ccsu.edu/~jones/chap17.pdf> [Accessed 15 April 2011].

Page 114: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

102

Self AssessmentA binary tree 1. T is frequently presented by a diagram in the plane called a ___________ of T.

picturea. subsetb. setc. treed.

Which of the following is false?2. Binary trees a. T and T′aresaidtobesimilariftheyhavethesamestructureor,inotherwords,ifthehavethe same shape.The trees are said to be copies if they are similar and if they have the same contents at corresponding b. nodes.Binary trees c. T and T′aresaidtobesimilariftheyhavethesamestructureor,inotherwords,ifthehavethe different shape.The value of d. N is greater than every value in the left sub tree of N and is less than every value in the right sub tree of N.

What is said to be a 2-tree or an extended binary tree if each node 3. N has either 0 or 2 children?extended binary tree a. binary treeb. ordered subsetc. partial orderd.

Sometimes the nodes are distinguished in diagrams by using __________ for internal nodes and squares for 4. external nodes.

segments a. verticesb. pathsc. circlesd.

What contains the data at the node 5. N?INFO[K]a. LEFT[K]b. RIGHT[K]c. ROOT[K] d.

If any __________ is empty, then the corresponding pointer will contain the null value; if the tree 6. T itself is empty , then ROOT will contain the null value.

subgrapha. ordered subset b. sub treec. subsetd.

Page 115: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

103

Which of the following is false?7. The root a. R of T is stored in TREE[1].If a node b. N occupies TREE[K], then its left child is stored in TREE[2*K] and its right child stored in TREE [2*K + 1].END contains the location of the last node of c. T.The root d. R of T is stored in TREE[K].

A spanning tree of a graph 8. G is a tree which is spanning ___________ of G.subgrapha. odered subset b. sub treec. subsetd.

Preorder, inorder and postorder are three standard ways of traversing a ___________ 9. T with root R.spanning treea. treeb. graphc. binary treed.

Which of the following is true?10. The value of a. N is smaller than every value in the left sub tree of N and is less than every value in the right sub tree of N.The value of b. N is greater than every value in the left sub tree of N and is less than every value in the right sub tree of N.The value of c. N is greater than every value in the right sub tree of N and is less than every value in the right sub tree of N.The value of d. N is greater than every value in the left sub tree of N and is greater than every value in the right sub tree of N.

Page 116: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

104

Chapter IX

Group Theory, Languages and Finite State Machines

Aim

The aim of this chapter is to:

introduce students to binary operations•

elaborate algebraic structures•

discuss semi-group•

explain the use of languages and grammar in binary operations•

Objectives

The objectives of this chapter are to:

determine homomorphism of semi-groups•

describe isomorphism of semi-groups•

discuss the concept of monoid, groups and sub-groups•

explainfinitestatemachines•

Learning outcome

At the end of this chapter, the students will be able to:

explain centre of a group and index of sub-group•

describe cosets•

understand alphabet, words, free semi-group in detail•

discuss languages, regular expressions and regular languages•

Page 117: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

105

9.1 Binary OperationsA binary operation * in a set A is a function from A A to A.

Note:ThewordbinaryisusedintheabovedefinitionbecauseweareassociatinganelementofthesetA with a pair of elements of A. We can also use symbols like 0, +, , etc.

Notation: If * is a binary operation (binary composition) in a set A then for the * image of the ordered pair (a, b) A A, we write a*b (or * (a, b)).

Example:Addition (+) is a binary operation in the set of natural number N. Set of integers Z and set of real numbers R.Multiplication ( ) is a binary operation in N, Z, Q, R and C.

Union, intersection and difference are binary operations in P (A), the power set of A.

9.2 General PropertiesLet A be any set. A Binary operation * A A→A is said to be commutative if for every a, b A.

a*b=b*a

Example:Addition is commutative in the set of natural numbers.

Let A be a non-empty set. A binary operation *; A A→A is said to be associative if,

(a*b) * c=a* (b*c) for every a, b, c A.

Example:The operations of addition and multiplication over the natural numbers are associative.

Let * be a binary operation on a set A. If there exists an element A such that * a=a for every a A, then the element is called the left identity with respect to *. Similarly, if there exists an element A such that a *

= a for every a A, the element is called the right identity in A with respect to *.

Let * be a binary operation on a nonempty set A. If these exists an element e A such that e*a=a*e=a for every a A, then the element e is called identity with respect to * in A.

Example:Zeroistheidentityelementinthesetintegerswithrespecttothebinaryoperationsaddition(i.e.,+). 9.3 Algebraic Structures (Algebraic Systems)A system consisting of a nonempty set S and one or more n-ary operations on the S is called an algebraic system. If A is a nonempty set and , , ,............. are n-ary operations on A, then (S, , , ,.......) is an algebraic systems (or structure). The operations on a set S,defineastructureontheelementsofS, therefore S is called an algebraic structure.

If A is a set and * is a binary operation on A, then (A, *) is called an algebraic structure.

Example:Let R be the set of real numbers, then (R, +) is an algebraic structure.

Let R be the set of integers. Addition (+) and multiplication ( ), are binary operations on Z. The system (Z, +) is an algebraic structure and (Z,∙)isalsoanalgebraicstructure.

If • N denotes the set of natural numbers then (N, +) is an algebraic structure.

Page 118: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

106

9.3.1 GroupoidWehavedefinedanalgebraicstructure.If*isabinaryoperationonanonemptysetA. Such that a*b A, then we say that A is closed the operation.

Example:If A = {0, 1}. Then A is closed under multiplication.We have 0 0 = 0, 0 1 = 0, 0 0 and 1 1 = 1But A is not closed under the binary operation addition. Since 1 + 1 = 2 does not belong to A.

A groupoid is an algebraic structure consisting of nonempty set A and a binary operation *, which is such that A is closed under *.

Example:The set of real numbers is closed under, therefore (R, +) is a groupoid.If R denotes the set of even numbers then E is closed under addition. And (E, +) is a groupoid.Let denotes the set of positive integers and * be a binary operation on definedasfollows:

A*b = 3a+ 4b a, b

Clearly ( , *) is a groupoid.

9.4 Semi-GroupDefinition: Let S be a nonempty set and * be a binary operation on S. The algebraic (S, *) is called a semi-group if the operation * is associative. In other words, the groupoid is a semi-group if,

(a*b) * c = a * (b*c) for all a, b, c S

Thus, a semi-group requires the following:A set•Abinaryoperation*definedontheelementsof• S.Closure, • a*b whenever a, b S.Associativity • i (a*b) * c+a * (b*c) for all a, b, c S.

Example:Let • N be the set of natural numbers. Then (N, +) and (N, *) are semi-groups.X• be a nonempty set and P (X) denote the power set of X. Then (P (x), ) and (P (x), ) are semi-groups.Let • Z be the set of integers and bethesetequivalenceclassesgeneratedbytheequivalencerelation“congruentmodulo M”foranypositiveintegerm. Then bedefinedintegersof+onZ as follows:

For any [i], [j]

[i], [j] = [(i+j) mod m]

The algebraic system ( + m) is a semi-group.

Page 119: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

107

9.5 Homomorphism of Semi-GroupsLet (S, *) and (T, 0) be any two semi-groups. A mapping f: S→T such that for any two elements a, b S,

f (a*b) = f (a) o f (b)

is called a semi-group homomorphism.

A homeomorphism of a semi-group into itself is called a semi-group endomorphism.

9.6 Isomorphism of Semi-GroupsLet (S, *) and (T, 0) be any two semi-groups. A homeomorphism f: S→T is called a semi-group isomorphism of f one-to-one and onto.

If f: S→T is an isomorphism then (S, *) and (T, 0) are said to be isomorphism.

Definition: An isomorphism of a semi-group onto itself is called a semi-group automorphism.

Theorem:Let (S, *), (T, 0) and (V, ) be semi-groups f: S→T and T→Vbe semi-group homomorphism. Then gof: S→V is a semi-groups homomorphism from (S, *) to ( ,Δ).

Proof:Let a, b S then, (gof) (a*b) = g [f (a*b) = g [f (a) o f(b)] = (gf (a)Δ(gf (b)) = (gof) (a)Δ(gof) (b)

Hence gof: S→V is a semi-group homomorphism.

9.7 MonoidA semi-group (M, *) with an identity element with respect to the binary operation * is called a monoid. In other words, an algebraic system (M, *) is called a monoid if:

(• a*b) * c=a * (b*c) a, b, c M.There exists an element • e M such that e*a=a*e=a a M.

Example:Let • Z be the set of integers (Z, +) is a monoid 0 is the identity element in Z with respect to +.Let • N be the set of natural numbers (N, X) is a monoid. 1 the identity element in N with respect to the composition X.

Let (M, *) be a monoid. If the operation * is commutative then (M, *) is said to be commutative. If,

, M, we have = * = * for all i, j M.

A monoid (M, *) is said to be cyclic if there exists an element a M. Such that every element of M can be expresses as some power of a. If M is a cyclic monoid such that every element is some power of a M, then a is called the generator of M. A cyclic monoid is commutative and a cyclic monoid is commutative and a cyclic monoid may have more than one generator.

The algebraic system (• N, +) is a cyclic monoid generator by 1.If • M = {-1, 2, i, -i}, where i = , then (M, *) is a cyclic monoid: The elements i and –i are its generators.

Page 120: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

108

9.8 GroupsA group is an algebraic structure (G, *) in which the binary operation * on Gsatisfiesthefollowingconditions:

G – 1 for all a, b, c G

a * (b * c) = (a * b) * c (associativity)

G – 2 there exists an elements e G such that for any a G

a*e=e*a=a (existence of identity)

G – 3 for every a G, there exists an element denoted by in G such that,

a* = *a=e

is called the inverse of a in G.

Example:( � Z, +) is a group, where Z denoted the set of integers.( � R, +) is a group, where R denote the set of real number.

Abelian group (or Commutative group)Let (G, *) be a group. If * is commutative that is,

a*b=b*a for all a, b G

then (G, *) is called an Abelian group.

Example:(Z, +) is an Abelian group.

Finite GroupA group GissaidtobeafinitegroupifthesetGisafiniteset.

Example:G = {-1, 1} is a group with respect to the operation multiplication. Where G isafinitesethaving2elements.Therefore Gisafinitegroup.

InfinitegroupA group G,whichisnotfinite,iscalledaninfinitegroup. OrderofafinitegroupTheorderofafinitegroup(G, *) is the number of distinct element in G. The order of G is denoted by O (G) or by |G|.

Example:Let G = {-1, 1}The set G is a group with respect to the binary operation multiplication and O(G) = 2.

Page 121: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

109

9.9 Sub-GroupLet (G, *) be a group and H, be a nonempty subset of G. If (H, *) is itself is a group, then (H, *) is called sub-group of (G, *).

Example:Let • a = {1, -1, i, -i} and H = {1, -1}

G and H are groups with respect to the binary operation, multiplication. H is a subset of G, therefore (H, X) is a sub-group (G, X).

Consider (• , + ), then group of integers modulo 6. H = {0, 2, 4} is a subset of and {H, } is a group. {H, } is a group.

Theorem:If (G, *) is group and H≤G, then (H, *) is a sub-group of (G, *) if and only if,

a• , b H a*b H;a• H H

Proof:If (H, *) is a sub-group of (G,*),thenboththeconditionsgivenaboveareobviouslysatisfied.

We,thereforeprovenowthatiftheaboveconditionsaresatisfiedthen,(H, *) is a sub-group of (G, *).

To prove that (H, *) is a group of (G, *) all that we are required to prove is: * associative in H and identity e H.

That * is associative in H follows from the fact that * is associative in G.Also, a H H .....by second conditionand e H and H a* =e H .....byfirstcondition

Hence, H is a group sub-group of G.

9.10 Centre of a GroupLet (a, *) be a group, then centre of the group is the set of those elements of G which commute with every element of G. The centre of G is denoted by Z (G).

Thus, Z (G) = {a G/a*x=x*a a G}

9.11 Index of a Sub-GroupThe number of distinct left (or right) cosets of H in G is called index of H in G. The index of H in G is denoted by

(H).

If (G,*)isafinitegroupand(H, *) is a group of G, then,

(H) =

9.12 CosetsLet (H, *) be a sub-group (G, *) and a GThen, the sub-set:

A*H = {a*h:h H}

is called a left coset of H in G and the subset,

H*G = {h*a:h H}

is called a right coset of H in G.

Page 122: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

110

Note: In general a*H H*a, however if G is Abelian then,

A*H=H*a a G

9.13 Normal Sub-GroupsA sub-Group (H, *) of (G, *) is called a normal sub-group of G if for all h H, g G and H.If H is normal in G then we write H G.

Example:Let (• G, *) be a group, then ({e}, *) is a normal sub-group in G. It is called the trivial normal sub-group.(• G, *) is normal in (G, *). It is called the improper normal sub-group of G.

9.13.1 Simple GroupA group (G, *) is called simple group if its only normal sub-groups are G and {e}.

Example:A group of prime order has no proper sub-groups.Therefore, every group of prime order is simple.Wenowgiveanequivalentdefinitionforthesub-grouptobenormal.

A sub-group (H, *) of a group (G, *) is said to be normal sun-group of (G, *) is for every s G, H.

9.13.2 Quotient GroupLet (H, *) be a normal sub-group of a group (G, *). The set of all cosets of H in G is known as the quotient G/H:

G/H = {a*H:a G}

Here, a*H=H*a a GNow, (a*H) * (b*H) = (a*b*H) * H = ((a*b) * H) * H = (a*b) * H*H = (a*b) * H

i.e., product of two left cosets of H in G is given a left coset in G. Similarly, we can show that, the product of two right cosets is again a right coset in G.

9.14 Alphabet, Words, Free Semi-GroupConsider a nonempty set A of symbols. A word or string w on the set Aisafinitesequenceoftitselements.

Example:Suppose A = {a, b, c}. Then the following sequence is words on A:

u=ababb and v=accbaaa

When discussing words on A, we frequently call A the alphabet and its elements are called letters. We will also abbreviate our notation and write for aa, for aaa and so on. thus, for the above words, u=aba and v=a b

Page 123: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

111

The empty sequence of letters, denote by (Greek letter lambda) or (Greek letter epsilon), or 1, is also considered to be a word on A, called the empty word. The set of all words on A is denoted by A*.

The length of a word u, written |u| or l (u), is the number of elements in its sequence of letters. For the above words u and v, we have l (u) = 5 and l (v) = 7. Also, l ( ) = 0, where is the empty word.

9.15 LanguagesA language L over an alphabet A is a collection of words on A. A8* denoted the set of all words on A. Thus a language L is simply a subset of A*.

Example:Let A = {a, b}. The following are languages over A.

a. = {a, ab, ,.......} c. = { | m > o}

b. = { | m > 0, n > 0} d. = a | m≥0,n≥0}

One may verbally describe these languages as follows:

a. consists of all words beginning with an a and followed by zero or more b’s.

b. consists of all words beginning with one or more as followed by one or more b’s.

c. consists of all words beginning with one or more as and followed by the same number of b’s.

d. consists of all words with exactly one a.

9.15.1 Operations on LanguagesSuppose L and M are languages over an alphabet A.Thenthe“concatenation”ofL and M, denoted by LM, is the languagedefinedasfollows:

LM = {uv|u L,v V}

That is, LM denoted the set of all words which come from the concatenation of a word from L with a word from M.

Example:Suppose, = {a, }, = { , ab, }, = { , , ,........}

Then, = { , a , a, }, = { , b, a , , ab, } = { , , ,............, , , ,...........}

Clearly, the concatenation of languages is associative since the concatenation of words is associative.

PowersofalanguageLaredefinedasfollows: ={λ}, = L, = LL, = L for m > 1

Page 124: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

112

9.16 Regular Expressions, Regular LanguagesLet Abea(nonempty)alphabet.Thissectiondefinesaregularexpressionr over A and a language L (r) over A associated with the regular expression r. The expression r and its corresponding language L (r)aredefinedinductivelyas follows:

Each of the following is a regular expression over an alphabet A.Thesymbol“λ”(emptyword)andthepair“()”(emptyexpression)areregularexpressions.•Each letter • a in A is a regular expression.If • r is a regular expression, then (r*) is a regular expression.If • and are regular expressions, then ( ) is a regular expression.If • and are regular expression, then ( ) is a regular expression.

All regular expressions are found in this way.

Observe that a regular expression r is a special kind of a word (string) which uses the letters of Aandthefivesymbols:

( ) * λ

We emphasise that no other symbols are used for regular expressions.

The language L (r)overdefinedbyaregularexpressionr over A is as follows:L• (λ)={λ}andL (( )) = , the empty set.L• (a) = {a}, where a is a letter in A.L• (r*) = (L (r))* (the Kleene closure of L (r)).L• ( ) = L ( ) L ( (the union of the language).L• ( ) = L ( ) L ( ) (the concatenation of the languages).

Let L be a language over A. Then L is called a regular language over A if there exists a regular expression r over A such that L = L (r). 9.17 GrammarsFig.9.1showsthegrammaticalconstructionofaspecificsentence.Observethatthereare:Various variablesExample: (sentence) , (noun phrase),......;

Various terminal wordsExample:The”,“boy”,......;

A beginning variable Example: ⟨sentence⟩ → ⟨noun phrase⟩ ⟨verb phrase⟩⟨object phrase⟩ → ⟨article⟩⟨noun⟩ → apple

Thefinalsentenceonlycontainsterminal,althoughbothvariablesappearinitsconstructionbytheproductions.Thisintuitivedescriptionisgiveninordertomotivatethefollowingdefinitionofagrammarandthelanguageitgenerates.

Page 125: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

113

(sentence)

(noun phrase) (verb phrase)

(article)

The little

(adjective) (noun) (article)

(object phrase)(verb)(noun phrase)

(noun)

boy ate an apple

Fig. 9.1 Grammars

A phrase structure grammar or simply, a grammar G consists of four parts:Afiniteset(vocabulary)• V.A subset • T of V whose elements are called terminals; the elements of N = V \ T are called non-terminals or variables.A non-terminal symbol • S called the start symbol.Afiniteset• P of productions. (A production is an ordered pair ( , ), usually written → , where and are words in V and the production must contain at least one non-terminal on its left side .)

Such a grammar G is denoted by G = G (V, T, S, P) when we want to indicate its four parts.

The following notation, unless otherwise stated or implied, will be used for our grammars. Terminals will be denoted by italic lower case Latin letters, a, b, c,.... and non-terminals will be denoted by italic capital Latin letters, A, B, C, ...., with S as the start symbol. Also, Greek letters, , , ....., will denote words in V, that is, words in terminals and non-terminals. Furthermore, we will write,

→( , ,........, ) instead of → , → ,........., →

9.17.1 Language L (G) of a Grammar GSuppose w and w′arewordsoverthevocabularysetV of a grammar G. We write,

w w′

if w′canbeobtainedfromw by using one of the productions; that is, if there exists words u and v such that w=uv and w′=u v and there is a production → . Furthermore, we write,

w w′ or w *w′

if w′canbeobtainedfromqusingafinitenumberofproductions.

Now let G be a grammar with terminal set T. The language of G, denoted by L (G), consists of all words in T that can be obtained from the start symbol S by the above process; that is,

L (G) = {w T* | S w}

Page 126: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

114

9.17.2 Types of GrammarsGrammarsareclassifiedaccordingtothekindsofproductionwhichareallowed.

AType0grammarhasnorestrictionsonitsproductions.Types1,2and3aredefinedasfollows:A grammar • G is said to be of Type 1 if every production is of the form → where | ≤| | or of the form → .

A grammar • G is said to be of Type 2 if every production is of the form A→ where the left side A is a non-terminal.A grammar • G is said to be of Type 3 if every production is of the form A→a or A→aB, that is, where the left side A is a single non-terminal and the right side is a single terminal or a terminal followed by a non-terminal, or of the form S→ .

Observe that the grammars form a hierarchy; that is, every Type 3 grammar is a Type 2 grammar, every Type 2 grammar is a Type 1 grammar and every Type 1 grammar is a Type 0 grammar.

Grammarsarealsoclassifiedintermsofcontext-sensitive,context-freeandregularasfollows:A grammar • G is said to be context-sensitive if the production are of the form,

A ′→ ′

Thename“context-sensitive”comesfromthefactthatwecanreplacethevariableA by in a word only when A lies between and ′.

A grammar • G is said to be context-free if the productions are of the form,

A→

Thename“context-free”comesfromthefactthatwecannowreplacethevariableA by regardless of where A appears.

A grammar • G is said to be regular if the productions are of the form,

A→a, A→aB, S→λ

Observe that a context-free grammar is the same as a Type 2 grammar and a regular grammar is the same as a Type 3 grammar.

9.17.3 Machines and Grammars

Pushdown Automata:• A pushdown automaton P is similar to a FSA (Finite State Automata) excepts that P has an auxiliary stack which provides an unlimited amount of memory for P. A language L is recognised by a pushdown automaton P if and only if L is context-free.Linear Bounded Automata:• A linear bounded automaton B is more powerful than a pushdown automaton. Such an automaton B uses a tape which is linearly bounded by the length of the input word w. A language L is recognised by a linear bounded automaton B if and only if L is context-sensitive.Turing Machine:• A Turing machine M,usesaninfinitetape;itisabletorecogniseeverylanguageL that can be generated by any phase-structure grammar G. In fact, a Turing machine M is one of a number of equivalent waystodefinethenotionofa“computable”function.

Page 127: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

115

9.18 Finite State MachinesFinitestatemachine(FST)whichissimilartoafinitestateautomaton(FSA)exceptthatthefinitestatemachine“prints”anoutputusinganoutputalphabetwhichmaybedistinctfromtheinputalphabet.

Afinitestatemachine(orcompletesequentialmachine)M consists of six parts:Afiniteset• A of input symbols.Afiniteset• Sof“internal”states.Afiniteset• Z of output symbols.An initial • in S.A next-state function • f from S A into S.An output function • g from S A into Z.

Such a machine M is denoted by M = M (A, S, Z, , f, g) when we want to indicate its six parts.

Page 128: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

116

SummaryA binary operation * in a set • A is a function from A A to A.A Binary operation * • A A→A is said to be commutative if for every a, a, b A.A binary operation *; • A A→A is said to be associative if, (a*b) * c=a* (b*c) for every a, b, c A.A system consisting of a nonempty set • S and one or more n-ary operations on the S is called an algebraic system.If • A is a set and * is a binary operation on A, then (A, *) is called an algebraic structure.A groupoid is an algebraic structure consisting of nonempty set • A and a binary operation *, which is such that A is closed under *.The algebraic (• S, *) is called a semi-group if the operation * is associative.A homomorphism of a semi-group into itself is called a semi-group endomorphism.•An isomorphism of a semi-group onto itself is called a semi-group automorphism.•A semi-group (• M, *) with an identity element with respect to the binary operation * is called a monoid.A group • GissaidtobeafinitegroupifthesetGisafiniteset.A group • G,whichisnotfinite,iscalledaninfinitegroup.A sub-Group (• H, *) of (G, *) is called a normal sub-group of G if for all h H, g G and H.A group (• G, *) is called simple group if its only normal sub-groups are G and {e}.A language • L over an alphabet A is a collection of words on A. A8* denoted the set of all words on A. Thus a language L is simply a subset of A*.A pushdown automaton • P is similar to a FSA (Finite State Automata) excepts that P has an auxiliary stack which provides an unlimited amount of memory for P.

ReferencesShankar Rao G., 2009.• DiscreteMathematicalStructure. New Age International.Acharjya & Sreekumar. D. P., 2009. • Fundamental Approach to DiscreteMathematics. New Age International. Lipschutz. S., 1997. • Schaum’sOutlineofDiscreteMathematics, 2nd ed., McGraw-Hill.Kolman B., 2008. • DiscreteMathematicalStructures, 6th ed., Prentice Hall.

Recommended ReadingFinite-stateautomata(FSA)anddirectedacyclicwordgraphs(DAWG)• . Available at: <http://www.eti.pg.gda.pl/katedry/kiw/pracownicy/Jan.Daciuk/personal/fsm_algorithms/> [Accesses 16 April 2011].Finite-StateMachines• . Available at: <http://www.cs.hmc.edu/~keller/cs60book/12%20Finite-State%20Machines.pdf> [Accessed 16 April 2011].FiniteStateAutomata• . Available at: <http://introcs.cs.princeton.edu/73fsa/> [Accessed 18 April 2011].Finitestatemachines• . Available at: <http://www.spinroot.com/spin/Doc/Book91_PDF/F8.pdf> [Accessed 18 April 2011].

Page 129: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

117

Self AssessmentA binary operation ___________ in a set 1. A is a function from A A to A.

a. ≈ b. * c. ′ d. ↑

If * is a binary operation in a set 2. A then for the * image of the ordered pair (a, b) A A, we write ____________.

a. ab (or * (a, b)) b. a*b (or (a, b)) c. a*b (or * (a * b)) d. a*b (or * (a, b))

A Binary operation * 3. A A→A is said to be ___________ if for every a, a, b A.commutativea. reflectiveb. antisymmetricc. transitived.

A binary operation *; 4. A A→A is said to be associative if, (a*b) * c=a* (b*c) for every a, b, c A.Reflectivea. Antisymmetricb. Associativec. Commutatived.

A system consisting of a nonempty set 5. S and one or more n-ary operations on the S is called a/an ___________.

boolean algebra a. algebraic systemb. ordered sets c. lattices d.

Which of the following is true?6. The operations on a set a. S, define a structure on the elements ofS, therefore S is called an algebraic system.A homeomorphism of a subgroup into itself is called a semi-group endomorphism.b. A endomorphism of a semi-group into itself is called a semi-group homeomorphism.c. A homeomorphism of a semi-group into itself is called a semi-group automorphism.d.

What is an algebraic structure consisting of nonempty set 7. A and a binary operation *, which is such that A is closed under *?

poseta. lattices b. groupoidc. cosetd.

Page 130: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

118

The algebraic (8. S, *) is called a __________ if the operation * is associative.semi-groupa. subgraphb. subsetc. semigraphd.

Which of the following is true?9. A homeomorphism of a semi-group onto itself is called a semi-group automorphism.a. An endomorphism of a semi-group onto itself is called a semi-group automorphism. b. An isomorphism of a semi-group onto itself is called a semi-group endomorphism. c. An isomorphism of a semi-group onto itself is called a semi-group automorphism. d.

A semi-group (10. M, *) with an identity element with respect to the binary operation * is called a __________.groupoida. monoidb. latticec. semi-graphd.

Page 131: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

119

Chapter X

Codes and Group Codes

Aim

The aim of this chapter is to:

explain codes and group codes•

introduce the terminologies of codes and group codes•

describe error correction•

Objectives

The objectives of this chapter are to:

discuss group codes•

determine weight of code word•

explain them the distance between the code words•

Learning outcome

At the end of this chapter, the students will be able to:

discuss error correction for block code•

identify maximum likelihood criterion•

recognise minimum distance decoding criterion•

Page 132: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

120

10.1 IntroductionWhen we want to send a message to someone, we send it through some communication channel. This transmission of message over a channel entails some chances of undesirable interference in the channel sometimes deliberate and sometimes due to random defects in the channel. This leads to coding problem. The coding problem is to represent distinct messages by distinct sequence of letters from a given alphabet set.

Example:In a Morse code we represent a message by dots and dashed. Similarly over alphabet can be {0, 1} i.e., binary alphabet.

Whenamessageis tobetransmitted, thenthemessageisfirstgivenbythesourcetotheencoder, theencoderconverts the message in to the code word. The encoded message is then sent through the channel, where noise may occur and change the message. When this message arrives at the decoder at the receivers end, it is equated to most likely code word.

Source Encoder Receiver

DecoderChannel

Code Word

Message

Transmitted

Noise

Fig. 10.1 Communication channel with noise

10.2 TerminologiesWe will use the following terms in our discussion:

Word: A word is the sequence of letters drawn from the alphabet set.•Code: Code is the collection of words to represent a distinct message.•Code word: A word represented by a code is called the code word.•Block Code: A code consisting of words that are of same length is called Block Code. One of the advantages •of using the Block Code is the ability to correct errors.

10.3 Error CorrectionWhen we transmit a message from the source to the destination, due to the presence of noise in the communication channel may get altered i.e., some of the 1’s transmitted may be received as 0’s and some of the 0’s may be received as 1’s. So the received message is no more is the transmitted message. Now we would want to recover the transmitted message from the received message. This is called error correction.

Page 133: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

121

10.4 Group CodesLet A be the set of all binary sequence of length n.Letusdefineabinaryoperation in A such that X, Y A implies (X Y) A i.e., a sequence of length n. Where,

(X Y) =

The set A together with the binary operation i.e., (A, ) forms a group and a subset G of A is called the group code if (G, ) is a subgroup of (A, ).

Let us consider X = 1 0 0 1 0 0 1 and Y = 0 1 0 1 0 0 1.

Therefore, we have,

(X Y) = 1 1 0 0 0 0 0

10.5 Weight of Code WordLet A be the set of all binary sequence of length n. Let X be a code in A, the weight of X denoted by (X) is the number of 1’s in X.

Let us consider the code words X = 10101 and Y = 00011. The number of 1’s present in X is three whereas the number of 1’s present in Y are two. So, the weight of X is 3 and the weight of Y is 2.

i.e. (X) = 3 and (Y) = 2

10.6 Distance Between the Code WordsLet A be the set of all binary sequence of length n. Let X and Y be two code words in A, the distance between X and Y denoted by d (X, Y)andisdefinedastheweightof (X Y).

i.e., d (X, Y) = (X Y)

The distance between code words X = 01011 and Y = 10101. Now the distance between X and Yisdefinesas (X Y). Now,

Therefore, d(X, Y) = (X Y) = 4

10.7 Error Correction for Block CodeWe know that block code consisting of words that are of same length. The advantage of using block code is its ability to correct the errors.

Let G be a block code, the distance of Gisdefinedastheminimumdistancebetweenanypairofdistinctcodewordsin G. The ability of block codes to correct the errors depends on its distance.

Let a word be transmitted and we receive a word Y (say). Now there is likelihood of received word containing an error. Now we will like to have the transmitted word corresponding to the received word Y.

We can use two methods i.e., maximum likelihood decoding criterion and minimum distance decoding criterion.

Page 134: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

122

10.7.1 Maximum Likelihood CriterionLet , ,..........., be the code words in G. One of this transmitted and we have received the code word Y. The receivedwordmaycontainerrorandweareinterestedtofindthewordtransmitted.Maximumlikelihoodcriterionsays that the conditional probabilities P ( | ),..... P ( | Y),........ P ( | Y) means the probability that is transmitted when the received word is Y. Let,

P ( | Y) = Max {( | Y)}; i = 1, 2,..........., n

Then, is the transmitted word.

10.7.2 Minimum Distance Decoding CriterionIn the minimum distance criterion we compute d ( , Y), d ( , Y), d ( , Y),.........., d ( , Y).Letusdefine,

d ( , Y) = Min{d ( , Y)}; i = 1, 2, 3,..........., n

Then X, is taken as the transmitted word when the received word is Y.

Page 135: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

123

SummaryA word is the sequence of letters drawn from the alphabet set.•Code is the collection of words to represent a distinct message.•A word represented by a code is called the code word.•A code consisting of words that are of same length is called Block code. One of the advantages of using the •Block Code is the ability to correct errors.The set • A together with the binary operation , i.e., (A, ) forms a group and a subset G of A is called the group code if (G, ) is a subgroup of (A, ).

ReferencesShankar Rao G., 2009.• DiscreteMathematicalStructure. New Age International.Acharjya & Sreekumar. D. P., 2009. • Fundamental Approach to DiscreteMathematics. New Age International. Lipschutz. S., 1997. • Schaum’sOutlineofDiscreteMathematics, 2nd ed., McGraw-Hill.Kolman B., 2008. • DiscreteMathematicalStructures, 6th ed., Prentice Hall.

Recommended ReadingCodesandGroupCodes• . Available at: <http://www.stanford.edu/class/ee387/handouts/notes3.pdf> [Accessed 18 April 2011].ErrorCorrectingCodes• .<http://www.quantdec.com/Articles/steganography/ecc.htm> [Accessed 18 April 2011].Errorcorrectingcodes• . Available at: <http://www.hackersdelight.org/ecc.pdf> [Accessed 18 April 2011].

Page 136: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

124

Self AssessmentA ____________ is the sequence of letters drawn from the alphabet set.1.

worda. codeb. code wordc. block coded.

____________ is the collection of words to represent a distinct message.2. Code worda. Block codeb. Codec. Wordd.

Which of the following is true?3. A code consisting of words that are of same length is called code word.a. A code consisting of words that are of same length is called word.b. A code consisting of words that are of same length is called code.c. A code consisting of words that are of same length is called Block code.d.

A _____________ represented by a code is called the code word.4. block codea. codeb. wordc. code wordd.

Which of the following is true?5. One of the advantages of using the code is the ability to correct errors.a. One of the advantages of using the Block Code is the ability to correct errors.b. One of the advantages of using the code word is the ability to correct errors.c. One of the advantages of using the group code is the ability to correct errors.d.

The set 6. A together with the binary operation i.e., (A, ) forms a group and a subset G of A is called the ___________ if (G, ) is a subgroup of (A, ).

group codea. block codeb. code wordc. coded.

Which of the following is true?7. The ability of Block codes to correct the errors depends on its shape.a. The ability of Block codes to correct the errors depends on its path.b. The ability of Block codes to correct the errors depends on its distance.c. The ability of Block codes to correct the errors depends on its vertex.d.

Page 137: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

125

In the ____________ distance criterion we compute 8. d ( , Y), d ( , Y), d ( , Y),.........., d ( , Y).maximuma. internalb. externalc. minimumd.

___________ likelihood criterion says that the conditional probabilities 9. P ( | ),..... P ( | Y),........ P ( | Y) means the probability that is transmitted when the received word is Y.

Internala. Maximumb. Externalc. Minimumd.

Whenamessageistobetransmitted,thenthemessageisfirstgivenbythesourcetotheencoder,theencoder10. converts the message in to the ____________.

block codea. group codeb. code wordc. wordd.

Page 138: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

126

Application I

Givenanexampleofanon-emptysetandarelationonthesetthatsatisfieseachofthefollowingcombinationsofproperties: draw a digraph of the relation:

Symmetricandreflexivebutnottransitive.1. Transitiveandreflective;butnotanti-symmetric.2.

Solution:LetA={a,b,c}andR={(a,a),(b,b),(c,c),(a,b),(a,c),(b,a),(c,b)}clearlyRissymmetricandreflective1. but not transitive. The digraph of R is given below:

Let,2. A = {a, b, c} and R = {(a, a), (b, b), (c, c), (a, b), (a, c), (b, c), (b, a), (c, b), (c, a)}

TherelationRisreflectiveandtransitivebutnotanti-symmetric.

Page 139: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

127

Application II

f: RRisdefinedbyf (x) = ax+b, where a, b,xR and a 0.

Show that fisinvertibleandfindtheinverseoff.

Page 140: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

128

Application III

ShowthatthegraphsGandG′inthefigurebelowareisomorphic.

Page 141: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

129

Bibliography

ReferencesAcharjya & Sreekumar. D. P., 2009. • Fundamental Approach to DiscreteMathematics, New Age International. Kolman B., 2008. • DiscreteMathematicalStructures, 6th Edition, Prentice Hall.Lipschutz. S., 1997. • Schaum’sOutlineofDiscreteMathematics, 2nd Edition, McGraw-Hill.Shankar Rao G., 2009. • DiscreteMathematicalStructure. New Age International.

Recommended ReadingBasicConceptsinGraphTheory• . Available at: <http://math.ucsd.edu/~ebender/DiscreteText2/GT.pdf> [Accessed 10 April 2011].BinaryTree.• Available at: <http://oz.nthu.edu.tw/~d947207/chap9_tree.pdf> [Accessed 15 April 2011]. BinaryTrees• . Available at: <http://cslibrary.stanford.edu/110/BinaryTrees.pdf> [Accessed 14 April 2011].BinaryTrees.• Available at: <http://www.cs.ccsu.edu/~jones/chap17.pdf> [Accessed 15 April 2011].Booleanalgebrasoverpartiallyorderedset• . Available at: <http://spot.colorado.edu/~szendrei/BLAST2010/bekkali.pdf> [Accessed 13 April 2011].CodesandGroupCodes• . Available at: <http://www.stanford.edu/class/ee387/handouts/notes3.pdf> [Accessed 18 April 2011].CompleteBinary Tree.• Available at: <http://www.cs.colorado.edu/~main/supplements/pdf/notes10a.pdf> [Accessed 15 April 2011].CountingMethods• . Available at: <http://hanlonmath.com/pdfFiles/281Ch.8CountingMethods.pdf> [Accessed 7 April 2011].Digraphsandtypesofrelations• . Available at: <http://www.facweb.iitkgp.ernet.in/~niloy/COURSE/Autumn2008/DiscreetStructure/scribe/Lecture07CS3028.pdf> [Accessed 9 April 2011].Errorcorrectingcodes• . Available at: <http://www.hackersdelight.org/ecc.pdf> [Accessed 18 April 2011].ErrorCorrectingCodes.• Available at: <http://www.quantdec.com/Articles/steganography/ecc.htm> [Accessed 18 April 2011].FiniteStateAutomata• . <http://introcs.cs.princeton.edu/73fsa/> [Accessed 18 April 2011].FiniteStateMachines• . <http://www.spinroot.com/spin/Doc/Book91_PDF/F8.pdf> [Accessed 18 April 2011].Finite-stateautomata(FSA)anddirectedacyclicwordgraphs(DAWG).• <http://www.eti.pg.gda.pl/katedry/kiw/pracownicy/Jan.Daciuk/personal/fsm_algorithms/> [Accesses 16 April 2011].Finite-StateMachines• . <http://www.cs.hmc.edu/~keller/cs60book/12%20Finite-State%20Machines.pdf> [Accessed 16 April 2011].GeneratingFunctions andRecurrenceRelation• . http://www.math.cmu.edu/~af1p/Teaching/Combinatorics/Slides/Ch10.pdf [Accessed 9 April 2011].GraphTheory• .Availableat:<http://math.tut.fi/~ruohonen/GT_English.pdf>[Accessed11April2011].IntroductiontoGraphTheory• .Availableat:<http://www.southernct.edu/~fields/TeX-PDF/GraphTheory.pdf>[Accessed 11 April 2011].Johnsonbaugh, R., 2008. • DiscreteMathematics, 7th Edition, Prentice Hall.LatticesandBooleanalgebra• . Available at: <http://www.math.hawaii.edu/~tom/612notes5.pdf> [Accessed 13 April 2011].MathematicalLogic• . Available at: <http://www.algebraworkbench.net/download/n41main.pdf> [Accessed 7 April 2011].Mathematical Logic• . Available at: <http://www.math.umn.edu/~jodeit/course/ACaRA01.pdf> [Accessed 6 April 2011].

Page 142: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

130

MathematicalLogic• . Available at: <http://www.mathgoodies.com/lessons/toc_vol9.html> [Accessed 7 April 2011].Monoids,BooleanAlgebras,MateriallyOrderedSets• . Available at: <http://www.math.cmu.edu/~wn0g/noll/MBM.pdf> [Accessed 11 April 2011].Nanda, 2002. • DiscreteMathematics, Allied Publishers.ProbabilitiesUsingCountingTechniques• .Available at: <http://mdm4u1.wetpaint.com/page/6.3+Probabilities+Using+Counting+Techniques> [Accessed 7 April 2011].Recurrence relations and generating functions• . Available at: <http://www.britannica.com/EBchecked/topic/127341/combinatorics/21881/Recurrence-relations-and-generating-functions> [Accessed 9 April 2011].Recurrence relations andgenerating functions• . Available at: <http://www.mathpages.com/home/kmath646/kmath646.htm> [Accessed 10 April 2011].Relations andDigraph• . Available at: <http://www.londoninternational.ac.uk/current_students/programme_resources/cis/pdfs/subject_guides/level_1/cis102_vol2/cis_102_volume_2_ch_1.pdf> [Accessed 8 April 2011].RepresentingRelations.• Available at: <http://www.wiziq.com/tutorial/694-Representing-Relations> [Accessed 8 April 2011].Rosen, K., 2006. • DiscreteMathematicsandItsApplications, 6th Edition, McGraw-Hill.SetTheoryandVennDiagram• . Available at: <http://www.saskschools.ca/curr_content/mathb30/prob/les2/notes.html>. [Accessed 6 April 2011].SetTheory• . Available at: <http://tedsider.org/teaching/st/st_notes.pdf>. [Accessed 5 April 2011].sStats:Counting Techniques• . Available at: <http://people.richland.edu/james/lecture/m170/ch04-not.html> [Accessed 8 April 2011].

Page 143: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

131

Self Assessment Answers

Chapter Id1. a2. c3. b4. a5. d6. c7. a8. b9. d10.

Chapter IIb1. a2. d3. c4. a5. b6. d7. a8. b9. d10.

Chapter IIIa1. c2. c3. a4. b5. d6. c7. b8. a9. c10.

Chapter IVb1. a2. c3. b4. d5. b6. a7. b8. d9. d10.

Page 144: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

Logic, Discrete Mathematical Structures

132

Chapter Vd1. b2. b3. d4. c5. a6. d7. c8. c9. d10.

Chapter VIb1. a2. c3. b4. d5. d6. a7. c8. c9. b10.

Chapter VIIa1. c2. b3. a4. d5. c6. b7. a8. d9. b10.

Chapter VIIIa1. c2. b3. d4. a5. c6. d7. a8. d9. b10.

Page 145: Logic, Discrete Mathematical Structuresjnujprdistance.com/assets/lms/LMS JNU/B.Sc.(IT)/Sem III... · 2019-07-28 · Logic, Discrete Mathematical Structures. Board of Studies Prof

133

Chapter IXb1. d2. a3. c4. b5. a6. c7. a8. d9. b10.

Chapter Xa1. c2. d3. c4. b5. a6. c7. d8. b9. c10.