You are on page 1of 181

Discrete

Mathematics -
CS218

4th Edition

Study Guide
1998 by International Division
Informatics Holdings Ltd
A Member of Informatics Group
Informatics Building
5 International Business Park
Singapore 609914

Discrete Mathematics - CS218


1st Edition - Completed in December 1994
nd
2 Edition - Completed in December 1997
3rd Edition - Completed in July 1998
4th Edition - Completed in December 1998

First Printing - 1994


Second Printing - 1997
Third Printing - 1998
Fourth Printing -1998

All rights reserved. No part of this publication may be reproduced, stored in a retrieval system,
or transmitted by any forms or means, electronic, mechanical, photocopying, recording, or
otherwise, without prior written permission of the publisher.

Every precaution has been taken by the publisher and author(s) in the preparation of this
study guide. The publisher offers no warranties or representations, nor does it accept any
liabilities with respect to the use of any information or examples contained herein.

All brands names and company names mentioned in this study guide are protected by their
respective trademarks and are hereby acknowledged.

The developer is wholly responsible for the contents, errors and omission.

Published by Informatics International


(Printing & Publishing Division)
Printed in Singapore
Foreword to students:

As there is no assignment for Discrete Mathematics, you will need to do some problems on
your own. The exercises provided at the end of each chapter for you are there for you to develop
your skills. These problems have been selected as they give a fair representation of the type of
problems you will be facing on both the progress tests and the exam paper.
As you work on the problems for each chapter please remember to follow the concepts you
have learned in class, in some cases there are alternative ways to construct or even do the
problems; however, they may not be acceptable on the exam paper. Follow the methods used
in this study guide as they will be always be acceptable.
Show all your work, as the only representative of your work is what you have written. You will
not have an opportunity to explain what you meant, you will be graded on what you have
written on the exam paper only, if you fail to write it you will not receive the marks. If what you
write as an answer is not clear, you will not receive the marks.
Understand there is a lot of material now in this study guide. The reason for this is so you will
not have to go source for material outside this guide. It is very difficult to learn mathematics
and apply it correctly if you don’t have a good foundation. This guide will now provide you with
that foundation.
It is important that you attend every class, as each class covers a new topic, and all topics will
be covered in depth on the progress tests and exam paper. Each topic is separate from the
other topics, learning one chapter does not mean you will have a better understanding of
another chapter. Most chapters have little if anything to do with one another, however, all the
concepts presented here are relevant to computer science.
As you start your study of Discrete Mathematics please use the following conventions for each
chapter:

Chap ter 1:

When constructing a truth table, use only T for true and F for false. You must start the truth
table (start of the columns) with T’s. When constructing arguments, If . . . means implies all
the time, at times it is not clear if you should be using and or implies in constructing the
argument, try to remember this, if you can insert the word ‘and’ in the sentence and not
change the meaning of the sentence (still have a sentence that makes sense) then use and
otherwise use implies (→).

Chap ter 2:

Follow the notation used in this study guide only. Do not make up your own or use some
notation you learned in your previous studies. Use only the symbols that in the table on pg.
2-14, other symbols may be acceptable in other places but will not be acceptable on the exam
paper.

Chap ter 3:

It is important you understand the concepts presented here. Be careful to prove something
fully. For example graphing a relation to show it is a function, does not in itself prove that it i s,
you must state why it is, or is not a function after graphing it. The same applies to determining
if a function is 1− 1or onto, graphing them does not prove they are 1− 1or onto, you must state if
they are and why.
Chap ter 4:

There is a lot of material in this chapter. With summation follow the notation. Practice all the
different types of proofing methods. Induction is a very important proofing method and so
make sure you understand it very well. Follow the examples in the study guide when you
attempt to prove a problem using induction, as this is the format that will be looked for on the
exam. When proving something do not attempt to prove the right side half way and then prove
the left side to that point. Doing this will only get you only the marks for the first part of your
proof (provided the first part of your proof is correct).

Chap ter 5:

With combinatorics you need to determine what type of formula should be used. Try to be
familiar with all the different types.

Chap ter 6:

Probability is an important concept, and it does require practice as many of the concepts can
be confusing.

Chap ter 7:

Graph theory is another important concept. When labelling bipartite graphs, use the labelling
convention stated on page 7-11, other type of labelling will not be accepted.

Chap ter 8:

This chapter finishes up your study of Discrete Mathematics, covering in more depth
matrices. This is just a brief introduction to matrices, more of a review of the basic concepts of
matrices that you may use in discrete mathematics.
Table of Contents

CHAPTER 1: INTRODUCTION TO LOGIC . . . . . . . . . . . . . 1-1


Chapter Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-1
1.1 WHAT IS LOGIC? . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
1.1.1 SIMPLE STATEMENTS . . . . . . . . . . . . . . . . . 1-2
1.1.2 TRUTH TABLES . . . . . . . . . . . . . . . . . . . . . 1-2
1.1.3 COMPOUND STATEMENTS . . . . . . . . . . . . . . 1-3
1.2 BASIC LOGIC CONNECTIVES. . . . . . . . . . . . . . . . . . . 1-3
1.2.1 CONJUNCTION. . . . . . . . . . . . . . . . . . . . . . 1-3
1.2.2 DISJUNCTION . . . . . . . . . . . . . . . . . . . . . . 1-4
1.2.3 NEGATION . . . . . . . . . . . . . . . . . . . . . . . . 1-4
1.2.4 CONDITIONAL . . . . . . . . . . . . . . . . . . . . . . 1-5
1.2.5 BICONDITIONAL. . . . . . . . . . . . . . . . . . . . . 1-6
1.3 PROPOSITIONS AND TRUTH TABLES . . . . . . . . . . . . . 1-6
1.3.1 EXCLUSIVE DISJUNCTION. . . . . . . . . . . . . . . 1-7
1.4 TAUTOLOGIES AND CONTRADICTIONS . . . . . . . . . . . . 1-8
1.4.1 TAUTOLOGY . . . . . . . . . . . . . . . . . . . . . . . 1-8
1.4.2 CONTRADICTION . . . . . . . . . . . . . . . . . . . . 1-8
1.4.3 PRINCIPLE OF SUBSTITUTION . . . . . . . . . . . . 1-9
1.4.4 LAW OF SYLLOGISM. . . . . . . . . . . . . . . . . . . 1-9
1.5 LOGICAL EQUIVALENCE . . . . . . . . . . . . . . . . . . . . . 1-9
1.5.1 DeMORGAN’S LAWS . . . . . . . . . . . . . . . . . . 1-10
1.5.2 LOGICALLY TRUE STATEMENTS . . . . . . . . . . 1-10
1.5.3 LOGICALLY EQUIVALENT STATEMENTS . . . . . 1-10
1.5.4 LAWS OF THE ALGEBRA OF PROPOSITIONS . . . 1-11
1.6 ARGUMENTS. . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-12
1.7 LOGICAL IMPLICATION . . . . . . . . . . . . . . . . . . . . . 1-14
1.8 SUMMARY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-15
1.8.1 BASIC LOGIC CONNECTIVES . . . . . . . . . . . . . 1-15
1.8.2 REMARKS . . . . . . . . . . . . . . . . . . . . . . . . 1-15
1.9 LOGIC EXERCISES . . . . . . . . . . . . . . . . . . . . . . . . 1-16

CHAPTER 2: SET THEORY . . . . . . . . . . . . . . . . . . . . . . 2-1


Chapter Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . 2-1

i
Ta ble of Con tents CS218

2.1 SETS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2


2.1.1 NOTATION . . . . . . . . . . . . . . . . . . . . . . . . 2-2
2.2 TYPES OF SETS . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3
2.2.1 FINITE AND INFINITE SETS. . . . . . . . . . . . . . 2-3
2.2.2 UNIVERSAL SET . . . . . . . . . . . . . . . . . . . . . 2-3
2.2.3 SUBSETS . . . . . . . . . . . . . . . . . . . . . . . . . 2-4
2.2.4 PROPER SUBSET. . . . . . . . . . . . . . . . . . . . . 2-4
2.2.5 NULL SETS . . . . . . . . . . . . . . . . . . . . . . . . 2-4
2.2.6 DISJOINT SETS. . . . . . . . . . . . . . . . . . . . . . 2-4
2.2.7 SETS OF SETS . . . . . . . . . . . . . . . . . . . . . . 2-5
2.2.8 POWER SETS . . . . . . . . . . . . . . . . . . . . . . . 2-5
2.3 OPERATIONS ON SETS . . . . . . . . . . . . . . . . . . . . . . 2-5
2.3.1 VENN DIAGRAMS . . . . . . . . . . . . . . . . . . . . 2-5
2.3.2 UNION . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6
2.3.3 INTERSECTION . . . . . . . . . . . . . . . . . . . . . 2-6
2.3.4 DIFFERENCE . . . . . . . . . . . . . . . . . . . . . . . 2-7
2.3.5 COMPLEMENT . . . . . . . . . . . . . . . . . . . . . . 2-7
2.4 ATTRIBUTES OF SETS. . . . . . . . . . . . . . . . . . . . . . . 2-8
2.4.1 EQUALITY OF SETS . . . . . . . . . . . . . . . . . . . 2-8
2.4.2 COMPARABILITY. . . . . . . . . . . . . . . . . . . . . 2-8
2.4.3 CARDINALITY . . . . . . . . . . . . . . . . . . . . . . 2-8
2.4.4 THE PRINCIPLE OF INCLUSION AND
EXCLUSION. . . . . . . . . . . . . . . . . . . . . . . . 2-8
2.5 PROOFS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-9
2.5.1 USING VENN DIAGRAMS . . . . . . . . . . . . . . . . 2-9
2.5.2 PROOFS USING ALGEBRAIC LAWS . . . . . . . . . 2-11
2.6 SET THEORY TRUTH TABLES . . . . . . . . . . . . . . . . . 2-11
2.7 THREE SET VENN DIAGRAMS . . . . . . . . . . . . . . . . . 2-12
2.8 VENN DIAGRAMS USING REGIONS . . . . . . . . . . . . . . 2-12
2.9 SUMMARY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-13
2.9.1 LAWS OF THE ALGEBRA OF SETS . . . . . . . . . . 2-13
2.9.2 COMMON SYMBOLS AND THEIR MEANINGS . . . 2-14
2.9.3 REMARKS . . . . . . . . . . . . . . . . . . . . . . . . 2-14
2.10 SET THEORY EXERCISES . . . . . . . . . . . . . . . . . . . . 2-15

CHAPTER 3: RELATIONS AND FUNCTIONS. . . . . . . . . . . . 3-1


Chapter Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-1

ii
MA214 Ta ble of Con tents

3.1 INTRODUCTION TO RELATIONS . . . . . . . . . . . . . . . . 3-2


3.1.1 ORDERED PAIRS AND PRODUCT SETS . . . . . . . 3-2
3.1.2 SOME SPECIAL SETS . . . . . . . . . . . . . . . . . . 3-2
3.1.3 DEFINITION OF RELATION . . . . . . . . . . . . . . 3-3
3.2 REPRESENTING RELATIONS . . . . . . . . . . . . . . . . . . 3-4
3.2.1 PICTORIAL REPRESENTATION OF RELATIONS . . 3-4
3.2.2 GRAPHICAL REPRESENTATION OF RELATIONS . 3-4
3.2.3 MATRIX REPRESENTATION OF A RELATION. . . . 3-6
3.3 PROPERTIES OF RELATIONS . . . . . . . . . . . . . . . . . . 3-7
3.3.1 REFLEXIVE . . . . . . . . . . . . . . . . . . . . . . . . 3-7
3.3.2 SYMMETRIC . . . . . . . . . . . . . . . . . . . . . . . 3-7
3.3.3 TRANSITIVE . . . . . . . . . . . . . . . . . . . . . . . 3-8
3.3.4 IRREFLEXIVE. . . . . . . . . . . . . . . . . . . . . . . 3-9
3.3.5 ANTISYMMETRIC . . . . . . . . . . . . . . . . . . . . 3-9
3.4 TYPES OF RELATIONS . . . . . . . . . . . . . . . . . . . . . . 3-9
3.4.1 EQUIVALENCE RELATIONS . . . . . . . . . . . . . . 3-9
3.4.2 PARTIALLY ORDERED RELATIONS . . . . . . . . . 3-10
3.4.3 UNIVERSAL RELATIONS . . . . . . . . . . . . . . . 3-10
3.4.4 EMPTY RELATIONS . . . . . . . . . . . . . . . . . . 3-10
3.4.5 INVERSE RELATIONS . . . . . . . . . . . . . . . . . 3-10
3.4.6 COMPOSITE RELATIONS . . . . . . . . . . . . . . . 3-11
3.5 INTRODUCTION TO FUNCTIONS . . . . . . . . . . . . . . . 3-12
3.5.1 ELEMENTS OF A FUNCTION . . . . . . . . . . . . . 3-13
3.6 GRAPHING FUNCTIONS . . . . . . . . . . . . . . . . . . . . . 3-14
3.6.1 COORDINATE GRAPHS . . . . . . . . . . . . . . . . 3-14
3.7 TYPES OF FUNCTIONS. . . . . . . . . . . . . . . . . . . . . . 3-15
3.7.1 INJECTIONS. . . . . . . . . . . . . . . . . . . . . . . 3-15
3.7.2 SURJECTIONS. . . . . . . . . . . . . . . . . . . . . . 3-15
3.7.3 BIJECTIONS . . . . . . . . . . . . . . . . . . . . . . . 3-15
3.8 CLASSES OF FUNCTIONS . . . . . . . . . . . . . . . . . . . . 3-16
3.8.1 LIMITS . . . . . . . . . . . . . . . . . . . . . . . . . . 3-16
3.8.2 BINARY OPERATIONS . . . . . . . . . . . . . . . . . 3-17
3.9 OPERATIONS ON FUNCTIONS . . . . . . . . . . . . . . . . . 3-17
3.9.1 EQUAL FUNCTIONS . . . . . . . . . . . . . . . . . . 3-17
3.9.2 SUM OF FUNCTIONS . . . . . . . . . . . . . . . . . . 3-18
3.9.3 DIFFERENCE OF FUNCTIONS . . . . . . . . . . . . 3-18
3.9.4 PRODUCT OF FUNCTIONS . . . . . . . . . . . . . . 3-18

iii
Ta ble of Con tents CS218

3.9.5 QUOTIENT OF FUNCTIONS . . . . . . . . . . . . . 3-18


3.9.6 COMPOSITE FUNCTIONS . . . . . . . . . . . . . . . 3-18
3.9.7 INVERTABLE FUNCTIONS . . . . . . . . . . . . . . 3-19
3.10 SUMMARY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-20
3.10.1 THEOREMS . . . . . . . . . . . . . . . . . . . . . . . 3-20
3.10.2 REMARKS . . . . . . . . . . . . . . . . . . . . . . . . 3-20
3.11 RELATIONS AND FUNCTIONS EXERCISES . . . . . . . . . . 3-21

CHAPTER 4: METHODS OF PROOFS . . . . . . . . . . . . . . . . 4-1


Chapter Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-1
4.1 MATHEMATICAL FACTS . . . . . . . . . . . . . . . . . . . . . 4-2
4.1.1 PREDICATE LOGIC . . . . . . . . . . . . . . . . . . . 4-2
4.1.2 ODD AND EVEN NUMBERS. . . . . . . . . . . . . . . 4-2
4.1.3 ABSOLUTE VALUE. . . . . . . . . . . . . . . . . . . . 4-2
4.1.4 DIVISIBILITY . . . . . . . . . . . . . . . . . . . . . . . 4-2
4.1.5 TYPES OF NUMBERS . . . . . . . . . . . . . . . . . . 4-3
4.1.6 RECURRENCE RELATION . . . . . . . . . . . . . . . 4-3
4.1.7 SEQUENCES . . . . . . . . . . . . . . . . . . . . . . . 4-3
4.1.8 SERIES. . . . . . . . . . . . . . . . . . . . . . . . . . . 4-4
4.1.9 EXPONENTS . . . . . . . . . . . . . . . . . . . . . . . 4-5
4.1.10 LOGIC . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-6
4.2 PROOFS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-6
4.2.1 DIRECT PROOFS . . . . . . . . . . . . . . . . . . . . . 4-6
4.2.2 CONTRAPOSITIVE PROOFS . . . . . . . . . . . . . . 4-7
4.2.3 PROOFS BY CONTRADICTION . . . . . . . . . . . . . 4-7
4.2.4 COUNTEREXAMPLES . . . . . . . . . . . . . . . . . . 4-8
4.2.5 MATHEMATICAL INDUCTION . . . . . . . . . . . . . 4-8
4.3 SUMMARY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-12
4.3.1 REMARKS . . . . . . . . . . . . . . . . . . . . . . . . 4-12
4.3.2 PRINCIPLE OF MATHEMATICAL INDUCTION. . . 4-12
4.4 METHODS OF PROOFS EXERCISES . . . . . . . . . . . . . . 4-13

CHAPTER 5: COMBINATORICS . . . . . . . . . . . . . . . . . . . 5-1


Chapter Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-1
5.1 BASIC COUNTING RULES. . . . . . . . . . . . . . . . . . . . . 5-2
5.1.1 THE SUM RULE . . . . . . . . . . . . . . . . . . . . . 5-2
5.1.2 THE PRODUCT RULE . . . . . . . . . . . . . . . . . . 5-2

iv
CS218 Ta ble of Con tents

5.2 FACTORIAL NOTATION. . . . . . . . . . . . . . . . . . . . . . 5-3


5.3 COUNTING FORMULAS . . . . . . . . . . . . . . . . . . . . . . 5-3
5.3.1 k-SAMPLES . . . . . . . . . . . . . . . . . . . . . . . . 5-4
5.3.2 k-PERMUTATIONS . . . . . . . . . . . . . . . . . . . . 5-4
5.3.3 k-COMBINATIONS . . . . . . . . . . . . . . . . . . . . 5-5
5.3.4 k-SELECTIONS . . . . . . . . . . . . . . . . . . . . . . 5-6
5.4 PIGEONHOLE PRINCIPLE . . . . . . . . . . . . . . . . . . . . 5-6
5.5 THE INCLUSIONEXCLUSION PRINCIPLE . . . . . . . . . . 5-7
5.6 PARTITION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-7
5.6.1 ORDERED PARTITIONS. . . . . . . . . . . . . . . . . 5-7
5.6.2 PERMUTATIONS WITH REPETITIONS . . . . . . . . 5-8
5.6.3 UNORDERED PARTITONS . . . . . . . . . . . . . . . 5-8
5.6.4 NUMBER OF PARTITIONS . . . . . . . . . . . . . . . 5-9
5.7 SUMMARY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-10
5.7.1 FORMULAS
5.7.2 THEOREMS . . . . . . . . . . . . . . . . . . . . . . . 5-10
5.7.3 REMARKS . . . . . . . . . . . . . . . . . . . . . . . . 5-11
5.7.4 TABLE . . . . . . . . . . . . . . . . . . . . . . . . . . 5-11
5.8 COMBINATORICS EXERCISES . . . . . . . . . . . . . . . . . 5-12

CHAPTER 6: PROBABILITY . . . . . . . . . . . . . . . . . . . . . 6-1


Chapter Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-1
6.1 INTRODUCTION TO PROBABILITY . . . . . . . . . . . . . . . 6-2
6.1.1 SAMPLE SPACES AND EVENTS . . . . . . . . . . . . 6-2
6.1.2 THEOREMS OF PROBABILITY . . . . . . . . . . . . . 6-3
6.2 TYPES OF SAMPLE SPACES . . . . . . . . . . . . . . . . . . . 6-3
6.2.1 FINITE PROBABILITY SPACES . . . . . . . . . . . . 6-3
6.2.2 FINITE EQUIPROBABLE SPACES . . . . . . . . . . . 6-4
6.3 CONDITIONAL PROBABILITY . . . . . . . . . . . . . . . . . . 6-5
6.3.1 MULTIPLICATION THEOREM . . . . . . . . . . . . . 6-6
6.3.2 STOCHASTIC PROCESSES & TREE DIAGRAMS . . . 6-6
6.4 INDEPENDENCE . . . . . . . . . . . . . . . . . . . . . . . . . . 6-7
6.5 REPEATED TRIALS. . . . . . . . . . . . . . . . . . . . . . . . . 6-9
6.6 RANDOM VARIABLES . . . . . . . . . . . . . . . . . . . . . . . 6-9
6.6.1 DISTRIBUTION AND EXPECTATION . . . . . . . . . 6-9
6.6.2 VARIANCE AND STANDARD DEVIATION. . . . . . 6-12
6.7 BINOMIAL DISTRIBUTIONS . . . . . . . . . . . . . . . . . . . 6-13

v
Ta ble of Con tents CS218

6.8 SUMMARY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-15


6.8.1 THEOREMS . . . . . . . . . . . . . . . . . . . . . . . 6-15
6.8.2 REMARKS . . . . . . . . . . . . . . . . . . . . . . . . 6-15
6.9 PROBABILITY EXERCISES . . . . . . . . . . . . . . . . . . . . 6-16

CHAPTER 7: GRAPH THEORY . . . . . . . . . . . . . . . . . . . . 7-1


Chapter Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-1
7.1 GRAPHS AND DIGRAPHS . . . . . . . . . . . . . . . . . . . . . 7-2
7.1.1 GRAPHS . . . . . . . . . . . . . . . . . . . . . . . . . . 7-2
7.1.2 MULTIGRAPHS AND PSEUDOGRAPHS. . . . . . . . 7-3
7.1.3 DIGRAPHS . . . . . . . . . . . . . . . . . . . . . . . . 7-3
7.2 BASIC DEFINITIONS . . . . . . . . . . . . . . . . . . . . . . . . 7-4
7.2.1 SUBGRAPHS . . . . . . . . . . . . . . . . . . . . . . . 7-5
7.2.2 ISOMORPHIC GRAPHS . . . . . . . . . . . . . . . . . 7-5
7.3 CLASSES OF GRAPHS . . . . . . . . . . . . . . . . . . . . . . . 7-7
7.3.1 TREES . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-7
7.3.2 BIPARTITE GRAPHS. . . . . . . . . . . . . . . . . . . 7-8
7.3.3 COMPLETE GRAPHS . . . . . . . . . . . . . . . . . . 7-9
7.3.4 REGULAR GRAPHS . . . . . . . . . . . . . . . . . . . 7-9
7.3.5 PLANAR GRAPHS . . . . . . . . . . . . . . . . . . . . 7-10
7.4 MATRICES ASSOCIATED WITH GRAPHS . . . . . . . . . . . 7-10
7.4.1 THE ADJACENCY MATRIX . . . . . . . . . . . . . . 7-10
7.4.2 THE INCIDENCE MATRIX . . . . . . . . . . . . . . . 7-12
7.4.3 THE DISTANCE MATRIX . . . . . . . . . . . . . . . 7-12
7.5 TRAVERSING GRAPHS . . . . . . . . . . . . . . . . . . . . . . 7-13
7.5.1 EULERIAN GRAPHS . . . . . . . . . . . . . . . . . . 7-13
7.5.2 HAMILTONIAN GRAPHS . . . . . . . . . . . . . . . 7-14
7.5.3 THE TRAVELLING SALESMAN PROBLEM . . . . . 7-16
7.6 SUMMARY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-17
7.6.1 THEOREMS . . . . . . . . . . . . . . . . . . . . . . . 7-17
7.6.2 REMARKS . . . . . . . . . . . . . . . . . . . . . . . . 7-17
7.7 GRAPH THEORY EXERCISES . . . . . . . . . . . . . . . . . . 7-19

CHAPTER 8: MATRICES . . . . . . . . . . . . . . . . . . . . . . . 8-1


Chapter Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-1
8.1 MATRICES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-2
8.1.1 MATRIX OPERATIONS . . . . . . . . . . . . . . . . . 8-2

vi
CS218 Ta ble of Con tents

8.1.2 TYPES OF MATRICES . . . . . . . . . . . . . . . . . . 8-4


8.1.3 MATRIX MULTIPLICATION . . . . . . . . . . . . . . 8-5
8.1.4 TRANSFORMING MATRICES. . . . . . . . . . . . . . 8-7
8.2 SUMMARY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-8
8.2.1 REMARKS . . . . . . . . . . . . . . . . . . . . . . . . . 8-8
8.3 MATRICES EXERCISES . . . . . . . . . . . . . . . . . . . . . . 8-9

GLOSSARY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-1

vii
CHAPTER 1: INTRODUCTION TO LOGIC

Chapter Objectives

In this chapter you will learn:

§ what logic is;

§ about the basis of logic: the simple statement;

§ how to construct a truth table;

§ about the five basic logic connectives and there truth tables;

§ the rules of logic;

§ what makes a statement a tautology;

§ what makes a statement a contradiction;

§ what logical equivalence is;

§ what a proposition is;

§ what makes an argument valid;

1-1
CHAPTER 1: INTRODUCTION TO LOGIC CS218

1.1 WHAT IS LOGIC?

u Logic is the study of the principles and methods used in distinguishing valid
arguments from those that are invalid. Logic is also known as propositional
calculus.

1.1.1 SIM PLE STATE MENTS

u The basic building block in logic is the statement, also referred to as a proposition. A
statement is a declarative sentence which can only be either true or false.

u Statements are represented by letters such as p, q, r, . . .

u The following are simple statements:

Example 1: Jakarta is a city in Indonesia.


Example 2: 2 + 1 = 5
Example 3: The digit in the 105th decimal place expansion of 37 is 8
Example 4: The moon is made of blue cheese.
Example 5: There is no intelligent life on Mars.
Example 6: It is raining.

u Clearly example 1 is true, while examples 2, and 4 are clearly false. Whether examples
3, 5 are true is not certain, but only because of our lack of knowledge, while whether
example 6 is true or false depends on the time the statement is made.

u The following are not statements:

Example 7: Come to our party!


Example 8: The sky is rich.
Example 9: How are you today lah?

1.1.2 TRUTH TABLES

u Since a statement can only be true or false, the values of a statement can be
represented by a truth table. Using the variables p and q to represent statements, and
letting T and F stand for true and false respectively yields table 1, a truth table.

Table 1

p ~p

T F

F T

l Remark 1: The number of truth values (rows) is 2 n , where n is the


number of basic statements (variables)

1-2
CS218 CHAPTER 1: INTRODUCTION TO LOGIC

1.1.3 COMPOUND STATEMENTS

u The combination of two or more simple statements is a compound statement, or


compound proposition.

Example 10: “2 + 1 = 5” and “6 + 2 = 8”

Example 11: “The sky is clear” or “It is raining today”

u The variables p, q, r, . . . denote simple statements in the compound proposition


P( p , q , r,...), where P is a proposition.

1.2 BASIC LOGIC CONNECTIVES

u Compound statements are connected using mainly five basic connectives:


conjunction, disjunction, negation, conditional, and biconditional.

1.2.1 CONJUNCTION

u Any two statements can be combined by the word “and” to form a composite
statement which is called the conjunction of the original statements.

- The connection of the statements p and q is symbolically represented by


p∧q
- The truth values of p ∧ q can be represented in a truth table:

p q p∧q
T T T
T F F
F T F
F F F

u If p is true and q is true then p ∧ q is true; otherwise p ∧ q is false. In other words, the
conjunction of two statements is true only if each component is true.

Example 12: Sidney is in Australia and 2 + 2 = 4

Example 13: Sidney is in Australia and 2 + 2 = 5

Example 14: Sidney is in Malaysia and 2 + 2 = 4

Example 15: Sidney is in Malaysia and 2 + 2 = 5

u Since only example 12 contains two simple statements that are true, and the others
all contain simple statements in which at least one of them is false only example 12 is
true.

1-3
CHAPTER 1: INTRODUCTION TO LOGIC CS218

1.2.2 DISJUNCTION

u Any two statements can be combined by the word “or” (in the sense of “and/or”,
called the “inclusive or”), to form a new statement which is called the disjunction
of the original two statements.

- The connection of the statements p or q is symbolically represented by


p ∨ q.
- The truth values of p ∨ q can be represented in a truth table:

p q p ∨q
T T T
T F T
F T T
F F F

u If p is true or q is true or both p and q are true, then p ∨ q is true; otherwise p ∨ q is


false. In other words, the disjunction of two statements is false only if each
component is false.

Example 16: Sidney is in Australia or 2 + 2 = 4


Example 17: Sidney is in Australia or 2 + 2 = 5
Example 18: Sidney is in Malaysia or 2 + 2 = 4
Example 19: Sidney is in Malaysia or 2 + 2 = 5

u Only example 19 is false. Each of the other compound statements is true since at least
one of its simple statements is true.

1.2.3 NEGATION

u Given any statement p, another statement, called the negation of p, can be formed
by writing “It is false that . . .” before p or, if possible, by inserting in p the word “not”.

- Negation can be symbolically represented by ~p, or ¬p


- The truth values of ~p can be represented in a truth table:

p ~p
T F
F T

u If p is true then ~p is false; if p is false, then ~ p is true. In other words, the truth value
of the negation of a statement is always the opposite of the truth value of the original
statement.

Example 20: If p is ‘Sidney is in Australia’, then ‘Sidney is not in Australia’ is the


negation ~p
Example 21: If p is ‘2 + 2 = x’, then ‘2 + 2 ≠ x’ is the negation ~p

1-4
CS218 CHAPTER 1: INTRODUCTION TO LOGIC

1.2.4 CONDITIONAL

u Many statements, especially in mathematics, are of the form “If p then q” or “p


implies q”. Such statements are called conditional statements.

- Conditional statements are symbolically represented as p → q


- The truth values of p → q can be represented in a truth table:

p q p→q
T T T
T F F
F T T
F F T

u The conditional p → q is true unless p is true and q is false. In other words p → q states
that a true statement cannot imply a false statement.

Example 22: If Sidney is in Australia then 2 + 2 = 4


Example 23: If Sidney is in Australia then 2 + 2 = 5
Example 24: If Sidney is in Malaysia then 2 + 2 = 4
Example 25: If Sidney is in Malaysia then 2 + 2 = 5

u By the conditional p → q only example 23 is false. But how can this be as clearly
‘2 +2 = 4’ is true and ‘2 + 2 = 5’ is clearly false? This is the case as once we know that
the “if” is false we no longer care if the “that” is true or not; hence we willing accept
that the proposition is vacuously true.

Exercise 1: Construct the truth table for ~p ∧ q

Exercise 2: Construct the truth table for (p ∨ q) → (p ∧ q)

1-5
CHAPTER 1: INTRODUCTION TO LOGIC CS218

1.2.5 BICONDITIONAL

u Another common statement called a biconditional statement is of the form


“p if and only if q” or, simply, “p iff q”

- Biconditional statements are symbolically represented as p ↔ q


- The truth values of p ↔ q can be represented in a truth table:

p q p↔q
T T T
T F F
F T F
F F T

u If p and q have the same truth value, thenp ↔ q is true; if p and q have opposite truth
values, then p ↔ q is false.

Example 26: Sidney is in Australia iff 2 + 2 = 4


Example 27: Sidney is in Australia iff 2 + 2 = 5
Example 28: Sidney is in Malaysia iff 2 + 2 = 4
Example 29: Sidney is in Malaysia iff 2 + 2 = 5

u By the conditional p ↔ q examples 26 and 29 are true, while examples 27 and 28 are
false.

l Remark 2: The biconditional statement can be defined as ( p → q ) ∧ ( q → p )

1.3 PROPOSITIONS AND TRUTH TABLES

u By repetitive use of the logical connectives (∧, ∨, ~, →, and, ↔), we can construct
compound statements that are more involved. In the case where the substatements
p, q, . . . of a compound statement P( p , q ,...), are variables, the compound statement is
called a proposition.

u The truth value of a proposition depends exclusively upon the truth values of its
variables, that is, the truth value of a proposition is known once the truth values of its
variables are known. A simple concise way to show this relationship is through a
truth table.

Example 30: The truth table of the proposition ~ ( p ∧ ~ q ), is:

p q ~q p ∧ ~q ~(p ∧ ~q)
T T F F T
T F T T F
F T F F T
F F T F T

1-6
CS218 CHAPTER 1: INTRODUCTION TO LOGIC

u Observe that the first columns of the table are for the variables p, q, . . . and there are
enough rows in the table to allow for all possible combinations of T and F for these
variables, i.e., the number of rows = 2 n

u There is then a column for each “elementary” stage of the construction of the
proposition, the truth value at each step being determined from the previous stages
by the definitions of the connectives ∧, ∨, ~

u Finally we obtain truth value of the proposition, which appears in the last column.

l Remark 3: The truth table of a proposition consists precisely of the columns


under the variables and the column under the proposition.

u The truth table of the proposition in example 30 is precisely:

p q ~(p ∧ ~q)
T T T
T F F
F T T
F F T

The other columns in example 30 are used only to construct the truth table.

Example 31: Construct the truth table for ( p → q ) ∧ ( q → p )

p q p → q q → p (p → q) ∧ (q → p)
T T T T T
T F F T F
F T T F F
F F T T T

Example 32: Construct the truth table for ~ ( p ∧ q ) ∨ ~ ( q ↔ p )

p q p ∧ q q ↔ p ~(p ∧ q) ~(q ↔ p) ~(p ∧ q) ∨ ~(q ↔ p)


T T T T F F F
T F F F T T T
F T F F T T T
F F F T T F T

1.3.1 EXCLUSIVE DISJUNCTION

u In addition to the “inclusive or” (see Disjunction section 2.2.2) there is another
meaning for “or” in English called the ‘exclusive or’, which means “either one or the
other, but not both.” In Logic exclusive or is referred to as exclusive disjunction.

1-7
CHAPTER 1: INTRODUCTION TO LOGIC CS218

u In mathematics or in logic, “or” always means “inclusive or” i.e., “or” always refers
to the disjunction connective.

- Exclusive or can be expressed using the basic connectives ~ ( p ↔ q )

Exercise 3: Complete the truth table for ~ ( p ↔ q )

1.4 TAUTOLOGIES AND CONTRADICTIONS

1.4.1 TAUTOLOGY

u A compound proposition that is always TRUE is called a tautology.

Example 33: p ∨ ~ p is a tautology as all entries in the last column are T’s

p ~p p ∨ ~p
T F T
F T T

1.4.2 CONTRADICTION

u A compound proposition that is always FALSE is called a contradiction.

Example 34: p ∧ ~ p is a contradiction as all entries in the last column are F’s

p ~p p ∧ ~p
T F F
F T F

l Remark 4: If P( p , q ,...) is a tautology then ~ P ( p , q ,... ) is a contradiction,


and if ~ P ( p , q , r,...) is a tautology then P( p , q , r...) is a
contradiction.

1-8
CS218 CHAPTER 1: INTRODUCTION TO LOGIC

1.4.3 PRINCIPLE OF SUBSTITUTION

u If P( p , q ,...) is a tautology, then P( P1 , P2 ,...) is also a tautology.

Example 35: We have shown that p ∨ ~ p is a tautology so by the principle of


substitution, substituting q ∧ r for p we obtain the proposition
( q ∧ r) ∨ ~ ( q ∧ r), which is also a tautology.
q r q∧r ~(q ∧ r) (q ∧ r) ∨ ~(q ∧ r)
T T T F T
T F F T T
F T F T T
F F F T T

1.4.4 LAW OF SYLLOGISM

u A fundamental principle of logical reasoning, called the Law of Syllogism,


states: “If p implies q and q implies r, then p implies r.” In other words the
proposition [( p → q ) ∧ ( q → r)] → ( p → r) is a tautology.

