Вы находитесь на странице: 1из 74

Propositional Logic

1
Propositional Logic
Introduction
• A proposition is a declarative sentence (a
sentence that declares a fact) that is either
true or false, but not both.
• Are the following sentences propositions?
– Toronto is the capital of Canada. (Yes)
– Read this carefully. (No)
– 1+2=3 (Yes)
– x+1=2 (No)
– What time is it? (No)

2
Propositional Logic
• Propositional Logic – the area of logic that
deals with propositions
• Propositional Variables – variables that
represent propositions: p, q, r, s
– E.g. Proposition p – “Today is Friday.”
• Truth values – T, F

3
Propositional Logic
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 proposition “Today is Friday.” and express this
in simple English.
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.”
– Find the negation of the proposition “At least 10 inches of rain fell
today in Miami.” and express this in simple English.
Solution: The negation is “It is not the case that at least 10 inches
of rain fell today in Miami.”
In simple English, “Less than 10 inches of rain fell today 4
in Miami.”
Propositional Logic
• Note: Always assume fixed times, fixed places, and particular people unless
otherwise noted.
• Truth table: The Truth Table for the
Negation of a Proposition.
p ¬p
T F
F T

• Logical operators are used to form new propositions from two or more
existing propositions. The logical operators are also called connectives.

5
Propositional Logic
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.

• Examples
– 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.
Solution: The conjunction is the proposition “Today is Friday and it
is raining today.” The proposition is true on rainy Fridays.

6
Propositional Logic
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 conjunction p ν q is false when both
p and q are false and is true otherwise.

• Note:
inclusive or : The disjunction is true when at least one of the two
propositions is true.
– E.g. “Students who have taken calculus or computer science can take this
class.” – those who take one or both classes.
exclusive or : The disjunction is true only when one of the
proposition is true.
– E.g. “Students who have taken calculus or computer science, but not both, can
take this class.” – only those who take one of them.
• Definition 3 uses inclusive or.

7
Propositional Logic
DEFINITION 4
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 Truth Table for The Truth Table for the
the Conjunction of the Disjunction of Exclusive Or (XOR) of
Two Propositions. Two Propositions. Two Propositions.
p q pΛq p q pνq p q p q
T T T T T T T T F
T F F T F T T F T
F T F F T T F T T
F F F F F F F F F
8
Propositional Logic
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

9
Propositional Logic
• 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.”

10
Propositional Logic
• Other conditional statements:
– Converse of p → q : q → p
– Contrapositive of p → q : ¬ q → ¬ p

– Inverse of p → q : ¬ p → ¬ q

11
Proof using contrapositive

Prove: If x2 is even, x is even

12
Proof 1
• x2 - 1 is odd since its 1 less than the even
number, x2.
• (x-1)(x+1), by factoring, where both x-1 and
x+1 must be odd for x2-1 to be odd.
• Therefore, x must be even.

13
Proof 2
• If x is odd, it can be expressed as 2k+1 for
some integer k.
• Then x2 = (2k+1) 2= 4k2 +4k+1 = 2(2k2 + 2k) + 1
which is also odd.
• Therefore if x is odd, then x2 is odd.
• Thus, it follows that if x2 is even, then x is even
(using contrapositive).

14
Exercise
The nth statement in a list of 100 statements is
“Exactly n of the statements in this list are
false.”
a) What conclusions can you draw from these
statements?
b) Answer part (a) if the nth statement is “At least n
of the statements in this list are false.”
c) Answer part (b) assuming that the list contains
99 statements.

15
Propositional Logic
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.
16
Propositional Logic

The Truth Table for the


Biconditional p ↔ q.
p q p↔ q
T T T
T F F
F T F
F F T

17
Propositional Logic
Truth Tables of Compound Propositions
• We can use connectives to build up complicated compound propositions
involving any number of propositional variables, then use truth tables to
determine the truth value of these compound propositions.
• Example: Construct the truth table of the compound proposition
(p ν ¬q) → (p Λ q).

The Truth Table of (p ν ¬q) → (p Λ q).


