You are on page 1of 58

Discrete Structures

Prepositional Logic 2

Prof. Engr. Mohsin Riaz

1
Recap
• Truth table:
A truth table displays the relationship between
the truth values of propositions. A table has 2𝑛
rows where 𝑛 is number of proposition variables.

• Exclusive or: ⊕
𝑝 ⊕ 𝑞 is true when exactly one of 𝒑 and 𝒒 is true
and is false otherwise.

• Exercise:
Draw a truth table of (𝑝 ⊕ 𝑞) ∨ (𝑝 ⇒ 𝑞)
2
Special Definitions
𝒑→𝒒

Inverse:¬𝒑 → ¬𝒒

Converse: 𝒒 → 𝒑

Contrapositive: ¬𝒒 → ¬𝒑

3
Example
Pakistani team wins whenever it is raining
p: It is raining
q: Pakistani team wins
q whenever p ≡ if p, then q (𝑝 → 𝑞)
If it is raining, then Pakistani team wins.
Inverse:¬𝒑 → ¬𝒒
If it isn’t raining, then Pakistani team doesn’t win.
Converse : 𝒒 → 𝒑
If Pakistani team wins, then it is raining.
Contrapositive: ¬𝒒 → ¬𝒑
If Pakistani team doesn’t win, then it isn’t raining.
4
Conditional Inverse Converse Contrapositive

𝑝 𝑞 𝑝 𝑞 𝑝𝑞 𝑝  𝑞 𝑞 → 𝑝 𝑞  𝑝

𝑇 𝑇 𝐹 𝐹 𝑇 𝑇 𝑇 𝑇
𝑇 𝐹 𝐹 𝑇 𝐹 𝑇 𝑇 𝐹
𝐹 𝑇 𝑇 𝐹 𝑇 𝐹 𝐹 𝑇
𝐹 𝐹 𝑇 𝑇 𝑇 𝑇 𝑇 𝑇

5
• Conditional ≡ Contrapositive
• 𝑝 → 𝑞 ≡ ¬𝑞 → ¬𝑝

• Inverse ≡ Converse
• ¬𝑝 → ¬𝑞 ≡ 𝑞 → 𝑝

6
Biconditionals
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.
7
Truth Table

• p ↔ q has exactly the same truth value as


(p → q) ∧ (q → p)
8
Common ways to express p ↔ q
• “p is necessary and sufficient for q”
• “if p then q, and conversely”
• “p iff q”

9
Example

p: “You can take the flight”


q: “You buy a ticket”
p ↔ q:

You can take the flight if and only if you buy a ticket

You can take the flight iff you buy a ticket

The fact that you can take the flight is necessary


and sufficient for buying a ticket
10
p: You can take flight
q: You buy a ticket
𝑝↔𝑞
You can take flight if and only if you buy a ticket
What is the truth value when:
• you buy a ticket and you can take the flight ??
• 𝑇↔𝑇≡𝑇
• you don’t buy a ticket and you can’t take the flight ??
• 𝐹↔𝐹≡𝑇
• you buy a ticket but you can’t take the flight ??
• 𝑇↔𝐹≡𝐹
• you can’t buy a ticket but can take the flight ??
• 𝐹↔𝑇≡𝐹
11
Precedence of Logical Operators

(𝑝 ⊕ 𝑞) ∨ (𝑝 ⇒ 𝑞)

Can be written as

(𝑝 ⊕ 𝑞) ∨ 𝑝 ⇒ 𝑞

(T/F) ?
¬𝑎 ∧ 𝑏 𝑎∧𝑏∧𝑐
𝑎∨𝑏 ⇔𝑏∨𝑎 𝑎∨𝑏∨𝑐
𝑎∧𝑏∨𝑐
12
Exercise:
For which values of a, b and c one
gets 0 in the truth table of
𝑎 ∧ 𝑏 ⇒ 𝑐 ⇒ ( 𝑏 ⇒ 𝑎 ∧ 𝑐)

13
Logic and Bit Operations
• Boolean values can be represented as 1 (true)
and 0 (false)
• A bit string is a series of Boolean values. Length of
the string is the number of bits.
– 10110100 is eight Boolean values in one string
• We can then do operations on these Boolean
strings
– Each column is its own
boolean operation
14
1.2 Applications of Propositional Logic
• Translating English sentences (Formalization)
• System Specifications
• Boolean Searches
• Logic circuits
• …

15
Translating English Sentences
• You can access the Internet from campus only if
you are a computer science major or you are not
a freshman.
𝒂: You can access the Internet from campus
𝒄: You are a computer science major
𝒇: you are a freshman