Example 36: Show that [( p → q ) ∧ ( q → r)] → ( p → r) is a tautology.

p q r p →q q → r (p → q) ∧ (q → r) p → r [(p → q) ∧ (q → r)] → (p → r)
T T T T T T T T
T T F T F F F T
T F T F T F T T
T F F F T F F T
F T T T T T T T
F T F T F F T T
F F T T T T T T
F F F T T T T T

1.5 LOGICAL EQUIVALENCE

u Two propositions P( p , q ,...) and Q( p , q , r,...) are said to be logically equivalent if


the final columns in their truth tables are the same.

- logical equivalence is denoted with ≡

Exercise 4: Show that p → q and ~ q → ~ p are logically equivalent.

1-9
CHAPTER 1: INTRODUCTION TO LOGIC CS218

Exercise 5: Show that [( p → q ) ∧ ( q → p )] ≡ p ↔ q

u Since the last two columns in the truth tables are the same the statements are
logically equivalent.

1.5.1 DeMORGAN’S LAWS

u DeMorgan’s Laws are simply:

a. ~ ( p ∧ q ) ≡ ~ p ∨ ~ q b. ~ ( p ∨ q ) ≡ ~ p ∧ ~ q

u DeMorgan’s Laws are an important both in logic and in set theory. The construction
of the truth tables is left as exercises.

1.5.2 LOGICALLY TRUE STATEMENTS

u A statement is said to be logically true if it is derivable from a tautology.

Example 37: It is raining or it is not raining.

u Example 37 is logically true since it is derivable from the tautology p ∨ ~p, where p is
‘It is raining.’

1.5.3 LOGICALLY EQUIVA LENT STATE MENTS

u Statements of the form P( p 0 , q 0 ,...) and Q( p 0 , q 0 ,...) are said to be logically


equivalent if the propositions P( p , q ,...) and Q( p , q ,...) are logically equivalent.

Example 38: Since ~ ( p ∧ q ) ≡ ~ p ∨ ~ q, the statement “It is not true that roses are
red and violets are blue” is logically equivalent to the statement
“Roses are not red or violets are not blue.” Where p is ‘roses are
red’, and q is ‘violets are blue.’

1 - 10
CS218 CHAPTER 1: INTRODUCTION TO LOGIC

1.5.4 LAWS OF THE ALGEBRA OF PROPOSITIONS

Idempotent Laws
1a. p∨ p≡ p 1b. p∧ p≡ p

Associative Laws
2a. ( p ∨ q) ∨ r ≡ p ∨ ( q ∨ r) 2b. ( p ∧ q) ∧ r ≡ p ∧ ( q ∧ r)
Commutative Laws
3a. p∨q≡ q∨ p 3b. p∧q≡ q∧ p
4a. ( p ↔ q) ≡ ( q ↔ p)
Distributive Laws
5a. p ∨ ( q ∧ r) ≡ ( p ∨ q ) ∧ ( p ∨ r) 5b. p ∧ ( q ∨ r) ≡ ( p ∧ q ) ∨ ( p ∧ r)

Identity Laws
6a. p∨c≡ p 6b. p∧t ≡ p
7a. p∨t ≡ t 7b. p∧c≡ c

Complement Laws
8a. p ∨~ p≡t 8b. p ∧~ p≡ f
9a. ~ t ≡ c 9b. ~ c ≡ t

Involution Law
10a. ~~ p≡ p

DeMorgan’s Laws
11a. ~ ( p ∨ q ) ≡ ~ p ∧ ~ q 11b. ~ ( p ∧ q ) ≡ ~ p ∨ ~ q
12a. ( p ∨ q) ≡ ~ ( ~ p ∧ ~ q) 12b. ( p ∧ q) ≡ ~ ( ~ p ∨ ~ q)
Contrapositive
13a. ( p → q) ≡ ( ~ q → ~ p)
Implication
14a. ( p → q) ≡ ( ~ p ∨ q) 14b. ( p → q) ≡ ~ ( p ∧ ~ q)
15a. ( p ∨ q) ≡ ( ~ p → q) 15b. ( p ∧ q) ≡ ~ ( p → ~ q)
16a. [( p → r) ∧ ( q → r)] ≡ [( p ∨ q ) → r] 16b. [( p → q) ∧ ( p → r)] ≡ [ p → ( q ∧ r)]
Equivalence
17a. ( p ↔ q) ≡ [( p → q) ∧ ( q → p)]
Exportation Law
18a. [( p ∧ q ) → r] ≡ [ p → ( q → r)]
Absorbtion Law
19a. ( p ∨ q ) ∧ ( p ∧ q ) ≡ p ∨ q 19b. ( p ∧ q ) ∧ ( p ∨ q ) ≡ p ∨ q
Reductio ad absurdum
20a. ( p → q) ≡ [( p ∧ ~ q) → c]

Note: In the table t represents a tautology and c represents a contradiction.

1 - 11
CHAPTER 1: INTRODUCTION TO LOGIC CS218

1.6 ARGUMENTS

u An argument is a relationship between a set of propositions, P1 , P2 ,... , Pn , called


premises, and another proposition Q, called the conclusion.

- An argument is denoted by P1 , P2 ,... Pn Q

u An argument is said to be valid if the premises yield (have as a consequence) the


conclusion.

l Remark 5: An argument P1 , P2 ,... Pn Q is valid if Q is true whenever all


the premises P1 , P2 ,... Pn are true.

u An argument that is not valid is called a fallacy.

l Remark 6: The argument P1 , P2 ,... Pn Q is valid iff ( P1 ∧ P2 ∧... Pn ) → Q is a


tautology.

Example 39: The argument p, p → q q is valid, since [p ∧ (p → q)] → q is a


tautology.

p q p→q p ∧ (p → q) [p ∧ (p → q)] → q
T T T T T
T F F F T
F T T F T
F F T F T

Example 40: The argument p → q, q p is a fallacy, since [(p → q) ∧ q] → p is


not a tautology.

p q p→q (p → q) ∧ q [(p → q) ∧ q] → p
T T T T T
T F F F T
F T T T F
F F T F T

u It should be emphasized that the validity of an argument does not depend upon the
truth values or the content of the statements appearing in the argument, but only on
the formal structure of the argument. One way to present an argument is:

Example 41: Analyse the following argument.


S 1: If a man is a bachelor, he is unhappy.
S 2 : If a man is unhappy, he dies young.
.........................................
S : Bachelors die young.

l Note: The statement S below the line denotes the conclusion of the argument,
and the statements S 1 , S 2 above the line denote the premises.

1 - 12
CS218 CHAPTER 1: INTRODUCTION TO LOGIC

In order to analyse the argument we must define our terms:


p: he is a bachelor q: he is unhappy r: he dies young

and the argument is p → q, q → r p→r

We need to show that [( p → q ) ∧ ( q → r)] → ( p → r ) is a tautology.

p q r p → q q → r [(p → q) ∧ (q → r)] p → r [(p → q) ∧ (q → r)] → (p →r)


T T T T T T T T
T T F T F F F T
T F T F T F T T
T F F F T F F T
F T T T T T T T
F T F T F F T T
F F T T T T T T
F F F T T T T T

Since [( p → q ) ∧ ( q → r)] → ( p → r) is a tautology the argument is valid.

u Another type of argument does not differentiate between the statements and the
conclusion by the use of a line; however, you can still determine the conclusion.
(Usually it contains the word therefore, but not always).

Example 42: Is this argument valid? An interesting teacher keeps me awake. I


stay awake in MA214 class. Therefore, my MA214 teacher is
interesting.

First define the terms:


t: my teacher is interesting a: I stay awake m: I am in MA214 class

and the argument is: t → a , a ∧ m m∧ t

We need to show that [( t → a ) ∧ ( a ∧ m)] → ( m ∧ t ) is a tautology.

t a m t → a a ∧ m (t → a) ∧ (a ∧ m) m ∧ t [(t → a) ∧ (a ∧ m)] → (m ∧ t)
T T T T T T T T
T T F T F F F T
T F T F F F T T
T F F F F F F T
F T T T T T F F
F T F T F F F T
F F T T F F F T
F F F T F F F T

Since [( t → a ) ∧ ( a ∧ m)] → ( m ∧ t ) is not a tautology, the argument is not a valid


argument.

1 - 13
CHAPTER 1: INTRODUCTION TO LOGIC CS218

Example 43: Is this argument valid? Sean is either a carpenter or a plumber


(but not both). If he carries a wrench, he’s a plumber. Sean is a
carpenter. Therefore, he does not carry a wrench.

First define the terms:


c: Sean is a carpenter p: Sean is a plumber w: Sean carries a wrench

and the argument is ~ ( c ↔ p ), w → p , c ~w

So we need to show that [~ ( c ↔ p ) ∧ ( w → p ) ∧ c] → ~ w is a tautology.

c p w ~(c ↔ p) w → p ~(c ↔ p) ∧ (w → p) ∧ c ~w [~(c ↔ p) ∧ (w → p) ∧ c] → ~w


T T T F T F F T
T T F F T F T T
T F T T F F F T
T F F T T T T T
F T T T T F F T
F T F T T F T T
F F T F F F F T
F F F F T F T T

Since [~ ( c ↔ p ) ∧ ( w → p ) ∧ c] → ~ w is a tautology, the argument is valid.

1.7 LOGICAL IMPLICATION

u A proposition P(p, q, . . .) is said to logically imply a proposition Q(p, q, . . .), written


P(p, q, . . .) ⇒ Q(p, q, . . .) if Q(p, q, . . .) is true whenever P(p, q, . . .) is true.

Example 44: Consider the truth table below. Observe that p is true in cases (lines)
1 and 2, and in these cases p ∨ q is also true. In other words, p
logically implies p ∨ q

p q p ∨q
T T T
T F T
F T T
F F F

l Remark 7: For any propositions P( p , q ,...) and Q( p , q ,...), the following


statements are equivalent:
i) P( p , q ,...) logically implies Q( p , q ,...)

ii) The argument P( p , q ,...) Q( p , q ,...) is valid.

iii) The proposition P( p , q ,...) → Q( p , q ,...) is a tautology.

1 - 14
CS218 CHAPTER 1: INTRODUCTION TO LOGIC

1.8 SUMMARY

1.8.1 BASIC LOGIC CONNECTIVES

Connective Meaning Symbolized by


conjunction and ∧
disjunction or ∨
negation not ¬, ~
conditional If ... then ..., Implies →
biconditional If and only if ↔

1.8.2 REMARKS

l The number of truth values (rows) is 2 n , where n is the number of basic


statements (variables).
l The biconditional statement can be defined as ( p → q ) ∧ ( q → p )

l The truth table of a proposition consists precisely of the columns under the
variables and the column under the proposition.
l If P( p , q ,...) is a tautology then ~ P ( p , q ,... ) is a contradiction, and if ~ P( p , q , r,...) is
a tautology then P( p , q , r...) is a contradiction.

l An argument P1 , P2 ,... Pn Q is valid if Q is true whenever all the premises


P1 , P2 ,... Pn are true.
l The argument P1 , P2 ,... Pn Q is valid iff ( P1 ∧ P2 ∧... Pn ) → Q is a tautology.

l For any propositions P( p , q ,...) and Q( p , q ,...), the following statements are
equivalent: i) P( p , q ,...) logically implies Q( p , q ,...) ii) The argument
P( p , q ,...) Q( p , q ,...) is valid iii) The proposition P( p , q ,...) → Q( p , q ,...) is a
tautology.

1 - 15
CHAPTER 1: INTRODUCTION TO LOGIC CS218

1.9 LOGIC EXERCISES

u Write out the truth tables for :

1. ~(p ∨ ~q)

2. p ∧ (q ∨ s)

3. (p ∧ q) ∨ (p ∧ s)

4. Compare (2) and (3) and draw a conclusion.

5. If P is the statement “It is raining ”


Q is the statement “ It is sunny ”
R is the statement “ It is cold ”

Represent the following using symbols :

a. It is raining and it is cold.


b. It is sunny and cold but not raining.
c. It is not cold but it is raining.

u Construct a truth table for the following:

6. (a ∧ ~b) ↔ (a ∧ b)

7. (a ∨ b) ↔ ~c

8. (a ∨ b) ∧ (a ∨ ~c) → a ∨ (b ∧ ~c)

9. (a → ~b) ↔ (b→ a ∧ b)

u Show that the following are tautologies :

10. (p ∧ q) → (p ∨ ~q)

11. p ∨ ~q ↔ ~( ~p ∧ q)

12. p ∨ ~(p ∧ q)

13. [(p ↔ q) ∧ ~p] → ~q

14. (p ∧ q) → (p ∨ ~q)

15. (p ∨ ~q) ↔ ~(~p ∧ q)

u Show that the following are contradictions:

16. p ∧ (~p ∧ q)

17. (p → q) ∧ ( ~q ∧ p)

18. (p ∧ q) ∧ ~ (p ∨ q)

19. (p → q) ∧ (~q ∧ p)

1 - 16
CS218 CHAPTER 1: INTRODUCTION TO LOGIC

u Prove the following :

20. p → q ≡ (~p ∨ q)

21. (p ∧ q) ∨ ~p ≡ ~p ∨ q

22. (p → q) ≡ ~(p ∧ ~q)

23. (p → q) ∨ ~p ≡ ~p ∨ q

u Construct the truth tables for DeMorgan’s Laws.

24. ~(p ∧ q) ≡ ~p ∨ ~q

25. ~(p ∨ q) ≡ ~p ∧ ~q

u Determine the validity of the following arguments:

26. p ∨ q , ~p q
27. p → q , q → r , ~r ~p

28. p → ~q , ~p → q ~p → r

u Analyse the following arguments:


29. If you do not study you will fail your examination. You failed therefore
you did not study.

30. If you do not get a degree, you will not get a job. You got a job therefore
you must have got a degree.

31. Tanya is either a singer or a ballerina. If she is a singer then she has a
lovely voice. If she is a ballerina then she has long legs. Tanya has lovely
voice and long legs so she is both.

32. If he does not have an explanation then he will be found guilty. He either
has an explanation or he has been framed. Therefore, if he has been
framed he will be found guilty.

33. If I am not in Malaysia, then I am not happy; if I am happy, then I am


singing; I am into singing; therefore, I am not in Mayalsia.

u Miscellaneous Problems

34. If the statement r is a tautology, what can we say about the statement
~r?
35. Simplify the follwowing argument ~ ((~ p ∨ ~ q ) ∨ (~ p ∧ ~ q )) p∨q

36. Consider the following propositions:


a: The road is narrow
b: The road is meandering
c: The road is an accident zone
i) Represent the following statement using logical symbols:
If the road is narrow and meandering then it is an accident
zone.
ii) Translate ~ a ∧ ~ b ↔ ~ c into English

1 - 17
CHAPTER 2: SET THEORY

Chapter Objectives

In this chapter, you will learn:

§ what a set is;

§ how to construct a set;

§ about the different types of sets;

§ about the operations that can be performed on sets;

§ about the attributes of sets;

§ how to prove something using sets;

§ what a Venn diagram is and how to construct one;

2-1
CHAP TER 2: SET THEORY CS218

2.1 SETS

u A set is any well-defined list, collection, or class of objects. The objects in sets can be
anything: numbers, people, letters, cities, etc. These objects are called the elements
or members of the set.

u The following are examples of sets:


Example 1: The numbers 2, 4, 5, 8, and 19.
Example 2: The solutions of the equation 2x 2 − 4 x − 8 = 0
Example 3: The first five letters of the alphabet: a, b, c, d, and e.
Example 4: The citizens of Singapore.
Example 5: The days: Monday, Tuesday, Wednesday, Thursday, and Friday.
Example 6: The students in MA214.
Example 7: The countries Singapore, Malaysia, Indonesia, and Thailand.
Example 8: The cities of Australia.
Example 9: The numbers 1, 3, 5, 7, 9, . . .
Example 10: The streets of Singapore.

u Notice that the sets in the odd numbered examples are defined, or are actual listings
of the members of the sets; and that the sets in the even numbered examples are
defined by stating properties, or rules which state whether or not a particular object
is a member of the set.

2.1.1 NOTATION

u Sets will usually be denoted by capital letters


A, B, C, X, . . .

u The elements of a set will usually be represented by lower case letters


a, b, c, x, . . .

u If a set is defined by actually listing its elements then the elements are separated by
commas and enclosed in brackets { }.

- This is called the tabular form of a set.


Example 11: If the elements of set A are the letters a, e, i, o, and u then we write
A= { a, e, i, o, u}

u If we define a particular set by stating the properties which its elements must satisfy
then we use a letter, usually x, to represent an arbitrary element, i.e., B = {x | x is
odd}

- This is read “B is the set of numbers x such that x is odd”


- This is called the set-builder form of a set.
- Notice the vertical line “|” is read “such that”

2-2
CS218 CHAP TER 2: SET THEORY

u If an object x is a member of a set A, i.e., A contains x as one of its elements, then we


write x ∈ A. Which is read “ x is an element of A” or as “ x belongs to A” or “ x is in A”.

u If on the other hand an object x is not a member of a set A, i.e., A does not contain x as
one of its elements, then we write x ∉ A. Which is read “x is not an element of A”.

Example 12: Let A = {a, b, c, d, e}. Then a ∈ A, f ∉ A, e ∈ A and t ∉ A


Example 13: Let B = {x | x is odd}. Then 1 ∈ B, 2 ∉ B, 3 ∈ B, and 4 ∉ B

Rewrite examples 1-10 in tabular form or set-builder form.

Ex er cise 1:

Ex er cise 2:

Ex er cise 3:

Ex er cise 4:

Exercise 5:

Exercise 6:

Exercise 7:

Exercise 8:

Exercise 9:

Exercise 10:

2.2 TYPES OF SETS

2.2.1 FINITE AND IN FI NITE SETS

u A set can be finite or infinite. A set is finite if it consists of a specific number of


different elements, i.e., if when you count the different elements of a set counting
eventually comes to an end. Otherwise the set is infinite.

Example 14: Let X be the number of days in a year. Then X is finite.


Example 15: Let N = {1, 3, 5, 7, 9, ...}. Then N is infinite.
Example 16: Let M = {1, 2, 3, 4, 5,...,10,000,000,000}. Then M is finite.
Example 17: Let Y = {y | y is a street in Singapore}. Then y is finite.

2.2.2 UNIVERSAL SET

u All the sets under consideration can thought of as subsets of another set called the
universal set. The universal set is denoted by U.

Example 18: The universal set U = the lowercase English alphabet.


Example 19: In human population studies, the universal set consists of all the
people in the world.

2-3
CHAP TER 2: SET THEORY CS218

2.2.3 SUBSETS

u A is a subset of B, written A ⊆ B, if every element of A is also an element of B. More


specifically, A is a subset of B if x ∈ A implies x ∈ B.

u If A is a subset of B, then we can also write B ⊇ A, which reads “B is a superset of A”


or “B contains A.

u If on the other hand A is not a subset of B, we write instead A ⊄ B.


Example 20: {1, 2, 3} ⊆ {1, 2, 3, 4}
Example 21: {1, 2, 3} ⊆ {1, 2, 3}
Example 22: {1, 2, 3} ⊄ {2, 3, 4} Α⊆Β

l Remark 1: If A is not a subset of B, that is, if A ⊄ B then, there is at least one


element in A that is not a member of B.
l Remark 2: Every set is a subset of itself, since every element in a set is in itself.

2.2.4 PROPER SUBSET

u We call B a proper subset of A if, first B is a subset of A and, secondly if B is not equal
to A. We denote B is a proper subset of A as B ⊂ A

- B⊆ A Means B is a subset of A, where B may be equal to A


- B⊂ A Means B is a proper subset of A, since B ≠ A
Example 23: Let A = {1, 2, 3}, B = {1, 2, 3, 4}, then A ⊂ B. This can also be written
as A ⊆ B
Example 24: Let A = {1, 2, 3}, B = {3, 2, 1}, then A ⊆ B and B ⊆ A. This cannot be
written as A ⊂ B as A = B

2.2.5 NULL SETS

u A set which contains no elements is called an empty set, or a null set. It is denoted
by the symbol ∅.

Example 25: Let A be the set of people in the world who are older than 200 years. As
there are no people in the known world older than 200 the set A is empty.
A=∅
Example 26: Let B = {x | x 2 = 4 , x is odd}. Then B = ∅

l Remark 3: The null set ∅ is considered to be a subset of every set.

2.2.6 DISJOINT SETS

u Two sets A and B are said to be disjoint if they have nothing in common.
Example 27: Let A = {a, b}, and B = {1, 2}, then A and B are disjoint sets.
Example 28: Let X = {a, b, c, 1}, and Y = {1, 2, 3, 4, 5}, then X and Y are not
disjoint as 1 ∈ X and 1 ∈ Y

2-4
CS218 CHAP TER 2: SET THEORY

2.2.7 SETS OF SETS

u At times sets can be the elements of another set. It is common practice to refer to
these “sets of sets” as “family of sets” or “class of sets”. Under these circumstances,
and in order to avoid confusion, families or classes of sets are denoted with script
letters A, B, C, . . .

Example 29: The set A = {{2, 3}, {2}, {5, 6}} is a family of sets. Its members are the sets
{2, 3}, {2}, and {5, 6}

2.2.8 POWER SETS

u The power set of a set X, denoted by P(X), is the set of all subsets of X.

u If a set X is finite, say X has n elements, then the power set of X can be shown to have
2 n elements.

Example 30: Let X = {0, 1}, then P(X) = {∅, {0}, {1}, {0, 1}}. Note: 2 n = 4.
Example 31: Let Y = {a, b, c}, then P(Y) = {∅, {a}, {b}, {c}, {a, b}, {a, c}, {b, c},
{a, b, c}}. Note: 2 n = 8.

2.3 OPERATIONS ON SETS

2.3.1 VENN DIAGRAMS

u A Venn diagram is a pictorial representation of sets by sets of points in the plane.


The universal set U is represented by the interior of a rectangle, and the other sets
are represented by disks lying within the rectangle.

u If A ⊂ B, then the disk representing A will be entirely within the disk representing B
as in Fig 1.3.1.

u If A and B are disjoint, i.e. have no elements in common, then the disk representing A
will be separated from the disk representing B as in Figure 1.3.2.

u If A and B are two arbitrary sets, it is possible that some objects are in A but not B,
some are in B but not A, some are in both A and B, and some are in neither A nor B;
hence in general we represent A and B as in Fig 1.3.3.

2-5
CHAP TER 2: SET THEORY CS218

2.3.2 UNION

u The union of sets A and B is the set of all elements which belong to A or to B or to
both.

- Union of A and B is denoted A ∪ B. Which is read “ A union B”


- Union of A and B may also be defined by A ∪ B = {x | x ∈ A or x ∈ B}
Example 37: Let X = {a, b, c, d} and Y = {f, b, d, g}. Then X ∪ Y = { a, b, c, d, f, g}
l Remark 4: From the definition of union it follows that A ∪ B and B ∪ A are the
same set, i.e. A ∪ B = B ∪ A.
l Remark 5: Both A and B are always subsets of A ∪ B, that is
A ⊆ ( A ∪ B ) and B ⊆ ( A ∪ B )

A ∪ B is shaded

2.3.3 INTERSECTION

u The intersection of sets A and B is the set of elements which are common to A and B,
that is, those elements which belong to A and which also belong to B.

- Intersection of A and B is denoted A ∩ B. Which is read


“A intersection B”
- Intersection of A and B may also be defined by A ∩ B = {x | x ∈ A , x ∈ B}.
Example 38: Let X = { a, b, c, d}, and Y = {f, b, d, g}. Then X ∩ Y = {b, d}
l Remark 6: From the definition of intersection of two sets it follows that
A∩B=B∩ A

l Remark 7: Each of the sets A and B contains A ∩ B as a subset, i.e.,


( A ∩ B ) ⊆ A and ( A ∩ B ) ⊆ B

l Remark 8: If sets A and B have no elements in common, i.e., if A and B are


disjoint, then the intersection of A and B is the null set, i.e.
A∩B=∅

A ∩ B is shaded

2-6
CS218 CHAP TER 2: SET THEORY

2.3.4 DIFFERENCE

u The difference of sets A and B is the set of elements which belong to A but don’t
belong to B.

- Difference is denoted A − B, A \ B or A ~ B. Which are read “A minus B”.


- The difference of A and B may also be defined by A − B = {x | x ∈ A , x ∉ B}
Example 39: Let X = {a, b, c, d} and Y = {f, b, d, g}. Then X − Y = {a, c}

l Remark 9: Set A contains A − B as a subset, i.e., ( A − B ) ⊆ A

l Remark 10: The sets ( A − B ), A ∩ B , and ( B − A ) are mutually disjoint, that is, the
intersection of any two sets is the empty set.

A − B is shaded

2.3.5 COMPLEMENT

u The complement of a set A is the set of elements which do not belong to A, that is,
the difference of the universal set U and A

- The complement of A is denoted A’, A or A c


- The complement of A may also be defined as A c = {x | x ∈ U , x ∉ A} or
simply A c = {x | x ∉ A}

( A ∪ B ) c is shaded

Example 40: Let the universal set U be the lower case English alphabet and let
X = {a, b}. Then X c = {c, d, e, f, g, . . . y, z}

l Remark 11: A \ B = A ∩ B c or A − B = A ∩ B c

Let A = {1, 2, 4, 8, 16}, B = {2, 4, 6, 8, 10} and C = {1, 3, 7, 15}. Find the
following sets:

Ex er cise 11: A ∪ B

Ex er cise 12: A ∩ B

Ex er cise 13: A − C

Exercise 14: A ∪ ( B ∩ C )

Exercise 15: ( A ∩ B ) ∪ ( A ∩ C )

Exercise 16: C − ( B − A )

2-7
CHAP TER 2: SET THE ORY CS218

2.4 ATTRIBUTES OF SETS

2.4.1 EQUAL ITY OF SETS

u Set A is equal to set B if they both contain the same elements, i.e., if every element in
A is in B and every element in B is also in A, then we write their equality as A = B.

u We can also say that A = B if and only if A ⊆ B and B ⊆ A.


Example 41: Let A = {1, 2, 3, 4} and B = {3, 1, 4, 2}, then A = B as the order of the
elements in a set does not change the set.
Example 42: Let C = {4, 3, 4, 2}, D = {2, 3, 2, 4} and E = {2, 3, 4}, then C = D = E as
repeating the elements in a set does not change the set.
Example 43: Let F = { x | x 2 − 3x = − 2}, G = {2, 1}, and H = {1, 2, 2, 1}, then F = G = H.

2.4.2 COMPARABILITY

u Two sets A and B are said to be comparable if A ⊂ B or B ⊂ A, that is if one of the sets
is a subset of the other set.

u Two sets A and B are said to be incomparable if A ⊄ B and B ⊄ A.

- If A is not comparable to B then there is an element in A which is not in


B and, also, there is an element in B which is not in A.
Example 44: Let A = { a, b}, and B = {a, b, c}. Then A is comparable to B, as A ⊆ B.
Example 45: Let R = {a , b}, and S = {b , c, d} . Then R and S are not comparable since
a ∈ R and a ∉ S , and c ∈ S , and c ∉ R

2.4.3 CARDINALITY

u The number of elements in a set is called its cardinality. Cardinality is denoted by


placing vertical bars around the set.

Example 46: |{1, 3, 9, 15}| = 4


Example 47: |{1, 2, 3, . . .}| = ∞

2.4.4 THE PRIN CI PLE OF IN CLU SION AND EX CLU SION

u Let A and B be finite sets. Then A ∪ B = A + B − A ∩ B

2-8
CS218 CHAP TER 2: SET THEORY

2.5 PROOFS

2.5.1 USING VENN DIAGRAMS

u If three or fewer sets are involved in the given identity, we can draw a Venn diagram
for each side and verify that the sets in question are equal.

Exercise 17: Prove by Venn diagram that A ∪ ( B ∩ C ) = ( A ∪ B ) ∩ ( A ∪ C )

B ∩C A ∪ (B ∩ C )

A∪B A ∪C

( A ∪ B) ∩ ( A ∪ C )

Exercise 18: Prove by Venn diagram that ( A − B ) ∩ C = ( A ∩ C ) ∩ B c

A−B ( A − B) ∩ C

A ∩C Bc

(A ∩C )∩ Bc

2-9
CHAP TER 2: SET THE ORY CS218

u The following exercise illustrates how to prove a problem with a Venn diagram.

Exercise 19: Use Venn diagrams to prove the following:

All MA214 students are hardworking and analytical.


Peter is not hardworking but analytical.

2 - 10
CS218 CHAP TER 2: SET THEORY

2.5.2 PROOFS USING ALGEBRAIC LAWS

u In order to prove something using an algebraic law you must know some of the
important laws that apply to sets. (They have been summarized in section 2.9.1). The
procedure is to apply the law you are using, then if the law has a name to correctly
identify the law you are using to the right of the application.

Example 49: Prove ( A ∪ B ) ∩ ( A ∪ B c ) = A using algebraic laws.

Statement Reason

( A ∪ B ) ∩ (A ∪ B c ) Left hand side

= A ∪ (B ∩ B c ) Distributive Law

=A∪∅ Complement Law

=A Identity Law

Exercise 20: Prove ( A ∩ B ) ∪ ( A ∩ B c ) = A using algebraic laws.

Statement Reason

Exercise 21: Prove A ∪ ( A ∩ B ) = A using algebraic laws.

Statement Reason

2.6 SET THEORY TRUTH TABLES

u The truth tables for intersection, union, and complement are the same as those for
and, or, and not.

A B A∩B A∪B Ac
T T T T F
T F F T F
F T F T T
F F F F T

2 - 11
CHAP TER 2: SET THEORY CS218

2.7 THREE SET VENN DIAGRAMS

Exercise 22: Shade in the correct regions that corresponds to the given data.

a. ( A ∩ B) ∪ C

b. A ∩ ( B − C )

c. ( A − B − C ) c

2.8 VENN DIAGRAMS USING REGIONS

u In the diagram notice that it is broken up into four regions. The numbers are used to
indicate an area not a numerical value. Each area can be described using the set
operations we learned before.

Area 1 ≡ A−B ≡ A ∩ Bc

Area 2 ≡A∩B

Area 3 ≡ B− A ≡ B ∩ Ac
Area 4 ≡ ( A ∪ B)c ≡ Ac ∩ Bc
Area 1, 2, 3 ≡ A ∪ B

Find the following regions:

Exercise 23: Area 1

Exercise 24: Area 2

Exercise 25: Area 3

Exercise 26: Area 4

Exercise 27: Area 5

Exercise 28: Area 6

Exercise 29: Area 7

Exercise 30: Area 8

2 - 12
CS218 CHAP TER 2: SET THEORY

2.9 SUMMARY

2.9.1 LAWS OF THE ALGEBRA OF SETS

u Some important laws of sets.

Idempotent Laws
1a. A ∪ A = A 1b. A ∩ A = A
Associative Laws
2a. ( A ∪ B ) ∪ C = A ∪ ( B ∪ C ) 2b. ( A ∩ B ) ∩ C = A ∩ ( B ∩ C )
Commutative Laws
3a. A ∪ B = B ∪ A 3b. A ∩ B = B ∩ A
Distributive Laws
4a. A ∪ ( B ∩ C ) = ( A ∪ B ) ∩ ( A ∪ C ) 4b. A ∩ ( B ∪ C ) = ( A ∩ B ) ∪ ( A ∩ C )
Identity Laws
5a. A ∪ ∅ = A 5b. A ∩ U = A
6a. A ∪ U = U 6b. A ∩ ∅ = ∅
Involution Law
7. (A c )c = A
Complement Laws
8a. A ∪ A c = U 8b. A ∩ A c = ∅
9a. U c = ∅ 9b. ∅ c = U

10a. A ∪ B = ( A c ∩ B c )
c
10b. A c ∩ B c = ( A ∪ B ) c
Alternative Representation for Set Difference
11a. A \ B = A ∩ B c 11b. A \ B c = A ∩ B
Double Complement Law
12. ( A c ) c = A
DeMorgan’s Laws
13a. ( A ∪ B )c =A ∩B
c c
13b. ( A ∩ B ) c = A c ∪ B c
14a. X \ ( A ∪ B ) = ( X \ A ) ∩ ( X \ B ) 14b. X \ ( A ∩ B ) = ( X \ A ) ∪ ( X \ B )
Subset Laws
15a. A ∪ B ⊆ X iff A ⊆ X and B ⊆ X 15b. X ⊆ A ∩ B iff X ⊆ A and X ⊆ B
16a. A ⊆ A ∪ B and B ⊆ A ∪ B 16a. A ∩ B ⊆ A and A ∩ B ⊆ B
Absorbtion Laws
17a. A ∪ ( A ∩ B ) = A 17b. A ∩ ( A ∪ B ) = A

2 - 13
CHAP TER 2: SET THE ORY CS218

2.9.2 COMMON SYMBOLS AND THEIR MEANINGS

Symbols Meanings
∈ Is an element of
∉ Is not an element of
A⊂B A is a proper subset of B
A⊆S A is a subset of S
A⊄B A is not a subset of B
S ⊇ A, S ⊃A Set S is a superset of the set A
∅ Empty set
∪ Union
∩ Intersection
A − B, A \ B, A ~ B A minus B
A’ , A , A
c
A complement
A=B A and B have exactly the same elements
A≠B A and B do not have exactly the same elements
A ≡Β Equivalence; A is equivalent to B
↔, ⇔ If and only if or iff
→, ⇒ Implies
∀ For all, for every
∃ There exists
∋, |, : Such that
∞ Infinity

2.9.3 REMARKS

l If A ⊄ B then there is at least one element in A that is not a member of B.

l Every set is a subset of itself, since every element in a set is in itself.

l The null set ∅ is considered to be a subset of every set.


l A∪B = B∪ A
l A ⊆ ( A ∪ B ) and B ⊆ ( A ∪ B ).

l A∩B=B∩ A
l ( A ∩ B ) ⊆ A and ( A ∩ B ) ⊆ B

l If A and B are disjoint, then A ∩ B = ∅.


l ( A − B) ⊆ A

l The sets ( A − B ), A ∩ B , and ( B − A ) are mutually disjoint.

l A \ B = A ∩ B c or A − B = A ∩ B c

2 - 14
CS218 CHAP TER 2: SET THEORY

2.10 SET THEORY EXERCISES

u Draw a Venn diagram and shade in the correct regions that corresponds to the given
data:

1. A − B − C
2. ( A − B ) c
3. (A c − B c ) A B
4. ( A c − B c )
c

5. A c ∩ B c ∩ C c
6. A c ∪ B c ∪ C c
7. ( A ∩ B ) c ∪ C c
8. A ∩ B ∩ C C
9. A ∪ B ∪ C
10. ( A ∩ B ) ∪ C c
11. A ∩ B c ∩ C
12. A c ∩ B ∩ C
13. A c ∪ B ∪ C
14. A ∪ B c ∪ C
15. A ∪ B c ∪ C c

u Show by using Venn Diagrams or otherwise, whether the following identities hold:
16. ( A ∩ B ) c ≡ Ac ∪ Bc
17. A − B ≡ A ∩ Bc
18. A c ∩ B c ∩ C c ≡ ( A ∪ B ∪ C )c
19. A ∪ (B ∩ C c ) ≡ ( A ∪ B ) ∩ (A ∪ C c )

u Explain in words, what you understand by:

20. A ⊆ A
21. A ∪ A = U
22. A ∩ U = A
23. ∅ ⊆ A

u Suppose X = {x | x = y 2 , y ∈ N}

P = { p | p is a prime number}

