Logic Notes - MAT2EB1
Logic Notes - MAT2EB1
Logic is a classical branch of mathematics which studies the foundations, laws and struc-
ture of mathematical reasoning. Contemporary logic has applications in a number of fields,
specifically in computer science in areas such as digital logic circuit design, database theory
and artificial intelligence.
• The lower level is propositional logic. Propositions are sentences which are built from
primitive statements with only a truth value (true or false), using logical connectives.
• The higher level is predicate (or first-order) logic. This builds on propositional logic
by using constants and variables, functions and predicates over objects, as well as
quantifiers. First-order logic provides us with a method to express any mathematical
statement.
The purpose of these notes is to give an introduction to the basic concepts of classical logic,
by introducing the formal languages of propositional and first-order logic and discussing the
concepts of truth, validity and logical equivalence.
1.1.1 Propositions
Some examples:
• UJ is situated in Johannesburg.
• 3 plus 3 equals 6.
• 3 plus 3 equals 5.
1
The following sentences are not propositions:
• She is a university student. (Whether this is true or false depends on who ‘she’ is.)
• This statement is false. (If it is true, then it contradicts the fact that the statement
is false. And it cannot be false, since the statement says it is false, which would then
make it true.)
Propositions which cannot be broken up into smaller parts, are called primitive, or atomic,
propositions. We can form compound propositions from primitive ones using logical connec-
tives. We use the lower case letters p, q and r as propositional variables to denote primitive
propositions.
For example, suppose we have the primitive propositions p = “2 is a prime number” and
q = “The sun is hot”. (Recall that a prime number is a natural number greater than 1
that has no positive divisors other than 1 and itself, see Section 1.2.1) We can then form
compound propositions from these primitive ones such as
• ¬p = “It is not the case that 2 is a prime number.” or “2 is not a prime number.”
2
• q → p = “If the sun is hot, then 2 is a prime number.”
For a more involved example, we can use the propositions p = “Sihle is healthy”, q = “Sihle
is wealthy” and r = “Sihle is wise” to compose the following compound proposition:
¬q ∨ (p → (q ∧ ¬r)) = “Sihle is not wealthy or, if she is healthy then she is wealthy and not
wise.”
In order to determine the truth value of a compound proposition, we need to know the
truth value of the primitive components. In the same way as we can calculate the value of
the algebraic expression a × (b − c) + b/a as soon as we know the values of a, b and c, we
can determine the truth value of a compound proposition such as “(p ∧ q) ∨ ¬r” if we know
the truth values of p, q and r.
We also need to know how our logical connectives behave with respect to truth values, so
we use the following rules of ‘propositional arithmetic’:
• The proposition ¬p (not p) is true precisely when the proposition p is false, i.e. it has
the opposite truth value from p.
We use T to denote the value ‘true’ and we use F to denote the value ‘false’. Then
the truth values for negation can be summarized in a truth table.
p ¬p
T F
F T
• The proposition p ∧ q (p and q) is true precisely when both p and q are true.
The truth values for conjunction can also be summarized in a truth table. The table
is obtained by considering the four possible combinations of truth values for p and q.
Each combination is displayed in one row of the table and the corresponding truth
value for the whole statement is placed in the right-most column of that row.
The truth table for conjunction is:
3
p q p∧q
T T T
T F F
F T F
F F F
p q p∨q
T T T
T F T
F T T
F F F
Note:
In ordinary language ‘or’ is often used in an exclusive sense, e.g. in ‘I will win or I will lose’,
while in formal logic ‘or’ is used in an inclusive sense, thus ‘It will rain or it will be cold’
will be true if it is both rainy and cold.
• The proposition p → q (if p, then q) is true precisely when p is false or q is true, i.e. it
is false only when p is true and q is false, otherwise it is true. We call p the antecedent
(or hypothesis) and q the consequent (or conclusion). The truth table for implication
is:
4
p q p→q
T T T
T F F
F T T
F F T
Note:
It is important to note that if p is not true, then the truth of p → q is independent of the
truth of q. One can think of an implication as a promise.
Consider the following example: Thabo’s father tells him: “If you pass your Maths exam,
then I will buy you a motorbike.” Under what circumstances will Thabo’s father have
spoken falsely?
Answer: If Thabo passed his maths exam and his father does not buy him a motorbike.
After all, Thabo’s father’s promise only says he will buy the motorbike if he passes the
exam, it says nothing about what will happen if Thabo doesn’t pass the exam. He can buy
a motorbike even if Thabo doesn’t pass the exam. Hence the statement can be true even if
the antecedent is false.
The implication p → q can be expressed in many different ways, which you should be able
to recognize:
(1) p implies q.
(2) If p, then q.
(3) p only if q.
(4) q if p.
(5) q whenever p.
• The proposition p ↔ q (p if and only if q) is true precisely when p and q have the
same truth values. (It is common to abbreviate ‘if and only if’ with ‘iff’.)
The truth table for biconditional is:
5
p q p↔q
T T T
T F F
F T F
F F T
p ↔ q ≡ (p → q) ∧ (q → p)
The truth value of a compound proposition only depends on the truth values of the prim-
itive propositions. So to check the truth value of a compound proposition we replace all
component propositions by their respective truth values and then ‘calculate’ the truth of
the whole proposition using truth tables.
Example 1.1
Suppose we know that
“Dineo is clever” is true,
“Dineo is lazy” is false,
“Dineo likes mathematics” is true.
Then we can determine the truth value of the compound proposition
“Dineo is not clever or, if she likes mathematics, then she is clever and not lazy.”
We first have to analyze the structure of the proposition. Let us make use of parentheses
to rewrite the sentence.
“(Dineo is not clever) or, (if (she likes mathematics) then ((she is clever) and (not lazy))).”
We can go one step further by using letters to denote the primitive propositions.
6
Let p = “Dineo is clever”,
q = “Dineo is lazy”,
r = “Dineo likes mathematics”.
(¬T ) ∨ (T → (T ∧ ¬F ))
= F ∨ (T → (T ∧ T ))
= F ∨ (T → T )
= F ∨T
= T
To avoid ambiguity, we will, as in arithmetic, impose a priority order amongst the logical
connectives:
(1) ¬
(2) ∧ and ∨
(3) →
(4) ↔
If we only consider specific propositions, our study of logic would be limited and not very
useful. Instead, we want to look at schemes of propositions and their properties, just like
we study algebraic formulas and equations in general.
We will make use of propositional variables p, q, r, . . . to denote unknown propositions, in the
same way we use algebraic variables to denote unknown numbers. We then use these propo-
sitional variables and the logical connectives defined in Section 1.1.2 to form propositional
formulas, similar to the way we form algebraic expressions from variables and arithmetic
operations. Note that it is common practice to denote propositional variables with the
letters p, q, r, etc. and propositional formulas with capital letters A, B, C, etc.
When constructing truth tables, we need to consider all the possible combinations for the
truth values of the relevant propositional variables. If a propositional formula contains two
propositional variables, then there are 2 × 2 = 4 possible combinations, since each variable
7
can take one of two truth values, T or F . Similarly, if a formula contains three variables,
there are 2 × 2 × 2 = 23 = 8 possible combinations of truth values. Hence, in general, if a
formula contains n variables, then there are 2n possible combinations.
One can simplify truth tables by successively calculating the truth values of all the occur-
ring subformulas, as we did in the example above. It is important to remember the order
of logical connectives when parentheses are not present.
Example 1.2
Construct a truth table for the propositional formula (p ∨ q) ∧ ¬(p ∧ q).
p q p ∨ q p ∧ q ¬(p ∧ q) (p ∨ q) ∧ ¬(p ∧ q)
T T T T F F
T F T F T T
F T T F T T
F F F F T F
Example 1.3
Construct a truth table for ((p ∧ ¬q) ∨ r) → ¬r.
T T T F F T F F
T T F F F F T T
T F T T T T F F
T F F T T T T T
F T T F F T F F
F T F F F F T T
F F T
F F F
8
1.1.6 Tautologies and contradictions
Definition: A tautology is a formula that obtains a truth value true for any assignment
of truth values to the variables, i.e. it is a formula that is always true. Tautologies are
also called logically valid formulas.
Example 1.4
Show that the propositional formulas p ∨ ¬p and (p ∧ (p → q)) → q are tautologies.
p ¬p p ∨ ¬p
T F T
F T T
p q p→q p ∧ (p → q) (p ∧ (p → q)) → q
T T T T T
T F F F T
F T T F T
F F T F T
Definition: A contradiction is a formula that obtains a truth value false for any assign-
ment of truth values, i.e. it is a formula that is always false.
Example 1.5
Is p ∧ ¬p a contradiction, a tautology or neither?
p ¬p p ∧ ¬p
T F F
F T F
Hence p ∧ ¬p is a contradiction.
9
1.1.7 Logical equivalence
Definition: Propositional formulas A and B are logically equivalent if for every assign-
ment of truth values to the variables in them they obtain identical truth values, i.e., they
have ‘the same truth table’.
We can determine whether or not two formulas are logically equivalent by constructing the
truth table and checking whether the columns for A and B are the same or not.
Example 1.6
Show that ¬(p ∨ q) ≡ ¬p ∧ ¬q.
p q p∨q ¬(p ∨ q) ¬p ¬q ¬p ∧ ¬q
T T T F F F F
T F T F F T F
F T T F T F F
F F F T T T T
↑ ↑
same truth values
There are a few logical equivalences which are used often, such as the one in Example 1.6
above. The two logical equivalences
¬(A ∧ B) ≡ ¬A ∨ ¬B
and ¬(A ∨ B) ≡ ¬A ∧ ¬B
are called De Morgan’s laws, after the British mathematician Augustus De Morgan, who
was the first to note these logical equivalences.
Note that we use the letter t to denote a tautology, and f to denote a contradiction.
Here are some more logical equivalences:
10
1. Commutative laws: A∧B ≡ B∧A A∨B ≡ B∨A
2. Associative laws: (A ∧ B) ∧ C ≡ A ∧ (B ∧ C) (A ∨ B) ∨ C ≡ A ∨ (B ∨ C)
3. Distributive laws: A ∧ (B ∨ C) ≡ (A ∧ B) ∨ (A ∧ C) A ∨ (B ∧ C) ≡ (A ∨ B) ∧ (A ∨ C)
4. Identity laws: A∧t ≡ A A∨f ≡ A
5. Negation laws: A ∨ ¬A ≡ t A ∧ ¬A ≡ f
6. Double negative law: ¬(¬A) ≡ A
7. Idempotent laws: A∧A ≡ A A∨A ≡ A
8. Universal bound laws: A∨t ≡ t A∧f ≡ f
9. De Morgan’s laws: ¬(A ∧ B) ≡ ¬A ∨ ¬B ¬(A ∨ B) ≡ ¬A ∧ ¬B
Note:
Propositional formulas A and B are logically equivalent if and only if the propositional
formula A ↔ B is a tautology.
We can use the following logical equivalence to rewrite a conditional proposition as an ‘or’
proposition:
A → B ≡ ¬A ∨ B
Note that the negation of a conditional proposition is an ‘and’ proposition, and not a
conditional proposition:
¬(A → B) ≡ A ∧ ¬B
Example 1.7
Use the logical equivalence above to rewrite the following statement in if-then form.
“You get to work on time or you are fired”.
Example 1.8
Write the negation of the following statement.
“If Nandi lives in Soweto, then she lives in South Africa.”
11
Recall that
A ↔ B ≡ (A → B) ∧ (B → A)
A very important law of logic is the equivalence between a conditional formula and its con-
trapositive.
Note that a conditional formula is logically equivalent to its contrapositive. There are two
other variants of an implication, but neither of these variants are logically equivalent to the
original implication.
• B → A is the converse of A → B
• ¬A → ¬B is the inverse of A → B.
• The converse and inverse of a conditional formula are logically equivalent to each
other.
p q ¬p ¬q p→q ¬q → ¬p q→p ¬p → ¬q
T T F F T T T T
T F F T F F T T
F T T F T T F F
F F T T T T T T
12
Example 1.9
Write down the contrapositive, converse and inverse of the following proposition: “If Rover
is a dog, then Rover is an animal.”
Example 1.10
Rewrite the following statements in the if-then form.
1.1 Exercises
a) 24 + 32 = 24.
b) 24 + 32 = x.
13
c) n is an even number.
2) Let A and B be true propositions and let C and D be false propositions. Determine
the truth value of each of the following compound propositions:
a) ¬(B ∧ ¬D) ∨ A
b) (C → A) → D
c) (B ↔ C) ∧ ¬C
d) (C ↔ ¬A) ∨ (B → ¬B)
e) ¬(A → D) ∨ (D → C)
f) ¬(¬(¬D ∧ (A → ¬B))).
3) Determine the truth value of the proposition A in each of the following cases:
4) Write down the negation of each of the following statements in clear and concise
English. Do not use the expression “It is not the case that” in your answers.
d) Miriam can complete the Comrades if and only if she runs 60 km per week.
f) Naledi likes gymnastics, or if she enjoys ballet then she doesn’t like gymnastics and
likes yoga.
14
5) Determine the antecedent and the consequent in each of the following implications:
6) Construct truth tables for the following propositional formulas and determine which
of them are tautologies and which are contradictions:
a) ¬(p ∧ q) ∨ (p ∨ q)
b) (p ∧ ¬p) → q
c) ¬p ∧ ¬(p → q)
d) ¬p ∨ (q → r)
e) (p → r) ↔ (q → r)
f) (p → q) ∧ (q → r) ∧ ¬(¬p ∨ r)
g) ¬(¬p ↔ q) ∧ (r ∨ ¬q)
7) Use truth tables to determine whether or not the following sets of propositions are
logically equivalent:
a) p → q ∨ r and p ∧ ¬q → r
b) p ∧ (q ∨ r) and (p ∧ q) ∨ (p ∧ r)
d) p → (q → r) and (p → q) → r
8) Use known logical equivalences to rewrite each of the following propositions using only
∧, ∨ and ¬:
a) p ∧ ¬q → r
b) p ∨ ¬q → r ∨ q
c) ¬p ∧ ¬(p → q)
15
d) (p → r) ↔ (q → r)
e) ((p → q) → p) → p
9) Use the contrapositive to rewrite the following statements in if-then form in two ways.
a) Orlando Pirates will win the championship only if they win tomorrow’s game.
10) Write down the converse and inverse of the following propositions:
a b a
a) If and are integers, then is an integer.
b c c
c) If ab = 0, then a = 0 or b = 0.
d) If x2 = 1, then x = ±1.
a) Doing homework regularly is a necessary condition for Jim to pass this course.
b) Catching the 6:50 bus is sufficient for my being on time for class.
d) Having two 45◦ angles is a sufficient condition for a triangle to be a right triangle.
16
1.2 Basic Concepts of Predicate Logic
Before we proceed to Predicate Logic, we remind ourselves of a few important concepts and
definitions from the number systems.
Number Theory is the branch of Mathematics that is devoted primarily to the study of
properties of the integers. We need some basic properties of integers for the examples and
exercises to come. Recall that the set of integers is denoted by Z. That is,
We will sometimes be interested only in the positive or negative integers. These are denoted
by Z+ and Z− respectively. That is,
The integers are used to construct the rational numbers. We denote the set of rational
numbers by Q. Formally,
a
q ∈ Q if and only if q = where a, b ∈ Z and b 6= 0
b
The number system that we are most familiar with is the real numbers, R. Note that
√ √
numbers like 2, π, e, 2 2 are elements of R but are not elements of Q.
Let m and n be integers. We say m divides n or m is a divisor of n and write m|n if there
exists an integer k such that n = m · k.
For example 2|6 and 5|15. Notice the following:
1. 1|n for every integer n, i.e. 1 is a divisor of n for every integer n, and
The above two properties mean that every integer n (other than 1) has at least two divisors.
Let p > 1 be an integer. If the only positive divisors of p are 1 and p, then we call p a prime
number.
17
Examples
• the first eight prime numbers are 2, 3, 5, 7, 11, 13, 17, 19. More than 2000 years ago, the
Greek mathematician Euclid proved that there are infinitely many prime numbers.
The propositional logic in Section 1.1 can formalize some of our reasoning, but it is incapable
of describing most of the statements in mathematics. Consider for example the statement
“x + 3 is greater than 5”.
This statement is not a proposition, since it can be true or false depending on the value of
x. It will only be a proposition once the domain from which x comes is specified, as well as
the value of x. Similarly, the sentence “There exists a number y such that y 2 = 2” is not a
proposition until the domain (or domain of discourse) is specified.
We also have to consider the role played by words that denote quantities such as ‘all’ or
‘some’. The study of quantified statements such as the ones above is called predicate logic,
or first-order logic.
1.2.2 Predicates
In grammar the word predicate refers to the part of a sentence that gives information about
the subject. In the sentence “Laika is a student at UJ”, the word Laika is the subject and
the phrase “is a student at UJ” is the predicate. A similar approach is used in logic.
Definition: Given a domain, a predicate is a property that objects from the domain can
have, or a relationship between objects from the domain.
For example, in the sentence above, let P stand for “is a student at UJ”. P is called a pred-
icate symbol. Then the sentence ‘x is a student at UJ’ can be symbolized as the predicate
P (x). Since there is only one variable, this is a unary predicate, but we also make use of
binary predicate when two variables are involved. For instance, let Q stand for “is a student
at”. Then the sentence “x is a student at y” can be represented by the predicate Q(x, y).
18
Example 1.11
Let P (x) be the predicate “x is a prime number” with domain Z+ , the set of all positive
integers. Write P (1), P (9) and P (13) and indicate whether each statement is true or false.
Example 1.12
Let P (x, y) be the predicate “x < y” with domain R, the set of all real numbers. Write
√
5 6
P (−9, −10), P π, 17 and P , and indicate whether each statement is true or false.
8 10
1.2.3 Quantifiers
Quantifiers are words that refer to quantities such as ‘some’ or ‘all’. The symbol ∀ denotes
‘for all’ or ‘for every’ and is called the universal quantifier. For example, we can express
the statement
“All integers are real numbers”
in predicate logic as
(∀x ∈ Z)(x ∈ R)
where Z denotes the set of integers and R denotes the set of real numbers.
Let Q(x) be a predicate and let D be the domain of x. The expression “(∀x ∈ D)( Q(x))”
is true if Q(x) is true for every choice of x from D. It is false if at least one x ∈ D can
be found such that Q(x) is false. The value for which Q(x) is false is called a counterexample.
19
Example 1.13
Determine the truth value of the following universally quantified statements:
a) (∀x ∈ R)(x2 = 1)
b) (∀x ∈ D)(x2 > x), where D = {1, 2, 3, 4, 5}
a) (∀x ∈ R)(x2 = 1)
This statement says that the square of every real number is 1. To show that it is false,
we have to find at least one real number whose square is not 1. Counterexample: if
we take x = 2, then x2 = 4, which is not equal to 1.
Hence the statement is false.
12 > 1 - True
22 > 2 - True
32 > 3 - True
42 > 4 - True
52 > 5 - True.
Hence the statement is true.
The other quantifier is called the existential quantifier, denoted by the symbol ∃, which
denotes ‘there exists at least one’ or ‘for some’. For example, we can rewrite the sentence
in formal language as
(∃x ∈ S)(M (x))
where S is the set of all students, and M (x) is the predicate “x takes MAT01A1”.
The expression (∃x ∈ D)(Q(x)) is true if at least one x ∈ D can be found such that Q(x) is
true for the particular x. It is therefore false if Q(x) is false for every x in D.
20
1.2.4 Using first-order (predicate) languages
Example 1.14
Rewrite the following formulas in natural language:
a) (∃x ∈ R)(x = x3 )
“There is a real number which equals its cube.” (True, take x = 0, x = 1.)
Example 1.15
Translate the following statements from English into first-order language:
21
Note:
Observe that two statements “(∀x ∈ R)(x ∈ Z → x ∈ Q)” and “(∀x ∈ Z)(x ∈ Q)” have
the same meaning. When translated into natural language, both mean “All integers are
rational”.
(∀x ∈ D)(Q(x))
by narrowing the universal domain U to the domain D consisting of all values of x that
make P (x) true.
Example 1.16
Consider Example 1.1.15(c): “Every computer science student is an engineering student.”
Consider the sentence “All mathematicians wear glasses”. One might think that the nega-
tion of this statement is “No mathematicians wear glasses”. But in fact, it is “There is at
least one mathematician who does not wear glasses”, since if there is even one mathemati-
cian who does not wear glasses, it proves that the statement is false.
Definition:
¬(∀x ∈ D)(Q(x)) ≡ (∃x ∈ D)(¬Q(x))
22
Example 1.17
Rewrite the following sentence in first-order language. Then write the negation in first-order
language and in natural language.
¬(p → q) ≡ p ∧ ¬q.
The same rule applies when negating a quantified conditional statement. Hence
Example 1.18
Write down the negation of the following universally quantified conditional statement:
23
1.2 Exercises
1. Determine whether the following statements are true or false. Justify your answer.
1
2. Let Q(n) be the predicate “n2 6 30”. Write Q(2), Q(−2), Q(7) and Q( ) and
2
determine which of these statements are false and which are true.
4. Translate the following first-order formulae into English and determine which of them
represent true propositions.
b) (∃x ∈ R)(x2 = 2)
f) ¬(∀x ∈ R)(x 6= 0)
g) (∃x ∈ R)(x + 2 = x)
24
5. Formalize the following sentences in first-order language.
d) The cube of any real number is greater than or equal to its square.
6. Negate the following statements and give your answer in natural language:
7. Write down the negation of the following propositions in first-order language. Simplify.
25
2 METHODS OF PROOF AND INDUCTION
2.1 Methods of proof
There are a number of ways to prove these theorems and in this section we consider a few
of these methods.
For example
Sometimes it is possible to prove such a statement directly, i.e. by assuming that the
hypothesis A is true and showing that the conclusion B is true by means of establishing the
truth of a sequence of implications
A → A1 → A2 → . . . → B.
Example 2.1
Suppose that x and y are real numbers such that 2x + y = 1 and x − y = −4. Prove that
x = −1 and y = 3.
Proof
y =x+4 (Make y the subject of the equation x − y = −4.)
∴ 2x + (x + 4) = 1. (Substitute y = x + 4 into 2x + y = 1.)
∴ x = −1. (Solve for x.)
∴ y = 3. (Substitute x = −1 into x − y = −4.)
∴ x = −1, y = 3.
26
Example 2.2
Prove that the sum of two even integers is even.
Proof
Let x be an even number, ∴ x = 2a where a is an integer.
Let y be an even number, ∴ y = 2b where b is an integer.
Then
x + y = 2a + 2b
= 2(a + b) where a + b is an integer
∴ x + y is even.
Example 2.3
Use proof by cases to prove that for any integer n, n2 + n is even.
Proof
Every integer is either even or odd.
Consider two cases.
∴ n2 + n is even.
∴ n2 + n is even.
27
Example 2.4
Let n be an integer. Prove that 9n2 + 3n − 2 is even.
Proof
We have 9n2 + 3n − 2 = (3n + 2)(3n − 1), where 3n + 2 and 3n − 1 are two integers.
Case 1: (3n + 2) is even.
If 3n + 2 is even, there exists p ∈ Z such that 3n + 2 = 2p.
Hence 9n2 + 3n − 2 = 2p(3n − 1) = 2(3np − p).
Since 3np − p ∈ Z we have that 9n2 + 3n − 2 is even.
In some cases a direct proof of a statement A is very difficult—we do not know how to
begin. In such a case, one approach is to assume that the conclusion is false, i.e. ¬A is
true. If this assumption leads to a statement which is clearly not true, or to a statement
which contradicts known truths, then we will have shown that ¬A is false. Hence, by the
principle of double negation, A must be true.
Example 2.5
Prove that for all real numbers x, x2 − 4x + 17 6= 0.
Proof
We have to prove A: For all real x, x2 − 4x + 17 6= 0.
Suppose A is false.
∴ x2 − 4x + 17 = 0 for some real number x.
Let x2 − 4x = −17 and complete the square:
∴ x2 − 4x + (−2)2 = −17 + (−2)2
28
∴ x2 − 4x + 4 = −17 + 4
∴ (x − 2)2 = −13
But this is a contradiction, since the square of this real number, x − 2, is now negative, and
we know that the square of any real number is greater than or equal to 0.
Hence our assumption that A is false is wrong.
Hence A is true.
Hence x2 − 4x + 17 6= 0.
Example 2.6
Suppose that x is a non-zero rational number and y is an irrational number. Prove that xy
is irrational.
Proof:
We need to prove the implication A → B where
A : “x is non-zero rational, y is irrational”.
B : “xy is irrational”.
Suppose this implication is false. (Recall that A → B is false only when A is true and B is
false.)
∴ There are numbers x and y such that x is non-zero rational, y is irrational and xy is
rational.
k
∴ x = ` for integers k and `, ` 6= 0 (because x is rational). Note that k 6= 0 since x is
non-zero.
m
We are assuming xy is rational so therefore xy = n where n 6= 0.
m
∴y= n ÷x
m k
∴y= n ÷ `
m `
∴y= n × k
m`
∴y= nk , and n 6= 0, k 6= 0.
From this we can conclude that y is a rational number. (It can be written as a quotient of
integers with the denominator non-zero.) But this contradicts the fact that y is given as
irrational.
Hence our assumption that A → B is false, is wrong.
Therefore A → B is true and xy is irrational.
29
2.1.4 Proof by contraposition
Example 2.7
Let x be an integer and prove that if x2 is even, then x is even.
Proof
In order to prove the implication “x2 even → x even”, we are going to prove the contrapos-
itive, “¬(x even) → ¬(x2 even)”, which is “x odd → x2 odd”.
x2 = (2m + 1)2
= 4m2 + 4m + 1
= 2(2m2 + 2m) + 1.
Example 2.8
Prove the statement by proving that its contrapositive is true: “If m2 + n2 6= 0, then m 6= 0
or n 6= 0.”
Proof
Write down the contrapositive:
“If m = 0 and n = 0, then m2 + n2 = 0.”
Let m = 0 and n = 0.
Then
m2 + n2 = 0 + 0
= 0
30
2.1.5 Disproof by counterexample
Consider the statement “All 2020 first-year UJ students were born before 1 January 2003”.
This statement is either true or false. To prove that it is true we would need to check
the date of birth of every first-year student. However, to show that it is false, we would
just need to find one 2020 first-year student born in 2003 or later. If we could find such a
student, they would be a counterexample that would disprove the statement above.
Consider the proposition “For every non-zero integer c, there exist non-zero integers a and
b such that a2 + b2 = c2 ”. This is false, since it is not true for c = 2: There are no integers
a and b such that a2 + b2 = 4. Thus c = 2 is a counterexample.
Note:
One can effectively disprove a universally quantified statement with a counterexample, but
one cannot prove a theorem with an example. The fact that it holds for one example does
not mean it holds universally. For example, the fact that 32 + 42 = 25 = 52 does not prove
the proposition above.
Example 2.9
Disprove the following statement by providing a counterexample which makes it false: “For
every integer n > 1, if n is odd, then n2 + 4 is a prime number.”
Proof
Counterexample: Take n = 9. Then n2 + 4 = (9)2 + 4 = 85.
31
2.1 Exercises
Use the method of direct proof unless a different method is suggested:
1
a) If a is an even integer, then a is an even integer.
2
b) For all real numbers x, there exists a real number y such that xy = 1.
7. Provide a counterexample for the statement: “For each integer n > 1, if n is odd,
then 4n − 1 is a prime number”.
8. Prove that every odd perfect square can be written in the form 4k + 1, where k ∈ Z.
9. Prove that the product of an odd integer and an even integer is always even.
10. Use proof by cases to prove that every perfect square is either a multiple of 4 or is of
the form 4q + 1 for some integer q.
13. Prove that for any rational number r, the number r + 1 is also rational.
14. Provide a counterexample for the statement: “For each n > 1 and m > 1, if m is odd
and n is even, then m + n is divisible by 3”.
15. Prove that for all integers n > 4, if n is a perfect square, then n − 1 is not prime.
16. Use proof by contradiction to show that for all x ∈ [0, π/2] we have sin x + cos x > 1.
32
2.2 Mathematical Induction
Mathematical induction is a method of proof which can be used to show that certain propo-
sitions are true for all positive integers n. The method is based on the following principle.
1) a ∈ S
2) k ∈ S → k + 1 ∈ S,
We can think of the principle of induction as a kind of “domino theory”. If the first domino
falls, and if each domino that falls causes the next one to fall, then according to the principle
of induction, every domino will fall (see this video of dominoes).
Example 2.10
Use mathematical induction to prove that
n(n + 1)
1 + 2 + 3 + ... + n =
2
Proof:
n(n + 1)
Let S be the set of positive integers n for which 1 + 2 + 3 + ... + n = .
2
1) Show that 1 ∈ S:
1(1 + 1)
LHS = 1 RHS = =1
2
∴ LHS = RHS
∴ 1 ∈ S.
k(k + 1)
2) Assume that k ∈ S. That is, 1 + 2 + 3 + . . . + k = .
2
Now we verify that the equation holds for the case where n = k + 1, that is, we will
show that:
(k + 1)(k + 1 + 1)
1 + 2 + 3 + . . . + k + (k + 1) =
2
33
Consider the left-hand side of the above equation:
+ . . . + k} +(k + 1)
LHS = 1| + 2 + 3{z
k(k + 1)
= + (k + 1) by the inductive hypothesis
2
k(k + 1) + 2(k + 1)
=
2
k 2 + k + 2k + 2
=
2
k 2 + 3k + 2
=
2
(k + 1)(k + 2)
=
2
(k + 1)((k + 1) + 1)
= = RHS
2
∴ k+1∈S
Example 2.11
Use mathematical induction to establish the truth of the following statement for n > 0:
n
X
2i = 2n+1 − 1
i=0
OR 1 + 2 + 22 + 23 + . . . + 2n = 2n+1 − 1.
Proof:
n
X
Let S be the set of integers n > 0 for which 2i = 2n+1 − 1.
i=0
1) Show that 0 ∈ S:
34
LHS = 20 = 1 RHS = 20+1 − 1 = 2 − 1 = 1
∴0∈S
k
X
2) Assume that k ∈ S. So we are assuming that 2i = 2k+1 − 1,
i=0
OR 1 + 2 + 22 + 23 + . . . + 2k = 2k+1 − 1.
k+1
X
Show that k + 1 ∈ S : 2i = 2k+1+1 − 1
i=0
k+1
X
LHS = 2i
i=0
= 2k+1 − 1 + 2k+1
= 2.2k+1 − 1
= 2k+1+1 − 1
= RHS
∴ k+1∈S
∴ It holds for all n > 0.
Example 2.12
Use mathematical induction to show that 4n − 1 is divisible by 3 for all n > 0 (n ∈ Z).
35
2.2 Exercises
Use mathematical induction to prove the following.
1 1 1 1 n
(3.) + + + ... + = , for n > 1.
1.2 2.3 3.4 n(n + 1) n+1
4(4n − 16)
(4.) 43 + 44 + 45 + . . . + 4n = , for n > 3.
3
n
X n2 (n + 1)2
(5.) i3 = , for n > 1.
4
i=1
n−1
X n(n − 1)(n + 1)
(6.) i(i + 1) = , for n > 2.
3
i=1
n+1
X
(7.) i.2i = n.2n+2 + 2, for n > 0.
i=1
(9.) n3 − n is divisible by 6 for all n ∈ Z+ . (Hint: you will need to use Example 2.3 at some
point in your proof.)
References
[1] D.R. Behrendt, E. Raubenheimer, Introductory Discrete Mathematics - Study notes,
2005.
[2] W.E. Conradie, V.F. Goranko, WIS3A20 Discrete Mathematics Lecture Notes: Logic,
Combinatorics and Graph Theory, 2010.
[3] S.S. Epp, Discrete Mathematics with Applications, Third Edition, Thomson
Brooks/Cole, 2004.
[4] E.G. Goodaire and M.M. Parmenter, Discrete Mathematics with Graph Theory, Pren-
tice Hall, 1998.
36