𝒂 → (𝒄 ∨ ¬𝒇)

16
• You cannot ride the roller coaster if you are
under 4 feet tall unless you are older than 16
years old.
𝑟: you can ride roller coaster
𝑓 ∶ you are under 4 feet
𝑜 ∶ you are older than 16 years old
𝑓 ∧ ¬𝑜 → ¬𝑟

17
System Specifications
• The automated reply cannot be sent when the
file system is full
p: The automated reply can be sent
q: The system is full
𝑞 ⟶ ¬𝑝

18
Consistency
• System specifications should be consistent,
– They should not contain conflicting
requirements that could be used to derive a
contradiction
• When specifications are not consistent, there
would be no way to develop a system that
satisfies all specifications

19
Determine whether these system specifications are
consistent:
1. The diagnostic message is stored in the buffer or
it is retransmitted.
2. The diagnostic message is not stored in the
buffer.
3. If the diagnostic message is stored in the buffer,
then it is retransmitted.

20
Determine whether these system specifications are
consistent:
1. The diagnostic message is stored in the buffer or
it is retransmitted.
2. The diagnostic message is not stored in the
buffer.
3. If the diagnostic message is stored in the buffer,
then it is retransmitted.
p: The diagnostic message is stored in the buffer
q: The diagnostic message is retransmitted
1. 𝒑 ∨ 𝒒 2. ¬𝒑 3. 𝒑 → 𝒒
21
1. 𝒑 ∨ 𝒒 2. ¬𝒑 3. 𝒑 → 𝒒
Reasoning
• An assignment of truth values that makes all three
specifications true must have p false to make ¬𝑝
true.
• Because we want 𝑝 ∨ 𝑞 to be true but 𝑝 must be
false, q must be true.
• Because 𝑝 → 𝑞 is true when 𝑝 is false and 𝑞 is
true
• we conclude that these specifications are
consistent
• Let us do it with truth table now 22
• Is it remain consistent if the specification
“The diagnostic message is not retransmitted” is
added?
p: The diagnostic message is stored in the buffer
q: The diagnostic message is retransmitted
1. 𝒑 ∨ 𝒒 2. ¬𝒑 3. 𝒑 → 𝒒

23
• Is it remain consistent if the specification
“The diagnostic message is not retransmitted” is
added?
p: The diagnostic message is stored in the buffer
q: The diagnostic message is retransmitted
1. 𝒑 ∨ 𝒒 2. ¬𝒑 3. 𝒑 → 𝒒
4. ¬𝒒

Inconsistent
24
Boolean Searches
• Logical connectives are used extensively in
searches of large collections of information,
such as indexes of Web pages.

• Because these searches employ techniques


from propositional logic, they are called
Boolean searches.

25
• Finding Web pages about universities in New
Mexico:
• New AND Mexico AND Universities
– ‘New Mexico’ Universities
– New Universities in Mexico
• “New Mexico” AND Universities

• (New AND Mexico OR Arizona) AND Universities


– ‘New Mexico’ Universities
– Arizona Universities
• (Mexico AND Universities) NOT New
26
Quiz

• Let x = “‫”لڑک‬
Then x + “‫لڑکا = ”ا‬
Write Boolean search capturing this pattern

27
Logic Puzzles
• An island has two kinds of inhabitants,
– Knights, who always tell the truth
– Knaves, who always lie.
• You encounter two people A and B.
• What are A and B if
– A says “B is a knight”
– B says “The two of us are opposite types?

28
– A says “B is a knight”
– B says “The two of us are opposite types?
p: A is a knight ¬𝑝: A is a knave
q: B is a knight ¬𝑞: B is a knave

29
– A says “B is a knight”
– B says “The two of us are opposite types?
p: A is a knight ¬𝑝: A is a knave
q: B is a knight ¬𝑞: B is a knave
First possibility:
A is a knight; that is p is true.