E = {s | s = 2t , t ∈ N}
Determine
24. P ∩ E
25. X ∪ E
26. X ∩ P
27. E c

2 - 15
CHAP TER 2: SET THE ORY CS218

u Verify the following using the concept of regions.

28. ( A ∩ B) ∩ C = A ∩ (B ∩ C )

29. ( A ∪ B ) ∪ C = A ∪ ( B ∪ C )

u Prove the following:

30. A \ ( A \ B ) = A ∩ B
31. A = A ∩ ( A ∪ B )
32. ( A ∩ B ) c = A c ∪ B c
33. A ∪ ( B ∩ C ) = ( A ∪ B ) ∩ ( A ∪ C )

u Determine whether each of the following statements is true or false. Then explain.

34. x ∈ {x}
35. {x} ⊆ {x}
36. {x} ∈ {x}
37. {x} ∈ {{x}}
38. ∅ ⊆ {x}

u Suppose that A is the set{a , b} and that B is the set {∅}. Write the following sets out in
full, listing their elements where possible:

39. the power set P ( A )


40. the power set P ( B )
41. the Cartesian product A × ∅
42. the Cartesian product A × B

u Venn diagrams

43. Draw a Venn diagram and shade the required region for the following:
i) ( A ∩ B )c ∩ C c
ii) Bc ∪ (A ∪C )

44. Show that A ∩ ( B ∪ C ) ≠ ( A ∩ B ) ∪ ( B ∩ C ) by using Venn diagrams.

45. Show that ( A ∩ B ∩ C ) c = A c ∪ B c ∪ C c by using Venn diagrams.

46. Show that the following argument is valid using Venn diagrams:

All bakers bake bread. All chefs bake cakes. All the chefs attended the
meeting. David bakes cakes, but did not attend the meeting. Therefore,
David is not a chef.

2 - 16
CS218 CHAPTER 2: SET THEORY

47. Draw a Venn diagram to show that


i) the following argument to be true
ii) the following argument to be false
S1: All students at Informatics are dedicated and trustworthy
S2: Simon is trustworthy and dedicated
S3: Simon is a student
.....................................
S: Simon is an Informatics student

u Algebraic Laws

48. Prove ( B c ∩ U ) ∩ ( A c ∪ ∅ ) = ( A ∪ B ) c using algebraic laws.

2 - 17
CHAPTER 3: RELATIONS AND FUNCTIONS

Chapter Objectives

In this chapter, you will learn:

§ how sets relate to relations;

§ what a relation is;

§ how to represent a relation;

§ about the properties of relations ;

§ about the various types of relations;

§ what a function is;

§ what makes something a function;

§ how to represent a function;

§ how to determine a function;

§ about the various types of functions;

§ about the different classes of functions;

§ what operations can be done on functions;

3-1
CHAP TER 3: RE LA TIONS AND FUNC TIONS CS218

3.1 INTRODUCTION TO RELATIONS


u Before we introduce what is meant by the term ‘relation’, we need to know the
following:

3.1.1 ORDERED PAIRS AND PROD UCT SETS

u An ordered pair consists of two elements, say a and b, in which one of them, say a is
designated as the first element and the other as the second element.

u An ordered pair is denoted by (a, b)

u Two ordered pairs (a, b) and (c, d) are equal if and only if a = c and b = d.

Example 1: The ordered pairs (2, 3) and (3, 2) are different.

Example 2: The set {2, 3} is not an ordered pair since the elements 2 and 3 are
not distinguished in a set.

Example 3: Ordered pairs can have the same first and second elements such as
(1, 1), (4, 4)

u An ordered n-tuple is defined similarly, the n-tuple ( x1 , x 2 ,K , xn ) having the first


term x1, the second term x 2 K

u The set of all ordered pairs (a, b), where a ∈ A and b ∈Β , is called the Cartesian
Product, or simply the product set, of the two sets.

- Cartesian Product is denoted by A × B


- A × B = {( a , b ) | a ∈ A , b ∈ B}

Example 4: Let A = {1, 2, 3} and B = {a, b}. The product set is


A × B = {(1, a), (1, b), (2, a), (2, b), (3, a), (3, b)}

Example 5: W = {x, y}. Then W × W = {(x, x), (x, y), (y, x), (y, y)}

l Theorem 1: Let A and B be sets. If A = n, and B = m, then A × B = nm

3.1.2 SOME SPE CIAL SETS

u ∅ denotes the “null” or “empty” set

u Z denotes the set of integers, i.e. Z = {... , − 3, − 2, − 1, 0, 1, 2, 3...}

u Q denotes the rational numbers. The rational numbers are those real numbers which
can be expressed as the ratio of two integers. Q = x | x = { p
}
q where p ∈ Z , q ∈ Z

u Q c denotes the irrational numbers, i.e. a number that is not rational is irrational.

u N denotes the natural numbers. N = {1, 2, 3, 4, 5, . . . }

u R denotes the real numbers. Real numbers are the rational and irrational numbers.

u For each n ∈ N , S n = {1,... , n}

3-2
CS218 CHAP TER 3: RE LA TIONS AND FUNCTIONS

3.1.3 DEFINITION OF RELATION

u A binary relation between sets A and B is a subset of A × B. That is, a binary relation
is a collection of ordered pairs from A × B.

u If A and B are equal, we refer to the relation as a relation on the set A.

u Since relation R is a subset of A × B, any relation R has a complementary relation R,


which is the complement of the set R relative to A × B.

Example 6: Let A = {1, 2, 3} and B = {a , b}. Define some relations between A and B.
R1 = {(1, a ), ( 2, b ), ( 3, a ), (1, b )}
R2 = {( 3, b )}
R3 = A × B
R4 = ∅

Exercise 1: Let A = {1, 2, 3}. Let R be the relation on A consisting of ordered


pairs ( a , b ) such that a ≥ b. List the elements of R.

Exercise 2: If A = 4 and B = 3, how many relations between A and B are there?

u The domain of a relation R is the set of all first elements of the ordered pairs which
belong to R, and the range of R is the set of second elements.

u A relation is also written a R b, which means “a is related to b”

Example 7: Let A = {1, 2, 3}, and R = {(1, 2), (1, 3), ( 3, 2)}. Then R is a relation on A
since it is a subset of A × A

With respect to this relation: 1 R 2, 1 R 3, 3 R 2, where the domain of R is {1, 3}


and the range of R is {2, 3}

Example 8: Let A = {eggs, milk, corn} and B = {cows, goats, hens}. We can
define a relation R from A to B by ( a , b ) ∈ R if a is produced by b. In
other words:
R = {(eggs, hens), (milk, cows), (milk, goats)}
With respect to this relation,
eggs R hens, milk R cows, milk R goats

Example 9: Suppose we say that two countries are adjacent if they have some
part of their boundaries in common. Then “is adjacent to” is a
relation R on the countries of the earth.
Thus:
(Malaysia, Indonesia) ∈ R, but (Indonesia, Thailand) ∉R

3-3
CHAP TER 3: RE LA TIONS AND FUNC TIONS CS218

3.2 REPRESENTING RELATIONS

u Relations can be represented by listing the elements, as in examples 7-9, or they can
be represented graphically, by using pictures, or by using a matrix.

3.2.1 PICTORIAL REPRESENTATION OF RELATIONS

Example 10: Let R be a relation from A = {1, 2, 3} to B = {a , b} where


R = {(1, a ), (1, b ), ( 3, a )}. The relation can be represented as follows:

Exercise 3: Represent example 8 pictorially:

3.2.2 GRAPHI CAL REP RE SEN TA TION OF RE LA TIONS

u Another way of picturing a relation when it is from a finite set to itself is to write
down the elements of the set and then draw an arrow from an element x to an element
y whenever x is related to y. This type of diagram is called a directed graph of the
relation. (We will be discussing directed graphs in greater detail in chapter 7).
Example 11: The directed graph of R = {(1, 2), ( 2, 2), ( 2, 4 ), ( 3, 2), ( 3, 4 ), ( 4 , 1), ( 4 , 3)}
on the set A = {1, 2, 3, 4} is:

Note: There is an arrow from 2 to itself, since 2 is related to 2 under R.

u We will use the following graphical representation; see example 12, to represent a
relation.

Example 12: Let A = {1, 2, 3}, and let R be the relation on A defined as
R = {(1, 2), ( 2 , 1), ( 2, 3), ( 3, 1), ( 3, 3)}. Graphically:

3-4
CS218 CHAP TER 3: RE LA TIONS AND FUNCTIONS

Exercise 4: Draw the graphical representations of the relations R1, R2, R3,
and R4 from example 6.

Exercise 5: List the ordered pairs belonging to the relation shown below:

Exercise 6: Draw the directed graph representation of the relation “less than
or equal to” on the set S 3.

Exercise 7: Draw the directed graph representation for the relation R such
that, R = {(1, 2 ), ( 2, 1), ( 2, 3), ( 3, 1), ( 3, 3)}

3-5
CHAP TER 3: RE LA TIONS AND FUNC TIONS CS218

3.2.3 MATRIX REPRESENTATION OF A RELATION

u The more commonly used representation of relations that is also more convenient for
computations is using a matrix to represent a relation.

u Let A be a set with n elements, and let B be a set with m elements.

A = {a1 , a 2 ,... , a n}
B = {b1 , b 2 ,... , b m}

u Let R be a relation between A and B. Define the n × m matrix M by


 false if ( a i , b j ) ∉ R
M ( i, j) = 
 true if ( a i , b j ) ∈ R

for i = 1, . . ., n and j = 1, . . ., m. M is called the logical matrix for R.

Exercise 8: Write the matrix that represents R = {( 3, 3), ( 2, 3), (1, 2), ( 3, 2)}

Example 13: Let A be the set S 3 , and let B be the set S 2 . Let R be the relation
between A and B. R = {(1, 1), (1, 2) , ( 2, 1), ( 3, 2)}. Write the matrix
representing R.

Since A = 3 and B = 2, the matrix representing R must have three rows


and two columns. In row 2, column 2, for instance, the entry will be
 T T
false since (2, 2) is not an element of R, i.e. M =  T F
 
 F T

Example 14: Describe the relations corresponding to the two matrices given
below.

 T F T T F T F 
M1 = F T F T M 2 = T F T
   
T F F T  T T T

For matrix M 1, there are three rows and four columns, so M 1 is a relation R1
between S 3 and S 4 . The graph of R1 is represented in (a). Matrix M 2 , which has
three rows and three columns then is a relation R 2 on the set S 3 . The graph
of M 2 is represented in (b)

3-6
CS218 CHAP TER 3: RE LA TIONS AND FUNCTIONS

3.3 PROPERTIES OF RELATIONS

u Relations on a set can be classified according to certain properties. Let R be a relation


on a set A.

- We say that R is reflexive if ∀ x ∈ A x R x

- We say that R is symmetric if ∀ x, y ∈ A , x R y ⇒ y R x


- We say that R is transitive if ∀ x , y, z ∈ A , x R y and y R z ⇒ x R z

3.3.1 REFLEXIVE

u Let R be a subset of A × A. Then R is called a reflexive relation if, ∀ a ∈ A , ( a , a ) ∈ R

Example 15: The directed graph of every reflexive relation includes an arrow from
every point to the point itself, i.e.

Example 16: Let V = {1, 2, 3, 4} and R = {(1, 1), ( 2, 4 ), ( 3, 3), ( 4 , 1), ( 4 , 4 )}. Then R is not
a reflexive relation since ( 2, 2) does not belong to R

l Remark 1: All ordered pairs ( a , a ) must belong to R in order for R to be reflexive.

3.3.2 SYMMETRIC

u Let R be a subset of A × A, then R is called a symmetric relation if


( a, b) ∈ R ⇒ ( b, a) ∈ R
Example 17: The reason for the name of the symmetric property can be seen in
the matrices below. Notice that each of the matrix representations
for the symmetric relations are symmetric with respect to the main
diagonal.

a b c d a b c d a b c d
a F F F F a F T F T a F F F F
b F F T F b T F T F b F F F F
cF T F F c F T F F cF F F F
     
d F F F F d T F F F d F F F F

u Directed graph representations of symmetric relations are also readily recognized


because for every arrow from a to b there must also be an arrow from b to a.

Example 18: Let S = {1, 2, 3, 4}, and let R = {(1, 3), ( 4 , 2), ( 2, 4 ), ( 2, 3), ( 3, 1)}. Then R is
not a symmetric relation since ( 2, 3) ∈ R but ( 3, 2) ∉ R

3-7
CHAP TER 3: RE LA TIONS AND FUNC TIONS CS218

3.3.3 TRANSITIVE

u A relation R in a set A is called a transitive relation i f


( a, b) ∈ R and ( b, c) ∈ R ⇒ ( a, c) ∈ R
Example 19: The directed graphs below illustrate transitive relations. Note that it
is not easy to determine if a relation is transitive from either the
matrix or the graph representation.

Example 20: Let W = {a , b , c}, and let R = {( a , b ), ( c, b ), ( b , a ), ( a , c)}. Then R is not a


transitive relation since ( c, b ) ∈ R and ( b , a ) ∈ R but ( c, a ) ∉ R

Example 21: Determine if each of the following relations is reflexive, symmetric,


or transitive.

1. “Less than” (<), on Z

2. The relation R = {(1, 1), ( 2, 3), ( 3, 1)}, on the set S 3

3. The relation R = {( a , b ), ( c, d )}, on {a , b , c, d}

4. The empty relation ∅, on S 3

1. Let R be the “less than” relation on the set Z. Then R is transitive, but
not reflexive or symmetric.

2. Since ( 2, 2) ∉ R , R is not reflexive. Since ( 2, 3) ∈ R, but ( 3, 2) ∉ R , R is not


symmetric. Finally, ( 2, 3 ) ∈ R and ( 3, 1) ∈ R , but ( 2, 1) ∉ R, so R is not
transitive. Hence R has none of the three properties.

3. Clearly R is neither reflexive nor symmetric. R is transitive, however,


since there are no x, y, z ∈ {a , b , c, d} such that x R y and y R z. Thus the
condition for transitivity is vacuously satisfied.

4. Let ∅ be the empty relation on the set S 3 . First let’s look at


symmetry. Symmetry can be restated as the following implication:

If ( x, y) ∈ ∅, then ( y, x) ∈ ∅

Since ( x, y) ∈ ∅ is never true, the implication is vacuously true. By


similar reasoning, the empty relation is also transitive. However, the
empty relation is not reflexive, because the condition for reflexivity is
the implication:

If x ∈ S 3 , then ( x, x) ∈ ∅

and, for instance, 1 ∈ S 3 , but (1, 1) ∉ ∅

3-8
CS218 CHAP TER 3: RE LA TIONS AND FUNCTIONS

3.3.4 IRREFLEXIVE

u We say that a relation R on a set S is irreflexive if x R x for all x ∈ S

u Do not confuse the irreflexive property with the absence of the reflexive property.
There are relations that are neither reflexive nor irreflexive.

Example 22: Show that the relation on the set {a , b , c} given by the set of ordered
pairs {( a , b ), ( b , c), ( c, a )} is irreflexive.

The relation on the set {a , b , c} given by the set of ordered pairs


{( a, b), ( b, c), ( c, a )} is irreflexive, because it does not contain any of the
ordered pairs ( a , a ), ( b , b ) , ( c, c)

3.3.5 ANTISYMMETRIC

u We say that R is antisymmetric if for all x, y ∈ S , x R y and y R x implies x = y

u Do not confuse the antisymmetric property with the absence of the symmetric
property either. There are also relations that are neither symmetric nor
antisymmetric.

Example 23: Show that the relation “greater than or equal to” on Z is
antisymmetric.

The relation “greater than or equal to” on the set of integers is antisymmetric,
because if x, y ∈ Z , then ( x ≥ y and y ≥ x) ⇒ ( x = y)

3.4 TYPES OF RELATIONS

3.4.1 EQUIVALENCE RELATIONS

u A relation ~ on a set S is called an equivalence relation if it has the following three


properties:

(1) For each a in S, we have a ~ a - Reflexive property

(2) If a ~ b, then b ~ a - Symmetric property

(3) If a ~ b and b ~ c, then a ~ c - Transitive property

u A relation is an equivalence relation if it is reflexive, symmetric, and transitive.

u The general idea behind an equivalence relation is that it is a classification of objects


which are in some way “alike”

Example 24: The relation = of equality on any set S is an equivalence relation;


that is:

(1) a = a for every a in S; - Reflexive property

(2) if a = b, then b = a; - Symmetric property

(3) if a = b and b = c, then a = c. -Transitive property

3-9
CHAP TER 3: RE LA TIONS AND FUNC TIONS CS218

3.4.2 PAR TIALLY OR DERED RE LA TIONS

u A relation on a set A which is reflexive, antisymmetric, and transitive is called a


partial ordering on the set. The reason for the word partial is that not every pair of
elements of A must be related, as in the figure.

We have C ⊆ A, but B ⊄ C and C ⊄ B. In such cases, B and C are said to be


incomparable.

Example 25: If a and b are positive integers, a|b means that a is a divisor of b,
i.e. b = ac for some integer c. Show that “|” is a partial ordering of
the set of positive integers.

By definition, the a|b means that the number b / a is an integer. We need to


verify reflexivity, antisymmetry, and transitivity.

1. Reflexivity: For all positive integers n, n| n as n / n is 1

2. Antisymmetry: If n|m and m|n, then m / n and n / m are both


integers. Since n / m = ( m / n ) −1, the integer n / m
has the property that its reciprocal is also an
integer. The only such positive integer is 1, and so
n / m = 1, i.e. n = m.

3. Transitivity: If n|m and m|p, then p / n = ( p / m ) × ( m / n ) is an


integer, since it is the product of two other integers.

It follows that “|” is a partial ordering.

3.4.3 UNIVERSAL RELATIONS

u Let A be any set then A × A is known as the universal relation.

3.4.4 EMPTY RELATIONS

u Let A be any set, then ∅ is know as the empty relation.

3.4.5 INVERSE RELATIONS

u Every relation R between sets A and B is a subset of A × B. We can reverse the roles of
A and B to obtain a relation between B and A called the inverse relation of R. The
inverse relation of R, denoted R −1, is the relation between B and A given by

R −1 = {( y, x) : ( x, y ) ∈ R}

3 - 10
CS218 CHAP TER 3: RE LA TIONS AND FUNCTIONS

Exercise 9: Find the inverse of the relation given below:

Exercise 10: Given R = {( 3, b ), ( 2, a ), ( 5, b ), (1, a ), ( 4 , c)}. Find R −1

3.4.6 COM POS ITE RE LA TIONS

u Let’s look now at how to create new relations from existing ones. Let R be a relation
between sets A and B, and let S be a relation between B and C. The composition of R
and S is the relation between A and C, denoted S o R, given by:

S o R = {(x, z) : x ∈ A , z ∈ C , ∃ y ∈ B ∋ x R y and y S z}

Example 26: Graphically represent a composite relation.

where ( S o R )( x) = S ( R ( x ) = S ( y ) = z, and

( S o R )( x ) = S ( R ( x )) = S ( u ) = w

u One can view the composite relation as a means of linking elements of A to elements
of C by using elements of B as intermediate points.

3 - 11
CHAP TER 3: RE LA TIONS AND FUNC TIONS CS218

Exercise 11: Let R be the relation between S 3 and S 4 , and let S be the relation
between S 4 and S 2 , (see figure below). Find the composite
relation S o R between S 3 and S 2 .

3.5 INTRODUCTION TO FUNCTIONS

u A function is an association of exactly one object from one set (the range) with each
object from another set (the domain).

u This means that there must be at least one arrow leaving each point in the domain,
and futher that there can be no more than one arrow leaving each point in the
domain.

Exercise 12: Which of the relations below are functions?

3 - 12
CS218 CHAP TER 3: RE LA TIONS AND FUNCTIONS

3.5.1 ELE MENTS OF A FUNC TION

u We usually denote relations with capital letters. With functions the convention is to
use lowercase letters.

u Let f be a function from A to B. Because each element x of A appears in one and only
one pair ( x, y) ∈ f , it is possible to write y = f ( x) whenever x ∈ A. This notation
suggests mapping the element x to the element y. Functions are often referred to as
mappings or transformations.

u The unique element y = f ( x) of B assigned to x ∈ A by f is called the image of x under f

u We write f : A → B to indicate that f is a function from A to B

u The set A is called the domain of f

u The set B is called the codomain of f

u The range of f denoted by f [ A ] , is the set of all images; that is,

f [ A ] = { f ( x) : x ∈ A}

u The pre-image or inverse image of a set B contained in the range of f is denoted by


f −1( B ) and is the subset of the domain whose members have images in B. In
particular, the inverse image of a point in y in the range is the set of all x for which
f (x ) = y

Example 27: Determine whether each of the following relations is a function.


For those that are functions, give the domain and range of the
function.

1. {(1, a), (1, b), ( 2, c), ( 3, b)}


2. {( a, a), ( b, b), ( c, c)}
3. {( x, y) : x, y are real numbers and y − x = 1}

4. {( x, y) : x, y are positive integers and y − x = 1}

1. This is not a function because (1, a) and (1, b) are both in the relation.

2. This is a function, with domain, codomain, and range equal to {a, b, c}

3. Since y − x = 1 iff y = x +1, it is easy to see that this is a function with domain
and codomain equal to the set of real numbers. Also, for each real number
y, there is a real number x such that y = x +1. Therefore, the range of the
function is the set of real numbers.

4. This is a function. The domain and codomain are both the set of positive
integers. However, if y is a positive integer, there is a positive integer x
such that y = x +1 iff y ≥ 2. Hence the range is {2, 3, . . .}

u Notice that the function in (4) is not equal to the function in (3), even though they
both have the form y = x +1

3 - 13
CHAP TER 3: RE LA TIONS AND FUNC TIONS CS218

3.6 GRAPHING FUNCTIONS

3.6.1 CO OR DI NATE GRAPHS

u The set of all ordered pairs of the function f plotted in a Cartesian coordinate system
is called the graph of f.

u The graph of a function f is equivalent to the graph of the equation y = f ( x) as


described in elementary algebra.

Example 28: Draw the graph of f ( x) = x 2

u Not all equations in x and y determine functions.

l Remark 2: For a graph to be the graph of a function, any given vertical line can
intersect the graph in a most one point.

Example 29: Draw the graph of the relation y 2 = x

Exercise 13: Explain why the graph of y 2 = x is not a function.

Exercise 14: Which of the following graphs are graphs of functions?

3 - 14
CS218 CHAP TER 3: RE LA TIONS AND FUNCTIONS

3.7 TYPES OF FUNCTIONS

3.7.1 INJECTIONS

u Let f : A → B be a function. The function f is called an injective function, or an


injection, if ∀ x, y ∈ A , f ( x) = f ( y) implies x = y. Graphically this means that if two
arrows arrive at the same point in B, they must come from the same point in A, and
therefore they are the same.

u An injective function is also called a one-to-one function, or 1 − 1 function.

Example 30: Graphically represent an injective function.

one-to-one function

3.7.2 SURJECTIONS

u The function f is called a surjective function, or a surjection, if for each


y ∈ B ∃ x ∈ A ∋ f ( x) = y. Graphically this means there must be an arrow arriving at
each point of B.

u A surjective function is also called an onto function.

Example 31: Graphically represent a surjective function.

onto function

3.7.3 BIJECTIONS

u A function can also be neither 1− 1nor onto, or it can be both 1− 1and onto. If a function
is both 1− 1 and onto it is called a bijection or bijective function.

u A bijection from a set A to itself is called a permutation of the set A.

Example 32: Graphically represent a bijective function.

or

3 - 15
CHAP TER 3: RE LA TIONS AND FUNC TIONS CS218

Example 33: Graphically represent a function that is neither 1− 1 nor onto.

or

l Remark 3: A graph of a function f is 1− 1 iff every horizontal line intersects


the graph in at most one point.

l Remark 4: A graph of a function f is onto iff every horizontal line intersects


the graph in at least one point.

l Remark 5: The codomain and the range are equivalent iff the function is onto.

3.8 CLASSES OF FUNCTIONS

3.8.1 LIMITS

u The limit of a function f as x approaches infinity for large values of x is a very


important concept.

u The function f(x) approaches the limit L as x approaches +∞, written


lim f ( x) = L, if the values of f ( x) get arbitrarily close to L as x gets arbitrarily large.
x→+∞

c 
l Remark 6: If n > 0, lim  n  = 0 for any constant c
x→+∞  x 

l Remark 7: To find the limit of a function as x approaches ∞, first divide the


numerator and denominator by the highest power of x appearing
in either place and then let x approach ∞
2x − 1
Exercise 15: By remark 10, lim 1x = 0. Show that lim =2
x→+∞ x→+∞ x −1

x 3 + 3x − 1
Example 34: Find the following limit: lim
x→+∞ x + 7x + 3
2

Dividing the numerator and denominator by x 3 , we have

x 3 + 3x − 1 1+ ( 3x 2 ) − ( 1x 3) 1+ 0 + 0 1
lim = lim = =
x + 7( x ) + ( x )
x→+∞ x + 7x + 3 x→+∞ ( 1 ) 0+ 0+ 0 0
2 12 3 3

We cannot divide by zero; the numerator in the limit approaches 1, the


denominator approaches 0 and is always positive. If we divide 1 by smaller and
smaller numbers, the quotients will become larger and larger. Thus, we write:
x 3 + 3x − 1
lim 2 = +∞
x→+∞ x + 7x + 3

3 - 16
CS218 CHAP TER 3: RE LA TIONS AND FUNCTIONS

1
l Remark 8: When the limit of a function is , we say that lim f ( x) = +∞.
0 x→+∞

l Remark 9: Another way to view limits as x approaches +∞ or −∞ is to


use only the highest degree terms in the numerator and
denominator.

5x 3 + 3x
Exercise 16: Find the lim
x→−∞ 9x − 4 x + 2
4 3

3.8.2 BI NARY OP ERA TIONS

u Another important class of functions is the class of functions known as binary


functions.

u A binary operation on a set A is a function op : A × A → A. Thus a binary operation


takes two elements of A and maps them to a third element of A.

u Rather than write op( a , b ) for the value of the operation, it is more common to write
a op b , a , b ∈ A.

- op( a , b ) is called prefix notation.

- a op b , a , b ∈ A is called infix notation.

Example 35: Here are some examples of binary operations:

- The set operations union ∪, and relative complement −


- The composition operation o on the set
F A = { f : f is a function from A → A}, A a set.

- The logical connectives and and or on a set of propositions.

3.9 OPERATIONS ON FUNCTIONS

3.9.1 EQUAL FUNCTIONS

u Two functions are said to be equal if they have the same domain and codomain, and
for all x in the domain f ( x) = g ( x)

Example 36: Let f ( x) = ( 6x − 4 ) 2 and g ( x) = 3x − 2, then f = g , since they both have


the same domain and codomain, and for all x in the domain
f ( x) = g ( x)

3 - 17
CHAP TER 3: RE LA TIONS AND FUNC TIONS CS218

3.9.2 SUM OF FUNCTIONS

u The sum of f and g, f + g , is defined by ( f + g )( x) = f ( x) + g ( x)

Example 37: Find the sum of f ( x ) = 3x + 5 and g ( x) = 4 x − 3

s( x) = ( f + g )( x) = ( 3x + 5) + ( 4 x − 3) = 7x + 2

3.9.3 DIF FER ENCE OF FUNC TIONS

u The difference of f and g, f − g , is defined by ( f − g )( x) = f ( x) − g ( x)

Example 38: Find the difference of f ( x) = 3x + 5 and g ( x) = 4 x − 3

d ( x) = ( f − g )( x) = f ( x) − g ( x) = ( 3 x + 5) − ( 4 x − 3) = −x + 8

3.9.4 PRODUCT OF FUNCTIONS

u The product of f and g, fg, is defined by ( fg )( x) = f ( x) ⋅ g ( x)

Example 39: Find the product of f ( x) = 3x + 5 and g ( x) = 4 x − 3

p( x) = ( fg )( x) = f ( x)g ( x) = ( 3x + 5)( 4 x − 3) = 12x 2 + 11x − 15

3.9.5 QUO TIENT OF FUNC TIONS

f ( x)
u The quotient of f and g, f g, is defined by ( f g )( x) =
g( x )

Example 40: Find the quotient of f ( x) = 3x + 5 and g ( x) = 4 x − 3

q( x) = ( f g )( x) = f ( x) g ( x) = ( 3x + 5) ( 4 x − 3)

3.9.6 COM POS ITE FUNC TIONS

u As functions are subsets of relations, the composition of a function is the same as for
relations.

Example 41: Let f ( x) = 3x + 5 and g ( x) = 4 x − 3. Find

a. ( f o g )( x) b. ( g o f )( x) c. ( f o f )( x) d. ( g o g )( x)
a. ( f o g )( x) = f ( g( x)) = f ( 4 x − 3) = 3( 4 x − 3) + 5 = 12x − 9 + 5 = 12x − 4

b. ( g o f )( x) = g( f ( x)) = g( 3x + 5) = 4( 3x + 5) − 3 = 12x + 20− 3 = 12x + 17


c. ( f o f )( x) = f ( f ( x)) = f ( 3x + 5) = 3( 3x + 5) + 5 = 9x + 15 + 9 = 9x + 24

d. ( g o g )( x) = g( g( x)) = g( 4x − 3) = 4( 4x − 3) − 3 = 16x − 12− 3 = 16x − 15

3 - 18
CS218 CHAP TER 3: RE LA TIONS AND FUNCTIONS

3.9.7 INVERTABLE FUNC TIONS

u Any function f has an inverse relation, f −1. The inverse relation does not need to be a
function. If the inverse relation of a function is a function, we say that the function is
invertible.

l Theorem 2: Let f : A → B be a function. The function f is invertible iff f is a


bijection.

Example 42: Determine if each of the functions below are invertible.

a. The function is not onto so it is not invertible.

b. The function is an injection and a surjection, i.e. bijective so the inverse


relation is a function, i.e. invertible.
l Remark 10: To find the inverse of a function y = f ( x):

1. Solve the equation y = f ( x ) for x in term of y.


2. In the resulting equation, replace x by y and y by x.

3. f −1 equals the right side of the equation found in step 2.

Example 43: Find the inverse of f ( x) = 4 x − 1

First we solve y = 4 x − 1 for x in terms of y:


y +1
y + 1= 4x or 4 x = y + 1 or x =
4
Now replace x by y and y by x, obtaining y = ( x +1) 4

Therefore, f −1( x) = ( x + 1) 4
x +1
Example 44: Verify that f −1( x) = is the inverse function of f ( x) = 4 x − 1
4

To verify this we need to show that ( f o f −1 )( x) = x and that ( f −1 o f )( x) = x:

 x + 1 x +1
(fo f −1 )( x) = f ( f − 1( x)) = f 
 4 
= 4⋅
4
− 1 = ( x + 1) − 1 = x and
( 4 x − 1) + 1 4 x
( f −1 o f )( x) = f −1 ( f ( x)) = f −1( 4x = 1) = 4 = 4 = x

So since ( f o f −1 )( x) = ( f −1 o f )( x) = x, f −1( x) = ( x + 1) 4 is the inverse of


f ( x) = 4 x − 1

3 - 19
CHAP TER 3: RE LA TIONS AND FUNC TIONS CS218

3.10 SUMMARY

3.10.1 THEOREMS
l Let A and B be sets. If A = n , and B = m, then A × B = nm.

l Let f : A → B be a function. The function f is invertible iff f is a bijection.

3.10.2 REMARKS

l All ordered pairs ( a , a ) must belong to R in order for R to be reflexive.

l For a graph to be the graph of a function, any given vertical line can intersect the
graph in a most one point.
l A graph of a function f is 1− 1 iff any horizontal line intersects the graph in at most
one point.
l A graph of a function f is onto iff every horizontal line intersects the graph in at
least one point.
l The codomain and the range are equivalent iff the function is onto.
c 
l If n > 0, lim  n  = 0 for any constant c
x→+∞  x 

l To find the limit of a function as x approaches ∞, first divide the numerator and
denominator by the highest power of x appearing in either place and then to let x
approach ∞.
1
l When the limit of a function is , we say that lim f ( x) = +∞
0 x→+∞

l Another way to view limits as x approaches +∞ or −∞ is to use only the highest


degree terms in the numerator and denominator.
l To find the inverse of a function y = f ( x):

1) Solve the equation y = f ( x) for x in terms of y

2) In the resulting equation, replace x by y and y by x

3) f −1 equals the right side of the equation found in step 2

3 - 20
CS218 CHAP TER 3: RE LA TIONS AND FUNCTIONS

3.11 RELATIONS AND FUNCTIONS EXERCISES

u Let A = {1, 2, 3, 4}, and let R be the relation on A given by R = {(1, 2) , (1, 3), ( 2, 4 )}. Show
the following representation of R.

1. The graph representation

2. The directed graph representation

3. The matrix representation

u Let A = {1, 2, 3, 4 , 5, 6}, a n d l e t R be the relation on A given by


R = {( x, y) : x < y or x is prime}

4. Give the matrix representation of R.

u Using this diagram:

5. Write the relation as a set of ordered pairs.

u Let A = {1, 3, 5, 9}, and let B = {u , v, w}. Represent the following relations in graphical
form.

6. R1 = {(1, v), (1, w), ( 5, u ), ( 9, v), ( 9, u )}

7. R 2 = {(1, v), ( 3, v), ( 5, v ), ( 9, v)}

8. R 3 = {( 5, u ), ( 5, v), ( 5, w )}

u Let Q be the relation on S 4 given by u Q v if u ≠ v. Represent Q in each of the following


ways:

9. as a set of order pairs

10. in graphical form

11. in matrix form

u Let A and B be sets such that A = m and B = n

12. How many relations between A and B are there?

u Given A = {1, 2}, B = {x, y, z} and C = {3, 4}

13. Find A × B × C

u Given ( 2x, x + y) = ( 6, 2)

14. Find x and y.

3 - 21
CHAP TER 3: RE LA TIONS AND FUNC TIONS CS218

u L e t R a n d S b e t h e f o l l o w i n g r e l a t i o n s o n A = {1, 2, 3}:
R = {(1, 1), (1, 2), ( 2, 3), ( 3, 1), ( 3, 3)} S = {(1, 2), (1, 3), ( 2, 1), ( 3, 3)}

15. Find R ∩ S , R ∪ S and R c

u For each of the following relations:

16. give the corresponding set of ordered pairs and the matrix
representation.

u For each of the following relation matrices, list the set of ordered pairs that belong to
the relation and draw the graph form of the relation.

1 2 3
1 2
1 2 3 4 1  T F T
17. 18. 1  F T 19.
1[T F F T] 2  T F F
2  F T  
3  F T T

u Given A = {1, 2, 3, 4} and B = { x, y, z}. Consider the following relation from A to B:


R = {(1, y), (1, z ), ( 3, y), ( 4 , x ), ( 4 , z )}

20. Plot R on a coordinate diagram of A × B

21. Determine the matrix of the relation.

22. Draw the arrow diagram of R

23. Find the inverse relation R −1 of R

24. Determine the domain and range of R

u Consider the set A = {a , b , c} and the relations on A represented by the directed


graphs below:

25. Determine which are reflexive, irreflexive, symmetric, antisymmetric, and


transitive.

3 - 22
CS218 CHAP TER 3: RE LA TIONS AND FUNCTIONS

u Consider the following five relations on the set A = {1, 2, 3}:


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

T = {(1, 1), (1, 2), ( 2, 2), ( 2, 3 )}, ∅ = empty relation, A × A = universal relation.
Determine whether or not each of the above relations on A is:

26. reflexive

27. symmetric

28. transitive

29. an equivalence relation

u Given the relation R = {( a , a ), ( b , b ) , ( c, c), ( a , b ), ( b , a )} on A = {a , b , c}

30. Show that R is an equivalence relation.

u Graph the partial ordering of:

31. “is a subset of” on the power set P( A ), where A = {a , b}

u The relations R, S, T and U are defined upon integers by the following equivalence’s:
a R b ↔ a ≥ b a S b ↔ a < b a T b ↔ a R b ∧ a S b aU b ↔ a R b ∨ a S b

32. which of these relations are reflexive relations?

33. which of these relations are symmetric relations?

34. which of these relations are transitive relations?

u Let R be the relation on the set of positive integers, defined by a R b iff a × b is odd.
Prove the following properties hold or give a counter-example.

35. reflexivity

36. symmetry

37. transitivity

u Let R be the relation on the set of positive integers defined by a R b iff a + 2b = 10. Give a
counterexample to prove that:

38. R is not reflexive

39. R is not symmetric

40. R is not transitive

u Let R be the following relation between S3 and S 5:


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

41. Find R −1, the inverse of R

3 - 23
CHAP TER 3: RE LA TIONS AND FUNC TIONS CS218

 F T
 T F F
u Let M 1 =  T F , let M 2 =
   T T T
 F T

42. Compute M 1 ⋅ M 2

43. Compute M 2 ⋅ M 1

u Let R and S be the following relations on A = {1, 2, 3, 4}:


R = {(1, 1), (1, 3), ( 3, 2), ( 3, 4 ), ( 4 , 2)} S = {( 2, 1) , ( 3, 3), ( 3, 4 ), ( 4 , 1)}. Find each of the
following composite relations on A.

44. RoS

45. S oR

46. RoR

47. S oS
u Use the following diagrams.

48. State whether each diagram defines a function from {a , b , c} to {x, y, z}

u Determine if each of the following functions is injective, surjective, or bijective.

49. f : R → R f ( x) = 2 x

50. f : Z → Z + f ( x) = x

51. f : Z+ → Z+ × Z+ f ( x) = ( x, x +1)

u Determine the number of different functions for:

52. a function from {1, 2} to {a , b , c}

u Determine graphically whether the following functions are 1− 1 or onto or bijective.


Consider the domain and codomain for the functions to be the real numbers.

53. f ( x) = x

54. g ( x) = x 3 + 1

55. h( x) = 3x − 1

u Find the inverse of:

56. f ( x) = 4 x − 1

57. g ( x) = x 3 + 1

3 - 24
CS218 CHAP TER 3: RE LA TIONS AND FUNCTIONS

u The functions f and g are both injective and surjective functions upon integers. The
functions h and i are defined by the following equalities: h = f o g , i = ( g −1 ) o ( f −1 )

58. which of h and i must be injective functions?

59. what is the relationship between h and i −1?

u Let X = {0, 1, 2} and Y = {0, 1, 4}. Let the function f : X → Y be defined by f : x → x 2

60. Is f 1− 1, onto or bijective? Use an arrow diagram to illustrate your answer.

61. Is the inverse relation f −1 :Y → X a function? Why?

u Two real-valued functions are defined by f ( y) = 4 y − 1 and g ( z ) = z 3

62. What is ( g o f )( x)?

u Show the following functions f and g are inverses of each other.

63. f ( x) = x +1 g ( x) = x −1

64. f ( x) = 1 x g ( x) = 1 x given that x ≠ 0

65. f ( x) = ( x + 1) ( x − 1) g ( x) = ( x + 1) ( x − 1) given that x ≠ 1

u Find the following limits:


6x 2 − 3
66. lim
x→+∞ 2x + 8

x2
67. lim x −
x→+∞ x +1

5x 3 + 1
68. lim
x→+∞ 2x + 3
3

u A relation maps elements from set A to set B. A has m elements, and B has n elements.
How many one-to-one functions are there if:

69. m= n ?

70. m> n ?

71. m< n ?

u The following functions are defined on the integers. State whether they are
one-to-one, onto, or bijective functions, and explain your reasons in each case.

72. f (x ) = x 2

73. g (x ) = x 3 − x

u Find a formula for the inverse of each of the following:

74. g (x ) = x 2 −1

2x − 3
75. h( x ) = , where x ≠ 5
7
5x − 7

3 - 25
CHAP TER 3: RE LA TIONS AND FUNC TIONS CS218

u Relations and functions can both be seen as sets of pairs. The presence of the pair
( x, y ) in the relation (or function) indicates that x is related to y (or that x maps to y
under the function).

76. Explain the difference between a function and a relation


77. Explain what is meant by the inverse of a relation
78. Explain what is meant by the composition of two functions

u Suppose that A is the set {1, 2, 3} and that B is the set {a , b , c, d }, with four distinct
elements:

79. Is it possible to define a function f from A to B such that f is onto?


Explain your answer.

80. If g is a function from B to A, can the inverse of g be a function?


Explain your answer.

81. If i is an onto function from B to A, and h is a 1-1 function from A to B,


which of the following statements are true? Explain your answer.
a. h o i is a function
b. h o i is 1-1
c. h o i is onto

u Since functions may be seen as a special case of relations, we may apply the terms
reflexive, symmetric, and transitive to functions, with the same meaning as before. If
F, G, and H are functions from {1, 2, 3} to {1, 2, 3}, what must be true if

82. F is reflexive?
83. G is symmetric?
84. H is a transitive, onto function?

u Find a formula for the inverse of each of the following.

85. g (x ) = x 2 −1
2x − 3
86. h( x ) = where x ≠ 75
5x − 7

u The following functions are defined on the integers. State whether they are
one-to-one, onto, or bijective functions, and explain your reasons in each case.

87. f (x ) = x 2
88. g (x ) = x 3 − x

u Using the relation that holds between two integers a and b if and only if a divides b
with no remainder.

89. Define the relation


90. Define what it means for this relation to be transitive
91. Prove that this relation is transitive

3 - 26
CS218 CHAP TER 3: RE LA TIONS AND FUNC TIONS

u Suppose that R is the relation {( 0, 2 ), (1, 1), ( 2, 0 )} on the set {0, 1, 2}

92. Which pairs would you need to add to R to make a reflexive relation?
93. Which pairs would you need to add to R to make a transitive relation?

u Relations

94. Consider the circle relation C defined for all ( x, y ) ∈ R × R, such that

1 ≤ x, y ≤ 1 ( x, y ) ∈ C ↔ x 2 + y 2 = 1. Is C a function? Explain.
95. Consider the relation L defined for all ( x, y ) ∈ R × R ( x, y ) ∈ L ↔ y = x −1 Is
L a function? Explain.

96. Consider the relation B = {( x, y ) ∈ N × N : | x − y| ≤ 2} Is this relation

i) reflexive?
ii) symmetric
iii) transitive?
iv) an equivalence relation?
In each case explain your answers.
97. Consider the relation R represented by the following matrix
V1 V2 V3
V1  1 1 0
V2  1 1 1
 
V3  0 1 1

Is the relation
i) reflexive?
ii) symmetric?
iii) transitive?
iv) an equivalence relation?
In each case explain your answers.

u Suppose that R and S are binary relations on a set A. Answer the following, and give
explanations for your answers.

98. If R and S are reflexive, is R ∩ S reflexive?


99. If R and S are symmetric, is R ∩ S symmetric?
100. If R and S are transitive, is R ∩ S transitive?

u Consider the circle relation on the set of real numbers: for all
x, y ∈ R , x C y ↔ x 2 + y 2 = 1. Determine if each of the following is true, and justify
your answers.

101. C is reflexive
102. C is symmetric

103. C is transitive.

104. C is an equivalence relation

3 - 27
CHAP TER 3: RE LA TIONS AND FUNC TIONS CS218

u Suppose that g is a function from A to B and f is a function from B to C.

105. Show that if both f and g are one-to-one functions, then f o g is also one-
to-one.

106. Show that if both f and g are onto functions, then f o g is also onto.

3 - 28
CHAPTER 4: METHODS OF PROOFS

Chapter Objectives

In this chapter, you will learn:

§ what a predicate quantifier is;

§ an exact definition for odd and even numbers;

§ what absolute value is;

§ what a sequence is;

§ about the different types of numbers;

§ what a recurrence relation is;

§ how to convert repeating decimals to fractions;

§ what a series is;

§ some important properties of sums;

§ the important rules involving exponents;

§ what the inverse, converse, and contrapositive of a proposition is;

§ how to prove something with a direct proof;

§ how to prove something using a contrapositive proof;

§ how to prove something using by contradiction;

§ how to prove something by counterexample;

§ what the principle of mathematical induction is;

§ how to prove something using mathematical induction;

4-1
CHAP TER 4: METH ODS OF PROOFS CS218

4.1 MATHEMATICAL FACTS

u Before we continue, you must be familiar with a few basic mathematical facts.

4.1.1 PREDICATE LOGIC

u We have been using the “Quantifiers” ∀ and ∃ so far without formally introducing
them to you. They are known as predicate quantifiers. ∀ means for all and ∃
means there exists.

Example 1: If we have one computer that all students must share, we say:

∃ one computer ∀ students.

Example 2: If each student has a separate computer, we would say:

∀ students ∃ one computer.

Note: The two example may both appear to be saying that “there exists” only one
computer; however, example 2 is actually saying mathematically that every
student has a ‘unique’ computer.

4.1.2 ODD AND EVEN NUMBERS

u Any odd integer can be expressed as n = 2 p + 1.

u Any even integer can be expressed as n = 2 p.

4.1.3 AB SO LUTE VALUE

u The absolute value of a number x, denoted x, is x when x is positive or zero and is − x


when x is negative.

Example 3: Find 4, and 4 .


4= ( 4) = 4 and 4 = 4
− −

4.1.4 DIVISIBILITY

u If a divides b, we write a | b.

Example 4: 3 | 18 is true because 18 = 3 × 6.

4-2
CS218 CHAPTER 4: METHODS OF PROOFS

4.1.5 TYPES OF NUMBERS

u There are several different types of numbers which you need to be aware of. They are:

a. Prime numbers: Prime numbers are numbers that are divisible by 1 and
the number itself, i.e. 2, 3, 5, 7, 11, 13, 17, 19, 23, . . .

b. Integers: Any of the numbers . . . , 4 , − 3, − 2, − 1, 0, 1, 2, 3, . . .

c. Natural numbers: The numbers 1, 2, 3, 4, 5, 6, . . .


d. Whole numbers: The numbers 0, 1, 2, 3, 4, . . .
e. Rational numbers: A number that can be expressed as an integer or as
a quotient of integers. (such as 2 , 3 , 7).
1 4

f. Irrational numbers: A number not expressible as an integer or


quotient of integers; a nonrational number.
g. Real numbers: Any rational or irrational number.

4.1.6 RECURRENCE RELATION

u A recurrence relation is an equation that defines the i th value in a sequence of


numbers in terms of the preceding i −1 values.

Example 5: 0 ! = 1 and n ! = ( n − 1) !⋅ n is a recurrence relation, i.e. the factorial


relation.

Exercise 1: Find the first six terms of the sequence satisfying the recurrence
relation: x1 = 2 x2 = 1 x n+2 = 3xn − 2xn+1.

4.1.7 SEQUENCES

u A sequence is simply a list, such as 2, 4, 6, . . . where the numbers 2, 4, etc. are the
terms of the sequence.

Example 6: 1, 12 , 13 ,L , 1n is a finite sequence.


Example 7: a1 , a 2 , a 3 ,L , a n ,L is an infinite sequence.

u A geometric sequence is a sequence for which the ratio of a term to its predecessor
is the same for all terms. The general form of a finite geometric sequence is
{a , ar, ar 2 , ar 3 ,L , ar n−1}, where a is the first term, r is the common ratio, and ar n−1 is
a (1− r n )
the last term. The sum of the terms is
1− r

4-3
CHAPTER 4: METHODS OF PROOFS CS218

a
l Remark 1: S∞ = represents a geometric sequence summed to infinity,
1− r
where a is the first term, and r is the common ratio.

Exercise 2: 0. 33 is a geometric sequence to infinity. Represent this as a fraction.

a − r n+1 a
Exercise 3: Show that S n = = as n goes to infinity when |r| < 1
1− r 1− r

l Remark 2: To express a decimal as a fraction:

1. Identify the first term a.

2. Identify the common ratio r.

a
3. Plug the values into the geometric sequence equation S ∞ =
1− r

4. Reduce the fraction to lowest terms.

4.1.8 SERIES
n
u A series can be written in the form a 1 + a 2 + a 3 + ... + a n + ..., or as ∑ a . The symbol
i
i =1

∑ ai means summation; read “the sum i equals 1 to n of a sub i”. The starting value
is the value on the bottom of the symbol ∑; the ending value is placed on top of the ∑
symbol.
5
Example 8: Write the sum ∑ ( 2i + 1) out in full.
i =1

∑ ( 2i + 1) = [ 2(1) + 1] + [ 2( 2) + 1] + [ 2( 3) + 1] + [ 2( 4) + 1] + [ 2( 5) + 1]
i =1

= [ 2 + 1] + [ 4 + 1] + [ 6 + 1] + [ 8 + 1] + [10 + 1] = 3 + 5 + 7 + 9 + 11.
k k+1
Example 9: The series 1+ 2 + 3 + L + k + k + 1 = ∑ i + ( k + 1) = ∑ i
i =1 i =1

k+1 k
Example 10: The summation ∑ i = ∑ i + ( k + 1)
i =1 i =1

4-4
CS218 CHAPTER 4: METHODS OF PROOFS

u The following properties about sums should be remembered.

Summation Properties
b b+k
1. ∑ i = ∑ (i − k) k ∈N
i=a i = a+k

b b −k
2. ∑ i = ∑ (i + k )
i=a i=a −k
k ∈N

b b
3. ∑ cx i = c∑ x i c is a constant , xi is an expression invo lving i.
i=a i=a

b b b
4. ∑ (x
i=a
i + y i ) = ∑ xi + ∑ yi
i=a i=a
x i and y i are expressions involving i.

n
5. ∑ c = nc c is a constant.
i =1

a
6. ∑x i = xa xi is an expression involving i.
i=a

Exercise 4: Using the summation properties evaluate each of the following:


10 6 13
a. 3∑ i b. ∑ 3( j + 4) c. ∑ 3( x − 3)
i=5 j =1 x= 8

4.1.9 EXPONENTS

u The rules for exponents that you will need to be familiar with are summarized in the
following table.

The Rules of
Exponents
x n ⋅ x m = x n+m
xn
= x n− m
xm
(x n ) m = x nm
x 0 = 1, x ≠ 0
1
x −n =
xn

( xy) n = x n ⋅ y n
n
x xn
  = n
 y y

4-5
CHAPTER 4: METHODS OF PROOFS CS218

4.1.10 LOGIC

u The inverse of p → q is ~ p → ~ q

u The converse of p → q is q → p

u The contrapositive of p → q is ~ q → ~ p

l Remark 3: p → q ≡ ~ q → ~ p

Exercise 5: State the inverse, the converse, and the contrapositive of: If x is
odd, then x 2 is odd.

inverse:

converse:

contrapositive:

Exercise 6: State the inverse, the converse, and the contrapositive of: He’s 60,
if he’s a day.

inverse:

converse:

contrapositive:

4.2 PROOFS

u Now that we have established the basic tools for propositions and predicates we can
use them to construct logic arguments. There are several ways in mathematics to
construct a logical argument. A logical argument is the same thing as a proof.

4.2.1 DI RECT PROOFS

u Direct arguments are probably familiar to you from algebra and plane geometry. Let
us look a direct proof to show you again what one is:

Example 11: Give a direct proof for “If x > y then x 2 > y 2 .”

2
We first observe that x 2 > y , since x > y. Also z 2 = z 2 for any number z. The
conclusion follows.

Example 12: Give a direct proof that for real numbers x and y, x + y ≥ x + y .

Use the fact that for any real number z, z 2 = z . For any real numbers x and
2

y, x + y = ( x + y) = x 2 + 2xy + y 2 . But 2xy ≤ 2 x y, so we get


2 2
( 2
) 2
x+ y ≤ x + y ,
and the inequality follows.

4-6
CS218 CHAPTER 4: METHODS OF PROOFS

4.2.2 CONTRAPOSITIVE PROOFS

u The second kind of argument, contrapositive, is based on the fact that not Q ⇒ not
P is logically equivalent to P ⇒ Q i.e. ( ~ q → ~ p ) ↔ ( p → q ).

Example 13: Let n be a positive integer. Give a contrapositive proof that, if n is a


prime number different from 2, then n is odd.

The contrapositive form of the statement “If n is a prime number different


from 2, then n is odd” is “If n is even, then either n = 2 or n is a not a prime
number.” We suppose that n is even. Then n = 2 ⋅ p for a positive integer, p < n.
Now, either p = 1 or p > 1. If p = 1, then n = 2. If p > 1, then n is not prime because
n is divisible by p and p ≠ n or p ≠ 1. In either case, we have proven the
contrapositive. Therefore, the initial implication is true.

Example 14: Prove if n 2 is even then n is also even by contrapositive.

The contrapositive form of the statement “if n 2 is even then n is also


even” is “if n is odd then n 2 is also odd.” We suppose that n is odd. Then
n = 2 p + 1 and n 2 = ( 2 p + 1) = 4 p 2 + 4 p + 1= 2( 2 p 2 + 2 p ) + 1 and if we let
2

m = ( 2 p 2 + 2 p ) then we have n = 2m + 1, which is odd. So we have proven


the contrapositive. Therefore, the initial implication is true.

4.2.3 PROOFS BY CONTRADICTION

u A proof by contradiction is a proof of an implication that shows that joining the


assumption “ Q is false” together with the premise “ P is true” leads to a contradiction.

Example 15: Let n be a positive integer. Give a proof by contradiction that if n


is a prime number different from 2, then n is odd.

Let P( n ) be the statement “n is a prime number different from 2,” and let
Q( n ) be the statement “n is odd.” To carry out the proof by contradiction, we
need to assume that n is a prime number different from 2 and that n is even.
Then if we find a contradiction, the proof is complete. From the assumption,
we see that n = 2 ⋅ p for some positive integer p. If p = 1, then n = 2. If p > 1, then n
is not prime because n is divisible by p and p ≠ n or p ≠ 1. In both cases, we
obtain a contradiction, so the initial implication is true.

Example 16: Prove that 2 is an irrational number. Use proof by contradiction.

Using proof by contradiction, we must prove that 2 is a rational number is


a
false. If 2 is a rational number then 2 can be expressed as with
b
a a a2
a , b ∈ Z , b ≠ 0. Assuming that is in lowest terms then: 2 = , and ( 2) = 2
2

b b b
2
a
⇒ 2 = 2 2 b 2 = a 2 which implies a 2 is even. If a 2 is even then a is also even, and
b
so a = 2 p ⇒ a 2 = 4 p 2 ⇒ 4 p 2 = 2b 2 ⇒ b 2 = 2 p 2 . Hence b 2 is also even, and so b is
also even. However if both a and b are even then they both have a common
factor and are not in lowest terms, so we have a contradiction, and thus the
initial implication is true.

4-7
CHAPTER 4: METHODS OF PROOFS CS218

4.2.4 COUNTEREXAMPLES

u At times use of proofs is not only impossible, but unnecessary. Sometimes in order to
prove something all that is necessary is to provide an example that proves the
statement false, i.e. a counterexample.

Exercise 7: Prove that ∀ positive integers x ∃ an integer y∋ y 2 = x is false.

4.2.5 MATHEMATICAL INDUCTION

u Mathematical induction is a method of proving a law or theorem by showing that


it holds in the first case and showing that, if it holds for all cases preceding a given
one, then it also holds for this case.

u Before mathematical induction can be applied it is necessary that the different cases
of the law depend upon a parameter which takes on the values 1, 2, 3,L

u The essential steps of the proof are as follows:

(1) Prove the theorem for the first case.

(2) Prove that if the theorem is true for the n th case (or for the first through
nth cases), then it is true for the ( n +1)th case.

u If there were a case for which it is not true, there must be a first case for which it is not
true. Because of (1), this is not the first case. But because of (2), it cannot be any other
case [since the previous case could not be true without the next case (known to be
false) being true; it could not be false because the next case is the false case].

u Mathematical induction is useful for proving propositions that must be true for all
integers or for a range of integers.

u Problems to which induction applies have the following form:

Prove: P( n ) for all integers n ≥ k

Principle of Mathematical Induction

Let P(n) be a proposition that is valid for n ≥ k,


n, k integers.
If (1) P(k) is true, and
(2) ∀ n ≥ k , P( n ) ⇒ P( n + 1)
then P(n) is true ∀ n ≥ k

u The statement P( n ) is called the inductive hypothesis, condition (1) is called the
base step, and condition (2) is called the induction step.

u When proving something using induction you need to be sure to check that both
condition (1) and condition (2) are satisfied.

4-8
CS218 CHAPTER 4: METHODS OF PROOFS

n
Example 17: Prove ∑ ( 2 i − 1) = n 2 is true using mathematical induction.
i =1

1
Step 1: Prove for P(1). P(1) = ∑ ( 2i − 1) = 2( 1) − 1 = 2 − 1 = 1= 12 . So we have
i =1
shown this to be true for P(1).
k
Step 2: Assume that P( k ) is true, i.e. that P( k ) = ∑ ( 2i − 1) = k 2 is true.
i =1
k+1
Prove that P( k +1), i.e. ∑ ( 2i − 1) = ( k + 1) 2 is true.
i =1

k+1 k
Proof: ∑ ( 2i − 1) = ∑ ( 2i − 1) + 2( k + 1) − 1= P( k ) + 2( k + 1) − 1
i =1 i =1

= k + 2( k + 1) − 1 = k 2 + 2k + 2 − 1 = k 2 + 2k + 1 = ( k + 1)( k + 1) = ( k + 1) 2
2

Thus P( k +1) is true. Since P( k ) is true implies P ( k +1) is true, by the


n
principle of mathematical induction, we have shown that ∑ ( 2i − 1) = n
i =1
2

n
n 2 ( n + 1) 2
Example 18: Prove that ∑ i 3 = is true using mathematical induction.
i =1 4

1
12 (1+ 1) 2 2 2 4
Step 1: Prove for P(1). P(1) = ∑ i 3 = 13 = 1 = = = = 1. So we have
i =1 4 4 4
shown this to be true for P(1)
k
k 2 ( k + 1) 2
Step 2: Assume that P( k ) is true, i.e. that P( k ) = ∑ i 3 = is true.
i =1 4
k+1 ( k + 1) 2 ( k + 1+ 1) 2
Prove that P( k +1), i.e. ∑ i = 3
is true.
i =1 4

k+1 k
k 2 ( k + 1) 2 k 2 ( k + 1) 2 4( k + 1) 3
Proof: ∑i =∑i
i =1
3

i =1
3
+ ( k + 1) 3 =
4
+ ( k + 1) 3 =
4
+
4

k 2 ( k + 1) 2 4( k + 1)( k + 1) 2 ( k + 1) 2 [k 2 + 4( k + 1)]
= + =
4 4 4

( k + 1) 2 (k 2 + 4 k + 4) ( k + 1) 2 ( k + 2)( k + 2) ( k + 1) 2 ( k + 2) 2
= = =
4 4 4

Since P( k ) is true implies P( k +1) is true, by the principle of mathematical


n
n 2 ( n + 1) 2
induction we have shown that ∑ i 3 = is true.
i =1 4

4-9
CHAPTER 4: METHODS OF PROOFS CS218

n( n + 1)
Example 19: Prove that ∀ n ≥ 1, 1+ 2 + 3 + ... + n = is true by induction.
2

n 1
1(1+ 1) 2
Step 1: Prove for P(1). Since 1+ 2 + 3 + ... + n = ∑ i; P(1) = ∑ i = 1 = = =1
i =1 i =1 2 2
So we have shown this to be true for P(1).
k
k( k + 1)
Step 2: Assume that P( k ) is true, i.e. that P( k ) = ∑ i = is true.
i =1 2
k+1 ( k + 1)( k + 2)
Prove that P( k +1), i.e. ∑ i = is true.
i =1 2
k+1 k
k( k + 1) k( k + 1) 2( k + 1)
Proof: ∑ i = ∑ i + ( k + 1) = 2
+ k + 1=
2
+
2
i =1 i =1

k 2 + k 2k + 2 k 2 + k + 2k + 2 k 2 + 3k + 2 ( k + 1)( k + 2)
= + = = =
2 2 2 2 2

n( n + 1)
So by induction 1+ 2 + 3 + ... + n = is true.
2

Example 20: Prove that n 2 > 2n + 1 for n ≥ 5 is true, using induction.

Step 1: Prove for P( 5); 5 2 > 2( 5) + 1 ⇒ 25 > 10 + 1 ⇒ 25 > 11. Which is true.

Step 2: Assume that P( k ) is true, i.e. that k 2 > 2k + 1 is true. Prove that
P( k +1), i.e. ( k + 1) 2 > 2( k + 1) + 1 = 2k + 3 is true.

Proof: ( k + 1) 2 = k 2 + 2k + 1 > 2k + 1+ 2k + 1 = 4 k + 2 > 2k + 3 for k ≥ 5

So we have proven that n 2 > 2 n + 1 is true for n ≥ 5 by induction.

Example 21: Show that ∀ n ≥ 5, 2 n > n 2 is true, using induction.

Step 1: Prove for P( 5). 2 5 > 5 2 ⇒ 32 > 25 which is true.

Step 2: Assume that P( k ) is true, i.e. that 2 k > k 2 is true. Prove that
P( k +1), i.e. 2 k+1 > ( k + 1) 2 is true.

Proof: 2 k+1 = 2 ⋅ 2 k > 2 ⋅ k 2 = k 2 + k 2 . Since k 2 > 2k + 1 for k ≥ 5, we have:

2k 2 = k 2 + k 2 > 2k + 1 and so

2 k+1 > k 2 + 2k + 1 = ( k + 1) 2 for k ≥ 5

So we have the inequality 2 n > n 2 for n ≥ 5 proven true by induction.

4 - 10
CS218 CHAPTER 4: METHODS OF PROOFS

Example 22: Use induction to prove that 1 2 n( n − 1) lines will be required in


order for n people to talk, given a person must have a direct
phone line in order to talk to someone else.

Step 1: Prove for P(1). P(1) = 12 (1)(1− 1) = 0, and since a person does not need a
phone line to talk to themselves, this is true.

Step 2: Assume that P( k ) is true, i.e. that 1 2 k( k − 1) lines are required for k
people is true. Prove that P( k +1), i.e. 1 2 ( k + 1)( k + 1− 1) = 1 2 ( k + 1)( k )
lines will be required for k +1 people.

Proof: If you add 1 person then k more lines will be needed, so P( k ) + k lines
k( k − 1) + 2k k 2 − k + 2k
will be needed. Thus 12 k( k − 1) + k = =
2 2
k + k k( k + 1) 1
2

= = = 2 k( k + 1)
2 2

So we have proven this true by induction.

4 - 11
CHAPTER 4: METHODS OF PROOFS CS218

4.3 SUMMARY

4.3.1 REMARKS
a
l S∞ = represents a geometric sequence summed to infinity.
1− r
l To express a decimal as a fraction:

1. Identify the first term a

2. Identify the common ratio r

a
3. Plug the values into the geometric sequence equation S ∞ =
1− r

4. Reduce the fraction to lowest terms.

l p →q≡~q →~ p

4.3.2 PRINCIPLE OF MATHEMATICAL INDUCTION

The Principle of
Mathematical Induction
The principle of Mathematical
Induction states that S n is true
for all positive integers n if :

1. S 1 is true, and
2. If S k is true, then S k+1 is true.

Note: Do not prove something 12 way then prove the other side to that point. This
is not a correct formal proof and is not acceptable.

4 - 12
CS218 CHAPTER 4: METHODS OF PROOFS

4.4 METHODS OF PROOFS EXERCISES

u Express the following sums more simply:


17 10 50
1. ∑ ( i − 8) 2. ∑ 25 j 3. ∑9
i =10 j= 3 k=1

10 10 50 8
4. ∑ ( 2i + 5) + ∑ ( i + 4) 5. ∑ 4( i − 30) 6. ∑ ( 5t − 3)
i=2 i=2 i = 36 t=8

u Write each of the terms in the following sums and add:


8 10 5
7. ∑ ( 5i − 2) 8. ∑i 2
9. ∑ (i 2
+ 3i)
i =1 i=4 i =1

u Write each of the following using summation notation:

10. 6 + 12 + 18 + 24 + ... + 120

11. 10 + 13 + 16 + 19 + ...

12. 4 + 16 + 36 + 64 + 100 + ... + 900 (Hint: factor out 4)

u State the inverse, the converse, and the contrapositive of each of the following:

13. Let P be a computer program. If P is correct then, P complies without


error message.

14. If n is a prime number then, n is odd.

15. If it is raining then, I will get wet.

u The Fibonacci sequence is the sequence of integers satisfying the recurrence


relation: x1 = 1, x2 = 1 and xn+2 = xn + x n+1 for n ≥ 1. Compute:

16. x3 17. x4 18. x7

u Given the recurrence relation x1 = 3, x2 = 2, x3 = 1, x n+3 = 2 ⋅ xn − xn+1 − x n+2 :

19. Find the first six terms of the sequence that satisfies the recurrence
relation.

u Find the recurrence relation connecting S n+1 to:

20. S n = 3 + 7 + 11+ 15 + 19 + ... + ( 4 n − 1)

u Define a sequence a 0 , a1 , a 2 ,K by the formula a n = 3n + 1, for all integers n ≥ 0.

21. Show that this sequence satisfies the recurrence relation a k = a k −1 + 3 for
all integers k ≥ 1

4 - 13
CHAPTER 4: METHODS OF PROOFS CS218

u Define a sequence a 0 , a1 , a 2 ,K by the formula

( − 2) 2
n
if n is even
an = ( −
2)  2  =  − (n −1) for all integers n ≥ 0
n

( 2) 2 if n is odd

22. Show that this sequence satisfies the recurrence relation a k = − 2a k − 2 for
all integers k ≥ 2

u Show the following:

23. That the sequence 0, 1, 3 , 7, K , 2 n−1 , K, for n ≥ 0, satisfies the recurrence


relation ck = 2ck −1 + 1, for all integers k ≥ 1

24. That the sequence 2, 3, 4 , 5, K , 2 + n , K, satisfies the recurrence relation


t k = 2t k −1 − t k − 2 , for all integers k ≥ 2

a(1− r n−1 )
u Given the sequence: 1, 12 , 14 , 18 ,... and the sum of the first n terms: S n = where
1− r
a is the first term and r is the ratio of the n and n −1 terms:

25. Evaluate the limit, i.e. S ∞

u Prove the following by induction:


n( n + 1)( 2n + 1)
26. 12 + 2 2 + 3 2 + ... + n 2 =
6

2n( n + 1)( 2n + 1)
27. 2 2 + 4 2 + 6 2 + ... + ( 2n ) 2 =
3

28. The number of n-bit binaries is 2 n .

1 1 1 n
29. + + ... + =
1× 2 2 × 3 n( n + 1) ( n + 1)
n
30. ∑2 i
= 2 n+1 − 1
i=0

31. 2n + 1 ≤ 3 n for all n ∈ N

32. n 3 + 2n is divisible by 3

33. 3 + 7 + 11+ ... + ( 4 n − 1) = n( 2n + 1)

34. n(n 2 + 5) is divisible by 6

35. x n −1 is divisible by x−1 for n ≥ 1

36. 1+ 2 + 4 + ... + 2n = 2 − 2n
1 1 1 1

u Give a direct proof for each of the following:

37. If n 2 is an even integer then n is an even integer

38. If n and m are even integers, then n + m is an even integer

39. If n and m are even integers, then n − m is an even integer

4 - 14
CS218 CHAPTER 4: METHODS OF PROOFS

u Give a contrapositive proof for each of the following:

40. If n 2 is not divisible 25 then n is not divisible by 5

41. If n 2 is an odd integer then n is an odd integer

42. If n and m are even integers, then n + m is an even integer

43. If n and m are even integers, then n − m is an even integer

44. If x > 1, then either x > 1 or x < − 1 for x ∈ R

u Give a proof by contradiction for each of the following:

45. If n and m are odd integers, then n + m is an even integer

46. If n is an even integer and m is an odd integer, then n + m is an odd


integer

u Find a counterexample to show that the following are false:

47. If x = p 2 + 1, where p is a positive integer, then x is a prime number.

48. The sum of two prime numbers is never a prime number.

u Express the following as fractions in lowest terms:

49. 0. 13 50. 0.507507...

4 - 15
CHAPTER 5: COMBINATORICS

Chapter Objectives

In this chapter you will learn:

§ about the fundamentals of counting;

§ what the sum rule is;

§ what the product rule is;

§ about factorials;

§ the formula for permutations;

§ the formula for permutations with repetition;

§ the formula for combinations;

§ the formula for combinations with repetitions;

§ how and when to use the counting formulas;

§ about patterns and partitions;

5-1
CHAP TER 5: COM BI NA TOR ICS CS218

5.1 BASIC COUNTING RULES

u Combinatorial analysis, or combinatorics, which includes the study of


permutations, combinations, and partitions, is concerned with determining the
number of logical possibilities of some event without necessarily enumerating
(listing out all the possibilities) each case.

5.1.1 THE SUM RULE

u SUM RULE: If one experiment has m possible outcomes and another experiment
has n possible outcomes, then there are m + n possible outcomes when exactly one of
these experiments takes place.

l Remark 1: Sum rule: The general form of the sum rule is: If one event can
occur in n 1 ways, a second event can occur in n 2
(different) ways, a third event can occur in n 3 (still
different) ways, . . ., then there are n1 + n 2 + n 3 + ...
ways in which (exactly) one of the events can occur.

Example 1: If there are 52 ways to select a representative for the MA214 class and
49 ways to select a representative for the QT211 class, then according
to the rule of sum there are 52 + 49 ways to select a representative for
either the MA214 class or the QT211 class.

Example 2: Suppose there are seven different courses offered in the morning and
five different courses offered in the afternoon. There will be
7 + 5 choices for a student that wants to enrol in only one course.

5.1.2 THE PROD UCT RULE

u PRODUCT RULE: If one experiment has m possible outcomes and another


experiment has n possible outcomes, then there are m × n possible outcomes when
both of these experiments take place.

l Remark 2: Product rule: The general form of the product rule is: If
something can happen in n1 ways, and no matter
how the first thing happens, a second thing can
happen in n 2 ways, and no matter how the first
two things happen, a third thing can happen in n 3
ways, and. . ., then all the things together can
happen in n 1 × n 2 × n 3 × ... ways.

Example 3: If there are 52 ways to select a representative for the MA214 class and
49 ways to select a representative for the QT211 class, then according
to the rule of product there will be 52 × 49 ways to select a
representative for both the MA214 class and QT211 class.

Example 4: Suppose there are seven different courses offered in the morning and
five different courses offered in the afternoon. There will be 7 × 5
choices for students who want to enrol in one course in the morning
and one in the afternoon.

5-2
MA214 CHAP TER 5: COMBINATORICS

Example 5: A variable name in the programming language D++ must be


either a letter or a letter followed by a digit. How many different
++
variable names are possible in D ?

First we consider variable names one character in length. Since such names
must consist of a single letter, there is only one event, the selection of the
letter. The event can happen in 26 ways. Hence there are 26 variable names of
length 1