p q ¬q p ν ¬q pΛq (p ν ¬q) → (p Λ q)

T T F T T T
T F T T F F
F T F F F T
F F T T F F
18
Propositional Logic
Precedence of Logical Operators
• We can use parentheses to specify the order in which logical operators in
a compound proposition are to be applied.
• To reduce the number of parentheses, the precedence order is defined
for logical operators.

Precedence of Logical Operators. E.g. ¬p Λ q = (¬p ) Λ q


Operator Precedence p Λ q ν r = (p Λ q ) ν r
¬ 1 p ν q Λ r = p ν (q Λ r)
Λ 2
ν 3
→ 4
↔ 5

19
Propositional Logic
Logic and Bit Operations
• Computers represent information using bits.
• A bit is a symbol with two possible values, 0 and 1.
• By convention, 1 represents T (true) and 0 represents F (false).
• A variable is called a Boolean variable if its value is either true or false.
• Bit operation – replace true by 1 and false by 0 in logical operations.

Table for the Bit Operators OR, AND, and XOR.


x y xνy x Λy x  y
0 0 0 0 0
0 1 1 0 1
1 0 1 0 1
1 1 1 1 0 20
Propositional Logic
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

21
Well Formed Formula (WFF)
A wff is defined as follows:
i. If p is a propositional variable then, it is a wff.
ii. If p is a propositional variable then ¬p is a wff.
iii. If p and q are wffs then (p V q), (p Λ q), (p → q),
(p ↔ q) are wffs.
iv. A string of symbols is a wff if and only if it is
obtained by a finite number of applications of
i-iii.

22
Propositional Equivalences
DEFINITION 8
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.

Examples of a Tautology and a Contradiction.


p ¬p p ν ¬p p Λ ¬p

T F T F
F T T F

23
Propositional Equivalences
DEFINITION 9
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
F F T T T 24
Logical Identities

25
Propositional Equivalences
Constructing New Logical Equivalences
• Example: Show that ¬(p → q ) and p Λ ¬q are logically equivalent.
Solution:
¬(p → q ) ≡ ¬(¬p ν q)
≡ ¬(¬p) Λ ¬q by the second De Morgan law
≡ p Λ ¬q by the double negation law
• Example: Show that (p Λ q) → (p ν q) is a tautology.
Solution: To show that this statement is a tautology, we will use logical
equivalences to demonstrate that it is logically equivalent to T.
(p Λ q) → (p ν q) ≡ ¬(p Λ q) ν (p ν q)
≡ (¬ p ν ¬q) ν (p ν q) by the first De Morgan law
≡ (¬ p ν p) ν (¬ q ν q) by the associative and
communicative law for disjunction
≡TνT
≡T
• Note: The above examples can also be done using truth tables.
26
Exercise
Explain, without using a truth table, why (p ∨ q
∨ r) ∧ (¬p ∨¬q ∨¬r) is true when at least one
of p, q, and r is true and at least one is false, but
is false when all three variables have the same
truth value.

27
Solution
The first clause (p V q V r) is true if and only if at least
one of p, q, and r is true. The second clause (¬ p V ¬ q
V ¬ r) is true if and only if at least one of the three
variables is false. Therefore both clauses are true, and
therefore the entire statement is true, if and only if
there is at least one T and one F among the truth values
of the variables, in other words, that they don't all have
the same truth value.

28
Exercise-1

“You cannot ride the roller coaster if you are under 4 feet
tall unless you are older than 16 years old.”

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.

29
Exercise-2
• 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 V ¬f).

30
Exercise-3
Let p and q be the propositions “Swimming at
the New Jersey shore is allowed” and “Sharks
have been spotted near the shore,” respectively.
Express each of these compound propositions as
an English sentence.
a) ¬q b) p ∧ q c) ¬p ∨ q
d) p →¬q e) ¬q → p f ) ¬p →¬q
g) p ↔¬q h) ¬p ∧ (p∨ ¬q)

31
Exercise-4
Construct a truth table for each of these
compound propositions.

