Module Title DISCRETE STRUCTURES FOR COM

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 70

1

College of Science and technology


Department of Computer Science
Academic year: 2016-2017

Module title: DISCRETE STRUCTURES FOR


COMPUTING

Module code: CSC 1263

Lecturer: Mr. Joseph SUNDAY


2

COURSE OUTLINE

Unit 1: History and overview


1.1 Knowledge themes include sets, logic, functions, and graphs
1.2 Contributors to the subject
1.3 Purpose and role of discrete structures in computer engineering
1.4 Contrasts between discrete-time models vs. continuous-time models
Unit 2 and 3: Basic logic and proof techniques
2.1 Propositional logic
2.2 Logical connectives
2.3 Truth tables
2.4 Use of logic to illustrate connectives
2.5 Normal forms (conjunctive and disjunctive)
2.6 Predicate logic
2.7 Universal and existential quantification
2.8 Limitations of predicate logic
2.9 Boolean algebra
2.10 Applications of logic to computer engineering
Unit 3: Proof techniques
4.1 Notions of implication, converse, inverse, negation, and contradiction
4.2 The structure of formal proofs
4.3 Direct proofs
4.4 Proof by counterexample, contraposition, and contradiction
4.5 Mathematical induction and strong induction
Unit 4 and 5: Sets, Functions and Relations
3.1 Sets (Venn diagrams, complements, Cartesian products, power sets)
3.2 Functions (one-to-one, onto, inverses, composition)
3.2 Relations (reflexivity, symmetry, transitivity, equivalence relations)
3.3 Discrete versus continuous functions and relations
3.5 Cardinality and countability
Unit 5: Basics of counting
5.1 Permutations and combinations
5.2 Counting arguments rule of products, rule of sums
5.3 The pigeonhole principle
5.4 Generating functions
5.6 Applications to computer engineering
Unit 6: Recursion
6.1 Recursive mathematical definitions
6.2 Developing recursive equations
6.3 Solving recursive equations
6.7 Applications of recursion to computer engineering
3

REFERENCES

Rosen, Kenneth H.: Discrete mathematics and its applications — 7th edition

ASSESSMENT:

Assignments : 10%

Quiz : 10%

Examinations: CATS : 30%


FINAL 50%

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

(b) Temperature recorded every half hour at a weather bureau. Ans. C


(c) Lifetimes of television tubes produced by a company Ans. C
(d) Yearly incomes of college professors. Ans. D
(e) Lengths of 1000 bolts produced in a factory. Ans. C
(f) Number of millimetres of rainfall in a city during various months of the year. Ans. C
(g) Speed of an automobile in kilometres per hour. Ans. C
(h) Number of 5000 Rwandan francs notes circulating in Rwanda at any time. Ans. D
(i) Student enrolment in a university over a number of years. Ans. D
(j) The exam results in(marks) in a given module. Ans. C

UNIT 2: BASIC LOGIC


It (logic) is covered in Chapter 1 of the reference textbook. It (logic) is a language that captures
the essence of our reasoning, and correct reasoning must follow the rules of this language. It
allows us to reason with statements involving variables among others.

2.1 PROPOSITIONAL LOGIC

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.

Elements of Propositional Logic


Simple sentences which are true or false are basic propositions. Larger and more complex
sentences are constructed from basic propositions by combining them with connectives. Thus
propositions and connectives are the basic elements of propositional logic. Though there are
many connectives, we are going to use the following five basic connectives here:
NOT(negation) is denoted by the symbol
AND (conjunction) is denoted by the symbol
OR (disjunction) is denoted by the symbol
IF_THEN (or IMPLY) (conditional statement or implication) is denoted by the symbol
IF_AND_ONLY_IF(biconditional statement) and is denoted by the symbol

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.

(a) Truth Table of Negation of a proposition p


p p
T F
F T
6

This table shows that if p is true, then ( p) is false, and that if p is false, then ( p) is true.

(b) Truth Table of Conjunction of propositions p and q

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.

(c) Truth Table of Disjunction of propositions p and q

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.

(d) Implication (conditional statement) of propositions p and q

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.

(e) Biconditional statement of propositions p and q

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.

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.

Construction of Complex Propositions


(a) Converse and Contrapositive
For the proposition p q, the proposition q p is called its converse, and the proposition
q p is called its contrapositive.
For example for the proposition "If it rains, then I get wet",
Converse: If I get wet, then it rains.
Contrapositive: If I don't get wet, then it does not rain.

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?

a. Kigali is the capital of Rwanda.


b. 2 + 3 = 7.
c. Open the door.
d. 5 + 7 < 10.
e. The moon is a satellite of the earth.
f. x + 5 = 7.
g. x + 5 > 9 for every real number x.

Solution
a. Yes, True
b. Yes, False
c. No
d. Yes, False
e. Yes, True
8

f. No
g. No

2. What is the negation of each of the following propositions?

a. Kigali is the capital of Rwanda.


b. Food is not expensive in Huye.
c. 3 + 5 = 7.
d. The summer in France is hot and sunny.
Solution
a. Kigali is not the capital of Rwanda.
b. Food is expensive in Huye.
c. 3 + 5 7.
d. The summer in France is not hot or (the summer in France is) not sunny.

3. Let p and q be the propositions

p: Your car is out of gas.


q: You can't drive your car.

Write the following propositions using p and q and logical connectives.


a) Your car is not out of gas.
b) You can't drive your car if it is out of gas.
c) Your car is not out of gas if you can drive it.
d) If you can't drive your car then it is out of gas.
Solution
a) p
b) p q
c) q p
d) q p