Next we consider variable names two characters in length. Here there are two
events. Event 1 is the selection of the letter, event 2 is the selection of the digit.
The first event can happen in 26 ways, and the second event can happen in 10
ways, or n1 = 26 and n 2 = 10, so there must be 26 ⋅ 10, or 260, ways to construct
variable names two characters in length. Hence, there are 26 + 260, or 286,
possible variable names in D++

Example 6: A calculator can display integers up to eight digits in length.


However leading zeros are not allowed. How many distinct numbers
can the calculator display?
There are 10 distinct numbers with only one digit; 90 with two digits; 900
with three digits, . . ., 90,000,000 with eight digits.

Hence there are (10 + 90 + 900 + 9000 + 90000 + 900000 + 90000000 +


900000000) = 100,000,000 distinct numbers. This is however only the positive
(or negative) numbers, multiplying by 2 gives will give us both the positive and
negative numbers, so 100,000,000 × 2 = 200,000,000, and since we have again
included 0 as + 0 and as − 0, we have to subtract 1 giving us a final answer of
199,999,999 distinct numbers that the calculator can display.

5.2 FACTORIAL NOTATION


u One uses the notation n !, read “n factorial,” to denote the product of the positive
integers from 1 to n, inclusive: n ! = 1⋅ 2 ⋅ 3 ⋅ ... ⋅ ( n − 2)( n − 1)n

l Remark 3: 0 != 1 1!= 1 and n ! = n ⋅ ( n −1) !

Example 7: 2 != 2 ⋅ 1 = 2 3 != 1⋅ 2 ⋅ 3 = 6 4 != 1⋅ 2 ⋅ 3 ⋅ 4 = 24

8! 8⋅ 7⋅ 6! 12 ⋅ 11⋅ 10 ⋅ 9 ! 12 !
Example 8: = = 8 ⋅ 7 = 56 12 ⋅ 11⋅ 10 = =
6! 6! 9! 9!

5.3 COUNTING FORMULAS

u When selecting elements from a given set, one can allow the list to contain
repetitions, or one can insist that the list not contain repetitions. One can also insist
that the order in which you select the elements matters or does not matter.

Order matters Order doesn’t matter


Elements repeated k-sample k-selection
Elements not repeated k-permutation k-combination

5-3
CHAP TER 5: COM BI NA TOR ICS CS218

5.3.1 k-SAMPLES

u With a k-sample order of the elements matters and elements can be repeated. The
formula for a k-sample is n k , where k is the number of samples you select from the set
of n elements.

Example 9: A computer represents integers with n-binary digits, using one bit
(binary digit) to indicate the sign and the remaining n −1 bits to
represent the magnitude of the integer. This is called sign-
magnitude representation of integers. How many distinct integers
can be represented in this notation?
There are n slots to fill, and each slot can be filled in two different ways.
Hence, there are 2 n distinct patterns. However, 0 is represented as + 0 and as

0, so there are 2 n − 1 distinct integers that can be represented using n bits in
the sign-magnitude representation.
Example 10: A number consists of 5 digits such that the sum of the first and last
digits must be even. Repetition of digits is allowed; however, the
number cannot consist of all zeros. How many different numbers
are there?
There are two ways for the sum of the first and last digits to be even: when you
add two odd numbers together, and when you add two even numbers together.
Note that there are 5 digits that are odd, 1, 3, 5, 7, and 9, and 5 that are even,
0, 2, 4, 6, and 8.
Case 1: First and last digits odd, gives us 5 ⋅ 10 ⋅ 10 ⋅ 10 ⋅ 5, which is 25000
numbers.
Case 2: First and last digits even, gives us 5 ⋅ 10 ⋅ 10 ⋅ 10 ⋅ 5 = 25000 choices
also; however, 1 choice is all 0’s which is not allowed giving us a
final answer of 25000 + 25000 − 1 = 49999 numbers.

5.3.2 k-PERMUTATIONS

u With a k-permutation the order of the elements matters, but repetition of the
elements is not allowed. The formula for a k-permutation is P( n , k ) =
n!
, where
( n − k)!
k≤n

l Remark 4: k-permutations can be written as n Pk , n Pk , or as P( n , k )

Example 11: Find the number of “words” with four distinct letters that can be
made from the letters c, a , b , i, n , e, t.

Here n = 7, and k = 4.

The number of words selected is

7! 7⋅ 6⋅ 5⋅ 4 ⋅ 3⋅ 2⋅ 1
P( 7, 4 ) = = = 7 ⋅ 6 ⋅ 5 ⋅ 4 = 840
3! 3⋅ 2⋅ 1

5-4
CS218 CHAP TER 5: COMBINATORICS

Example 12: A number consists of 5 digits such that the sum of the first and
last digits must be even. Repetition of digits is not allowed. How
many different numbers are there?

This problem is similar to that of example 10; however in this case repetition of
the digits is not allowed, which means that we have 5 ⋅ 8 ⋅ 7 ⋅ 6 ⋅ 4 possible
numbers. Since there are again two cases which are exactly the same, we have
2 ⋅ 5 ⋅ 8 ⋅ 7 ⋅ 6 ⋅ 4 = 13440 numbers. This can also be expressed as 2 ⋅ P( 5 , 2) ⋅ P( 8, 3)
5! 8!
= 2⋅ ⋅ = 13440 numbers.
3! 5!

5.3.3 k-COMBINATIONS

u With a k-combination the order in which the elements are selected does not matter
and the elements cannot repeat. The formula for a k-combination is
C( n , k ) =
n!
( n − k ) !k !

 n
l Remark 5: k-combinations can be written as n C k , n C k ,  , or as C( n , k )
k

Example 13: A menu in a Chinese restaurant allows you to order exactly two of
eight main dishes as part of the dinner special. How many different
combinations of main dishes could you order?

There are 8 C 2 combinations of the eight main dishes taken two at a time.
8! 8⋅ 7
Thus, you could choose one of 8 C 2 = = = 28 different combinations.
6! 2! 2

Example 14: A group consists of seven men and five women. Find the number m
of committees of five that can be selected from the group.

Each committee is a combination of the twelve people taken five at a time.


12 ! 12 ⋅ 11⋅ 10 ⋅ 9 ⋅ 8
Thus m = 12C 5 = = = 792 committees.
5! 7! 5⋅ 4 ⋅ 3⋅ 2

Example 15: Suppose in forming a committee from seven men and five women,
that the committee m of 5 members is to consist of three men and
two women. How many committees can be formed?

In this case the three men can be chosen from the seven men in 7 C 3 ways, and
the two women can be chosen from the five women in 5 C 2 ways. Hence
 7  5 7! 5! 7⋅ 6⋅ 5⋅ 5⋅ 4
m=     = = = 350 committees.
 3  2 3 ! 4 ! 2 ! 3 ! 3⋅ 2⋅ 2

Example 16: Suppose in forming a committee from seven men and five women,
that the committee m, of 5 members, must consist of at least one
man and at least one woman. How many committees can be
formed?

Using the result from example 14, there are 12 C 5 = 792 possible committees.
Among these committees, there is 5 C 5 = 1 committee consisting of the five
women, and 7 C 5 = 21 consisting of five men. These committees are not allowed
so eliminating them from the possible committees yields m = 792 − 21− 1 = 770
committees.

5-5
CHAP TER 5: COM BI NA TOR ICS CS218

5.3.4 k-SELECTIONS

u k-selections is similar to k-combinations in that the order in which you select the
elements does not matter, but in this case repetitions can occur. The formula for a
k-selection is n+k −1C k ∀ n , k ≥ 1

l Remark 6: k-selections are also called combinations with repetitions.


n+k −1
Example 17: Compute C k with n = 4, and k = 3

4+3−1
6! 6⋅ 5⋅ 4
C 3 = 6C 3 = = = 20
3! 3! 3⋅ 2

Example 18: Four dice are to be tossed. How many different outcomes are
possible if the order does not matter?

If the first die shows 4 and the rest of the dice show 2, it is the same outcome
as if the first three dice show 2 and the last one shows 4. Hence, order does not
matter. But since all dice could show the same value, repetitions are allowed.
Thus the outcomes are the 4-selections from the set {1, 2, 3, 4 , 5, 6}, and there are

6+4 −1 9! 9⋅ 8⋅ 7⋅ 6
C4 = 9
C4 = = = 126 possible outcomes.
4 ! 5! 4 ⋅ 3⋅ 2

Example 19: How many ways are there to choose 8 coins from a pile containing
100 identical pennies and 80 identical nickels?

Since the coins are identical the order in which the coins are selected does not
matter. Further since all pennies and all nickels have the same value repetition
is allowed. So we have 8-selections not from 100 + 80 = 180 coins, but from the
two different types of coins, i.e. a penny and a nickel. So we have 2+8 −1C 8 = 9 C 8
9!
= = 9 ways.
1! 8 !

Example 20: A hockey team has ten players who want to play in the front line.
How many 3-player lines can be formed if a player can be in more
than one line?

Here the order in which the players are selected does not matter, and
repetition of the players can also occur, since it is possible for a player to be in
more than one line. So we have 3-selections of players from 10, which is 10+3−1C 3
12 ! 12 ⋅ 11⋅ 10
= 12C 3 = = = 220 ways.
9! 3! 3⋅ 2

5.4 PIGEONHOLE PRINCIPLE

u Many results in combinatorial theory come from the following almost obvious
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.

Generalized 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.

5-6
CS218 CHAP TER 5: COMBINATORICS

Example 21: Find the minimum 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 or k = 2. Hence among


any kn + 1 = 25 students (pigeons), three of them are born in the same month.

Example 22: Suppose a laundrybag contains many red, white, and blue socks.
Find the minimum number of socks that one needs to choose in
order to get two pairs (four socks) of the same colour.

Here there are n = 3 colours (pigeonholes) and k + 1 = 4 or k = 3. Thus among any


kn + 1 = 10 socks (pigeons), four of them have the same colour.

5.5 THE INCLUSIONEXCLUSION PRINCIPLE

u Let A and B be any finite sets. Then | A ∪ B | = | A | + | B | − | A ∩ B |. This principle holds


for any number of sets. The following theorem states the principle for three sets.

Theorem 3: For any finite set A, B, and C we have

| A ∪ B ∪ C | = | A | + | B | + |C | − | A ∩ B | − | A ∩ C | − | B ∩ C | − | A ∩ B ∩ C |

Example 23: Find the number of mathematics students at a university taking at


least one of the languages Mandarin, English, and Japanese given
the following data:
65 study Mandarin 20 study Mandarin and English
45 study English 25 study Mandarin and Japanese
42 study Japanese 8 study all three languages

We want to find | M ∪ E ∪ J | where M, E, and J denote the sets of students


studying Mandarin, English, and Japanese respectively. By the
inclusionexclusion principle,

| M ∪ E ∪ J | = | M | + | E| + | J | − | M ∩ E| − | M ∩ J | − | E ∩ J | +
| M ∩ E ∩ J | = 65 + 45 + 42 − 20 − 25 − 15 + 8 = 100

Thus 100 students study at least one of the languages.

5.6 PARTITIONS

5.6.1 ORDERED PARTITIONS

Theorem 4: Let A contain n elements and let n1 , n 2 ,K , n r be positive integers


whose sum is n, that is, n1 + n 2 +L+ n r = n. Then there exist
n!
n 1 ! n 2 ! n 3 !L n r !
different ordered partitions of A of the form [ A1 , A 2 ,K , A r ] where A1
contains n1 elements, A 2 contains n 2 elements, . . ., and A r contains n r
elements.

5-7
CHAP TER 5: COM BI NA TOR ICS CS218

Example 24: Find the number m of ways that nine toys can be divided between
four children if the youngest child is to receive three toys and each
of the others two toys.

We wish to find the number m of ordered partitions of the nine toys into four
cells containing 3, 2, 2, 2 toys respectively. By Theorem 4,

9!
m= = 7560
3! 2! 2! 2!

Example 25: A puzzle has three squares, two triangles, and four circles. How
many patterns can be formed by laying these nine shapes out in a
row?

Using Theorem 4, the pieces can be arranged into

9! 9⋅ 8⋅ 7⋅ 6⋅ 5
= = 1260 ways.
3! 2! 4 ! 3⋅ 2⋅ 2

5.6.2 PER MU TA TIONS WITH REPE TI TIONS

u Permutations with repetition, or a set of elements in which some of the elements


are alike can be expressed as :

n!
P ( n; n 1 , n 2 ,K , n r ) = where P ( n; n 1 , n 2 ,K , n r ) denotes the
n 1 ! n 2 ! n 3 !L n r !
number of permutations of n objects of which n1 are alike, n 2 are alike, . . ., n r
are alike.

Example 26: Find the number of all possible five-letter “words” using the letters
from the word “apple”.

What we have is five letters in which two of them repeat, so this is a type of
5!
problem involving a permutation with repetition, or = 5 ⋅ 4 ⋅ 3 = 60 ways.
2!

Example 27: How many different signals, each consisting of six flags hung in a
vertical line, can be formed from four identical red flags and two
identical blue flags?

This problem again involves permutations with repetitions. There are


6! 6⋅ 5
= = 15 signals.
4 ! 2! 2

5.6.3 UN OR DERED PARTITONS

u In each example from section 5.6.1 the order in which we placed the items made a
difference, i.e. order mattered. There are times when you will want to partition a set
A into a collection of subsets A1 , A 2 ,K , A r where the subsets are now unordered;
where the order in which the sets are placed does not make a difference.

u This type of problem can be solved in two ways, as you will see in the next example.

5-8
CS218 CHAP TER 5: COMBINATORICS

Example 28: Find the number m of ways that 12 students can be partitioned into
three teams, A1 , A 2 , and A 3 , so that each team contains four
students.
11
Method 1: Let A denote one of the students. Then there are   ways to
 3
choose three other students to be on the same team as A. Now let
B denote a student who is not on the same team as A; then there
 7
are   ways to choose three students of the remaining students to
 3
be on the same team as B. The remaining four students constitute
the third team. Thus, altogether, the number of ways to partition
the students is

11  7
m =   ⋅   = 165 ⋅ 35 = 5775
 3   3

Method 2: Observe that each partition {A1 , A 2 , A 3 } of the students can be


arranged in 3 != 6 ways as an ordered partition. Using Theorem 4
12 !
there are = 34 ,650 such ordered partitions. Thus there are
4 !4 !4 !
m = 34650 / 6 = 5775 (unordered) partitions.

5.6.4 NUMBER OF PARTITIONS

u We also need a way to count the number of partitions that can be formed from a given
set, however, there is no simple closed form expression for this, but there is a simple
recurrence relation that express it.

Theorem 5: The number of ways to partition a set with n elements into k


blocks is given by S ( n , k ), where S ( n , k ) satisfies the following
recurrence relation:

1. S ( n, 1) = 1 and S (n , n) = 1, for all n ≥ 1

2. S ( n + 1, k + 1) = ( k + 1)S ( n , k + 1) + S ( n , k ), for n ≥ 1 and 1≤ k ≤ n

Exercise 29: In how many ways can a set with five elements be partitioned into
three blocks?

We use theorem 5 and write S ( 5, 3) = 3S ( 4 , 3) + S ( 4 , 2)

Now we have to apply theorem 3 again to obtain

S ( 4 , 3) = 3S ( 3, 3 ) + S ( 3, 2) S ( 4 , 2) = 2S ( 3, 2) + S ( 3, 1)
S ( 3, 2) = 2S ( 2, 2 ) + S ( 2, 1) S ( 2, 1) = S ( 3, 1) = 1
S ( 3, 3) = 1 S ( 2, 2) = 1

Putting these values in and moving back up the equations, we get

S ( 3, 2) = 2 + 1 = 3 S ( 4 , 2) = 2 ⋅ 3 + 1 = 7 S ( 4 , 3) = 3 + 3 = 6

Finally, S ( 5, 3) = 3 ⋅ 6 + 7 = 25

5-9
CHAP TER 5: COM BI NA TOR ICS CS218

5.7 SUMMARY

5.7.1 FORMULAS

u Factorial: n != n ⋅ ( n − 1) ⋅ ( n − 2) ⋅K⋅ 2 ⋅ 1

n!
u Permutations: P(n , r) = ( = n( n − 1)( n − 2)K( n − r + 1), where n is the number of
n − r) !
objects and r is the number selected.

n!
u Permutations with Repetitions: where you have n objects of which n1
n 1 ! n 2 !K n r !
are alike, n 2 are alike, . . ., n r are alike.

P( n , r) n!  n
u Combinations: n C r = = =  , where n is the number of objects taken
r! r !( n − r) !  r 
r at a time.

u Combinations with repetitions: n+r −1C r , where n is the number of elements and r
is number of selections.

u Number of Partitions: The number of ways to partition a set with n elements into
k blocks is given by S ( n , k ), where S ( n , k ) satisfies the following recurrence relation:

1. S ( n, 1) = 1 and S (n , n) = 1, for all n ≥ 1

2. S ( n + 1, k + 1) = ( k + 1)S ( n , k + 1) + S ( n , k ), for n ≥ 1 and 1≤ k ≤ n

5.7.2 THEOREMS

l 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.

l Generalized 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.
l For any finite set A, B, and C we have

| A ∪ B ∪ C | = | A | + | B | + |C | − | A ∩ B | − | A ∩ C | − | B ∩ C | − | A ∩ B ∩ C |

l Suppose there are n objects, of which n 1 objects are of type 1, n 2 objects are of type
n!
2, and so on, up to n r objects of type r. Then there are distinct
( n1 !)( n2 !)K( nr !)
patterns that can be formed with the n objects. Moreover, each pattern appears
exactly ( n 1 !)( n 2 !)K( n r !) times among the n ! permutations.

l The number of ways to partition a set with n elements into k blocks is given by
S ( n , k ), where S ( n , k ) satisfies the following recurrence relation:

1. S ( n, 1) = 1 and S (n , n) = 1, for all n ≥ 1

2. S ( n + 1, k + 1) = ( k + 1)S ( n , k + 1) + S ( n , k ), for n ≥ 1 and 1≤ k ≤ n

5-10
CS218 CHAP TER 5: COMBINATORICS

5.7.3 REMARKS

l Sum rule: If one event can occur in n1 ways, a second event can occur in n 2
(different) ways, a third event can occur in n 3 (still different)
ways, . . ., then there are n 1 + n 2 + n 3 + ... ways in which (exactly)
one of the events can occur.
l Product rule: If something can happen in n 1 ways, and no matter how the
first thing happens, a second thing can happen in n 2 ways,
and no matter how the first two things happen, a third thing
can happen in n 3 ways, and. . ., then all the things together
can happen in n1 × n 2 × n 3 × ... ways.
l 0 != 1 1!= 1 and n ! = n ⋅ ( n −1) !
l k-permutations can be written as n Pk , n Pk , or as P( n , k )

 n
l k-combinations can be written as n C k , n C k ,   or as C( n , k )
k

l k-selections are also called combinations with repetitions.

5.7.4 TABLE

Order matters Order doesn’t matter


n+k −1
Elements repeated nk Ck

C ( n, k ) =
n!
Elements not repeated P( n , k ) = (
n!
n − k )! ( n − k ) !k !

5-11
CHAP TER 5: COMBINATORICS CS218

5.8 COMBINATORICS EXERCISES

u Compute.

 7
1. P( 20, 17) 2. C(13, 9) 3.   4. 7
P5 5. 7+5−1
C5 6. S ( 6, 4 )
 5

u Let S = {1, 2, 3, 4}, using the correct formula find the number of:

7. 2-samples

8. 2-selections

9. 2-permutations

10. 2-combinations

u Permutations

11. There are four bus lines between A and B; and three bus lines between B
and C. In how many ways can a man travel

(a) by bus from A to C by way of B?


(b) round-trip by bus from A to C by way of B?
(c) round-trip by bus from A to C by way of B, if he does not want to
use a bus line more than once?

12. Suppose repetitions are not permitted.


(a) how many three-digit numbers can be formed from the six digits 2,
3, 5, 6, 7, and 9?
(b) How many of these numbers are less than 400?
(c) How many are even?

13. Find the number of ways that a party of seven persons can arrange
themselves:
(a) in a row of seven chairs
(b) around a circular table

14. Find the number of distinct permutations that can be formed from the
letters of the following words:
(a) RADAR
(b) UNUSUAL
(c) MISSISSIPPI
(d) COMPILER
(e) DISCRETE

15. In how many ways can four mathematics books, three history books,
three chemistry books, and two sociology books be arranged on a shelf so
that all books of the same subject are together?

5-12
CS218 CHAP TER 5: COMBINATORICS

16. Find n if:


(a) P ( n , 2 ) = 72
(b) P ( n , 4 ) = 42P ( n , 2 )
(c) 2P ( n , 2 ) + 50 = P ( 2n , 2 )

u Combinations

17. In how many ways can a committee consisting of three men and two
women be chosen from seven men and five women?

18. A bag contains six white marbles and five red marbles. Find the number
of ways four marbles can be drawn from the bag if
(a) they can be any colour
(b) two must be white and two red
(c) they must all be of the same colour

19. How many committees of five with a given chairperson can be selected
from 12 persons?

u Ordered and Unordered Partitions

20. In how many ways can nine students be partitioned into three teams
containing four, three, and two students, respectively?

21. There are 12 students in a class. In how many ways can the 12 students
take four different tests if three students are to take each test?

22. In how many ways can 12 students be partitioned into four teams,
A1 , A 2 , A 3 , and A 4 , so that each team contains three students.

u The Pigeonhole Principle

23. Assume there are n distinct pairs of shoes in a closet. Show that if you
choose n +1 single shoes at random from the closet, you are certain to have
a pair.

24. Assume there are three men and five women at a party. Show that if
these people are lined up in a row, at least two women will be next to each
other.

25. Find the minimum number of students needed to guarantee that five of
them belong to the same class (sec1, sec2, sec3, sec4).

26. Let L be a list (not necessarily in alphabetical order) of the 26 letters in


the English alphabet (which consists of 5 vowels, A, E, I, O, U, and 21
consonants).
(a) Show that L has a sublist consisting of four or more consecutive
consonants.
(b) Assuming L begins with a vowel, say A, show that L has a sublist
consisting of five or more consecutive consonants.

5-13
CHAP TER 5: COMBINATORICS CS218

27. Find the minimum number n of integers to be selected from S = {1, 2,K , 9}
so that:
(a) the sum of two of the n integers is even
(b) the difference of two of the n integers is 5

u The Inclusion-Exclusion Principle

28. There are 22 female students and 18 male students in a classroom. How
many students are there in total?

29. Of 32 people who save paper or bottles (or both) for recycling, 30 save
paper and 14 save bottles. Find the number m of people who
(a) save both
(b) save only paper
(c) save only bottles

30. Find the number N of students in a centre given the data:

12 take AP207, 5 take AP207, CS202, 3 take AP207, CS202, MA214,


20 take CS202, 7 take AP207, MA214, 2 take AP207, CS202, SA205,
20 take MA214, 4 take AP207, SA205, 2 take CS202, MA214, SA205,
8 take SA205, 16 take CS202, MA214, 3 take AP207, MA214, SA205,
4 take CS202, SA205, 2 take all four
3 take MA214, SA205, 71take none.

u Miscellaneous Problems

31. A student must take five classes from three areas of study. Numerous
classes are offered in each discipline, but the student cannot take more
than two classes in any given area.
(a) Using the pigeonhole principle, show that the student will take at
least two classes in one area.
(b) Using the inclusion-exclusion principle, show that the student will
have to take at least one class in each area.

32. How many different 7-card hands can be drawn from a standard 52-card
deck?

33. How many different 3-note sequences can be formed from an 8-note
scale?

34. A hockey team has ten players who want to play in the front line. How
many distinct 3-player lines can be formed?

35. A certain software package has three main modules. To configure the
package, users must choose among options given for each module. If the
first module has four options, the second five options, and the third
three options, how many different sets of options are supported?

36. How many distinct 5-card poker hands are there?

37. Are there more 4-samples or more 4-selections from a set with six
elements?

5-14
CS218 CHAP TER 5: COMBINATORICS

38. A salesperson is to visit eight different cities exactly once. In how many
different ways can this be done?

39. Three exams are to be scheduled during a four-day period, with at most
one exam per day. In how many ways can this be accomplished?

40. Find the number of patterns that can be formed by permuting the
letters of the word reentrant?

41. How many ways can a set with three elements be partitioned?

42. There are four groups of students of size 5, 8, 4, and 6. A team of 10


students is selected such that there are at least two students from each
group. How many different teams can be formed?

43. A committee of three has to elected from a group of 9 people. This group
consists of 5 men and 4 women. How many different committees can be
can be formed?

44. A committee consists of a chairperson and 3 members. Given that the


chairperson must be a man and no more than 2 members are male, how
many ways can a committee be formed from 4 men and 3 women?

45. A committee consists of a chairperson, a vice chairperson, a secretary, a


treasurer and a member. If the chairperson is male then the vice
chairperson will be female and vice versa. The secretary must be
female. In how many ways can the committee be formed if there are
four males and four females?

46. A box contains eight black balls and six white balls. In how many ways
can four balls be chosen so that:
(a) exactly two black balls are chosen.
(b) at least three black balls are chosen.
(c) at least one white ball is chosen.

47. A box contains nine red balls and eight blue balls and seven white balls.
In how many ways can you draw three balls given:
(a) that the three balls are all the same colour.
(b) that you replace the balls after drawing them and all the balls are
the same colour?
(c) that all three balls are a different colour?
(d) that you replace the balls after drawing them and that all the balls
are a different colour?

48. Three officers, a president, a secretary and a treasurer are to be chosen


from among four people: Alan, Brian, Cindy, and Dan. Suppose that Brian
cannot be treasurer, and Cindy cannot be secretary. How many ways can
the officers be chosen?

49. A sample of 80 car owners revealed that 24 owned station wagons and 62
owned cars which are not station wagons. Find the number k of people
who owned both a station wagon and some other car.

5-15
CHAP TER 5: COMBINATORICS CS218

50. An examination paper consists of 3 questions in section A and 5 questions


in section B. A total of 5 questions must be answered. In how many ways
can you select the questions if:

(a) you can choose any number of questions from section A or B?


(b) you are to answer not more than 2 questions from section A?
(c) you must answer 2 questions from section A.

51. Suppose 12 people read the Wall Street Journal (W) or Business Week (B)
or both. Given three people read only the Journal and six read both, find
the number k of people who read only Business Week .

52. Show that any set of seven distinct integers insludes two integers, x and y,
such that either x + y or x − y is divisible by 10.

53. Consider a tournament in which each of n players plays against every


player and each player wins at least once. Show that there are at least two
players having the same number of wins.

54. Suppose that there are 8 runners in a race. The awards given are gold for
the winner, silver for the person who comes second, and bronze for the
person who comes third. How many different ways are there to award
these medals if all possible outcomes of the race can occur?

55. Given a bit-string of length 10:


a) How many possible bit-strings begin wiht three 0’s?
b) How many possible bit-strings end with two 0’s?
c) How many possible bit-strings begin wiht three 0’s and end with
two 0’s?
d) How many possible bit-strings either begin with three 0’s or end
with two 0’s?

56. How many 6-digit postal codes are there if the first two digits and the last
three digits cannot be 0?

57. A box contains eight black balls and six white balls. In how many ways
can four balls be chosen so that:
a) exactly two black balls are chosen?
b) at least three black balls are chosen?
c) at most one white ball is chosen?

58. A multiple choice test contains 10 questions; there are 4 possible answers
for each question.
a) How many ways can a student answer the questions on the test if
every question is answered?
b) How many ways can a student answer the questions on the test if
the students can leave answers blank?

59. A palindrome is a string whose reversal is identical to the string. How


many different bit strings of length n are palindromes?

5-16
CS218 CHAP TER 5: COMBINATORICS

60. How many bit strings contain exactly eight 0’s and ten 1’s if every 0 must
be followed immediately by a 1?

61. Suppose that a department contains 10 men and 15 women. How many
ways are there to form a committee with 6 members if it must have the
same number of men and women?

5-17
CHAPTER 6: PROBABILITY

Chapter Objectives

In this chapter, you will be learn:

§ what sample spaces and events are;

§ what makes an event mutually exclusive;

§ some probability properties;

§ what probability is;

§ how to find the probability of some event;

§ how to find the probability of an event given another event has occurred;

§ about the multiplication theorem for probability;

§ what a stochastic process is;

§ how to use a tree diagram;

§ what makes an event independent;

§ what repeated trials are;

§ what a random variable is;

§ about distributions and expected values;

§ how to determine variance and standard deviation;

§ about Binomial distributions;

6-1
CHAPTER 6: PROBABILITY CS218

6.1 INTRODUCTION TO PROBABILITY

u Probability is the study of random or non-deterministic experiments. It is usually


associated with games of chance.

6.1.1 SAM PLE SPACES AND EVENTS

u The set S of all possible outcomes of some given experiment is called the sample
space.

u A particular outcome, i.e., an element in S, is called a sample point.

u An event A is a set of outcomes or, in other words, a subset of the sample space S.

u The event {a} consisting of a single sample a ∈ S is called an elementary event.

u The empty set ∅ and S itself are events; ∅ is called the impossible event, and S the
certain or sure event.

u Since an event is a set, we can combine events to form new events using the various
set operations:

(i) A ∪ B is the event that occurs if A occurs or B occurs (or both);

(ii) A ∩ B is the event that occurs if A occurs and B occurs;

(iii) A c , the complement of A is the event that occurs if A does not occur.

u Two events A and B are called mutually exclusive if they are disjoint, i.e. if
A ∩ B = ∅. In other words, A and B are mutually exclusive if they cannot occur
simultaneously.

Example 1: Toss a die and observe the number that appears on top.

The sample space S consists of the six possible numbers; that is, S = {1, 2, 3, 4 , 5, 6}

Let A be the event that an even number occurs, B that an odd number occurs,
and C that a prime number occurs; that is, let

A = {2, 4 , 6} B = {1, 3, 5} C = {2, 3, 5}


Then
A ∪ C = {2, 3, 4 , 5, 6} is the event that an even or a prime number occurs.
B ∩ C = {3, 5} is the event that an odd prime number occurs.
C c = {1, 4 , 6} is the event that a prime number does not occur.

Note that A and B are mutually exclusive: A ∩ B = ∅. In other words, an even


number and an odd number cannot occur simultaneously.

l Remark 1: The probability of an event can be thought of as “a favourable


favorable
outcome” over “all possible outcomes,” i.e.
total

6-2
CS218 CHAPTER 6: PROBABILITY

6.1.2 THE OREMS OF PROB ABIL ITY

l Theorem 1: Let S be a sample space, let E be the class of events, and let P
be a real-valued function defined on E. Then P is called a
probability function, and P( A ) is called the probability
of the event A if the following axioms hold:
[P1 ] For every event A , 0 ≤ P( A ) ≤ 1

[P2 ] P( S ) = 1

[P3 ] If A and B are mutually exclusive events, then


P( A ∪ B ) = P( A ) + P( B )
[P4 ] If A1 , A 2 ,K is a sequence of mutually exclusive events,
then P ( A1 ∪ A 2 ∪ K ) = P ( A1 ) + P ( A 2 ) + K

l Theorem 2: If ∅ is the empty set, then P( ∅) = 0


l Theorem 3: If A c is the complement of an event A, then P ( A c ) = 1− P ( A )

l Theorem 4: If A ⊆ B, then P( A ) ≤ P ( B )

l Theorem 5: If A and B are any two events, then P ( A \ B ) = P( A ) − P( A ∩ B )


l Theorem 6: If A and B are any two events, then
P( A ∪ B ) = P( A ) + P( B ) − P( A ∩ B )

6.2 TYPES OF SAMPLE SPACES

6.2.1 FINITE PROB ABIL ITY SPACES

u Let S be a finite sample space; say, S = {a 1 , a 2 ,K , a n}. A finite probability space is


obtained by assigning to each point a i ∈ S a real number p i , called the probability of
a i , satisfying the following properties:

(i) each p i is nonnegative, p i ≥ 0


(ii) the sum of the p i is one, p i + p 2 + K + p n = 1
The probability P( A ) of any event A, is then defined to be the sum of the
probabilities of the points in A

Example 2: Three horses A, B, and C are in a race; A is twice as likely to win as B


and B is twice as likely to win as C. What are their respective
probabilities of winning, i.e. P( A ), P( B ), and P(C )?
Let P(C ) = p; since B is twice as likely to win as C, P( B ) = 2 p; and since
A is twice as likely to win as B, P( A ) = 2P( B ) = 2( 2 p ) = 4 p. Now the sum
of the probabilities must be 1; hence p + 2 p + 4 p = 1 or 7 p = 1 or p = 17
Accordingly, P( A ) = 4 p = 47 , P( B ) = 2 p = 27, P(C ) = p = 17

Example 3: What is the probability that horse B or C wins from example 2?

By definition P ( B ∪ C ) = P ( B ) + P (C ) − P ( B ∩ C ) = 27 + 17 − 0 = 37

6-3
CHAPTER 6: PROBABILITY CS218

6.2.2 FINITE EQUI PROB ABLE SPACES

u Frequently, the physical characteristics of an experiment suggest that the various


outcomes of the sample space be assigned equal probabilities. Such a finite
probability space S, where each sample point has the same probability, will be called
an equiprobable or uniform space. In particular, if S contains n points then the
probability of each point is 1 n. Furthermore, if an event A contains r points then its
probability is r ⋅ n = n. In other words,
1 r

number of elements in A
P( A ) =
number of elements in S
or
number of ways that the event A can occur
P( A ) =
number of ways that the sample space S can occur

u It must be emphasized that the above formula for P( A ) can only be used with respect
to an equiprobable space, i.e. that each sample point in S must have the same
probability.

u The expression “ at random” will be used only with respect to an equiprobable space;
formally the statement “choose a point at random from a set S” shall mean that S is
an equiprobable space, i.e. that each sample point in S has the same probability.

Example 4: Let a card be selected at random from an ordinary pack of 52 cards.


Let A = {the card is a spade} and B = {the card is a face card}. What is
P( A ), P( B ) and P( A ∩ B )?

Since we have an equiprobable space,

number of spades 13 1
P( A ) = = =
number of cards 52 4

number of face cards 12 3


P( B ) = = =
number of cards 52 13

number of spade face cards 3


P( A ∩ B ) = =
number of cards 52

Example 5: Let 2 items be chosen at random from a lot containing 12 items of


which 4 are defective. Let A = {both items are defective} and
B = {both items are not defective}. Find P( A ) and P( B ).

S can occur in 12
C 2 = 66 ways, the number of ways that 2 items can be chosen
from 12 items;

A can occur in 4
C 2 = 6 ways, the number of ways that 2 defective items can
be chosen from 4 defective items;

B can occur in 8
C 2 = 28 ways, the number of ways that 2 non-defective items
can be chosen from 8 non-defective items.

6 1 28 14
Accordingly, P( A ) = = and P( B ) = =
66 11 66 33

6-4
CS218 CHAPTER 6: PROBABILITY

Example 6: What is the probability that at least one item is defective from
example 5?

C = {at least one item is defective} is the complement of B; that is, C = B c


14 19
Thus by theorem 6.2, P(C ) = P(B c ) = 1− P( B ) = 1− =
33 33
l Remark 2: The odds that an event with probability p occurs is defined to
be the ratio p :(1− p )

Example 7: What are the odds that at least one item is defective from example 5?

19 14
The odds that at least one item is defective are ⋅ or 19 :14 which
33 33
is read “19 to 14”

