Logic PDF
Logic PDF
University Of Baghdad
Course:-Discrete Structures
In this report we introduce the principles of logic that are essential for
problem solving in mathematics. The ability to reason using the principles of logic is key
to seek the truth which is our goal in mathematics.
Before we explore and study logic, let us start by spending some time motivating this
topic. Mathematicians reduce problems to the manipulation of symbols using a set of rules.
As an illustration, let us consider the following problem:
Example 1.1 Joe is 7 years older than Themba. Five years from now Joe will be twice
Themba’s age. How old are Joe and Themba?
Solution. To answer the above question, we reduce the problem using symbolic formula-
tion. We let Themba’s age be x . Then Joe’s age is x + 7. We are given that five years from
now Joe will be twice Themba’s age. In symbols, (x + 7) + 5 = 2( x + 5). Solving for x yields
x = 2. Therefore, Themba is 2 years old and Joe is 9.
Our objective is to reduce the process of mathematical reasoning, i.e., logic, to the
manipulation of symbols using a set of rules. The central concept of deductive logic
is the concept of argument form. An argument is a sequence of statements aimed at
demonstrating the truth of an assertion (a “claim”). Consider the following two arguments.
Argument 1. If x is a real number such that x < − 2 or x > 2, then x2 > 4. Therefore,
if x2 ≤ 4, then x ≥ −2 and x ≤ 2.
Argument 2. If it is raining or I am sick, then I stay at home. Therefore, if I do not
stay at home, then it is not raining and I am not sick.
Although the content of the above two arguments is very different, their logical form is
the same. To illustrate the logical form of these arguments, we use letters of the alphabet
(such as p, q and r) to represent the component sentences and the expression “not p” to
refer to the sentence “It is not the case that p.” Then the common logical form of both the
arguments above is as follows:
| {z> 4}.
p q r
Therefore, if x 2 ≤ 4, then x ≥ −2 and x ≤ 2.
| {z } | {z } | {z }
not r not p not q
Argument 2. If it is raining (p ) or I am sick ( q), then I stay at home (r ).
Therefore, if I do not stay at home (not r), then it is not raining (not p)
and I am not sick (not q ).
1
1.2 Statements
Every statement has a truth value, namely true (denoted by T) or false (denoted by
F ). We often use p, q and r to denote statements, or perhaps p1 , p2 , . . . , pn if there are
several statements involved. For example, we might write
We have seen that p and q are statements, where p has truth value T and q has truth
value F .
The possible truth values of a statement are often given in a table, called a truth table .
The truth values for two statements p and q are given in Figure 1.1. Since there are two
possible truth values for each of p and q, there are four possible combinations of truth values
for p and q. It is customary to consider the four combinations of truth values in the order
of TT, TF, FT, FF from top to bottom as shown in Figure 1.1.
p q
T T
T F
F T
F F
2
1.3 Negation
The negation of statement p has the opposite truth value from p : if p is true, then ∼ p is
false; if p is false, then ∼ p is true. The truth table for ∼ p (in terms of the possible truth
values of p) is given in Figure 1.2.
p ∼p
T F
F T
1.4 Conjunction
The conjunction p ∧ q is true only if both p and q are true; otherwise, p ∧ q is false. For
example, consider the statements
p: The integer 2 is even.
q : 4 is less than 3.
3
The conjunction of p and q , namely,
p ∧ q : The integer 2 is even and 4 is less than 3 .
is a false statement since q is false (even though p is true). The truth table for the conjunc-
tion of two statements is shown in Figure 1.3. (As before, we write the truth values for p
and q in the order of TT, TF, FT, FF from top to bottom in the table.) This truth table
describes precisely when p∧ q is true (or false).
p q p ∧q
T T T
T F F
F T F
F F F
1.5 Disjunction
p q p ∨q
T T T
T F T
F T T
F F F
4
1.6 The Implication
Of special importance to us will be a connective called the implication (also called the
conditional).
If p, then q.
p implies q.
q if p.
p only if q.
p is sufficient for q.
q is necessary for p.
p q p→q
T T T
T F F
F T T
F F T
Notice that the only situation for which the implication p → q is false is when p is true
and q is false. The truth table for p → q is actually a definition, but let us convince ourselves
with an example that the truth values in this truth table are indeed justified.
Example 1.3 Suppose your boss makes you the following promise:
“If you meet the month-end deadline, then you will get a bonus.”
Under what circumstances are you justified in saying that your boss spoke falsely?
Solution. The answer is: You do meet the month-end deadline and you do not get a
bonus. Your boss’s promise only says you will get a bonus if a certain condition (you meet
5
the month-end deadline) is met; it says nothing about what will happen if the condition is
not met. So if the condition is not met, your boss did not lie (your boss promised nothing
if you did not meet the month-end deadline); so your boss told the truth in this case. Are
you convinced? Good! If not, let us then check the truth and falseness of the implication
based on the various combinations of the truth values of the statements
The given statement can be written as p → q. Suppose first that p is true and q is true.
That is, you meet the month-end deadline and you do get a bonus. Did your boss tell the
truth? Yes, indeed. So if p and q are both true, then so too is p → q, which agrees with the
first row of the truth table of Figure 1.5.
Second, suppose that p is true and q is false. That is, you meet the month-end deadline
and you did not get a bonus. Then your boss did not do as he/she promised. What your
boss said was false, which agrees with the second row of the truth table of Figure 1.5.
Third, suppose that p is false and q is true. That is, you did not meet the month-end
deadline and you did get a bonus. Your boss (who was most generous) did not lie (your
boss promised nothing if you did not meet the month-end deadline); so he/she told the
truth. This agrees with the third row of the truth table of Figure 1.5.
Finally, suppose that p and q are both false. That is, you did not meet the month-end
deadline and you did not get a bonus. Your boss did not lie here either. Your boss only
promised you a bonus if you met the month-end deadline. So your boss told the truth. This
agrees with the fourth row of the truth table of Figure 1.5.
In summary, the implication p → q is false only when p is true and q is false. A conditional
(or implication) statement that is true by virtue of the fact that its hypothesis is false is
said to be vacuously true or true by default. Thus the statement: “If you meet the
month-end deadline, then you will get a bonus” is vacuously true if you do not meet the
month-end deadline!
Example 1.4 Write the converse, inverse and contrapositive of the statement in Exam-
ple 1.3.
6
Solution. Recall that the given statement can be written as p → q where p and q are the
statements
p : You meet the month-end deadline.
q : You get a bonus.
The converse of this implication is q → p, which is
q → p : If you get a bonus, then you have met the month-end deadline .
Example 1.5 Write the converse, inverse and contrapositive of the following statements:
“If today is Saturday, then I will go for a 10km run.”
Solution. Let p and q be the following statements:
p : Today is Saturday .
q : I will go for a 10km run.
Then the given statement can be written as p → q. The converse of this implication is
q → p, which is
q → p: If I go for a 10km run, then today is Saturday .
The symbols ∼, ∧, ∨ and → are sometimes referred to as logical connectives. From given
statements, we can use these logical connectives to form more intricate statements, called
compound statements.
For example, for given statements p and q, the conjunction p∧q is a compound statement.
For a slightly more complex example, consider the compound statement given by
((∼ p )∨ ∼ ( q ∧ r )) ∨ (∼ ( s ∧ (q ∨ ( ∼ t)))).
7
In compound statements, we avoid the use of many parentheses when no confusion
arises . We often omit the outer pair of parentheses in a compound statement. For example,
we write ∼ p rather than (∼ p). In expressions using the logical connectives ∼, ∧ , ∨ and
→, we adopt the following order of operation :
∼ performed first,
∧, ∨ performed second,
→ performed third.
For example,
∼ p ∧ q = (∼ p ) ∧ q.
As in ordinary algebra, however, the order of operation can be overridden by the use of
parentheses. Thus,
∼ (p ∨ q )
represents the negation of the disjunction of p and q. Notice that the symbols ∧ and ∨
are coequal in order of operation. Therefore an expression such as p ∧ q ∨ r is considered
ambiguous. It should be written as either
(p ∧ q ) ∨ r or p ∧ (q ∨ r)
.
Example 1.6 Write each of the following sentences symbolically, letting p and q be the
statements:
p : It is hot.
q : It is sunny.
(a) It is not hot and it is sunny.
(b) It is not hot and it is not sunny.
Solution. (a) ( ∼ p) ∧ q .
(b) (∼ p) ∧ (∼ q ).
Example 1.6 Construct the truth table for the compound statement
(p → q ) ∧ (q → p ).
Solution. Set up columns labelled p, q, p → q, q → p , and ( p → q )∧ ( q → p). Complete the
p and q columns with all four possible combinations of truth values for p and q (in the order
of TT, TF, FT, FF from top to bottom). Then use the truth tables for → (see Figure 1.5)
to fill in the p → q and q → p columns. Finally, using the truth table for ∧ (see Figure 1.3),
fill in the (p → q) ∧ ( q → p) column. The resulting truth table is given in Figure 1.6.
p q p →q q→p (p → q ) ∧ (q → p )
T T T T T
T F F T F
F T T F F
F F T T T
8
References
[2] Epp S. S., Discrete Mathematics with Applications (Third Edition). Thomson
Brooks/Cole (2004).
[3] Johnsonbaugh R., Discrete Mathematics (Fourth Edition). Prentice Hall, Inc., New
Jersey (1997).
[4] Malik D. S. and M. K. Sen, Discrete Mathematical Structures: Theory and Applications
Thomson Course Technology (2004).
10