Unit 01
Unit 01
UNIT I
LOGIC
Introduction 02
Session 1 03
Propositional Logic
Session 2 15
Predicate Logic
Session 3 23
Methods of Proof
Answers to the Activities 28
Introduction
1
©2020, The Open University of Sri Lanka
Unit I: Logic
2
©2020, The Open University of Sri Lanka
Session 1: Propositional Logic
Session 1
Propositional Logic
Contents
Introduction, p 3
1.1. Propositions and Truth Tables, p 3
1.2 Tautologies and Contradictions, p 7
1.3. Logical Consequences, p 10
Summary, p 12
Learning outcomes, p 13
Introduction
Definition 1.1
Example 1.1
3
©2020, The Open University of Sri Lanka
Unit I: Logic
The truth or falsity of a proposition is called its truth value, and is denoted
by T (true) and F (false) respectively. We use lowercase letters such as p, q,
r,… to denote propositions.
Example 1.2
p: Snow is white.
Example 1.3
The propositions 1-5 in Example 1.1 are called simple propositions as they
make only a single statement. Simple propositions can be combined with
logical connectives to form compound propositions representing various
forms of complicated idea. Here, we will be using five commonly used
4
©2020, The Open University of Sri Lanka
Session 1: Propositional Logic
logical connectives; (not), (and), (or), (if … then …), and (if
and only if).
Logical connective has the meaning of the word “not” in English, which
reverses the truth value of the proposition. Let p be a proposition. The
compound proposition p is read as “the negation of p” or “not p”. p is
true when p is false, and p is false when p is true. This relationship
between p and p can easily be summarized in a table by giving the truth
value of p for all possible truth values of p. Such a table is called a truth
table.
Truth table of p
p p
T F
F T
Example 1.4
2. Let q denote the proposition “all children are innocent.” q states that
“not all children are innocent.” or “some children are not innocent.”
Logical connective has the meaning of the word “and” in English. Let p
and q be propositions. The compound proposition p q will be true only
when both p and q are true. Otherwise p q is false. p q is called the
conjunction of p and q.
5
©2020, The Open University of Sri Lanka
Unit I: Logic
Truth table of p q
p q pq
T T T
T F F
F T F
F F F
Example 1.5
Logical connective has the meaning of the word “inclusive or” in English.
Let p and q be propositions. The compound proposition p q will be true if
at least one of p and q is true. Otherwise p q is false. p q is called the
disjunction of p and q.
Truth table of p q
p q pq
T T T
T F T
F T T
F F F
Example 1.6
6
©2020, The Open University of Sri Lanka
Session 1: Propositional Logic
Truth table of p q
p q pq
T T T
T F F
F T T
F F T
Note:
Example 1.7
Logical connective has the meaning of the word “if and only if” in
English. Let p and q be propositions. The compound proposition p q will
be true whenever the truth values of both p and q are the same. Otherwise p
q is false. p q is read as “p if and only if q”.
7
©2020, The Open University of Sri Lanka
Unit I: Logic
Truth table of p q
p q pq
T T T
T F F
F T F
F F T
Example 1.8
Example 1.9
1. Represent the scenario: “If the girl cries but is not sick then she does not
need a doctor.” as a compound proposition in propositional logic.
Answer:
q: girl is sick.
2. With respect to the propositions defined in Example 1.9 (1), express the
compound proposition ( (q p)) ( r) in natural English.
Answer:
The girl does not need a doctor if she is neither sick nor cries.
8
©2020, The Open University of Sri Lanka
Session 1: Propositional Logic
Note:
, , , , .
Activity 1.1
1. Let p be the proposition “she is sick”, q be “she is injured”, r be “she needs a doctor”
ii. She does not need a doctor or a lawyer if she is neither sick nor injured.
iii. If she needs a lawyer then she is both sick and injured.
i. (p q) (r s).
ii. r (p q).
iii. p (q r).
9
©2020, The Open University of Sri Lanka
Unit I: Logic
Definition 1.2
Definition 1.3
Example 1.10
p q pq p (p q)
T T T T
T F T T
F T T T
F F F T
From the last column of the above truth table, we see that p (p
q) is always true. Hence, p (p q) is a tautology.
10
©2020, The Open University of Sri Lanka
Session 1: Propositional Logic
Answer:
p q pq q pq (p q) (p q)
T T T F F F
T F F T T F
F T T F F F
F F T T F F
From the last column of the above truth table, we see that (p q)
(p q) is always false. Hence, it is a contradiction.
Note:
Example 1.11
1. Show that p q = p q.
Answer:
p q pq p pq
T T T F T
T F F F F
F T T T T
F F T T T
From the above truth table, we see that p q and p q have
the same truth values. Therefore, p q = p q.
11
©2020, The Open University of Sri Lanka
Unit I: Logic
1. P Q = (P Q) (Q P).
2. P Q = P Q.
3. P Q = Q P .
PQ=QP . (commutative law)
4. (P Q) R = P (Q R).
(P Q) R = P (Q R). (associative law)
5. P (Q R) = (P Q) (P R).
P (Q R) = (P Q) (P R). (distributive law)
6. P F = P.
P F = F.
7. P T = T.
P T = P.
8. P P = T.
P P = F.
9. ( P) = P.
10. (P Q) = P Q.
(P Q) = P Q. (De Morgan’s law)
Activity 1.2
1. Which of the following compound propositions are tautologies and which are
contradictions?
i. (p q) p.
12
©2020, The Open University of Sri Lanka
Session 1: Propositional Logic
iii. (p q) p.
iv. (p q) (p q).
2. Determine whether the following pairs of compound propositions are equal or not:
i. p (q r), (p q) r.
In mathematics, as well as in our daily lives, we are often faced with the
problem of deciding whether one statement logically follows from a given
set of statements. This leads to the concept called “logical consequence” or
“logical implication”, which will be formalized in this section.
Example 1.12
P Q PQ P (P Q)
T T T T
T F F F
F T T F
F F T F
From the above truth table, we see that Q is true whenever
P (P Q) is true. Therefore, Q is a logical consequence of
P and P Q.
13
©2020, The Open University of Sri Lanka
Unit I: Logic
2. If it rained last night then you would get wet. Suppose you did not get
wet. Conclude that it was not rained last night.
Answer:
The premises can then be written as p q (If it rained last night then
you would get wet) and q (you did not get wet). The conclusion is
p (it was not rained last night). Next, let us construct the following
truth table:
p q pq q (p q) q p
T T T F F F
T F F T F F
F T T F F T
F F T T T T
From the last two columns of the above truth table, we see that p
is true whenever (p q) q is true. Therefore, the given
conclusion is true.
Theorem 1.1
Example 1.13
14
©2020, The Open University of Sri Lanka
Session 1: Propositional Logic
P Q P (P Q) (P (P Q)) Q
T T T T
T F F T
F T F T
F F F T
(P (P Q)) Q
= (P ( P Q)) Q (Law 2)
= (F (P Q)) Q (Law 8)
= (P Q) Q (Law 6)
= (P Q) Q (Law 2)
= P ( Q Q) (Associative law)
=PT (Law 8)
=T (Law 7)
((p q) q) p
15
©2020, The Open University of Sri Lanka
Unit I: Logic
= (( p q) q) p (Law 2)
= (( p q) F) p (Law 8)
= ( p q) p (Law 6)
= ( (p q)) p (Law 2)
= (p q) p (Law 9)
= (q p) p (Commutative law)
= q (p p) (Associative law)
=qT (Law 8)
=T (Law 7)
Activity 1.3
i. If the grass was wet then it must have been rained last night or the sprinkler was
on. It did not rain last night, but the grass was wet. Therefore, the sprinkler was
on.
ii. If you are eligible for admission, then you must be under 22 years. You will not be
16
©2020, The Open University of Sri Lanka
Session 1: Propositional Logic
Summary
Learning outcomes
arguments.
17
©2020, The Open University of Sri Lanka
Session 2: Predicate Logic
Session 2
Predicate Logic
Contents
Introduction, p 15
2.1. Atomic Formulas, p 15
2.2 Quantifiers, p 17
2.3. Logical Consequences, p 20
Summary, p 22
Learning outcomes, p 22
Introduction
Our intuition says that the above reasoning is correct. Let us try to use
propositional system to make such reasoning. Let the propositions p, q and r
be such that
q: 5 is a rational number
r: 5 is a real number
19
©2020, The Open University of Sri Lanka
Unit I: Logic
Suppose we want to represent that “x is less than y.” First, we shall define a
predicate called LESS(x, y) to mean “x is less than y.” Here, the predicate
LESS is a relation which relates x and y. Then we represent the sentence “x
is less than 5” as LESS(x, 5), “3 is less than 7” as LESS(3, 7), and “4 is less
than y” as LESS(4, y) etc.
Example 2.1
Predicate logic allows us to use function symbols as well. Let us define the
function mother(x) to denote the mother of x and plus(x, y) to denote x + y.
Then CHILD(Rasika, mother(Rasika)) means that Rasika is a child of
Rasika’s mother. LESS(plus(x, 3), 8) means x + 3 is less than 8. We use
strings of lowercase letters to denote functions.
20
©2020, The Open University of Sri Lanka
Session 2: Predicate Logic
Definition 2.1
A constant is a term.
A variable is a term.
Example 2.2
Definition 2.2
Example 2.3
2.2 Quantifiers
Consider the proposition “all rational numbers are real numbers.” Another
way of saying it is “for every x, if x is a rational number, then it is a real
number.” Let us define two predicates Q(x) and R(x) to “x is a rational
number” and “x is a real number” respectively. Then the above proposition
can be symbolized as (x)(Q(x) R(x)). Now consider a new proposition
21
©2020, The Open University of Sri Lanka
Unit I: Logic
“some real numbers are rational.” It means that there is at least one real
number which is also rational. So we can symbolize it as (x)(R(x) Q(x)).
Example 2.4
Answer:
1. ((x)(R(x) Q(x))).
P(x): x is a person
H(x): x is honest
Definition 2.3
An atom is a formula.
Example 2.5
22
©2020, The Open University of Sri Lanka
Session 2: Predicate Logic
Example 2.6
1. Evaluate the truth values of (x)P(x) and (x)P(x) given D = {1, 2}, P(1)
= F and P(2) = T.
Answer:
the other hand, P is true for at least one value of x (=2) D. Therefore,
23
©2020, The Open University of Sri Lanka
Unit I: Logic
Answer:
When x = 0,
= F P(1, 1)
=T
When x = 1,
= T P(1, 0)
=TF
=F
Note:
Activity 2.1
24
©2020, The Open University of Sri Lanka
Session 2: Predicate Logic
COMPUTER(x): “x is a computer”
f(x): successor of x
3. Evaluate the truth values of the following formulas under the given domain.
P(1) = T, P(2) = F,
25
©2020, The Open University of Sri Lanka
Unit I: Logic
Example 2.7
P2: Q(5)
Answer:
A(x): x is an animal
D(x): x is a dragon
26
©2020, The Open University of Sri Lanka
Session 2: Predicate Logic
“Some animals which are not dragons have sharp claws” can be
written as
The conclusion “There are animals without scales which have sharp
claws” can be symbolized as
T S(a) F = T
S(a) = T
=TTT
= T.
27
©2020, The Open University of Sri Lanka
Unit I: Logic
Activity 2.2
i. Every athlete is strong. Everyone who is both strong and intelligent will
ii. Everyone who eats apples has strong teeth. All those who do not eat apples
are unhealthy. Rasika does not have strong teeth. Therefore, Rasika is
unhealthy.
Summary
28
©2020, The Open University of Sri Lanka
Session 2: Predicate Logic
given set of formulas if the formula is true whenever all the formulas given
are true.
Learning outcomes
29
©2020, The Open University of Sri Lanka
Session 3: Methods of Proof
Session 3
Methods of Proof
Contents
Introduction, p 23
3.1 Direct Proof, p 23
3.2 Indirect Proof, p 24
3.3 Proof by Cases, p 24
3.4 Proof by Induction, p 25
Summary, p 26
Learning outcomes, p 27
Introduction
There are various techniques that can be used to prove theorems. In this
session we shall introduce several basic methods of proof. These proofs are
different from each other as they are designed to establish different results.
Depending on what we have to prove, we can select the appropriate method
of proof which makes the proof simple. Suppose we want to prove that the
conclusion Q is true whenever the premise P is true.
23
©2020, The Open University of Sri Lanka
Unit I: Logic
Proof by Contrapositive
Proof by Contradiction
Here we assume that the conclusion Q is false and try to reach a logical
fallacy.
Example 3.4
Show that n2 is odd when n is odd.
Answer:
Assume that n2 is not odd. Since n is odd, n2 is odd [example 3.1]. Now n2 is
both odd and not odd, which is impossible. Therefore, our assumption is
false, which means n2 is odd.
Example 3.5
Show that 2 is irrational.
Answer:
Assume that 2 is rational. Then we can write 2 = p / q, where p and q are
integers with no common divisors. Squaring and cross multiplying, we get
2q2 = p2. That is, p2 is even. Then from example 3.3, p is even, and hence,
we can write p = 2k, where k is an integer. Now 2q2 = p2 = (2k)2 = 4k2. Then,
q2 = 2k2. That is, q2 is even and so is q. Now both p and q are even, and
share a common divisor, which contradicts our assumption. Therefore, 2 is
irrational.
24
©2020, The Open University of Sri Lanka
Session 3: Methods of Proof
Case 1: x ≥ 0
│x2│= x2 = │x│2.
Case 2: x < 0
│x2│= x2 = (- x)2 = │x│2.
When using the method of proof by cases, make sure that all the cases are
covered.
25
©2020, The Open University of Sri Lanka
Unit I: Logic
Example 3.8
Show that │2A│= 2│A│ for any finite set A, where 2A denotes the power set
of A and │A│denotes the cardinality of A.
Answer:
We prove this identity using the induction on the cardinality (number of
elements) of the set A.
Basis step
Let │A│= 0. This implies A = . Then
L.H.S. = │2A│= │2│= │{}│= 1.
R.H.S. = 2│A│ = 2││ = 20 = 1 = L.H.S.
Hence, the result is true for │A│= 0.
Induction hypothesis
Assume the given result for some │A│= k ≥ 0.
Inductive step
Let │A│= k+1. That is, there is at least one element a in A, and we can write
A = B {a}, where │B│= k and a B. Now the power set of A can be
partitioned in to two sets; one containing the element a, and the other
without containing it. That is, 2A = 2B {{a} X │ X 2B}. These two
sets contain the same number of elements. Therefore, │2 A│= 2│2B│= 2.2k
= 2k+1, which gives the desired result.
Activity 3.1
5. ∑𝑛𝑗=0(𝑗 + 1) 2𝑗 = 𝑛2𝑛+1 + 1
6. n2 < 2n for any integer n ≥ 5.
Summary
There are various different methods of proof that can be used to prove
theorems. The particular proof technique is chosen based on what we have
to prove. The principle of mathematical induction takes a prominent place
among these methods of proof. The other methods can be categorized as
direct and indirect proofs.
26
©2020, The Open University of Sri Lanka
Session 3: Methods of Proof
Learning outcomes
After studying this session, you should be able to,
Describe the various methods of proof.
Define and interpret the principle of mathematical induction.
27
©2020, The Open University of Sri Lanka
Mathematics for Computing
28
©2020, The Open University of Sri Lanka
Session 1: Propositional Logic
Activity 1.1
1. i. (p q) (s r).
ii. (p q) (r s).
iii. s (p q).
iv. r p.
2. i. She needs a doctor and a lawyer if and only if she is both sick and injured.
ii. She does not need a doctor unless she is sick or tired.
iii. If she is sick, if she is injured, then she needs a doctor.
Activity 1.2
1. i
p q pq (p q) p
T T T T
T F F T
F T F T
F F F T
(p q) p is a tautology.
ii
p q r pq qr (p q) (q r) p
(q r) (q r)
T T T T T T T T
T T F T F F F F
T F T F T F F F
T F F F T F F F
F T T T T T T T
F T F T F F F T
F F T T T T F T
F F F T T T F T
29
©2020, The Open University of Sri Lanka
Unit I: Logic
2. i.
p q r pq q r p (q r) (p q) r)
T T T T T T T
T T F T F F F
T F T F T T T
T F F F T T T
F T T T T T T
F T F T F T F
F F T T T T T
F F F T T T F
p (q r) and (p q) r are not equal.
ii. p (p (p q))
= p ( p (p q)) (Law 2)
= p (( p p) ( p q)) (Distributive law)
= p (T ( p q)) (Law 8)
= p ( p q) (Law 7)
= (p p) q (Associative law)
=Tq (Law 8)
= T. (Law 7)
p q (p q)
= (p q) (p q) (De Morgan’s law)
= T. (Law 8)
Therefore, p (p (p q)) = p q (p q)
30
©2020, The Open University of Sri Lanka
Session 1: Propositional Logic
Activity 1.3
1.
( Q P) (P Q)
= ( ( Q) P) (P Q) (Law 2)
= (Q P) (P Q) (Law 9)
= (Q P) (P Q) (Law 2)
= (Q P) ( P Q) (Law 2)
= (Q P) (Q P) (Commutative law)
= T. (Law 8)
( Q P) (P Q) is a tautology. Hence, P Q is a logical
consequence of Q P.
2.
P Q R PQ (P Q) Q R RP
T T T T T T
T T F T F T
T F T F F T
T F F F F T
F T T T T F
F T F T F T
F F T T F F
F F F T F T
From the above truth table, we see that R P is not true whenever (P Q) Q
R is true. Therefore, R P is not a logical consequence of (P Q), Q and R.
3. i. Let us define the following propositions:
p: Grass was wet
q: It rained last night
r: Sprinkler was on
Premises:
(1): p (q r)
(2): qp
Conclusion: r
((p (q r)) ( q p)) r
= (( p (q r)) ( q p)) r (Law 2)
= (( p (q r)) ( q p)) r (Law 2)
= ( p (q r)) ( q p) r (De Morgan’s law)
= ( p (q r)) (( q) p) r (De Morgan’s law)
= ( p (q r)) (q p) r (Law 9)
= ( p (q r)) ( p q) r (Commutative law)
= ( p (q r)) p (q r) (Associative law)
31
©2020, The Open University of Sri Lanka
Unit I: Logic
=T (Law 8)
((p (q r)) ( q p)) r is a tautology. Therefore, the conclusion is
correct.
ii. Let us define the following propositions:
p: You are eligible for admission
q: You are under 22 years
r: You are qualified for a scholarship
Premises:
(1): pq
(2): qr
Conclusion: rp
q r pq q r q (p q) r
p r ( q p
r)
T T T T F F T T T
T T F T F T T T T
T F T F T F F F T
T F F F T T T F T
F T T T F F T T F
F T F T F T T T T
F F T T T F F F F
F F F T T T T T T
r p is not true whenever (p q) ( q r) is true. The conclusion is not
a logical consequence of the given premises. Therefore, the conclusion is not
correct.
32
©2020, The Open University of Sri Lanka
Session 2: Predicate Logic
Activity 2.1
Activity 2.2
1. Let D be the domain of values for which (x)(S(x) H(x)) H(a) = T. That is,
(x)(S(x) H(x)) = T and H(a) = T. Since (x)(S(x) H(x)) = T, we have S(x)
H(x) = T for all x. Hence, it is true for x = a. That is, S(a) H(a) = T, and hence,
33
©2020, The Open University of Sri Lanka
Unit I: Logic
S(a) H(a) = T. Now S(a) H(a) = S(a) F = S(a). That is, S(a) = T.
Therefore, S(a) is a logical consequence of (x)(S(x) H(x)) and H(a).
2. Let D be the domain of values for which (x)(C(x) B(x)) (x)(B(x) A(x)) = T.
That is, (x)(C(x) B(x)) = T and (x)(B(x) A(x)) = T. Since (x)(B(x) A(x)) =
T, there is at least one value (call it a) such that B(a) A(a) = T. That is, B(a) = T
and A(a) = T.
Since (x)(C(x) B(x)) = T, C(a) B(a) = T. That is, C(a) B(a)
= T. Now, C(a) B(a) = C(a) F = C(a). That is, C(a) = T.
Now, A(a) C(a) = T T = T. That is, (x)(A(x) C(x)) = T. Therefore,
(x)(A(x) C(x)) is a logical consequence of (x)(C(x) B(x)) and
(x)(B(x) A(x)).
3. i. First define the following predicates:
A(x): “x is an athlete”
S(x): “x is strong”
I(x): “x is intelligent”
C(x): “x will succeed in his career”
Then the given premises can be formalized as:
F1: (x)(A(x) S(x))
F2: (x)((S(x) I(x)) C(x))
F3: A(Nuwan)
F4: I(Nuwan), and the conclusion can be formalized as:
G: C(Nuwan).
Let D be the domain of values for which F1 F2 F3 F4 = T. That is, F1 = T,
F2 = T, F3 = T, and F4 = T.
Since F1 = T, A(Nuwan) S(Nuwan) = T. That is, A(Nuwan) S(Nuwan) = T.
Now, A(Nuwan) S(Nuwan) = F S(Nuwan) = S(Nuwan).
That is, S(Nuwan) = T.
Since F2 = T, (S(Nuwan) I(Nuwan)) C(Nuwan) = T. Now, (S(Nuwan)
I(Nuwan)) C(Nuwan) = (T T) C(Nuwan) = T C(Nuwan) = C(Nuwan).
That is, C(Nuwan) = T.
Therefore, the conclusion is a logical sequence of the given premises. Hence, the
argument is correct.
ii. First define the following predicates:
E(x): “x eats apples”
S(x): “x has strong teeth”
U(x): “x is unhealthy”
Then the given premises can be formalized as:
F1: (x)(E(x) S(x))
F2: (x)( E(x) U(x))
F3: S(Rasika), and the conclusion can be formalized as:
G: U(Rasika).
Let D be the domain of values for which F1 F2 F3 = T. That is, F1 = T, F2 = T,
34
©2020, The Open University of Sri Lanka
Session 2: Predicate Logic
and F3 = T.
Since F1 = T, E(Rasika) S(Rasika) = T. Now, E(Rasika) S(Rasika) =
E(Rasika) S(Rasika) = E(Rasika) F = E(Rasika).
That is, E(Rasika) = T.
Since F2 = T, E(Rasika) U(Rasika) = T. Now, E(Rasika) U(Rasika)
= E(Rasika) U(Rasika) = F U(Rasika) = U(Rasika). That is, U(Rasika) = T.
Therefore, the conclusion is a logical sequence of the given premises. Hence,
the argument is correct.
35
©2020, The Open University of Sri Lanka