0% found this document useful (0 votes)
28 views41 pages

Unit 01

The document is a unit on Logic from a Mathematics for Computing course, focusing on propositional logic, predicate logic, and methods of proof. It introduces key concepts such as propositions, truth tables, logical connectives, tautologies, and contradictions. The unit aims to provide foundational knowledge in symbolic logic, which is essential for reasoning in mathematics and computer science.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views41 pages

Unit 01

The document is a unit on Logic from a Mathematics for Computing course, focusing on propositional logic, predicate logic, and methods of proof. It introduces key concepts such as propositions, truth tables, logical connectives, tautologies, and contradictions. The unit aims to provide foundational knowledge in symbolic logic, which is essential for reasoning in mathematics and computer science.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 41

Mathematics for Computing

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

This unit is divided into three sessions, namely, propositional logic,


predicate logic and methods of proof. Logic, sometimes referred to as
mathematical logic or symbolic logic, considers the languages whose
purpose is to represent (using symbols) the reasoning we encountered in
mathematics as well as in real life. Logic can be studied from various points
of view, and traditionally, it was studied in mathematical and philosophical
orientations. We can use logic for a wide variety of purposes such as to
represent problems and to find their solutions, to establish the validity of
arguments, and to prove that a formula logically follows from some other
formulas. A man’s desire to find a general decision procedure to prove
theorems dates back to Leibniz (1646 – 1716). Logic, with the invention of
powerful inference rules and digital computers, is used today for mechanical
theorem proving.
In first session, we shall study the simplest form of symbolic logic called
propositional logic. In second session, you will be introduced to a bit more
advanced logic system called predicate logic as propositional system does
not have much expressive power to represent many problems we encounter
in this world. The last session deals with proofing techniques that are used
in proving theorems.

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

The simplest form of symbolic logic is known as the propositional logic or


propositional calculus. In this logic system, we are interested in declarative
statements which are either true or false, but not both simultaneously.
Propositional logic is very easy to learn and understand, but it does not have
much expressive power to represent many problems we encounter in this
world.

1.1 Propositions and Truth Tables

Definition 1.1

A proposition is a declarative statement which is either true or


false, but not both simultaneously.

Example 1.1

The followings are some examples of propositions.


1. Snow is white.

3
©2020, The Open University of Sri Lanka
Unit I: Logic

2. Triangles have three sides.


3. 2 + 5 > 9.
4. This boy is wearing a red shirt.
5. It rained last night.

Propositions 1 and 2 are true, whereas proposition 3 is false. The truth or


falsity of proposition 4 depends on the context in which it was stated. The
truth or falsity of proposition 5 depends on when and where it was stated.

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.

q: This boy is wearing a red shirt.

Note that commands, requests, questions and exclamations etc. are


not propositions since we cannot declare them as true of false.

Example 1.3

The followings are not propositions.

1. Do not bring mobile phones in to the examination hall.

2. Please bring me a cup of tea.

3. Did you forget to bring your umbrella?

4. Long live the king!

Logical connectives and compound propositions

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

1. Let p denote the proposition “the child is injured.”  p can be written as


“the child is not injured.”

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 pq

T T T
T F F
F T F
F F F

Example 1.5

1. Let p be the proposition “student attends lectures” and q be “student


studies hard”. Then p  q means that the student attends lectures and
works hard.

2. Let p be the proposition “it is raining” and q be “it is lightning”. Then p


 q means that it is raining and lightning.

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 pq

T T T
T F T
F T T
F F F

Example 1.6

Let p be the proposition “it is raining” and q be “sprinkler is on”. Then p  q


means that it is raining or sprinkler is on (or both).

Logical connective  has the meaning of the word “if …then …” in


English. Let p and q be propositions. The compound proposition p  q will

6
©2020, The Open University of Sri Lanka
Session 1: Propositional Logic

be false only when p is true and q is false. Otherwise p  q is true. p  q is


read as “p implies q” or “if p then q”.

Truth table of p  q

p q pq

T T T
T F F
F T T
F F T

Note:

p  q is true irrespective of the truth value of q when p is false.

Example 1.7

