0% found this document useful (0 votes)
20 views58 pages

Logics

Logic is the study of reasoning and arguments. It involves understanding what constitutes valid reasoning and identifying fallacies. Propositional logic deals with propositions that can be either true or false. Logical operators like negation, conjunction, disjunction, implication, equivalence, and biconditional are used to form compound propositions from simple propositions. Truth tables are used to determine the truth values of compound propositions based on the truth values of the constituent simple propositions.

Uploaded by

Umar Draz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views58 pages

Logics

Logic is the study of reasoning and arguments. It involves understanding what constitutes valid reasoning and identifying fallacies. Propositional logic deals with propositions that can be either true or false. Logical operators like negation, conjunction, disjunction, implication, equivalence, and biconditional are used to form compound propositions from simple propositions. Truth tables are used to determine the truth values of compound propositions based on the truth values of the constituent simple propositions.

Uploaded by

Umar Draz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 58

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.

• In Computer Science, these rules are used in the design of:


• computer circuits,
• the construction of computer programs,
• the verification of the correctness of programs, etc..

• software systems have been developed for constructing some, but


not all, types of proofs automatically
Propositional Logic
• The area of logic that deals with propositions is called the propositional
calculus or propositional logic.

• Propositional logic is a simple logic that allows us to reason about a variety of


concepts

Proposition

• A proposition is a declarative statement (that is, a sentence that declares a


fact) that is either true or false, but not both.

• Facts
• True or False (Corresponds to 1 and 0 in digital circuits)
Proposition
Example 1:
Are given statements are proposition or not?

1. Washington, D.C., is the capital of the United States of America.


2. Toronto is the capital of Canada.
3. 1 + 1 = 2.
4. 2 + 2 = 3.
Proposition

EXAMPLE 2:
Are given statements are proposition or not?

1. What time is it?


2. Read this carefully.
3. x + 1 = 2
4. x + y = z
Proposition
EXAMPLE 2:
Are given statements are proposition or not? If yes what are their truth values?

1. The sun rises in the East and sets in the West.


2. 1 + 1 = 2
3. 'b' is a vowel.
4. Go out and play
Practice Task
Which of these sentences are propositions? What are the truth
values of those that are propositions?
a) Lahore is the capital of Punjab.
b) Beijing is the capital of China.
c) 2 + 3 = 5.
d) 5 + 7 = 10.
e) x + 2 = 11.
f ) Answer this question.
How to represent proposition ?

• We use letters to denote propositional variables (or statement variables)

• just as letters are used to denote numerical variables.

• The conventional letters used for propositional variables are p, q, r, s, . . . .

• The truth value of a proposition is true, denoted by T

• the truth value of a proposition is false, denoted by F


Negation Proposition
• Let p be a proposition. The negation of p, denoted by ¬ p (also
denoted by p¯)
• “It is not the case that p.”

• The proposition ¬ p is read “not p.”

• The truth value of the negation of p, ¬ p, is the opposite of the truth


value of p.
Negation Proposition… Example

Find the negation of the proposition and express this in simple


English.

• “Michael’s PC runs Linux”

Solution: The negation is


“It is not the case that Michael’s PC runs Linux.”
• This negation can be more simply expressed as:
“Michael’s PC does not run Linux.”
Practice Task
Find the negation of the proposition and express this in simple English.

• “Ali’s smartphone has at least 32GB of memory”

Solution: The negation is


• “It is not the case that Ali’s smartphone has at least 32GB of memory.”

This negation can also be expressed as


• “Ali’s smartphone does not have at least 32GB of memory”

or even more simply as


• “Ali’s smartphone has less than 32GB of memory.”
Practice Task
What is the negation of each of these propositions? and express this
in simple English.

a) Mr. ABC has an MP3 player.


b) There is no pollution in New Jersey.
c) 2 + 1 = 3.
d) The summer in Japan is hot and sunny.
Practice Task
What is the negation of each of these propositions?

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.

• Let p be a proposition. The negation of p, denoted by

• The proposition is read "not p."

• Example: Today is Monday


The negation is Today is not Monday
Logical operators
We will discuss the following logical connectives:

• ¬ (not)
• ∧ (conjunction)
• ∨ (disjunction)
• → (implication)
• ⊕ (exclusive)
• ↔ (biconditional)
The Truth Table for the Negation of a Proposition

T F

F T
Propositional Conjunction

• Let p and q be propositions. The conjunction of p and q, denoted by p ∧ q, is


the proposition “p and q.”

• 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

Find the conjunction of the propositions p and q where p is the


proposition “Tariq’s PC has more than 16 GB free hard disk space” and q
is the proposition “The processor in Tariq’s PC runs faster than 1 GHz.”

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:

• Let us consider our proposition p is “a+b=c” and proposition q is


“d+e=f”.

• 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.

• Let p and q be propositions. The disjunction of p and q, denoted by p ∨ q,


is the proposition “p or q.”

• 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

Find the disjunction of the propositions p and q where p is the


proposition “Tariq’s PC has more than 16 GB free hard disk space” and q
is the proposition “The processor in Tariq’s PC runs faster than 1 GHz.”

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

• Lets consider the same example as we consider for disjunction.

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

• The statement p → q is called a conditional statement because p → q states that q is


true on the condition that p holds.

• A conditional statement is also called an implication.


• p → q is true when both p and q are true and when p is false.
ways to express implication statement
• “if p, then q”
• “p implies q”
• “if p, q”
• “p only if q”
• “p is sufficient for q”
• “a sufficient condition for q is p”
• “q if p”
• “q whenever p”
• “q when p”
• “q is necessary for p”
• “a necessary condition for p is q”
• “q follows from p”
• “q unless ¬ p”
Implication truth table

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

• Lets consider the same example as we consider for conjunction and


disjunction.

P= Today is Friday
q = It is raining today

Find p → q?
Find True and False cases of this example?
Implication
Example:

• P= you work hard


• q= you will get reward

• If you work hard then you will get reward.


Above statement can be expressed as p → q.

Find out in which cases p → q is true and false?


Practice Task
Determine whether each of these conditional statements is true or
false.

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.”

• The biconditional statement p ↔ q is true when p and q have the


same truth values, and is false otherwise.

• Biconditional statements are also called bi-implications.

• It can also represent as:


• p is necessary and sufficient for q”
• “if p then q, and conversely”
• “p iff q.”
Biconditional truth table

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

“You can take the flight if and only if you buy a ticket.”
Example

• Lets consider the same example as we consider for conjunction, disjunction


and implication.

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.

• For instance, the inclusive or is being used in the statement

• “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.

a) Coffee or tea comes with dinner.


b) A password must have at least three digits or be at least eight characters
long.
c) The prerequisite for the course is a course in number theory or a course in
cryptography.
d) You can pay using U.S. dollars or euros.
Example
Write each of these statements in the form “if p, then q” in English.

• a) It snows whenever the wind blows from the northeast.


• b) The apple trees will bloom if it stays warm for a week.
• c) That the Pistons win the championship implies that they beat the Lakers.
• d) It is necessary to walk 8 miles to get to the top of Long’s Peak.
• e) To get tenure as a professor, it is sufficient to be world famous.
• f ) If you drive more than 400 miles, you will need to buy gasoline.
• g) Your guarantee is good only if you bought your CD player less than 90
days ago.
• h) Jan will go swimming unless the water is too cold.
CONVERSE, CONTRAPOSITIVE, AND INVERSE

• We can form some new conditional statements starting with a conditional


statement p → q.

• there are three related conditional statements that occur so often that they
have special names.

• The proposition q → p is called the converse of p → q.


• The contrapositive of p → q is the proposition ¬ q → ¬ p.
• The proposition ¬ p → ¬ q is called the inverse of p → q.
Example
What are the contrapositive, the converse, and the inverse of the
conditional statement “The home team wins whenever it is raining?”
Precedence of Logical Operators

P ∧ q ∨ r means (p ∧ q) ∨ r rather than p ∧ (q ∨ r)


Reminder
Truth Tables of compound propositions
Construct the truth table of the compound proposition
• (p ∨ ¬ q) → (p ∧ q).
Practice task
• (q → ¬ p) ∨ ( ¬ p → ¬ q)

• (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.

• A compound proposition that is always false is called a


contradiction.

• A compound proposition that is neither a tautology nor a


contradiction is called a contingency.
Example: Tautology, Contradiction,
• Below table shows the example of Tautology, Contradiction.
 construct truth table of following:
(i) PV ¬ p
(ii) p ∧ ¬ p

• Because p v ¬ p is always true, it is a tautology. Because p Λ ¬ p is


always false, it is a contradiction.
Logical Equivalences
• Compound propositions that have the same truth values in all possible
cases are called logically equivalent.
Example
Example
• Find out whether “p ∨ (q ∧ r) and (p ∨ q) ∧ (p ∨ r)” is logically
equivalent or not.
Practice Task
Practice Task
Prove following equivalences:
1) p  q   p  q
2) p  q   q   p
3) p  q   p  q
4) p  q   (p   q)

 Show (p  q)  (p  q) is a tautology

 Show (p  q)  r and
p  (q  r) are not equivalent
Logical Equivalences

You might also like