4. Determine whether each of the following implications is true or false.


a) If 0.5 is an integer, then 1 + 0.5 = 3.
b) If cars can fly, then 1 + 1 = 3.
c) If 5 > 2 then pigs can fly.
d) If 3*5 = 15 then 1 + 2 = 3.
Solution
a) True (because the condition is false)
b) True (because the condition is false)
c) False
d) True
9

5. State the converse and contrapositive of each of the following implications.


a. If it snows today, I will stay home.
b. We play the game if it is sunny.
c. If a positive integer is a prime then it has no divisors other than 1 and itself.
Solution

a. Converse: "If I stay home, then it snows today. "


Contrapositive: "If I do not stay home, then it does not snow today. quot;
b. Converse: "If we play the game, then it is sunny."
Contrapositive: "If we don't play the game, then it is not sunny."
c. Converse: "If a positive integer has no divisors other than 1 and itself then it is a prime."
Contrapositive: "If a positive integer has divisors other than 1 and itself then it is not a prime.

6. Construct a truth table for each of the following compound propositions.

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

Use of logic to illustrate connectives


1. If_Then Variations

 different ways of saying if_then: only if, necessary, sufficient


10

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".

2.From English to Proposition


 translation of English sentences to propositions
As we are going to see in the next section, reasoning is done on propositions using inference
rules. For example, if the two propositions "if it snows, then the school is closed", and "it snows"
are true, then we can conclude that "the school is closed" is true. In everyday life, that is how we
reason.

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.

Identities of propositional logic and Dual propositions

Identities of propositional logic


From the definitions 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 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

20. [(p q) r] [p (q r)] ----- exportation


21. [(p q) (p q)] p ----- absurdity
22. (p q) ( q p) ----- contrapositive

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".

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".

6. [(p q) r] [p (q r)] ----- associativity of


Similar to 5. above.

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."

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."

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".

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
15

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.

12. (p False) False

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.

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."

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.

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."

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."
16

21. [(p q) (p q)] 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 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.

For example, the dual of [p q] p is [p q] p, and the dual of [ p q] [t r]


is [ p q] [f r] .

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.

Examples of Use of Identities


Here a few examples are presented to show how the identities in Identities can be used to prove
some useful results.

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).

To prove this, first note that P ( P T ).


Hence
P (P Q)
(P T) (P Q)
P ( T Q ) , by the distributive law.
( P T ) , since ( T Q ) T.
P , since ( P T ) P.

Note that by the duality


P (P Q) P also holds.
Exercises
1. Use truth table to verify the following equivalences.

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.

This can also be proven similarly to b).

b) [ p (p q) ]

[ (p F) (p q) ]

[ (p (F q) ] [p F] p

This can also be proven similarly to a).

5. Find the dual of each of the following propositions.


a. p q r
b. (p q r) s
c. (p F) (q T)

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)

Implications of propositional logic

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

freezing and (it is) snowing, then it is freezing."

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.
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, (P Q) is equivalent to ( Q ) ( P ). Thus if in addition Q holds,
then by the modus ponens, 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.

