M112 Topic 2

Download as pdf or txt
Download as pdf or txt
You are on page 1of 14

Mathematical Logic

1.1 Introduction
• Mathematical logic is the analytical theory of reasoning that aim to systemize and codify principles of
valid reasoning.
• Mathematical logic is used to evaluate correctness of statements.
• The principles of logic are valuable to problem analysis, programming and logic design.
1.2 Statements (Propositions)
• A statement/ proposition is a declarative sentence which is either true of false but not both.
• The truthfulness or falsity of a statement is called its truth value denoted by T and F 𝒐𝒓 ⊥
respectively.
• A simple statement is an atomic/ primary statement that need not use logical connectives.
• A compound statement is formed from combining atomic/ simple propositions through the use of logical
connectives.
Examples
I. Socrates is mortal
II. 𝑥 is a pig
III. 2 is greater than 5
IV. May God bless you!
V. You must complete the work today.
VI. 9 is a prime number
From the above examples, I,III, and VI are propositions/statements, the rest are not.
1.3 Laws of Formal Logic
1.3.1 Law of \Contradiction
• The same statement cannot be both affirmed and denied precisely of the same subject.
• i.e a statement say P cannot be both true and false.
AsambaSam@KSU Lecture Notes 1
Mathematical Logic
1.4 Logical Connectives
We use logical connectives to connect several simple statements into a single compound.
The following are the most basic and fundamental connectives that we shall discuss:
 Negation
 Conjunction
 Disjunction
 Conditional/ implication
 Bi-conditional
 Exclusive OR
 NAND
 NOR
1.4.1 Negation
• If 𝐴 is a statement, then the negation of 𝐴 (¬𝐴) is also a statement.
• ¬𝐴 is read as ‘not 𝐴’
• Rule: if 𝐴 is true, then ¬𝐴 is false and if 𝐴 is false, then ¬𝐴 is true.
• Truth table:
𝐴 ¬𝑨
T F
F T

AsambaSam@KSU Lecture Notes 2


Mathematical Logic
1.4.2 Conjunction
• The logical connective ‘And’ is used for conjunction
• The conjunction of two statements 𝐴 and 𝐵 is a statement denoted as 𝑨 ∧ 𝑩
• Rule: 𝐴 ∧ 𝐵 is true if both 𝐴 and 𝐵 are true, otherwise false.
• Truth table:
𝑨 𝑩 𝐴∧𝐵
T T T
T F F
F T F
F F F
1.4.3 Disjunction
• The logical connective ‘Or’ is used for disjunction
• The conjunction of two statements 𝐴 and 𝐵 is a statement denoted as 𝑨 ∨ 𝑩
• Rule: 𝐴 ∨ 𝐵 is false when both 𝐴 and 𝐵 are false, otherwise true.

𝑨 𝑩 𝑨∨𝑩
T T T
T F T
F T T
F F F
AsambaSam@KSU Lecture Notes 3
Mathematical Logic
1.4.4 Conditional/ Implication
• 𝐴 ⇒ 𝐵 𝑜𝑟 (𝐴 → 𝐵) is a conditional statement which can be put in any of the forms below:
i) If 𝐴, then 𝐵
ii) 𝐴 only if 𝐵
iii) 𝐴 implies 𝐵
iv) 𝐵 if 𝐴
• In the implication 𝐴 ⇒ 𝐵, 𝐴 is called the hypothesis/ antecedent and 𝐵 is the conclusion/consequent.
• Rule: 𝐴 ⇒ 𝐵 is false only when the hypothesis (𝐴) is true and the conclusion (𝐵) is false, otherwise true.

𝑨 𝑩 𝑨⇒𝑩
T T T

T F F
F T T
F F T

AsambaSam@KSU Lecture Notes 4


Mathematical Logic
1.4.5 Bi-Conditional/ double implication
• The statement 𝐴 ⇔ 𝐵 is a bi-conditional statement which can be put in any of the following forms:
• i) 𝐴 if and only if 𝐵
• Ii) 𝐴 is necessary and sufficient of 𝐵
• Iii) 𝐴 is necessary and sufficient for 𝐵
• Iv) 𝐴 implies and is implied by 𝐵
• 𝐴 ⇔ 𝐵 is defined as 𝐴 ⇔ 𝐵 ≡ 𝐴 ⇒ 𝐵 ∧ 𝐵 ⇒ 𝐴
• Rule: 𝐴 ⇔ 𝐵 is true only when both 𝐴 and 𝐵 have identical truth values, otherwise false.
• Truth table:

𝑨 𝑩 𝐴⇔𝐵
T T T
T F F
F T F
F F T

Exercise 1.4.6: (MUST)


write down the rules for the following logical connectives:
a) EXCLUSIVE OR b) NAND c) NOR
AsambaSam@KSU Lecture Notes 5
Mathematical Logic

Connective Logical name Denotation Other forms Rule


