CHAPTER I
The Foundations: Logic and Proofs
1.1 Propositional Logic : The rules of logic give precise meaning to mathematical statements.
It has numerous applications in computer science. The rules are used in the design of computer
circuits, the construction of computer program and in many ways, verification and correctness
of programs.
Proposition: A proposition is a declarative sentence that is either true or false, but not both.
Example
1+1 = 2 (True)
2+2 = 3 (False)
Riyadh is capital of Saudi (True)
The following statements are not propositions,
x+1 = 2
x+y = z
Note: The first two may be made propositions if we assign values.
Letters can be used for denoting propositional variables (or statement variables) p,q,r,s ……
The tuth values of the propositions, true denoted by (T) and false denoted by (F).
Logical operators: Negation , Conjunction, Disjunction,Conditional,Biconditional and
Exclusive OR.
Definition: Let p be a proposition. The negation of p, denoted by ( ¬ p) is the opposite of the
truth values of p.
Example 1: Find the negation of the proposition.
p: Today is Friday
¬ p : Today is not Friday
p ( ¬ p)
T F
F T
Definition : Let p and q be propositions. The conjunction of p and q denoted by p ∧ q is true
when both p and q are true and is false otherwise.
Example:
p: Today is Friday ,
q: It is raining today
(p ∧ q) : Today is Friday and it is raining today,
p q p∧ q
T T T
T F F
F T F
F F F
Definition: Let p and q be propositions. The disconjunction of p and q denoted by p ∨ q is false
when both p and q are false and is true otherwise.
Example: p: Today is Friday,
q: It is raining today,
(p ∨ q): Today is Friday or it is raining today
p q p∨ q
T T T
T F T
F T T
F F F
Definition: Let p and q be propositions. The conditional statement p → q is false when p is
true and q is false and is true otherwise. (p → q is if p then q). In the conditional statement
p → q, p is called the hypothesis (or antecedent or premise) and q is called the conclusion (or
consequence).
p q p→q
T T T
T F F
F T T
F F T
Example:
p: Get 100% in the final,
q: You will get A,
(p → q): If you get 100% in the final then you will get A.
Example: Let p be the statement "Maria learns discrete mathematics" and q the statement
"Maria will find a good job." Express the statement p → q as a statement in English.
Solution:
p: Maria learns discrete mathematics,
q: Maria will find a good job,
(p → q): If Maria learns discrete mathematics then she will find a good job.
Definition: Let p and q be propositions. The biconditional statement p ↔ q is true when p
and q have same truth values and is false otherwise. (p ↔ q is p iff q). Biconditional
statements are also called bi-implications.
p q p↔q
T T T
T F F
F T F
F F T
Example: Let p be the statement "You can take the flight" and let q be the statement "You buy
a ticket." Then p ↔ q is the statement.
Solution:
p: You can take the flight,
q: You can buy the ticket,
(p ↔ q) :You can take a flight iff you can buy a ticket.
Definition: Let p and q be propositions. The exclusive OR of p and q denoted by p ⊕ q is a
proposition that is true when exactly one of p and q is true and is false otherwise.
p q p⊕q
T T F
T F T
F T T
F F F
Precedence of logic operators: ¬, ∧, ∨, →, ↔
p q ¬p ¬q p∧ q p∨ q p→q p↔q p⊕q
T T F F T T T T F
T F F T F T F F T
F T T F F T T F T
F F T T F F T T F
Example: Construct the truth table for the compound proposition
(p ∨ ¬ q) → (p ∧ q).
Solution:
p q ¬q p∨ ¬q p∧ q (p ∨ ¬ q) → (p ∧ q)
T T F T T T
T F T T F F
F T F F F T
F F T T F F
Example: Construct the truth table for the compound proposition
( p → q ) ∧ ( ¬ p → q)
Solution:
p q ¬p p →q ¬p→ q ( p → q ) ∧ ( ¬ p → q)
T T F T T T
T F F F T F
F T T T T T
F F T T F F
Example: Construct the truth table for the compound proposition
¬p ⊕ ¬q
Solution:
p q ¬p ¬q ¬p ⊕ ¬q
T T F F F
T F F T T
F T T F T
F F T T F
Exercises
1. How many rows appear in a truth table for each of these compound propositions?
a) (q → ¬ p) ∨ ( ¬ p → ¬ q)
b) (p v ¬ t) ∧ (p ∨ ¬ s)
c) (p → r) ∨ ( ¬ s → ¬ t) ∨ ( ¬ u → v)
d) (p ∧ r ∧ s) ∨ (q ∧ t) ∨ (r ∧ ¬ t)
2. Construct a truth table for each of these compound propositions.
a) p → ¬ p
b) p ↔ ¬ p
c) p ⊕ (p ∨ q)
d) (p ∧ q) → (p ∨ q)
e) (q → ¬ p) ↔ (p ↔ q)
f) (p ↔ q) ⊕ (p ↔ ¬ q)
3. Construct a truth table for each of these compound propositions.
a) p ⊕ p
b) p ⊕ ¬ p
c) p ⊕ ¬ q
d) ¬ p ⊕ ¬ q
e) (p ⊕ q) ∨ (p ⊕ ¬ q)
f) (p ⊕ q) ∧ (p ⊕ ¬ q)