6. [(P Q) (Q R)] (P R) ----- 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. (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.

8. [(P Q) (R S)] [(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 flooded." are true, then the statement "If the wind blows hard and it
rains heavily, then the beach erodes and the streets get flooded." is also true.

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.

Reasoning with Propositions

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)

Similarly if the left(right) hand side of an implication appearing in a proposition is replaced by


the right(left) hand side of the implication, then the resulting proposition is logically implied by
the original proposition. Thus the new proposition is deduced from the original proposition.

The tautologies listed as "implications" can also be considered inference rules as shown below.

Rules of Inference Tautological Form Name

P P (P Q) addition
............
P Q

P Q (P Q) P simplification
............
P

P [P (P Q)] Q modus ponens


P Q
............
Q
22

Q [ Q (P Q)] P modus tollens


P Q
...........
P

P Q [(P Q) P] Q disjunctive syllogism


P
............
Q

P Q [(P Q) (Q R)] [P R] hypothetical syllogism


Q R
............
P R

P conjunction
Q
.............
P Q

(P Q) (R S) [(P Q) (R S) (P R)] [Q S] constructive dilemma


P R
...........................
Q S

(P Q) (R S) [(P Q) (R S) ( Q S)] [ P destructive dilemma


Q S R]
..........................
P R

Example of Inferencing

Consider the following argument:

1. Today is Tuesday or Wednesday.

2. But it can't be Wednesday, since the doctor's office is open today, and that office is always
closed on Wednesdays.

3. Therefore today must be Tuesday.


23

This sequence of reasoning (inferencing) can be represented as a series of application of modus


ponens to the corresponding propositions as follows.

The modus ponens is an inference rule which deduces Q from P Q and P.

T: Today is Tuesday.

W: Today is Wednesday.

D: The doctor's office is open today.

C: The doctor's office is always closed on Wednesdays.

The above reasoning can be represented by propositions as follows.

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

which is correct by modus tollens.

From this W combined with T W of 1. above,

W
T W
………
T

which is correct by disjunctive syllogism.


Thus we can conclude that the given argument is correct.
24

To save space we also write this process as follows eliminating one of the W's:

D
W D
…………
W
T W
…………
T

Proof of Identities using truth tables


All the identities in Identities can be proven to hold using truth tables as follows. In general two
propositions are logically equivalent if they take the same value for each set of values of their
variables. Thus to see whether or not two propositions are equivalent, we construct truth tables
for them and compare to see whether or not they take the same value for each set of values of
their variables.

For example consider the commutativity of :


(P Q) (Q P).

To prove that this equivalence holds, let us construct a truth table for each of the proposition

(P Q) and (Q P).

A truth table for (P Q) is, by the definition of ,

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

A truth table for (Q P) is, by the definition of ,

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

We can also put these two tables into one as follows:


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

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.

Proof of Implications using truth table and tautologies


1. All the implications in Implications can be proven to hold by constructing truth tables and
showing that they are always true.

For example consider the first implication "addition": P (P Q).


To prove that this implication holds, let us first construct a truth table for the proposition P Q.

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.

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.
26

For example suppose that the identity "exportation":


[(X Y) Z] [X (Y Z)] ,
and the implication "hypothetical syllogism":
[(P Q) (Q R)] (P R)
have been proven. Then the implication No. 7:
(P Q) [(Q R) (P R)]
can be proven by applying the "exportation" to the "hypothetical syllogism" as follows:

Consider (P Q) , (Q R) , and (P R) in the "hypothetical syllogism" as X, Y and


Z of the "exportation", respectively.
Then since [ (X Y ) Z] [X (Y Z ) ] implies [ ( X Y ) Z] [X (Y
Z ) ] , the implication of No. 7 follows.

Similarly the modus ponens (implication No. 3) can be proven as follows:


Noting that ( P Q) ( P Q),
P (P Q)
P ( P Q)
(P P ) ( P Q ) --- by the distributive law
F (P Q)
(P Q)
Q

Also the exportation (identity No. 20), ( P (Q R)) (P Q) R ) can be


proven using identities as follows:
(P (Q R)) P (Q R)
P ( Q R)
( P Q) R
(P 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 affecting its value.

For example by substituting ( Q P ) for ( P Q ) , since they are equivalent being


contrapositive to each other, modus tollens (the implication No. 4): [( P Q) Q] P,
reduces to the modus ponens: [ X (X Y)] Y. Hence if the modus ponens and the
"contrapositive" in the "Identities" have been proven, then the modus tollens follows from them.

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

a. The argument is translated as follows:


T S
T C
S
……………………………………
C
28

The inference rules used are:


From ( T S ) and S
by modus tollens we deduce T
From T and ( T C )
by disjunctive syllogism we conclude C.

b. The argument is translated as follows:


T S
T C
S
……………………………………
C

The inference rules used are:


From ( T S ) and S
by modus tollens we deduce T
From T and ( T C )
by disjunctive syllogism we conclude C.

c. The argument is translated as follows:


(S W) (R C)
…………………………….
( W C)

The inference rules used are:


( S W ) is equivalent to ( S W)
by implication and De Morgan
Also ( R C ) is equivalent to ( R C ) by De Morgan.
Hence ( S W ) ( R C ) is equivalent to ( S W) ( R C ), which
is equivalent to
(S R) ( W C)
Hence by simplification ( W C)
d. The argument is translated as follows:
C S
O L
O C
……………….
S L

The inference rules used are:


S C
by Contrapositive of C S
C O
by Contrapositive of O C
By hypothetical syllogism from the last two
29

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

The inference rules used are:


>From Z M and
M F
by hypothetical syllogism
Z F is obtained.
Then from G F
by taking contrapositive M F is obtained.
>From this and Z F
by hypothetical syllogism Z G is obtained.
f. The argument is translated as follows:
R (H L)
H ( L R)
…………………..
R

The inference rules used are:


From H ( L R ) by distributive law
( H L) ( H R)
From this by simplification
( H L)
From this by De Morgan ( H L )
With this and R ( H L )
by disjunctive syllogism R is concluded.

2.2 INTRODUCTION TO PREDICATE LOGIC

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

in mathematics and we want to do inferencing on those assertions.

Also the pattern involved in the following logical equivalences can not be captured by the
propositional logic:

"Not all birds fly" is equivalent to "Some birds don't fly".


"Not all integers are even" is equivalent to "Some integers are not even".
"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 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.

2.1 Predicate and quantifiers

A predicate is a verb phrase template that describes a property of objects, or a relationship


among objects represented by the variables.

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.

Quantifiers Forming Propositions from 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:

1. assign a value to the variable


2. quantify the variable using a quantifier.

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 Universal Quantifier

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:

 P(x) is the predicate denoting: x has wheels, and


 the universe of discourse is only populated by cars.

Universal Quantifier and Connective AND


If all the elements in the universe of discourse can be listed then the universal quantification x
P(x) is equivalent to the conjunction: P(x1)) P(x2) P(x3) ... P(xn).

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 Existential Quantifier

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:

 P(x) is the predicate meaning: x loves you,


 The universe of discourse contains (but is not limited to) all living creatures.

Existential Quantifier and Connective OR


If all the elements in the universe of discourse can be listed, then the existential quantification x
P(x) is equivalent to the disjunction: P(x1) P(x2) P(x3) ... P(xn).
33

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)

An appearance of a variable in a wff is said to be bound if either a specific value is assigned to it


or it is quantified. If an appearance of a variable is not bound, it is called free. The extent of the
application(effect) of a quantifier, called the scope of the quantifier, is indicated by square
brackets [ ]. If there are no square brackets, then the scope is understood to be the smallest wff
following the quantification.
For example, in x P(x, y), the variable x is bound while y is free. In x [ y P(x, y) Q(x,
y) ] , x and the y in P(x, y) are bound, while y in Q(x, y) is free, because the scope of y is P(x,
y). The scope of x is [ y P(x, y) Q(x, y)] .

How to read quantified formulas


