Professional Documents
Culture Documents
1
Propositional logic
(In Book: Chapter 1-sec 1.1)
2
Propositional Logic
3
Propositions
The basic building blocks of logic.
It is a declarative sentence that is either True or False, but not both.
Example 1 1) Example 2
1) Riyadh is the capital of Saudi 1) What time is it?
Arabia. 2) Read this carefully.
2) Cairo is the capital of Lebanon. 3) x+1=2
3) 1+1=2 4) x+y=z
4) 2+2=3
5
Propositions
6
Negation of a proposition
Definition :
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”
Negation construct a new proposition from a single existing
proposition.
The truth table for the negation of a proposition.
p p
Notice that p is a F T
proposition! T F
7
Negation of a proposition
Example :
Find the negation of the proposition
“Sara’s pc runs Linux” and express this in simple English.
Solution:
Negation is: “it is not the case that Sara’s pc runs Linux”
More simply: “Sara’s pc does not run Linux”
8
Negation of a proposition
Example :
Find the negation of the proposition
“Ahmad’s smart phone has at least 32 GB of memory” and express this
in simple English.
Solution:
Negation is: “Ahmad’s smart phone does not have at least32 GB of
memory”
More simply: “Ahmad’s smart phone has less than 32 GB of memory”
9
Logical connectives
10
Conjunction of propositions
Definition :
Let p and q be propositions. The conjunction of p and q, denoted
by pq, is the proposition “p and q”. The conjunction pq is true
when both p and q are true, and is false otherwise.
The truth table for the conjunction of two proposition.
p q pq
T T T
Notice that conjunction T F F
can be between two or F T F
more propositions
F F F
11
Conjunction of propositions
Example :
Find the conjunction of the propositions p and q,
where p is the proposition “Ahmad’s pc has more than 16
GB free hard disk space”
and q is the proposition “The processor in Ahmad’s pc runs
faster than 1 GHz” express this in simple English.
Solution:
Ahmad’s pc has more than 16 GB free hard disk space and The
processor in Ahmad’s pc runs faster than 1 GHz.
Definition:
Let p and q be propositions. The disjunction of p and q, denoted by
p q, is the proposition “p or q”. The conjunction p q is false
when both p and q are false, and is true otherwise.
The truth table for the disjunction of two proposition.
p q pq
Notice that disjunction T T T
can be between two or T F T
more propositions
F T T
F F F
13
Disjunction of propositions
Example :
Find the disjunction of the propositions p and q,
where p is the proposition “Ahmad’s pc has more than 16
GB free hard disk space”
and q is the proposition “The processor in Ahmad’s pc runs
faster than 1 GHz” express this in simple English.
Solution:
Ahmad’s pc has more than 16 GB free hard disk space orThe
processor in Ahmad’s pc runs faster than 1 GHz.
When it will be true? False?
14
Exclusive-OR of propositions
Definition:
Let p and q be propositions. The exclusive or of p and q, denoted
by p ⊕ q, is the proposition that is true when exactly one of p
and q is true and is false otherwise.
The truth table for the exclusive or of two proposition.
p q p⊕q
T T F
Notice it can be between T F T
two or more propositions
F T T
F F F
15
Conditional Statement (Implication)
Definition:
Let p and q be propositions. The conditional statement (implication)
p q is the proposition “if p, then q”. The conditional statement
p q is false when p is true and q is false, otherwise true.
In the conditional statement p q, p is called the hypothesis or
(antecedent or premise) and q is called the conclusion or
(consequence).
Comes in format:
If p, then q
If p, q
p is sufficient for q
p implies q
…
you will find rest of them in book. Look at them! 16
Conditional Statement (Implication)
The truth table for the implication of two proposition.
p q p q
T T T
T F F
F T T
F F T
Ex:
“If you get 100% on the final, then you will get an A”.
Hypothesis Conclusion
17
Conditional Statement (Implication)
Example:
Hypothesis Conclusion
If Juan has a smart phone, then 2+3 = 5
This proposition is true, because conclusion is true.
Solution:
If Maria learns discrete mathematics, then she will find job.
Maria will find job when she learns discrete mathematics.
Rest example in book page 7
When it will be true? False?
19
Converse, Contrapositive and Inverse
20
Converse, Contrapositive and Inverse
Converse: q p is converse of p q.
Ex.: p q: “If it is noon, then I am hungry.”
q p: “If I am hungry, then it is noon.”
Contrapositive: q p is contapositive of p q.
Ex.: q p: “If I am not hungry, then it is
not noon.”
Inverse: p q is inverse of p q.
Ex.: p q: “If it is not noon, then I am not
hungry.”
See
p q has same truth values as q p example 7
21
Biconditional Statement
p q
T T T
T F F
F T F
F F T
22
Biconditional Statement
23
Implicit use of Biconditional Statement
Means
“You can have dessert if and only if you finish your meal”
24
Truth Table of Compound Proposition
# of raws = 2 # of variable
25
Well-formed formula
26
Well-formed formula
Operator Precedence
1
2
3
4
5
27
Logic and Bit Operations
0 0 0 0 0
0 1 1 0 1
1 0 1 0 1
1 1 1 1 0
Example 13
Find bitwise OR, AND, and XOR of the bit strings:
0110110110 and 1100011101
29
Propositional Logic – Translating English Sentences
The sentence “The automated reply cannot be sent when the file
system is full” can be translated as
q → p
where p: “The automated reply can be sent ”
q: “The file system is full”
The sentence “You cannot drive a car if you are under 4 feet tall
unless you are older than 16 years old” can be translated as
(q r) → p
where p: “You can drive a car ”
q: “You are under 4 feet tall ”
r: “You are older than 16 years old”
30
Propositional Logic – Translating English Sentences
The sentence “You can access the Internet from campus only if you
are a computer science major or you are not a freshman” can be
translated as
p → (q r)
where p: “You can access the Internet from campus”
q: “You are a computer science major”
r: “You are a freshman”
Q4: Translate the following sentences into logical expressions:
“Access is granted whenever the user has paid the subscription
fee and enters a valid password”
“If the user has not entered a valid password but has paid the
subscription fee, then access is granted”
31
Propositional
Equivalences
(In Book: Chapter 1-sec 1.3)
32
1.3 Propositional Equivalences
Definition
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.
p p p p p p
F T T F
T F T F
33
Logic Equivalence
Example:
Show that ¬(p ν q) and p q are logically equivalent.
De Morgan laws
p q p q (p q) p q p q
F F F T T T T
T F T F F T F
F T T F T F F
T T T F F F F
34
Logic Equivalence
Equivalence Name
p Λ T p and p ν F p Identity laws
p ν T T and p Λ F F Domination laws
p ν p p and p Λ p p Idempotent laws
¬( ¬ p) p Double negation law
p ν q q ν p and p Λ q q Λ p Commutative laws
(p ν q) ν r p ν (q ν r) and (p Λ q) Λ r p Λ (q Λ
Associative laws
r)
p (q r) (p q) (p r)
Distributive laws
p (q r) (p q) (p r)
¬(p ν q) ¬p Λ ¬q and ¬(p Λ q) ¬p ν ¬q De Morgan’s laws
p (p q) p and p (p q) p Absorption laws
36
Predicates and
Quantifiers
(In Book: Chapter 1-sec 1.4)
37
Limitation of propositional logic
Propositional logic cannot adequately express the meaning of all statements in
mathematics and in natural language.
For example, suppose that we know that:
“Every computer connected to the university network is functioning properly.”
No rules of propositional logic allow us to conclude the truth of the
statement:
“MATH3 is functioning properly”
where MATH3 is one of the computers connected to the university network.
Likewise, if CS2 is a computer on the university network and the statement is:
“CS2 is under attack by an intruder,”
No rules of propositional logic allow us to conclude the truth of
“There is a computer on the university network that is under attack by an intruder.”
38
Limitation of propositional logic
39
Predicates
• The following statements with unspecified variables are not propositions:
“x > 3”
“x = y + 3”
“computer x is functioning properly”
“computer x is under attack by an intruder”
40
Predicates
The statement “x > 3” has two parts:
• is greater than 3, the predicate, refers to the property that the subject of
the statement can have.
We denote “x > 3” by P(x), where P denotes the predicate “is greater than 3”
and x is the variable
41
Predicates
Definition
A predicate, or propositional function, is a function that takes some
variable(s) as arguments and returns True or False.
Example1: Let P(x) = “x > 3”, what are the truth values of P(2) and P(4)?
Sol: P(2) = “2 > 3” is false and P(4) = “4 > 3” is true
Example3: Let Q(x, y) = “x = y + 3”, what are the truth values of Q(1, 2) and Q(3, 0)?
Sol: Q(1,2)= “1=2+3” is false, Q(3,0)= “3=0+3” is true
Definition
A statement of the form P(x1, x2, …., xn) is the value of the propositional
function P at the n-tuple (x1, x2, …., xn), and P is called n-ary predicate
42
Predicates
Example:
Let A(c,n) denote the statement “Computer c is connected to network n”,
where:
• c is a variable representing a computer, and
• n is a variable representing a network.
Suppose that the computer MATH1 is connected to network CAMPUS2, but
not to network CAMPUS1.
What are the values of A(MATH1, CAMPUS1) and A(MATH1, CAMPUS2)?
sol:
– A(MATH1, CAMPUS1) – “MATH1 is connect to CAMPUS1”, false
– A(MATH1, CAMPUS2) – “MATH1 is connect to CAMPUS2”, true
43
Predicates
Example: Consider the statement
if x > 0 then x := x + 1.
Here P(x) = “x > 0”.
• If P(x) is true for the value of x, then the assignment statement x :=
x + 1 is executed, x is increased by 1.
• If P(x) is false for the value of x, then the assignment statement is
not executed, x remains same
The statements that describe valid input are known as preconditions,
and the conditions that the output should satisfy when it has run are
known as postconditions
Example: Let R(x, y, z) = “x + y = z”, what are the truth values of R(1,
2, 3) and R(0, 0, 1)? 44
Quantifiers
45
Universal Quantifiers
Definition:
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 universal quantifier. An element
for which P(x) is false is called a counterexample of x P(x).
Quantifiers:
Example: Let P(x) = “x+1 > x”. What is the truth value of the
quantification x P(x), where the domain consists of all real
numbers?
Sol: Because P(x) is true for all real numbers x, the quantification
x P(x) is true.
Example: Let Q(x) = “x < 2”. What is the truth value of the
quantification x Q(x), where the domain consists of all real
numbers?
Sol: Because Q(x) is not true for every real number x, because, for
instance, Q(3) is false. That is, x=3 is a counterexample for the
statement x Q(x).
47
Universal Quantifiers
Q8: Let P(x) = “x2 > 0”. What is the truth value of the
quantification x P(x), where the domain consists of all real
numbers?
Q9: Let Q(x) = “x2 < 10”. What is the truth value of the
quantification x Q(x), where the domain consists of positive
integers less than 4?
Q10: Let R(x) = “x2 ≥ x”. What is the truth value of the
quantification x R(x), where the domain consists of all real
numbers? What is the truth value of the quantification if the domain
consists of all integers?
48
Existential Quantifiers
Example: Let P(x) = “x > 3”. What is the truth value of the
quantification x P(x), where the domain consists of all real
numbers?
Sol: Because P(x) is sometimes true - for instance, when x=4 – the
existential quantification of P(x), which is x P(x), is true.
49
Existential Quantifiers
Q11: Let Q(x) = “x2 > 10”. What is the truth value of the
quantification x Q(x), where the domain consists of positive
integers not exceeding 4?
Q12: Let R(x) = “x2 ≥ x”.What is the truth value of the
quantification x R(x), where the domain consists of all real
numbers? What is the truth value of the quantification if the domain
consists of all integers?
50
Quantifiers with Restricted Domain
Example
What do the statements x < 0(x2 > 0), y≠0(y3 ≠ 0), and z > 0(z2 = 2) mean,
where the domain in each case consists of all real numbers?
Sol: The statement x < 0(x2 > 0) states that for every number x with x < 0,
x2 > 0. That is, it states “The square of a negative real number is positive”.The
statement is the same as x (x < 0 → x2 > 0).
The statement y ≠ 0(y3 ≠ 0) states that for every real number y with
y ≠ 0, we have y3 ≠ 0. That is, it states “The cube of every nonzero real is nonzero”.The
statement is the same as y (y ≠ 0 → y3 ≠ 0).
Finally, the statement z > 0(z2 = 2) states that there exist a real number z with z > 0
such that z2=2. That is, it states “There is positive square root of 2”. The statement is
the same as z (z > 0 ⌃z2 = 2).
51
Quantifiers with Restricted Domain
52
Precedence of Quantifiers
53
Binding variables
54
Binding variables
Example:
• x ( x+y=1)
• x is bound by existential quantification x
• y is free because it is not bound by a quantifier and no value is
assigned to this variable.
57
Negating Quantified Expression
58
Negating Quantified Expression
59
Negating Quantified Expression
Example 20:What are the negations of the statements “There is a
religious man” and “All Saudi eat Rice”?
60
Negating Quantified Expression
Example 21
What are the negations of the statements
x (x2 > x) and x (x2 = 2)”?
61
Negating Quantified Expression
Example26: Let L(x) = “x is a lion”, F(x) = “x is fierce”, and C(x) = “x drinks coffee”.
Show the quantifiers for the statements (i) All lions are fierce, (ii) Some lions don’t
drink coffee, (iii) Some fierce creatures don’t drink coffee.
Sol: (i) x (L(x) F(x)), ii) x (L(x) C(x)), and
(iii) x (F(x) C(x))
Example27: Let B(x) = “x is a hummingbird”, L(x) = “x is a large bird”, H(x) = “x lives
on honey”, and R(x) = “x is richly colored”. Show the quantifiers for the statements
(i) All hummingbirds are richly colored = x (B(x) R(x))
(ii) No large birds live on honey
= x (L(x) H(x)) = x(L(x) v H(x))
(iii) Birds that do not live on honey are dully colored
= x ( H(x) R(x))
(iv) Not all large birds live on honey.
= x (L(x) H(x))= x (L(x) v H(x))
62
Translating English into Logical Expression
Example 23: Express the statement “Every student in this class has studied calculus”
using predicates and quantifiers.
Sol: We rewrite as “For every student in this class, the student has studied calculus”.
Let P(x) = “x has studied calculus”, then our statement is represented by x P(x).
=> “For every person x, if person x is a student in this class, x has studied calculus”.
Example 24: Express the statements “Some students in this class visited Dubai” and “Every student in
this class has visited either Makah or Medina” using predicates and quantifiers.
Solution : The statement “Some students in this class visited Dubai” means “there is a student x in this
class with the property that the student has visited Dubai” => x D(x)
If we interested in people other than those in this class, the statement will be “there is a person x
having the properties that x is a student in this class and x has visited Dubai” = x (S(x) D(x) )
The statement “Every student in this class has visited either Makah or Medina” means “For every x in
this class, x has the property that x has visited Makah or x has visited Medina” => x (K(x) v M(x)).
If we interested in people other than those in this class, the statement will be:
“For every person x, if x is a student in this class then x has visited Makah or x has visited Medina”
71
Rule of Inference-Valid Arguments in Propositional Logic
To deduce new statements from statements we already have, we use rules of inference
which are templates for constructing valid arguments.
72
Rules of Inference
Therefore,
73
Rules of Inference
To determine whether this is a valid argument , i.e. to determine whether:
The conclusion q : “You can log onto the network” must be True when :
The premises p q : “If you have a current password, then you can log onto the
network” is True And p:“You have a current password” is True
p→q
p
q where is the symbol that denotes “therefore.”
“If you have access to the network, then you can change your grade.”
“You have access to the network.”
∴ “You can change your grade.”
The argument we obtained is a valid argument, but because one of the premises, namely
the first premise, is false, we cannot conclude that the conclusion is true.
75
Rules of Inference
Definition
An argument in propositional logic is a sequence of propositions. All but the final
proposition in the argument are called premises and the final proposition is called the
conclusion. An argument is valid if the truth of all its premises implies that the
conclusion is true.
An argument form in propositional logic is a sequence of compound propositions
involving propositional variables. An argument form is valid no matter which
particular propositions are substituted for the propositional variables in its premises,
the conclusion is true if the premises are all true.
76
Rules of Inference for Propositional Logic
We can always use a truth table to show that an argument form is valid by showing that
whenever the premises are true, the conclusion must also be true
if we have an argument form involves 10 different propositional variables
it is tedious approach
Instead of showing by truth table, we can establish the validity of some relatively simple argument
forms, called rules of inference, which can be used as building blocks to construct more complicated valid
argument forms.
77
Rules of Inference for Propositional Logic
78
Rules of Inference for Propositional Logic
Example : Determine whether the argument given here is valid and determine whether
its conclusion must be true because of the validity of the argument.
2
3 3 3
" If 2 , then ( 2 ) . We know that
2
2 .
2 2 2
p q 2
3 9
Consequently, ( 2 ) 2 ."
2
2 4
Solution
The premises of the argument are : p → q and p while q is its conclusion
This argument is valid because it is constructed by using modus ponens, a valid
argument form. Since premises (p → q) ^ p are false, therefore the conclusion q is also
false because
79
Rule of Inference Tautology Name
p (p ∧ (p → q)) → q Modus ponens
p→q
∴q 80
¬q (¬ q ∧ (p → q))→¬ p Modus tollens
p→q
∴ ¬p
p→q ((p → q) ∧ (q → r)) → (p → r) Hypothetical syllogism
q→r
∴p→r
p∨q ((p ∨ q)∧¬ p) → q Disjunctive syllogism
¬p
∴q
p p → (p ∨ q) Addition
∴p∨q
p∧q (p ∧ q) → p Simplification
∴p
p
p∨q
81
Rules of Inference for Propositional Logic
82
Rules of Inference for Propositional Logic
Example : State which rule of inference is the basis of the following argument:
“If it rains today, then we will not have a barbecue today. If we do not have a barbecue today, then
we will have a barbecue tomorrow. Therefore, if it rains today, then we will have a barbecue tomorrow.”
When there are many premises, several rules of inference are often needed to show that
an argument is valid.
84
Rules of Inference for Propositional Logic
SOLUTION
Let p: “it is sunny this afternoon”
p ^ q, r p, r s, s t
the conclusion is t
85
Rules of Inference for Propositional Logic
We construct an argument to show that our hypotheses lead to desired conclusion as follows
Step Reason
1. p^q Hypothesis
2. p Simplification using (1)
3. rp Hypothesis
4. r Modus tollens (2,3)
5. rs Hypothesis
6. s Modus ponens (4,5)
7. st Hypothesis
8. t Modus ponens (6,7)
Note:
that if we used the truth table, we would end up with 32 rows ( 2^5 = 32) !!!
86
Rules of Inference for Propositional Logic
Example :
Show that the premises “ If you send me an email message, then I will finish writing
the program, “ “ If you do not send me an email message, then I will go to sleep
early” , and “ If I go to sleep early, then I will wake up feeling refreshed” lead to the
conclusion “ If I do not finish writing the program, then I will wake up feeling
refreshed”
87