Logic
Logic
Lecture 1 : Logic
Contents
Definitions
Operators
Predicates and Quantifiers
Methods of Proof
Definitions
Proposition
A proposition is a mathematically precise statement that is
either true or false, but not both.
Examples
Paradox
A paradox is a statement that cannot be assigned a truth value.
Example 1
“This statement is false”
If true, than false and if false, then true.
Example 2
A classic example of a paradox is the barber paradox. It states:
“The barber shaves every man in town who does not shave himself.”
If the barber shaves himself, then this means the barber does not shave
himself and if he does not shave himself then he must shave himself. Neither
is possible and so it is a paradox.
Definitions
Definition
A compound proposition is a statement obtained by combining propositions with
logical operators.
operators
1. ∧ conjunction (and)
Truth Table :
p q p∧q q∧p
T T T T
T F F F
F T F F
F F F F
2. ∨ disjunction (or)
Truth Table:
p q p∨q q∨p
T T T T
T F T T
F T T T
F F F F
The disjunction operator returns T when at least one of the two propositions p or q is true.
The operator ∨ is commutative.
Operators
Remark
More than two propositions can be joined using logical operators.
In this instances, it is important to be careful about how they are grouped.
Example
2+1=4 ∧ 2+2=5 ∨ 5 − 2 = 3 is true
2 + 1 = 4 ∧ ( 2 + 2 = 5 ∨ 5 − 2 = 3 ) is false
Operators
3. ¬ negation (not)
Truth Table:
p ¬p
T F
F T
Operators
4. ⊕ exclusive (xor)
Truth Table:
p q p⊕q
T T F
T F T
F T T
F F F
The statement is true if and only if exactly one of the statements is true.
Operators
5. Implication ( ⟹)
1) p implies q
2) If p, then q
Operators
Truth table
p q ¬p p⟹q
(¬p ∨ q)
T T F T
T F F F
F T T T
F F T T
The converse of p ⟹ q is q ⟹ p.
The contrapositive of p ⟹ q is ¬q ⟹ ¬p
Operators
6. Equivalence (⟺ )
p ⟺ q means (p ⟹ q and q ⟹ p).
Truth table
p q p⟹q q⟹p p⟺q
T T T T T
T F F T F
F T T F F
F F T T T
Equivalent Propositions
Two propositions are equivalent if they have identical truth tables.
Properties
1) (p ∧ q) ⟺ (q ∧ p)
2) (p ∨ q) ⟺ (q ∨ p)
3) (p ∧ q) ∧ r ⟺ p ∧ (q ∧ r)
4) (p ∨ q) ∨ r ⟺ p ∨ (q ∨ r)
5) p ∧(q ∨ r) ⟺ (p ∧ q) ∨(p ∧r)
6) p ∨ (q ∧ r) ⟺ (p ∨ q) ∧ (p ∨ r)
7) ¬(¬ p) ⟺ p
8) ¬(p ∧ q) ⟺ (¬ p) ∨(¬ q)
9) ¬(p ∨ q) ⟺ (¬ p) ∧ (¬ q)
10) (p ⟹ q) ⟺ (¬q ⟹ ¬p)
11) ((p ⟹ q) ∧ (q ⟹ r)) ⟹ (p ⟹r)
12) ((p ⟺ q) ∧ (q ⟺ r)) ⟹ (p ⟺ r)
An amizing exercise
Definiton
A predicate is a statement that contains variables. A predicate may be true or
false depending on the values of these variables.
Predicates and Quantifiers
Universal quantifier
∀ 𝑥 (for all x), 𝑃(𝑥)
means that the predicate 𝑃(𝑥) is true for all possible values of 𝑥.
Predicates and Quantifiers
Existential quantifier
∃ 𝑥 (there exists 𝑥), 𝑃(𝑥)
Means that there exists an 𝑥 where 𝑃 𝑥 is true.
Sometimes, we will use also
∃! 𝑥, 𝑃(𝑥)
It means that there exists a unique 𝑥 where 𝑃(𝑥) is true.
Predicates and Quantifiers
¬ ∀ 𝑥, 𝑃 𝑥 ⟺ ∃ 𝑥, ¬𝑃 𝑥
¬ ∃ 𝑥, 𝑃 𝑥 ⟺ ∀ 𝑥, ¬𝑃 𝑥
Predicates and Quantifiers
Example 1
The statement
∀ 𝑥 ∈ ℤ, 𝑥2 = 5 ⟹ 𝑥 = 2
is true.
Example 2
The statement
∃ 𝑥 ∈ ℝ, 𝑥 2 = 2
is true, but the statement
∃ 𝑥 ∈ ℤ, 𝑥 2 = 2
is false.
Predicates and Quantifiers
Example 3
Some statement involve several quantifiers.
The statement
∀ 𝑥 ∈ ℝ, ∃ 𝑦 ∈ ℝ, 𝑦 > 𝑥
means that for all 𝑥 ∈ ℝ, there exists 𝑦 ∈ ℝ such that 𝑦 > 𝑥.
This statement is true.
The order of the quantifiers is very important.
The statement
∃ 𝑦 ∈ ℝ, ∀ 𝑥 ∈ ℝ, 𝑦 > 𝑥
is false.
Predicates and Quantifiers
Examples
Statement : ∀ 𝑥 ∈ ℝ, 2𝑥 < 3
Negation : ∃ 𝑥 ∈ ℝ, 2𝑥 ≥ 3
Statement :∃ 𝑥 ∈ ℝ, 2𝑥 = 256
Negation :∀𝑥 ∈ ℝ, 2𝑥 ≠ 256
Statement :∃ 𝑦 ∈ ℝ, ∀ 𝑥 ∈ ℝ, 𝑦 > 𝑥
Negation : ∀ 𝑦 ∈ ℝ, ∃ 𝑥 ∈ ℝ, 𝑦 ≤ 𝑥
Methods of proof
Direct Proof
𝐴⟹𝐵
Example
Let 𝑎, 𝑏 ∈ ℤ. Show that
𝑎+𝑏 2= 0⟹𝑎 =𝑏 = 0
Proof by contrapositive
We show ¬𝐵 ⟹ ¬𝐴 instead of 𝐴 ⟹ 𝐵
Example
Let 𝑛 ∈ ℕ∗ .
Show that
𝑛2 − 1 is not divisible by 8 ⟹ 𝑛 is even
Methods of proof
Proof by contradiction
To show that 𝑝 is true, we suppose that 𝑝 is false and than ¬𝑝 is true.
We show that ¬𝑝 ⟹ ¬𝑞, where 𝑞 is true.
So q ⟹ 𝑝 is true.
As 𝑞 is true then 𝑝 is true.
Example
Show that 0 does not admit an inverse in ℝ.
Methods of proof
4. By induction
Let 𝑃(𝑛) be a logical statement for each 𝑛 ∈ ℕ. The principle of mathematical
induction states that 𝑃(𝑛) is true all 𝑛 ∈ ℕ if :
1. 𝑃(1) is true, and
2. 𝑃(𝑛) → 𝑃(𝑛 + 1) 𝑓𝑜𝑟 𝑎𝑙𝑙 𝑛 ∈ ℕ
Example
Show that for all 𝑛 ∈ ℕ∗ , we have 2𝑛−1 ≤ 𝑛! ≤ 𝑛𝑛 .
Methods of proof
5. By giving a counter example
To show that a proposition 𝑝 is false, we must show that ¬𝑝 is true.
Example 1
Let 𝑓: ℝ ⟶ ℝ a function defined by 𝑓 𝑥 = 𝑥 2 .
Show that the proposition :
∀ 𝑥, 𝑦 ∈ ℝ, 𝑓 𝑥 = 𝑓 𝑦 ⟹ 𝑥 = 𝑦
is false.
Example 2
Show that the proposition
∀ 𝑦 ∈ ℝ, ∃𝑥 ∈ ℝ, 𝑓(𝑥) = 𝑦
is false.