When reading quantified formulas in English, read them from left to right. x can be read as
"for every object x in the universe the following holds" and x can be read as "there erxists an
object x in the universe which satisfies the following" or "for some object x in the universe the
following holds". Those do not necessarily give us good English expressions. But they are where
we can start. Get the correct reading first then polish your English without changing the truth
values.

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".

Order of Application of Quantifiers


When more than one variables are quantified in a wff such as y x P( x, y ), they are applied
from the inside, that is, the one closest to the atomic formula is applied first. Thus y x P( x, y
) reads y [ x P( x, y ) ] , and we say "there exists an y such that for every x, P( x, y ) holds" or
"for some y, P( x, y ) holds for every x".
34

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.

However, the positions of different types of quantifiers can not be switched.


For example x y P( x, y ) is not equivalent to y x P( x, y ). For let P( x, y ) represent x
< y for the set of numbers as the universe, for example. Then x y P( x, y ) reads "for every
number x, there is a number y that is greater than x", which is true, while y x P( x, y ) reads
"there is a number that is greater than every (any) number", which is not true.

Well-Formed Formula for First Order Predicate Logic

 wff (well formed formula)


 atomic formula
 syntax of wff

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.

Rules for constructing Wffs


A predicate name followed by a list of variables such as P(x, y), where P is a predicate name, and
x and y are variables, is called an atomic formula.

Wffs are constructed using the following rules:

1. True and False are wffs.


2. Each propositional constant (i.e. specific proposition), and each propositional variable
(i.e. a variable representing propositions) are wffs.
3. Each atomic formula (i.e. a specific predicate with variables) is a wff.
4. If A, B, and C are wffs, then so are A, (A B), (A B), (A B), and (A B).
5. If x is a variable (representing objects of the universe of discourse), and A is a wff, then
so are x A and x A .

(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.

If x is a variable representing people in the world, then taller(x,Tom), x taller(x,Tom), x


taller(x,Tom), x y taller (x,y) are all wffs among others.

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

2. There is a student who is happy.

a. Every student is not happy.


b. There is a student who is not happy.
c. Not all students are unhappy.

3. a) F b) T c) F d)F e) T f) F

4. a) P(1, 2) P(2, 2) P(3, 2)

b) P(3, 1) P(3, 2) P(3, 3)

c) P(1, 1) P(1, 2) P(1, 3) P(2, 1) P(2, 2) P(2, 3) P(3, 1) P(3, 2) P(3, 3)

e) (P(1, 1) P(1, 2) P(1, 3) ) ( P(2, 1) P(2, 2) P(2, 3) ) ( P(3, 1) P(3, 2) P(3, 3) )

f) ( P(1, 1) P(2, 1) P(3, 1) ) ( P(1, 2) P(2, 2) P(3, 2) ) ( P(1, 3) P(2, 3) P(3, 3) )

Sets
• Set: Collection of objects (called elements)
• aA “a is an element of A”
“a is a member of A”
• aA “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:

• A = {9, 2, 7, -3}, B = {7, 9, -3, 2} : A = B


• A = {dog, cat, horse},
B = {cat, horse, squirrel, dog} : A  B
• A = {dog, cat, horse},
B = {cat, horse, dog, dog} : A = B

Examples for Sets

“Standard” Sets:

• Natural numbers N = {0, 1, 2, 3, …}


• Integers Z = {…, -2, -1, 0, 1, 2, …}
• Positive Integers Z+ = {1, 2, 3, 4, …}
• Real Numbers R = {47.3, -12, , …}
• Rational Numbers Q = {1.5, 2.6, -3.8, 15, …}
• A= “empty set/null set”
• A = {z} Note: zA, but z  {z}
• A = {{b, c}, {c, x, d}} set of sets
• A = {{x, y}} Note: {x, y} A, but {x, y}  {{x, y}}
• A = {x | P(x)} “set of all x such that P(x)” P(x) is the membership function of set A
x (P(x)  xA)
• A = {x | x N  x > 7} = {8, 9, 10, …} “set builder notation”

We are now able to define the set of rational numbers Q:

Q = {a/b | aZ  bZ  b0}

And how about the set of real numbers R?

R = {r | r is a real number}
It can neither be defined by enumeration nor builder function.

Subsets
AB “A is a subset of B”

A  B if and only if every element of A is also an element of B.


38

We can completely formalize this: A  B  x (xA xB)


Examples:

A = {3, 9}, B = {5, 9, 1, 3}, A  B ? true

A = {3, 3, 3, 9}, B = {5, 9, 1, 3}, A  B ? true

A = {1, 2, 3}, B = {2, 3, 4}, A  B ? false

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)

• A  A for any set A

Proper subsets:

AB “A is a proper subset of B” A  B  x (xA  xB)  x (xB  xA) or

A  B  x (xA  xB)  x (xB xA)

Cardinality of Sets

If a set S contains n distinct elements, nN, we call S a finite set with cardinality n.

Examples:

A = {Mercedes, BMW, Porsche}, |A| = 3

B = {1, {2, 3}, {4, 5}, 6} , |B| = 4

C= , |C| = 0
39

D = { xN | x  7000 }, |D| = 7001

E = { xN | x  7000 }, E is infinite

The Power Set


P(A) “power set of A” (also written as 2|A|)

P(A) = {B | B  A} (contains all subsets of A)

Examples:

A = {x, y, z}

P(A) = {, {x}, {y}, {z}, {x, y}, {x, z}, {y, z}, {x, y, z}}

A=

P(A) = {}

Note: |A| = 0, |P(A)| = 1

Cardinality of power sets: | P(A) | = 2|A|

