Discrete Structures 1.1
Discrete Structures 1.1
Collection Editor:
The Duy Bui
Discrete Structures
Collection Editor:
The Duy Bui
Author:
Duy Bui
Online:
< http://cnx.org/content/col10768/1.1/ >
CONNEXIONS
1
2 CHAPTER 1. DISCRETE STRUCTURES COURSE INFORMATION
1.3 Resources
Course Reading material
MIT's OpenCourseWare
2
Connexions
3
On-line Discrete Math tutorials
4
Students are presumed to be familiar with basic programming techniques, including the use of functions and
procedures, loops and recursion. Also assumed is facility with basic algebra.
Students are also expected to be familiar with the use of standard Internet-based tools including e-mail.
2 http://ocw.mit.edu/index.html
3 http://cnx.org/
4 http://math.about.com/cs/discretemath/
Understand fundamental mathematical concepts as they apply to computer science by seeing how
mathematics supports CS, and how CS concepts can be formalized in mathematics
Illustrate by examples the basic terminology of functions, relations, and sets and demonstrate knowl-
edge of their associated operations.
Establish and solve recurrence relations that arise in counting problems including the problem of
determining the time complexity of recursively dened algorithms.
Model logic statements arising in algorithm correctness and real-life situations and manipulate them
using the formal methods of propositional and predicate logic.
Outline basic proofs for theorems using the techniques of: direct proofs, proof by counterexample,
proof by contraposition, proof by contradiction, and mathematical induction.
Relate the ideas of mathematical induction to recursion and recursively dened structures.
Enhance one's ability to program by seeing how mathematical concepts form the basis for many common
programming problems (e.g. grammars for parsing, predicate calculus for logic programming, sets and
algebras for relational databases, graphs and topological sorting for automating optimization).
Further their ability to write large programs by integrating code from a diverse spectrum of program
components.
Midterm: 20%
Weekly homework: 40%
Final: 40%
Finally, back in Chapter 1 again, we briey study functions. Functions are a special type of relation
and basically the same kind of concept as the ones we see in calculus. However, functions are one of the
most important concepts in the discussion of many subjects on computer and computation, such as data
structures, database, formal languages and automata, and analysis of algorithms, which is briey covered in
Chapter 2.
Unit 2
Task 1: Read the following:
Unit 3
Task 1: Read the following:
Introduction to Logic
What is Proposition
Elements of Propositional Logic
Truth Table
Connectives
Construction of Proposition
Converse and Contrapositive
Textbook p. 11 : 1 all
Textbook p. 11 : 3 all
Textbook p. 11 : 7 a c e g
Textbook p. 12 : 9 b d f h
Textbook p. 13 : 19 all
Textbook p. 13 : 21 a c e
Textbook p. 13 : 23 d f
Reading Material: Chapter Logic - Exercise 16-21
Unit 4
Task 1: Read the following:
Variations of if_then
From English to Proposition
Textbook p. 12 : 15 all
Textbook p. 12 : 17 all
Reading Material: Chapter Logic - Exercise 22-23
Unit 5
Task 1: Read the following:
Introduction to Reasoning
Identities of Propositions and Dual
Example of Use of Identities
Textbook p. 19 : 1 a d f
Textbook p. 19 : 5
Textbook p. 20: 9 b d f
Textbook p. 20: 11 a
Textbook p. 20: 20 all
Textbook p. 20: 25
Reading Material: Chapter Logic - Exercise 24-29
Unit 6
Task 1: Read the following:
Implications
Reasoning with Propositions
Proof of Identities
Proof of Implications
These materials can also be found in Textbook 1.1 - 1.2 and pp. 167 - 173.
Task 2: Do the following exercises: These exercises are NOT homework questions. They are for helping
you understand the materials of this unit.
Unit 7
Task 1: Read the following:
Textbook p. 33 : 3 all
Textbook p. 33 : 5 all
Textbook p. 35 : 19 all
Textbook p. 36 : 23 a c e
Reading Material: Chapter Logic - Exercise 32-35
Unit 8
Task 1: Read the following:
From W to Proposition
English to Logic Translation
Textbook p. 34 : 13 b d f h
Textbook p. 35 : 17 a c e g
Textbook p. 36 : 31 all
Textbook p. 36 : 33 all
Converting English to Logic
Reading Material: Chapter Logic - Exercise 36-39
Unit 9
Task 1: Read the following:
Textbook p. 37 : 35
Textbook p. 183: 9 all
Textbook p. 183: 11 b d
Reading Material: Chapter Logic - Exercise 40-42
Unit 10
Task 1: Read the following:
Textbook p. 37 : 41
Textbook p. 37 : 43 a
Reading Material: Chapter Logic - Exercise 43-44
Unit 11
Task 1: Read the following:
Introduction to Sets
Representation of Set
Textbook p. 45 : 1 a d
Textbook p. 45 : 3 all
Textbook p. 45 : 5 all
Textbook p. 45 : 9
Textbook p. 45 : 13 all
Reading Material: Chapter Set Theory - Exercise 4-8
Unit 12
Task 1: Read the following:
Mathematical Reasoning
Set Operations
Textbook p. 45 : 21
Textbook p. 45 : 23
Textbook p. 54 : 3 all
Textbook p. 54 : 19 a c
Textbook p. 54 : 21
Reading Material: Chapter Set Theory - Exercise 9-13
Unit 13
Task 1: Read the following:
Textbook p. 54 : 7 all
Textbook p. 54 : 9 a
Textbook p. 54 : 15 a
Reading Material: Chapter Set Theory - Exercise 14-16
Recursive Denition
Generalized Set Operations
Textbook p. 55 : 35 a
Textbook p. 55 : 36 b
Textbook p. 210: 21
Textbook p. 210: 23 all
Textbook p. 210: 31 (An empty string is a string with no symbols in it.)
Reading Material: Chapter Recursion - Exercise 5-9
Unit 15
Task 1: Read the following:
Textbook p. 209: 1 a b c
Textbook p. 209: 3 a b
Textbook p. 209: 7
Textbook p. 218: 1
Textbook p. 218: 3
Reading Material: Chapter Recursion - Exercise 10-14
Unit 16
Task 1: Read the following:
Textbook p. 199: 3
Textbook p. 200: 9
Textbook p. 200: 13
Textbook p. 200: 19
Textbook p. 200: 21
Textbook p. 201: 43
Reading Material: Chapter Recursion - Exercise 15-20
Unit 17
Task 2: Do the following exercises: These exercises are NOT homework questions. They are for helping
you understand the materials of this unit.
Textbook p. 199: 5
Textbook p. 202: 59
Reading Material: Chapter Recursion - Exercise 21-22
Introduction to Relation
Binary Relation
Denition of Relation (general relation)
Equality of Relations
Recursive Denition of Relation
Unit 19
Task 1: Read the following:
Digraph
Digraph Representation of Binary Relation
Properties of Binary Relation
These materials can also be found in Textbook 6.3, 7.1 and 7.2.
Task 2: Do the following exercises: These exercises are NOT homework questions. They are for helping
you understand the materials of this unit.
Textbook p. 382: 3 b d f
Textbook p. 382: 5 a c g e
Textbook p. 383: 19 a b
Textbook p. 396: 12
Textbook p. 396: 13
Textbook p. 396: 15
Reading Material: Chapter Relation - Exercise 14-17
Unit 20
Task 1: Read the following:
Textbook p. 383: 19 a b
Textbook p. 383: 21
Textbook p. 383: 35
Textbook p. 406: 1
Textbook p. 406: 3
Textbook p. 406: 11 for 5
Textbook p. 407: 22
Unit 21
Task 1: Read the following:
Equivalence Relation
Order Relation (Partial, Total, and Quasi Orders)
Textbook p. 413: 1 a c e
Textbook p. 413: 5 a b
Textbook p. 413: 9
Textbook p. 413: 11
Textbook p. 414: 23
Textbook p. 414: 25
Textbook p. 414: 31 a b
Reading Material: Chapter Relation - Exercise 23-28
Unit 22
Task 1: Read the following:
Textbook p. 428: 1
Textbook p. 428: 3
Textbook p. 428: 5
Textbook p. 428: 15 a d
Textbook p. 428: 17
Textbook p. 429: 27
Reading Material: Chapter Relation - Exercise 29-31
Unit 23
Task 1: Read the following:
Denitions on Function
Growth of Functions
Textbook p. 67: 1
Textbook p. 67: 5 a c
Textbook p. 67: 10 a b c
Textbook p. 67: 11 a b c
Textbook p. 67: 15 a b
Textbook p. 68: 17 a c
Textbook p. 68: 49
Textbook p. 90: 1
Textbook p. 90: 3
Reading Material: Chapter Function - Exercise 3-9
Unit 24
Task 1: Read the following:
Textbook p. 90: 5
Textbook p. 90: 11
Textbook p. 90: 13
Textbook p. 90: 15
Textbook p. 91: 19 a b
Textbook p. 91: 31
Reading Material: Chapter Function - Exercise 10-14
1 Unit 1, Unit 2
2 Unit 3, Unit 4
Submit Homeworks 1, 2
3 Unit 5, Unit 6
4 Unit 7, Unit 8
Submit Homeworks 3, 4
5 Unit 9, Unit 10
Submit Homeworks 5, 6
Submit Homeworks 7, 8
Submit Homeworks 9, 10
Table 1.1
1.13 Readings
Course Reading Material
Textbook: Kenneth H. Rosen, Discrete Mathematics and Its Applications, 6th edition, McGraw-Hill
Science/Engineering/Math, 2006, ISBN 978-0073312712.
1.14 Reference
Task Force on Computing Curricula. Computing Curricula 2001: Computer Science, Final Report,
December 2001. Available at http://www.sigcse.org/cc2001/
Discrete Mathematical Structures, 5th edition, by B. Kolman, R.C. Busby, and S.C. Ross, published
by Prentice Hall, 2004.
Mathematical Structures for Computer Science, 5th edition, by J.L. Gersting, published by Freeman,
2003.
Essential Discrete Mathematics for Computer Science, by T. Feil and J. Krone, published by Prentice
Hall, 2003.
Discrete Structures, Logic, and Computability, 2nd edition, by J.L. Hein, published by Jones and
Bartlett, 2002.
Discrete Mathematics for Computer Scientists, by J. Truss, published by Addison Wesley, 1999.
Discrete Mathematics with Applications, 3rd edition, by S. Epp, published by Brooks/Cole, 2004.
Discrete Mathematics, 5th edition, by K.A. Ross and C.R.B. Wright, published by Prentice Hall, 2003.
Discrete Mathematics, 4th edition, by J.A. Dossey, A.D. Otto, L.E. Spence, and C.V. Eynden, pub-
lished by Addison Wesley, 2002.
Discrete Mathematics, by S. Washburn, T. Marlowe, and C.T. Ryan, published by Addison Wesley,
1999.
Discrete Mathematics with Graph Theory, 2nd edition, by E.G. Goodaire and M.M. Parmenter, pub-
lished by Prentice Hall, 2002.
Discrete and Combinatorial Mathematics, 5th edition, by R.P. Grimaldi, published by Addison Wesley,
2004.
Discrete Mathematics with Combinatorics, 2nd edition, by J.A. Anderson, published by Prentice Hall,
2004.
Discrete Mathematics: Numbers and Beyond, by S. Barnett, published by Addison Wesley, 1998.
Copying assignments
Allowing another student to copy an assignment from you and present it as their own work
Copying from another student during a test or exam
Referring to notes, textbooks, etc. during a test or exam
Talking during a test or an exam
Not sitting at the pre-assigned seat during a test or exam
Communicating with another student in any way during a test or exam
Having access to the exam/test paper prior to the exam/test
Asking a teaching assistant for the answer to a question during an exam/test
Presenting another's work as your own
Modifying answers after they have been marked
Any other behaviour which attempts unfairly to give you an advantage over other students in the
grade-assessment process
Refusing to obey the instructions of the ocer in charge of an examination.
2.1 Relation
2.1.1 Introduction to Relation
The relation we are going to study here is an abstraction of relations we see in our everyday life such as
those between parent and child, between car and owner, among name, social security number, address and
telephone number etc. We are going to focus our attention on one key property which all the everyday
relations have in common, dene everything that has that property as a relation, and study properties of
those relations. One of the places where relation in that sense is used is data base management systems.
Along with hierarchical and network models of data, the relational model is widely used to represent data
in a database. In this model the data in a database are represented as a collection of relations. Informally,
each relation is like a table or a simple le. For example, consider the following table.
Employee
Table 2.1
Each row of this table represents a collection of data values such as name, address, and telephone number
of a person. Each row is considered an instance of a relation and the table as the collection of the rows is
considered a relation, which is the relation we are going to be studying in this chapter. Operations such as
inserting or deleting entries to or from a table, merging two tables, nding the intersection of two tables,
and searching for certain entries can be described simply and precisely as operations on relations, and known
mathematical results on relations can be utilized without reinventing them. The relational model is exible
(easy to expand, easy to modify) and interface to query languages is simple. It is thus widely used today.
2.1.2 Denitions
2.1.2.1 Binary Relation
Here we are going to dene relation formally, rst binary relation, then general n-ary relation. A relation
in everyday life shows an association of objects of a set with objects of other sets (or the same set) such
15
16 CHAPTER 2. DISCRETE STRUCTURES RELATION
as John owns a red Mustang, Jim has a green Miata etc. The essence of relation is these associations. A
collection of these individual associations is a relation, such as the ownership relation between peoples and
automobiles. To represent these individual associations, a set of "related" objects, such as John and a red
Mustang, can be used. However, simple sets such as {John, a red Mustang} are not sucient here. The
order of the objects must also be taken into account, because John owns a red Mustang but the red Mustang
does not own John, and simple sets do not deal with orders. Thus sets with an order on its members are
needed to describe a relation. Here the concept of ordered pair and, more generally, that of ordered n-tuple
are going to be dened rst. A relation is then dened as a set of ordered pairs or ordered n-tuples.
Denition (ordered pair):
An ordered pair is a set of a pair of objects with an order associated with them. If objects are represented
by x and y, then we write an ordered pair as <x, y> or <y, x>. In general <x, y> is dierent from <y, x>.
Denition (equality of ordered pairs):
Two ordered pairs <a, b> and<c, d> are equal if and only if a = c and b = d. For example, if the
ordered pair <a, b> is equal to <1, 2>, then a = 1, and b = 2. <1, 2> is not equal to the ordered pair
<2, 1>.
Denition (binary relation):
A binary relation from a set A to a set B is a set of ordered pairs <a, b> where a is an element of A and
b is an element of B.
When an ordered pair <a, b> is in a relation R, we write a R b, or <a, b> R. It means that element a
is related to element b in relation R. When A = B, we call a relation from A to B a (binary) relation on A.
Denition (Cartesian product):
The set of all ordered pairs <a, b>, where a is an element of A and b is an element of B, is called the
Cartesian product of A and B and is denoted by A B.
Thus a binary relation from A to B is a subset of Cartesian product A B.
Examples:
If A = {1, 2, 3} and B = {4, 5}, then {<1, 4>, <2, 5>, <3, 5>}, for example, is a binary relation from
A to B.
However, {<1, 1>, <1, 4>, <3, 5>} is not a binary relation from A to B because 1 is not in B.
The parent-child relation is a binary relation on the set of people. <John, John Jr.>, for example, is an
element of the parent-child relation if John is the father of John Jr.
A unary relation represents a property/characteristic, such as tall, rich etc., shared by the members of
A1 listed in the relation.
Inductive Clause: For all x, y and z in N, if <x, y, z> Ra + b = c , then <x + 1, y, z + 1> and <x,
y + 1, z + 1> Ra + b = c.
Extremal Clause: Nothing is in Ra + b = c unless it is obtained from the Basis and Inductive Clauses.
Figure 2.1
2. <x, y> is an arc of G from vertex x to vertex y if and only if <x, y> is in R.
Example: The less than relation R on the set of integers A = {1, 2, 3, 4} is the set {<1, 2>, <1, 3>,
<1, 4>, <2, 3> , <2, 4> , <3, 4> } and it can be represented by the digraph in Figure 2.
Figure 2.2
Figure 2.3
Sometimes we need to refer to part of a given digraph. A partial digraph of a digraph is a digraph
consisting of arbitrary numbers of vertices and arcs of the given digraph, while a subdigraph is a digraph
consisting of an arbitrary number of vertices and all the arcs between them of the given digraph. Formally
they are dened as follows: Denition (subdigraph, partial digraph): Let G = (V, A ) be a digraph. Then
a digraph ( V', A' ) is a partial digraph of G , if V' V , and A' A ( V' V' ) . It is a subdigraph of
G , if V' V , and A' = A ( V'V' )
A partial digraph and a subdigraph of G3 given above are shown in Figure 4.
Figure 2.4
Denition (transitive relation): A relation R on a set A is called transitive if and only if for any a, b, and
c in A, whenever <a, b> R , and <b, c> R , <a, c> R .
Example 8: The relation on the set of integers {1, 2, 3} is transitive, because for <1, 2> and <2, 3>
in , <1, 3> is also in , for <1, 1> and <1, 2> in , <1, 2> is also in , and similarly for the others.
As a matter of fact on any set of numbers is also transitive. Similarly and = on any set of numbers are
transitive.
Figure 5 show the digraph of relations with dierent properties.
(a) is reexive, antisymmetric, symmetric and transitive, but not irreexive.
(b) is neither reexive nor irreexive, and it is antisymmetric, symmetric and transitive.
(c) is irreexive but has none of the other four properties.
(d) is irreexive, and symmetric, but none of the other three.
(e) is irreexive, antisymmetric and transitive but neither reexive nor symmetric.
Figure 2.5
Figure 2.6
Example 2: If R is the parent-child relation on a set of people A, then RR, also denoted by R2, is the
grandparent-grandchild relation on A.
More examples:
The digraphs of R2 for several simple relations R are shown in Figure 7:
Figure 2.7
Figure 2.8
The closures have the following properties. They are stated here as theorems without proof.
Theorem: Let E denote the equality relation, and Rc the inverse relation of binary relation R, all on a
set A, where Rc = {< a, b >|< b, a > R}. Then
1. r(R) = R E
2. s(R) = R Rc
n
3. t(R) = i=1 Ri = i=1 Ri, if |A| = n.
4. R is reexive if and only if r(R) = R.
5. R is symmetric if and only if s(R) = R.
6. R is transitive if and only if t(R) = R.
Example 2: The congruent modulo m relation on the set of integers i.e. {<a, b>| a b (mod m)}, where
m is a positive integer greater than 1, is an equivalence relation.
Note that the equivalence relation on hours on a clock is the congruent mod 12, and that when m = 2,
i.e. the congruent mod 2, all even numbers are equivalent and all odd numbers are equivalent. Thus the set
of integers are divided into two subsets: evens and odds.
Example 3: Taking this discrete structures course together this semester is another equivalence relation.
Equivalence relations can also be represented by a digraph since they are a binary relation on a set. For
example the digraph of the equivalence relation congruent mod 3 on {0, 1, 2, 3, 4, 5 , 6} is as shown in
Figure 9. It consists of three connected components.
Figure 2.9
The set of even numbers and that of odd numbers in the equivalence relation of congruent mod 2, and
the set of integers equivalent to a number between 1 and 12 in the equivalence relation on hours in the clock
example are called an equivalence class. Formally it is dened as follows:
Denition (equivalence class): For an equivalence relation R on a set A, the set of the elements of A that
are related to an element, say a, of A is called the equivalence class of element a and it is denoted by [a].
Example 4: For the equivalence relation of hours on a clock, equivalence classes are
[1] = {1, 13, 25, ... } = {1+ 12n: n N} ,
[2] = {2, 14, 26, ... } = {2+ 12n: n N} ,
........,
where N is the set of natural numbers. There are altogether twelve of them.
For an equivalence relation R on a set A, every element of A is in an equivalence class. For if an element,
say b, does not belong to the equivalence class of any other element in A, then the set consisting of the
element b itself is an equivalence class. Thus the set A is in a sense covered by the equivalence classes.
Another property of equivalence class is that equivalence classes of two elements of a set A are either disjoint
or identical, that is either [a] = [b] or [a] [b] = for arbitrary elements a and b of A. Thus the set A is
partitioned into equivalence classes by an equivalence relation on A. This is formally stated as a theorem
below after the denition of partition.
Denition (partition): Let A be a set and let A1, A2, ..., An be subsets of A. Then {A1, A2, ..., An} is
a partition of A, if and only if
n
(1) i=1 Ai = A, and
(2) Ai Aj = , if Ai 6= Aj , 1 i, j n .
(3) Example 5: Let A = {1, 2, 3, 4, 5}, A1 = {1, 5}, A2 = {3}, and A3 = {2, 4}. Then {A1, A2, A3} is
a partition of A. However, B1 = {1, 2, 5}, B2 = {2, 3}, and B3 = {4} do not form a partition for A because
B1 B2 6=, though B1 6=B2.
Theorem 1: The set of equivalence classes of an equivalence relation on a set A is a partition of A.
Conversely, a partition of a set A determines an equivalence relation on A.
Theorem 2: Let {A1, ..., An} be a partition of a set A. Dene a binary relation R on A as follows: <a,
b> R if and only if a Ai and b Ai for some i, 1 i n . Then R is an equivalence relation.
Example 8: The poset of the powerset of {1, 2} with has the least element .
Denition(well order): A total order R on a set A is a well order if every non-empty subset of A has the
least element.
Example 9: The poset of the set of natural numbers with the less-than-or-equal-to relation is a well order,
because every set of natural numbers has the least element.
The poset of the set of positive real numbers with the less-than-or-equal-to relation is not a well order,
because the set itself does not have any least element (0 is not in the set).
A digraph of a binary relation on a set can be simplied if the relation is a partial order. Hasse diagrams
dened as follows are such graphs.
Denition(Hasse diagram): A Hasse diagram is a graph for a poset which does not have loops and arcs
implied by the transitivity. Further, it is drawn so that all arcs point upward eliminating arrowheads.
To obtain the Hassse diagram of a poset, rst remove the loops, then remove arcs < a, b > if and only
if there is an element c that <> and < c, b > exist in the given relation.
a, c
Example 10: For the relation {< a, a >, < a, b >, < a, c >, < b, b >, < b, c >, < c, c >} on set {a,
b,c}, the Hasse diagram has the arcs {< a, b >, < b, c >} as shown in Figure 10.
Figure 2.10
The elements in a nite poset can be ordered linearly in a number of ways while preserving the partial order.
For example {, {1}, {2}, {1, 2}} with the partial order , can be ordered linearly as , {1}, {2}, {1, 2},
or , {2}, {1}, {1, 2}. In these orders a set appears before (to the left of ) another set if it is a subset of the
other. In real life, tasks for manufacturing goods in general can be partially ordered based on the prerequisite
relation, that is certain tasks must be completed before certain other tasks can be started. For example the
arms of a chair must be carved before the chair is assembled. Scheduling those tasks is essentially the same
as arranging them with a linear order (ignoring here some possible concurrent processing for simplicity's
sake).
The topological sorting is a procedure to nd from a partial order on a nite set a linear order that does
not violate the partial order. It is based on the fact that a nite poset has at least one minimal element.
The basic idea of the topological sorting is to rst remove a minimal element from the given poset, and
then repeat that for the resulting set until no more elements are left. The order of removal of the minimal
elements gives a linear order. The following algorithm formally describes the topological sorting.
Algorithm Topological Sort
Input: A nite poset <A, R >.
Output: A sequence of the elements of A preserving the order R.
integer i;
i := 1;
while ( A 6=) {
pick a minimal element b from A;
A := A - {b};
i := i + 1;
output b
} Example: Let A = {{1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3}} with the partial order . This given
A has three minimal elements {1}, {2}, and {3}.
Select {2} and remove it from A. Let A denote the resultant set i.e. A := A - {2}. The new A has two
minimal elements {1}, and {3}.
Select {1} and remove it from A. Denote by A the resultant set, that is A = {{3}, {1, 2}, {1, 3}, {2, 3},
{1, 2, 3}}.
This new A has two minimal elements {3} and {1, 2}.
Select {1, 2} and remove it from A.
Proceeding in like manner, we can obtain the following linear order: {{2}, {1}, {1, 2}, {3}, {1, 3}, {2,
3}, {1, 2, 3}}.
Figure 2.11
10. List the ordered pairs in the relation R from A = {0,1, 2, 3} to B = {0, 1, 2, 3, 4} where (a, b)
R if and only if
a. a > b.
b. a + b = 3.
c. a divides b.
d. a - b = 0.
e. gcd(a, b) = 1.
f. lcm(a, b) = 6.
11. Recursively dene the relation { ( , a b) | a=2b }, where a and b are natural numbers.
12. List unary relation on {1, 2, 3}.
13. Prove that there are 2n2 binary relations on a set of cardinality n.
14. For each of the following relations on the set {1, 2, 3, 4}, decide whether it is reexive, symmetric,
antisymmetric and/or transitive.
a. {(1, 1), (1, 2), (2, 1), (2, 2), (3, 3), (4, 4)}
b. {(1, 3), (1, 4), (2, 3), (3, 4)}
c. {(1, 1), (1, 3), (1, 4), (2, 1), (2, 3), (2, 4), (3, 1), (3, 3), (3, 4)}
15. Determine whether the relation R on the set of all integers is reexive, symmetric, antisymmetric,
and/or transitive, where ( , x y) R if and only if
a. x is divisible by y.
b. x 6= y.
c. y = x + 2 or y = x - 2.
d. x = y2 + 1.
16. Let A be the set of people in your town. Let R1 be the unary relation representing the people in
your town who were registered in the last election and R2 be the unary relation representing the people in
your town who voted in the last election. Describe the 1-tuples in each of the following relations.
a. R1 R2.
b. R1 R2.
17. Draw the directed graph that represents the relation {( , ), ( , ab a c), (b, c), (c, b), (c, c), (c, d), (d,
a), (d, b)}.
18. Let R be the parent-child relation on the set of people that is, R = { (a, b) | a is a parent of b
}. Let S be the sibling relation on the set of people that is, R a b) | a and b are siblings (brothers
= { ( ,
or sisters) }. What are S oR and R oS?
19. Let R be a reexive relation on a set A. Show that R n is reexive for all positive integers n.
20. Let R be the relation on the set { 1, 2, 3, 4} containing the ordered pairs (1, 1), (1, 2), (2, 2), (2, 4),
(3, 4), and (4, 1). Find
a. the reexive closure ofR
b. symmetric closure of R and
c. transitive closure of R.
21. Let R be the relation { (a, b) | a is a (integer) multiple of b } on the set of integers. What is the
symmetric closure of R?
22. Suppose that a binary relation R on a set A is reexive. Show that R* is reexive, where R*
n i
= i=1 R .
23. Which of the following relations on {1, 2, 3, 4} are equivalence relations? Determine the properties
of an equivalence relation that the others lack.
a. {(1, 1), (2, 2), (3, 3), (4, 4)}
b. {(1, 1), (1, 2), (2, 1), (2, 2), (3, 3), (4, 4)}
c. {(1, 1), (1, 2), (1, 4), (2, 2), (2, 4), (3, 3), (4, 1), (4, 2), (4, 4)}
24. Suppose that A is a nonempty set, and f is a function that has A as its domain. Let R be the
relation on A consisting of all ordered pairs (x, y) where f(x) = f(y).
a. Show that R is an equivalence relation on A.
b. What are the equivalence classes of R?
25. Show that propositional equivalence is an equivalence relation on the set of all compound propositions.
26. Give a description of each of the congruence classes modulo 6.
27. Which of the following collections of subsets are partitions of {1, 2, 3, 4, 5, 6}?
a. {1, 2, 3}, {3, 4}, {4, 5, 6}
b. {1, 2, 6}, {3, 5}, {4}
c. {2, 4, 6}, {1, 5}
d. {1, 4, 5}, {2, 3, 6}
28. Consider the equivalence relation on the set of integers R= { ( x, y) | x - y is an integer}.
a. What is the equivalence class of 1 for this equivalence relation?
b. What is the equivalence class of 0.3 for this equivalence relation?
29. Which of the following are posets?
a. ( Z, = )
b. ( Z, 6=)
c. ( A collection of sets, ).
30. Draw the Hasse diagram for the divisibility relation on the following sets
a. {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
b. {1, 2, 5, 8, 16, 32}
31. Answer the following questions concerning the poset ({{1}, {2}, {3}, {4}, {1, 3}, {1, 4}, {2, 4}, {3,
4}, {1, 2, 4}, {2, 3, 4}},).
a. Find the maximal elements.
b. Find the minimal elements.
c. Is there a greatest element?
d Is there a least element?
e. Find all upper bounds of {{2}, {4}}.
f. Find the least upper bound of {{2}, {4}}, if it exists.
g. Find all lower bounds of {{1, 2, 4}, {2, 3, 4}}
h. Find the greatest lower bound of {{1, 2, 4}, {2, 3, 4}}, if it exists.
35
36 CHAPTER 3. DISCRETE STRUCTURES INTRODUCTION
investing a certain amount every year for certain number of years with a certain expected annual return, we
use variables, say A, R and n, to represent the principal newly invested every year, the return ratio, and the
number of years invested, respectively. With these symbols, the principal and return after n years, denoted
by S, can be expressed as S = A(1 + R) + A(1 + R)2 + ... + A(1 + R)n. As well known, this S can be put
into a more compact form by rst computing S - (1 + R)S as
S = A ( (1 + R)n + 1 - (1 + R) ) / R .
Once we have it in this compact form, it is fairly easy to compute S for dierent values of A, R and n,
though one still has to compute (1 + R)n + 1 . This simple formula represents innitely many cases involving
all dierent values of A, R and n. The derivation of this formula, however, involves another problem. When
computing the compact form for S, S - (1 + R)S was computed using S = A(1 + R) + A(1 + R)2
+ ... + A(1 + R)n . While this argument seems rigorous enough, in fact practically it is a good enough
argument, when one wishes to be very rigorous, the ellipsis ... in the sum for S is not considered precise. You
are expected to interpret it in a certain specic way. But it can be interpreted in a number of dierent ways.
In fact it can mean anything. Thus if one wants to be rigorous, and absolutely sure about the correctness
of the formula, one needs some other way of verifying it than using the ellipsis. Since one needs to verify it
for innitely many cases (innitely many values of A, R and n), some kind of formal approach, abstracted
away from actual numbers, is required.
Suppose now that somehow we have formally veried the formula successfully and we are absolutely sure
that it is correct. It is a good idea to write a computer program to compute that S, especially with (1 + R)n
+ 1 to be computed. Suppose again that we have written a program to compute S. How can we know that
the program is correct? As we know, there are innitely many possible input values (that is, values of A, R
and n). Obviously we can not test it for innitely many cases. Thus we must take some formal approach.
Related to the problem of correctness of computer programs, there is the well known "Halting Problem".
This problem, if put into the context of program correctness, asks whether or not a given computer program
stops on a given input after a nite amount of time. This problem is known to be unsolvable by computers.
That is, no one can write a computer program to answer that question. It is known to be unsolvable. But,
how can we tell it is unsolvable? How can we tell that such a program can not be written? You can not
try all possible solution methods and see they all fail. You can not think of all (candidate) methods to
solve the Halting Problem. Thus you need some kind of formal approaches here to avoid dealing with an
extremely large number (if not innite) of possibilities. Discrete mathematics is the foundation for the formal
approaches. It discusses languages used in mathematical reasoning, basic concepts, and their properties and
relationships among them. Though there is no time to cover them in this course, discrete mathematics is also
concerned with techniques to solve certain types of problems such as how to count or enumerate quantities.
The kind of counting problems includes: How many routes exist from point A to point B in a computer
network? How much execution time is required to sort a list of integers in increasing order? What is the
probability of winning a lottery? What is the shortest path from point A to point B in a computer network?
...
The subjects covered in this course include propositional logic, predicate logic, sets, relations, and func-
tions, in particular growth of function. The rst subject is logic. It is covered in Chapter 1 of the textbook.
It is a language that captures the essence of our reasoning, and correct reasoning must follow the rules
of this language. We start with logic of sentences called propositional logic, and study elements of logic,
(logical) relationships between propositions, and reasoning. Then we learn a little more powerful logic called
predicate logic. It allows us to reason with statements involving variables among others. In Chapter 1 we
also study sets, relations between sets, and operations on sets. Just about everything is described based
on sets, when rigor is required. It is the basis of every theory in computer science and mathematics. In
Chapter 3 we learn mathematical reasoning, in particular recursive denitions and mathematical induction.
There are sets, operations and functions that can be dened precisely by recursive denitions. Properties of
those recursively dened objects can be established rigorously using proof by induction. Then in Chapter
6 we study relations. They are an abstraction of relations we are familiar with in everyday life such as
husband-wife relation, parent-child relation and ownership relation. They are also one of the key concepts
in the discussion of many subjects on computer and computation. For example, a database is viewed as
a set of relations and database query languages are constructed based on operations on relations and sets.
Graphs are also covered briey here. They are an example of discrete structures and they are one of the most
useful models for computer scientists and engineers in solving problems. More in-depth coverage of graph
can be found in Chapter 7. Finally back in Chapter 1 we study functions and their asymptotic behaviors.
Functions are a special type of relation and basically the same kind of concept as the ones we see in calculus.
However, function is one of the most important concepts in the discussion of many subjects on computer and
computation such as data structures, database, formal languages and automata, and analysis of algorithms
which is briey covered in Chapter 2.
4.1.2.1 Proposition
4.1.2.1.1 What Is Proposition?
Sentences considered in propositional logic are not arbitrary sentences but are the ones that are either true
or false, but not both. This kind of sentences are called propositions. If a proposition is true, then we say
it has a truth value of "true"; if a proposition is false, its truth value is "false".
39
40 CHAPTER 4. DISCRETE STRUCTURES LOGIC
For example, "Grass is green", and "2 + 5 = 5" are propositions. The rst proposition has the truth
value of "true" and the second "false".
But "Close the door", and "Is it hot outside?" are not propositions. Also "x is greater than 2", where x
is a variable representing a number, is not a proposition, because unless a specic value is given to x we can
not say whether it is true or false, nor do we know what x represents.
Similarly "x = x" is not a proposition because we don't know what "x" represents hence what "=" means.
For example, while we understand what "3 = 3" means, what does "Air is equal to air" or "Water is equal
to water" mean? Does it mean a mass of air is equal to another mass or the concept of air is equal to the
concept of air? We don't quite know what "x = x" mean. Thus we can not say whether it is true or not.
Hence it is not a proposition.
OR
W
P Q (P Q)
F F F
F T T
T F T
T T T
Table 4.1
W
In the table, F represents truth value false and T true. This table shows that P Q is false if P and Q
are both false, and it is true in all the other cases.
shown using truth table. In the tables P and Q represent arbitrary propositions, and true and false are
represented by T and F, respectively.
NOT
P P
T F
F T
Table 4.2
This table shows that if P is true, then (P) is false, and that if P is false, then (P) is true.
AND
V
P Q (P Q)
F F F
F T F
T F F
T T T
Table 4.3
V
This table shows that (P Q) is true if both P and Q are true, and that it is false in any other case.
Similarly for the rest of the tables.
OR
W
P Q (P Q)
F F F
F T T
T F T
T T T
Table 4.4
IMPLIES
P Q (PQ)
F F T
F T T
T F F
T T T
Table 4.5
When PQ is always true, we express that by P Q. That is P Q is used when proposition P always
implies proposition Q regardless of the value of the variables in them.
IF AND ONLY IF
P Q ( P Q )
F F T
F T F
T F F
T T T
Table 4.6
When P Q is always true, we express that by P Q. That is is used when two propositions always
take the same value regardless of the value of the variables in them.
On the other hand, the contrapositive of a proposition is always logically equivalent to the proposition.
That is, they take the same truth value regardless of the values of their constituent variables. Therefore, "If
it rains, then I get wet." and "If I don't get wet, then it does not rain." are logically equivalent. If one is
true then the other is also true, and vice versa.
If p, then q.
p implies q.
If p, q.
p only if q.
p is sucient for q.
q if p.
q whenever p.
q is necessary for p.
It is necessary for p that q.
For instance, instead of saying "If she smiles then she is happy", we can say "If she smiles, she is happy",
"She is happy whenever she smiles", "She smiles only if she is happy" etc. without changing their truth
values.
"Only if" can be translated as "then". For example, "She smiles only if she is happy" is equivalent to "If
she smiles, then she is happy".
Note that "She smiles only if she is happy" means "If she is not happy, she does not smile", which is the
contrapositive of "If she smiles, she is happy". You can also look at it this way: "She smiles only if she is
happy" means "She smiles only when she is happy". So any time you see her smile you know she is happy.
Hence "If she smiles, then she is happy". Thus they are logically equivalent.
Also "If she smiles, she is happy" is equivalent to "It is necessary for her to smile that she is happy". For
"If she smiles, she is happy" means "If she smiles, she is always happy". That is, she never fails to be happy
when she smiles. "Being happy" is inevitable consequence/necessity of "smile". Thus if "being happy" is
missing, then "smile" can not be there either. "Being happy" is necessary "for her to smile" or equivalently
"It is necessary for her to smile that she is happy".
V
[ [ P Q ] P ] Q,
or
P Q
P
Q This representation is concise, much simpler and much easier to deal with. In addition today there
are a number of automatic reasoning systems and we can verify our arguments in symbolic form using them.
One such system called TPS is used for reasoning exercises in this course. For example, we can check the
correctness of our argument using it.
To convert English statements into a symbolic form, we restate the given statements using the building
block sentences, those for which symbols are given, and the connectives of propositional logic (not, and, or,
if_then, if_and_only_if ), and then substitute the symbols for the building blocks and the connectives. For
example, let P be the proposition "It is snowing", Q be the proposition "I will go the beach", and R be the
proposition "I have time".
Then rst "I will go to the beach if it is not snowing" is restated as "If it is not snowing, I will go to the
beach". Then symbols P and Q are substituted for the respective sentences to obtain P Q.
Similarly, "It is not snowing and I have time only if I will go to the beach" is restated as "If it is not
V
snowing and I have time, then I will go to the beach", and it is translated as (P R ) Q.
4.1.2.4 Identities
From the denitions (meaning) of connectives, a number of relations between propositions which are useful
in reasoning can be derived. Below some of the often encountered pairs of logically equivalent propositions,
also called identities, are listed.
These identities are used in logical reasoning. In fact we use them in our daily life, often more than one
at a time, without realizing it.
If two propositions are logically equivalent, one can be substituted for the other in any proposition in
which they occur without changing the logical value of the proposition.
Below corresponds to and it means that the equivalence is always true (a tautology), while
means the equivalence may be false in some cases, that is in general a contingency.
That these equivalences hold can be veried by constructing truth tables for them.
First the identities are listed, then examples are given to illustrate them.
List of Identities:
W W
1. P (P VP) idempotence of V
2. P (P P) idempotence of
W W W
3. (P Q) (Q
V VP) commutativity of V
4. (P
WQ) W(Q P) W commutativity
W of
W
5. [(P Q) R] [P (Q R)] associativity of
V V V V V
6. [(P
WQ) R] [PV (Q R)] associativity of
7. (P
VQ) ( P W Q) DeMorgan's Law
8. (P
V Q)W( P VQ)W DeMorgan's Law
V V W
9. [P (Q R] [(P
W V W V(P WR)] distributivity of Wover V
Q)
10. [P
W(Q R] [(P Q) (P R)] distributivity of over
11. (P
VTrue) True
12. (P
WFalse) False
13. (P
VFalse) P
14. (P
WTrue) P
15. (P
VP) True
16. (P P) False
17. P ( P) double negation
W
18. (P Q) ( P Q) implication
V
19. (P Q) [(P Q) (Q P)] equivalence
V
20. [(P Q) R] [P (QR)] exportation
V
21. [(P Q) (PQ)] P absurdity
22. (P Q) (Q P) contrapositive
Let us see some example statements in English that illustrate these identities.
W W
Examples: 1. P (P P) idempotence of
What this says is, for example, that "Tom is happy." is equivalent to "Tom is happy or Tom is happy".
This and the next identity are rarely used, if ever, in everyday life. However, these are useful when manip-
ulating propositions in reasoning in symbolic form.
V V
2. P (P P) idempotence of
Similar to 1. above.
W W W
3. (P Q) (Q P) commutativity of
What this says is, for example, that "Tom is rich or (Tom is) famous." is equivalent to "Tom is famous
or (Tom is) rich".
V V V
4. (P Q) (Q P) commutativity of
What this says is, for example, that "Tom is rich and (Tom is) famous." is equivalent to "Tom is famous
and (Tom is) rich".
W W W W W
5. [(P Q) R] [P (Q R)] associativity of
What this says is, for example, that "Tom is rich or (Tom is) famous, or he is also happy." is equivalent
to "Tom is rich, or he is also famous or (he is) happy".
V V V V V
6. [(P Q) R] [P (Q R)] associativity of
Similar to 5. above.
W V
7. (P Q) ( P Q) DeMorgan's Law
For example, "It is not the case that Tom is rich or famous." is true if and only if "Tom is not rich and
he is not famous."
V W
8. (P Q) ( P Q) DeMorgan's Law
For example, "It is not the case that Tom is rich and famous." is true if and only if "Tom is not rich or
he is not famous."
V W V W V V W
9. [P (Q R] [(P Q) (P R)] distributivity of over
What this says is, for example, that "Tom is rich, and he is famous or (he is) happy." is equivalent to
"Tom is rich and (he is) famous, or Tom is rich and (he is) happy".
W V W V W W V
10. [P (Q R] [(P Q) (P R)] distributivity of over
Similarly to 9. above, what this says is, for example, that "Tom is rich, or he is famous and (he is)
happy." is equivalent to "Tom is rich or (he is) famous, and Tom is rich or (he is) happy".
W W
11. (P True) True. Here True is a proposition that is always true. Thus the proposition (P True)
is always true regardless of what P is.
This and the next three identities, like identities 1 and 2, are rarely used, if ever, in everyday life. However,
these are useful when manipulating propositions in reasoning in symbolic form.
V
12. (P
WFalse) False
13. (P
VFalse) P
14. (P
WTrue) P
15. (P P) True
What this says is that a statement such as "Tom is 6 foot tall or he is not 6 foot tall." is always true.
V
16. (P P) False
What this says is that a statement such as "Tom is 6 foot tall and he is not 6 foot tall." is always false.
17. P ( P) double negation
What this says is, for example, that "It is not the case that Tom is not 6 foot tall." is equivalent to "Tom
is 6 foot tall."
W
18. (P Q) ( P Q) implication
For example, the statement "If I win the lottery, I will give you a million dollars." is not true, that is, I
am lying, if I win the lottery and don't give you a million dollars. It is true in all the other cases. Similarly,
the statement "I don't win the lottery or I give you a million dollars." is false, if I win the lottery and don't
give you a million dollars. It is true in all the other cases. Thus these two statements are logically equivalent.
V
19. (P Q) [(P Q) (Q P)] equivalence
What this says is, for example, that "Tom is happy if and only if he is healthy." is logically equivalent to
""if Tom is happy then he is healthy, and if Tom is healthy he is happy."
V
20. [(P Q) R] [P (Q R)] exportation
For example, "If Tom is healthy, then if he is rich, then he is happy." is logically equivalent to "If Tom
is healthy and rich, then he is happy."
V
21. [(P Q) (PQ)] P absurdity
For example, if "If Tom is guilty then he must have been in that room." and "If Tom is guilty then he
could not have been in that room." are both true, then there must be something wrong about the assumption
that Tom is guilty.
22. (P Q) (Q P) contrapositive
For example, "If Tom is healthy, then he is happy." is logically equivalent to "If Tom is not happy, he is
not healthy."
The identities 1 16 listed above can be paired by duality relation, which is dened below, as 1 and 2,
3 and 4, ..., 15 and 16. That is 1 and 2 are dual to each other, 3 and 4 are dual to each other, .... Thus if
you know one of a pair, you can obtain the other of the pair by using the duality.
4.1.2.4.3 Implications
The following implications are some of the relationships between propositions that can be derived from the
denitions (meaning) of connectives. below corresponds to and it means that the implication always
holds. That is it is a tautology.
These implications are used in logical reasoning. When the right hand side of these implications is
substituted for the left hand side appearing in a proposition, the resulting proposition is implied by the
original proposition, that is, one can deduce the new proposition from the original one.
First the implications are listed, then examples to illustrate them are given. List of Implications:
W
1. P
V(P Q) addition
2. (P
V Q) P simplication
3. [P (P Q] Q modus ponens
V
[(P Q)
4.
V WQ] P modus tollens
[ P
5. (P
V Q] Q disjunctive syllogism
6. [(P Q) (QR)] (PR) hypothetical syllogism
7. (PQ) [(QR)(PR)]
V V V
[(PQ)
8.
V(RS)] [(P R)(Q S)]
9. [(P Q) (Q R)] (P R)
Examples:
W
1. P (P Q) addition
For example, if the sun is shining, then certainly the sun is shining or it is snowing. Thus
"if the sun is shining, then the sun is shining or it is snowing." "If 0 < 1, then 0 1 or a similar statement
is also often seen.
V
2. (P Q) P simplication
For example, if it is freezing and (it is) snowing, then certainly it is freezing. Thus "If it is freezing and
(it is) snowing, then it is freezing."
V
3. [P (P Q] Q modus ponens
For example, if the statement "If it snows, the schools are closed" is true and it actually snows, then the
schools are closed.
This implication is the basis of all reasoning. Theoretically, this is all that is necessary for reasoning.
But reasoning using only this becomes very tedious.
V
4. [(P Q) Q] P modus tollens
For example, if the statement "If it snows, the schools are closed" is true and the schools are not closed,
then one can conclude that it is not snowing. Note that this can also be looked at as the application of the
contrapositive and modus ponens. That is, (PQ) is equivalent to ( Q )( P ). Thus if in addition Q
holds, then by the modus ponens,
V W P is concluded.
5. [ P (P Q] Q disjunctive syllogism
For example, if the statement "It snows or (it) rains." is true and it does not snow, then one can conclude
that it rains.
V
6. [(PQ) (QR)] (PR) hypothetical syllogism
For example, if the statements "If the streets are slippery, the school buses can not be operated." and "If
the school buses can not be operated, the schools are closed." are true, then the statement "If the streets
are slippery, the schools are closed." is also true.
7. (PQ) [(QR)(PR)]
This is actually the hypothetical syllogism in another form. For by considering (PQ) as a proposition
S, (QR) as a proposition T, and (PR) as a proposition U in the hypothetical syllogism above, and then
by applying the "exportation" from the identities, this is obtained.
V V V
8. [(PQ) (RS)] [(P R)(Q S)]
For example, if the statements "If the wind blows hard, the beach erodes." and "If it rains heavily, the
streets get ooded." are true, then the statement "If the wind blows hard and it rains heavily, then the beach
erodes and the streets get ooded." is also true.
V
9. [(P Q) (Q R)] (P R)
This just says that the logical equivalence is transitive, that is, if P and Q are equivalent, and if Q and
R are also equivalent, then P and R are equivalent.
Table 4.7
W
T W
T
which is correct by disjunctive syllogism.
Thus we can conclude that the given argument is correct.
To save space we also write this process as follows eliminating one of the W's:
D
W D
W
W
T W
T
W
P Q (P Q)
F F F
F T T
T F T
T T T
Table 4.8
W W
A truth table for (Q P) is, by the denition of ,
W
P Q (Q P)
F F F
F T T
T F T
T T T
Table 4.9
W W
As we can see from these tables (P Q) and (Q P) take the same value for the same set of value of P
and Q. Thus they are (logically) equivalent.
We can also put these two tables into one as follows:
W W
P Q (P Q) (Q P)
F F F F
F T T T
T F T T
T T T T
Table 4.10
Using this convention for truth table we can show that the rst of De Morgan's Laws also holds.
W V
P Q (P Q) P Q
F F T T
F T F F
T F F F
T T F F
Table 4.11
W V
By comparing the two right columns we can see that (P Q) and P Q are equivalent.
W
P Q (P Q)
F F F
F T T
T F T
T T T
Table 4.12
W
Then by the denition of , we can add a column for P (P Q) to obtain the following truth table.
W W
P Q (P Q) P (P Q)
F F F T
F T T T
T F T T
T T T T
Table 4.13
The rst row in the rightmost column results since P is false, and the others in that column follow since
W
(P Q) is true.
W
The rightmost column shows that P (P Q) is always true.
2. Some of the implications can also be proven by using identities and implications that have already
been proven.
For example suppose that the identity "exportation":
V
[(X Y) Z] [X (YZ)] ,
and the implication "hypothetical syllogism":
V
[(PQ) (QR)] (PR)
have been proven. Then the implication No. 7:
(PQ) [(QR)(PR)]
can be proven by applying the "exportation" to the "hypothetical syllogism" as follows:
Consider (PQ) , (QR) , and (PR) in the "hypothetical syllogism" as X, Y and Z of the "exporta-
tion", respectively.
V V
Then since [ (X Y )Z ] [ X( YZ ) ] implies [ ( X Y )Z ] [ X(YZ ) ] , the implication
of No. 7 follows.
Similarly the modus ponens (implication No. 3) can be proven as follows:
W
Noting that ( PQ ) ( P Q ) ,
V
P ( PQ )
V W
P V ( P
WQ )
V
( PW PV) ( P Q ) by the distributive law
F V ( P Q )
( P Q )
Q V
Also the exportation (identity No. 20), ( P( QR ) ) ( P Q )R ) can be proven using identities
as follows:
W
( P ( Q R ) )
W W P ( Q R )
P W ( Q R )
W
( P
V Q )
W R
( PV Q ) R
( P Q ) R
3. Some of them can be proven by noting that a proposition in an implication can be replaced by an
equivalent proposition without aecting its value.
For example by substituting ( QP ) for ( PQ ) , since they are equivalent being contrapositive to
V
each other, modus tollens (the implication No. 4): [ ( PQ ) Q ] P , reduces to the modus ponens:
V
[ X ( XY ) ] Y. Hence if the modus ponens and the "contrapositive" in the "Identities" have been
proven, then the modus tollens follows from them.
"Not all cars are expensive" is equivalent to "Some cars are not expensive",
... .
Each of those propositions is treated independently of the others in propositional logic. For example, if
P represents "Not all birds y" and Q represents "Some integers are not even", then there is no mechanism
in propositional logic to nd out tha P is equivalent to Q. Hence to be used in inferencing, each of these
equivalences must be listed individually rather than dealing with a general formula that covers all these
equivalences collectively and instantiating it as they become necessary, if only propositional logic is used.
Thus we need more powerful logic to deal with these and other problems. The predicate logic is one of
such logic and it addresses these issues among others.
Similarly the existential quantier turns, for example, the statement x > 1 to "for some object x in the
universe, x > 1", which is expressed as "x x > 1." Again, it is true or false in the universe of discourse, and
hence it is a proposition once the universe is specied.
The universe of discourse contains (but is not limited to) all living creatures.
4.1.3.3.3 Equivalence
Two ws W1 and W2 are equivalent if and only if W1 W2 is valid, that is if and only if W1 W2 is true
for all interpretations.
V
For example
V x P(x) and x P(x) are equivalent for any predicate name P. So are x [ P(x) Q(x) ]
and [ x P(x) x Q(x) ] for any predicate names P and Q .
than the universe of integers. In such a case the element type is specied as a precondition using if_then
construct.
Examples: In the examples that follow the universe is the set of numbers including real numbers, and
complex numbers. I(x), E(x) and O(x) representing "x is an integer", "x is even", and "x is odd", respectively.
"All integers are even" is transcribed as
x [ I(x) E(x)]
It is rst restated as "For every object in the universe (meaning for every numnber in this case) if it is
integer, then it is even". Here we are interested in not any arbitrary object(number) but a specic type of
objects, that is integers. But if we write x it means "for any object in the universe". So we must say "For
any object, if it is integer .." to narrow it down to integers.
"Some integers are odd" can be restated as "There are objects that are integers and odd", which is
expressed as
V
x [ I(x) E(x)]
"A number is even only if it is integer" becomes
x [ E(x)I(x)]
"Only integers are even" is equivalent to "If it is even, then it is integer". Thus it is translated to
x [ E(x)I(x)]
4.1.3.5.1.2 Example
As an example of inference using these rules, let us consider the following reasoning:
A check is void if it has not been cashed for 30 days. This check has not been cashed for 30 days.
Therefore this check is void. You can not cash a check which is void. Therefore you can not cash this check.
We now have a check which can not be cashed.
This can be put into symbolic form using the following predicates assuming the universe is the set of all
objects:
C(x): x is a check.
T(x): x has been cashed within 30 days.
V(x): x is void.
S(x): x can be cashed.
This_check represents a specic object in the universe which corresponds to "this check".
V
x [ [ C(x) T(x) ] V(x) ]
T( This_check )
V( This_check )
V
x [ [ C(x) V(x) ] S(x) ]
-
S( This_check )
V
x [ C(x) S(x) ] .
Here the reasoning proceeds as follows:
V
From x
VT(x) ] V(x) ] by Universal Instantiation
[ [ C(x)
[ [ C( This_check ) T( This_check ) ] V( This_check ) ]
Since This_check is a check and T( This_check ) ,
V
[ C( This_check ) T( This_check ) ] holds.
Hence
V
[ [ C( This_check )
V T( This_check ) ] V( This_check ) ]
[ C( This_check ) T( This_check ) ]
V( This_check )
by Modus Ponens.
V
Then from x [ [ C(x)
V V(x) ] S(x) ] by Universal Instantiation,
[ [ C( This_check ) V( This_check ) ] S( This_check ) ]
Since V( This_check ) , and C( This_check ),
V
[ [ C( This_check )
V V( This_check ) ] S( This_check ) ]
[ C( This_check ) V( This_check ) ]
-
S( This_check )
by Modus Ponens.
Since C( This_check ) also holds,
S( This_check )
C( This_check )
-
V
C( This_check ) S( This_check )
V
Then by Existential Generalization x [ C( x ) S(x) ] .
Figure 4.1
That is, LHS says everyone is rich and happy, and RHS says everyone is rich and everyone is happy. Thus
LHS and RHS describe the same situation. That is, LHS is true if and only if RHS is true.
W W
2. [ x P(x) x Q(x) ] x [ P(x) Q(x) ] for the same interpretation as 1. above can be shown in
Figure 2:
Figure 4.2
That is, LHS says everyone is rich or everyone is happy, and RHS says everyone is rich or happy. Thus
if LHS is true, then RHS is certainly true. However on RHS it can happen that two people are rich but the
third is not rich but happy. In that case LHS is not true while RHS is true. Thus RHS does not necessarily
imply LHS.
W W
3. x [ P(x) Q(x) ] [ x P(x) x Q(x) ] , again for the same example, can be shown in Figure 3:
Figure 4.3
LHS says someone is rich or happy, and RHS says someone is rich or someone is happy. Thus clearly LHS
implies RHS. Also if someone is rich then that person is certainly rich or happy. Thus RHS implies LHS.
V V
4. x [ P(x) Q(x) ] [ x P(x) x Q(x) ] , for the same example, can be shown in Figure 4:
Figure 4.4
LHS say someone is rich and happy. Hence there is someone who is rich and there is someone who is
happy. Hence LHS implies RHS. However, since RHS can be true without anyone being rich and happy at
the same time, RHS does not necessarily imply LHS.
Table 1
P Q Proposition Z
F F F
T F T
T T T
T F T
Table 4.14
Table 2
P Q Proposition Z
F F F
T F T
T T F
Table 4.15
Table 3
P Q Proposition Z
F F F
F T T
T F T
T T T
Table 4.16
Table 4
P Proposition Z
F F
F T
T F
Table 4.17
3. Indicate which of the following statements are correct and which ones are incorrect.
V
a. If P is True and Q is False, then P Q is True.
b. If P is False and Q is True, then P Q is True.
c. If P is False and Q is False, then P Q is False
W
d. If P is True and Q is False, then P Q is True.
V
e. If P is True and Q is False, then [P Q] is False
4. Indicate which of the following expressions are propositions and which are not.
V
a. P
WQ. V
b. [[P
V [QW R]]
Q]
c. [[P
W Q] Q ]
d. [P Q]
W V
e. [[Q R][P Q]]
5. Indicate which of the following converses and contrapositives are correct and which are not.
a. If it snows, the schools will be closed.
Converse: If the schools are closed, it snows.
Contrapositive: If the schools are not closed, it does not snow.
b. If I work all night, I can nish this project.
Converse: If I cannot nish this project, I work all night.
Contrapositive: If I can nish this project, I don't work all night.
c. I eat spicy food, only if it upsets my stomach.
Converse: If I eat spicy food, it upsets my stomach.
Contrapositive: If I don't eat spicy food, it doesn't upset my stomach.
6. Which of the following pairs of propositions are logically equivalent?
a. (1) You get promoted only if you have worked hard.
(2) If you have worked hard, you get promoted
b. (1) To get promoted you must work hard.
(2) If you work hard, then you get promoted
c. (1) Whenever there is a noreaster, the beach erodes
(2) If there is a noreaster, the beach erodes.
d. (1) I will stay home, if it snows tonight.
(2) If it snows tonight, I stay home.
7. Indicate which of the following sentences are translated correctly.
Let S represent It is snowing, F represent It is below freezing and G represent I go outside.
a. If it is snowing or below freezing, then I don't go outside.
W
translates to (S F) G
b. I go outside only if it is neither snowing nor below freezing.
V
translates to (S F) G
c. Whenever I go outside, it is snowing.
translates to S G
d. It is either snowing or below freezing.
W
translates to S F
8. For each of the following propositions, indicate what they are (Tautology, Contingency or Contraction).
a. P P
b. P P V V
c. [[P Q] P] Q
W V
d. [P
V [P
W Q] P
e. [P [P Q] P
10. Indicate which of the following statements are correct and which are not.
V V
a. [R
WS]
V [S R] V V
b. [PV [QW R]] [VP W [Q R]]
c. [[P
W R] [[P R] S]
S]
[P
d.
W Q] V [PV Q] W
e. [[Q R] [R Q]] [Q R]
11. Indicate which of the following statements are correct and which are not. If it is correct, what
implications are used?
a. If it snows, the schools will be closed. It is snowing.
p V(p Wq) ] p
W V
a. [
b. [ p (p q) ] p
29. Find the dual of each of the following propositions.
a. p WqW rV
W W
b. (p
V q Wr) Vs
c. (p F) (q T)
30. Find a compound proposition involving the propositions p, q, and r that is true when exactly one of
p, q, and r is true and is false otherwise. (Hint: Form a disjunction of conjunctions. Include a conjunction
for each combination of values for which the proposition is true. Each conjunction should include each of
the three propositions or their negations).
31. What rule of inference is used in each of the following arguments?
a. John likes apple pies. Therefore, John likes apple pies or icecream.
b. Mary likes chocolate and icecream. Therefore, Mary likes chocolate.
c. If it snows, then the roads are closed; it snows. Therefore, the roads are closed.
d. If it snows, then the roads are closed; the roads are not closed. Therefore, it does not snow.
e. To go to Tahiti, one must y or take a boat; there is no seat on any ight to Tahiti this year. Therefore,
one must take a boat to go to Tahiti this year.
32. Express the following arguments using the symbols indicated. What rules of inference are used in
each of them?
a. If the teens like it, then the sales volume will go up; Either the teens like it or the store will close; The
sales volume will not go up. Therefore, the store will close.
Symbols to be used: The teens like it (T). The sales volume will go up (S). The store will close (C).
b. It is not the case that if there is not a lot of sun, then there is enough water, nor is it true that either
there is a lot of rain or the crop is good. Therefore, there is not enough water and the crop is not good.
Symbols to be used: There is not a lot of sun (S). There is enough water (W). There is a lot of rain (R).
The crop is good (C).
c. If owers are colored, they are always scented; I don't like owers that are not grown in the open air;
All owers grown in the open air are colored. Therefore, I don't like any owers that are scentless. Symbols
to be used: Flowers are colored (C). Flowers are scented (S). I like owers (L). Flowers are grown in the
open air (O).
d. No animals, except giraes, are 15 feet or higher; There are no animals in this zoo that belong to
anyone but me; I have no animals less than 15 feet high. Therefore, all animals in this zoo are giraes.
Symbols to be used: Animals are giraes (G). Animals are 15 feet or higher (F). Animals are in the zoo (Z).
Animals belong to me (M).
e. Bees like red owers, or my hat is red and bees like hats; However, my hat is not red, or bees don't
like hats but they like red owers. Therefore bees like red owers. Symbols to be used: Bees like red owers
(R). My hat is red (H). Bees like hats (L).
33. Let Q(x, y) denote the statement "x is greater than y." What are the truth values of the following?
a. Q (3, 1)
b. Q (5, 5)
c. Q (6, -6)
d. Q (28, 256)
34. Let P(x) be the statement "x is happy," where the universe of discourse for x is the set of students.
Express each of the following quantications in English.
a. x P(x)
b. x P(x)
c. x P(x)
d. x P(x)
35. Let P(x) be the statement " x > x2." If the universe of discourse is the set of real numbers, what
are the truth values of the following?
a. P(0)
b. P(1/2)
c. P(2)
d. P(-1)
e. x P(x)
f. x P(x)
36. Suppose that the universe of discourse of the atomic formula P(x,y) is {1, 2, 3}. Write out the
following propositions using disjunctions and conjunctions.
a. x P(x, 2)
b. y P(3, y)
c. x yP(x, y)
d. x yP(x, y)
e. x y P(x, y)
f. y x P(x, y)
37. Let L(x, y) be the predicate " x likes y," and let the universe of discourse be the set of all people.
Use quantiers to express each of the following statements.
a. Everyone likes everyone.
b. Everyone likes someone.
c. Someone does not like anyone.
d. Everyone likes George.
e. There is someone whom everyone likes.
f. There is no one whom everyone likes.
g. Everyone does not like someone.
38. Let S(x) be the predicate "x is a student," B(x) the predicate "x is a book," and H(x,y) the
predicate " x has y, " where the universe of discourse is the universe, that is the set of all objects. Use
quantiers to express each of the following statements.
a. Every student has a book.
b. Some student does not have any book.
c. Some student has all the books.
d. Not every student has a book.
e. There is a book which every student has.
39. Let B(x), E(x) and G(x) be the statements " x is a book," " x is expensive, "and " x is good,"
respectively. Express each of the following statements using quantiers; logical connectives; and B(x), E(x)
and G(x), where the universe of discourse is the set of all objects.
a. No books are expensive.
b. All expensive books are good.
c. No books are good.
d. Does (c) follow from (a) and (b)?
40. Let G(x), F(x), Z(x), and M(x) be the statements "x is a girae," "x is 15 feet or higher, ""x is in
this zoo, "and " x belongs to me," respectively. Suppose that the universe of discourse is the set of animals.
Express each of the following statements using quantiers; logical connectives; and G(x), F(x), Z(x), and
M(x).
a. No animals, except giraes, are 15 feet or higher;
b. There are no animals in this zoo that belong to anyone but me;
c. I have no animals less than 15 feet high.
d. Therefore, all animals in this zoo are giraes.
e. Does (d) follow from (a), (b), and (c)? If not, is there a correct conclusion?
41. Show that the statements x y P(x, y) and x y P(x, y) have the same truth value.
42. For each of the following arguments, explain which rules of inference are used for each step. The
universe is the set of people.
a. "John, a student in this class, is 16 years old. Everyone who is 16 years old can get a driver's license.
Therefore, someone in this class can get a driver's license."
b. "Somebody in this class enjoys hiking. Every person who enjoys hiking also likes biking. Therefore,
there is a person in this class who likes biking."
c. "Every student in this class owns a personal computer. Everyone who owns a personal computer can
use the Internet. Therefore, John, a student in this class, can use the Internet."
d. "Everyone in this class owns a personal computer. Someone in this class has never used the Internet.
Therefore, someone who owns a personal computer has never used the Internet."
43. Determine whether each of the following arguments is valid. If an argument is correct, what rule of
inference is being used? If it is not, what fallacy occurs?
a. "If n is a real number with n > 1, then n2 > 1. Suppose that n2 1. Then n 1.
b. "If n is a real numberVwith n > 1, then n2 > 1.VSuppose that n2 > 1. Then n > 1.
Show that x P(x)
44.
Vx Q(x) and x(P(x) Q(x)) are not logically equivalent.
Show that x P(x) x Q(x) and x y(P(x) Q(y)) are equivalent.
V
45.
5.1 Function
5.1.1 Denitions on Function
A function is something that associates each element of a set with an element of another set (which may
or may not be the same as the rst set). The concept of function appears quite often even in non-technical
contexts. For example, a social security number uniquely identies the person, the income tax rate varies
depending on the income, and the nal letter grade for a course is often determined by test and exam scores,
homeworks and projects, and so on.
In all these cases to each member of a set (social security number, income, tuple of test and exam
scores, homeworks and projects) some member of another set (person, tax rate, letter grade, respectively) is
assigned.
As you might have noticed, a function is quite like a relation. In fact, formally, we dene a function as a
special type of binary relation.
Denition (function): A function, denote it by f, from a set A to a set B is a relation from A to B that
satises
1. for each element a in A, there is an element b in B such that <a, b> is in the relation, and
2. if <a, b> and <a, c> are in the relation, then b = c .
The set A in the above denition is called the domain of the function and B its codomain.
Thus, f is a function if it covers the domain (maps every element of the domain) and it is single valued.
The relation given by f between a and b represented by the ordered pair <a, b> is denoted as f(a) =
b , and b is called the image of a under f .
The set of images of the elements of a set S under a function f is called the image of the set S under f,
and is denoted by f(S) , that is,
f(S) = { f(a) | a S }, where S is a subset of the domain A of f .
The image of the domain under f is called the range of f.
Example: Let f be the function from the set of natural numbers N to N that maps each natural number
x to x2. Then the domain and co-domain of this f are N, the image of, say 3, under this function is 9, and
its range is the set of squares, i.e. { 0, 1, 4, 9, 16, ....} .
Denition (sum and product): Let f and g be functions from a set A to the set of real numbers R.
Then the sum and the product of f and g are dened as follows:
For all x, ( f + g )(x) = f(x) + g(x) , and
for all x, ( f*g )(x) = f(x)*g(x) ,
where f(x)*g(x) is the product of two real numbers f(x) and g(x).
69
70 CHAPTER 5. DISCRETE STRUCTURES FUNCTION
Example: Let f(x) = 3x + 1 and g(x) = x2 . Then ( f + g )(x) = x2 + 3x + 1 , and ( f*g )(x) = 3x3 +
x2
Denition (one-to-one): A function f is said to be one-to-one (injective) , if and only if whenever f(x) =
f(y) , x = y .
Example: The function f(x) = x2 from the set of natural numbers N to N is a one-to-one function. Note
that f(x) = x2 is not one-to-one if it is from the set of integers (negative as well as non-negative) to N,
because for example f(1) = f(-1) = 1 .
Denition (onto): A function f from a set A to a set B is said to be onto(surjective) , if and only if for
every element y of B , there is an element x in A such that f(x) = y , that is, f is onto if and only if f( A
) = B .
Example: The function f(x) = 2x from the set of natural numbers N to the set of non-negative even
numbers E is an onto function. However, f(x) = 2x from the set of natural numbers N to N is not onto,
because, for example, nothing in N can be mapped to 3 by this function.
Denition (bijection): A function is called a bijection , if it is onto and one-to-one.
Example: The function f(x) = 2x from the set of natural numbers N to the set of non-negative even
numbers E is one-to-one and onto. Thus it is a bijection.
Every bijection has a function called the inverse function.
These concepts are illustrated in Figure 1. In each gure below, the points on the left are in the domain
and the ones on the right are in the co-domain, and arrows show < x, f(x) > relation.
Figure 5.1
Denition (inverse): Let f be a bijection from a set A to a set B. Then the function g is called the inverse
function of f, and it is denoted by f -1 , if for every element y of B, g(y) = x , where f(x) = y . Note that
such an x is unique for each y because f is a bijection.
For example, the rightmost function in the above gure is a bijection and its inverse is obtained by
reversing the direction of each arrow.
Example: The inverse function of f(x) = 2x from the set of natural numbers N to the set of non-negative
even numbers E is f -1(x) = 1/2 x from E to N. It is also a bijection.
A function is a relation. Therefore one can also talk about composition of functions.
Denition (composite function): Let g be a function from a set A to a set B, and let f be a function from
B to a set C . Then the composition of functions f and g, denoted by fg, is the function from A to C that
satises
fg(x) = f( g(x) ) for all x in A .
Example: Let f(x) = x2 , and g(x) = x + 1 . Then f( g(x) ) = ( x + 1 )2 .
5.1.2.2 Big - Oh
The following example gives the idea of one function growing more rapidly than another. We will use this
example to introduce the concept the big-Oh.
Example: f(n) = 100 n2, g(n) = n4, the following table and Figure 2 show that g(n) grows faster than
f(n) when n > 10. We say f is big-Oh of g.
n f(n) g(n)
10 10,000 10,000
50 250,000 6,250,000
Table 5.1
Figure 5.2
Denition (big-oh): Let f and g be functions from the set of integers (or the set of real numbers) to the
set of real numbers. Then f(x) is said to be O( g(x) ) , which is read as f(x) is big-oh of g(x) , if and only if
there are constants C and n0 such that
| f(x) | C | g(x) |
whenever x > n0 .
Note that big-oh is a binary relation on a set of functions (What kinds of properties does it have ?
reexive ? symmetric ? transitive ?).
The relationship between f and g can be illustrated as follows when f is big-oh of g.
For example, 5 x + 10 is big-oh of x2, because 5 x + 10 < 5 x2 + 10 x2 = 15 x2 for x > 1 .
Hence for C = 15 and n0 = 1 , | 5x + 10 | C | x2 | . Similarly it can be seen that 3 x2 + 2 x + 4 <
9 x2 for x > 1 . Hence 3 x2 + 2 x + 4 is O( x2 ) . In general, we have the following theorem:
Theorem 1: an xn + ... + a1 x + a0 is O( xn ) for any real numbers an , ..., a0 and any nonnegative
number n .
Note: Let f(x) = 3 x2 + 2 x + 4, g(x) = x2, from the above illustration, we have that f(x) is O(g(x)).
Also, since x2 < 3 x2 + 2 x + 4, we can also get g(x) is O(f(x)). In this case, we say these two functions are
of the same order.
From this theorem it follows that if f1(x) and f2(x) are O( g(x) ) , then (f1 + f2)( x ) is O( g(x) ) ,
and
(f1 + f2)( x ) is O( max( f1(x) , f2(x) ) ) .
Theorem 3: If f1(x) is O( g1(x) ) , and f2(x) is O( g2(x) ) , then (f1 * f2)( x ) is O( g1(x) * g2(x) ) .
1 logn n nlogn n2 2n n! nn
Table 5.2
Now, we can use what we've learned above about the concept of big-Oh and the calculation methods to
calculate the order of these functions. The result shows that each function in the above list is big-oh of the
functions following them. Figure 2 displays the graphs of these functions, using a scale for the values of the
functions that doubles for each successive marking on the graph.
***SORRY, THIS MEDIA TYPE IS NOT SUPPORTED.***
d. f(x) = 5ln x
9. Use the denition of big-oh to show that x4 + 5x3 + 3x2 + 4x + 6 is O(x4).
10. Show that ( x2 + 2x + 3) / (x + 1) is O(x).
11. Show that 5x4 + x + 1 is O(x4/2) and x4/2 is O(5x4 + x + 1).
2 2
b. (3logn + 5n )(n + 3n + 2)
2 3
77
78 CHAPTER 6. DISCRETE STRUCTURES PROBLEM SOLVING
that antecedent could be obtained. ... We repeat this process until either the data/hypotheses are reached
or some easy to solve problem is reached.
(11) Simplify the problem if possible. Take advantage of symmetries which often exist.
Keep in mind that your rst try may not work. But don't get discouraged. If one approach doesn't
work, try another. You have to keep trying dierent approaches, dierent ideas. As you gain experience,
your problem solving skills improve and you tend to nd the right approach sooner.
Let us now look at some examples to illustrate the topics discussed above.
6.1.5 Examples
Example 1
This is an example in which you can nd a solution once you analyze and understand the unknowns and
data.
Problem: A survey of TV viewers shows the following results:
To the question "Do you watch comedies?", 352 answered "Yes".,
To the question "Do you watch sports ?", 277 answered "Yes", and
To the question "Do you watch both comedies and sports ?", 129 answered "Yes".
Given these data, nd, among people who watch at least one of comedies and sports, percentages of
people who watch at least one of comedies and sports watch only comedies, only sports, and both comedies
and sports.
Let us try to solve this problem following the framework presented above.
Understanding the Problem: This is a "nd" type problem. So we try to identify unknowns, data and
conditions.
The unknowns are the percentage of people who watch only comedies, the percentage of people who
watch only sports, and the percentage of people who watch both comedies and sports.
The data are the three numbers: 352, 277 and 129, representing the number of people who watch comedies,
sports, and both comedies and sports, respectively. Note that 352 includes people who watch both comedies
and sports as well as people who watch only comedies. Similarly for 277.
The conditions are not explicitly given in the problem statement. But one can see that the percentages
must add up to 100, and they must be nonnegative.
Devising a Solution Plan: Here we rst examine the principal parts in detail.
First let us consider the unknowns in more detail. To calculate the percentage of the people who watch
only comedies, for example, we need the number of people who watch at least one of comedies and sports,
and the number of people who watch only comedies. Thus actually two unknowns are involved in each of
the required percentages, and the real unknowns are the number of people in each of the categories, and the
number of people who watch at least one of comedies and sports.
Next let us look at the data. First the number 352 is the number of people who watch comedies. But
that is not necessarily that of the people who watch only comedies. It includes that and the number of
people who watch both comedies and sports. Similarly for the second number 277.
Let us use symbols to represent each of the unknowns: Let C represent the number of people who watch
only comedies, S that of the people who watch only sports, and T that of the people who watch at least one
of those programs.
Then we have the following relationships among the unknowns:
C + 129 = 352
S + 129 = 277
C + S + 129 = T
From these equations we can easily obtain C = 223, S = 148, and T = 500. Thus the required percentages
are 44.6%, 29.6%, and 25.8%, respectively.
All we had to do to solve this problem is to analyze relationships between the data and the unknowns,
that is, nothing much beyond "understanding the problem".
Example 2
This is a problem which you can solve using similar known results.
Problem: Find the (length of ) diagonal of a rectangular parallelepiped given its length, width and height.
Again let us try to solve this problem following the framework presented above.
Understanding the Problem: This is a "nd" type problem. So we try to identify unknowns, data and
conditions.
The unknown is the diagonal of a rectangular parallelepiped, and the data are its length, width and
height. Again there are no explicitly stated conditions. But the unknown and data must all be a positive
number.
Before proceeding to the next phase, let us make sure that we understand the terminologies. First a
rectangular parallelepiped is a box with rectangular faces like a cube except that the faces are not necessarily
a square but a rectangle as shown in Figure 1.
Figure 6.1
Next a diagonal of a rectangular parallelepiped is the line that connects its two vertices (corner points)
that are not on the same plane. It is shown in Figure 2.
Figure 6.2
Devising a Solution Plan: Here we rst try to nd relevant facts. Relevant facts often involve the same or
similar words or concepts. Since the unknown is a diagonal, we look for facts concerning diagonal. Note that
drawing gures here is quite helpful. One of the facts that immediately comes to our mind in this problem
is Pythagoras' theorem. It has to do with right triangles and is shown in Figure 3.
Figure 6.3
Let us try to see whether or not this theorem helps. To use this theorem, we need a right triangle
involving a diagonal of a parallelepiped. As we can see in Figure 4, there is a right triangle with a diagonal
x as its hypotenuse.
Figure 6.4
However, the triangle here involves two unknowns: x and y. Since x is what we are looking for, we need
to nd the value of y. To nd y, we note another right triangle shown in Figure 5.
Figure 6.5
Devising a Solution Plan: For this problem, let us try "proof by contradiction". When you are asked to
prove the impossibility of an event or non-existence of certain things, this approach often is quite helpful.
Following the "proof by contradiction", let us assume that the conclusion is false, that is the equation
ax2 + bx + c = 0 has a rational root m/n, where m and n are integers, when a, b, and c are odd integers.
We can assume without loss of generality that m and n do not have any factors in common. Then
a(m/n)2 + b(m/n) + c = 0 . (1)
Let us try to derive a contradiction from this. First let us make this equation simpler, that is, let us get
rid of fractions.
Since n is not equal to 0, multiplying the both sides of (1) by n2, we get
am2 + bmn + cn2 = 0. (2)
Since m is an integer, it is either even or odd. We are going to consider those cases one by one. That is
"divide into cases".
Let us rst consider the case when m is even. Then n is odd, since otherwise m and n have a common
factor 2. Now am2 + bmn is even, and cn2 is odd. Hence am2 + bmn + cn2 can not be 0.
Next let us consider the case when m is odd. By an argument similar to the previous case, we can see
that n is also odd. If m and n are odd, then am2, bmn, and cn2 are all odd, since a, b, and c are odd
integers. However, the sum of three odd numbers can not be equal to 0.
Thus by assuming that the conclusion is false, we have arrived at a contradiction, that is m/n does not
satisfy the equation. Hence our assumption must be wrong, and therefore the conclusion is correct.
Example 4
This is another proof type problem and "working backward" technique is used.
Problem: Prove that ( a + b + c )2 4(ab + bc + ca) , if a, b, c are three sides of a triangle.
Understanding the Problem: This is a "prove" type problem.
The hypothesis is that a, b, and c are three sides of a triangle, and the conclusion is that inequality ( a
+ b + c )2 4( ab + bc + ca ) holds.
Devising a Solution Plan: Here we try "Working Backward" heuristic. That is manipulate the conclusion
possibly using the hypothesis and reduce it into something that is obviously true.
First by multiplying out the left hand side of the inequality, ( a + b + c )2 = a2 + b2 + c2 + 2(ab +
bc + ca).
Hence if a2 + b2 + c2 2(ab + bc + ca) , then the conclusion holds.
Next, to see what we can try, note that we have not used the hypothesis yet, and see if it can help here.
It is well known that the sum of two sides of a triangle is greater than the third side. Hence a + b > c ,
b + c > a , and c + a > b hold.
From these we can obtain c(a + b) > c2 , a(b + c) > a2 , and b(c + a) > b2.
By adding these three inequalities, we get
a2 + b2 + c2 < a(b + c) + b(c + a) + c(a + b) = 2(ab + bc + ca).
Hence a2 + b2 + c2 < 2(ab + bc + ca).
Hence a2 + b2 + c2 2(ab + bc + ca).
Hence ( a + b + c )2 4(ab + bc + ca) holds.
Example 5
This is a nd type problem and "working backward" technique is used.
Problem: Given a 4 quart pail and a 9 quart pail, obtain 6 quarts of water in the 9 quart pail using these
two pails. You can ll or empty the pails and you can have as much water as you want.
Understanding the Problem: This is a "nd" type problem.
The problem is to obtain 6 quarts of water in the 9 quart pail using 4 quart and 9 quart pails as measures.
You can ll either pail from the water source or from the other pail, and you can empty the pails any time.
Devising a Solution Plan: You can solve this in a number of dierent ways. Here we try "Working
Backward" heuristic. It starts with the desired solution and work backward step by step. At each step we
try to nd a state that immediately precedes the current state such that we can reach the current state from
that state with one simple operation such as lling a pail or emptying a pail in this problem. We repeat this
process until we reach some easily reachable state such as empty pails, full pails, one pail full and the other
empty, etc.
Our solution to the original problem is obtained by traversing this process backward to the desired state.
Let us denote the 9 quart pail by A and the 4 quart pail by B for simplicity. In this problem, the desired
state is to have 6 qts in A (Figure 6).
Figure 6.6
Thus in the rst step of "working backward", we ask how we could get to the desired state with one
operation.
As one can easily see if we could dump 3 qts from 9 qts in A, then we would have 6 qts in A. To be able
to dump 3 qts from A we need 1 qt in B. Thus the state immediately preceding the current state is the one
where A is full and B has 1 qt in it (Figure 7).
Figure 6.7
In the second step, the question we ask is how to get 1 qt in B. It does not look easy to get 1 qt in B.
So let us see whether or not we can get 1 qt in A. If we have 1 qt in A, then we can certainly get 1 qt in B
without any trouble. thus we might say that the third state is to have 1 qt in A (Figure 8).
Figure 6.8
In the third step, the question we ask is how to get 1 qt in A. This is relatively easy to accomplish because
all you have to do is to get rid of 8 qts from a full A, which can be done by emptying A twice into B.
Figure 6.9
Figure 6.10
Since this state can be easily reached (all you have to do to get to this state is to ll A with water), we
stop here. Our solution to the original problem is now obtained by going this process backward.
Thus rst we ll up A. Then dump A into B leaving 5 qts in A (Figure 9). Then dump A into B again.
This gives us 1 qt in A. Pour that into B. Then ll A and empty it into B. We now have 6 qts in A, which
is what is required.
Example 6
Problem: A survey of TV viewers shows the following results:
To the question "Do you watch comedies?", 374 replied "Yes".
To the question "Do you watch sports?", 360 replied "Yes".
To the question "Do you watch detective stories?", 350 replied "Yes".
To the question "Do you watch comedies and sports?", 134 replied "Yes".
To the question "Do you watch comedies and detectives?", 96 replied "Yes".
To the question "Do you watch detectives and sports?", 241 replied "Yes".
To the question "Do you watch all three?", 37 replied "Yes".
Find the percentages of people who watch only comedies, only sports, only detective stories, comedies
and sports, comedies and detectives, sports and detectives, and all three. By doing the same kind of analyses
on the unknowns and data, one can nd these percentages. The total number of people who watch at least
one of these programs is
374 + 360 + 350 - 134 - 96 - 241 + 37 = 650,
because each of 134, 96 and 241 is counted twice into 374 + 360 + 350, and 37 is counted in three times
and subtracted out three times in 374 + 360 + 350 - 134 - 96 - 241.
Similarly the number of those watching only comedies is
374 - 134 - 96 + 37 = 181,
the number of those watching only detectives is
6.1.5.1 Reference
Polya: G. Polya, How to Solve It, A New Aspect of Mathematical Method, Second Ed., Princeton
University Press, Princeton, NJ, 1985. Larson: L. C. Larson, Problem-Solving Through Problems, Springer-
Verlag, New York, NY, 1983.
7.1 Recursion
7.1.1 Recursive Denition
7.1.1.1 Recursive Denition
Sets which have too many elements to list them up, and for which there are no convenient or obvious
predicates to specify their elements can often be dened using a recursive denition (also called inductive
denition). It essentially gives a procedure to generate the members of the set one by one starting with some
subset of its elements. In this type of denition, rst a collection of elements to be included initially in the
set is specied. These elements can be viewed as the seeds of the set being dened. Next, the rules to be
used to generate elements of the set from elements already known to be in the set (initially the seeds) are
given. These rules provide a method to construct the set element by element starting with the seeds. These
rules can also be used to test elements for the membership in the set.
A recursive denition of a set always consists of three distinct clauses:
1. The basis clause (or simply basis) of the denition establishes that certain objects are in the set. This
part of the denition species the "seeds" of the set from which the elements of the set are generated using
the methods given in the inductive clause. The set of elements specied here is called basis of the set being
dened.
2. The inductive clause (or simply induction) of the denition establishes the ways in which elements
of the set can be combined to produce new elements of the set. The inductive clause always asserts that if
objects are elements of the set, then they can be combined in certain specied ways to create other objects.
Let us call the objects used to create a new object the parents of the new object, and the new object is their
child.
3. The extremal clause asserts that unless an object can be shown to be a member of the set by applying
the basis and inductive clauses a nite number of times, the object is not a member of the set.
The set you are trying to dene recursively is the set that satises those three clauses.
There are a number of other ways of expressing the extremal clause that are equivalent to the extremal
clause given above.
Examples of Recursive Denition of Set
Example 1. Denition of the Set of Natural Numbers N
The set N is the set that satises the following three clauses:
Basis Clause: 0 N
Inductive Clause: For any element x in N, x + 1 is in N.
Extremal Clause: Nothing is in N unless it is obtained from the Basis and Inductive Clauses.
91
92 CHAPTER 7. DISCRETE STRUCTURES RECURSION
The basis for this set N is { 0 } . The x + 1 in the Inductive Clause is the parent of x, and x is the child
of x + 1. Following this denition, the set of natural numbers N can be obtained as follows:
First by the Basis Clause, 0 is put into N. Then by the Inductive Clause, since 0 is in N, 0 + 1 (= 1)
is in N. 0 is the parent of 1, and 1 is the child of 0. Then by the Inductive Clause again, 1 + 1 (= 2) is in
N. 1 is the parent of 2, and 2 is the child of 1. Proceeding in this manner all the "natural numbers" are put
into N.
Note that if we don't have the Extremal Clause, 0.5, 1.5, 2.5, ... can be included in N, which is not what
we want as the set of natural numbers.
Example 2. Denition of the Set of Nonnegative Even Numbers NE
The set NE is the set that satises the following three clauses:
Basis Clause: 0 NE
Inductive Clause: For any element x in NE, x + 2 is in NE.
Extremal Clause: Nothing is in NE unless it is obtained from the Basis and Inductive Clauses.
Example 3. Denition of the Set of Even Integers EI
The set EI is the set that satises the following three clauses:
Basis Clause: 0 EI
Inductive Clause: For any element x in EI, x + 2, and x - 2 are in EI.
Extremal Clause: Nothing is in EI unless it is obtained from the Basis and Inductive Clauses.
Example 4. Denition of the Set of Strings S over the alphabet {a,b} excepting empty string. This is
the set of strings consisting of a's and b's such as abbab, bbabaa, etc.
The set S is the set that satises the following three clauses:
Basis Clause: a S, and b S.
Inductive Clause: For any element x in S, ax S, and bx S.
Here ax means the concatenation of a with x.
Extremal Clause: Nothing is in S unless it is obtained from the Basis and Inductive Clauses.
Tips for recursively dening a set:
For the "Basis Clause", try simplest elements in the set such as smallest numbers (0, or 1), simplest
expressions, or shortest strings. Then see how other elements can be obtained from them, and generalize
that generation process for the "Inductive Clause".
The set of propositions (propositional forms) can also be dened recursively.
In general, recursive computer programs require more memory and computation compared with iterative
algorithms, but they are simpler and for many cases a natural way of thinking about the problem.
Example 1: Algorithm for nding the k-th even natural number Note here that this can be solved very
easily by simply outputting 2*(k - 1) for a given k . The purpose here, however, is to illustrate the basic
idea of recursion rather than solving the problem.
Algorithm 1: Even(positive integer k)
Input: k , a positive integer
Output: k-th even natural number (the rst even being 0)
Algorithm:
if k = 1, then return 0;
else return Even(k-1) + 2 .
Here the computation of Even(k) is reduced to that of Even for a smaller input value, that is Even(k-
1). Even(k) eventually becomes Even(1) which is 0 by the rst line. For example, to compute Even(3),
Algorithm Even(k) is called with k = 2. In the computation of Even(2), Algorithm Even(k) is called with k
= 1. Since Even(1) = 0, 0 is returned for the computation of Even(2), and Even(2) = Even(1) + 2 = 2 is
obtained. This value 2 for Even(2) is now returned to the computation of Even(3), and Even(3) = Even(2)
+ 2 = 4 is obtained.
As can be seen by comparing this algorithm with the recursive denition of the set of nonnegative even
numbers, the rst line of the algorithm corresponds to the basis clause of the denition, and the second line
corresponds to the inductive clause.
By way of comparison, let us see how the same problem can be solved by an iterative algorithm.
Algorithm 1-a: Even(positive integer k)
Input: k, a positive integer
Output: k-th even natural number (the rst even being 0)
Algorithm:
int i, even;
i := 1;
even := 0;
while( i < k ) {
even := even + 2;
i := i + 1;
}
return even .
Example 2: Algorithm for computing the k-th power of 2
Algorithm 2 Power_of_2(natural number k)
Input: k , a natural number
Output: k-th power of 2
Algorithm:
if k = 0, then return 1;
else return 2*Power_of_2(k - 1) .
By way of comparison, let us see how the same problem can be solved by an iterative algorithm.
Algorithm 2-a Power_of_2(natural number k)
Input: k , a natural number
Output: k-th power of 2
Algorithm:
int i, power;
i := 0;
power := 1;
while( i < k ) {
power := power * 2;
i := i + 1;
}
return power .
The next example does not have any corresponding recursive denition. It shows a recursive way of
solving a problem.
Example 3: Recursive Algorithm for Sequential Search
Algorithm 3 SeqSearch(L, i, j, x)
Input: L is an array, i and j are positive integers, i j, and x is the key to be searched for in L.
Output: If x is in L between indexes i and j, then output its index, else output 0.
Algorithm:
if i j , then
{
if L(i) = x, then return i ;
else return SeqSearch(L, i+1, j, x)
}
else return 0.
Recursive algorithms can also be used to test objects for membership in a set.
Example 4: Algorithm for testing whether or not a number x is a natural number
Algorithm 4 Natural(a number x)
Input: A number x
Output: "Yes" if x is a natural number, else "No"
Algorithm:
if x < 0, then return "No"
else
if x = 0, then return "Yes"
else return Natural( x - 1 )
Example 5: Algorithm for testing whether or not an expression w is a proposition (propositional form)
Algorithm 5 Proposition( a string w )
Input: A string w
Output: "Yes" if w is a proposition, else "No"
Algorithm:
if w is 1(true), 0(false), or a propositional variable, then return "Yes"
else if w = w1, then return Proposition(w1)
else
V
if ( w = w1 w2 or w1 w2 or w1 w2 or w1 w2 ) and
Proposition(w1) = Yes and Proposition(w2) = Yes
then return Yes
else return No
end
property (inductive step). Here you prove that the property is inherited from one generation (n) to the next
generation (n + 1).
When these two are proven, then it follows that all the natural numbers have that property. For since
0 has the property by the basis step, the element next to it, which is 1, has the same property by the
inductive step. Then since 1 has the property, the element next to it, which is 2, has the same property
again by the inductive step. Proceeding likewise, any natural number can be shown to have the property.
This process is somewhat analogous to the knocking over a row of dominos with knocking over the rst
domino corresponding to the basis step.
More generally mathematical statements involving a natural number n such as 1 + 2 + ... + n = n( n
+ 1 )/2 can be proven by mathematical induction by the same token.
To prove that a statement P(n) is true for all natural number nn0, where n0 is a natural number, we
proceed as follows:
Basis Step: Prove that P(n0) is true.
Induction: Prove that for any integer kn0, if P(k) is true (called induction hypothesis), then P(k+1) is
true.
The rst principle of mathematical induction states that if the basis step and the inductive step are
proven, then P(n) is true for all natural number nn0.
As a rst step for proof by induction, it is often a good idea to restate P(k+1) in terms of P(k) so that
P(k), which is assumed to be true, can be used.
Example:
Prove that for any natural number n, 0 + 1 + ... + n = n( n + 1 )/2 .
Proof:
Basis Step: If n = 0, then LHS = 0, and RHS = 0 * (0 + 1) = 0 .
Hence LHS = RHS.
Induction: Assume that for an arbitrary natural number n, 0 + 1 + ... + n = n( n + 1 )/2 .
Induction Hypothesis
To prove this for n+1, rst try to express LHS for n+1 in terms of LHS for n, and somehow use the
induction hypothesis.
Here let us try
LHS for n + 1 = 0 + 1 + ... + n + (n + 1) = (0 + 1 + ... + n) + (n + 1).
Using the induction hypothesis, the last expression can be rewritten as
n( n + 1 )/2 + (n + 1) .
Factoring (n + 1) out, we get
(n + 1)(n + 2) / 2,
which is equal to the RHS for n+1.
Thus LHS = RHS for n+1.
End of Proof.
return S
Let us rst see how this code computes the square of a natural number. For example let us compute 3 2
using it.
First S <- 0 and i <- 0 give S = 0 and i = 0 initially.
Since i < 3, the while loop is entered.
S <- 0 + 3
i <- 0 + 1
producing S = 3 and i = 1.
Since i < 3, the while loop is entered the second time.
S <- 3 + 3
i <- 1 + 1
producing S = 6 and i = 2.
Since i < 3, the while loop is entered the third time.
S <- 6 + 3
i <- 2 + 1
producing S = 9 and i = 3.
Since i = 3, the while loop is not entered any longer, S = 9 is returned and the algorithm is terminated.
In general to compute n2 by this algorithm, n is added n times.
To prove that the algorithm is correct, let us rst note that the algorithm stops after a nite number of
steps. For i increases one by one from 0 and n is a natural number. Thus i eventually becomes equal to n.
Next, to prove that it computes n2, we show that after going through the loop k times, S = k*n and i =
k hold. This statement is called a loop invariant and mathematical induction can be used to prove it.
Proof by induction.
Basis Step: k = 0. When k = 0, that is when the loop is not entered, S = 0 and i = 0. Hence S = k*n
and i = k hold.
Induction Hypothesis: For an arbitrary value m of k, S = m * n and i = m hold after going through the
loop m times.
Inductive Step: When the loop is entered (m + 1)-st time, S = m*n and i = m at the beginning of the
loop. Inside the loop,
S <- m*n + n
i <- i + 1
producing S = (m + 1)*n and i = m + 1.
Thus S = k*n and i = k hold for any natural number k.
Now, when the algorithm stops, i = n. Hence the loop will have been entered n times.
Thus S = n*n = n2. Hence the algorithm is correct.
The next example is an algorithm to compute the factorial of a positive integer.
FACTORIAL Function: FAC(n)
i <- 1
F <- 1
while i <=n
F <- F * i
i <- i + 1
return F
Let us rst see how this code computes the factorial of a positive integer. For example let us compute 3!.
First i <- 1 and F <- 1 give i = 1 and F = 1 initially.
Since i < 3, the while loop is entered.
F <- 1 * 1
i <- 1 + 1
producing F = 1 and i = 2.
Since i < 3, the while loop is entered the second time.
F <- 1 * 2
i <- 2 + 1
producing F = 2 and i = 3.
Since i = 3, the while loop is entered the third time.
F <- 2 * 3
i <- 3 + 1
producing F = 6 and i = 4.
Since i = 4, the while loop is not entered any longer, F = 6 is returned and the algorithm is terminated.
To prove that the algorithm is correct, let us rst note that the algorithm stops after a nite number of
steps. For i increases one by one from 1 and n is a positive integer. Thus i eventually becomes equal to n.
Next, to prove that it computes n!, we show that after going through the loop k times, F = k ! and i =
k + 1 hold. This is a loop invariant and again we are going to use mathematical induction to prove it.
Proof by induction.
Basis Step: k = 1. When k = 1, that is when the loop is entered the rst time, F = 1 * 1 = 1 and i = 1
+ 1 = 2. Since 1! = 1, F = k! and i = k + 1 hold.
Induction Hypothesis: For an arbitrary value m of k, F = m! and i = m + 1 hold after going through
the loop m times.
Inductive Step: When the loop is entered (m + 1)-st time, F = m! and i = (m+1) at the beginning of
the loop. Inside the loop,
F <- m!* (m + 1)
i <- (m + 1) + 1
producing F = (m + 1)! and i = (m + 1) + 1.
Thus F = k! and i = k + 1 hold for any positive integer k.
Now, when the algorithm stops, i = n + 1. Hence the loop will have been entered n times. Thus F = n!
is returned. Hence the algorithm is correct.
Proof: Assume that for all positive integers k, n > k > 1, k can be written as the product of prime
numbers.
We are going to prove that n can be written as the product of prime numbers.
Since n is an integer, it is either a prime number or not a prime number. If n is a prime number, then it
is the product of 1, which is a prime number, and itself. Therefore the statement holds true.
If n is not a prime number, then it is a product of two positive integers, say p and q. Since both p and q
are smaller than n, by the induction hypothesis they can be written as the product of prime numbers (Note
that this is not possible, or at least very hard, if the First Principle is being used). Hence n can also be
written as the product of prime numbers.
b. f(n + 1) = 3f(n).
c. f(n + 1) = 2f(n).
11. Find f(2), f(3), and f(4), if f(n) is dened recursively by f(0) = 1, f(1) = -2 and for
n= 1, 2,...
a. f(n + 1) = f(n) + 3f(n - 1).
b. f(n + 1) = f(n)2 f(n - 1).
12. Let F be the function such that F(n) is the sum of the rst n positive integers. Give a recursive
denition of F(n).
13. Give a recursive algorithm for computing nx whenever n is a positive integer and x is an integer.
14. Give a recursive algorithm for nding the sum of the rst n odd positive integers.
15. Use mathematical induction to prove that 3 + 3 * 5 + 3 * 52+ ... + 3 * 5n = 3 (5n+1 - 1)/4
whenever n is a nonnegative integer.
16. Prove that 12 + 32 + 52+ ... + (2 n + 1)2 = (n + 1)(2n + 1)(2n+ 3)/3 whenever n is a nonnegative
integer.
17. Show that 2n > n2whenever n is an integer greater than 4.
18. Show that any postage that is a positive integer number of cents greater than 7 cents can be formed
using just 3-cent stamps and 5-cent stamps.
19. Use mathematical induction to show that 5 divides n5- n whenever n is a nonnegative integer.
20. Use mathematical induction to prove that if A1, A2, ...An are subsets of a universal set U, then
n A
i=1 i =
intersectni=1 Ai
21. Find a formula for
1/2 + 1/4 + 1/8 + ... + 1/2n
by examining the values of this expression for small values of n. Use mathematical induction to prove
your result.
22. Show that if a1, a2, an are n distinct real numbers, exactly n - 1 multiplications are used to
...,
compute the product of these n numbers no matter how parentheses are inserted into their product. (Hint:
Use the second principle of mathematical induction and consider the last multiplication).
101
102 CHAPTER 8. DISCRETE STRUCTURES SET THEORY
in the set otherwise) from the set. For example the set of natural numbers N can be dened recursively as
the set that satises the following (1), (2), and (3):
(1) 0 N
(2) For any number x if x N, then x + 1 N.
(3) Nothing is in N unless it is obtained from (1) and (2).
Following this denition, the set of natural numbers N can be obtained as follows: First by (1), 0 is put
into N.
Then by (2), since 0 is in N, 0 + 1 (= 1) is in N.
Then by (2) again, 1 + 1 (= 2) is in N.
Proceeding in this manner all the natural numbers are put into N. Note that if we don't have (3), 0.5,
1.5, 2.5, ... can be included in N, which is not what we want as the set of natural numbers.
V
However, x [x x
/ A] implies x [x ] by formula 4 of the relationships between the connectives
and quantiers from predicate logic and "simplication" from the implications of propositional logic. But x
15. AB A
The properties 16, and 11 can be proven using equivalences of propositional logic. The others can also
be proven similarly by going to logic, though they can be proven also using some of these properties (after
those properties are proven, needless to say). Let us prove some of these properties.
Proof for 4: A B = B A
We are going to prove this by showing that every element that is in AB is also in BA and vice versa.
Consider an arbitrary element x. Then by the denition of set union x A B x A x B
x A x B by the commutativity of
x B A by the denition of set union.
Hence by Universal Generalization, every element is in A B is also in B A.
Hence A B = B A.
Note here the correspondence of the commutativity of and that of . This correspondence holds not
just for the commutativity but also for others.
V
Furthermore a similar correspondence exists between and , and between and .
Proof for 6: By the denition of the equality of sets, we need to prove that x [x A (B C)] if and
only if x (A B) (A C).
For that, considering the Universal Generalization rule, we need to show that for an arbitrary element in
the universe x, x A (B C) if and only if x (A B) (A C).
Here the only if part is going to be proven. The if part can be proven similarly.
x A (B C) Vx A x (B C) by the denition of
x A (x B Vx C) by the denition of
(x A x VB) (x A x C) by the distribution from the equivalences of propositional logic
x (A B) x (A C) by the denition of .
x (A B) (A C) by the denition of .
Proof for 8: (a) If AB then A B = B.
Let x be an arbitrary element in the universe.
Then x A
x A x B.
B
Since AB, x xB A
Also x B x B
Hence x A B x B.
Hence A B B
Since B A B (use "addition" rule), A B = B follows.
(b) Similarly for A B = A.
Alternative proof:
These can also be proven using 8, 14, and 15. For example, (b) can be proven as follows:
First by 15, A B A.
Then since A A, and A B, by 7 A A A B.
Since A A = A by 3, A A B.
Proof for 9: Let x be an arbitrary element in the universe.
V
Then [x A (B - A)]
V [x A (x B x
/ A)]
A x B)
[(x
V (x A x
/ A)]
[(x A x B) True]
[x A x B]
Hence A (B - A) = A B.
Alternative proof
This can also proven using set properties as follows.
A ( B - A ) = A ( B A) by the denition of ( B - A ) .
= ( A B ) ( A A) by the distribution.
= (A B ) U
= ( A B ) by 1.
Proof for 10: Suppose A (B - A) 6= .
Also since A A = A A , A A = .
Hence A = A.
and {}
{a,b,c} and {a,b,c,c}
{1,2,3} and {{1},{2},{3}}
2. Let S1={a,b,c}, S2={a,b}, S3={b,c} and S4={b,c,d}. Which of the followings is correct?
S2 S1
S3 S1
S4 S1
3. Let A={a,b,c,d} and B={a,b,c,d,e,f}. Which of the followings is correct?
A B = {a,b,c,d,e,f}
A B = {a,b,c,d}
A B = {e,f}
B A = {e,f}
1. {a}
2. {a, {a}}
3. {, {}}
4. Let A be a set. Show that x A = A x = .
5. How many dierent elements does A x B have if A has m elements and B has n elements?
6. Let A = {1, 2, 3, 4} and b = {0, 3, 5}. Find
1. A B
2. A B
3. A-B
4. B-A
5. What can you say about the sets A and B if the following are true?
1. A B
2. A B = A
3. A-B=A
4. Let A and B be subsets of a universal set U. Show that A B if and only if B A.
5. Let A and B be sets. Show that
1. A B = B A.
2. A B = B A.
3. Show that if A and B are sets, then (A B)=A B by showing each side is a subset of the other
side.
4. Let A, B, and C be sets. Show that A ( B C ) = ( A B ) C.
Attributions
Collection: Discrete Structures
Edited by: The Duy Bui
URL: http://cnx.org/content/col10768/1.1/
License: http://creativecommons.org/licenses/by/3.0/
Connexions's modular, interactive courses are in use worldwide by universities, community colleges, K-12
schools, distance learners, and lifelong learners. Connexions materials are in many languages, including
English, Spanish, Chinese, Japanese, Italian, Vietnamese, French, Portuguese, and Thai. Connexions is part
of an exciting new information distribution system that allows for Print on Demand Books. Connexions
has partnered with innovative on-demand publisher QOOP to accelerate the delivery of printed course
materials and textbooks into classrooms worldwide at lower prices than traditional academic publishers.