a) (p ∨ q) → (p ⊕ q) b) (p ⊕ q) → (p ∧ q)
c) (p ∨ q) ⊕ (p ∧ q) d) (p ↔ q) ⊕ (¬p ↔ q)
e) (p ↔ q) ⊕ (¬p ↔¬r)
f ) (p ⊕ q) → (p ⊕¬q)

32
Exercise-5
A father tells his two children, a boy and a girl, to play in their
backyard without getting dirty. However, while playing, both
children get mud on their foreheads. When the children stop
playing, the father says “At least one of you has a muddy
forehead,” and then asks the children to answer “Yes” or “No”
to the question: “Do you know whether you have a muddy
forehead?”

The father asks this question twice. What will the children
answer each time this question is asked, assuming that a child
can see whether his or her sibling has a muddy forehead, but
cannot see his or her own forehead? Assume that both
children are honest and that the children answer each
question simultaneously.
33
Exercise-6
In an island that has two kinds of inhabitants,
knights, who always tell the truth, and their
opposites, knaves, who always lie.
You encounter two people A and B. What are A
and B if A says “B is a knight” and B says “The
two of us are opposite types?”

34
Logical Identities

35
Exercise 7
• Prove Absorption law
• Show that (p ∧ q) V (p ∧ ¬ q) ≡ p
• Show that (p → q) ∧ (r → q) ≡ (p v r) → q

36
Normal Forms
◼ Well formed formula (wff) – also called
formula, is a string consists of propositional variables,
connectives, and parenthesis used in the proper
manner. E.g. ((p  q)  ( p  r))
◼ pqr is a disjunction expression, and pq 
r is a conjunction expression.
◼ Product for conjunction, sum for disjunction.

◼ An elementary product (sum)is a product (sum)


of the variables and their negations in a formula.
◼ An elementary sum is a disjunction of literals.

37
Disjunctive/Conjunctive Normal
Form
◼ Disjunctive normal form (DNF) – a formula
which is equivalent to a given formula and
consists of a sum of elementary products
◼ E.g. (p →q)  q ≡ (p  q)  (q  q) is in
DNF.
◼ Conjunctive normal form (CNF) - a formula
which is equivalent to a given formula and
consists of a product of elementary sums
◼ E.g (p →q)  q ≡ (p  q)  q is in CNF.
38
Construction to obtain a
Disjunctive normal form
• Step 1 Eliminate → and ↔ using logical
identities.
• Step 2 Use DeMorgan's laws to eliminate ¬
before sums or products.
• The resulting formula has ¬ only before the
propositional variables, i.e. it involves sum,
product and literals.
• Step 3 Apply distributive laws repeatedly to
eliminate the product of sums.
39
Exercise
• Obtain a disjunctive normal form of :
• p v (¬ p → (q v (q → ¬ r)))
• (p ∧ ¬ (q ∧ r)) v (p → q)

40
Construction to obtain a
Conjunctive normal form
• To obtain the conjunctive normal form of p,
we construct the disjunctive normal form of
¬ p and use negation.

41
Exercise
• Obtain a conjunctive normal form of :
• p ↔(q v r)
• ¬(¬(p v ¬q)) ∧ ¬(p v q)

42
Satisfiability

43
Semantic Tableaux
• The method of semantic tableaux is an
efficient decision procedure for satisfiability in
propositional logic
• Theorem: A set of literals is satisfiable if and
only if it does not contain a complementary
pair of literals.

44
A = p ∧ (¬q ∨¬p)

• The principal operator of A is conjunction, so interpretation I


(A) = T if and only if both I (p) = T and I (¬q ∨¬p) = T .
• The principal operator of ¬q ∨¬p is disjunction, so I (¬q
∨¬p) = T if and only if either I (¬q) = T or I (¬p) = T .
• Integrating the information we have obtained from this
analysis, we conclude that I (A) = T if and only if either:
1. I (p) = T and I (¬q) = T , or
2. I (p) = T and I (¬p) = T

• A is satisfiable if and only if there is an interpretation such