For 3 elements in A, there are 222 = 8 elements in 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: AB = {(a, b) | aA  bB}

Example:

A = {good, bad}, B = {student, prof}

AB = {(good, student), (good, prof), (bad, student), (bad, prof)}

BA = {(student, good), (prof, good), (student, bad), (prof, bad)}


40

Example: A = {x, y}, B = {a, b, c}


AB = {(x, a), (x, b), (x, c), (y, a), (y, b), (y, c)}

Note that:

• A = 
• A = 
• For non-empty sets A and B: AB  AB  BA
• |AB| = |A||B|

The Cartesian product of two or more sets is defined as: A1A2…An = {(a1, a2, …, an) | aiAi
for 1  i  n}.

Set Operations
Union: AB = {x | xA  xB}

Example: A = {a, b}, B = {b, c, d}: AB = {a, b, c, d}

Intersection: AB = {x | xA  xB}

Example: A = {a, b}, B = {b, c, d}: AB = {b}

Cardinality: |AB| = |A| + |B| - |AB|.

Two sets are called disjoint if their intersection is empty, that is, they share no elements:

AB = 

The difference between two sets A and B contains exactly those elements of A that are not in B:

A-B = {x | xA  xB}


Example: A = {a, b}, B = {b, c, d}, A-B = {a}

Cardinality: |A-B| = |A| - |A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

Example: U = N, B = {250, 251, 252, …}

Bc = {0, 1, 2, …, 248, 249}


41

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,  (PQ)  ( P)  ( Q)
– Law with implication PQPQ

Set Identity

The following is a list of various set identities

– Identity laws, A = A, AU = A


– Domination laws, AU = U, A = 
– Idempotent laws, AA = A, AA = A
– Complementation law, (Ac)c = A
– Commutative laws, AB = BA, AB = BA
– Associative laws, A(B  C) = (AB)C, …
– Distributive laws, A(BC) = (AB)(AC), …
– De Morgan’s laws, (AB)c = AcBc, (AB)c = AcBc
– Absorption laws, A(AB) = A, A(AB) = A
– Complement laws, AA = U, AAc = 
c

How can we prove A(BC) = (AB)(AC)?

Method I: logical equivalent

xA(BC)

 xA  x(BC)
 xA  (xB  xC)
 (xA  xB)  (xA  xC) (distributive law)
 x(AB)  x(AC)
 x(AB)(AC)

Every logical expression can be transformed into an equivalent expression in set theory and vice
versa.
42

Method II: Membership table

1 means “x is an element of this set”


0 means “x is not an element of this set”

A B C BC A(BC) AB AC (AB) (AC)


0 0 0 0 0 0 0 0
0 0 1 0 0 0 1 0
0 1 0 0 0 1 0 0
0 1 1 1 1 1 1 1
1 0 0 0 1 1 1 1
1 0 1 0 1 1 1 1
1 1 0 0 1 1 1 1
1 1 1 1 1 1 1 1

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: AB (note: Here, ““ has nothing to do with if…
then).
If f:AB, 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:AB is the set of all images of all elements of A.
We say that f:AB maps A to B.

Example
Let us take a look at the function f:PC 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: RR: f(x) = 2x. This leads to: f(1) = 2, f(3) = 6, f(-3) = -6 …

Let f1 and f2 be functions from A to R.


Then the sum and the product of f1 and f2 are also functions from A to R defined by:
(f1 + f2)(x) = f1(x) + f2(x)
(f1f2)(x) = f1(x) f2(x)
43

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:AB is the set of all images of elements aA.
If we only regard a subset SA, the set of all images of elements sS is called the image of S.
We denote the image of S by f(S):
f(S) = {f(s) | sS}

Let us look at the following well-known function:


f(Linda) = Bugesera
f(Max) = Musanze
f(Kathy) = Nyarugenge
f(Peter) = Huye
What is the image of S = {Linda, Max} ?
f(S) = {Bugesera, Musanze}
What is the image of S = {Max, Peter} ?
f(S) = {Musanze, Huye}

Properties of Functions

1. A function f:AB is said to be one-to-one (or injective), if and only if

x, yA (f(x) = f(y)  x = y)

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?

Yes, each element is assigned a unique element of the image.

How can we prove that a function f is one-to-one?

Whenever you want to prove something, first take a look at the relevant definition(s):

x, yA (f(x) = f(y)  x = y)

Example:

f:RR

f(x) = x2

Disproof by counterexample:

f(3) = f(-3), but 3  -3, so f is not one-to-one.

… and yet another example:

f:RR

f(x) = 3x

One-to-one: x, yA (f(x) = f(y)  x = y)

To show: f(x)  f(y) whenever x  y (indirect proof)

xy

 3x  3y
 f(x)  f(y),

so if x  y, then f(x)  f(y), that is, f is one-to-one.


45

2. A function f:AB with A,B  R is called strictly increasing, if

x,yA (x < y  f(x) < f(y)),

and strictly decreasing, if

x,yA (x < y  f(x) > f(y)).

Obviously, a function that is either strictly increasing or strictly decreasing is one-to-one.

3. A function f:AB is called onto, or surjective, if and only if for every element bB there is
an element aA with

f(a) = b.

In other words, f is onto if and only if its range is its entire codomain.

4. A function f: AB is a one-to-one correspondence, or a bijection, if and only if it is both one-


to-one and onto.

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:AB.
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

Is f injective? No f is not even function.

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

An interesting property of bijections is that they have an inverse function.

The inverse function of the bijection f:AB is the function f-1:BA 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.

The inverse function f-1 is given by:

f-1(Bugesera) = Linda
f-1(Musanze) = Max
f-1(Nyarugenge)= Kathy
f-1(Huye) = Peter
f-1(Nyanza) = Helena

Inversion is only possible for bijections


(= invertible functions)
48

A B
Linda Nyanza f: A B

Max Musanze f -1: B A

Kathy Nyarugenge

Peter Bugesera

Helena Huye

f-1:BA 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: AB and f:BC, denoted by fg, is defined by

(fg)(a) = f(g(a))

This means that

• first, function g is applied to element aA, mapping it onto an element of B,


• then, function f is applied to this element of B, mapping it onto an element of C.
• Therefore, the composite function maps from A to C.

Example:

f(x) = 7x – 4, g(x) = 3x,

f:RR, g:RR

(fg)(5) = f(g(5)) = f(15) = 105 – 4 = 101

(fg)(x) = f(g(x)) = f(3x) = 21x – 4

Composition of a function and its inverse:

(f-1f)(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}.

These are the rules that underlie electronic circuits.

We are going to focus on three operations:

• 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.

The Boolean sum, denoted by + or by OR, has the following values:

1 + 1 = 1, 1 + 0 = 1, 0 + 1 = 1, 0+0=0

The Boolean product, denoted by  or by AND, has the following values:

1  1 = 1, 1  0 = 0, 0  1 = 0, 00=0

Boolean Functions and Expressions

Definition: Let B = {0, 1}. The variable x is called a Boolean variable if it assumes values only
from B.

A function from Bn, the set {(x1, x2, …, xn) |xiB,


1  i  n}, to B is called a Boolean function of degree n.

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:

• 0, 1, x1, x2, …, xn are Boolean expressions.


• If E1 and E2 are Boolean expressions, then (-E1),
(E1E2), and (E1 + E2) are Boolean expressions.

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:

Since x and y are Boolean expressions, so is xy.

Since z is a Boolean expression, so is (-z).

Since xy and (-z) are expressions, so is xy + (-z).

… 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

Possible solution: F(x, y) = (-x)y

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.

Definition: A literal is a Boolean variable or its complement. A minterm of the Boolean


variables x1, x2, …, xn is a Boolean product y1y2…yn, where yi = xi or yi = -xi.

Hence, a minterm is a product of n literals, with one literal for each variable.
51

Consider F(x,y,z) again:

x y z F(x, y, z) F(x, y, z) = 1 if and only if: x = y = z = 0 or


0 0 0 1
0 0 1 1 x = y = 0, z = 1 or x = 1, y = z = 0
0 1 0 0
0 1 1 0 Therefore, F(x, y, z) = (-x)(-y)(-z) + (-x)(-y)z + x(-y)(-z)
1 0 0 1
1 0 1 0
1 1 0 0
1 1 1 0

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 xy1 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

(F + G)(b1, b2, …, bn) = F(b1, b2, …, bn) + G(b1, b2, …, bn)

(FG)(b1, b2, …, bn) = F(b1, b2, …, bn) G(b1, b2, …, bn)

Question: How many different Boolean functions of degree 1 are there?

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

Question: How many different Boolean functions of degree 2 are there?

Solution: There are 16 of them, F1, F2, …, F16:

x y F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16


0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
0 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
1 0 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1
1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1

Question: How many different Boolean functions of degree n are there?

Solution:

There are 2n different n-tuples of 0s and 1s.

A Boolean function is an assignment of 0 or 1 to each of these 2n different n-tuples.

Therefore, there are 22n different Boolean functions.

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:

The dual of x(y + z) is x + yz.

The dual of -x1 + (-y + z) is (-x + 0)((-y)z).

The dual of a Boolean function F represented by a Boolean expression is the function


represented by the dual of this expression.

This dual function, denoted by Fd, does not depend on the particular Boolean expression used to
represent F.

Therefore, an identity between functions represented by Boolean expressions remains valid


when the duals of both sides of the identity are taken.
53

We can use this fact, called the duality principle, to derive new identities.

For example, consider the absorption law


x(x + y) = x.

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).

Definition of a Boolean Algebra

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.

For this purpose, we need an abstract definition of a Boolean algebra.

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  0 = x and x  1 = x (identity laws)

x  (-x) = 1 and x  (-x) = 0 (domination laws)

(x  y)  z = x  (y  z) and
(x  y)  z = x  (y  z) and (associative laws)

x  y = y  x and x  y = y  x (commutative laws)

x  (y  z) = (x  y)  (x  z) and
x  (y  z) = (x  y)  (x  z) (distributive laws)

Logic Gates

Electronic circuits consist of so-called gates.


There are three basic types of gates:

Inverter
54

OR gate

AND gate

Example: How can we build a circuit that computes the function xy + (-x)y ?

Logic, Sets, and Boolean Algebra

Logic Set Boolean Algebra

False  0

True U 1

AB AB AB

AB AB A+B

A AC Ā

Compare the equivalence laws of them

EXERCISES

Page 827(847) Ex.1-5,6

Page 818(839) Ex. 1,2,3.a, 5,6, 28


55

Home work

1) Page 818 Ex. 5.d, 6.d, 26 c and d


2) Page 827 Ex.5, 6.d

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.

Since this is a relation between two sets, it is called a binary relation.

Definition: Let A and B be sets. A binary relation from A to B is a subset of AB.

In other words, for a binary relation R we have


R  AB. We use the notation aRb to denote that (a, b)R and aRb to denote that (a, b)R.

When (a, b) belongs to R, a is said to be related to b by R.

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).

P = {Carl, Suzanne, Peter, Carla},