6.3 CONDITIONAL PROBABILITY

u Let E be an arbitrary event in a sample space S with P( E ) > 0. The probability that an
event A occurs once E has occurred or, in other words, the conditional probability
of A given E, written P( A | E ), is defined as follows:
P( A ∩ E )
P( A | E ) =
P( E )

l Theorem 7: Let S be a finite equiprobable space with events A and E.


number of elements in A ∩ E
Then P( A | E ) =
number of elements in E

or P( A | E ) =
number of ways A and E can occur
number of ways E can occur

Example 8: Let a pair of fair dice be tossed. If the sum is 6, find the probability
that one of the dice is 2. In other words, if
E = {sum is 6} = {(1, 5), ( 2, 4 ), ( 3, 3), ( 4 , 2), ( 5, 1)} and
A = {a 2 appears on at least one die} find P( A | E ) and P ( A )

Now E consists of five elements and two of them, ( 2, 4 ) and ( 4 , 2), belong
to A: A ∩ E = {( 2, 4 ), ( 4 , 2)} =
2 5
and P ( E ) =
36 36
2
P( A ∩ E )
Then P( A | E ) =
36 2
= =5
P (E ) 5
36

6-5
CHAPTER 6: PROBABILITY CS218

Example 9: A man visits a couple who have two children. One of the children, a
boy, comes into the room. Find the probability p that the other child
is also a boy if (i) the other child is known to be younger, (ii) nothing
is known about the other child.

The sample space for the sex of two children is S = {bb , bg , gb , gg} with
probability 14 for each point. (Here the sequence of each point corresponds to
the sequence of births).

(i) The reduced sample space consists of two elements, {bb , bg}; hence p = 12

(ii) The reduced sample space consists of three elements, {bb , bg , gb}; hence
p= 3
1

6.3.1 MULTIPLICATION THEOREM

l Multiplication Theorem: P( E ∩ A ) = P( E )P( A | E )

l Corollary: For any events A1 , A 2 , K , A n ,


P( A1 ∩ A 2 ∩ K ∩ A n )
= P( A1 )P( A 2 | A1 )P( A 3 | A1 ∩ A 2 )K P ( A n | A1 ∩ A 2 ∩ K ∩ A n−1 )

Example 10: A lot contains 12 items of which 4 are defective. Three items are
drawn at random from the lot one after the other. Find the
probability p that all three are not defective.

The probability that the first item is not defective is 128 since 8 of 12 items are
not defective. If the first item is not defective, then the probability that the
next item is not defective is 11 since only 7 of the remaining 11 items are not
7

defective. If the first two items are not defective, then the probability that the
last item is not defective is 10 since only 6 of the remaining 10 items are now
6

not defective. Thus by the multiplication theorem, p = 128 ⋅ 117 ⋅ 106 = 14


55

6.3.2 STO CHAS TIC PROC ESSES & TREE DIA GRAMS

u A (finite) sequence of experiments in which each experiment has a finite number of


outcomes with given probabilities is called a (finite) stochastic process. A
convenient way of describing such a process and computing the probability of any
event is by a tree diagram. The multiplication theorem is also used to compute the
probability that the result represented by any given path of the tree does occur.

Example 11: We are given three boxes as follows:

Box I has 10 light bulbs of which 4 are defective.


Box II has 6 light bulbs of which 1 is defective.
Box III has 8 light bulbs of which 3 are defective.

We select a box at random and then draw a bulb at random. What is


the probability p that the bulb is defective?

Here we perform a sequence of two experiments:

(i) select one of the three boxes;


(ii) select a bulb which is either defective (D) or not defective (N)

6-6
CS218 CHAPTER 6: PROBABILITY

The following tree diagram describes this process and gives the probability of
each branch of the tree:

The probability that any particular path of the tree occurs is, by the
multiplication theorem, the product of the probabilities of each branch of the
path, i.e., the probability of selecting box I and then a defective bulb is 13 ⋅ 25 = 152

Now since there are three mutually exclusive paths which lead to a defective
bulb, the sum of the probabilities of these paths is the required probability:
p = 13 ⋅ 25 + 13 ⋅ 61 + 13 ⋅ 83 = 113
360

Example 12: A coin, weighted so that P( H ) = 23 and P(T ) = 13, is tossed. If heads
appears, then a number is selected at random from the numbers 1
through 9; if tails appears, then a number is selected at random
from the numbers 1 through 5. Find the probability p that an even
number is selected.
The tree diagram with respective probabilities is

Note that the probability of selecting an even number from the numbers 1
through 9 is 49 since there are 4 even numbers out of the 9 numbers, whereas
the probability of selecting an even number from the numbers 1 through 5 is 5
2

since there are 2 even numbers out of the 5 numbers. Two of the paths lead to
an even number: HE and TE. Thus p = P( E ) = 23 ⋅ 49 + 13 ⋅ 25 = 135
58

6.4 INDEPENDENCE

u An event B is said to be independent of an event A if the probability that B occurs is


not influenced by whether A has or has not occurred. Formally:

Events A and B are independent if P( A ∩ B ) = P( A )P( B ); otherwise they


are dependent.

6-7
CHAPTER 6: PROBABILITY CS218

Example 13: Let a fair coin be tossed three times; we obtain the equiprobable
space S = { HHH, HHT, HTH, HTT, THH, THT, TTH, TTT}. Consider the
events A = {first toss is heads}, B = {second toss is heads},
C = {exactly two heads are tossed in a row}. Show that A and B and A
and C are independent events, and that B and C are dependent
events.

We have P( A ) = P({HHH, HHT, HTH, HTT}) = 48 = 12

P( B ) = P({HHH, HHT, THH, THT}) = 8 = 2


4 1

P(C ) = P({HHT, THH}) = 82 = 41

Then P( A ∩ B ) = P({HHH, HHT}) = 41

P( A ∩ C ) = P({HHT}) = 8
1

P( B ∩ C ) = P({HHT, THH}) = 4
1

Accordingly, P( A )P( B ) = 12 ⋅ 12 = 41 = P( A ∩ B ), and so A and B are independent;


P( A )P(C ) = 2 ⋅ 4 = 8 = P( A ∩ C ), and so A and C are independent;
1 1 1

P( B )P(C ) = 2 ⋅ 4 = 8 ≠ P( B ∩ C ), and so B and C are dependent.


1 1 1

u Frequently, we will postulate that two events are independent, or it will be clear from
the nature of the experiment that two events are independent.

Example 14: The probability that A hits a target is 14 and the probability that B
hits it is 25. What is the probability that the target will be hit if A and
B each shoot at the target?

We are given that P( A ) = 41 and P( B ) = 25, and we seek P( A ∪ B ). Furthermore,


the probability that A or B hits the target is not influenced by what the other
does; that is, the event that A hits the target is independent of the event that B
hits the target; P( A ∩ B ) = P( A )P( B ). Thus

P( A ∪ B ) = P( A ) + P( B ) − P( A ∩ B ) = P( A ) + P( B ) − P( A )P( B ) = 41 + 25 − 14 ⋅ 25 = 11
20

l Remark 3: Three events A, B, and C are independent if:


(i) P( A ∩ B ) = P( A )P( B ), P ( A ∩ C ) = P( A )P(C ) and P ( B ∩ C ) = P( B )P(C )
i.e. if the events are pairwise independent, and
(ii) P( A ∩ B ∩ C ) = P( A )P( B )P (C )

u Condition (ii) does not follow from condition (i); in other words, three events may be
pairwise independent but not independent themselves, as is shown in the next
example.

Example 15: Let a pair of fair coins be tossed; here S = {HH, HT, TH, TT} is an
equiprobable space. Consider the events

A = {heads on the first coin} = {HH, HT}

B = {heads on the second coin} = {HH, TH}

C = {heads on exactly one coin} = {HT, TH}

6-8
CS218 CHAPTER 6: PROBABILITY

Show that A, B, and C are pairwise independent, but are not


independent.
In order to show pairwise independence we must find P ( A ), P ( B ) and P (C ), and
show that P ( A ∩ B ) = P ( A )P ( B ), P ( A ∩ C ) = P ( A )P ( C ) and P ( B ∩ C ) = P ( B )P (C )

Well P( A ) = P( B ) = P(C ) = 42 = 12, and P( A ∩ B ) = P({HH}) = 14 ,


P( A ∩ C ) = P({HT}) = 4 , P( B ∩ C ) = P({TH}) = 4 . Since 2 ⋅ 2 = 4 condition (i)
1 1 1 1 1

in remark 3 is satisfied; so A, B, and C are pairwise independent.

For independence P( A ∩ B ∩ C ) = P( A )P( B )P(C ), must be true, but A ∩ B ∩ C = ∅


and so P( A ∩ B ∩ C )= P( ∅) = 0 ≠ P( A )P( B )P(C ). In other words, condition (ii) is
not satisfied and so the events are not independent.

6.5 REPEATED TRIALS


u Let S be a finite probability space. By n independent or repeated trials, we mean
the probability space T consisting of ordered n-tuples of elements of S with the
probability of an n-tuple defined to be the product of the probabilities of its
components: P(( s1 , s2 ,K , sn ) ) = P( s1 )P( s2 )K P ( sn )

Example 16: Whenever three horses a, b, and c race together, their respective
probabilities of winning are 2 , 3 and 6 . In other words, S = {a , b , c}
1 1 1

with P( a ) = 12, P( b ) = 13 and P( c) = 16 . If the horses race twice, what is


the probability of horse a winning the first race and horse c
winning the second race?

The sample space is T = {aa , ab , ac, ba , bb , bc, ca , cb , cc} for the 2 repeated
trials, where to simplify things we write ac for the ordered pair ( a , c).
The probability of ac is P ( ac) = P( a )P( c) = 2 ⋅ 6 = 12
1 1 1

6.6 RANDOM VARIABLES

u A random variable X is a rule that assigns a numerical value to each outcome in a


sample space S.

6.6.1 DISTRIBUTION AND EXPECTATION

u Let X be a random variable on a sample space S with a finite image set; say
X ( S ) = {x1 , x 2 ,K , xn}. We make X ( S ) into a probability space by defining the
probability of xi to be P( X = x i ) which we write as f ( x i ). This function f on X ( S ), i.e.
defined by f ( xi ) = P ( X = xi ), is called the distribution or probability function of
X and is usually given in the form of a table:

x1 x2 L xn
f ( x1 ) f (x 2 ) L f ( xn )

The distribution f satisfies the conditions


n
(i) f ( xi ) ≥ 0 and (ii) ∑ f (x ) = 1
i
i =1

6-9
CHAPTER 6: PROBABILITY CS218

u Now if X is a random variable with the above distribution, then the mean or
expectation or expected value of X, denoted by E( X ) or µ, is defined by
n
E( X ) = x1 f ( x1 ) + x2 f ( x 2 ) +K+ xn f ( xn ) = ∑ xi f ( xi )
i =1

That is, E( X ) is the weighted average of the possible values of X, each value
weighted by its probability.

Example 17: A pair of fair dice is tossed. We obtain the finite equiproable space S
consisting of the 36 ordered pairs of numbers between 1 and 6:

S = {(1, 1), (1, 2),K , ( 6, 6 )}

Let X assign to each point ( a , b ) in S the maximum of its numbers,


i.e. X ( a , b ) = max( a , b ). X is a random variable with the image set

X ( S ) = {1, 2, 3, 4 , 5, 6}

Compute the distribution f of X, and the mean of X.

The distribution f of X is:

f (1) = P( X = 1) = P ({(1, 1)}) = 1


36

f ( 2) = P( X = 2) = P({( 2, 1), ( 2, 2), (1, 2)}) = 3


36

f ( 3) = P( X = 3) = P({( 3, 1), ( 3, 2), ( 3, 3), ( 2, 3), (1, 3)}) = 5


36

f ( 4 ) = P( X = 4 ) = P({( 4 , 1), ( 4 , 2), ( 4 , 3), ( 4 , 4 ), ( 3, 4 ), ( 2, 4 ), (1, 4 )}) = 7


36

Similarly,
f ( 5) = P( X = 5) = 369 and f ( 6) = P( X = 6) = 11
36

This information is put in the form of a table as follows:

xi 1 2 3 4 5 6
f (x i )
1 3 5 7 9 11
36 36 36 36 36 36

We next compute the mean of X:


6
E( X ) = ∑ xi f ( xi ) = 1⋅ 36 + 2 ⋅ 36 + 3 ⋅ 36 + 4 ⋅ 36 + 5 ⋅ 36 + 6 ⋅ 36 = = 4 .47
1 3 5 7 9 11 161
36
i =1

Example 18: Let Y assign to each point ( a , b ) in S = {(1, 1), (1, 2),K , ( 6, 6)} the sum
of its numbers, i.e. Y ( a , b ) = a + b. Then Y is also a random variable
on S with the image set Y ( S ) = {2, 3, 4 , 5, 6, 7, 8, 9, 10, 11, 12}. Compute
the distribution g and mean of Y

The distribution g of Y is:

yi 2 3 4 5 6 7 8 9 10 11 12
g ( yi )
1 2 3 4 5 6 5 4 3 2 1
36 36 36 36 36 36 36 36 36 36 36

The mean of Y is:


12
E(Y ) = ∑ yi g ( yi ) = 2 ⋅ 36 + 3 ⋅ 36 +K+ 12 ⋅ 36 = 7
1 2 1

i =1

6 - 10
CS218 CHAPTER 6: PROBABILITY

Example 19: A coin weighted so that P( H ) = 3 and P(T ) = 3 is tossed three times.
2 1

The probabilities of the points in the sample space


S = {HHH, HHT, HTH, HTT, THH, THT, TTH, TTT} are as follows:

P( HHH) = 3 ⋅ 3 ⋅ 3 = 27 P( THH) = 3 ⋅ 3 ⋅ 3 = 27 P( HHT) = 3 ⋅ 3 ⋅ 3 = 27


2 2 2 8 1 2 2 4 2 2 1 4

P( THT) = 3 ⋅ 3 ⋅ 3 = 27 P( HTH) = 3 ⋅ 3 ⋅ 3 = 27 P( TTH) = 3 ⋅ 3 ⋅ 3 = 27


1 2 1 2 2 1 2 4 1 1 2 2

P( HTT) = 3 ⋅ 3 ⋅ 3 = 27 P( TTT) = 3 ⋅ 3 ⋅ 3 = 27
2 1 1 2 1 1 1 1

Let X be the random variable which assigns to each point in S the


largest number of successive heads which occurs. Find the
distribution f of X.

The distribution f of X is:

f ( 0) = P( TTT ) = 27
1

f (1) = P({HTH, HTT, THT, TTH}) = 27 + 27 + 27 + 27 = 27


4 2 2 2 10

f ( 2) = P({HHT, THH}) = 274 + 274 = 278

f ( 3) = P( HHH) = 278

Which is put in a table as:

xi 0 1 2 3
f ( xi )
1 10 8 8
27 27 27 27

Example 20: What is the mean of X in example 19?

The number of times we get a successive head is as follows:

X ( TTT) = 0, X ( HTH) = X ( HTT) = X ( THT ) = X ( TTH) = 1,


X ( HHT) = X ( THH) = 2, and X ( HHH) = 3

So the mean is computed as:

E( X ) = ∑ xi f ( xi ) = 0 ⋅ 271 + 1⋅ 10
27 + 2 ⋅ 27 + 3 ⋅ 27 = 27 = 185
8 8 50
.

Example 21: A sample of 3 items is selected at random from a box containing 12


items of which 3 are defective. Find the expected number E of
defective items.

12
The sample space S consists of the   = 220 distinct equally likely samples of
 3
size 3. Note that there are:

 9
  = 84 samples with no defective items;
 3

 9
3 ⋅   = 108 samples with 1 defective item;
 2

6 - 11
CHAPTER 6: PROBABILITY CS218

 3
9 ⋅   = 27 samples with 2 defective items;
 2

 3
  =1 sample with 3 defective items;
 3

Thus the probability of getting 0, 1, 2, and 3 defective items is respectively


220 , 220 , 220 , and 220 . Thus the expected number E of defective items is
84 108 27 1

E = 0 ⋅ 220
84
+ 1⋅ 108
220 + 2 ⋅ 220 + 3 ⋅ 220 = 220 = 0.75
27 1 165

6.6.2 VARI ANCE AND STAN DARD DE VIA TION

u The mean of a random variable X measures, in a certain sense, the “average” value of
X. The variance of X measures the “spread” or “dispersion” of X

u Let X be a random variable with the following distribution:

x1 x2 L xn
f ( x1 ) f ( x 2 ) L f (x n )

Then the variance of X, denoted by Var(X), is defined by

(( X − µ) )
n
Var(X) = ∑ ( xi − µ ) f ( x i ) = E
2 2

i =1

where µ is the mean of X

u The standard deviation of X, denoted by σ X , is the (nonnegative) square root of


Var(X):

σ X = Var( X )

u The following theorem gives an alternate and sometimes more useful formula for
calculating the variance of the random variable X.
n
l Theorem 9: Var(X) = ∑ xi2 f ( xi ) − µ 2 = E( X 2 )− µ 2
i =1

Example 22: Consider the random variable X from example 17 (which assigned
the maximum of the numbers showing on a pair of dice). Compute
the variance and standard deviation of X.

The distribution of X is:

xi 1 2 3 4 5 6
f ( x i ) 36
1 3 5 7 9 11
36 36 36 36 36

and the mean of X is 4.47 First we need to compute E( X 2


):
6
E( X 2 ) = ∑ xi2 f ( x i ) = 12 ⋅ 361 + 2 2 ⋅ 363 + 3 2 ⋅ 365 + 4 2 ⋅ 367 + 5 2 ⋅ 369 + 6 2 ⋅ 3611 = 791
36 = 2197
.
i=1

Hence Var( X ) = E( X 2 ) − µ 2X = 2197


. − 19.98 = 199
. and σ X = 199
. = 14
.

6 - 12
CS218 CHAPTER 6: PROBABILITY

Example 23: Compute the variance and standard deviation of Y the random
variable of example 18 (which assigned the sum of the numbers
showing on a pair of dice).

The distribution of Y is:

yi 2 3 4 5 6 7 8 9 10 11 12
g ( yi ) 36
1 2 3 4 5 6 5 4 3 2 1
36 36 36 36 36 36 36 36 36 36

and the mean of Y is 7. First compute E(Y 2 ) :

E(Y 2 ) = ∑ yi2 g ( y i ) = 2 2 ⋅ 361 + 3 2 ⋅ 362 +K+ 12 2 ⋅ 361 = 1974


36 = 54.8

Hence Var(Y ) = E(Y 2 ) − µ Y2 = 54.8 − 49 = 5.8 and σY = 5.8 = 2.4

6.7 BINOMIAL DISTRIBUTIONS

u We are looking at repeated and independent trials of an experiment with two


outcomes; we call one of the outcomes success and the other outcome failure. Let p
be the probability of success, so that q = 1− p is the probability of failure.

u If we are interested in the number of successes and not in the order in which they
occur, then the following theorem applies.

l Theorem 10: The probability of exactly k successes in n repeated trials is


denoted and given by b( k; n , p ) = ( nk ) p k q n− k

u Here ( nk ) is the binomial coefficient. Observe that the probability of no successes is


q n , and therefore the probability of at least one success is 1− q n

Example 24: A fair coin is tossed 6 times or, equivalently, six fair coins are
tossed; call heads a success. Then n = 6 and p = q = 2
1

Find (i) The probability that exactly two heads occur.


(ii) The probability of getting at least four heads.
(iii) The probability of no heads.

(i) The probability that exactly two heads occurs, (i.e. k = 2) is


b( 2; 6, 12 ) = ( 62 )( 12) ( 12) = 15
2 4
64

(ii) The probability of getting at least four heads (i.e. k = 4 , 5 or 6) is


b(4;6, 12) + b(5; 6, 12) + b(6;6, 12) = ( 64 )( 12) ( 12 ) + ( 65 )( 12) ( 12) + ( 66 )( 12)
4 2 5 6

= 64 + 64 + 64 = 32
15 6 1 11

The probability of no heads (i.e. all failures) is q 6 = ( 2) = 64 , and so the


1 6
(iii)
1

probability of at least one head is 1− q 6 = 1− 641 = 64


63

Example 25: A fair die is tossed 7 times; call a toss a success if a 5 or a 6 appears.
Then n = 7, p = P({5, 6}) = 13 and q = 1− p = 23

Find (i) The probability that a 5 or a 6 occurs exactly 3 times.


(ii) The probability that a 5 or a 6 never occurs.

6 - 13
CHAPTER 6: PROBABILITY CS218

(i) The probability that a 5 or a 6 occurs exactly 3 times (i.e. k = 3) is


b( 3; 7, 13 ) = ( 73 )( 13) ( 23) = 2187
3 4 560

(ii) The probability that a 5 or a 6 never occurs (i.e. all failures) is


q 7 = ( 23) = 2187
7 128

u If we regard n and p as constants, then the function P( k ) = b( k; n , p ) is a discrete


probability distribution:

k 0 1 2 L n
P( k ) qn ( 1n )q n−1 p ( n2 )q n− 2 p 2 L pn

It is called the binomial distribution since for k = 0, 1, 2,K , n it corresponds


to the successive terms of the binomial expansion

( q + p) n = q n + ( 1n )q n−1 p + ( n2 )q n− 2 p 2 +L+ p n

u Properties of a binomial distribution are as follows:

Binomial Distribution
Mean µ = np
Variance σ 2 = npq
Standard deviation σ = npq

Example 26: A fair die is tossed 180 times. Find the expected number of sixes,
and the standard deviation.

The expected number of sixes is µ = np = 180 ⋅ 6 = 30. The standard


1

deviation is σ = npq = 180 ⋅ 61 ⋅ 65 = 5

6 - 14
CS218 CHAPTER 6: PROBABILITY

6.8 SUMMARY

6.8.1 THEOREMS

l Let S be a sample space, let E be the class of events, and let P be a real-valued
function defined on E. Then P is called a probability function, and P( A ) is
called the probability of the event A if the following axioms hold:
[P1 ] For every event A , 0 ≤ P( A ) ≤ 1
[P2 ] P( S ) = 1
[P3 ] If A and B are mutually exclusive events, then P( A ∪ B ) = P( A ) + P( B )
[P4 ]If A1 , A 2 ,K is a sequence of mutually exclusive events, then
P ( A1 ∪ A 2 ∪ K ) = P ( A1 ) + P ( A 2 ) + K
l If ∅ is the empty set, then P( ∅) = 0
l If A c is the complement of an event A, then P( A c ) = 1− P( A )

l If A ⊆ B, then P( A ) ≤ P( B )

l If A and B are any two events, then P( A \ B ) = P( A ) − P( A ∩ B )

l If A and B are any two events, then P( A ∪ B ) = P( A ) + P( B ) − P( A ∩ B )


l Let S be a finite equiprobable space with events A and E. Then
number of elements in A ∩ E
P( A | E ) =
number of elements in E

l Multiplication Theorem: P( E ∩ A ) = P( E )P ( A | E )

l Corollary: For any events A1 , A 2 , K , A n , P( A1 ∩ A 2 ∩ K ∩ A n )


= P( A1 )P( A 2 | A1 )P( A 3 | A1 ∩ A 2 )K P ( A n | A1 ∩ A 2 ∩ K ∩ A n−1 )
n
l Var(X) = ∑ xi2 f ( xi ) − µ 2 = E( X 2 )− µ 2
i =1

l The probability of exactly k successes in n repeated trials is denoted and


given by b( k; n , p ) = ( nk ) p k q n− k

6.8.2 REMARKS

l The probability of an event can be thought of as “a favourable outcome” over “all


favorable
possible outcomes,” i.e.
total
l The odds that an event with probability p occurs is defined to be the ratio
p :(1− p )

l Three events A, B, and C are independent if:


(i) P( A ∩ B ) = P( A )P( B ), P ( A ∩ C ) = P( A )P(C ) and P ( B ∩ C ) = P( B )P(C ) i.e. if the
events are pairwise independent, and

(ii) P( A ∩ B ∩ C ) = P( A )P( B )P(C )

6 - 15
CHAPTER 6: PROBABILITY CS218

6.9 PROBABILITY EXERCISES

u Sample spaces and events


1. Let A and B be events. Find an expression and exhibit the Venn diagram for
the event that:

(i) A but not B occurs; i.e. only A occurs

(ii) either A or B, but not both, occurs, i.e. exactly one of the two events
occurs.

2. Let A, B and C be events. Find an expression and exhibit the Venn diagram
for the event that

(i) A and B but not C occurs

(ii) only A occurs

3. Let a coin and a die be tossed; let the sample space S consist of the twelve
elements: S = {H1, H2, H3, H4, H5, H6, T1, T2, T3, T4, T5, T6}

(i) Express explicitly the following events: A = {heads and an even


number appear}, B = {a prime number appears}, C = {tails and an
odd number appear}

(ii) Express explicitly the event that: (a) A or B occurs, (b) B and C
occurs, (c) only B occurs

(iii) Which of the events A, B, and C are mutually exclusive?

u Finite probability spaces

4. Suppose a sample space S consists of 4 elements: S = {a 1 , a 2 , a 3 , a 4 }. Which


function defines a probability space on S?

(i) P( a1 ) = 2 , P( a 2 ) = 3 , P( a 3 ) = 4 , P( a 4 ) = 5
1 1 1 1

(ii) P( a1 ) = 2 , P( a 2 ) = 4 , P( a 3 ) = − 4 , P( a 4 ) = 2
1 1 1 1

(iii) P( a1 ) = 2 , P( a 2 ) = 4 , P( a 3 ) = 8 , P( a 4 ) = 8
1 1 1 1

(iv) P( a1 ) = 2 , P( a 2 ) = 4 , P( a 3 ) = 4 , P( a 4 ) = 0
1 1 1

5. Let S = {a 1 , a 2 , a 3 , a 4 }, and let P be the probability function on S.

(i) Find P( a 1 ) if P( a 2 ) = 3 , P( a 3 ) = 6 , P( a 4 ) = 9
1 1 1

(ii) Find P( a 1 ) and P( a 2 ) if P( a 3 ) = P( a 4 ) = 4 and P( a1 ) = 2P( a 2 )


1

(iii) Find P( a 1 ) if P({a 2 , a 3}) = 23 , P({a 2 , a 4 }) = 12 and P( a 2 ) = 13

6. A coin is weighted so that heads is twice as likely to appear as tails. Find


P(T) and P(H)

6 - 16
CS218 CHAPTER 6: PROBABILITY

7. Two men, m1 and m2 , and three women, w1 , w2 and w3 are in a chess


tournament. Those of the same sex have equal probabilities of winning, but
each man is twice as likely to win as any woman.

(i) Find the probability that a woman wins the tournament.

(ii) If m1 and w1 are married, find the probability that one of them wins
the tournament

8. Let a die be weighted so that the probability of a number appearing when


the die is tossed is proportional to the given number (e.g. 6 has twice the
probability of appearing as 3). Let A = {even number}, B = {prime
number}, C = {odd number}

(i) Describe the probability space, i.e. find the probability of each
sample point

(ii) Find P(A), P(B) and P(C)

(iii) Find the probability that:

(a) an even or prime number occurs

(b) an odd prime number occurs

(c) A but not B occurs

u Finite equiprobable spaces

9. Determine the probability p of each event:

(i) an even number appears in the toss of a fair die

(ii) a king appears in drawing a single card from an ordinary pack of 52


cards

(iii) at least one tail appears in the toss of three fair coins

(iv) a white marble appears in drawing a single marble from an urn


containing 4 white, 3 red and 5 blue marbles

10. Two cards are drawn at random from an ordinary pack of 52 cards. Find
the probability p that

(i) both are spades

(ii) one is a spade and one is a heart

11. Three light bulbs are chosen at random from 15 bulbs of which 5 are
defective. Find the probability p that

(i) none is defective

(ii) exactly one is defective

(iii) at least one is defective

12. Two cards are selected at random from 10 cards numbered 1 to 10. Find
the probability p that the sum is odd if

6 - 17
CHAPTER 6: PROBABILITY CS218

(i) the two cards are drawn together

(ii) the two cards are drawn one after the other without replacement

(iii) the two cards are drawn one after the other with replacement

13. Six married couples are standing in a room

(i) If 2 people are chosen at random, find the probability p that

(a) they are married

(b) one is male and one is female

(ii) If 4 people are chosen at random, find the probability p that

(a) 2 married couples are chosen

(b) no married couple is among the 4

(c) exactly one married couple is among the 4

(iii) If the 12 people are divided into six pairs, find the probability p that

(a) each pair is married

(b) each pair contains a male and a female

14. A class contains 10 men and 20 women of which half the men and half the
women have brown eyes. Find the probability p that a person chosen at
random is a man or has brown eyes.

u Conditional probability

15. A pair of dice is thrown. Find the probability p that the sum is 10 or
greater if

(i) a 5 appears on the first die

(ii) a 5 appears on at least one of the dice

16. Three fair coins are tossed. Find the probability p that they are all heads
if

(i) the first coin is heads

(ii) one of the coins is heads

17. A pair of fair dice is thrown. If the two numbers appearing are different,
find the probability p that

(i) the sum is six

(ii) an ace appears

(iii) the sum is 4 or less

18. Two digits are selected at random from the digits 1 through 9. If the sum
is even, find the probability p that both numbers are odd.

6 - 18
CS218 CHAPTER 6: PROBABILITY

19. A man is dealt 4 spade cards from an ordinary pack of 52 cards. If he is


given three more cards, find the probability p that at least one of the
additional cards is also a spade.

20. Four people, called North, South, East and West, are each dealt 13 cards
from an ordinary pack of 52 cards.

(i) If South has no aces, find the probability p that his partner North
has exactly two aces.

(ii) If North and South together have nine hearts, find the probability p
that East and West each has two hearts.

u Multiplication theorem

21. A class has 12 boys and 4 girls. If three students are selected at random
from the class, what is the probability p that they are all boys?

22. A man is dealt 5 cards one after the other from an ordinary pack of 52
cards. What is the probability p that they are all spades?

23. An urn contains 7 red marbles and 3 white marbles. Three are drawn
from the urn one after the other. Find the probability p that the first two
are red and the third is white.

24. The students in a class are selected at random, one after the other, for an
examination. Find the probability p that the boys and girls in the class
alternate if

(i) the class consists of 4 boys and 3 girls,

(ii) the class consists of 3 boys and 3 girls.

u Finite stochastic processes

25. A box contains three coins; one coin is fair, one coin is two-headed, and
one coin is weighted so that the probability of heads appearing is 13. A coin
is selected at random and tossed. Find the probability p that heads
appears.

26. Box A contains nine cards numbered 1 through 9, and box B contains five
cards numbered 1 through 5. A box is chosen at random and a card
drawn. If the number is even, find the probability that the card came
from box A.

27. We are given three urns as follows:

Urn A contains 3 red and 5 white marbles.

Urn B contains 2 red and 1 white marble.

Urn C contains 2 red and 3 white marbles.

An urn is selected at random and a marble is drawn from teh urn. If the
marble is red, what is the probability that it came from urn A?

6 - 19
CHAPTER 6: PROBABILITY CS218

28. An urn contains 3 red marbles and 7 white marbles. A marble is drawn
from the urn and a marble of the toher colour is then put into the urn. A
second marble is drawn from the urn.

(i) Find the probability p that the second marble is red.

(ii) If both marbles were of the same colour, what is the probability p
that they were both white?

29. We are given two urns as follows:

Urn A contains 3 red and 2 white marbles.

Urn B contains 2 red and 5 white marbles.

An urn is selected at random; a marble is drawn and put into the other
urn; then a marble is drawn from the second urn. Find the probability
p that both marbles drawn are of the same colour.

u Independence

30. Let A = event that a family has children of both sexes, and let B = event
that a family has at most one boy.

(i) Show that A and B are independent events if a family has three
children.

(ii) Show that A and B are dependent events if a family has two
children.

31. The probability that a man will live 10 more years is 41, and the probability
that his wife will live 10 more years is 3. Find the probability that
1

(i) both will be alive in 10 years,

(ii) at least one will be alive in 10 years,

(iii) neither will be alive in 10 years,

(iv) only the wife will be alive in 10 years.

32. Box A contains 8 items of which 3 are defective, and box B contains 5
items of which 2 are defective. An item is drawn at random from each
box.

(i) What is the probability p that both items are non-defective?

(ii) What is the probability p that one item is defective and one not?

(iii) If one item is defective and one is not, what is the probability p that
the defective item came from box A?

33. The probabilities that three men hit a target are respectively 61 , 1
4 and 13.
Each shoots once at the target.

(i) Find the probability p that exactly one of them hits the target.

(ii) If only one hit the target, what is the probability that it was the
first man?

6 - 20
CS218 CHAPTER 6: PROBABILITY

u Repeated trials

34. A certain type of missile hits its target with probability 0.3. How many
missiles should be fired so that there is at least an 80% probability of
hitting a target?

35. A certain soccer team wins (W) with the probability 0.6, loses (L) with the
probability 0.3 and ties (T) with the probability 0.1. The team plays three
games over the weekend.

(i) Determine the elements of the event A that the team wins at least
twice and doesn’t lose; and find P(A).

(ii) Determine the elements of the event B that the team wins, loses
and ties; and find P(B).

u Random variables and expectations

36. Find the expectation µ, variance σ 2 and standard deviation σ of each of


the following distributions:

(i)

xi 2 3 11
f ( xi )
1 1 1
3 2 6

(ii)
− −
xi 5 4 1 2
f ( xi ) 1
4
1
3
1
2
1
8

(iii)

xi 1 3 4 5
f ( xi ) 0.4 0.1 0.2 0.3

37. A fair die is tossed. Let X denote twice the number appearing, and let Y
denote 1 or 3 according to whether an odd or an even number appears.
Find the distribution, expectation, expectation, variance and standard
deviation of
(i) X

(ii) Y

(iii) X + Y

(iv) XY

38. A coin is weighted so that P ( H ) = 4 and P (T ) = 4 is tossed three times. Let


3 1

X be the random variable which denotes the longest string of heads which
occurs. Find the distribution, expectation, variance and standard
deviation of X.

6 - 21
CHAPTER 6: PROBABILITY CS218

39. Concentric circles of radius 1 and 3 cm are drawn


on a circular target of radius 5 cm. A man receives
10, 5 or 3 points if he hits the target inside the
smaller circle, inside the middle annular region or
inside the outer annular region respectively.
Suppose the man hits the target with probability 12
and then is just as likely to hit one point of the
target as the other. Find the expected number E
of points he scores each time he fires.

40. A player tosses two fair coins. He wins $1 if 1 head appears, $2 if 2 heads
appear. On the other hand he loses $5 if no heads appear. Determine the
expected value E of the game and if it is favourable to the player.

u Binomial distribution

41. Find
(i) b( 2 ; 5, 13 )

(ii) b( 3 ; 6, 12 )

(iii) b( 3 ; 4 , 41 )

42. A fair coin is tossed three times. Find the probability P that there will
appear

(i) three heads


(ii) two heads
(iii) one head
(iv) no heads

43. Team A has probability 23 of winning whenever it plays. If A plays 4 games,


find the probability that A wins
(i) exactly 2 games

(ii) at least 1 game

(iii) more than half of the games


44. A family has 6 children. Assuming that the probability of any particular
child being a boy is 12, find the probabilty P that there are
(i) 3 boys and 3 girls

(ii) fewer boys than girls

45. How many dice must be thrown so that there is a better than even chance
of obtaining a six?

46. Determine the expected number of boys in a family with 8 children,


