Logics
Logics
Logic
• Logic is a tool to develop reasonable conclusions based on a given set
of data.
• Logic is the study of correct and incorrect reasoning.
• Logicians want to understand what makes good reasoning good and
what makes bad reasoning bad.
• The first logician was Aristotle
• logic we use and study these days—sometimes called “Modern Logic”
or “Contemporary Logic”
Exp:
• Mr. ABC is vegetarian
• There is nothing on menu that Mr. ABC can eat.
Logics in Computer Science
• The rules of logic give precise meaning to mathematical statements.
Proposition
• Facts
• True or False (Corresponds to 1 and 0 in digital circuits)
Proposition
Example 1:
Are given statements are proposition or not?
EXAMPLE 2:
Are given statements are proposition or not?
a) Steve has more than 100 GB free disk space on his laptop.
b) Mr. A blocks e-mails and texts from Mr. B
c) 7 · 11 · 13 = 999.
d) Ahmed rode his bicycle 100 miles on Sunday.
Compound Propositions
• A proposition formed from existing propositions using logical operators is
known as compound proposition.
• ¬ (not)
• ∧ (conjunction)
• ∨ (disjunction)
• → (implication)
• ⊕ (exclusive)
• ↔ (biconditional)
The Truth Table for the Negation of a Proposition
T F
F T
Propositional Conjunction
• The conjunction p ∧ q is true when both p and q are true and is false
otherwise.
• Note that in logic the word “but” sometimes is used instead of “and” in a
conjunction.
Truth Table for conjunction of two propositions
P q pΛq
T T T
T F F
F T F
F F F
Example
Solution:
“Tariq’s PC has more than 16 GB free hard disk space, and the processor
in Tariq’s PC runs faster than 1 GHz.”
conjunction
• Example
P= Today is Friday
q = "It is raining today”.
Find p Λ q ?
In which cases p Λ q will T and F ?
Conjuction
Example:
• Find p Λ q?
• In which cases p Λ q will True?
• In which cases p Λ q will false?
Review
Disjunction
• In logic, a disjunction is a compound sentence formed by using the word
or to join two simple sentences.
• The disjunction p ∨ q is false when both p and q are false and is true
otherwise.
Truth Table for the Disjunction of two Propositions
P q P∨q
T T T
F T T
T F T
F F F
Example
Solution:
“Tariq’s PC has more than 16 GB free hard disk space, or the processor in
Tariq’s PC runs faster than 1 GHz.”
Example
P= Today is Friday
q = It is raining today
Find p ∨ q ?
Find True and False cases of this example?
Implication (→)
• Let p and q be propositions. The conditional statement p → q is the proposition “if p,
then q.”
• The conditional statement p → q is false when p is true and q is false, and true
otherwise.
• In the conditional statement p → q, p is called the hypothesis and q is called the
conclusion (or consequence).
Or
P q p →q
T T T
T F F
F T T
F F T
Note that the statement p → q is true when both p and q are true and when p is false.
Example
• Let p be the statement “Ali learns discrete mathematics” and q the
statement “Ali will find a good job.” Express the statement p → q as a
statement in English.
Sol:
• “If Ali learns discrete mathematics, then he will find a good job.”
Example
P= Today is Friday
q = It is raining today
Find p → q?
Find True and False cases of this example?
Implication
Example:
a) If 1 + 1 = 2, then 2 + 2 = 5.
b) If 1 + 1 = 3, then 2 + 2 = 4.
c) If 1 + 1 = 3, then 2 + 2 = 5.
d) If monkeys can fly, then 1 + 1 = 3.
BICONDITIONALS
• Let p and q be propositions. The biconditional statement p ↔ q is the
proposition “p if and only if q.”
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.”
“You can take the flight if and only if you buy a ticket.”
Example
P= Today is Friday
q = It is raining today
Find p ↔ q?
Find True and False cases of this example?
Practice Task
Determine whether these biconditionals are true or false.
a) 2 + 2 = 4 if and only if 1 + 1 = 2.
b) 1 + 1 = 2 if and only if 2 + 3 = 4.
c) 1 + 1 = 3 if and only if monkeys can fly.
d) 0 > 1 if and only if 2 > 1.
Inclusive or & exclusive or
• A disjunction is true when at least one of the two propositions is true.
• “Students who have taken calculus or computer science can take this
class.”
• Here, we mean that students who have taken both calculus and computer
science can take the class, as well as the students who have taken only one
of the two subjects. (inclusive or)
Cont…
• We can use exclusive or:
• “Students who have taken calculus or computer science, but not both,
can enroll in this class.”
• Here, we mean that students who have taken both calculus and a
computer science course cannot take the class. Only those who have
taken exactly one of the two courses can take the class.
Example
• For each of these sentences, determine whether an inclusive or, or an
exclusive or, is intended. Explain your answer.
• there are three related conditional statements that occur so often that they
have special names.
• (p → q) ↔ ( ¬ q → ¬ p)
• (q → ¬ p) ↔ (p ↔ q)
• (p ⊕ q) ∧ (p ⊕ ¬ q)
Propositional Equivalences
• important type of step used in a mathematical argument.
-replacement of a statement with another statement with the
same truth value.
• Tautology
• Contradiction
• Contingency
Propositional Equivalences
• A compound proposition that is always true, no matter what
the truth values of the propositional variables that occur in it,
is called a tautology.
Show (p q) (p q) is a tautology
Show (p q) r and
p (q r) are not equivalent
Logical Equivalences