C = {Mercedes, BMW, tricycle}

D = {(Carl, Mercedes), (Suzanne, Mercedes),


(Suzanne, BMW), (Peter, tricycle)}

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

Since the graph of f is a subset of AB, it is a relation from A to B.

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 aA the unique element bB such that (a, b)R.

Relations on a Set

Definition: A relation on the set A is a relation from A to A.

In other words, a relation on the set A is a subset of AA.

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

How many different relations can we define on a set A with n elements?

A relation on a set A is a subset of AA.

How many elements are in AA ?

There are n2 elements in AA, so how many subsets (= relations on A) does AA 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 AA.
2
Answer: We can define 2𝑛 different relations on A.

Properties of Relations

We will now look at some useful ways to classify relations.

Definition: A relation R on a set A is called reflexive if (a, a)R for every element aA.

Are the following relations on {1, 2, 3, 4} reflexive?

R = {(1, 1), (1, 2), (2, 3), (3, 3), (4, 4)} No.

R = {(1, 1), (2, 2), (2, 3), (3, 3), (4, 4)} Yes.

R = {(1, 1), (2, 2), (3, 3)} No.

Definition: A relation on a set A is called irreflexive if (a, a)R for every element aA.

Definitions:

A relation R on a set A is called symmetric if (b, a)R whenever (a, b)R for all a, bA.

A relation R on a set A is called antisymmetric if


a = b whenever (a, b)R and (b, a)R.

A relation R on a set A is called asymmetric if


(a, b)R implies that (b, a)R for all a, bA.

Are the following relations on {1, 2, 3, 4} symmetric, antisymmetric, or asymmetric?

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

R = {(1, 1)} sym. and antisym.

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

R = {(4, 4), (3, 3), (1, 4)} non of them

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, cA.

Are the following relations on {1, 2, 3, 4} transitive?


58

R = {(1, 1), (1, 2), (2, 2), (2, 1), (3, 3)} No.

R = {(1, 3), (3, 2), (2, 1)} No.

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

Counting Relations

Example: How many different reflexive relations can be defined on a set A containing n
elements?

Solution: Relations on R are subsets of AA, which contains n2 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 aA.

Consequently, we can only choose among n2 – n = n(n – 1) elements to generate reflexive


relations, so there are 2n(n – 1) of them.

Equivalence Relations

Equivalence relations are used to relate objects that are similar in some way.

Definition: A relation on a set A is called an equivalence relation if it is reflexive, symmetric,


and transitive.

Two elements that are related by an equivalence relation R are called equivalent.

Since R is symmetric, a is equivalent to b whenever b is equivalent to a.

Since R is reflexive, every element is equivalent to itself.

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 reflexive, because l(a) = l(a) and therefore


aRa for any string a.
• R is symmetric, because if l(a) = l(b) then l(b) = l(a), so if aRb then bRa.
• R is transitive, because if l(a) = l(b) and l(b) = l(c),
then l(a) = l(c), so aRb and bRc implies aRc.

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.

The equivalence class of a with respect to R is denoted by [a]R.

When only one relation is under consideration, we will delete the subscript R and write [a] for
this equivalence class.

If b[a]R, b is called a representative of 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.

For example, ‘horse’ would be a representative of this equivalence class.

Theorem: Let R be an equivalence relation on a set A. The following statements are equivalent:

• aRb
• [a] = [b]
• [a]  [b]  

Definition: A partition of a set S is a collection of disjoint nonempty subsets of S that have S as


their union. In other words, the collection of subsets Ai,
iI, forms a partition of S if and only if
(i) Ai   for iI

• Ai  Aj = , if i  j
• iI Ai = S

Examples: Let S be the set {u, m, b, r, o, c, k, s}.


Do the following collections of sets partition S ?
60

{{m, o, c, k}, {r, u, b, s}} yes

{{c, o, m, b}, {u, s}, {r}} no (k is missing).

{{b, r, o, c, k}, {m, u, s, t}} no (t is not in S).

{{u, m, b, r, o, c, k, s}} yes

{{b, o, o, k}, {r, u, m}, {c, s}} yes ({b,o,o,k} = {b,o,k}).

{{u, m, b}, {r, o, c, k, s}, } no ( not allowed).

Theorem: Let R be an equivalence relation on a


set S. Then the equivalence classes of R form a partition of S. Conversely, given a partition
{Ai | iI} of the set S, there is an equivalence relation R that has the sets Ai, iI, as its
equivalence classes.

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)}.

Then the equivalence classes of R are:

{{Frank, Suzanne, George}, {Stephanie, Max}, {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.

Another example: Let R be the relation


{(a, b) | a  b (mod 3)} on the set of integers.

Is R an equivalence relation?

Yes, R is reflexive, symmetric, and transitive.

What are the equivalence classes of R ?


61

{{…, -6, -3, 0, 3, 6, …},


{…, -5, -2, 1, 4, 7, …},
{…, -4, -1, 2, 5, 8, …}}

Basic Counting Principles


Counting problems are of the following kind:

“How many different 8-letter passwords are there?”

“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.

(“What is the probability of winning the lottery?”)

The sum rule:

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:

The department will award a free computer to either a CS student or a CS professor.

How many different choices are there, if there are 530 students and 15 professors?

There are 530 + 15 = 545 choices.

Generalized sum rule:

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.

The product rule:

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.

So there are 262626 = 17576 different license plates.

Generalized product rule:

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|.

The pigeonhole principle:

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).

Permutations and Combinations

A permutation of a set of distinct objects is an ordered arrangement of these objects.

An ordered arrangement of r elements of a set is called an r-permutation.

Example: Let S = {1, 2, 3}.


63

The arrangement 3, 1, 2 is a permutation of S.

The arrangement 3, 2 is a 2-permutation of S.

The number of r-permutations of a set with n distinct elements is denoted by P(n, r).

We can calculate P(n, r) with the product rule:

P(n, r) = n(n – 1)(n – 2) …(n – r + 1).

(n choices for the first element, (n – 1) for the second one, (n – 2) for the third one…)

Example:

P(8, 3) = 876 = 336

= (87654321)/(54321)

General formula:

P(n, r) = n!/(n – r)!

An r-combination of elements of a set is an unordered selection of r elements from the set.

Thus, an r-combination is simply a subset of the set with r elements.

Example: Let S = {1, 2, 3, 4}.

Then {1, 3, 4} is a 3-combination from S.

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}.

