Logic and Proof Techniques Notes
Logic and Proof Techniques Notes
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 (or
both), 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
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
Then it can be rewritten as
(¬p) ∨ (r → (p ∧ ¬q))
(¬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) ↔
In addition we will require that parentheses be added from left to right for connectives of
the same priority order.
Example 1.2
Consider the following propositional formula:
p∨q∧r
Since ∧ and ∨ have the same priority order, one might think that the order in which these
connectives are applied are interchangeable. However, this is not the case.
Suppose we apply the ∨ first, i.e., we have the formula (p ∨ q) ∧ r. Then consider the
truth assignment that assigns true to p and q, but false to r. Then the truth value of the
compound proposition is:
(p ∨ q) ∧ r
= (T ∨ T ) ∧ F
= T ∧F
= F
7
On the other hand, if the ∧ is applied first, i.e., we have the formula p ∨ (q ∧ r), then the
same truth assignment gives the following truth value to the compound proposition:
p ∨ (q ∧ r)
= T ∨ (T ∧ F )
= T ∨F
= T
Following the convention that parentheses are added from left to right, the ∨ should be
applied before the ∧. That is, p ∨ q ∧ r is
(p ∨ q) ∧ r.
The reader is encouraged to also attempt Exercise 1.1.8 d) and e), as these exercises also
illustrate why we need to add parentheses in an agreed upon order.
Example 1.3
Add parentheses to the compound propositions to indicate the order in which the connec-
tives should be applied.
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
8
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.4
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
9
Example 1.5
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
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.6
Show that the propositional formulas p ∨ ¬p and (p ∧ (p → q)) → q are tautologies.
p ¬p p ∨ ¬p
T F T
F T T
10
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.7
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.
Example 1.8
T T T T T F
T F F F T F
F T T F T F
F F T F T F
11
Example 1.9
p q r q ∨ r p → (q ∨ r)
T T T T T
T T F T T
T F T T T
T F F F F
F T T
F T F
F F T
F F F
The compound proposition p → (q ∨ r) is true for at least one assignment of truth values
(e.g. any one of the first three rows of the truth table), and false for at least one assignment
of truth values (e.g. the fourth row of the truth table). Hence, p → (q ∨r) is not a tautology,
nor is it a contradiction. The last four rows of the truth table are again left to the reader
to complete as an exercise.
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.
Alternatively, note that propositional formulas A and B are logically equivalent if and only
if the propositional formula A ↔ B is a tautology.
12
Example 1.10
Show that ¬(p ∨ q) ≡ ¬p ∧ ¬q.
T T T F F F F T
T F T F F T F T
F T T F T F F T
F F F T T T T T
↑ ↑ ↑
same truth values a tautology
Example 1.11
Are ¬(p ∨ q) and (q → p) ∧ ¬q logically equivalent?
T T T F T F F T
T F T F T T T F
F T T F F F F T
F F F T T T T T
Since there is at least one assignment of truth values to the variables that assigns different
truth values to ¬(p ∨ q) and (q → p) ∧ ¬q (the truth assignment in the second row in the
above truth table), these formulas are not equivalent. Note that this is the conclusion even
though the two formulas obtain identical truth values for all other assignments of truth
values. The final column illustrates that the biconditional proposition involving these two
formulas is not a tautology.
There are a few logical equivalences which are used often, such as the one in Example 1.10
above. The two logical equivalences
¬(A ∧ B) ≡ ¬A ∨ ¬B
and ¬(A ∨ B) ≡ ¬A ∧ ¬B
13
are called De Morgan’s laws, after the British mathematician Augustus De Morgan, who
was the first to note these logical equivalences.
In the following we use the letter t to denote a tautology, and f to denote a contradiction.
Here are some more logical equivalences:
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
10. Absorption laws: A ∨ (A ∧ B) ≡ A A ∧ (A ∨ B) ≡ A
The propositional formula A ↔ B is equivalent to propositions A → B and B → A being
true at the same time. In symbols:
A ↔ B ≡ (A → B) ∧ (B → A)
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.12
Use the logical equivalence above to rewrite the following statement in if-then form.
“You do not do your homework or you pass the test’.
14
The given statement is in the form ¬p ∨ q.
Hence p = You do your homework.
So the equivalent if-then statement, p → q, is
“If you do your homework, then you pass the test.”
Example 1.13
Write the negation of the following statement.
“If Nandi lives in Soweto, then she lives in South Africa.”
Example 1.14
Use the known logical equivalences given above to rewrite (p ↔ q) → ¬(p → ¬r) using only
∧, ∨ and ¬.
(p ↔ q) → ¬(p → ¬r)
≡ ¬(p ↔ q) ∨ ¬(p → ¬r) Implication in terms of ¬ and ∨
≡ ((p ∧ ¬q) ∨ (q ∧ ¬p)) ∨ ¬(p → ¬r) Negation of ↔
≡ ((p ∧ ¬q) ∨ (q ∧ ¬p)) ∨ (p ∧ ¬¬r) Negation of →
≡ ((p ∧ ¬q) ∨ (q ∧ ¬p)) ∨ (p ∧ r) Double negation
Example 1.15
Show that (p ∨ q) → r and (p → r) ∧ (q → r) are logically equivalent without using a truth
table (that is, use known equivalences instead).
(p ∨ q) → r
≡ ¬(p ∨ q) ∨ r Implication in terms of ¬ and ∨
≡ (¬p ∧ ¬q) ∨ r De Morgan’s law
≡ r ∨ (¬p ∧ ¬q) Commutative law
≡ (r ∨ ¬p) ∧ (r ∨ ¬q) Distributive law
≡ (¬p ∨ r) ∧ (¬q ∨ r) Commutative law
≡ (p → r) ∧ (q → r) Implication in terms of ¬ and ∨
A very important law of logic is the equivalence between a conditional formula and its con-
trapositive.
15
Definition: The contrapositive of the implication A → B is ¬B → ¬A.
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
Example 1.16
Write down the contrapositive, converse and inverse of the following proposition: “If Rover
is a dog, then Rover is an animal.”
16
1.1.9 Necessary and sufficient conditions
To better understand this, consider the following: “A is a sufficient condition for B” means
that the truth of A is sufficient, or enough, to guarantee the truth of B. That is, if A is
true, then B is true, i.e., A → B.
On the other hand, “A is a necessary condition for B” means that B can only be true if A
is true. That is, B only if A, which we saw in Section 1.1.3 is equivalent to B → A.
Combining the above, we note that “A is a necessary and sufficient condition for B” means
A ↔ B.
Example 1.17
Rewrite the following statements in the if-then form.
17
1.1 Exercises
a) 24 + 32 = 24.
b) 24 + 32 = x.
c) n is an even number.
2) Let A and B be true propositional formulas and let C and D be false propositional
formulas. Determine the truth value of each of the following propositional formulas:
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 propositional formula A in each of the following cases:
18
d) B → ¬A is true, ¬B → ¬C is true, C is true.
4) Add parentheses to the following propositional formulas to indicate the order in which
the connectives should be applied:
a) B → ¬¬¬A ∨ C
b) A ∨ B → C ∧ A
c) ¬¬A ↔ A ↔ B ∨ C
d) ¬A ∨ B ∨ C ∧ D → A → ¬A
e) C → A → A ↔ ¬A ∨ B
5) 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.
6) Determine the antecedent and the consequent in each of the following implications:
7) Construct a truth table for each the following propositional formulas to determine if it
is a tautology, a contradiction or neither:
19
a) ¬(p ∧ q) ∨ (p ∨ q)
b) (p → (q → r)) ↔ ((p ∨ q) → r)
c) ¬p ∧ ¬(p → q)
d) (p ∧ ¬q) → r
e) (p → r) ↔ (q → r)
f) ¬p ∨ (q → r)
g) ¬(¬p ↔ q) ∧ (r ∨ ¬q)
i) (p → q) ∧ (q → r) ∧ ¬(¬p ∨ r)
j) (p ∧ ¬p) → q
8) Use truth tables to determine whether the pair of propositional formulas are logically
equivalent to one another:
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
e) p ∧ (q ∨ r) and (p ∧ q) ∨ r
f) (p ∧ q) → r and (p → r) ∨ (q → r)
g) (p ∨ q) ∧ (¬p ∨ q) and q
h) p → (q → r) and (p ∧ q) → r
i) (p → q) ∧ (q → r) and p → r
j) p ∧ (q ↔ r) and (p ∧ q) ↔ (p ∧ r)
9) Use known logical equivalences to rewrite each of the following propositional formulas
using only ∧, ∨ and ¬:
a) p ∧ ¬q → r
b) p ∨ ¬q → r ∨ q
20
c) ¬p ∧ ¬(p → q)
d) (p → r) ↔ (q → r)
e) ((p → q) → p) → p
10) Show that following pairs of propositional formulas are equivalent without using a truth
table (that is, use known equivalences instead).
a) (B → A) ∧ (¬B → A) and A.
b) (A → B) → (A → C) and (A ∧ B) → C
c) A → (B ∨ C) and (A → B) ∨ (A → C)
e) A ↔ B and (A ∨ B) → (A ∧ B)
11) 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.
12) Write down the converse and inverse of the following statements:
a b a
a) If and are integers, then is an integer.
b c c
b) If 4ABC is a right triangle, then a2 + b2 = c2 .
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.
21
14) Suppose we wish to add an “exclusive or” binary connective to the propositional logic,
denoted by ⊕, such that p ⊕ q is true precisely when exactly one of p and q is true.
Construct a truth table for the “exclusive or” connective.
15) Let downarrow denote the binary connective “not ... or ...” (often referred to as NOR)
such that p ↓ q is true precisely when neither p nor q is true. The truthtable for NOR is:
p q p↓q
T T F
T F F
F T F
F F T
16) Find a propositional formula A with variables p, q and r such that the truth table for A
is
p q r A
T T T F
T T F T
T F T T
T F F F
F T T F
F T F F
F F T T
F F F F
22
1.2 Basic Concepts of Predicate Logic
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.
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 set of non-negative integers (integers greater than or equal to zero) is called the natural
numbers and is denoted by N. That is
N = {0, 1, 2, 3, . . .}
The integers are used to construct the rational numbers. We denote the set of rational
23
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 num-
√ √
bers like 2, π, e, 2 2 are elements of R but are not elements of Q.
Note that the number systems reviewed above form a sequence of increasing number sys-
tems. That is, every natural number is an integer, every integer is a rational number, and
every rational number is a real number. In symbols we write:
N ⊆ Z ⊆ Q ⊆ R.
1. 1|n for every integer n, i.e. 1 is a divisor of n for every integer n, and
2. n|n for every integer n 6= 0, i.e. every non-zero integer divides itself.
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.
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.
24
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).
Example 1.18
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.19
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
25
1.2.3 Quantifiers
The symbol ∀ denotes ‘for all’ or ‘for every’ and is called the universal quantifier. For
example, we can express the statement
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 of x for which Q(x) is false is called a counterexample.
Example 1.20
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.
Note that there may be many counterexamples. For instance, if we take x = 3 then
x2 = 9 and not equal to 1, so 3 serves as another counterexample. We must just be
able to identify at least one member of the domain that makes the predicate false.
26
12 > 1 - True
22 > 2 - True
32 > 3 - True
42 > 4 - True
52 > 5 - True.
The second quantifier used in predicate logic 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.
Example 1.21
Determine the truth value of the following existentially quantified statements:
a) (∃x ∈ Z)(x + 5 = 5)
b) (∃x ∈ Z)(x < x + 1)
c) (∃x ∈ D)(x2 6 x), where D = {2, 3, 4, 5, 6}
Note that 0 is the only possible integer that can make the statement true. Since the
existential quantifier only requires at least one member of the domain that makes the
predicate true, the quantified statement is true.
27
b) (∃x ∈ Z)(x < x + 1).
This statement says that there exists some integer that is less than its successor. To
show that it is true, we have to find at least one integer less that its successor. If we
take x = 1, then 1 < 1 + 1. Hence, the statement is true.
Note that in this example we could let x be any integer. There may be multiple
members of the domain that make the predicate true. As long as we can find at least
one, the quantified statement is true.
22 6 2 - False.
32 6 3 - False.
42 6 4 - False.
52 6 5 - False.
62 6 6 - False.
Example 1.22
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.)
28
b) (∀x ∈ R)(x2 6= −1)
“All real numbers have squares not equal to −1.”
OR “No real numbers have squares equal to −1.”
(True, the square of any real number is greater than or equal to 0.)
Example 1.23
Translate the following statements from English into first-order language:
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))
29
by narrowing the universal domain U to the domain D consisting of all values of x that
make P (x) true.
Example 1.24
Consider Example 1.23(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))
Example 1.25
Rewrite the following sentence in first-order language. Then write the negation in first-order
language and in natural language.
30
Recall that in propositional logic, the negation of an implication is a conjunction:
¬(p → q) ≡ p ∧ ¬q.
The same rule applies when negating a quantified conditional statement. Hence
Example 1.26
Write down the negation of the following universally quantified conditional statement:
31
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 determine
2
which of these statements are false and which are true.
1
a) (∀x ∈ R) x >
x
a−1
b) (∀a ∈ Z) is not an integer
a
4) Translate the following first-order formulae into English and determine which of them
represent true statements.
b) (∃x ∈ R)(x2 = 2)
f) ¬(∀x ∈ R)(x 6= 0)
g) (∃x ∈ R)(x + 2 = x)
32
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 statement in first-order language. Simplify.
33
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. That is, we assume that the
hypothesis A is true and show that the conclusion B is true. This is done by establishing
the truth of a sequence of implications.
The reader is referred back to Exercise 1.1.8 i) to see why proving such a sequence of im-
plications established the truth of A → B.
Many of the proofs we will encounter are direct proofs. We use the symbol ∴ (read as
therefore) to indicate successive implications. The symbol indicates the end of the proof.
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
34
Assume that 2x + y = 1 and x − y = −4. Assume that A is true.
∴y =x+4 (Make y the subject of the equation x − y = −4.) A → A1
∴ 2x + (x + 4) = 1. (Substitute y = x + 4 into 2x + y = 1.) A1 → A2
∴ x = −1. (Solve for x.) A → A1 A2 → A3
∴ y = 3. (Substitute x = −1 into x − y = −4.) A3 → A4
∴ x = −1, y = 3. A4 → B
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.
35
n2 + n = (2a)2 + 2a
= 4a2 + 2a
= 2(2a2 + a) where 2a2 + a is an integer
∴ n2 + n is even.
∴ n2 + n is even.
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
36
true. If this assumption leads to a statement which is clearly not true, or to a statement
which contradicts known truths or our initial assumptions, then we have shown that ¬A is
false. Since ¬A is true only if A is true (this follows from the truth table for the negation
connective), we conclude that the statement A holds.
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
∴ 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, for all real x, 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.
37
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 assumption that y is
irrational.
Hence our assumption that A → B is false, is wrong.
Therefore A → B is true and xy is irrational.
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.
38
Since we have shown that “x odd → x2 odd”, it holds that “x2 even → x even”.
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
Consider the statement “All 2021 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 2021 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.
Example 2.9
Disprove the following statement by providing a counterexample which makes it false:
39
“For every non-zero integer c, there exist non-zero integers a and b such that a2 + b2 = c2 ”.
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.10
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.”
40
2.1 Exercises
Use the method of direct proof unless a different method is suggested:
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.
41
16) Use proof by contradiction to show that for all x ∈ [0, π/2] we have sin x + cos x > 1.
42
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 natural numbers 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.11
Use mathematical induction to prove that
n(n + 1)
1 + 2 + 3 + ... + n =
2
Proof:
n(n + 1)
Let S be the set of natural numbers n > 1 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
43
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.12
Use mathematical induction to establish the truth of the following statement for all natural
numbers:
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 natural numbers for which 2i = 2n+1 − 1.
i=0
1) Show that 0 ∈ S:
44
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 natural numbers.
Example 2.13
Use mathematical induction to show that 4n − 1 is divisible by 3 for all natural numbers.
Proof: Let S be the set of all natural numbers n for which 4n − 1 is divisible by 3.
45
2.2 Exercises
Use mathematical induction to prove the following.
1 1 1 1 n
3) + + + ... + = , for all natural numbers n > 1.
1.2 2.3 3.4 n(n + 1) n+1
4(4n − 16)
4) 43 + 44 + 45 + . . . + 4n = , for all natural numbers n > 3.
3
n
X n2 (n + 1)2
5) i3 = , for all natural numbers n > 1.
4
i=1
n−1
X n(n − 1)(n + 1)
6) i(i + 1) = , for all natural numbers n > 2.
3
i=1
n+1
X
7) i.2i = n.2n+2 + 2, for all natural numbers.
i=1
9) n3 − n is divisible by 6 for all natural numbers n > 1. (Hint: you will need to use
Example 2.3 at some point in your proof.)
10) If X is any set, then we denote by P(X) the set of all subsets of X. For example, if
X = {a, b} then there are four subsets: ∅ (the empty set), {a}, {b} and {a, b} = X.
That is, P(X) = {∅, {a}, {b}, X}.
If X is a finite set, we write |X| = n to denote that there are n elements in X. Prove
that if |X| = n, then |P(X)| = 2n for all natural numbers n > 1.
46
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.
47