1. Let p be the proposition “sun is shining” and q be “sky is blue”. Then p


 q means that if the sun is shining then the sky is blue.

2. Let p: it is raining, q: grass is wet. Then p  q means that the grass is


wet whenever it is raining.

3. Let p: 2 + 3 = 6, q: snow is red. Then p  q is true because p is false.

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 pq

T T T
T F F
F T F
F F T

Example 1.8

1. Let p: I drink water, q: I am thirsty. Then p  q means that I drink


water if and only if I am thirsty.

2. Let p: 2 + 3 = 6, q: snow is red. Then p  q is true because both p and


q have the same truth value (false).

3. Let p: 2 + 3 = 6, q: snow is white. Then p  q is false because the truth


values p and q are not the same (p is false whereas q is true).

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:

First, we need to identify and symbolize the propositions present in the


given scenario. Let us define the propositions p, q and r as:
p: the girl cries.

q: girl is sick.

r: girl needs a doctor.

Then the above scenario can be symbolized as (p  ( q))  ( r).

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:

The binding order of logical connectives from highest to lowest


precedence is as follows:

, , , , .

We can omit unnecessary parentheses by using the binding order


of connectives. For example, the compound proposition in
Example 1.9 (1) can be written as p   q   r. But you may
still use additional parentheses as you wish in order to increase the
clarity of your expressions.

Activity 1.1

1. Let p be the proposition “she is sick”, q be “she is injured”, r be “she needs a doctor”

and s be “she needs a lawyer.” Symbolize the following compound propositions:

i. She needs a lawyer or a doctor if she is sick or injured.

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.

iv. She needs a doctor only if she is sick.

2. Using the propositions defined in (1), express the following compound

propositions in natural English:

i. (p  q)  (r  s).

ii.  r  (p  q).

iii. p  (q  r).

9
©2020, The Open University of Sri Lanka
Unit I: Logic

1.2 Tautologies and Contradictions

We often encounter special types of compound propositions whose truth


value is always true or always false no matter what the truth values of their
individual simple propositions making up the compound proposition. For
example, if p is a proposition, p   p is always true and p   p is always
false. We formalize this as the following:

Definition 1.2

A tautology is a compound proposition whose truth value is


always true irrespective of the truth values of its individual
propositions which comprised the compound proposition.

Definition 1.3

A contradiction is a compound proposition whose truth value is


always false irrespective of the truth values of its individual
propositions which comprised the compound proposition.

Example 1.10

1. Show that p  (p  q) is a tautology.


Answer:

Let us construct the truth table of p  (p  q).

p q pq 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.

2. Show that (p  q)  (p   q) is a contradiction.

10
©2020, The Open University of Sri Lanka
Session 1: Propositional Logic

Answer:

Let us construct the truth table of (p  q)  (p   q).