An r-combination of elements of a set is an unordered selection of r elements from the set.

Thus, an r-combination is simply a subset of the set with r elements.

Example: Let S = {1, 2, 3, 4}.

Then {1, 3, 4} is a 3-combination from S.

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}.

How can we calculate C(n, r)?

Consider that we can obtain the r-permutation of a set in the following way:

First, we form all the r-combinations of the set


(there are C(n, r) such r-combinations).

Then, we generate all possible orderings in each of these r-combinations (there are P(r, r) such
orderings in each case).

Therefore, we have: P(n, r) = C(n, r)P(r, r).

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

= n!/(n – r)!/(r!/(r – r)!)

= 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)?

C(6, 3) = 6!/(3!3!) = 720/(66) = 720/36 = 20

There are 20 different ways, that is, 20 different groups to be picked.

Corollary:

Let n and r be nonnegative integers with r  n.

Then C(n, r) = C(n, n – r).

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?

C(8, 6)  C(7, 5) = 8!/(6!2!)  7!/(5!2!)


65

= 2821

= 588

Combinations

We also saw the following:

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:

Let n and k be positive integers with n  k.


Then C(n + 1, k) = C(n, k – 1) + C(n, k).

How can this be explained?

What is it good for?

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.

Calculating C(n + 1, k) is equivalent to answering the question: How many subsets of T


containing k items are there?

Case I: The subset contains (k – 1) elements of S


plus the element a: C(n, k – 1) choices.

Case II: The subset contains k elements of S and


does not contain a: C(n, k) choices.

Sum Rule: C(n + 1, k) = C(n, k – 1) + C(n, k).


66

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

… … … … … … …

Since we have C(n + 1, k) = C(n, k – 1) + C(n, k) and


C(0, 0) = 1, we can use Pascal’s triangle to simplify the computation of C(n, k):

C(0, 0) = 1

C(1, 0) = 1 C(1, 1) = 1

n C(2, 0) =1 C(2, 1) = 2 C(2, 2) = 1

C(3, 0) = 1 C(3, 1) = 3 C(3, 2) = 3 C(3, 3) = 1

C(4, 0) = 1 C(4, 1) = 4 C(4, 2) = 6 C(4, 3) = 4 C(4, 4) = 1

Binomial Coefficients

Expressions of the form C(n, k) are also called binomial coefficients.

How come?

A binomial expression is the sum of two terms, such as (a + b).

Now consider (a + b)2 = (a + b)(a + b).

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 = a·a + a·b + b·a + b·b

Then we can sum identical terms:

(a + b)2 = a2 + 2ab + b2
67

For (a + b)3 = (a + b)(a + b)(a + b) we have

(a + b)3 = aaa + aab + aba + abb + baa + bab + bba + bbb

(a + b)3 = a3 + 3a2b + 3ab2 + b3

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.

Similarly, there is three times the term ab2


(C(3, 1) = 3) and once the term b3 (C(3, 0) = 1).
n
This leads us to the following formula: (a  b) n   C (n, j )  a n  j b j (Binomial Theorem)
j 0

With the help of Pascal’s triangle, this formula can considerably simplify the process of
expanding powers of binomial expressions.

For example, the fifth row of Pascal’s triangle


(1 – 4 – 6 – 4 – 1) helps us to compute (a + b)4:

(a + b)4 = a4 + 4a3b + 6a2b2 + 4ab3 + b4

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).

“All lions are fierce.”


“Some lions do not drink coffee.”
“Some fierce creatures do not drink coffee.”

Solution: We can express these statements as:

∀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

third statement cannot be written as


∃x(Q(x)→¬R(x)).

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).

Solution: We can express the statements in the argument as


∀x(P(x) → S(x)).
¬∃x(Q(x) ∧ R(x)).
∀x(¬R(x)→¬S(x)).
∀x(P(x)→¬Q(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).

a) All clear explanations are satisfactory.


b) Some excuses are unsatisfactory.
c) Some excuses are not clear explanations.
∗d) Does (c) follow from (a) and (b)?

4 Consider these relations on the set of integers:


R1 = {(a, b) | a ≤ b},
R2 = {(a, b) | a > b},
R3 = {(a, b) | a = b or a = −b},
R4 = {(a, b) | a = b},
R5 = {(a, b) | a = b + 1},
R6 = {(a, b) | a + b ≤ 3}.
Which of these relations contain each of the pairs (1, 1), (1, 2), (2, 1), (1,−1), and (2, 2)?
Remark: Unlike the relations in Examples 1–4, these are relations on an infinite set.

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.

When f is a function from A to B, the image of a subset of A can also be defined.

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

9 What is the expansion of (x + y)4?


Solution: From the binomial theorem it follows that

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.

You might also like