Lecture 5 - Logic PDF
Lecture 5 - Logic PDF
STRUCTURES
Lecture 5: Logic
Lecture Overview
2
Statement
Logical Connectives
Conjunction
Disjunction
Propositions
Conditional
Bio-conditional
Converse
Inverse
Contrapositive
Laws of Logic
Quantifiers
Universal
Existential
I like orange
4–2= 3
Truth values: T, F
DEFINITION 1
Let p be a proposition. The negation of p, denoted by ¬p, is the statement
“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.
Examples
Find the negation of the following propositions and express this in simple
English.
“Today is Friday.”
Solution: The negation is “It is not the case that today is Friday.”
In simple English, “Today is not Friday.” or “It is not
Friday today.”
“At least 10 inches of rain fell today in Miami” .
Solution: The negation is “It is not the case that at least 10 inches of rain
fell today in Miami.”
28-Mar-22 Computer Sciences Department
In simple English, “Less than 10 inches of rain fell today in Miami.”
1.1 Propositional Logic
8
Exercise ..
Give the negation of the following:
• p: 2 + 3 > 1
¬ p: 2 + 3 ≤ 1
• q: It is cold .
¬ q: It is not cold.
• r: 2+3 ≠5
¬ r: 2 + 3 = 5
• g: 2 is a positive integer
28-Mar-22 ¬ g: 2 is not a positive integer . OR ¬g: 2 is aComputer
negativeSciences
integerDepartment
.
1.1 Propositional Logic
9
Truth table:
The Truth Table for the
Negation of a Proposition.
p ¬p
T F
F T
DEFINITION 2
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.
Example
Find the conjunction of the propositions p and q where p is the
proposition “Today is Friday.” and q is the proposition “It is raining today.”,
and the truth value of the conjunction.
DEFINITION 3
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.
Example
Find the disjunction of the propositions p and q where p is the
proposition “Today is Friday.” and q is the proposition “It is raining today.”,
and the truth value of the conjunction.
Solution: The conjunction is the proposition “Today is Friday or it is
raining today”
The proposition is:
TRUE whether today is Fridays or a rainy day including rainy
Fridays
FALSE on days that are not a Fridays and when it does not rain .
DEFINITION 4
Let p and q be propositions. The exclusive or of p and q, denoted by 𝒑 ⊕ 𝒒 ,
is the proposition that is true when exactly one of p and q is true and is false
otherwise.
Conditional Statements
DEFINITION 5
Let p and q be propositions. The conditional statement p → q, is the
proposition “if p, then q.” The conditional statement is false when p is
true and q is false, and true otherwise. In the conditional statement p
→ q, p is called the hypothesis (or antecedent or premise) and q is
called the conclusion (or consequence).
A conditional statement is also called an implication.
Example: “If I am elected, then I will lower taxes.” p→q
implication:
elected, lower taxes. T T |T
not elected, lower taxes. F T |T
not elected, not lower taxes. F F |T
elected, not lower taxes. T F |F
28-Mar-22
1.1 Propositional Logic
17
Example:
Let p be the statement “Maria learns discrete mathematics.” and q the
statement “Maria will find a good job.” Express the statement p → q as a
statement in English.
Solution: Any of the following -
“If Maria learns discrete mathematics, then she will find a
good job.
“Maria will find a good job when she learns discrete
mathematics.”
“For Maria to get a good job, it is sufficient for her to
learn discrete mathematics.”
“Maria will find a good job unless she does not learn
discrete mathematics.”
28-Mar-22 Computer Sciences Department
1.1 Propositional Logic
18
Equivalent Statements:
Statements with the same truth table values.
Converse and Inverse are equivalents.
Contrapositive and p → q are equivalents.
DEFINITION 6
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.
p ↔ q has the same truth value as (p → q) Λ (q → p)
“if and only if” can be expressed by “iff”
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.”
Implication:
If you buy a ticket you can take the flight.
If you don’t buy a ticket you cannot take the flight.
28-Mar-22 Computer Sciences Department
1.1 Propositional Logic
20
28-Mar-22
1.1 Propositional Logic
21
Exercise ..
Let p and q be the propositions
p : I bought a lottery ticket this week.
q : I won the million dollar jackpot on Friday.
Express each of these propositions as an English sentence.
1) ¬𝑝 I did not buy a lottery ticket this week.
3) ¬ 𝑝∨𝑞 I did not buy a lottery ticket this week, and I did not
win the million dollar jackpot on Friday.
T T F T T T
T F T T F F
F T F F F T
F F T T F F
28-Mar-22
Types of statements
23
A statements that is true for all possible values of its propositional variables
is called tautology
(𝑝 ∨ 𝑞) ↔ (𝑞 ∨ 𝑝) Examples of a Tautology and a Contradiction.
𝑝 ∨∼ 𝑝
p ¬p p ν ¬p p Λ ¬p
T F T F
F T T F
A statement that is always false is called contradiction
𝑝 ∧∼ 𝑝
A statement that can be either true or false, depending of the values of its
propositional variables, is called a contingency
(𝑝 ⟶ 𝑞) ∧ (𝑝 ∧ 𝑞)
28-Mar-22 Computer Sciences Department
1.1 Propositional Logic
24
Exercise ..
find the truth table of the following proposition
p ˄ ( ¬( q ˅ ¬p))
p q ¬p q ˅ ¬p ¬( q ˅ ¬p) p ˄ ( ¬( q ˅ ¬p))
T T F T F F
T F F F T T
F T T T F F
F F T T F F
Solution: Let q, r, and s represent “You can ride the roller coaster,”
“You are under 4 feet tall,” and “You are older than
16 years old.” The sentence can be translated into:
(r Λ ¬ s) → ¬q.
28-Mar-22
1.1 Propositional Logic
27
Example: How can this English sentence be translated into a logical expression?
“You can access the Internet from campus only if you are a computer science
major or you are not a freshman.”
Solution: Let a, c, and f represent “You can access the Internet from
campus,” “You are a computer science major,” and “You are
a freshman.” The sentence can be translated into:
a → (c ν ¬ f ) .
28-Mar-22
1.1 Propositional Logic
28
Exercise ..
Write the following statement in logic :
If I do not study discrete structure and I go to movie ,
then I am in a good mood .
Solution :
p: I study discrete structure ,
q: I go to movie ,
r: I am in a good mood
(¬p ˄ q )➝ r
0 0 0 0 0
0 1 1 0 1
1 0 1 0 1
28-Mar-22 1 1 1 1 0
1.1 Propositional Logic
30
DEFINITION 7
A bit string is a sequence of zero or more bits. The length of this
string is the number of bits in the string.
Example: Find the bitwise OR, bitwise AND, and bitwise XOR of the bit string
01 1011 0110 and 11 0001 1101.
Solution:
01 1011 0110
11 0001 1101
-------------------
11 1011 1111 bitwise OR
01 0001 0100 bitwise AND
10 1010 1011 bitwise XOR
Introduction
DEFINITION 1
A compound proposition that is always true, no matter what the truth
values of the propositions that occurs 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 or a contradiction is
called a contingency.
T F T F
F T T F
28-Mar-22
1.2 Propositional Equivalences
32
Logical Equivalences
DEFINITION 2
The compound propositions p and q are called logically equivalent
if p ↔ q is a tautology. The notation p ≡ q denotes that p and q are
logically equivalent.
Compound propositions that have the same truth values in all possible cases
are called logically equivalent.
Example: Show that ¬p ν q and p → q are logically equivalent.
Truth Tables for ¬p ν q and p → q .
p q ¬p ¬p ν q p→q
T T F T T
T F F F F
F T T T T
28-Mar-22
F F T T T
1.2 Propositional Equivalences
33
Exercise ..
Show that this statements ((p ˄ q) → (p ˅ q)) is
p q q˄p p˅q (p ˄ q) → (p ˅ q)
T T T T T
T F F T T
F T F T T
F F F F T
Identity Laws
p vF ≡p
p ^T≡ p
Domination Laws
p vT ≡T
P ^F≡F
Idempotent Laws
pvp≡ p
p^p≡ p
Double Negation Law
¬(¬p) ≡ p
Commutative Laws
pvq≡ qvp
p^q≡ q^p
Association Laws
(p v q ) v r ≡ p v (q v r)
Distributive Laws
p v (q ^ r ) ≡ (p v q) ^ (p v r)
p ^ (q v r) ≡ (p ^ q) v (p ^ r)
De Morgan’s Laws
~ (p v q) ≡ ~p ^ ~q
~ (p ^ q) ≡ ~p v ~q
Absorption Laws
p v (p ^ q) ≡ p
p ^ (p v q) ≡ p
Complement Laws
p v ~p ≡ T p ^ ~p ≡ F
~ ~p ≡ p ~ T ≡ F , ~F ≡ T
p → q ≡ ¬p ˅ q
¬(p → q ) ≡ p Λ ¬q
28-Mar-22
1.2 Propositional Equivalences
40
28-Mar-22
Exercises
41
Show that
~p ^ (~q ^ r) v (q ^ r) v (p ^ r) ≡ r
(p → q) v (p → r) ≡ p → q v r
(p v q ) ^ ~p
≡ ~p ^ ( p v q )
≡ ( ~p ^ p ) v ( ~ p ^ q )
≡ F v ( ~p ^ q )
≡ ~p ^ q
~p ^ (~q ^ r) v (q ^ r) v (p ^ r) ≡ r
≡ ~p ^ r ^ (~q v q) v (p ^ r)
≡ ~p ^ r ^ T v (p ^ r)
≡ ~p ^ r v (p ^ r)
≡ (~p ^ r) v (p ^ r)
≡ r ^ (~p v p)
≡r^T
≡r
(p → q) v (p → r) ≡ p → q v r
≡ ¬𝑝⋁𝑞 ⋁(¬𝑝⋁𝑟)
≡¬𝑝 ⋁𝑞⋁¬𝑝⋁𝑟
≡ ¬𝑝 ⋁¬𝑝⋁𝑞 ⋁𝑟
Complement
≡ ¬𝑝⋁𝑞 ⋁𝑟
Laws
≡ ¬𝑝⋁(𝑞⋁𝑟) p → q ≡ ¬p ˅ q
≡ 𝑝 → (𝑞 ⋁𝑟)
≡ q ˅ ¬ (¬p ˅ q ) ˅ ¬p
≡ (¬p ˅ q ) ˅ ¬ (¬p ˅ q )
≡ T
Example:
If you have access to the network, then you can
Hypothesis
change your grade
premises
You have access to the network
--------------------------------------------------
∴ You can change your grade Valid
conclusion Argument
63
p: “it is snowing”,
q: “Jasmine is skiing”,
r: “Bart is playing hockey”
SOLUTION We can represent the hypotheses as
¬ p v q and p v r, respectively
Using Resolution, the proposition q v r, “Jasmine is
skiing or Bart is playing hockey” follows
DEFINITION 1
The universal quantification of p(x) is the statement
“P(x) for all values of x in the domain .”
The notation ∀ x P(x) denotes the universal quantification of P(x). Here
∀ is called the universal quantifier. We read ∀ x P(x) as “for all x P(x)” or
“for every x P(x) ”. An element for which P(x) is false called
counterexample of ∀ x P(x)
Example 8..
Let P(x) be the statement “x+1>x”. What is the truth value of the
quantification ∀ x P(x), where the domain consists of all real numbers?
Solution
The quantification ∀ x P(x),is true because P(x) is true for all real numbers.
Example 9..
Let Q(X) be the statement “x < 2”. What is the truth value of the
quantification ∀ x Q(x), where the domain consists of all real numbers?
Solution
Q(x) is not true for every real number x, because Q(3) is false. That is, x=3
is a counterexample for the statement ∀ x Q(x), thus
∀ x Q(x) is false
Example 11..
What is the truth value of the quantification ∀ x P(x), where P(X) is the
statement “x2 < 10” and the domain consists of the positive integers not
exceeding 4 ?
Solution
The statement ∀ x P(x) is the same as the conjunction
P(1) ^ P(2) ^ P(3) ^ P(4)
Because the domain consists of the positive integers 1,2,3 and 4.
Because P(4), which the statement “42 < 10” is false, it follows that ∀ x P(x)
is false.
DEFINITION 2
The essential quantification of p(x) is the proposition
“There exists an element x in the domain such that P(x).”
We use the notation ∃ x P(x) for the essential quantification of P(x).
Here ∃ is called the essential quantifier.
In some situations, we only require that there is at least one
value for which the predicate is true.
The existential quantification of a predicate
P(x) is the statement “there exists a value of x, for which P(x) is
true.
∃x P(x)
There is a dog without tail (∃ a dog) (a dog without tail)
28-Mar-22 Computer Sciences Department
2.Existential Quantifiers
74
Example 16..
What is the truth value of ∃x P(x), where P(X) is the statement “x2 > 10”
and the universe of discourse consists of the positive integers not exceeding
4?
Solution
Because the domain is {1, 2, 3, 4}, the proposition ∃ x P(x) is the same as
the disjunction
P(1) v P(2) v P(3) v P(4)
Because P(4), which the statement “42 > 10” is true, it follows that ∃x P(x) is
true.
Rule:
∀x p(x) ∃x ¬p(x)
∃x p(x) ∀x ¬p(x)
Exercise ..
p(x): x is even
q(x): x is a prime number
r(x,y): x+y is even .
Write an English sentence that represent the following :
A. ∀x P(x) for every x where x is even
B. ∃x Q(x) there is exists x where x is a prime number
C. ∀x ∃y R(x,y) for all x there exists y where x+y is even
Find negation for a. and b.
∃x ¬p(x) there is exist x where x is odd
∀x ¬q(x) for every x where x not prime number