p q pq q pq (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:

We use uppercase letters P, Q, R, S etc., to denote compound


propositions.

Two compound propositions P and Q are said to be equal and


write P = Q if and only if the truth values P and Q are the same
for all possible truth values of their individual propositions.

Example 1.11

1. Show that p  q =  p  q.
Answer:

p q pq p pq

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

Laws of propositional logic

Let P, Q and R be (possibly compound) propositions.

1. P  Q = (P  Q)  (Q  P).
2. P  Q =  P  Q.
3. P  Q = Q  P .
PQ=QP . (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)

Each of these laws can be verified by using truth tables. It is left as an


exercise to the reader to verify them.

Activity 1.2

1. Which of the following compound propositions are tautologies and which are

contradictions?

i. (p  q)  p.

ii. ((p  q)  (q  r))  (p  (q  r)).

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.

ii. p  (p  (p  q)),  p   q  (p  q).

1.3 Logical Consequences

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.

A proposition (possibly compound) G is said to be a logical consequence of


the propositions P1, P2, …, Pn (or G logically follows from P1, P2, …, Pn)
(or P1  P2  …  Pn logically implies G) if G is true whenever P1  P2 
…  Pn is true.

P1, P2, …, Pn are called premises and G is called the conclusion.

Example 1.12

1. Show that Q is a logical consequence of P and P  Q.


Answer:

P Q PQ 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:

Let us first define the following propositions in order to translate the


given premises and the conclusion in to propositions.
p: it rained last night.

q: you would get wet.

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 pq 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

A compound proposition G is a logical consequence of the given


propositions P1, P2, …, Pn if and only if (P1  P2  …  Pn)  G
is a tautology.

The proof of this theorem is left as an exercise to the reader.

Example 1.13

1. In Example 1.12.1, we have

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

From the above truth table, we see that (P  (P  Q))  Q is a

tautology. Therefore, according to the theorem, Q is a logical


consequence of P and P  Q.

2. In Example 1.12.1, we have

(P  (P  Q))  Q

= (P  ( P  Q))  Q (Law 2)

= ((P   P)  (P  Q))  Q (Distributive law)

= (F  (P  Q))  Q (Law 8)

= (P  Q)  Q (Law 6)

=  (P  Q)  Q (Law 2)

= ( P   Q)  Q (De Morgan’s law)

=  P  ( Q  Q) (Associative law)

=PT (Law 8)

=T (Law 7)

Therefore, (P  (P  Q))  Q is a tautology, and hence, Q is a logical


consequence of P and P  Q.

3. In Example 1.12.2, we have

((p  q)   q)   p

15
©2020, The Open University of Sri Lanka
Unit I: Logic

= (( p  q)   q)   p (Law 2)

= (( p   q)  (q   q))   p (Distributive law)

= (( p   q)  F)   p (Law 8)

= ( p   q)   p (Law 6)

=  (p  q)   p (De Morgan’s law)

=  ( (p  q))   p (Law 2)

= (p  q)   p (Law 9)

= (q  p)   p (Commutative law)

= q  (p   p) (Associative law)

=qT (Law 8)

=T (Law 7)

Therefore, ((p  q)   q)   p is a tautology, and hence,  p is a


logical consequence of (p  q) and  q.

Activity 1.3

1. Show that P  Q is a logical consequence of  Q   P.

2. Is R  P a logical consequence of (P  Q), Q and R?

3. Test the validity of the following arguments

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

qualified for a scholarship if you are not under 22 years. Therefore, if

you qualify for a scholarship, you are eligible for admission.

16
©2020, The Open University of Sri Lanka
Session 1: Propositional Logic

Summary

Propositional logic, the simplest symbolic logic system, is based on


propositions which are declarative statements that are either true or false,
but not both. Compound propositions representing complex ideas can be
formed by combining propositions with logical connectives. A tautology is a
compound proposition which is always true, whereas a contradiction is a
compound proposition that is always false. Truth table is a convenient way
to check the truth or falsity of a compound proposition. Two compound
propositions are equal if and only if they have the same truth value, which
can easily be checked using truth tables. It also can be done algebraically
using the laws of propositional logic. A compound proposition is logically
derived from a given set of compound propositions if the proposition is true
whenever all the propositions given are true.

Learning outcomes

After studying this session, you should be able to

 Describe the propositional logic system and its fundamentals.

 Demonstrate the necessary theoretical background to test the validity of

arguments.

 Apply the foundation to more advanced logic systems.

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

The most primitive elements of propositional logic are propositions. Such a


proposition is treated as a single unit, whose structure is suppressed. We
often encounter many ideas that cannot be treated in this way. For instance,
consider the following deduction of statements you are familiar with in
mathematics.

“Every rational number is a real number. 5 is a rational number. Therefore,


5 is a real number.”

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

p: Every rational number is a real number

q: 5 is a rational number

r: 5 is a real number

Then r is not a logical consequence of p and q within the propositional


framework. Hence, we need a logic system that could use structures of p, q

19
©2020, The Open University of Sri Lanka
Unit I: Logic

and r in order to prove that r is a logical consequence of p and q. This leads


to the introduction of predicate logic (predicate calculus or first-order logic).

2.1 Atomic Formulas

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.

We use strings of uppercase letters to denote predicates.

Example 2.1

Suppose we want to express “Rasika is a child of Manel.” Let the predicate


CHILD(x, y) mean x is a child of y. Then CHILD(Rasika, Manel) represents
that Rasika is a child of Manel.

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.

A predicate or a function symbol can take a number of arguments. If a


predicate takes n arguments, it is called an n-place predicate symbol.
Similarly, if a function takes n arguments, it is called an n-place function
symbol. Predicate CHILD defined above is a 2-place predicate symbol,
mother is a 1-place function symbol, and plus is a 2-place function symbol.
In the above examples, x and y are called variables, and 3, 5, Rasika, and
Manel are called constants.

Note that a function is a mapping that maps a number of variables/constants


to a variable/constant. For example, plus(x, y) maps two variables x and y to
their sum, mother(Rasika) maps a person named Rasika to a person who is
Rasika’s mother. A predicate maps a list of constants to T (true) or F (false).

20
©2020, The Open University of Sri Lanka
Session 2: Predicate Logic

Definition 2.1

A term in predicate logic is defined recursively as follows:

A constant is a term.

A variable is a term.

If f is an n-place function symbol and t1, t2, …, tn are terms, then


f(t1, t2, …, tn) is a term.

All terms are generated by applying the above rules.

Example 2.2

mother(Rasika), plus(plus(x, 1), 3) are terms in predicate logic whereas


LESS(x, 2) is not.

Definition 2.2

If P is an n-place predicate symbol and t1, t2, …, tn are terms, then


P(t1, t2, …, tn) is an atom or an atomic formula.

Example 2.3

CHILD(Rasika, Manel) and CHILD(Rasika, mother(Rasika)) are atoms.

2.2 Quantifiers

There are two quantifiers in predicate logic; universal quantifier (denoted by


) and existential quantifier (denoted by ). If x is a variable, (x) is read as
“for all x” or “for every x” while (x) is read as “for some x” or “for at least
one x” or “there exists an x.”

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

Symbolize the following propositions:

1. Not all real numbers are rational.

2. Some people are not honest.

3. There is no number for which 0 is the successor.

Answer:

1.  ((x)(R(x)  Q(x))).

2. First, we define the required predicates as follows:

P(x): x is a person

H(x): x is honest

Proposition can then be symbolized as (x)(P(x)   H(x)).

3. Let us define a function f(x) to mean “successor of x” and a predicate E(x,


y) to mean “x equals y.” Given proposition is then symbolized as 
((x)E(f(x), 0)).

Definition 2.3

A formula in predicate logic is defined recursively as follows:

An atom is a formula.

If P and Q are formulas, then  P, (P  Q), (P  Q), (P  Q) and


(P  Q) are formulas.

If P is a formula and x is a variable, then (x)P and (x)P are


formulas.

All formulas are generated only by applying the above rules.

Example 2.5

22
©2020, The Open University of Sri Lanka
Session 2: Predicate Logic

1. (x)(Q(x)  R(x)) and (x)(R(x)  Q(x)) are formulas.

2. Translate the statement “every rational number is a real number. 5 is a


rational number. Therefore, 5 is a real number” in to a formula in
predicate logic.
Answer:

(x)(Q(x)  R(x)) means “every rational number is a real number.”

Q(5) means “5 is a rational number.”

R(5) means “5 is a real number.”

Then the whole statement can be symbolized as

((x)(Q(x)  R(x))  Q(5))  R(5).

In order to check the truth value of a formula in predicate logic, first we


have to define a nonempty domain D of values for variables and constants
occurring in the formula. In this case, (x) means “for all x in D” and (x)
means “for at least one x in D.” The formula (x)P is evaluated to true (T) if
P is true for all values of x in D; otherwise, it is evaluated to false (F). The
formula (x)P is evaluated to true (T) if P is true for at least one value of x
in D; otherwise, it is evaluated to false (F).

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:

P is not true for all x  D. Therefore, (x)P(x) is evaluated to false. On

the other hand, P is true for at least one value of x (=2)  D. Therefore,

(x)P(x) is evaluated to true.

2. Evaluate the truth value of (x)(Q(x)  P(a, g(x))) given

D = {0, 1}, a = 1, g(0) = 1, g(1) = 0, Q(0) = F, Q(1) = T

23
©2020, The Open University of Sri Lanka
Unit I: Logic

P(0, 0) = T, P(0, 1) = T, P(1, 0) = F, P(1, 1) = T

Answer:

When x = 0,

Q(x)  P(a, g(x))

= Q(0)  P(1, g(0))

= F  P(1, 1)

=T

When x = 1,

Q(x)  P(a, g(x))

= Q(1)  P(1, g(1))

= T  P(1, 0)

=TF

=F

Q(x)  P(a, g(x)) is not true for all x  D.

Therefore, (x)(Q(x)  P(a, g(x))) is false.

Note:

All laws in propositional logic are true for predicate logic. In


addition, we have

 ((x)P(x)) = (x)(  P(x)) and

 ((x)P(x)) = (x)(  P(x)) ; where P(x) is a formula


containing x.

Activity 2.1

1. Translate the following statements in natural English to formulas in predicate logic.

24
©2020, The Open University of Sri Lanka
Session 2: Predicate Logic

i. Everyone loves someone.

ii. Someone is loved by everyone.

iii. No parent buys a dangerous toy for their kids.

iv. Some patients like all doctors.

2. Consider the predicates and functions defined below:

COMPUTER(x): “x is a computer”

BIOS(x): “x is a BIOS chip”

CONTAIN(x, y): “x contains y”

E(x, y): “x equals y”

f(x): successor of x

Translate the following formulas in predicate logic to natural English.

i. (x)(COMPUTER(x)  (y)(BIOS(y)  CONTAIN(x, y))).

ii. (x)(y)E(y, f(x)), assuming the domain of values as numbers.

(x)(y)(E(y, f(x))  (z)(E(z, f(x))  E(y, z))).

3. Evaluate the truth values of the following formulas under the given domain.

i. (x)(P(a, g(x))  Q(x, a)),

D = {1, 2}, a = 2, g(1) = 1, g(2) = 2

P(1, 1) = T, P(1, 2) = F, P(2, 1) = F, P(2, 2) = T,

Q(1, 1) = F, Q(1, 2) = F, Q(2, 1) = T, Q(2, 2) = F.

ii. (x)((P(x)  Q(a, g(x)))  R(x, x)),

D = {1, 2}, a = 1, g(1) = 2, g(2) = 1

P(1) = T, P(2) = F,

Q(1, 1) = T, Q(1, 2) = T, Q(2, 1) = F, Q(2, 2) = T,

R(1, 1) = F, R(1, 2) = T, Q(2, 1) = F, R(2, 2) = T,

2.3 Logical Consequences

25
©2020, The Open University of Sri Lanka
Unit I: Logic

We have already introduced the concept of logical consequence under


propositional logic in session 1. Idea is the same here even in the predicate
logic, and we are reproducing it here as follows:

A formula G is said to be a logical consequence of the formulas P1, P2, …,


Pn (or G logically follows from P1, P2, …, Pn) if G is true whenever P1  P2
 …  Pn is true.

P1, P2, …, Pn are called premises and G is called the conclusion.

Example 2.7

1. Consider the formulas:


P1: (x)(Q(x)  R(x))

P2: Q(5)

We shall show that R(5) is a logical consequence of P1 and P2.

Let D be the domain of values. Let P1  P2 = T. Then P1 = T and P2 = T.


Since P1 = T, Q(x)  R(x) = T for all values of x  D. Therefore, Q(5) 
R(5) = T. So we have  Q(5)  R(5) = T. Further, Q(5) = T as P2 = T. Then
 Q(5) = F. Now F  R(5) = T. Since F  R(5) = R(5), we have R(5) = T.
Therefore, R(5) is a logical consequence of P1 and P2.

2. Check the validity of the following argument:


“All animals with scales are dragons. Some animals which are not dragons
have sharp claws. Therefore, there are animals without scales which have
sharp claws.”

Answer:

Let us define the predicates A, S, D and C as

A(x): x is an animal

S(x): x has scales

D(x): x is a dragon

C(x): x has sharp claws

26
©2020, The Open University of Sri Lanka
Session 2: Predicate Logic

“All animals with scales are dragons” can be written as

P1: (x)((A(x)  S(x)) D(x)).

“Some animals which are not dragons have sharp claws” can be
written as

P2: (x)(A(x)   D(x)  C(x)).

The conclusion “There are animals without scales which have sharp
claws” can be symbolized as

G: (x)(A(x)   S(x)  C(x)).

We shall show that G is a logical consequence of P1 and P2. Let D be


the domain of values. Let P1  P2 = T. Then P1 = T and P2 = T. Since
P2 = T, A(x)   D(x)  C(x) = T for at least one value (call it a) of x
 D. That is, A(a)   D(a)  C(a) = T and consequently, A(a) = T,
 D(a) = T and C(a) = T.

Since P1 = T, (A(x)  S(x)) D(x) = T for all x  D. Therefore, (A(a)


 S(a)) D(a) = T. Now we have

(A(a)  S(a)) D(a) = T

  (A(a)  S(a))  D(a) = T

  A(a)   S(a)  D(a) = T

  T   S(a)  F = T

  S(a) = T

Now A(a)   S(a)  C(a)

=TTT

= T.

27
©2020, The Open University of Sri Lanka
Unit I: Logic

So, we have A(x)   S(x)  C(x) = T for a  D. Therefore, G is


true. Hence, G is a logical consequence of P1 and P2, and the given
argument is correct.

Activity 2.2

1. Show that  S(a) is a logical consequence of (x)(S(x)  H(x)) and  H(a).

2. Show that (x)(A(x)   C(x)) is a logical consequence of (x)(C(x)   B(x))

and (x)(B(x)  A(x)).

3. Check the validity of the following arguments:

i. Every athlete is strong. Everyone who is both strong and intelligent will

succeed in his career. Nuwan is an athlete. Nuwan is intelligent. Therefore,

Nuwan will succeed in his career.

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

Predicate logic is introduced as propositional system is not expressive


enough to represent many ideas we encounter in real world. It is based on
predicates, a relation between arguments appearing in the predicate. The use
of functions is allowed in this logic system. Variables, constants, functions
and predicates together with two quantifiers; universal and existential, are
involved in formulas. A domain of values for variables and constants
appearing in formulas has to be defined in order to evaluate the truth values
of formulas. If P is a formula involving x, then (x)P is evaluated to true if
P is true for all values of x in the domain; otherwise, it is evaluated to false.
(x)P is evaluated to true if P is true for at least one value of x in the
domain; else it is evaluated to false. A formula is logically derived from a

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

By the end of this session you will be able to

 Describe the predicate logic and its fundamentals.

 Use necessary theoretical background to make inference

using predicate logic.

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.

3.1 Direct Proof


This method starts with the given premise P and the conclusion Q is
deduced directly through a series of logical steps.
Example 3.1
Show that if n is odd, then n2 is odd.
Answer:
We start by taking n is odd and then deduce that n2 is odd.
If n is odd, we can write n = 2k +1, where k is an integer.
Now, n2 = (2k + 1)2
= 4k2 + 4k + 1
= 2(2k2 + 2k) + 1
which is odd as (2k2 + 2k) is an integer.
Example 3.2
Let r and s be rational numbers. Show that rs is rational.
Answer:
Since r and s are rational, we can write them as
r = p1 / q1 and s = p2 / q2 ; where p1, q1, p2, q2 are integers.
Now rs = (p1 p2) / (q1 q2). Here, (p1 p2) and (q1 q2) are integers, and hence, rs
is rational.

23
©2020, The Open University of Sri Lanka
Unit I: Logic

3.2 Indirect Proof


There are two major forms of indirect proof; indirect proof by contrapositive
and proof by contradiction.

Proof by Contrapositive

Here by assuming the conclusion Q to be false, we show that the premise P


is false as well through a series of logical steps. It follows from the fact that
(P  Q) is a logical consequence of ( Q   P) and vice versa [Activity
5, Session 1].
Example 3.3
Let n be an integer. If n2 is even, then n is even.
Answer:
Suppose that n is not even. Then, from example 3.1, n2 is not even, which
completes the proof.

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.

3.3 Proof by Cases


Sometimes it is easy for us to prove a theorem by splitting it in to several
cases and proving these cases.
Example 3.6
Show that │x2│= │x│2 for any real x.
Answer:
Let us split the proof in to cases; x ≥ 0 and x < 0.

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.

3.4 Proof by Induction


In this section we shall introduce a very powerful method of proof called
mathematical induction.

The Principle of Mathematical Induction


Let A be a set of natural numbers with the property that
1. 0  A, and
2. For each natural number n, if {0, 1, …, n}  A, then n + 1  A.
Then A = , the set of natural numbers.
In practice, mathematical induction is used to prove assertions of the form:
“Property P(n) is true for every natural number n.”
The following procedure can be used in doing so.
1. In the basis step, we show that the property P(0) is true.
2. Next, we assume that (Induction hypothesis) for some fixed but arbitrary
k ≥ 0, P(k) is true for each natural number 0, 1, …, k.
3. In the last step (Induction step), we show using the induction hypothesis,
that P(k + 1) is true. Then by the induction principle, P(n) is true for
every natural number n.
Example 3.7
Show that 1 + 2 + … + n = n(n + 1)/2 for n ≥ 0.
Answer: Basis step
Let n = 0. Then the left hand side is zero as nothing to add. The right hand
side is equal to 0(0 + 1)/2, which is zero. Therefore, the given result is true
for n = 0.
Induction hypothesis
Assume that for some k ≥ 0, 1 + 2 + … + k = k(k + 1)/2.
Inductive step
Now
1 + 2 + … + (k + 1) = 1 + 2 + … + k + (k + 1)
= k(k + 1)/2 + (k + 1) [Inductive hypothesis]
= [k(k + 1) + 2(k + 1)]/2
= (k + 1)(k + 2)/2
That is, the given result is true for (k + 1). Therefore, the result is true for
any natural n.

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

Using an appropriate method, prove the followings:


1. 1 + 3 + 5 + + … + (2n - 1) = n2 for any natural number n.
2. n2 is even if n is even.
3. 1.2 + 2.3 + 3.4 + n(n + 1) = n(n + 1)(n + 2)/3 for any positive integer n.
4. If r and s are rational, then (r + s) is rational.

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

Answers to the Activities

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 pq (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 pq qr (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

((p  q)  (q  r))  (p  (q  r))


T
T
T
T
T
F
T
T

29
©2020, The Open University of Sri Lanka
Unit I: Logic

((p  q)  (q  r))  (p  (q  r)) is not a tautology, nor a contradiction.


iii.
p q pq (p  q)  p
T T T T
T F T T
F T T F
F F F T
(p  q)  p is not a tautology, nor a contradiction.
iv.
p q pq pq (p  q)  (p  q)
T T T T T
T F T F T
F T T F T
F F F F T
(p  q)  (p  q) is a tautology.

2. i.
p q r pq 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)
=Tq (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 PQ (P  Q)  Q  R RP
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): qp
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): pq
(2): qr
Conclusion: rp

q r pq 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

1. i. (x)(y)LOVE(x, y), where the predicate LOVE(x, y) means “x loves y.”


ii. (x)(y)LOVE(y, x), where the predicate LOVE(x, y) means “x loves y.”
iii. (x)(PARENT(x)   BUY(x)), where the predicates PARENT(x) and BUY(x)
mean “x is a parent” and “x buys a dangerous toy for their kids” respectively.
iv. (x)(PATIENT(x)  (y)(DOCTOR(y)  LIKES(x, y))), where the predicates
PATIENT(x), DOCTOR(x) and LIKES(x, y) mean “x is a patient”, “x is a doctor”
and “x likes y” respectively.
2. i. Every computer contains at least one BIOS chip.
ii. Every number has a successor.
iii. Every number has one and only one successor.
3. i. For x = 1,
P(a, g(x))  Q(x, a)
= P(2, g(1))  Q(1, 2)
= P(2, 1)  F
=FF
=T
For x = 2,
P(a, g(x))  Q(x, a)
= P(2, g(2))  Q(2, 2)
= P(2, 2)  F
=TF
=F
Therefore, (x)(P(a, g(x))  Q(x, a)) is false.
ii. For x = 1,
(P(x)  Q(a, g(x)))  R(x, x)
= (P(1)  Q(1, g(1)))  R(1, 1)
= (T  Q(1, 2))  F
=TF
=F
Therefore, (x)((P(x)  Q(a, g(x)))  R(x, x)) is false.

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

You might also like