that (1) holds or an interpretation such that (2) holds.

45
46
B = (p ∨ q) ∧ (¬p∧¬q)

47
Exercise
1. Is the implication (p ∧ (p →¬ q)) v (q →¬ q)
→¬ q a tautology?
2. Determine using semantic tableaux method
whether each of these compound propositions
is satisfiable.
• p→(q∨ ¬p)
• ((p ∨q) →r) →s
• (p ∨¬q) ∧ (¬p ∨ q) ∧ (¬p ∨¬q)
• (p → q) ∧ (p →¬q) ∧ (¬p → q) ∧ (¬p →¬q)
• (p ↔ q) ∧ (¬p ↔ q) 48
Horn formulas
A formula F is a Horn formula if it is in CNF and
every disjunction contains at most one positive
literal.
The conjunction of two Horn formulas is again a
Horn formula.

A ∧ (¬A ∨ ¬B ∨ C) ∧ (¬B ∨ D) ∧ (¬C ∨ ¬D)

49
Basic Horn formula

A basic Horn formula is a Horn formula that


does not use ∧.
Types of basic Horn Formulas:
• No positive literal
• No negative literal
• Both a positive literal and negative literals

50
Basic Horn formula
If a basic Horn formula contains no positive
literal, then it can be written as an implication
involving a contradiction
• (¬B ∨¬D) is equivalent to (B ∧ D) →⊥, where ⊥ is a
contradiction
If a basic Horn formula contains no negative
literals, then it is an atomic formula
• Atomic formula A is equivalent to T → A, where T is a
tautology

51
Horn algorithm
• Step 1: Mark each atomic formula A in the list that is in a sub-
formula of the form (T → A).
• Step 2: If there is a sub-formula of the form (A1∧A2∧・ ・ ・
∧Am) → C where each Ai has been marked and C has not been
marked, then mark C. Repeat this step until there are no sub-
formulas of this form and then proceed to step 3.
• Step 3: Consider the sub-formulas of the form (A1 ∧ A2∧ ・ ・
・ ∧Am) →⊥. If there exists such a sub-formula where each Ai
has been marked, then conclude “No, H is not satisfiable.”
Otherwise, conclude “Yes, H is satisfiable.”

52
Exercise
Check the satisfiability of the following using
Horn algorithm
• (T → A) ∧ (C → D) ∧ ((A ∧ B) → C) ∧ ((C ∧ D) →⊥) ∧ (T → B)
• A ∧ (¬A ∨ ¬B ∨ C) ∧ (¬B ∨ D) ∧ (¬C ∨ ¬D)
• (T → A) ∧ ((A ∧ B) → C) ∧ (B → D) ∧ ((C ∧ D) →⊥)

53
Exercise
Freedonia has fifty senators. Each senator is
either honest or corrupt. Suppose you know
that at least one of the Freedonian senators is
honest and that, given any two Freedonian
senators, at least one is corrupt. Based on these
facts, can you determine how many Freedonian
senators are honest and how many are corrupt?
If so, what is the answer?

54
Exercise
When three professors are seated in a
restaurant, the hostess asks them: “Does
everyone want coffee?” The first professor says:
“I do not know.” The second professor then says:
“I do not know.” Finally, the third professor says:
“No, not everyone wants coffee.” The hostess
comes back and gives coffee to the professors
who want it. How did she figure out who
wanted coffee?
55
Entailment
• Inference: The process of deriving new
sentences from old one is called inference.
Example:
p: The sky is blue; Inference: The Sun is shining
q: It is raining; Inference: There are clouds in the
sky
• Entailment (╞ ) is defined as any true
inference from a true proposition.
56
Entailment
p: Brutus killed Ceaser
q: Ceaser dies

p: All dogs are purple


q: My dog is purple

Then, p╞ q
p╞ q iff p=T and q=T
57
Entailment test
Step1: Take any proposition p
Step2: Assume any proposition q such that p╞ q
Step3: Make negation of q (¬q)
Step4: Perform p ∧ ¬q
Step5: If the result is a contradiction then p╞ q
else p⊭q