30
– A says “B is a knight”
– B says “The two of us are opposite types?
p: A is a knight ¬𝑝: A is a knave
q: B is a knight ¬𝑞: B is a knave
First possibility:
A is a knight; that is p is true.
• If A is a knight, then he is telling the truth when he
says that B is a knight, so that q is true, and A and B
are the same type (both knight).
• But, if B is a knight, then B’s statement that A and B
are of opposite types (p ∧¬q) ∨ (¬p ∧ q), have to
be true. But it is not; because A and B are both
knights. Not consistent.
• Conclusion: A is not a knight (p is false). 31
– A says “B is a knight”
– B says “The two of us are opposite types?
p: A is a knight ¬𝑝: A is a knave
q: B is a knight ¬𝑞: B is a knave
Second possibility:
A is a knave; that is p is false.
• If A is a knave, then he is telling lie when he says
that B is a knight. So B is knave (q is false).
• Also when B says that A and B are of opposite
types (p ∧¬q) ∨ (¬p ∧ q), he again lies.
• Conclusion: A and B are both knaves.
32
Logic Circuits
• Propositional logic can be applied to the design
of computer hardware
• A logic circuit (or digital circuit) receives input
signals 𝑝1 , 𝑝2 , . . . , 𝑝𝑛 , each a bit [either 0 (off) or
1 (on)], and produces output signals
𝑠1 , 𝑠2 , . . . , 𝑠𝑛 , each a bit.

33
Quiz: Draw 𝒑 ∧ ¬𝒒 ∨ ¬𝒓

34
Quiz: Draw 𝒑 ∧ ¬𝒒 ∨ ¬𝒓

35
1.3 Propositional Equivalence

• An important type of step used in a mathematical


argument is the replacement of a statement with
another statement with the same truth value

• Propositional Equivalence is extensively used in


the construction of mathematical arguments.

36
Tautology and Contradiction
• A compound proposition which is always true,
is called tautology. For example, ¬𝑝 ∨ 𝑝, 𝑎
⇒ 𝑎, 𝑎 ⇒ (𝑏 ⇒ 𝑎)

• A compound proposition which is always


false, is called contradiction. For example, ¬𝑝
∧ 𝑝, ¬(𝑎 ⇒ 𝑎), 𝑎 ∧ 𝑏 ∧ ¬𝑎

37
Example on notebook:
𝑎 ⇒ (𝑏 ⇒ 𝑎)
𝑎⇒𝑎
38
Logical Equivalences
• Compound propositions that have the same truth
values in all possible cases are called logically
equivalent.

• 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.
39
• Show that ¬ 𝑝 ∨ 𝑞 ≡ ¬𝑝 ∧ ¬𝑞

40
Standard equivalences
Identity
•𝑝 ∧ 𝑻 ≡ 𝑝
•𝑝 ∨ 𝑭 ≡ 𝑝

Domination
•𝑝 ∨ 𝑻 ≡ 𝑻
•𝑝 ∧ 𝑭 ≡ 𝑭
41
Standard equivalences
Idempotence
• 𝑝∧𝑝≡𝑝
• 𝑝∨𝑝≡𝑝

Double Negation
• ¬¬𝑝 ≡ 𝑝
42
Standard Equivalences

Commutative law:
•𝑝∧𝑞 ≡𝑞∧𝑝
•𝑝∨𝑞 ≡𝑞∨𝑝
•𝑝⇔𝑞≡𝑞⇔𝑝

43
Standard equivalences
Associativity
• 𝑝∧𝑞 ∧𝑟 ≡𝑝∧ 𝑞∧𝑟
• 𝑝∨𝑞 ∨𝑟 ≡𝑝∨ 𝑞∨𝑟
• 𝑝 ⇔ 𝑞 ⇔ 𝑟 ≡ 𝑝 ⇔ (𝑞 ⇔ 𝑟)

44
Standard equivalences
• Inversion
¬𝑇 ≡ 𝐹
¬𝐹 ≡ 𝑇
• Negation
¬𝑝 ≡ (𝑝 ⇒ 𝐹)

• Contradiction
𝑝 ∧ ¬𝑝 ≡ 𝐹

45
Distributive Law

•𝑝∧ 𝑞∨𝑟 ≡ 𝑝∧𝑞 ∨ 𝑝∧𝑟


•𝑝∨ 𝑞∧𝑟 ≡ 𝑝∨𝑞 ∧ 𝑝∨𝑟

46
47
De Morgan’s Law

• ¬ 𝑝 ∧ 𝑞 ≡ ¬𝑝 ∨ ¬𝑞
• ¬(𝑝1 ∧ 𝑝2 ∧ · · · ∧ 𝑝𝑛 ) ≡ (¬𝑝1 ∨ ¬𝑝2 ∨ ··· ∨ ¬𝑝𝑛 )

• ¬ 𝑝 ∨ 𝑞 ≡ ¬𝑝 ∧ ¬𝑞
• ¬ (𝑝1 ∨ 𝑝2 ∨ · · · ∨ 𝑝𝑛 ) ≡ (¬𝑝1 ∧ ¬𝑝2 ∧ ··· ∧ ¬𝑝𝑛 )

