Module Title DISCRETE STRUCTURES FOR COM
Module Title DISCRETE STRUCTURES FOR COM
COURSE OUTLINE
REFERENCES
Rosen, Kenneth H.: Discrete mathematics and its applications — 7th edition
ASSESSMENT:
Assignments : 10%
Quiz : 10%
UNIT1: INTRODUCTION
Meaning of the word “structures”: It means a complex composition of knowledge as elements
and their combinations. Discrete Structures are the abstract mathematical structures used to
represent discrete objects and relationships between these objects. These discrete structures
include logic, sets, permutations, relations, graphs, trees, and finite-state machines.
Discrete structures are those complex compositions of knowledge that are taken from the field
of discrete mathematics. Discrete mathematics is mathematics that deals with discrete objects.
Discrete objects are those which are separated from (not connected to/distinct from) each other.
Integers, automobiles, houses, people etc. are all discrete objects.
On the other hand, real numbers which include irrational as well as rational numbers are not
discrete. As you know between any two different real numbers there is another real number
different from either of them. So they are packed without any gaps and cannot be separated from
their immediate neighbors. In that sense they are not discrete. In this course we will be concerned
with objects such as integers, propositions, sets, relations and functions, which are all discrete.
We are going to learn concepts associated with them, their properties, and relationships among
them among others.
Discrete mathematics is about the mathematics of integers and of collections of objects. It
underlies the operation of digital computers, and is used widely in all fields of computer science
for reasoning about data structures, algorithms and complexity. Topics covered in the module
include logic, proof techniques and sets, functions, relations, summations and recurrences,
counting techniques and recursion.
Note: Discrete structures is the term used for discrete mathematics for computer science
whereas Discrete mathematics is often referred to as finite mathematics.
Exemple-Exercise
State which of the following represent discrete data and which represent continuous data.
(a) Numbers of shares sold each day in the stock market. Ans. D
4
Definition
A proposition is a declarative sentence (that is, a sentence that declares a fact) that is either true
or false, but not both. Propositional logic is a logic at the sentential level. Thus sentences
considered in this logic are not arbitrary sentences rather are the ones that are true or false. 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".
Example1
"Grass is green", and "2 + 5 = 5" are propositions.
The first proposition has the truth value of "true" and the second "false".
Example2
Consider the following sentences.
1. What time is it?
2. Read this carefully.
3. x+1=2.
4. x+y = z.
Sentences 1 and 2 are not propositions because they are not declarative sentences. Sentences 3
and 4 are not propositions because they are neither true nor false. Note that each of sentences 3
and 4 can be turned into a proposition if we assign values to the variables.
5
We use letters to denote propositional variables (or statement variables), that is, variables that
represent propositions, just as letters are used to denote numerical variables. The conventional
letters used for propositional variables are p,q,r,s,... .The truth value of a proposition is true,
denoted by T, if it is a true proposition, and the truth value of a proposition is false, denoted by
F, if it is a false proposition.
The area of logic that deals with propositions is called the propositional calculus or
propositional logic.
We now turn our attention to methods for producing new propositions from those that
we already have. Many mathematical statements are constructed by combining one or more
propositions. New propositions, called compound propositions, are formed from existing
propositions using logical operators.
Truth Table
Often we want to discuss properties/relations common to all propositions. In such a case rather
than stating them for each individual proposition we use variables representing an arbitrary
proposition and state properties/relations in terms of those variables. Those variables are called a
propositional variable. Propositional variables are also considered a proposition and called
a proposition since they represent a proposition hence they behave the same way as
propositions.
A proposition in general contains a number of variables. For example (p q) contains variables
p and q each of which represents an arbitrary proposition. Thus a proposition takes different
values depending on the values of the constituent variables. This relationship of the value of a
proposition and those of its constituent variables can be represented by a table. It tabulates the
value of a proposition for all possible values of its variables and it is called a truth table.
This table shows that if p is true, then ( p) is false, and that if p is false, then ( p) is true.
p q p q
T T T
T F F
F T F
F F F
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.
p q p q
T T T
T F T
F T T
F F F
This table shows that (p q) is false if both p and q are false and is true otherwise.
p q p q
T T T
T F F
F T T
F F T
The conditional statement p q is the proposition “if p, then q.” The conditional statement
p q is false when p is true and q is false, and true otherwise. In the conditional statement
p q, p is called the hypothesis (or antecedent or premise) and q is called the conclusion (or
consequence).When p q 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.
p q p q
T T T
7
T F F
F T F
F F T
The biconditional statement p q is the proposition “p if and only if q.” The biconditional
statement p q is true when p and q have the same truthvalues, and is false otherwise.
Biconditional statements are also called bi-implications.
The converse of a proposition is not necessarily logically equivalent to it, that is they may or
may not take the same truth value at the same time.
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.
Exercises
1. Which of the following sentences are propositions? What are the truth values of those that are
propositions?
Solution
a. Yes, True
b. Yes, False
c. No
d. Yes, False
e. Yes, True
8
f. No
g. No
a) p p
b) (p q) q
c) (p q) ( q p)
Solutions
a)
p p p p
T F F
F T F
b)
p q q p q (p q) q
T T F T T
T F T T F
F T F F T
F F T T F
p q p q q p q p (p q) ( q p)
T T T F F T T
T F F T F F T
F T T F T T T
F F T T T T T
If-then statements appear in various forms in practice. The following list presents some of the
variations. These are all logically equivalent, that is as far as true or false of statement is
concerned there is no difference between them. Thus if one is true then all the others are also
true, and if one is false all the others are false.
If p , then q.
p implies q.
If p, q.
p only if q.
p is sufficient 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".
To check the correctness of reasoning, we must check whether or not rules of inference have
been followed to draw the conclusion from the premises. However, for reasoning in English or in
11
general for reasoning in a natural language, that is not necessarily straightforward and it often
encounters some difficulties. Firstly, connectives are not necessarily easily identified as we can
get a flavor of that from the previous topic on variations of if_then statements. Secondly, if the
argument becomes complicated involving many statements in a number of different forms
twisted and tangled up, it can easily get out of hand unless it is simplified in some way.
One solution for that is to use symbols (and mechanize it). Each sentence is represented by
symbols representing building block sentences, and connectives. For example, if P represents "it
snows" and Q represents "the school is closed", then the previous argument can be expressed as
[[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.
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 first "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 snowing and I have time, then I will go to the beach", and it is translated as
( P R) Q.
Exercise
1. Write each of the following statements in the form "if p, then q" in English. (Hint: Refer to
the list of common ways to express implications listed in this section.)
a. The newspaper will not come if there is an inch of snow on the street.
b. It snows whenever the wind blows from the northeast.
c. That prices go up implies that supply will be plentiful.
d. It is necessary to read the textbook to understand the materials of this course.
e. For a number to be divisible by 3, it is sufficient that it is the sum of three consecutive
integers.
f. Your guarantee is good only if you bought your TV less than 90 days ago.
Solution
12
a. If there is an inch of snow on the street, the newspaper will not come.
b. If the wind blows from the northeast, then it snows.
c. If prices go up, then supply will be plentiful.
d. If you are going to understand the materials of this course, you must read the textbook.
e. If a number is the sum of three consecutive integers, then it is divisible by 3.
f. If you guarantee is good, then you must have bought your TV less than 90 days ago.
2. Write each of the following propositions in the form "p if and only if q" in English.
a. If it is hot outside you drink a lot of water, and if you drink a lot of water it is hot outside.
b. For a program to be readable it is necessary and sufficient that it is well structured.
c. I like fruits only if they are fresh, and fruits are fresh only if I like them.
d. If you eat too much sweets your teeth will decay, and conversely.
e. The store is closed on exactly those days when I want to shop there.
Solution
a. You drink a lot of water if and only if it is hot outside.
b. A program is readable if and only if it is well structured.
c. I like fruits if and only if they are fresh.
d. Your teeth will decay if and only if you eat too much sweets.
e. The store is closed if and only if it is the day when I want to shop there.
Introduction to Reasoning
Introduction
Logical reasoning is the process of drawing conclusions from premises using rules of inference.
Here we are going to study reasoning with propositions. Later we are going to see reasoning with
predicate logic, which allows us to reason about individual objects. However, inference rules of
propositional logic are also applicable to predicate logic and reasoning with propositions is
fundamental to reasoning with predicate logic.
These inference rules are results of observations of human reasoning over centuries. Though
there is nothing absolute about them, they have contributed significantly in the scientific and
engineering progress the mankind have made. Today they are universally accepted as the rules of
logical reasoning and they should be followed in our reasoning.
Since inference rules are based on identities and implications, we are going to study them first.
We start with three types of proposition which are used to define the meaning of "identity" and
"implication".
Types of Proposition
Some propositions are always true regardless of the truth value of its component propositions.
For example (p p) is always true regardless of the value of the proposition p.
a proposition that is always true called a tautology.
13
there are also propositions that are always false such as (p p).
such a proposition is called a contradiction.
a proposition that is neither a tautology nor a contradiction is called a contingency.
for example (p q) is a contingency.
These types of propositions play a crucial role in reasoning. In particular every inference rule is
a tautology as we see in identities and implications.
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 verified by constructing truth tables for them.
First the identities are listed, then examples are given to illustrate them.
list of identities:
1. P (P P) ----- idempotence of
2. P (P P) ----- idempotence of
3. (p q) (q p) ----- commutativity of
4. (p q) (q p) ----- commutativity of
5. [(p q) r] [p (q r)] ----- associativity of
6. [(p q) r] [p (q r)] ----- associativity of
7. (p q) ( p q) ----- de Morgan's law
8. (p q) ( p q) ----- de Morgan's law
9. [p (q r] [(p q) (p r)] ----- distributivity of over
10. [p (q r] [(p q) ( p r)] ----- distributivity of over
11. (p true) true
12. (p false) false
13. (p false) p
14. (p true) p
15. (p p) true
16. (p p) false
17. p ( p) ----- double negation
18. (p q) ( p q) ----- implication
19. (p q) [(p q) (q p)]----- equivalence
14
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 manipulating propositions in reasoning in symbolic form.
2. p (p p) ----- idempotence of
Similar to 1. above.
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".
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".
is) happy." is equivalent to "Tom is rich or (he is) famous, and Tom is rich or (he is) happy".
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.
13. (p False) p
14. (p True) 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.
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.
The identities 1 ~ 16 listed above can be paired by duality relation, which is defined 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.
Dual of Proposition
Let X be a proposition involving only , , and as a connective. Let X* be the proposition
obtained from X by replacing with , with , T with F, and F with T. Then X* is called the
dual of X.
Property of Dual: If two propositions p and q involving only , , and as connectives are
equivalent, then their duals p* and q* are also equivalent.
1. (p q) (p q)
What this means is that the negation of "if p then q" is "p but not q". For example, if you said
to someone "If I win a lottery, I will give you $100,000." and later that person says "You lied to
me." Then what that person means is that you won the lottery but you did not give that person
$100,000 you promised.
To prove this, first let us get rid of using one of the identities: ( p q ) ( p q ).
That is, ( p q) ( p q ).
Then by De Morgan, it is equivalent to p q , which is equivalent to P Q, since the
double negation of a proposition is equivalent to the original proposition as seen in the identities.
2. p ( p q ) p --- Absorption
What this tells us is that p ( p q ) can be simplified to p, or if necessary p can be expanded
17
into p (p q).
a) p False False
b) p True Ttrue
c) p p p
Solution
p p False p True p p
T F T T
F F F F
1. Use truth tables to verify the distributive law p (q r) (p q) (p r).
p q r q r p (q r) p q p r (p q) (p r)
T T T T T T T T
T T F T T T F T
T F T T T F T T
T F F F F F F F
F T T T F F F F
F T F T F F F F
F F T T F F F F
F F F F F F F F
2. Show that each of the following implications is a tautology without using truth tables.
a) p (p q)
b) (p q) (p q)
c) (p q) q
Solution
a) If the hypothesis p is true, by the definition of disjunction, the conclusion p q is also true.
18
If p is false on the other hand, then by the definition of implication p (p q)is true.
Altenatively, p (p q) ( p (p q)) (( p p) q) (T q) T
b) If the hypothesis p q is true, then both p and q are true so that the conclusion p q is also
true. If the hypothesis is false, then "if-then" statement is always true.
This can also be proven similarly to the alternative proof for a).
c) If the hypothesis (p q) is true, then p q is false, so that p is true and q is false. Hence,
the conclusion q is true.If the hypothesis is false, then "if-then" statement is always true.
This can also be proven similarly to the alternative proof for a).
4. Verify the following equivalences, which are known as the absorption laws.
a) [ p (p q) ] p
b) [ p (p q) ] p
Solution
a) If p is true, then p (p q) is true since the first proposition in the disjunction is true. On the
other hand, if p is false, then p q is also false, so p (p q) is false. Since p and p (p q)
always have the same truth value, they are equivalent.
b) [ p (p q) ]
[ (p F) (p q) ]
[ (p (F q) ] [p F] p
Solution
a) (p q r)
19
b) (p q r) s
c) (p T) (q F)
6. 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 propostion istrue. Each
conjunction should include each of the three propositions or theirnegations.)
Solution
(p q r) ( p q r) ( p q r)
The following implications are some of the relationships between propositions that can be
derived from the definitions 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.
List of Implications:
1. P (P Q) ----- addition
2. (P Q) P ----- simplification
3. [P (P Q] Q ----- modus ponens
4. [(P Q) Q] P ----- modus tollens
5. [ P (P Q] Q ----- disjunctive syllogism
6. [(P Q) (Q R)] (P R) ----- hypothetical syllogism
7. (P Q) [(Q R) (P R)]
8. [(P Q) (R S)] [(P R) (Q S)]
9. [(P Q) (Q R)] (P R)
Examples:
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.
2. (P Q) P ----- simplification
For example, if it is freezing and (it is) snowing, then certainly it is freezing. Thus "If it is
20
7. (P Q) [(Q R) (P R)]
This is actually the hypothetical syllogism in another form. For by considering (P Q) as a
proposition S, (Q R) as a proposition T, and (P R) as a proposition U in the
hypothetical syllogism above, and then by applying the "exportation" from the identities, this
is obtained.
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.
Logical reasoning is the process of drawing conclusions from premises using rules of inference.
The basic inference rule is modus ponens. It states that if both P Q and P hold, then Q can
be concluded, and it is written as
21
P
P Q
Q
Here the lines above the dotted line are premises and the line below it is the conclusion drawn
from the premises.
For example if "if it rains, then the game is not played" and "it rains" are both true, then we can
conclude that the game is not played.
In addition to modus ponens, one can also reason by using identities and implications.
If the left(right) hand side of an identity appearing in a proposition is replaced by the right(left)
hand side of the identity, then the resulting proposition is logically equivalent to the original
proposition. Thus the new proposition is deduced from the original proposition. For example in
the proposition P (Q R), (Q R) can be replaced with ( Q R) to conclude
P ( Q R), since (Q R) ( Q R)
The tautologies listed as "implications" can also be considered inference rules as shown below.
P P (P Q) addition
............
P Q
P Q (P Q) P simplification
............
P
P conjunction
Q
.............
P Q
Example of Inferencing
2. But it can't be Wednesday, since the doctor's office is open today, and that office is always
closed on Wednesdays.
T: Today is Tuesday.
W: Today is Wednesday.
1. T W
2. D
C
……….
W
………
3. T
To see if this conclusion T is correct, let us first find the relationship among C, D, and W:
C can be expressed using D and W. That is, restate C first as the doctor's office is always closed
if it is Wednesday. Then C (W D) Thus substituting (W D) for C, we can proceed as
follows.
D
W D
…………
W
W
T W
………
T
To save space we also write this process as follows eliminating one of the W's:
D
W D
…………
W
T W
…………
T
To prove that this equivalence holds, let us construct a truth table for each of the proposition
(P Q) and (Q P).
P Q P Q
F F F
F T T
T F T
T T T
P Q Q P
F F F
F T T
T F T
T T T
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.
25
Using this convention for truth table we can show that the first rule of De Morgan's Laws also
holds.
P Q (P Q) P Q
F F T T
F T F F
T F F F
T T F F
By comparing the two right columns we can see that (P Q) and P Q are equivalent.
P Q P Q
F F F
F T T
T F T
T T T
Then by the definition of , we can add a column for P (P Q) to obtain the following
truth table.
P Q P Q P (P Q)
F F F T
F T T T
T F T T
T T T T
The first row in the rightmost column results since P is false, and the others in that column
follow since (P Q) is true.
2. Some of the implications can also be proven by using identities and implications that have
already been proven.
26
3. Some of them can be proven by noting that a proposition in an implication can be replaced by
an equivalent proposition without affecting its value.
Exercises
1. 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.
27
e. To go to Tahiti, one must fly or take a boat; there is no seat on any flight to Tahiti this
year. Therefore, one must take a boat to go to Tahiti this year.
Solution
a. Addition
b. Simplification
c. Modus ponens
d. Modus tollens
e. Disjunctive syllogism
2. 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 flowers are colored, they are always scented; I don't like flowers that are not grown in
the open air; All flowers grown in the open air are colored . Therefore, I don't like any
flowers that are scentless.
Symbols to be used: Flowers are colored (C). Flowers are scented (S). I like flowers (L).
Flowers are grown in the open air (O).
d. No animals, except giraffes, 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 giraffes.
Symbols to be used: Animals are giraffes (G). Animals are 15 feet or higher (F). Animals
are in the zoo (Z). Animals belong to me (M).
e. Bees like red flowers, 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 flowers. Therefore bees like red flowers.
Symbols to be used: Bees like red flowers (R). My hat is red (H). Bees like hats (L).
Solution
S O
By another hypothetical syllogism from this and O L,
S L
is obtained.
e. The argument is translated as follows:
G F
Z M
M F
…………….
Z G
Introduction
The propositional logic is not powerful enough to represent all types of assertions that are used in
computer science and mathematics, or to express certain types of relationship between
propositions such as equivalence.
For example, the assertion "x is greater than 1", where x is a variable, is not a proposition
because you can not tell whether it is true or false unless you know the value of x. Thus the
propositional logic can not deal with such sentences. However, such assertions appear quite often
30
Also the pattern involved in the following logical equivalences can not be captured by the
propositional logic:
Each of those propositions is treated independently of the others in propositional logic. For
example, if P represents "Not all birds fly" and Q represents "Some integers are not even", then
there is no mechanism in propositional logic to find out whether or not 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.
For example, the sentences "The car Tom is driving is blue", "The sky is blue", and "The cover
of this book is blue" come from the template "is blue" by placing an appropriate noun/noun
phrase in front of it. The phrase "is blue" is a predicate and it describes the property of being
blue. Predicates are often given a name. For example any of "is blue", "Blue" or "B" can be used
to represent the predicate "is blue" among others. If we adopt B as the name for the predicate "is
blue", sentences that assert an object is blue can be represented as "B(x)", where x represents an
arbitrary object. B(x) reads as "x is blue".
Similarly the sentences "John gives the book to Mary", "Jim gives a loaf of bread to Tom", and
"Jane gives a lecture to Mary" are obtained by substituting an appropriate object for variables x,
y, and z in the sentence "x gives y to z". The template "... gives ... to ..." is a predicate and it
describes a relationship among three objects. This predicate can be represented by Give ( x, y, z )
or G( x, y, z ), for example.
Note: The sentence "John gives the book to Mary" can also be represented by another predicate
such as "gives a book to". Thus if we use B( x, y ) to denote this predicate, "John gives the book
31
to Mary" becomes B( John, Mary ). In that case, the other sentences, "Jim gives a loaf of bread to
Tom", and "Jane gives a lecture to Mary", must be expressed with other predicates.
universe
universal quantifier
existential quantifier
free variable
bound variable
scope of quantifier
order of quantifiers
A predicate with variables is not a proposition. For example, the statement x > 1 with variable x
over the universe of real numbers is neither true nor false since we don't know what x is. It can
be true or false depending on the value of x.
For x > 1 to be a proposition either we substitute a specific number for x or change it to
something like "There is a number x for which x > 1 holds", or "For every number x, x > 1
holds".
More generally, a predicate with variables (called an atomic formula) can be made a
proposition by applying one of the following two operations to each of its variables:
For example, x > 1 becomes 3 > 1 if 3 is assigned to x, and it becomes a true statement, hence a
proposition.
In general, a quantification is performed on formulas of predicate logic (called wff ), such as x >
1 or P(x), by using quantifiers on variables. There are two types of quantifiers: universal
quantifier and existential quantifier.
The universal quantifier turns, for example, the statement x > 1 to "for every object x in the
universe, x > 1", which is expressed as " x, x > 1". This new statement is true or false in the
universe of discourse. Hence it is a proposition once the universe is specified.
Similarly the existential quantifier 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 specified.
Universe of Discourse
The universe of discourse, also called universe, is the set of objects of interest. The propositions
in the predicate logic are statements on objects of a universe. The universe is thus the domain of
32
the (individual) variables. It can be the set of real numbers, the set of integers, the set of all cars
on a parking lot, the set of all students in a classroom etc. The universe is often left implicit in
practice. But it should be obvious from the context.
The expression: x P(x), denotes the universal quantification of the atomic formula P(x).
Translated into the English language, the expression is understood as: "For all x, P(x) holds",
"for each x, P(x) holds" or "for every x, P(x) holds". is called the universal quantifier, and x
means all the objects x in the universe. If this is followed by P(x) then the meaning is that P(x) is
true for every object x in the universe. For example, "All cars have wheels" could be transformed
into the propositional form, x P(x), where:
For example, in the above example of x P(x), if we knew that there were only 4 cars in our
universe of discourse (c1, c2, c3 and c4) then we could also translate the statement as: P(c1)
P(c2) P(c3) P(c4)
The expression: x P(x), denotes the existential quantification of P(x). Translated into the
English language, the expression could also be understood as: "There exists an x such that P(x)"
or "There is at least one x such that P(x)" is called the existential quantifier, and x means at
least one object x in the universe. If this is followed by P(x) then the meaning is that P(x) is true
for at least one object x of the universe. For example, "Someone loves you" could be transformed
into the propositional form, x P(x), where:
For example, in the above example of x P(x), if we knew that there were only 5 living creatures
in our universe of discourse (say: me, he, she, rex and fluff), then we could also write the
statement as: P(me) P(he) P(she) P(rex) P(fluff)
For example, let the universe be the set of airplanes and let F(x, y) denote "x flies faster than y".
Then
x y F(x, y) can be translated initially as "For every airplane x the following holds: x is faster
than every (any) airplane y". In simpler English it means "Every airplane is faster than every
airplane (including itself !)".
x y F(x, y) can be read initially as "For every airplane x the following holds: for some
airplane y, x is faster than y". In simpler English it means "Every airplane is faster than some
airplane".
x y F(x, y) represents "There exist an airplane x which satisfies the following: (or such that)
for every airplane y, x is faster than y". In simpler English it says "There is an airplane which is
faster than every airplane" or "Some airplane is faster than every airplane".
x y F(x, y) reads "For some airplane x there exists an airplane y such that x is faster than y",
which means "Some airplane is faster than some airplane".
The positions of the same type of quantifiers can be switched without affecting the truth value as
long as there are no quantifiers of the other type between the ones to be interchanged.
For example x y z P(x, y , z) is equivalent to y x z P(x, y , z), z y x
P(x, y , z), etc. It is the same for the universal quantifier.
Not all strings can represent propositions of the predicate logic. Those which produce a
proposition when their symbols are interpreted must follow the rules given below, and they are
called wffs (well-formed formulas) of the first order predicate logic.
(Note : More generally, arguments of predicates are something called a term. Also variables
representing predicate names (called predicate variables) with a list of variables can form atomic
formulas. But we do not get into that here.
For example, "The capital of Virginia is Richmond." is a specific proposition. Hence it is a wff
by Rule 2.
Let B be a predicate name representing "being blue" and let x be a variable. Then B(x) is an
35
atomic formula meaning "x is blue". Thus it is a wff by Rule 3. above. By applying Rule 5. to
B(x), xB(x) is a wff and so is xB(x). Then by applying Rule 4. to them x B(x) x B(x) is
seen to be a wff. Similarly if R is a predicate name representing "being round". Then R(x) is an
atomic formula. Hence it is a wff. By applying Rule 4 to B(x) and R(x), a wff B(x) R(x) is
obtained.
In this manner, larger and more complex wffs can be constructed following the rules given
above.
Note, however, that strings that can not be constructed by using those rules are not wffs. For
example, xB(x)R(x), and B( x ) are NOT wffs, NOR are B( R(x) ), and B( x R(x) ) .
One way to check whether or not an expression is a wff is to try to state it in English. If you
can translate it into a correct English sentence, then it is a wff.
More examples: To express the fact that Tom is taller than John, we can use the atomic formula
taller(Tom, John), which is a wff. This wff can also be part of some compound statement such
as taller (Tom, John) taller(John, Tom), which is also a wff.
However, taller( x, John) and taller (Tom Mary, Jim), for example, are NOT wffs.
Exercises
1. 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)
2. 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 quantifications in English.
a. x P(x)
b. x P(x)
c. x P(x)
d. x P(x)
3. 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)
36
d. P(-1)
e. x P(x)
f. x P(x)
4. 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 y P(x, y)
d. x y P(x, y)
e. x y P(x, y)
f. y x P(x, y)
Solution
1. a) T b) F c) T d) F
3. a) F b) T c) F d)F e) T f) F
Sets
• Set: Collection of objects (called elements)
• aA “a is an element of A”
“a is a member of A”
• aA “a is not an element of A”
• A = {a1, a2, …, an} “A contains a1, …, an”
• Order of elements is insignificant
37
• It does not matter how often the same element is listed (repetition doesn’t count).
Set Equality
Sets A and B are equal if and only if they contain exactly the same elements.
Examples:
“Standard” Sets:
R = {r | r is a real number}
It can neither be defined by enumeration nor builder function.
Subsets
AB “A is a subset of B”
Useful rules:
• A = B (A B) (B A)
• (A B) (B C) A C (see Venn Diagram)
U
C
• A for any set A (but A may not hold for any set A)
Proper subsets:
Cardinality of Sets
If a set S contains n distinct elements, nN, we call S a finite set with cardinality n.
Examples:
C= , |C| = 0
39
Examples:
A = {x, y, z}
P(A) = {, {x}, {y}, {z}, {x, y}, {x, z}, {y, z}, {x, y, z}}
A=
P(A) = {}
Cartesian Product
The ordered n-tuple (a1, a2, a3, …, an) is an ordered collection of n objects.
Two ordered n-tuples (a1, a2, a3, …, an) and (b1, b2, b3, …, bn) are equal if and only if they
contain exactly the same elements in the same order, i.e. ai = bi for 1 i n.
The Cartesian product of two sets is defined as: AB = {(a, b) | aA bB}
Example:
Note that:
• A =
• A =
• For non-empty sets A and B: AB AB BA
• |AB| = |A||B|
The Cartesian product of two or more sets is defined as: A1A2…An = {(a1, a2, …, an) | aiAi
for 1 i n}.
Set Operations
Union: AB = {x | xA xB}
Two sets are called disjoint if their intersection is empty, that is, they share no elements:
AB =
The difference between two sets A and B contains exactly those elements of A that are not in B:
The complement of a set A contains exactly those elements under consideration that are not in A:
denoted Ac (or as in the text)
Ac = U-A
Logical Equivalence
Equivalence laws
– Identity laws, P T P,
– Domination laws, P F F,
– Idempotent laws, P P P,
– Double negation law, ( P) P
– Commutative laws, P Q Q P,
– Associative laws, P (Q R) (P Q) R,
– Distributive laws, P (Q R) (P Q) (P R),
– De Morgan’s laws, (PQ) ( P) ( Q)
– Law with implication PQPQ
Set Identity
xA(BC)
xA x(BC)
xA (xB xC)
(xA xB) (xA xC) (distributive law)
x(AB) x(AC)
x(AB)(AC)
Every logical expression can be transformed into an equivalent expression in set theory and vice
versa.
42
Functions
Definition
A function f from a set A to a set B is an assignment of exactly one element of B to each element
of A.
We write f(a) = b if b is the unique element of B assigned by the function f to the element a of A.
If f is a function from A to B, we write f: AB (note: Here, ““ has nothing to do with if…
then).
If f:AB, we say that A is the domain of f and B is the codomain of f.
If f(a) = b, we say that b is the image of a and a is the pre-image of b.
The range of f:AB is the set of all images of all elements of A.
We say that f:AB maps A to B.
Example
Let us take a look at the function f:PC with
P = {Linda, Max, Kathy, Peter}
C = {Huye,Nyarugenge , Musanze, Bugesera}
f(Linda) = Bugesera
f(Max) = Musanze
f(Kathy) = Nyarugenge
f(Peter) = Huye
Here, the range of f is C.
If the domain of our function f is large, it is convenient to specify f with a formula, e.g.:
f: RR: f(x) = 2x. This leads to: f(1) = 2, f(3) = 6, f(-3) = -6 …
Example:
f1(x) = 3x, f2(x) = x + 5
(f1 + f2)(x) = f1(x) + f2(x) = 3x + x + 5 = 4x + 5
(f1f2)(x) = f1(x) f2(x) = 3x (x + 5) = 3x2 + 15x
We already know that the range of a function f:AB is the set of all images of elements aA.
If we only regard a subset SA, the set of all images of elements sS is called the image of S.
We denote the image of S by f(S):
f(S) = {f(s) | sS}
Properties of Functions
In other words: f is one-to-one if and only if it does not map two distinct elements of A onto the
same element of B.
And again…
f(Linda) = Bugesera
f(Max) = Musanze
f(Kathy) = Nyarugenge
f(Peter) = Musanze
Is f one-to-one?
No, Max and Peter are mapped onto the same element of the image.
44
g(Linda) = Bugesera
g(Max) = Musanze
g(Kathy) = Nyarugenge
g(Peter) = Huye
Is g one-to-one?
Whenever you want to prove something, first take a look at the relevant definition(s):
Example:
f:RR
f(x) = x2
Disproof by counterexample:
f:RR
f(x) = 3x
xy
3x 3y
f(x) f(y),
3. A function f:AB is called onto, or surjective, if and only if for every element bB there is
an element aA with
f(a) = b.
In other words, f is onto if and only if its range is its entire codomain.
Obviously, if f is a bijection and A and B are finite sets, then |A| = |B|.
Examples:
In the following examples, we use the arrow representation to illustrate functions f:AB.
In each example, the complete sets A and B are shown.
A B
Linda Musanze
Max Huye
Kathy Nyarugenge
Peter Bugesera
Is f injective? No.
Is f surjective?No.
Is f bijective? No.
46
A B
Linda Musanze
Max Huye
Kathy Nyarugenge
Peter Bugesera
Paul
Is f injective? No.
Is f surjective?Yes.
Is f bijective? No
A B
Linda Musanze
Max Huye
Kathy Nyarugenge
Peter Bugesera
Nyanza
Is f injective? Yes.
Is f surjective?No.
Is f bijective? No
A B
Linda Musanze
Max Huye
Kathy Nyarugenge
Peter Bugesera
Nyanza
47
A B
Linda Musanze
Max Huye
Kathy Nyarugenge
Peter Bugesera
Helena Nyanza
Is f injective?Yes.
Is f surjective?Yes.
Is f bijective? Yes.
5 Inversion
The inverse function of the bijection f:AB is the function f-1:BA with f-1(b) = a whenever
f(a) = b.
Example:
f(Linda) = Bugesera
f(Max) = Musanze
f(Kathy)= Nyarugenge
f(Peter) = Huye
f(Helena) = Nyanza
Clearly, f is bijective.
f-1(Bugesera) = Linda
f-1(Musanze) = Max
f-1(Nyarugenge)= Kathy
f-1(Huye) = Peter
f-1(Nyanza) = Helena
A B
Linda Nyanza f: A B
Kathy Nyarugenge
Peter Bugesera
Helena Huye
f-1:BA is not function, because it is not defined for all elements of B and assigns two images to
the pre-image Musanze.
Composition
The composition of two functions g: AB and f:BC, denoted by fg, is defined by
(fg)(a) = f(g(a))
Example:
f:RR, g:RR
(f-1f)(x) = f-1(f(x)) = x
The composition of a function and its inverse is the identity function i(x) = x.
49
Boolean Algebra
Boolean algebra provides the operations and the rules for working with the set {0, 1}.
• Boolean complementation,
• Boolean sum, and
• Boolean product
Boolean Operations
The complement is denoted by a bar (on the slides, we will use a minus sign). It is defined by
-0 = 1 and -1 = 0.
1 + 1 = 1, 1 + 0 = 1, 0 + 1 = 1, 0+0=0
1 1 = 1, 1 0 = 0, 0 1 = 0, 00=0
Definition: Let B = {0, 1}. The variable x is called a Boolean variable if it assumes values only
from B.
Boolean functions can be represented using expressions made up from the variables and Boolean
operations.
The Boolean expressions in the variables x1, x2, …, xn are defined recursively as follows:
Each Boolean expression represents a Boolean function. The values of this function are obtained
by substituting 0 and 1 for the variables in the expression.
50
For example, we can create Boolean expression in the variables x, y, and z using the “building
blocks”
0, 1, x, y, and z, and the construction rules:
… and so on…
Example: Give a Boolean expression for the Boolean function F(x, y) as defined by the
following table:
x y F(x, y)
0 0 0
0 1 1
1 0 0
1 1 0
Another Example:
x y z F(x, y, z)
Possible solution I: F(x, y, z) = -(xz + y)
0 0 0 1
0 0 1 1
0 1 0 0
0 1 1 0 Possible solution II: F(x, y, z) = (-(xz))(-y)
1 0 0 1
1 0 1 0
1 1 0 0
1 1 1 0
There is a simple method for deriving a Boolean expression for a function that is defined by a
table. This method is based on minterms.
Hence, a minterm is a product of n literals, with one literal for each variable.
51
Definition: The Boolean functions F and G of n variables are equal if and only if F(b1, b2, …,
bn) = G(b1, b2, …, bn) whenever b1, b2, …, bn belong to B.
Two different Boolean expressions that represent the same function are called equivalent.
For example, the Boolean expressions xy, xy + 0, and xy1 are equivalent.
The complement of the Boolean function F is the function –F, where –F(b1, b2, …, bn) =
-(F(b1, b2, …, bn)).
Let F and G be Boolean functions of degree n. The Boolean sum F+G and Boolean product FG
are then defined by
Solution: There are four of them, F1, F2, F3, and F4:
x F1 F2 F3 F4
0 0 1 0 1
1 0 0 1 1
52
Solution:
Duality
There are useful identities of Boolean expressions that can help us to transform an expression A
into an equivalent expression B
We can derive additional identities with the help of the dual of a Boolean expression.
The dual of a Boolean expression is obtained by interchanging Boolean sums and Boolean
products and interchanging 0s and 1s.
Examples:
This dual function, denoted by Fd, does not depend on the particular Boolean expression used to
represent F.
We can use this fact, called the duality principle, to derive new identities.
By taking the duals of both sides of this identity, we obtain the equation x + xy = x, which is also
an identity (and also called an absorption law).
All the properties of Boolean functions and expressions that we have discovered also apply to
other mathematical structures such as propositions and sets and the operations defined on
them.
If we can show that a particular structure is a Boolean algebra, then we know that all results
established about Boolean algebras apply to this structure.
Definition: A Boolean algebra is a set B with two binary operations and , elements 0 and 1,
and a unary operation – such that the following properties hold for all x, y, and z in B:
(x y) z = x (y z) and
(x y) z = x (y z) and (associative laws)
x (y z) = (x y) (x z) and
x (y z) = (x y) (x z) (distributive laws)
Logic Gates
Inverter
54
OR gate
AND gate
Example: How can we build a circuit that computes the function xy + (-x)y ?
False 0
True U 1
A AC Ā
EXERCISES
Home work
Relations
If we want to describe a relationship between elements of two sets A and B, we can use ordered
pairs with their first element taken from A and their second element taken from B.
Example: Let P be a set of people, C be a set of cars, and D be the relation describing which
person drives which car(s).
This means that Carl drives a Mercedes, Suzanne drives a Mercedes and a BMW, Peter drives a
tricycle, and Carla does not drive any of these vehicles.
Functions as Relations
You might remember that a function f from a set A to a set B assigns a unique element of B to
each element of A.
The graph of f is the set of ordered pairs (a, b) such that b = f(a).
56
Moreover, for each element a of A, there is exactly one ordered pair in the graph that has a as its
first element.
Conversely, if R is a relation from A to B such that every element in A is the first element of
exactly one ordered pair of R, then a function can be defined with R as its graph.
This is done by assigning to an element aA the unique element bB such that (a, b)R.
Relations on a Set
Example: Let A = {1, 2, 3, 4}. Which ordered pairs are in the relation R = {(a, b) | a < b} ?
Solution: R = {(1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4)}
1 1
2 2
3 3
4 4
R 1 2 3 4
1 X X X
2 X X
3 X
4
There are n2 elements in AA, so how many subsets (= relations on A) does AA have?
57
2
The number of subsets that we can form out of a set with m elements is 2m. Therefore, 2𝑛
subsets can be formed out of AA.
2
Answer: We can define 2𝑛 different relations on A.
Properties of Relations
Definition: A relation R on a set A is called reflexive if (a, a)R for every element aA.
R = {(1, 1), (1, 2), (2, 3), (3, 3), (4, 4)} No.
R = {(1, 1), (2, 2), (2, 3), (3, 3), (4, 4)} Yes.
Definition: A relation on a set A is called irreflexive if (a, a)R for every element aA.
Definitions:
A relation R on a set A is called symmetric if (b, a)R whenever (a, b)R for all a, bA.
R = {(1, 1), (1, 2), (2, 1), (3, 3), (4, 4)} symmetric
Definition: A relation R on a set A is called transitive if whenever (a, b)R and (b, c)R, then
(a, c)R for a, b, cA.
R = {(1, 1), (1, 2), (2, 2), (2, 1), (3, 3)} No.
Counting Relations
Example: How many different reflexive relations can be defined on a set A containing n
elements?
Therefore, different relations on A can be generated by choosing different subsets out of these n2
2
elements, so there are 2𝑛 relations.
A reflexive relation, however, must contain the n elements (a, a) for every aA.
Equivalence Relations
Equivalence relations are used to relate objects that are similar in some way.
Two elements that are related by an equivalence relation R are called equivalent.
Since R is transitive, if a and b are equivalent and b and c are equivalent, then a and c are
equivalent.
Obviously, these three properties are necessary for a reasonable definition of equivalence.
Example: Suppose that R is the relation on the set of strings that consist of English letters such
that aRb if and only if l(a) = l(b), where l(x) is the length of the string x. Is R an equivalence
relation?
59
Solution:
R is an equivalence relation.
Equivalence Classes
Definition: Let R be an equivalence relation on a set A. The set of all elements that are related to
an element a of A is called the equivalence class
of a.
When only one relation is under consideration, we will delete the subscript R and write [a] for
this equivalence class.
Example: In the previous example (strings of identical length), what is the equivalence class of
the word mouse, denoted by [mouse] ?
Solution: [mouse] is the set of all English words containing five letters.
Theorem: Let R be an equivalence relation on a set A. The following statements are equivalent:
• aRb
• [a] = [b]
• [a] [b]
• Ai Aj = , if i j
• iI Ai = S
Example: Let us assume that Frank, Suzanne and George live in Boston, Stephanie and Max live
in Lübeck, and Jennifer lives in Sydney.
Let R be the equivalence relation {(a, b) | a and b live in the same city} on the set P = {Frank,
Suzanne, George, Stephanie, Max, Jennifer}.
Then R = {(Frank, Frank), (Frank, Suzanne), (Frank, George), (Suzanne, Frank), (Suzanne,
Suzanne), (Suzanne, George), (George, Frank), (George, Suzanne), (George, George),
(Stephanie,Stephanie), (Stephanie, Max), (Max, Stephanie),(Max, Max), (Jennifer, Jennifer)}.
This is a partition of P.
The equivalence classes of any equivalence relation R defined on a set S constitute a partition of
S, because every element in S is assigned to exactly one of the equivalence classes.
Is R an equivalence relation?
“How many possible ways are there to pick 11 soccer players out of a 20-player team?”
Most importantly, counting is the basis for computing probabilities of discrete events.
If a task can be done in n1 ways and a second task in n2 ways, and if these two tasks cannot be
done at the same time, then there are n1 + n2 ways to do either task.
Example:
How many different choices are there, if there are 530 students and 15 professors?
If we have tasks T1, T2, …, Tm that can be done in n1, n2, …, nm ways, respectively, and no two
of these tasks can be done at the same time, then there are n1 + n2 + … + nm ways to do one of
these tasks.
Suppose that a procedure can be broken down into two successive tasks. If there are n1 ways to
do the first task and n2 ways to do the second task after the first task has been done, then there
are n1n2 ways to do the procedure.
Example:
How many different license plates are there that containing exactly three English letters ?
62
Solution:
There are 26 possibilities to pick the first letter, then 26 possibilities for the second one, and 26
for the last one.
If we have a procedure consisting of sequential tasks T1, T2, …, Tm that can be done in n1, n2, …,
nm ways, respectively, then there are n1 n2 … nm ways to carry out the procedure.
The sum and product rules can also be phrased in terms of set theory.
Sum rule: Let A1, A2, …, Am be disjoint sets. Then the number of ways to choose any element
from one of these sets is |A1 A2 … Am | =
|A1| + |A2| + … + |Am|.
Product rule: Let A1, A2, …, Am be finite sets. Then the number of ways to choose one element
from each set in the order A1, A2, …, Am is
|A1 A2 … Am | = |A1| |A2| … |Am|.
If (k + 1) or more objects are placed into k boxes, then there is at least one box containing two
or more of the objects.
Example 1: If there are 11 players in a soccer team that wins 12-0, there must be at least one
player in the team who scored at least twice.
Example 2: If you have 6 classes from Monday to Friday, there must be at least one day on
which you have at least two classes.
The generalized pigeonhole principle: If N objects are placed into k boxes, then there is at
least one box containing at least N/k of the objects.
Example 1: In our 60-student class, at least 12 students will get the same letter grade (A, B,
C, D, or F).
The number of r-permutations of a set with n distinct elements is denoted by P(n, r).
(n choices for the first element, (n – 1) for the second one, (n – 2) for the third one…)
Example:
= (87654321)/(54321)
General formula:
The number of r-combinations of a set with n distinct elements is denoted by C(n, r).
Example: C(4, 2) = 6, since, for example, the 2-combinations of a set {1, 2, 3, 4} are {1, 2}, {1,
3}, {1, 4}, {2, 3}, {2, 4}, {3, 4}.
The number of r-combinations of a set with n distinct elements is denoted by C(n, r).
64
Example: C(4, 2) = 6, since, for example, the 2-combinations of a set {1, 2, 3, 4} are {1, 2}, {1,
3}, {1, 4}, {2, 3}, {2, 4}, {3, 4}.
Consider that we can obtain the r-permutation of a set in the following way:
Then, we generate all possible orderings in each of these r-combinations (there are P(r, r) such
orderings in each case).
= n!/(r!(n – r)!)
Question
How many ways are there to pick a set of 3 people from a group of 6 (disregarding the order of
picking)?
Corollary:
Note that “picking a group of r people from a group of n people” is the same as “splitting a
group of n people into a group of r people and another group of (n – r) people”.
Example:
A soccer club has 8 female and 7 male members. For today’s match, the coach wants to have 6
female and 5 male players on the grass. How many possible configurations are there?
= 2821
= 588
Combinations
n! n!
C (n, n r ) C (n, r )
(n r )![n (n r )]! (n r )!r!
This symmetry is intuitively plausible. For example, let us consider a set containing six elements
(n = 6).
Picking two elements and leaving four is essentially the same as picking four elements and
leaving two.
In either case, our number of choices is the number of possibilities to divide the set into one set
containing two elements and another set containing four elements.
Pascal’s Identity:
Imagine a set S containing n elements and a set T containing (n + 1) elements, namely all
elements in S plus a new element a.
Pascal’s Triangle
In Pascal’s triangle, each number is the sum of the numbers to its upper left and upper right:
1
1 1
1 2 1
1 3 3 1
1 4 6 4
1 5 10 10 5 1
… … … … … … …
C(0, 0) = 1
C(1, 0) = 1 C(1, 1) = 1
Binomial Coefficients
How come?
When expanding such expressions, we have to form all possible products of a term in the first
factor and a term in the second factor:
(a + b)2 = a2 + 2ab + b2
67
There is only one term a3, because there is only one possibility to form it: Choose a from all
three factors: C(3, 3) = 1.
There is three times the term a2b, because there are three possibilities to choose a from two out
of the three factors: C(3, 2) = 3.
With the help of Pascal’s triangle, this formula can considerably simplify the process of
expanding powers of binomial expressions.
Hints
1. P(x), Q(x), and R(x) be the statements “x is a lion,” “x is fierce,” and “x drinks coffee,” respectively.
Assuming that the domain consists of all creatures, express the statements in the argument using quantifiers
and P(x), Q(x), and R(x).
∀x(P(x) → Q(x)).
∃x(P(x) ∧ ¬R(x)).
∃x(Q(x) ∧ ¬R(x)).
Notice that the second statement cannot be written as ∃x(P(x)→¬R(x)). The reason is that
P(x)→¬R(x) is true whenever x is not a lion, so that ∃x(P(x)→¬R(x)) is true as long as
there is at least one creature that is not a lion, even if every lion drinks coffee. Similarly, the
68
2 Consider these statements, of which the first three are premises and the fourth is a valid conclusion.
“All hummingbirds are richly colored.”
“No large birds live on honey.”
“Birds that do not live on honey are dull in color.”
“Hummingbirds are small.”
Let P(x), Q(x), R(x), and S(x) be the statements “x is a hummingbird,” “x is large,” “x lives on
honey,” and “x is richly colored,” respectively. Assuming that the domain consists of all birds,
express the statements in the argument using quantifiers and P(x), Q(x), R(x), and S(x).
3 Let P(x), Q(x), and R(x) be the statements “x is a clear explanation,” “x is satisfactory,” and “x is an excuse,”
respectively. Suppose that the domain for x consists of all English text. Express each of these statements using quantifiers,
logical connectives, and P(x), Q(x), and R(x).
Solution: The pair (1, 1) is in R1, R3, R4, and R6; (1, 2) is in R1 and R6; (2, 1) is in R2, R5,
and R6; (1,−1) is in R2, R3, and R6; and finally, (2, 2) is in R1, R3, and R4
5 There are 32 microcomputers in a computer center. Each microcomputer has 24 ports. How
many different ports to a microcomputer in the center are there?
Solution: The procedure of choosing a port consists of two tasks, first picking a microcomputer
and then picking a port on this microcomputer. Because there are 32 ways to choose the microcomputer
and 24 ways to choose the port no matter which microcomputer has been selected, the product rule shows that
there are 32 · 24 = 768 ports.
69
6 How many different license plates can be made if each plate contains a sequence of three
uppercase English letters followed by three digits (and no sequences of letters are prohibited,
even if they are obscene)?
26 choices for each letter 10 choices for each digit
Solution: There are 26 choices for each of the three uppercase English letters and ten choices for
each of the three digits. Hence, by the product rule there are a total of 26 · 26 · 26 · 10 · 10 · 10 =
17,576,000 possible license plates.
7 Let f1 and f2 be functions from R to R such that f1(x) = x2 and f2(x) = x − x2. What are
the functions f1 + f2 and f1f2?
Solution: From the definition of the sum and product of functions, it follows that
(f1 + f2)(x) = f1(x) + f2(x) = x2 + (x − x2) = x
and
(f1f2)(x) = x2(x − x2) = x3 − x4.
8 A total of 1232 students have taken a course in Spanish, 879 have taken a course in French,
and 114 have taken a course in Russian. Further, 103 have taken courses in both Spanish and
French, 23 have taken courses in both Spanish and Russian, and 14 have taken courses in both
French and Russian. If 2092 students have taken at least one of Spanish, French, and Russian,
how many students have taken a course in all three languages?
Solution: Let S be the set of students who have taken a
course in Spanish, F the set of students
who have taken a course in French, and R the set of
students who have taken a course in Russian.
Then
|S| = 1232, |F| = 879, |R| = 114,
|S ∩ F| = 103, |S ∩ R| = 23, |F ∩ R| = 14,
and
|S ∪ F ∪ R| = 2092.
When we insert these quantities into the equation
|S ∪ F ∪ R| = |S| + |F| + |R| − |S ∩ F| − |S ∩ R| − |F ∩ R|
+ |S ∩ F ∩ R|
we obtain
2092 = 1232 + 879 + 114 − 103 − 23 − 14 + |S ∩ F ∩ R|.
We now solve for |S ∩ F ∩ R|. We find that |S ∩ F ∩ R| = 7. Therefore, there are seven students
who have taken courses in Spanish, French, and Russian. This is illustrated in Figure above
70
10 How many students must be in a class to guarantee that at least two students receive the same
score on the final exam, if the exam is graded on a scale from 0 to 100 points?
Solution: There are 101 possible scores on the final. The pigeonhole principle shows that among
any 102 students there must be at least 2 students with the same score.