assuming the sex distribution to be equally probable. What is the
probability that the expected number of boys does occur?

6 - 22
CS218 CHAPTER 6: PROBABILITY

47. The probability of a man hitting a target is 14 .

(i) If he fires 7 times, what is the probability P of his hitting the target
at least twice?

(ii) How many times must he fire so that the probability of his hitting
the target at least once is greater than 23?

u Miscellaneous problems

48. Let A and B be events with P( A ) = 8 , P( B ) = 2 and P( A ∩ B ) = 4 . Find


3 1 1

(i) P( A ∪ B )
(ii) P( A c ) and P(B c )
(iii) P( A c ∩ B c )

(iv) P( A c ∪ B c )
(v) P( A ∩ B c )
(vi) P(B ∩ A c )

49. Find the probability p of an event if the odds that it will occur are a : b,
that is “a to b”.

50. A die is tossed 100 times. The following table lists the six numbers and
frequency with which each number appeared:

Number 1 2 3 4 5 6
Frequency 14 17 20 18 15 16

Find the relative frequency f of the event


(i) a 3 appears
(ii) a 5 appears
(iii) an even number appears

(iv) a prime appears

51. In a certain college, 25% of the students failed mathematics, 15% of the
students failed chemistry, and 10% of the students failed both
mathematics and chemistry. A student is selected at random.

(i) If he failed chemistry, what is the probability that he failed


mathemetics?

(ii) If he failed mathematics, what is the probability that he failed


chemistry?

(iii) What is the probability that he failed mathematics or chemistry?

6 - 23
CHAPTER 6: PROBABILITY CS218

52. Let A and B be events with P( A ) = 12, P( B ) = 13 and P( A ∩ B ) = 14 . Find

(i) P( A | B )

(ii) P( B | A )

(iii) P( A ∪ B )

(iv) P( A c | B c )

(v) P( B c | A c )

53. Find P( B | A ) if

(i) A is a subset of B

(ii) A and B are mutually exclusive

54. Let A and B be events with P ( A ) = 83 , P ( B ) = 85 and P ( A ∪ B ) = 43. Find


P ( A | B ) and P ( B | A )

55. A string of three bits is obtained randomly.


(i) List all the elements of the sample space
(ii) Let A be the event that the string contains an odd number of 1’s,
and let B be the event that the string starts with a 1. Are a and b
independent? Explain your answer using probability calculations.

56. Suppose that three computer boards in a production run of 40 are


defective. A sample of four is to be selected to be checked for defects.
(i) How many different samples can be chosen?
(ii) How many samples will contain at least one defective board?
(iii) What is the probability that a randomly chosen sample of four
contains at least one defective board?

57. A coin is tossed 10 times. In each case, the outcome H (for head), or T (for
tail) is recorded.
(i) What is the total number of possible outcomes of the coin-tossing
experiment?
(ii) In how many of the possible outcomes are exactly five heads
obtained?
(iii) In how many of the possible outcomes are at least nine heads
obtained?
(iv) In how many of the possible outcomes are at most one head
obtained?
(v) In how many of the possible outcomes are at least one tail obtained?

58. What are independent events?

59. What are mutually exclusive events?

60. A technician is installing software in his labortory; he has six different


kinds of packages to choose from, and four computers, each of which is to

6 - 24
CS218 CHAPTER 6: PROBABILITY

have one kind of package installed on it. Instead of putting a different


package on each machine, he simply picks a package at random each time.
Since he has multiple copies of each package, there is the possibility of
installing one kind of package on more than one computer. What is the
probability that each machine gets a different package?

61. A suitcase contains five pink, four grey, and three blue socks. Three socks
are drawn without replacement. Consider the following events
A: at least one pink sock is drawn
B: exactly two pink socks are drawn
C: one sock of each colour is drawn
(i) Which events are mutually exclusive? Explain.
(ii) Which events are not mutually exclusive? Explain.
(iii) Calculate the probabilities of A, B, and C

62. Given two events E1 and E2, state the conditions for the events to be

(i) independent

(ii) mutually exclusive

63. The technician in charge of software installation has put an accounts


package on half the machines in the laboratory, and a spreadsheet
package on two-thirds of the computers at random, and in no case paying
attention to what software is already on the machine. What is the
probability that any given machine has:
(i) both packages on it?
(ii) at least one package on it?
(iii) neither package on it?

64. A string containing 8 bits, each of which is either 0 or 1, can be used to


represent any one of 2 8 = 256 different values.
(i) How many 8-bit strings contain seven consecutive zeros?
(ii) How many 8-bit strings are there in which the first three bits are
zeros?
(iii) How many 8-bit strings are there in which the first bit is zero?

65. Two ordinary dice are thrown, giving the individual scores p and q each
ranging from 1 to 6:
(i) What is the probability that the sum of p and q is exactly 6?
(ii) What is the probability that p = q?
(iii) What is the probability that p = q and p + q = 6?
(iv) What is the probability that p = q or p + q = 6?

6 - 25
CHAPTER 6: PROBABILITY CS218

66. A single dice is thrown eight times; each time, either 0 or 1 is written
down: we write 0 if the score is between 1 and 5; we write 1 if the score is
6.

(i) What is the probability that the resulting bit sequence contains
seven consectutive 0’s?
(ii) What is the probability that the resulting bit sequence contains 5
consecutive 0’s?

67. In a lucky draw, you win a computer and a software package. The
computer is either a PC or a Macintosh. There are four software
packages, three of which will run only on the PC. What is the probability
that you have won a compatible pair?

6 - 26
CHAPTER 7: GRAPH THEORY

Chapter Objectives

In this chapter you will learn:

§ what makes up a graph;

§ what a multigraph is;

§ what a pseudograph is;

§ what a digraph is;

§ some basis definitions of graph theory;

§ what a subgraph is;

§ how to determine if a graph is isomorphic;

§ about different classes of graphs;

§ how to determine if a graph is bipartite;

§ how to find an adjacency matrix of a graph;

§ how to find the incidence matrix of a graph;

§ how to find the distance matrix of a graph;

§ what makes a graph Eulerian;

§ what makes a graph Hamiltonian;

§ about the travelling salesman problem;

7-1
CHAPTER 7: GRAPH THEORY CS218

7.1 GRAPHS AND DIGRAPHS

7.1.1 GRAPHS

u A graph is just a set of points called vertices connected by lines called edges.

u Graphs are denoted by uppercase letters like G and H. The set of vertices of a graph G
is denoted by V(G), and the set of edges of a graph G is denoted by E(G).

u A single element from the set of vertices is called a vertex. Vertices will be denoted
by lowercase letters.

u An edge is denoted by listing the vertices that are its endpoints. When naming the
edge the order of the vertices is not important, e.g. edge db is the same as edge bd.

u If there is an edge joining a pair of vertices, those vertices are said to be adjacent.
Otherwise, they are nonadjacent.

u An edge is incident with a vertex if the edge is joined to the vertex. Therefore, an
edge is incident with its endpoints.

u The number of edges connected to a given vertex is called the degree of that vertex.
The degree of a vertex is denoted d(v). The degree sequence of a graph is the list of
the degrees of its vertices in non-increasing order.

Exercise 1: Find the degree of each vertex in graph G

Exercise 2: What is the degree sequence of G?

u An edge contributes 1 to the degree of each of its two endpoints. This fact gives us the
following theorem.

l Theorem 1: In a graph G, the sum of the degrees of the vertices equals


twice the number of edges.
l Corollary 1: The sum of the degrees of the vertices of a graph is an even
number.

7-2
CS218 CHAPTER 7: GRAPH THEORY

7.1.2 MULTIGRAPHS AND PSEUDOGRAPHS

u A multigraph allows more than one edge between a pair of vertices. Such edges are
called multiple edges.

u A pseudograph allows loops and multiple edges. A loop is an edge that connects a
vertex to itself.

7.1.3 DIGRAPHS

u A graph whose edges are all directed is called a directed graph or digraph. The
directed edges are called arcs.

u In a digraph parallel arcs are pairs of arcs in which one is directed from vertex a to
vertex b and the other in directed from vertex b to vertex a. They are distinct arcs and
are denoted ab and ba respectively. So the order in which we list the vertices of an arc
is important.

u The direction of an arc is indicated by an arrow on the edge.

Digraph H

Exercise 3: List the arcs in the digraph H

Exercise 4: List all the parallel arcs in digraph H.

u The indegree of a vertex v is the number of arcs directed toward v and is denoted
id(v)

u The outdegree of v is the number of arcs directed away from v and is denoted od(v).

Exercise 5: List the indegree of each vertex in digraph H.

Exercise 6: List the outdegree of each vertex in digraph H.

7-3
CHAPTER 7: GRAPH THEORY CS218

u Notice that each arc contributes 1 to the indegree of the vertex it points to and 1 to the
outdegree of the vertex it points away from. This gives the following theorem:

l Theorem 2: In a digraph, the sum of the indegrees equals the sum of the
outdegrees.

7.2 BASIC DEFINITIONS


u A path in a graph G is a sequence of distinct vertices v0 , v1 , v2 ,K , v k such that
v1v 2 , v2 , v3 ,K , v k −1vk are edges of G.

u The length of a path is the number of edges in it.

l Remark 1: A path having n vertices is denoted Pn

Example 1: In graph G, c, e, b is a
path of length 2 between c and b.
The edges of the path are ce and eb

Example 2: In graph G, c, d , e, a , b is a path of length 4 between c and b. The edges


of the path are cd, de, ea and ab
l Remark 2: A path using k distinct vertices has length k −1

u A graph is connected if every pair of its vertices is connected by a path.

u A graph is disconnected if there is not a path between every pair of vertices.

Example 3: Graph G is a connected graph, while graph H is disconnected, since


there is no path between f and i.

u A graph that is disconnected contains two or more pieces, called components of the
graph.

u A cycle is a path that begins and ends at the same place.

l Remark 3: A cycle having n vertices is denoted C n

7-4
CS218 CHAPTER 7: GRAPH THEORY

7.2.1 SUBGRAPHS
u A subgraph A of graph B has as its vertex set a subset of the vertices of B, and as its
edge set a subset of the edges of B.

l Remark 4: For graphs A and B, A ⊆ B iff V ( A ) ⊆ V ( B ) and E ( A ) ⊆ E ( B )

Example 4: Determine which of the graphs are subgraphs of graph B

Graph B is a subgraph of graph B since B ⊆ B

Graph C is a subgraph of graph B: A subgraph need not contain all the vertices
of the original graph.

Graph D is not a subgraph of graph B since bc ∈ E ( D ), but bc ∉ E ( B )

Graph F is a subgraph of graph B: A subgraph need not contain all the edges of
the original graph.

u An induced subgraph is whenever an edge appears between a pair of vertices in the


original graph it also must appear in the subgraph.

Example 5: Graph C is an induced subgraph of B

Example 6: F is not an induced subgraph of B, because c and f are vertices in F,


and cf ∈ E ( B ) but cf ∉ E ( F )

7.2.2 ISOMORPHIC GRAPHS


u Graphs may be drawn differently by different people.

Example 7: Suppose you are asked to draw the graph G with vertex set
V (G ) = {a , b , c, d , e} and edge set E (G ) = {ab , ac, bc, bd , ce}. It is possible to
draw this graph in many different ways. For instance:

u Graphs G and H are isomorphic if they can be labelled so that u and v are adjacent in
G iff the corresponding vertices are adjacent in H.

u G and H are isomorphic if there exists a , 1− 1onto function between their vertices that
preserves adjacency. This function is called an isomorphism.

7-5
CHAPTER 7: GRAPH THEORY CS218

l Remark 5: If two graphs are isomorphic, corresponding vertices have the


same degree.

Example 8: Describe a function that shows the graphs G1 and G 2 are isomorphic.

In order to show that the graphs are isomorphic we must give a


correspondence between the vertices of G1 and G 2 that preserves adjacency.

Thus, vertex a, of degree 3, must correspond to either e or f; vertex b, of degree 2


must correspond to h or g

If we let f ( a ) = e, f ( b ) = h , f ( c ) = f , and f ( d ) = g , then a function f induces a


correspondence from the edges of G1 to the edges of G 2 as follows:
ab → eh , bc → hf , ad → eg , cd → fg and ac → ef

Because {eh , hf , eg , fg , ef } is precisely the edge set of G 2 , G1 is isomorphic to G 2

Example 9: Describe a function that shows the graphs G 3 and G 4 are isomorphic.

If we say f ( k ) = q, then since i is adjacent to k and has degree 1, f ( i ) = v or r


So: f ( k ) = q , f ( m ) = t , f ( i ) = v, f ( j ) = r, f ( n ) = u , and f ( p ) = s
Thus G 3 is isomorphic to G 4
l Remark 6: Let G and H be isomorphic with isomorphism f :V (G ) → V ( H ). If
v1 , v 2 ,K , vk is a shortest path between vertices v1 and v k in G then
f ( v1 ), f ( v2 ),K f ( vk ) is a shortest path between vertices f ( v1 ) and f ( vk )
in H
l Remark 7: Some items to check when trying to show that a pair of graphs
are not isomorphic are:

1. The number of vertices

2. The number of components

3. The number of edges

4. The degree sequence

5. The length of the shortest path between pairs of vertices with a given
degree

6. The length of the longest path in the graph

7-6
CS218 CHAPTER 7: GRAPH THEORY

Example 10: There are five nonisomorphic graphs with degree sequence 3, 3, 2,
2, 1, 1. Draw them and explain why they are not isomorphic to
one another.

The five nonisomorphic graphs are:

Notice that four of the graphs are connected, while graph e has 2
components. In other words graph e is not isomorphic to any of the
other graphs as it has 2 components, i.e. is not connected.

In order to see why the other graphs are not isomorphic we focus on the
length of the shortest path between the two vertices of degree 1. In
graph a this length is 2, in graph b this length is 3, and in graphs c and
d the length is 4. This shows that graphs a and b are not isomorphic to
any of the other graphs.

We now need to show that graph c and d are not isomorphic to each
other. The longest path in graph c has length 4, while the longest path
in graph d has length 5. So graph c and d are also not isomorphic.

7.3 CLASSES OF GRAPHS


u There are several important classes of graphs: trees, bipartite graphs, complete
graphs, regular graphs and planar graphs.

7.3.1 TREES

u A tree is a connected graph that does not contain


a cycle as a subgraph.

l Remark 8: Suppose G is a graph having n vertices. Then the following


statements are equivalent:

1. G is a tree

2. G is connected and has n −1 edges

3. G has n −1 edges and no cycles

4. Any two vertices of G are connected by a unique path

5. G contains no cycles, but the addition of any edge to G will


produce a single cycle.

7-7
CHAPTER 7: GRAPH THEORY CS218

7.3.2 BIPARTITE GRAPHS

u A tree is a special type of bipartite graph. A graph is bipartite if its vertices can be
separated into two sets A and B, so that vertices within the same set are nonadjacent.

u A bipartite graph is drawn with the vertices of A on the left and vertices of B on the
right, or vertices of A at the top and vertices of B at the bottom.

u Note that the vertices that are adjacent are between vertices of the set A and vertices
of the set B. There are no adjacent vertices within the sets A or B.

l Remark 9: A simple labelling procedure determines whether G is bipartite:

G is bipartite iff adjacent vertices get distinct labels:

1. Label any vertex a

2. Label all vertices adjacent to a with the label b

3. Next, label all vertices that are adjacent to a vertex just


labelled b with label a

4. Repeat steps 2 & 3 until you have labelled all vertices with
a distinct label (bipartite) or you have a conflict, i.e. you
have to label a vertex with a and b. (not bipartite)

Example 11: Label each graph to determine if it is bipartite. For those that are
bipartite, redraw them showing the vertex sets A and B of the
definition.

graph a graph b graph c

redrawing the bipartite graphs to show their bipartite nature yields:

graph a graph c

7-8
CS218 CHAPTER 7: GRAPH THEORY

u Another way to determine if a graph is bipartite without the labelling procedure is


stated in remark 8, where an odd cycle is defined to be a cycle containing an odd
number of vertices.

l Remark 10: G is bipartite iff G does not contain any odd cycles.

Exercise 7: Draw all nonisomorphic bipartite graphs having four vertices.

7.3.3 COMPLETE GRAPHS

u A complete bipartite graph is one in which each vertex in set A is adjacent to every
vertex in set B.

u The complete bipartite graph having m vertices in A and n vertices in B is denoted


K m,n

Example 12: Draw the complete bipartite graphs K 2,3 and K 3, 3

l Remark 11: The complete graph K n has n vertices, with every vertex
connected to every other vertex.

Exercise 8: Draw each K n for n ≤ 5

7.3.4 REGULAR GRAPHS

u A graph is k-regular if all its vertices have the same degree, k.

u K n is ( n −1)-regular, because each vertex of K n has degree n −1

u C n is 2-regular

7-9
CHAPTER 7: GRAPH THEORY CS218

7.3.5 PLA NAR GRAPHS

u A plane graph is a graph drawn in the plane (a flat surface) having on edges
crossing.

u In a plane graph, each cycle not containing any smaller cycles encloses a region called
a face. The region exterior to the graph is called the infinite face.

u Let f be the number of faces (including the exterior face), e be the number of edges,
and n be the number of vertices in a plane graph.

l Euler’s formula: In a connected plane graph with f faces, e edges, and n


vertices, we have the relationship: n − e + f = 2

Example 13: Redraw the following graphs with as few edge crossings as possible.
For any plane graphs you draw, verify Euler’s formula.

Graph a is a plane graph and there are 6 vertices, 9 edges, and 5 faces. Thus
n − e + f = 6 − 9 + 5 = 2. Graph c is a plane graph also and there are 7 vertices, 13
edges, and 8 faces. Thus n − e + f = 7 − 13 + 8 = 2

7.4 MATRICES ASSOCIATED WITH GRAPHS

u Graphs are represented on a computer using matrices. Some matrices are used to
represent graphs, while others are used to describe properties of graphs.

7.4.1 THE AD JA CENCY MA TRIX

u A (0, 1)-matrix is a matrix each of whose entries is 0 or 1. The identity matrix and
the zero matrix are examples of (0, 1)-matrices.

u Let the vertices of G be labelled v1 , v 2 ,K , vn . The adjacency matrix A(G) is the


n × n ( 0, 1)-matrix, where

 1 if v i v j is an edge of G
a ij = 
 0 otherwise

u Since a vertex is never adjacent to itself, A(G) has 0’s on the diagonal.

7 - 10
CS218 CHAPTER 7: GRAPH THEORY

Example 14: A graph G and its adjacency matrix are as follows:

v1 v2 v 3 v4 v 5
v1  0 1 1 0 1
v2  1 0 1 0 1
 1 0 0 0
A (G ) = v3 1
 
v4  0 0 0 0 1
v5  1 1 0 1 0

u A lot of the time a graph does not come conveniently labelled. The graph can have
labels other than v1 , v2 ,K , vn or it may have no labels at all. In either case just
arbitrarily assign labels v1 , v2 ,K , vn to the n vertices of the graph. Different label
assignments will produce different matrices.

u With bipartite graphs however we will always label all the vertices of side A first then
the vertices of side B. This labelling will be the only acceptable labelling format. (To
ensure ease of grading)

Example 15: From the graph G construct A(G)

If we label the graph G as below then A(G) is:

123 4 5
1 0 1 0 0 0
2 1 0 1 1 0
 1 0 1 1
A (G ) = 3 0
 
4 0 1 1 0 0
5 0 0 1 0 0

Example 16: From the adjacency matrix A(H) construct the graph H.

0 1 0 1
1 0 1 1
A (H ) = 
0 1 0 0
 
1 1 0 0

First labelling the rows and columns of the matrix 1, 2, 3, 4 helps us to obtain
the graph H

1 23 4
1 0 1 0 1
2 1 0 1 1
A (H ) = 
3 0 1 0 0
 
4 1 1 0 0

u Notice that the adjacency matrix is symmetric, i.e. that a ij = a ji ∀ i, j

7 - 11
CHAPTER 7: GRAPH THEORY CS218

7.4.2 THE IN CI DENCE MA TRIX

u Suppose G has vertex set V (G ) = {v1 , v2 ,K , vn } and edge set E (G ) = {e1 , e2 ,K , e m }. The
incidence matrix M(G) is the n × m (0,1)-matrix defined by:

1 if vi is an endpoint of e j
m ij = 
 0 otherwise

u Since an edge has two endpoints, there are two 1’s in each column of M(G)

u Each 1 in row i of M(G) corresponds to an edge incident with vi . Thus, the number of
1’s in row i is the degree of vi

Example 17: Find the incidence matrix M = m ij of the graph G below.

e1 e2 e3 e4 e5 e6 e7 e8
v1  1 1 1 0 1 0 0 0
v2  1 0 0 1 0 0 0 0
 1
M = v3 0 0 1 1 0 0 1
 
v4  0 0 0 0 1 1 0 1
v5  0 1 0 0 0 1 1 0

7.4.3 THE DIS TANCE MA TRIX

u The distance between vi and v j , denoted d ij , is the length of the shortest path
connecting vi and v j . If G is connected, d ij is finite for every pair vi , v j . When G is
disconnected, d ij = ∞ for vertices in distinct components and is finite otherwise.

u The distance matrix D(G) is the n × n matrix where [D (G )]ij = d ij

Example 18: Find the distance matrix for the graphs G and H.

v1 v2 v3 v4 v5 u1 u 2 u 3 u 4 u 5
v1  0 1 2 2 3 u1  0 ∞ ∞ 2 1
v2  1 0 1 1 2 u 2 ∞ 0 1 ∞ ∞
 1 1  ∞
D (G ) = v3 2 1 0 D( H ) = u3 ∞ 1 0 ∞
   
v4  2 1 1 0 2 u4  2 ∞ ∞ 0 1
v5  3 2 1 2 0 u5  1 ∞ ∞ 1 0

u The distance matrix is also symmetric.

7 - 12
CS218 CHAPTER 7: GRAPH THEORY

7.5 TRAVERSING GRAPHS

u An interesting part of graph theory is the puzzle in which you try to draw a given
figure without taking your pencil off the paper, and without drawing over a line.

Example 19: See if you can draw each of the graphs below without taking your
pencil off the paper. Before starting, a warning: Only two of them
can be drawn in this manner, and it may matter where you start.

7.5.1 EULERIAN GRAPHS

u Now lets look at a theorem that tells us exactly which figures we can draw without
taking a pencil off the paper. First some definations:

u A walk is a sequence of vertices v0 , v1 , v2 ,K , vk where vi vi+1 is an edge of G. In a walk


we may reuse vertices and/or edges already used.

u A path requires that vertices and edges be distinct.

u A trail is a walk in which the edges (but not necessarily the vertices) are distinct.

u So a path is a special type of trail, and a trail is a special type of walk.

u An Eulerian trail is a trail that includes each edge of the graph.

u If the trail begins and ends at the same vertex, it is said to be closed.

u A bridge is an edge whose removal increases the number of components.

u A graph is Eulerian if it contains a closed Eulerian trail, sometimes called an


Eulerian circuit. In other words a graph is Eulerian if it contains a walk that
includes each edge exactly once and ends at the original vertex.

u A graph is semi-Eulerian if it contains an Eulerian trail (the trail need not be


closed)

7 - 13
CHAPTER 7: GRAPH THEORY CS218

Example 20: Find an Eulerian trail in each of the graphs from example 19, if
possible. Which of the graphs is Eulerian?

For graph G we have the Eulerian trail d, e, a, b, e, c, b, d, c. Other trails


are possible, but each trail must start at c or d. If the trail starts at c, it
will end at d; and if it starts at d it will end at c. Hence G is semi-
Eulerian.

For graph H, we have the Eulerian trial f, g, h, i, j, k, v, m, g, i, k, m, f.


Other trails are also possible. Hence graph H is Eulerian.

Graph L does not contain an Eulerian trail.

u How can one tell if a graph is Eulerian? The answer is contained in the Euler
theorem.

l Euler Theorem:

(i) A connected graph is Eulerian iff each vertex has an even degree.

(ii) A connected graph is semi-Eulerian but not Eulerian iff the graph
contains precisely two vertices having odd degree. Furthermore, the
Eulerian trail must begin at one of the odd vertices and end at the
other.

u To find a closed Eulerian trail in an Eulerian graph use the following algorithm.

l Fleury’s Algorithm: Suppose a graph is Eulerian. To find an Eulerian trail,


begin at any vertex. Record and erase each edge as it is
used, subject to the following condition: Never use a
bridge unless there is no alternative.

Example 21: Apply Fleury’s Algorithm to graph H from example 19

Starting at vertex f, we record and erase the edges in the trail f, g, m. At this
point fm is a bridge and there is an alternative. Use the alternative, thus f, g,
m, v is are trail so far. Now however, vk is a bridge but there is no alternative,
so we use it. Thus, are trail is f, g, m, v, k, i, g, h, i, j, k, m, f

7.5.2 HAMILTONIAN GRAPHS

u A path that contains every vertex of a graph is called a Hamiltonian path.

u If a graph contains a Hamiltonian path it is called semi-Hamiltonian.

u A Hamiltonian cycle is a cycle that includes every vertex. If a graph contains a


Hamiltonian cycle then the graph is Hamiltonian.

l Remark 12: In Hamiltonian problems, one passes through each vertex


exactly once. In Eulerian problems one passes through each
edge exactly once.

7 - 14
CS218 CHAPTER 7: GRAPH THEORY

Example 22: Draw a connected graph having four vertices that is

a. Hamiltonian and Eulerian

b. Hamiltonian and semi-Eulerian (but not Eulerian)

c. Eulerian and semi-Hamiltonian (but not Hamiltonian)

d. Eulerian but not semi-Hamiltonian

e. Hamiltonian but not semi-Eulerian

f. Neither semi-Eulerian nor semi-Hamiltonian

g. Semi-Eulerian and semi-Hamiltonian

Graphs for c and d do not exist.

Example 23: Find a Hamiltonian cycle for each graph below:

A Hamiltonian cycle for G is a, b, f, d, e, c, a

A Hamiltonian cycle in H is g, h, i, j, k, p, t, o, s, n, r, m, q, v, w, x, y, z, u, g

7 - 15
CHAPTER 7: GRAPH THEORY CS218

7.5.3 THE TRAV EL LING SALES MAN PROB LEM

u The travelling salesman problem is related to a Hamiltonian graph. In this type of


problem a salesman plans to visit various locations to show his merchandise. He
would like to stop at each location once and return to the home office while
minimizing his travel time. Thus, we want to find a minimum-weight Hamiltonian
cycle in a weighted graph, where the weights correspond to travel times.

Example 24: Find a minimum-weight Hamiltonian cycle for the weighted graph
below.

We must check all Hamiltonian cycles:

a, b, c, d, e, f, a has weight 28

a, b, d, e, f, c, a has weight 26

a, b, e, d, c, f, a has weight 30

a, c, b, d, e, f, a has weight 26

a, c, d, b, e, f, a has weight 28

Thus we can choose either a, b, d, e, f, c, a or a, c, b, d, e, f, a as our minimum-


weight Hamiltonian cycle.

u As you can see the travelling salesman problem is difficult, even for a small problem.
Unfortunately, there is no efficient method for solving the travelling salesman
problem.

7 - 16
CS218 CHAPTER 7: GRAPH THEORY

7.6 SUMMARY

7.6.1 THEOREMS

l In a graph G, the sum of the degrees of the vertices equals twice the number of
edges.
l Corollary: The sum of the degrees of the vertices of a graph is an even number.

l In a digraph, the sum of the indegrees equals the sum of the outdegrees.
l Euler’s formula: In a connected plane graph with f faces, e edges, and n
vertices, we have the relationship: n − e + f = 2

l Euler Theorem:

(i) A connected graph is Eulerian iff each vertex has an even degree.

(ii) A connected graph is semi-Eulerian but not Eulerian iff the graph
contains precisely two vertices having odd degree. Furthermore, the
Eulerian trail must begin at one of the odd vertices and end at the other.
l Fleury’s Algorithm: Suppose a graph is Eulerian. To find an Eulerian trail,
begin at any vertex. Record and erase each edge as it is
used, subject to the following condition: Never use a
bridge unless there is no alternative.

7.6.2 REMARKS

l A path having n vertices is denoted Pn

l A path using k distinct vertices has length k −1


l A cycle having n vertices is denoted C n
l For graphs A and B, A ⊆ B iff V ( A ) ⊆ V ( B ) and E ( A ) ⊆ E ( B )
l If two graphs are isomorphic, corresponding vertices have the same degree.
l Let G and H be isomorphic with isomorphism f :V (G ) → V ( H ). If v1 , v2 ,K , vk is a
shortest path between vertices v1 and vk in G then f ( v1 ), f ( v 2 ),K f ( v k ) is a shortest
path between vertices f ( v1 ) and f ( v k ) in H

l Some items to check when trying to show that a pair of graphs are not isomorphic
are:

1. The number of vertices

2. The number of components

3. The number of edges

4. The degree sequence

5. The length of the shortest path between pairs of vertices with a given
degree

6. The length of the longest path in the graph

7 - 17
CHAPTER 7: GRAPH THEORY CS218

l Suppose G is a graph having n vertices. Then the following statements are


equivalent:

1. G is a tree

2. G is connected and has n −1 edges

3. G has n −1 edges and no cycles

4. Any two vertices of G are connected by a unique path

5. G contains no cycles, but the addition of any edge to G will produce a single
cycle.
l A simple labelling procedure determines whether G is bipartite:

G is bipartite iff adjacent vertices get distinct labels:

1. Label any vertex a

2. Label all vertices adjacent to a with the label b

3. Next, label all vertices that are adjacent to a vertex just labelled b with label a

4. Repeat steps 2 & 3 until you have labelled all vertices with a distinct label
(bipartite) or you have a conflict (not bipartite)
l G is bipartite iff G does not contain any odd cycles.
l The complete graph K n has n vertices, with every vertex connected to every other
vertex.
l In Hamiltonian problems, one passes through each vertex exactly once. In
Eulerian problems one passes through each edge exactly once.

7 - 18
CS218 CHAPTER 7: GRAPH THEORY

7.7 GRAPH THEORY EXERCISES

u For each of the following graphs

1. List V(G) 2. List E(G)

3. List the degree of each vertex for each graph

4. List the degree sequence of each graph

u Construct graphs with the following vertex and edge sets:

5. V (G ) = {a , b , c, d } E (G ) = {ab , cd , bd , bc}

6. V ( H ) = {e, f , g , h , i, j} E ( H ) = {eh , ej , hi, ij, fh , hj}

7. V ( M ) = {k , m, n , p , q , r} E ( M ) = {km, mp , kp , qr}

u Three graphs have degree sequence 3, 2, 2, 1, 1, 1

8. Find two of them

u Use the following digraphs

9. List the indegree for each vertex

10. List the outdegree for each vertex

11. List the parallel arcs

12. A vertex having indegree 0 is called a transmitter; list all the


transmitters

13. A vertex having outdegree 0 is called a receiver; list all the receivers

7 - 19
CHAPTER 7: GRAPH THEORY CS218

u Explain

14. Why is it easy to spot a vertex that is both a transmitter and a receiver?

15. How you would define a multidigraph?

16. How you would define a pseudodigraph?

17. Why is 5, 3, 3, 2, 1, 1, 1, 1 not the degree sequence of a graph?

18. Why is 5, 2, 1, 1, 1 not the degree sequence of a graph?

u What is the largest number of components a graph can have

19. if it has six vertices and five edges?

20. if it has six vertices and three edges?

21. if it has six vertices and seven edges?

u Using the graph G1

22. List all the paths between a and b

23. Determine what the length of each path between a and b is.

24. Draw three connected subgraphs of G1

25. Draw three disconnected subgraphs of G1

26. Draw the induced subgraph with vertex set {a, b, c, e}

u Graph G has n vertices.

27. What is the minimum number of edges it must have to be connected?

u Explain why each pair of graphs is not isomorphic.

28.

29.

30.

7 - 20
CS218 CHAPTER 7: GRAPH THEORY

u Give a function to show that each of the pairs of graphs are isomorphic.

31.

32.

33.

u Draw all nonisomorphic graphs having the following degree sequences:

34. 3, 3, 2, 1, 1, 1, 1 35. 4, 2, 2, 1, 1, 1, 1

36. 3, 2, 1, 1, 1, 1, 1 37. 5, 3, 2, 2, 2, 1, 1

u Draw each of the following

38. A graph that has degree sequence 2, 1, 1, 0

39. A multidigraph that is not a digraph

40. A pseudograph that is not a multidigraph

41. P6 42. C4 43. C3 44. P3

45. All trees having five or fewer vertices

46. All eleven trees having seven vertices

47. All six trees having six vertices

48. All connected bipartite graphs having five vertices

49. K4 50. K 3,4 51. K6 52. K 2,5

53. A 3-regular graph on eight vertices

54. Two 3-reqular graphs on six vertices (be sure they are not isomorphic)

55. A 4-regular graph on seven vertices

7 - 21
CHAPTER 7: GRAPH THEORY CS218

u Answer and explain

56. Which complete graphs are trees?

57. Which cycles are complete graphs?

58. Which trees are regular?

59. When is K m,n regular?

60. State a property of the incidence matrix of a digraph.

u Show that

61. K m,n has mn edges

u A wheel W n is formed from C n−1 ( n ≥ 4 ) by adding an additional vertex v and edges


from v to each vertex of C n−1. Draw

62. W4 63. W5 64. W6 65. W7

u How many edges are in the following:

66. K 10 67. C8 68. P12 69. K 3,7 70. Wn

u Using the following graphs

71. Redraw them using as few crossing edges as possible.

72. Which graphs are planar?

73. Verify Euler’s formula for the graphs that are planar.

7 - 22
CS218 CHAPTER 7: GRAPH THEORY

u Using the following graphs; Find

74. A (G ) 75. A (H ) 76. [ A (G )] 2 77. [ A (G )] 3


78. out what the number of walks of length 3 from x1 to x5 there are.
79. B (G ) 80. B (H ) 81. D (G ) 82. D(H ) 83. A (L)
84. A (M ) 85. B (L) 86. B (M ) 87. D(M ) 88. D(L)

u Using the following graphs

89. Use Euler’s theorem to determine which graphs are Eulerian or semi-
Eulerian.

90. List an Eulerian trail for each Eulerian graph and each semi-Eulerian
graph.

91. Which graphs are Hamiltonian or semi-Hamiltonian?

92. List a Hamiltonian cycle for each Hamiltonian graph, and list a
Hamiltonian path for each semi-Hamiltonian graph.

u For which values of n are each of the following Eulerian:

93. Kn 94. Pn 95. Cn 96. Wn

u For which values of n are each of the following Hamiltonian:

97. Kn 98. Pn 99. Cn 100. Wn


u For each values of m and n is K m,n

7 - 23
CHAPTER 7: GRAPH THEORY CS218

101. Eulerian? 102. Hamiltonian?

u Draw a connected graph having five vertices that is

103. Hamiltonian and Eulerian

104. Hamiltonian and semi-Eulerian (but not Eulerian)

105. Eulerian and semi-Hamiltonian (but not Hamiltonian)

106. Eulerian but not semi-Hamiltonian

107. Hamiltonian but not semi-Eulerian

108. neither semi-Hamiltonian nor semi-Eulerian

109. semi-Hamiltonian and semi-Eulerian

u Using the following graphs:

110.
Solve the Traveling Salesman problem for each graph.

u Find the adjaceny matrix for

111. K4

112. K 2,3

u Show that the following pairs of graphs are not isomorphic by finding an isomorphic
invariant they do not share.