58
Example 1
p: All dogs are purple
q: My dog is purple
¬q: My dog is not purple
p ∧ ¬q: All dogs are purple and my dog is not
purple

Here, p ∧ ¬q is a contradiction, therefore p╞ q

59
Example 2
p: All dogs are purple
q: My dog likes cats
¬q: My dog does not like cats
p ∧ ¬q: All dogs are purple and my dog does
not like cats

Here, p ∧ ¬q is a not contradiction, therefore


p⊭q
60
Entailment Relations
• Paraphrase: p╞ q and q╞ p
p: John is a man; q: John is male
• Contradiction: p╞ ¬ q
p: John is a man; q: John is female
• Inclusion: p╞ q
p: John is a man; q: John is human

61
Soundness and completeness
• Soundness: A logic is said to be sound if it
produces only true statement. Formally a logic
is sound iff p is a subset of T.

• Completeness: A logic is said to be complete if


it produces all true statements. Formally a
logic is complete iff T is a subset of p.

62
Rules of Inference
Argument in propositional logic
• An argument (in propositional logic) is a sequence of propositions that
ends with a conclusion

• All but the final proposition are called premises

• The last proposition is the conclusion

• The argument is valid iff the truth of all premises implies the conclusion
is true

• An argument form is a sequence of compound propositions

• 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
Valid Arguments in Propositional
Logic
Is this a valid argument?

If you listen you will hear what I’m saying


You are listening
Therefore, you hear what I am saying

Let p represent the statement “you listen”


Let q represent the statement “you hear what I am saying”

p→q
The argument has the form: p
q
Valid Arguments in Propositional
Logic
p→q
p
q

((p →q) ∧ p) →q is a tautology


The rules of inference
Rule of inference Tautology Name
p→q
p [ p  ( p → q)] → q Modus ponens
q
q
p→q [q  ( p → q)] → p Modus tollen
 p
p→q
q→r [( p → q )  (q → r )] → ( p → r ) Hypothetic al syllogism
p→r
pq
p (( p  q )  p ) → q Disjunctiv e syllogism
q
p
p → ( p  q) Addition
pq
pq
( p  q) → p Simplifica tion
p
p
q (( p)  (q )) → ( p  q ) Conjunctio n
pq
pq
p  r [( p  q )  (p  r )] → ( p  r ) Resolution
q  r
Valid Arguments and correct
conclusion

Suppose that the conditional statement “If it snows today,


then we will go skiing” and its hypothesis, “It is snowing
today,” are true.

Then, by modus ponens, it follows that the conclusion of


the conditional statement, “We will go skiing,” is true.
Valid Arguments and incorrect
conclusion

Determine whether the argument given here is valid and determine


whether its conclusion must be true because of the validity of the
argument.

69
Exercise
• State which rule of inference is the basis of the following argument: “It is
below freezing now. Therefore, it is either below freezing or raining now.”

• State which rule of inference is the basis of the following argument: “It is
below freezing and raining now. Therefore, it is below freezing now.”

• State which rule of inference is used in the 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.”

70
Exercise
• Show that the premises “It is not sunny this afternoon and it is colder than
yesterday,” “We will go swimming only if it is sunny,” “If we do not go
swimming, then we will take a canoe trip,” and “If we take a canoe trip, then
we will be home by sunset” lead to the conclusion “We will be home by
sunset.”

71
72
Exercise
• Show that the premises “If you send me an e-mail message, then I will finish
writing the program,” “If you do not send me an e-mail 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.”

• Use rules of inference to show that the hypotheses “Randy works hard,” “If
Randy works hard, then he is a dull boy,” and “If Randy is a dull boy, then he
will not get the job” imply the conclusion “Randy will not get the job.”

• Use rules of inference to show that the hypotheses “If it does not rain or if it
is not foggy, then the sailing race will be held and the lifesaving
demonstration will go on,” “If the sailing race is held, then the trophy will be
awarded,” and “The trophy was not awarded” imply the conclusion “It
rained.”

73
74

Вам также может понравиться