Negation NOT ¬ 𝑜𝑟 ~ ¬𝑃 If P is True, then ¬ 𝑃 and
• not P if P is False then ¬ 𝑃 is
true.

Conjunction AND ∧ P∧Q (P∧Q) is true if both P and


• P and Q Q are True, otherwise
False.

Disjunction OR ∨ P ∨Q (P ∨Q) is True if either P or


• P or Q Q are true and False when
both P and Q are false.

Implication/ Conditional Implies → 𝑜𝑟 ⇒ P⇒Q P⇒Q is False if P


• If P then Q (hypothesis/antecedent)
• P only if Q is True and Q
• P implies Q (conclusion/consequent)
• Q if P. is False, otherwise True.

Bi-conditional/ If and only if ↔ or⇔ P⇔Q P⇔Q is True ONLY when


equivalence/double • P if and only if Q both P and Q have
implication • P is necessary and identical values,
sufficient of/for Q otherwise False.
• P implies and is
implied by Q.

AsambaSam@KSU Lecture Notes 6


Mathematical Logic
1.5 Converse, Inverse and Contrapositive
Let us consider the following example:
‘If you put on your socks then you can wear the shoes’
P: Put on your socks Q: Wear the shoes.
So the statement can be represented as: P⇒Q
1.5.1 Converse
• The converse of the implication P⇒Q is given as Q⇒ P.
• The converse of the above example becomes: ‘If you wear the shoes then you have put on your socks’
1.5.2 Inverse
• The inverse of the implication P⇒Q is given as ¬P⇒ ¬Q.
• The inverse of the statement in our example becomes: ‘If you don’t put on your socks, then you don’t
wear the shoes.’
1.5.3 Contrapositive
• The contra-positive statement of the conditional P⇒Q is given as ¬Q ⇒ ¬P
• The contrapositive of the statement in our example becomes: ‘If you do not wear the shoes, then you do
not put on your socks.’

AsambaSam@KSU Lecture Notes 7


Mathematical Logic
1.6 Tautology, Contradiction and Satisfiable statements
1.6.1 Tautology
• A tautology is a composite statement whose truth values are always true irrespective of the truth values
of its atomic statements.
• The last column of a tautology has only T as the truth value.
• e.g 𝑃 ∧ (𝑃 → 𝑄) → 𝑄 is a tautology. (exercise : verify)
1.6.2 Contradiction
• A contradiction is a composite statement whose truth values are always false irrespective of the truth
values of its atomic statements.
• The last column of a contradiction has only F as the truth value.
• e.g ¬ 𝑃 → (𝑄 → (𝑃 ∧ 𝑄)) is a contradiction. (exercise : verify)
1.6.3 Satisfiable
• A satisfiable statement is a compound statement whose truth values are sometimes true and sometimes
false irrespective of the truth values of its atomic statements.
• e.g 𝑃 → 𝑄 → 𝑄 → 𝑃 . (exercise : verify)

AsambaSam@KSU Lecture Notes 8


1. Mathematical Logic (contd)
1.7 Worked Examples
1.7.1 example
(a) Find the negation of 𝑃 ⇒ 𝑄.
(b) Find the negation of the statement ‘If cows are crows then crows are four legged.’
(c) Find the negation of 𝑃 ⇔ 𝑄.
Solution
(a) 𝑃 ⇒ 𝑄 is equivalent to ¬𝑃 ∨ 𝑄 . So ¬ 𝑃 ⇒ 𝑄 ≡ ¬ ¬𝑃 ∨ 𝑄
≡ ¬(¬𝑃) ∧ (¬𝑄) (by De-Morgan’s law)
≡ 𝑃 ∧ ¬𝑄
Thus negation of 𝑃 ⇒ 𝑄 is 𝑃 ∧ ¬𝑄 .

(b) Let P: Cows are crows Q: Crows are four legged


Thus the statement ‘If cows are crows then crows are four legged’≡ 𝑃 ⇒ 𝑄. Since the negation of 𝑃 ⇒ 𝑄 is
𝑃 ∧ ¬𝑄 the negation of this statement therefore becomes: ‘Cows are crows and crows are not four legged.’

(c )

𝑃 ⇔ 𝑄 ≡ (𝑃 ⇒ 𝑄) ∧ (𝑄 ⇒ 𝑃)
So, ¬(𝑃 ⇔ 𝑄) ≡ ¬[ 𝑃 ⇒ 𝑄 ∧ 𝑄 ⇒ 𝑃 ]
≡ ¬(𝑃 ⇒ 𝑄) ∨ (𝑄 ⇒ 𝑃) (by De-Morgan’s law)
≡ 𝑃 ∧ ¬𝑄 ∨ 𝑄 ∧ ¬𝑃 (by negation of implications)
Hence negation of 𝑃 ⇔ 𝑄 is 𝑃 ∧ ¬𝑄 ∨ 𝑄 ∧ ¬𝑃 .
AsambaSam@KSU Lecture Notes 9
Mathematical Logic

