Lecture TWO LOGIC
Lecture TWO LOGIC
Definition
Logic is the formal reasoning study which is mainly on statements or
proposition. It acts as a collections of rules which govern structure and
presentation of a mathematical proof.
Definition
It is simply defined as a sentence (declarative statement) which is either
true or false but not both. The following are examples of a propositional
logic
Earth is the only planet in the universe that contain life
Discrete mathematics is among of the courses offered to ICT and
data management students.
While the following is not an example of propositional logic,
x +4=6 (1)
Note
A propositional logic is typically expressed as a declarative sentence.They
are the building block of any logical theory.
Connectives AND/OR
These are word or symbols used to connect sentence in grammatically
acceptable way. In other words, these are boolean statement which are
used to join propositions and obtain a single proposition.
Conjunctions
Let p and q be two propositions. The conjunction of p and q, denoted
p ∧ q is the proposition p and q.
Disjunction
Let p and q be two propositions. The disjunction of p or q, denoted p ∨ q
is the proposition p or q.
p q p∧q
T T T
T F F
F T F
F F F
when the variable x is less than 10 and the variable y is greater than 4 is
true. Otherwise is false.
Definition
Suppose p and q are propositions, then the new proposition p ∨ q is
defined by the following truth table
p q p∨q
T T T
T F T
F T T
F F F
Mr. Michael Peter Logic 9 / 32
Propositional logic cont· · ·
Note
The inclusive-or of propositions p and q is true if p or q is true and false
otherwise. That is
(
T : provided p or q or both is true
p∨q = (7)
F : otherwise
when the variable x is less than 10 is true or the variable y is greater than
4 is true or both. Otherwise is false.
Mr. Michael Peter Logic 10 / 32
Propositional logic cont· · ·
Negation
The negation of p is denoted ¬p, means (not p). Truth value of the
proposition ¬p is defined by the truth table
p ¬p
T F
F T
Mr. Michael Peter Logic 11 / 32
Propositional logic cont· · ·
p∨q∧r (10)
is true or false.
Mr. Michael Peter Logic 12 / 32
Propositional logic cont· · ·
Definition
If p and q are propositions, the proposition
if p then q (11)
p =⇒ q. (12)
p q (p =⇒ q)
T T T
T F F
F T T
F F T
For example:
p ∨ q =⇒ ¬r (13)
is interpreted as
(p ∨ q) =⇒ (¬r ) (14)
Assuming that p is true, q is false, and r true, find the truth value of each
propositions
p ∧ q =⇒ r (15)
p ∨ q =⇒ ¬r (16)
p ∧ (q =⇒ r ) (17)
p =⇒ (q =⇒ r ) (18)
Sufficient condition
This is the condition that sufficies to guarantee a particular outcome.
Example
p ⇐⇒ q (20)
p q (p ⇐⇒ q)
T T T
T F F
F T F
F F T
Note.
p ⇐⇒ q = (p =⇒ q) ∧ (q =⇒ p) (21)
Two propositions p and q are said to be equivalent is and only if they have
the same truth value. For example
p =⇒ q ≡ ¬p ∨ q (22)
¬ (p ∨ q) ≡ ¬p ∧ ¬q (23)
¬ (p ∧ q) ≡ ¬p ∨ ¬q (24)
Exercise
Deductive reasoning
This is the process of drawing conclusion from a sequence of propositions.
For example:-
The given propositions, such as XXX are called hypothesis or premises and
the propositions that follows from the hypothesis is called conclusion.
p1 , p2 , · · · , pn therefore q (27)
The argument is valid provided that if p1 and p1 and · · · and pn , are all
true then q must be true; otherwise the argument is invalid or fallacy.
p =⇒ q
p
q
In the previous section of this lecture we have seen the roles of logic which
are incapable in describing most of the programming statements. For
example.
p : n is an integer. (28)
Definition
A predicate is a statement involving variables which are defined in a
particular domain. Sometimes is known as a propositional function.
Universal quantifiers
Definition. Let P be a propositional function with domain of discourse D.
The statement
The symbol ∀ means ”for every ”. Thus the statement for every x, P(x)
may be written as ∀ x P(x)
∀x x 2 ≥ 0 ; x ∈ D = R
(30)
The statement is true because, for every real number x, it is true that the
square of x is positive or zero. Also is false if for at least one x in the
domain of discourse, the proposition P(x) is false.
∀ x P(x) (31)
{d1 , · · · , dn }. (32)
∀ x P(x) (33)
is true or false
for i=1 to n
if (¬p(di ))
return false.
return true
The for loop examines the number di of the domain of discourse one by
one. If it finds the value di for which P(di ) is false, the condition ¬P(di )
in the if statement is true; So the code returns false and terminates. In
this case, di is a counterexample
Existential quantifiers
Definition. Let P be a propositional function with domain of discourse D.
The statement
∃ x P(x). (34)
The statement ∃ x P(x) is true if P(x) is true for at least one x in D. The
statement
∃x P(x) (35)
∃x P(x) (36)