113.

114.

7 - 24
CS218 CHAPTER 7: GRAPH THEORY

u Using the following two graphs

115. Show that the two graphs are isomorphic by finding the two functions
g :V (G ) → V (G ' )
h: E (G ) → E (G ' )

u Redraw the following bipartite graphs, so that their bipartite natures are evident.

116.

u Draw the graph with the following adjacency matrix

0 1 0 1 0
1 0 0 1 1
0 0 0 1 1
117.
 
1 1 1 0 1
0 1 1 1 0

0 1 1 0 1
1 0 1 0 1
1 1 0 0 0
118.
 
0 0 0 0 1
1 1 0 1 0

u Find the diameters of the following matrics

119. A complete graph of n vertices

120. A complete bipartite graph, K m,n

121. An m-regular graph with n vertices

u For all integers n ≥ 1, show that


n ( n −1 )
122. The number of edges of K n is
2

7 - 25
CHAPTER 7: GRAPH THEORY CS218

u Miscellaneous problems.

123. In a group of 15 people, is it possible for each person to have exactly 3


friends? Explain.

124. How many vertices of K m,n have degree m?

125. How many vertices of K m,n have degree n?

126. What is the total degree of K m,n ?

127. Find a formula in terms of m and n for the number of edges of K m,n .
Explain.

128. Draw all non-isomorphic simple graphs with three vertices.

129. Find the adjacency matrix and the distance matrix corresponding to the
following graph F:

a
d

b
e
c

130. What does it mean for two graphs to G and H to be isomorphic?

131. How would you attempt to show that two graphs are isomorphic?

132. How whould you attempt to show that two graphs are not isomorphic?
List the stuctural properties you would have to consider.

133. Explain what is mean by a bipartite graph.

134. If G is a bipartite graph and G is isomorphic to graph H, is it possible


for H not to be bipartite? Explain.

135. Show that the following graphs are not isomorphic.

a b p q
c

e d
t s
G
H

7 - 26
CHAPTER 8: MATRICES

Chapter Objectives

In this chapter, you will learn:

§ about some operations that can be performed with matrices;

§ about some special types of matrices;

§ how to multiply matrices;

§ how to transform a matrix;

8-1
CHAPTER 8: MATRICES CS218

8.1 MATRICES

8.1.1 MATRIX OPERATIONS

u A matrix is a rectangular table of numbers. The numbers are called entries (or
elements) of the matrix.

u The dimension of the matrix is the number of rows and columns it contains. The
dimension is written in the form:

(Number of rows) × (Number of columns)

where the × is read “by.”

6 −
1 3
Example 1: For the matrix A =  4 2 5 list a 23 , a 31 , and a 12
 
7 1 8

a 23 is the entry in the second row and third column of A. Thus a 23 = 5. Similarly,
a 31 = 7, and a12 = − 1

u An alternative notation used to express the entries of a matrix is ,[ A ] ij instead of .a ij

Algebraic Operations on Matrices


Two matrices A and B are equal if they have the same
Equality dimension and corresponding entries are equal, that is
a ij = b ij for all pairs (i, j)

Two matrices may be added only if they have the same


Addition dimension. To add two matrices, add corresponding
entries.

Two matrices may be subtracted only if they have the


Subtraction same dimension. To subtract two matrices, subtract
corresponding entries.

Scalar To multiply a matrix by a scalar, multiply each entry


Multiplication of the matrix by the scalar.

 a b  6 3
Exercise 1: If A =   and B =   and A = B what are the values of a, b, c,
 c d   9 5
and d?

8-2
CS218 CHAPTER 8: MATRICES

 2 − 1 4  3 5 − 1  1 1 − 4
Example 2: If A =  − , B = , and C =
 3 7 10 12 2 6  2 8 17

Calculate each of the following:

a. A + B b. A − C c. 3B d. A + 2B − C e. B + 5C

 2 − 1 4   3 5 − 1  2 + 3 − 1+ 5 4 + ( − 1)  5 4 3
a. A + B =  − + = − =
 3 7 10 12 2 6  3 + 12 7 + 2 10 + 6  9 9 16

 2 − 1 4   1 1 − 4   2 − 1 − 1− 1 4 − ( − 4 )  1 −
2 8
b. A − C =  − − = − = −
 3 7 10  2 8 17  3 − 2 7 − 8 10 − 17  5 7
− −
1

 3 5 − 1  3 ⋅ 3 3 ⋅ 5 3( − 1 )  9 15 − 3
c. 3B = 3  = =
12 2 6  3 ⋅ 12 3 ⋅ 2 3 ⋅ 6  36 6 18

 2 − 1 4   3 5 − 1  1 1 − 4 
d. A + 2B − C =  − +2 −
 3 7 10 12 2 6  2 8 17
 2 + 6 − 1 − 1+ 10 − 1 4 − 2 + 4   7 8 6 
= − =
 3 + 24 − 2 7 + 4 − 8 10 + 12 − 17 19 3 5 

− − − −
 3 5 1  1 1 4   3 + 5 5 + 5 1− 20  8 10 21
e. B + 5C =  +5 = =
12 2 6  2 8 17 12 + 10 2 + 40 6 + 85  22 42 91

 − 5 8  4 7
Example 3: Find D so that 2D +  = −
 1 3  1 5

 x y
D must be a 2 × 2 matrix, so let D = 
 z w

 2 x − 5 2 y + 8  4 7

 x y  5 8  4 7
Then 2  + = − yields = −
 z w  1 −
3  1 5  2 z + 1 2w − 3  1 5

Thus, using the definition of equality of matrices,


2x − 5 = 4 , 2 y + 8 = 7, 2 z + 1 = − 1 and 2w − 3 = 5

Solving each equation gives us x = 9 2 , y = 1 2 , z = − 1, and w = 4

9 −1 
Therefore, D =  −2 2
 1 4

8-3
CHAPTER 8: MATRICES CS218

Basic Properties of Matrix Addition and Scalar Multiplication


If A, B, and C have the same dimensions, the following laws hold:

1. Associative property of addition: ( A + B ) + C = A + ( B + C )

2. Commutative property of addition: A + B = B + A

3. Distributive properties of scalar multiplication:

a. k ( A + B ) = kA + kB

b. ( k + h ) A = kA + hA

4. Properties of the zero matrix (the matrix having all entries


equal to zero):

a. A +0= A

b. k ⋅0= 0

c. 0⋅ A = 0

8.1.2 TYPES OF MATRICES

u A vector is a list of numbers. If the list is written horizontally in a row then it is called
a row vector. If the list is written vertically in a column then it is called a column
vector.

u A row vector with n entries is a 1× n matrix, and a column vector with m entries is an
m×1 matrix.

Example 4: An example of a row vector is v = [15 3 4]

 15
Example 5: An example of a column vector is v =  − 3
 
 4

l Remark 1: A column vector is not equal to a row vector even if there entries
are the same.

u A matrix is a square matrix if the number of rows equals the number of columns.

u The diagonal of a matrix A consists of all the entries a ii , that is, the entries whose
row and column numbers are equal.

u A diagonal matrix is a square matrix is a square matrix whose only nonzero entries
are diagonal entries. That is, a ij = 0 if i ≠ j

u The identity matrix of order n is the n × n matrix having 1’s on the diagonal and 0’s
elsewhere. The identity matrix is denoted by I n

u The zero matrix is an m × n matrix in which all the entries in the matrix are zero. The
zero matrix is denoted by 0 mn

8-4
CS218 CHAPTER 8: MATRICES

 1 2 3
Example 6: Find the diagonal of the matrix A =  4 5 6
 
 7 8 9

Matrix A is a square matrix since the number of rows is three and the number
of columns is three also. The diagonal of matrix A is the numbers 1, 5, and 9

1 0 0 0
0 1 0 0
Example 7: The matrix  is the identity matrix I
0 0 1 0
 
0 0 0 1

 0 0 0 0
Example 8: The matrix  0 0 0 0 is the zero matrix 0 34
 
 0 0 0 0

8.1.3 MATRIX MULTIPLICATION

Matrix Multiplication
1. In order to multiply AB, the number of columns of A must
be equal to the number of rows of B. The answer matrix
will have the same number of rows as A and the same
number of columns as B.

2. To find the (i, j) entry of the answer matrix, multiply row i


of A into column j of B and add.

l Remark 2: In order to multiply two matrices the number of columns in the


first matrix (vector) must be equal to the number of rows in the
second matrix (vector).
l Remark 3: If you can multiply two matrices, the answer is a matrix, not a
number.

−  9
Example 9: What is [ 2 5] ?
 4 

−  9  9 −
[2 5] = 2 ⋅ 9 + ( − 5 ) ⋅ 4 = 18 − 20 = − 2. Thus [ 2 −
5] = [ 2]
 4   4 

 8
Example 10: What is [ 3 7 2]  − 1 ?
 
 6

 8  8
[ 3 7 2] 1 = 3 ⋅ 8 + 7 ⋅ ( 1) + 2 ⋅ 6 = 24 − 7 + 12 = 29. Thus [ 3 7 2]  − 1 = [ 29]
 −  −

   
 6  6

l Remark 4: For the product AB to be defined, the middle two numbers must
be equal.

8-5
CHAPTER 8: MATRICES CS218

l Remark 5: If the middle numbers of AB are equal, the dimension of AB is


given by the two outside numbers

Thus, if n = k, the answer is an m × h matrix.

Exercise 2: For the following matrices, determine if the multiplication AB


can be performed and if so what is the dimension of the answer
matrix?

a. A is 4 × 3 and B is 3 × 2 b. A is 3 × 2 and B is 3 × 2

c. A is 2 × 4 and B is 4 × 4 d. A is 3 × 1 and B is 1× 2

 11 8
 3 1
Example 11: Calculate  5 − 2  −
   2 6
16 4 

First check to make sure that the multiplication can be performed:


the answer matrix is a 3 × 2 matrix. To get the (1, 1) entry, multiply row 1 of
the first matrix into column 1 of the second: (11⋅ 3 ) + ( 8 ⋅ ( − 2 )) = 33 − 16 = 17. To get
the (1, 2) entry, multiply row 1 of the first matrix into column 2 of the second:
(11⋅ 1) + ( 8 ⋅ 6 ) = 11+ 48 = 59. To get the (2, 1) entry, multiply row 2 of the first
matrix into column 1 of the second: ( 5 ⋅ 3 ) + (( − 2 )( − 2 )) = 15 + 4 = 19. Thus

 11 8  11⋅ 3 + 8( − 2 ) 11⋅ 1+ 8 ⋅ 6  17 59


 5 − 2 
3 1
=  5 ⋅ 3 + ( − 2 )( − 2 ) 5 ⋅ 1+ ( − 2 )6 =  19 − 7
  2 6 

 −   
16 4   16 ⋅ 3 + 4 ( 2 ) 16 ⋅ 1+ 4 ⋅ 6  40 40

l Remark 6: To get the ( i, j ) entry of a matrix AB, multiply row i of matrix A


into column j of matrix B.

8-6
CS218 CHAPTER 8: MATRICES

8.1.4 TRANS FORM ING MA TRI CES

u If A is an m × n matrix, then the transpose of A is the n × m matrix whose first row is


the first column of A, whose second row is the second column of A and so on.

u The transpose of A is denoted A t



 3 1 5
Example 12: Find the transpose of A = 
12 7 6

Since A is a 2 × 3 matrix, the dimension of A t is 3 × 2. The first row of A t is the


first column of A, that is, 3 12. The second row of A t is the second column of
A, that is, 1 7. The third row of A t is the third column of A. Thus, we have

 3 12
A =  1 7
t

− 
 5 6

Example 13: Determine each of the following:


− t
 5 1 9
−3 0 2 2 1 7
a.   b. [1 2 6] t
 8 3 4 

3 16
 −

 15 2 8

a. The transpose has dimension 3 × 4, and the rows of the transpose correspond
to the columns of the given matrix. Thus, we have

 5 −
3 3 15
 −1 0 1 − 2
 
 9 2 6 8

b. First apply the transpose operation. The t applies only to the second matrix
(the row vector that becomes a column vector). We then multiply:

 1
2 1 7 2 1 7 ( 2 ⋅ 1) + (1⋅ 2 ) + ( 7 ⋅ 6 )  46
[ 1 2 6] t
=  2 =  =
 8 3 4   8 3 4     ( 8 ⋅ 1) + (( − 3 ) ⋅ 2 ) + ( 4 ⋅ 6 )  26
− −

 
6

Properties of the Transpose


The transpose satisfies the following properties:

1. ( A t )t = A

2. ( A + B )t = A t + B t

3. ( AB ) t = B t A t

4. ( kA ) t = kA t

l Remark 7: Matrix A is symmetric if A = A t

8-7
CHAPTER 8: MATRICES CS218

8.2 SUMMARY

8.2.1 REMARKS

l A column vector is not equal to a row vector even if there entries are the same.

l In order to multiply two matrices the number of columns in the first matrix
(vector) must be equal to the number of rows in the second matrix (vector)
l If you can multiply two matrices, the answer is a matrix, not a number.

l For the product AB to be defined, the middle two numbers must be equal.
l If the middle numbers of AB are equal, the dimension of AB is given by the two
outside numbers

Thus, if n = k, the answer is an m × h matrix.


l To get the ( i , j ) entry of a matrix AB, multiply row i of matrix A into column j of
matrix B

l Matrix A is symmetric if A = A t

8-8
CS218 CHAPTER 8: MATRICES

8.3 MATRICES EXERCISES

u Evaluate:
 3  12  5 −
5  3 1
 2 − 1 3  8 11 − 15
1.  − 1 +  3 2.  + − − 3.  − 2 3 − 2 7 −
2
  −   0 5 7  2 3 9    − 
 10  2  0 1  8 5

 4 2 7  2 1 − −
4.  − 5. [ 5 2 8 4] + [ 2 7 5]
13

5 8 10 0 

−5 2 3 −
6 13 − 2
u For A =  − 1 0 B = 0
 1 and C =  11 9 evaluate:
 −     − 
 2 6 5 8  7 1

6. B − 2 A 7. C + 3 A − B 8. A + C

9. 4A 10. 1
2 A + 32 B . A + 0.2B − 0.3C
11. 01

u Construct each of the following matrices:

12. 2 × 4 matrix A where a ij = i − 2 j

13. 3 × 3 matrix B where b ij = 3i − 4 ij + j 2

14. 3 × 2 matrix C where cij = max{i, j}

15. 2 × 3 matrix D where d ij = 2i + 7 j

u Solve for the variables in each of the following matrices:

 2x + 5 11  x + 3  5x + 1  10 
16. = 17. + = −
 y − 3  7  2 y + 1  4 y − 2  4 

 3x + 4   4 x − 6  4 x − 3 y  8

18. = 19. = 
 5 y + 2  3 y + 16  x + 2 y  9

 x + 2 y  9
 x + 2 y − 5  12

20.  = 21.  y − 4 w =  25


 3x − y + 2  16    
 2w  − 6

u State the dimension of each of the following matrices:

 12 − 1
 3  − 3 1 4 7 8
22. − 23.  24.  3 6 25. [ 5 5 −
1 0]
 8  1 2 3 1 11

− 
 2 2

8-9
CHAPTER 8: MATRICES CS218

u A company has three factories. Their production output is listed in the following
matrix with the columns representing the four weeks in February:

 320 430 190 318


 212 189 300 260
 
 290 450 385 273

26. How many items did factory 3 produce in the second week of February?

27. How many items did factory 1 produce in the last week of February?

28. What was factory 2’s total output for the month?

29. How many items did the company produce during the second week of
February?

 8 − 1 − 3 7
u For the matrix A =  − 3 9 4 2 list
 − 
 0 1 2 5

30. a13 31. a 22 32. a 32 33. j if a 2 j = − 3

u Find:

 1 3 4   − 21 5 − 9
34. A matrix E so that 5E −  − =
 3 1 7  8 11 43

u Calculate each of the following:

 2
 5 − 7  11 12
3 −
5 6   1 2  4
35.  8 11 36.  − 3 0  − 37. [ 5 8 − 1 10]  − 
2 0 − 4     − 
 3 12 3
 0 2  5 6  
 17

u If B has dimension 5 × 2 and AB is square, what is the dimension of:

38. AB 39. B t 40. BA 41. A

u Simplify:

− −  5 4
 4 3 3   8 17
42.  −  3 − 2 +  −
 1 0 4  −   10 31
 1 0
− −
 1 3 5 7
43. [ − 7 12]  − − [ 9 − 10 11 − 12]
 2 4

6 8

 1 2  2 3
u Let A =  −  and B =  − 
 4 1  2 5

44. Show that AB ≠ BA

8 - 10
CS218 CHAPTER 8: MATRICES

u Find:

45. A 2 × 2 matrix A such that A + A = AA

u Determine each of the following:


− t − t
4 3 6  3 12 2 2
46.  47.  −
1

1 0  6 5

6 1

 2 3  − 5 0
u Let A =  −  and B = 
 5 1  8 6

48. Show ( AB ) t ≠ A t B t 49. ( AB ) t = B t A t

u Answer the question using the rules of matrics.

50. What do you know about the sizes of the matrices A and B if both of the
products AB and BA are defined?

8 - 11
APPENDIX A: GLOSSARY

The following are some of the terms you should be familiar with, or will
encounter during your study of discrete mathematics. You are not
required to memorize these terms. They are presented here to help your
understanding of discrete mathematics.

A-1
APPENDIX A: GLOSSARY CS218

GLOSSARY

u A
Absolute value of a real number: The absolute value of a, written |a|, is the
nonnegative number which is equal to a if a is nonnegative and equal to −a if a is
negative.

Additive inverse: The additive inverse of a number a is the number −a for which
a + (−a ) = 0.

Adjacent vertices: Two vertices that are connected together by an edge.

Antecedent: The first statement in an implication. See hypothesis.

Antisymmetric: A relation is antisymmetric if a related to b and b related to a imply


a = b.

Arc: A segment, or piece, of a curve which has direction.

u B
Biconditional: A biconditional is an equivalence formed from two given
propositions by connecting them by “if, and only if.” An equivalence is true if both
propositions are true, or if both are false. The equivalence formed from propositions
p and q is usually denoted by p ↔ q, or p ≡ q.

Bijection: A bijection from set A to a set B is a one-to-one correspondence between A


and B, i.e., a function from A into B that is both an injection and a surjection.

Binary (binary number system): A system of numerals for representing real


numbers that uses the base 2 instead of the base 10. Only the digits 0 and 1 are
needed.

Binary operation: An operation which is applied to two objects.

Bridge: In a graph G, a bridge is an edge whose removal will increase the number of
components in the graph.

u C
Cardinal (cardinal number): A number which designates the manyness of a set of
things; the number of units, but not the order in which they are arranged; used in
distinction to signed numbers.

Cartesian product: The Cartesian product of two sets A and B is the set (denoted
by A × B) of all pairs ( x, y ) such that x is a member of A and y is a member of B.

Categorical syllogism: A categorical syllogism relates implications with universal


quantifiers, an example of which is: If the propositions “ For any quadrilateral T, if T
is a square, then T is a rectangle” and “For any quadrilateral T, if T is a rectangle,
then T is a parallelogram” are true, then the proposition “For any quadrilateral T, if
T is a square, then T is a parallelogram” is true.

Circuit: A closed walk that does not contain a repeated edge. See trail.

A-2
CS218 APPENDIX A: GLOSSARY

Closed walk: A walk that begins and ends at the same vertex.

Combination: A combination of a set of objects is any subset without regard to


order.

Comparable (comparable functions): Functions f and g which have real-number


values, which have a common domain of definition D, and which are such that either
f ( x ) ≤ g ( x ) for all x in D or f ( x ) ≥ g ( x ) for all x in D.

Complement of a set:The set of all objects that do not belong to the given set U, but
belong to a given whole space (or set) that contains U.

Complete graph: A graph in which any two distinct nodes are joined by exactly one
edge.

Component of a graph: A maximal connected subgraph.

Compostion of functions: Forming a new function h (the composite function)


from given functions g and f by the rule that h ( x ) = g [ f ( x )] for all x in the domain of f
for which f ( x ) is in the domain of g. This composite of h of g and f is writtenas g o f or
gf. The order in which functions are combined is important.

Compostion of relations: Given a relation R and a relation S, the composite


relation R o S is the relation for whichx is related to z if and only if there is an object y
for which xRy and yRz.

Compound event: Suppose S 1 and S 2 are sampe spaces for the outcomes of two
experiments and that E1 and E 2 are events contained in S 1 and S 2 , respectively. Then
the Cartesian product E1 × E 2 is a compound event.

Conclusion: The statement which follows (or is to be proved to follow) as a


consequence of the hypothesis of the theorem.

Conditional probability: If A and B are events, then the conditional probability of


A given B is the probability of A, assuming B holds.

Conditional statement: Same as implication.

Conjunction: The proposition formed from two given propositions by connecting


them with the word and. The conjunction of propositions p and q is usually written as
p ∧ q, or p ⋅ q, and read “ p and q .” The conjunction of p and q is true if and only if both p
and q are true.

Connected graph: A graph is connected if any two nodes can be joined by moving
along edges, otherwise it is disconnected.

Consecutive: Following in order without jumping.

Consequent: The second statement in an implication. See conclusion.

Contradiction: A contradiction is a statement form that is always false regardless


of the truth values of the individual statements substituted for its statement
variables.

Contradiction proof: See indirect proof.

Contradictory statement: A statement whose form is a contradiction.

Contrapositive: The implication which results from replacing the antecedent by


the negation of the consequent and the consequent by the negation of the antecedent.
An implication and its contrapositive are equivalentthey are either both true or

A-3
APPENDIX A: GLOSSARY CS218

both false. The contrapositive of an implication is the converse of the inverse (or the
inverse or the converse) of the implication.

Converse: The theorem (or implication) resulting from interchanging the


hypothesis and conclusion. If an implication is true, its converse my be either true or
false. If an implication p → q and its converse q → p are both true, then the
equivalence p ↔ q is true.

Cycle: In a graph G is a path that begins and ends at the same place.

u D
Dependent events: Two events are dependent if they are not independent.

Disjoint: Two sets are disjoint if there is no object which belongs to each of the sets
(i.e., if the intersection of the sets is the null set).

Difference of sets: The difference A − B of two sets A and B is the set of all objects that
belong to A and do not belong to B.

Direct proof: A direct proof uses an argument that makes direct use of the
hypotheses and arrives at the conclusion.

Directed line (directed edge): A line (or line segment) on which the direction from
one end to the other has been indicated.

Disconnected graph: See connected graph.

Disjoint: Two sets are disjoint if there is no object which belongs to each of the sets
(i.e., if the intersection of the sets is the null set).

Disjunction: The proposition formed from two given propositions by connecting


them with the word or, thereby asserting the truth of one or both of the given
propositions. The disjunction of two propositions is false if and only if both the
propositions are false. The disjunction of propositions p and q is usually written p ∨ q
and read “p or q.” This is the inclusive disjunction, which is ordinarily used in
mathematics.

Domain: The domain of a function is the set of values which the independent
variable may take on, or the range of the independent variable.

u E
Edge: A line or a line segment which is the intersection of two plane faces of a
geometric figure, or which is the boundary of a plane figure.

Elementary event: A single outcome of an experiment.

Elurian circuit: Let G be a graph. AnEulerian circuit for G is a circuit that contains
every vertex and every edge of G. That is, an Eulerian circuit for G is a sequence of
adjacent vertices and edges in G that starts and ends at the same vertex, uses every
vertex of G at least once, and uses every edge of G exactly once.

Elurian path: Let G be a graph and let v and w be two vertices of G. An Eulerian
path from v to w is a sequence of adjacent edges and vertices that starts at v, ends at
w, passes through every vertex of G at least once, and traverses every edge of G
exactly once.

A-4
CS218 APPENDIX A: GLOSSARY

Empty set: The set with no members.

Endpoints: The ends of an edge in a graph.

Equality: The relation of being equal; the statement, usually in the form of an
equation, that two things are equal.

Equivalence of propositions: See biconditional.

Equivalence relation: A relation between elements of a given set which is a


reflexive, symmetric, and transitive relation and which is such that any two elements
of the set are either equivalent or not equivalent.

Equivalent: Two objects that are so related that they are ‘similar’ in such a way that
they can be said to be equal.

Even number: An integer that is divisible by 2. All even numbers can be written in
the form 2n, where n is an integer.

Event: For an experient with a finite or countably infinite number of outcomes, an


event is any subset of the possible outcomes of the experiment.

Exclusive disjunction: The exclusive disjunction of p and q is true if and only if


exactly one of p and q is true.

Existential quantifier: The exixtential quantifier is the prefix “there exists.” It is


symbolized ∃.

u F
Finite geometric sequence: The general form of a finite geometric sequence is
{a , ar, ar 2 , ar 3 ,L , ar n−1}, where a is the first term, r is the common ratio, and ar n−1 is
a (1− r n )
the last term. The sum of the terms is .
1− r

Finite set: A set which contains a finite (limited) number of members; a set which
has, for some integer n, just n members.

Function: An association of exactly one object from one set (the range) with each
object from another set (the domain).

u G
Geometric sequence: A geometric sequence is a sequence for which the ratio of a
term to its predecessor is the same for all terms.

Graph: An abstract mathematical system that consists of a set of objects called


nodes (or vertices or points), a set of objects called edges (or arcs, lines, or segments),
and a function f (the incidence function).

Graph theory: The study of graphs.

u H
Hamiltonian circuit: Given a simple graph G, a Hamiltonian circuit for G is a
simple circuit that includes every vertex of G. That is, a Hamiltonian circuit for G is a

A-5
APPENDIX A: GLOSSARY CS218

sequence of adjacent vertices and distinct edges in which every vertex of G appears
exactly once, and that starts and ends at the same vertex.

Hamiltonian path: Given a graph G and letting v and w be two vertices of G, then a
Hamiltonian path is a path starting a v and ending at w in which every vertex of graph
G appears exactly once.

Hypothesis: An assumed proposition used as a premise in proving something else; a


condition; that from which something follows.

Hypothetical syllogism: A hypothetical syllogism is a particular type of syllogism


which relates three implications ( p , q , r ) and states: “If p implies q, and q implies r,
then p implies r.” This is frequently written as [( p → q ) ∧ ( q → r] → ( p → r )

u I
Image: If A is a subset of the domain of f, then the image of A is denoted by f ( A ) and
is the set of all images of members of A.

Implication: (1) A statement that follows from other given statements. (2) A
proposition formed from two given propositions by connecting them in the form “ IfL,
then L.” The first statement is the antecedent (or bypothesis) and the second is the
consequent (or conclusion). An implication is true in all cases except when the
antecedent is true and the consequent is false. For propositions p and q, the
implication “if p, then q” is usually written as p → q, and is read “p implies q.”

Incidence function: A function defined on the set of edges that assigns to each
directed edged exactly one ordered pair of nodes and to each undirected edge exactly
one unordered pair.

Inclusive disjunction: See disjunction.

Independent events: Two events are independent if the occurance or


nonoccurrence of one of them does not change the probability of the occurrence of the
other event.

Indirect proof: An indirect proof shows that it is impossible for that which is to be
proved to be false, because if it is false some accepted facts are contradicted; in other
words, it assumes the negation of the proposition to be proved and then shows that
this leads to a contradiction.

Induction: A method of proving a law or theorem by showing that it holds in the first
case and showing that, if it holds for all the cases preceding a given one, then it holds
for this case. Before the method can be applied it is necessary that the different cases
of the law depend upon a parameter which takes on the values 0, 1, 2, 3, …. The
essential steps of the proof are as follows: (1) Prove the theorem for the first case. (2)
Prove that if the theorem is true for the nth case (or for the first through nth cases),
then it is true for the ( n +1)th case. (3) Conclude that it must then be true for all cases.
For, if there were a case for which it is not true, there must be a first case for which it
is not true. Because of (1) this is not the first case. But because of (2), it cannot be any
other case [since the previous case could not be true without the next case (known to
be false) being true; it could not be false because the next case is the false case].

Infinite set: A set which is not finite; a set which has an unlimited number of
members; a set which can be put into one-to-one correspondence with a proper part of
itself.

A-6
CS218 APPENDIX A: GLOSSARY

Injection: An injection from a set A to a set B is a function that is one-to-one and


whose domain is A and whose range is contained in B.

Integer: Any of the numbers L , − 4 , − 3, − 2, − 1, 0, 1, 2, 3, 4 ,L

Intersection: The intersection of two sets consists of all the points that belong to
each of the sets. The intersection of sets U and V usually is denoted by U ∩ V .

Inverse image: The inverse image (pre-image) of a set B contained in the range of f
is denoted by f −1 ( B ) and is the subset of the domain whose members have images in
B. In particular, the inverse image of a point y in the range is the set of all x for which
f ( x ) = y.

Inverse of a function: If y = f ( x ) is equivalent to x = g ( y ), then f is the inverse of g


(and vice versa).

Inverse of an implication: The implication which results from replacing both the
antecedent and the consequent by their negations. The converse and the inverse of an
implication are equivalentthey are either both true or both false.

Irrational number: A real number not expressible as an integer or quotient of


integers.

Irreflexive: A relation such that x does not bear the given relation to itself for anyx.

u J

u K

u L
Logically equivalent: Two statements are logically equivalent if they are
equivalent because of their logical form rather than because of mathematical
content.

Loop: An edge that joins a node to itself.

u M
Mathematical induction: See induction.

Multiple edges: Two egdes with the same set of endpoints.

Multiplicative inverse: The multipicative inverse of a nonzero number a is the


number 1a for which a ⋅ ( 1a ) = 1.

u N
Natural numbers: The positive integers. 1, 2, 3, …

Negation: The proposition formed from the given proposition by prefixing “It is
false that,” or simply “not.” The negation of a proposition p is frequently written as

A-7
APPENDIX A: GLOSSARY CS218

~p and read “not p.” The negation of a proposition is true if and only if the
proposition is false.

Negation: The proposition formed from the given proposition by prefixing “It is
false that,” or simply “not.” The negation of a proposition p is frequently written as
~p and read “not p.” The negation of a proposition is true if and only if the
proposition is false.

Node: A dot.

Null set: The set which is emptyhas no members.

u O
Odd integer: A number that is not evenly divisible by 2; any number of the form
2n + 1, where n is an integer.

Ordered pair: A set with two (possibly equal) terms for which one term is
designated as the first and the other as the second.

Ordered n-tuple: Similar to an ordered pair, where the ordered n-tuple ( x1 , x2 ,L , x n )


has the first term x1, the second term x2 , etc.

u P
Pairwise disjoint: A system of more than two sets is pairwise disjoint if each pair of
sets belonging to the system is disjoint.

Parallel arcs: Directed lines in which one is directed from vertex v to vertex w and
the other is directed from vertex w to vertex v.

Path: A sequence of edges that goes from one edge to another through a common
node, but each edge in the sequence occurs only once.

Partial ordering: A relation on a set A that is reflexive, antisymmetric, and


transitive.

Permutation: (1) An ordered arrangement or sequence of all or part of a set of


things. (2) An operation which replaces each of a set of objects by itself or another
object in the set in a one-to-one manner.

Plane: A surface such that a straight line joining any two of its points lies entirely in
the surface.

Power set: Given a set A, the power set of A denoted P ( A ) is the set of all subsets of A.

Pre-image: See inverse image.

Prime number: An integer p which is not 0 or ±1 and is divisible by no integers


except ±1 and ± p.

Probability: Let n be the number of exhaustive, mutually exclusive, and equally


likely cases of an event under a given set of conditions. If m of these cases are known
as the event A, then the probability of event A under the given set of conditions is mn.

Proof: (1) The logical argument which establishes the truth of a statement. (2) The
process of showing by means of an assumed logical process that what is to be proved
follows from certain previously proved or axiomatically accepted propositions.

A-8
CS218 APPENDIX A: GLOSSARY

Proper set: A subset R is a proper subset of a set S if R is a subset of S and R ≠ S .

Proposition: (1) A theorem or problem. (2) A theorem or problem with its proof or
solution. (3) Any statement which makes an assertion which is either true or false, or
which has been designated as true or false.

u Q
Quantifier: Prefixes such as “for every” or “there are.” Quantifiers precede a
propositional function and may be represented symbolically. See universial
quantifier, existential quantifier.

u R
Range: The range of a function is the set of values that the function takes on.

Rational number: A number that can be expressed as an integer or as a quotient of


integers.

Real number: Any rational or irrational number.

Reciprocal: See multiplicative inverse.

Recurrence relation: A recurrence relation for a sequence a 0 , a1 , a 2 ,K is a formula


that relates each term a k to certain of its predecessors a k −1 , a k − 2 ,K , a k − i , where i is a
fixed integer and k is any integer greater than or equal to i. The initial conditions
for such a recurrence relation specify the values of a 0 , a 1 , a 2 ,K , a i −1.

Reflexive relation: A relation of which it is true that, for any x, x bears the given
relation to itself.

Region: A set that is the union of an open connected set and none, some or all of its
boundary points.

Relation: Equality, inequality, or any property that can be said to hold (or not hold)
for two objects in a specified order.

u S
Sequence: A set of quantities ordered as are the positive integers.

Series: The indicated sum of a finite or infinite sequence of terms.

Set: A collection of particular things, as the set of numbers between 3 and 5, the set of
points on a segment of a line, or within a circle, etc.

Simple circuit: A circuit that does not have any other repeated vertex except the
first and the last.

Simple path: A path from v to w that does not contain a repeated vertex.

Subset: If each member of a set A belongs to a set B, then one says that A is contained
in B, B contains A, A is a subset of B, or B is a superset of A.

Superset: See subset.

A-9
APPENDIX A: GLOSSARY CS218

Surjection: A surjection from a set A to a set B is a function whose domain is A and


whose range is B, i.e., a function from A onto B.

Syllogism: A logical statement that involves three propositions, usually called the
major premise, minor premise, and conclusion, the conclusion necessarily being true
if the premises are true.

Symbol: A letter or mark of any sort representing quantities, relations, or


operations.

Symmetric function: A function of two or more variables which remains


unchanged under every interchange of two of the variables; xy + xz + yz is a symmetric
function of x, y, and z.

Symmetric relation: A relation which has the property that if a is related to b, then
b is related in like manner to a.

u T
Tautology: A tautology is a statement form that is always true regardless of the
truth values of the individual statements substituted for its statement variables.

Tautological statement: A statement whose form is a tautology.

Trail: A walk in which the edges (but not necessarily the vertices) are distinct.

Transitive relation: A relation which has the property that if A bears the relation
to B and B bears the same relation to C, then A bears the relation to C.

Transpose of a matrix: The matrix resulting from interchanging the rows and
columns in the given matrix.

Tree: A connected nonempty graph that contains no closed paths.

u U
Undirected edge: A line segment. A line without direction.

Union: The union of of a collection of sets is the set whose members are those objects
that belong to at least one of the given sets. The union of two set U and V is usually
denoted by U ∪ V .

Universial quantifier: The universal quantifier is the prefix “for every”


symbolized ∀.

Universial set: The set of all objects admissible in a particular problem or


discussion.

u V
Vertex: A dot. The endpoints in a graph.

u W
Walk: A finite alternating sequence of adjacent vertices from v to w in a graph G.

A - 10
CS218 APPENDIX A: GLOSSARY

Whole number: (1) One of the integers 0, 1, 2, 3, … (2) A positive integer; i.e., a
natural number.

u X

u Y

u Z
Zero of a function: A value of the argument for which the function is zero.

A - 11

You might also like