1.7.2 example
By use of a truth table show that 𝑃 ⇒ (𝑄 ⇒ 𝑅) ≡ (𝑃 ∧ 𝑄) ⇒ 𝑅
Solution:
number of rows: 23 = 8

P Q R 𝑄⇒𝑅 𝑃 ⇒ (𝑄 ⇒ 𝑅) 𝑃∧𝑄 (𝑃 ∧ 𝑄) ⇒ 𝑅

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

AsambaSam@KSU Lecture Notes 10


1. Mathematical Logic (contd)
1.7.3 example
Show that the following statements are equivalent:
1. Good food is not cheap
2. Cheap food is not good
Solution
Let P: Food is good Q: Food is cheap
So, statement 1 ≡ 𝑃 ⇒ ¬𝑄; and statement 2≡ 𝑄 ⇒ ¬𝑃
Now, to show they are equivalent we use the following truth table:

P Q ¬𝑃 ¬𝑄 𝑃 ⇒ ¬𝑄 𝑄 ⇒ ¬𝑃

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

AsambaSam@KSU Lecture Notes 11


1. Mathematical Logic (contd)
1.7.4 Exercise
1. Construct truth tables for the following propositions
a) ¬𝑃 ⇒ 𝑅 ∧ 𝑄 ⇔ 𝑃
b) 𝑃 ⇒ 𝑃 ⇒ 𝑄 ∧ ¬ ¬𝑄 ∨ ¬𝑃
2. Show that 𝑃 ⇒ 𝑄 ∧ 𝑅 ⇒ 𝑄 ≡ 𝑃 ∨ 𝑅 ⇒ 𝑄
3. Write the converse, inverse and contrapositive of the following statements by indicating the conditional
statement
a) If cos 𝑥 = 1 then 𝑥 = 0.
b) Two sets are similar if they contain equal number of elements.
c) In a binary system 1 + 1 = 11.
4. Show by truth table that the following statements are logically equivalent:
Statement 1: Rich men are unhappy
Statement 2: Men are unhappy or poor. (let ‘poor’ indicate ‘not rich’)
5. Find the negation of the statement:
‘He is rich and unhappy.’

AsambaSam@KSU Lecture Notes 12


Mathematical Logic
1.8 Predicate logic
This area of logic deals with quantified statements .
Denition 1.8.1 A k-place predicate 𝑃(𝑥1 ; ∶∶∶ ; 𝑥𝑘 ) is a sentence involving the variables 𝑥1 ; : : : ; 𝑥𝑘
to which a truth value can be assigned under each assignment of values to 𝑥1 ; : : : ; 𝑥𝑘 from a nonempty set,
called a universe of discourses (UD).
• Predicates use quantifiers. There are two major quantifiers:
i. Universal quantifier: This is the quantifier ‘all’. It is denoted by ∀ read as : for all or for each or for
every.
ii. Existential quantifier: This is the quantifier ‘some’. It is denoted by ∃ read as : for some or there exists
or for at least one.
1.8.2 Example
Consider the sentence ‘All apples are green’
Let x be an apple. Then the sentense can be written as : ‘For every x, x is green’
Symbolically ∀ 𝑥, 𝑃(𝑥): 𝑥 is green.
Here 𝑃(𝑥) is a predicate. It states the property the object 𝑥 has. 𝑃(𝑥) is not a proposition but just an
expression, but it is transformed into a proposition when values of x are assigned from universe of discourses
(UD) in this case this is the set of all apples.
1.8.3 Example
Rewrite the sentence ‘Some chalkboards are black’, symbolically.
Choose the set of all chalkboards as the UD. Let x be an arbitrary chalkboard. Then the given sentence can
be written as: ‘There exists an x such that x is black’.
Hence, ∃ 𝑥: 𝑥 is black.
AsambaSam@KSU Lecture Notes 13
Mathematical Logic
1.8.4 Exercise
1. Rewrite each of the following sentences symbolically, where P(x): x is a 16-bit machine, Q(x): x uses
the ASCII character set, and the UD = set of all computers.
a) There is a computer that is a 16-bit machine and uses the ASCII character set as well.
b) We can find a 16-bit computer that does not use the ASCII character set.
c) We can find a computer that is either a 16-bit machine or does not use the ASCII character set.
d) There exists a computer that is neither a 16-bit machine nor uses the ASCII character set.

2. Rewrite each of the following sentence symbolically, where the UD consists of real numbers.
a) The product of any two real numbers x and y is positive.
b) There are real numbers x and y such that x = 2y.
c) For each real number x, there is some real number y such that x .y = x.
d) There is a real number x such that x + y = y for every real number y.
1.8.5 Uniqueness Quantifier
• A third useful quantifier is the uniqueness quantifier .
• It is denoted by ∃! read as ‘there exists a unique’ or ‘ there exists exactly one’
• Example
• The proposition ∃! ∶ 𝑃(𝑥) means There exists a unique (meaning exactly one) x such that
P(x).

AsambaSam@KSU Lecture Notes 14

You might also like