48
Generalization
𝑛
• 𝑖=1 𝑝𝑖 𝑐𝑎𝑛 𝑏𝑒 𝑢𝑠𝑒𝑑 𝑓𝑜𝑟 𝑝1 ∧ 𝑝2 ∧ ⋯ ∧ 𝑝𝑛
𝑛
• 𝑖=1 𝑝𝑖 𝑐𝑎𝑛 𝑏𝑒 𝑢𝑠𝑒𝑑 𝑓𝑜𝑟 𝑝1 ∨ 𝑝2 ∨ ⋯ ∨ 𝑝𝑛

De Morgan’s Laws
𝑛 𝑛
• ¬ 𝑖=1 𝑝𝑖 ≡ 𝑖=1 ¬𝑝𝑖
𝑛 𝑛
• ¬( 𝑖=1 𝑝𝑖 ) ≡ 𝑖=1 ¬𝑝𝑖
49
50
Absorption laws

• 𝑝 ∨ (𝑝 ∧ 𝑞) ≡ 𝑝
•𝑝 ∧ 𝑝 ∨ 𝑞 ≡ 𝑝

51
Negation laws

• 𝑝 ∨ ¬𝑝 ≡ 𝑻
• 𝑝 ∧ ¬𝑝 ≡ 𝑭

52
Implication
• 𝑝 ⇒ 𝑞 ≡ ¬𝑝 ∨ 𝑞
• 𝑝 ∨ 𝑞 ≡ ¬𝑝 ⇒ 𝑞

53
More Implication Laws

• 𝑝 → 𝑞 ≡ ¬𝑞 → ¬𝑝
• 𝑝 ∧ 𝑞 ≡ ¬(𝑝 → ¬𝑞)
• ¬(𝑝 → 𝑞) ≡ 𝑝 ∧ ¬𝑞
• (𝑝 → 𝑞) ∧ (𝑝 → 𝑟) ≡ 𝑝 → (𝑞 ∧ 𝑟)
• (𝑝 → 𝑟) ∧ (𝑞 → 𝑟) ≡ (𝑝 ∨ 𝑞) → 𝑟
• (𝑝 → 𝑞) ∨ (𝑝 → 𝑟) ≡ 𝑝 → (𝑞 ∨ 𝑟)
• (𝑝 → 𝑟) ∨ (𝑞 → 𝑟) ≡ (𝑝 ∧ 𝑞) → 𝑟
54
Bi-implications
• 𝑝 ↔ 𝑞 ≡ (𝑝 → 𝑞) ∧ (𝑞 → 𝑝)
• 𝑝 ↔ 𝑞 ≡ ¬𝑝 ↔ ¬𝑞
• 𝑝 ↔ 𝑞 ≡ (𝑝 ∧ 𝑞) ∨ (¬𝑝 ∧ ¬𝑞)
• ¬(𝑝 ↔ 𝑞) ≡ 𝑝 ↔ ¬𝑞

55
Using Logical Equivalence

• Show that ¬(𝑝 → 𝑞) and 𝑝 ∧ ¬𝑞 are logically


equivalent.

• Show that ¬(𝑝 ∨ (¬𝑝 ∧ 𝑞)) and ¬𝑝 ∧ ¬𝑞 are


logically equivalent by developing a series of
logical equivalences.

• Prove that (𝑝 ∧ 𝑞) ⇒ (𝑝 ∨ 𝑞) is a tautology.


56
Using Logical Equivalence
Ex: Prove that 𝑝 ∧ 𝑞 ⇒ (𝑝 ∨ 𝑞) is a tautology.
To show that this statement is a tautology, we will use
logical equivalences to demonstrate that it is logically
equivalent to T
𝑝 ∧ 𝑞 → 𝑝 ∨ 𝑞
≡¬ 𝑝 ∧ 𝑞 ∨ 𝑝 ∨ 𝑞 Implication equivalence
≡ ¬𝑝 ∨ ¬𝑞 ∨ 𝑝 ∨ 𝑞 1st De Morgan law
≡ ¬𝑝 ∨ (¬𝑞 ∨ 𝑝 ∨ 𝑞 ) Associative law
≡ ¬𝑝 ∨ (𝑝 ∨ ¬q ∨ 𝑞 ) Commutative law
≡ (¬𝑝 ∨ 𝑝) ∨ ¬q ∨ 𝑞 Associative law
≡𝑇∨𝑇 Tautologies
≡𝑇 Idempotence
57
Do Exercises

58

You might also like