0% found this document useful (0 votes)
63 views41 pages

Department of Computer Science, CUI Lahore Campus: CSC102 - Discrete Structures by Mahwish Waqas

The document outlines a lecture on discrete structures, covering: 1. Applications of propositional logic such as translating English sentences to logic, system specifications, and logic circuits. 2. The relationship between logic and bit operations in computing, where bits represent true and false values. 3. Logical equivalence and how statements can be replaced with logically equivalent statements while preserving truth values.

Uploaded by

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

Department of Computer Science, CUI Lahore Campus: CSC102 - Discrete Structures by Mahwish Waqas

The document outlines a lecture on discrete structures, covering: 1. Applications of propositional logic such as translating English sentences to logic, system specifications, and logic circuits. 2. The relationship between logic and bit operations in computing, where bits represent true and false values. 3. Logical equivalence and how statements can be replaced with logically equivalent statements while preserving truth values.

Uploaded by

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

Department Of Computer Science, CUI

Lahore Campus
CSC102 - Discrete Structures
By
Mahwish Waqas
9/27/2020 CSC102 - Discrete Structures 2

Lecture Outline
• Applications of Propositional Logic
• Logic and Bit Operations
• Logical Equivalence
9/27/2020 CSC102 - Discrete Structures 3

Applications of Propositional Logic


• Translating English sentences (Formalization)
• System Specifications
• Boolean Searches
• Logic circuits
9/27/2020 CSC102 - Discrete Structures 4

Translating English Sentences

• Steps to convert an English sentence to a statement in


propositional logic
• Identify atomic propositions and represent using
propositional variables.
• Determine appropriate logical connectives
9/27/2020 CSC102 - Discrete Structures 5

Translating English Sentences


• “I have neither given nor received help on this exam”
Let p = I have given help on this exam
q = I have received help on this exam

• Rephrase: It is not the case that either I have given or


received help on this exams
9/27/2020 CSC102 - Discrete Structures 6

Translating English Sentences


• “I have neither given nor received help on this exam”
Let p = I have given help on this exam
q = I have received help on this exam
¬p ¬q

• Rephrase: It is not the case that either I have given or


received help on this exams

¬(p ∨ q)
9/27/2020 CSC102 - Discrete Structures 7

Translating English Sentences


• “If I go to Harry’s or to the country, I will not go shopping.”
9/27/2020 CSC102 - Discrete Structures 8

Translating English Sentences


• “If I go to Harry’s or to the country, I will not go shopping.”

• Let p = I go to Harry’s
• q = I go to the country.
• r = I will go shopping.
9/27/2020 CSC102 - Discrete Structures 9

Translating English Sentences


• “If I go to Harry’s or to the country, I will not go shopping.”

• Let p = I go to Harry’s
• q = I go to the country.
• r = I will go shopping.

• If p or q then not r
(p ∨ q) → ¬r
9/27/2020 CSC102 - Discrete Structures 10

Translating English Sentences


• Let p = It is below freezing
q = It is snowing
a) It is below freezing and it is snowing
b) It is below freezing but not snowing
c) It is not below freezing and it is not snowing
d) It is either snowing or below freezing (or both)
e) If it is below freezing, it is also snowing
f) It is either below freezing or it is snowing (not both), but it
is not snowing if it is below freezing
g) That it is below freezing is necessary and sufficient for it to
be snowing
9/27/2020 CSC102 - Discrete Structures 11

Translating English Sentences


• “You can access the Internet from campus only if you are
a computer science major or you are not a freshman.”
9/27/2020 CSC102 - Discrete Structures 12

Translating English Sentences


• “You can access the Internet from campus only if you are
a computer science major or you are not a freshman.”

• Let a = You can access the Internet from campus


c = You are a computer science major
and f = You are a freshman” respectively
9/27/2020 CSC102 - Discrete Structures 13

Translating English Sentences


• “You can access the Internet from campus only if you are
a computer science major or you are not a freshman.”

• Let a = You can access the Internet from campus


c = You are a computer science major
and f = You are a freshman” respectively

• a only if c or not f
a → (c ∨¬f ).
9/27/2020 CSC102 - Discrete Structures 14

Exercise
• Let p and q be the propositions “The election is decided”
and “The votes have been counted,” respectively. Express
each of these compound propositions as an English
sentence.
1. ¬p
2. p ∨ q
3. ¬p ∧ q
4. q → p
5. ¬q → ¬p
6. ¬p → ¬q
7. p ↔ q
8. ¬q ∨ (p ∧ q)
9/27/2020 CSC102 - Discrete Structures 15

System Specifications
• System and Software engineers take requirements in
English and express them in a precise specification
language based on logic.

• The automated reply cannot be sent when the file system


is full
9/27/2020 CSC102 - Discrete Structures 16

System Specifications
• System and Software engineers take requirements in
English and express them in a precise specification
language based on logic.

• The automated reply cannot be sent when the file system


is full
p = The automated reply can be sent
q = The system is full
𝑞 ⟶ ¬𝑝
9/27/2020 CSC102 - Discrete Structures 17

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.

• A list of propositions is consistent if it is possible to


assign truth values to the proposition variables so that
each proposition is true.
9/27/2020 CSC102 - Discrete Structures 18

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.
9/27/2020 CSC102 - Discrete Structures 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.
• p = The diagnostic message is stored in the buffer
• q = The diagnostic message is retransmitted
• 1. 𝒑∨𝒒 2. ¬𝒑 3. 𝒑→𝒒
9/27/2020 CSC102 - Discrete Structures 20

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
9/27/2020 CSC102 - Discrete Structures 21

• 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. 𝒑 → 𝒒
9/27/2020 CSC102 - Discrete Structures 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. 𝒑 → 𝒒
4. ¬𝒒

Inconsistent
9/27/2020 CSC102 - Discrete Structures 23

Logic and Bit Operations


• Computer represents information using bits. A bit
is a symbol with two possible values, namely, 0
(zero) and 1 (one).
• 1 represents T (true) and 0 represents (false).
• A variable is called a Boolean Variable if its value
is either true or false.
• A Boolean Variable can be represented by a bit.
• A bit string is a sequence of zero or more bits.
Length of the string is the number of bits.
• 1 0101 0011 is bit string of length 9.
9/27/2020 CSC102 - Discrete Structures 24

Logic and Bit Operations


• We can then do operations on these bit strings.
• Each column is its own bit operation
9/27/2020 CSC102 - Discrete Structures 25

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.
9/27/2020 CSC102 - Discrete Structures 26

Tautology and Contradiction


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

p ¬p p ∨ ¬p p ∧ ¬p
T F T F
F T T F

• Show that (p ∧ q) → p is a tautology.


9/27/2020 CSC102 - Discrete Structures 27

Logical Equivalence
• 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.
9/27/2020 CSC102 - Discrete Structures 28

Logical Equivalence

p q p→q p q ¬p ¬p  q
T T T T T F T
T F F T F F F
F T T F T T T
F F T F F T T
9/27/2020 CSC102 - Discrete Structures 29

Logical Equivalence
• Converse
The proposition q → p is converse of p → q.

• Contrapositive
The contrapositive of p → q is the proposition ¬q →¬p.

• Inverse
The proposition ¬p →¬q is called the inverse of p → q.
9/27/2020 CSC102 - Discrete Structures 30

Logical Equivalence

Implication Inverse Converse Contrapositive


p q p q p→q p → q q→p q → p
T T F F T T T T
T F F T F T T F
F T T F T F F T
F F T T T T T T
9/27/2020 CSC102 - Discrete Structures 31

Logical Equivalence
Equivalence Name
p∧T≡p Identity laws
p∨F≡p
p∨T≡T Domination laws
p∧F≡F
p∨p≡p Idempotent laws
p∧p≡p
¬(¬p) ≡ p Double negation law
p∨q≡q∨p Commutative laws
p∧q≡q∧p
(p ∨ q) ∨ r ≡ p ∨ (q ∨ r) Associative laws
(p ∧ q) ∧ r ≡ p ∧ (q ∧ r)
p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r) Distribution Laws
p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r)
9/27/2020 CSC102 - Discrete Structures 32

Logical Equivalence

Equivalence Name
¬(p ∧ q) ≡ ¬p ∨¬q De Morgan’s laws
¬(p ∨ q) ≡ ¬p ∧¬q
p ∨ (p ∧ q) ≡ p Absorption laws
p ∧ (p ∨ q) ≡ p
p ∨¬p ≡ T Negation laws
p ∧¬p ≡ F
9/27/2020 CSC102 - Discrete Structures 33

Logical Equivalence
• Distributive: p  (q  r)  (p  q)  (p  r)

p q r q r p  (q  r) (p  q) (p  r) (p  q)  (p 
r)
T T T T T T T T
T T F F T T T T
T F T F T T T T
T F F F T T T T
F T T T T T T T
F T F F F T F F
F F T F F F T F
F F F F F F F F
9/27/2020 CSC102 - Discrete Structures 34

Logical Equivalence involving Implication

Logical Equivalence involving Implication


p → q ≡ ¬p ∨ q
p → q ≡ ¬q →¬p
p ∨ q ≡ ¬p → q
p ∧ q ≡ ¬(p →¬q)
¬(p → q) ≡ p ∧¬q
(p → q) ∧ (p → r) ≡ p → (q ∧ r)
(p → r) ∧ (q → r) ≡ (p ∨ q) → r
(p → q) ∨ (p → r) ≡ p → (q ∨ r)
(p → r) ∨ (q → r) ≡ (p ∧ q) → r
9/27/2020 CSC102 - Discrete Structures 35

Logical Equivalence involving Bi-conditional

Logical Equivalence involving Bi-conditional


p ↔ q ≡ (p → q) ∧ (q → p)
p ↔ q ≡ ¬p ↔¬q
p ↔ q ≡ (p ∧ q) ∨ (¬p ∧¬q)
¬(p ↔ q) ≡ p ↔¬q
9/27/2020 CSC102 - Discrete Structures 36

Proof using Logical Equivalence

• Show that (p  q)  q  p  q is logically equivalent.

(p  q)  q
 (p  q)  q DeMorgan’s
 (p  q)  q Double negation
 p  (q  q) Associative
 p  q Idempotent


9/27/2020 CSC102 - Discrete Structures 37

Proof using Logical Equivalence


Show that (p  q) → q is a Tautology.

Proof:
(p  q) → q
 (p  q)  q Implication
 ( p   q)  q De Morgan
  p  ( q  q) Associative
 p  T Negation
 T Dominations
9/27/2020 CSC102 - Discrete Structures 38

Proof using Logical Equivalence


• Show that [p  (p → q)] → q is a tautology.

[p  (p → q)] → q
 [p  (p  q)] → q Substitution for →
 [(p  p)  (p  q)] → q Distributive
 [ F  (p  q)] → q Negation
 (p  q) → q Identity
 (p  q)  q Substitution for →
 (p  q)  q DeMorgan’s
 p  (q  q ) Associative
 p  T Negation
T Domination
9/27/2020 CSC102 - Discrete Structures 39

Proof using Logical Equivalence


Show that ( p  (p  q ))  p  q is logically equivalent.
L.H .S = ( p  (p  q ))
 p  (p  q ) DeMorgan's Law
 p  ((p )  q ) DeMorgan's Law
 p  ( p   q ) Double Negation Law
 ( p  p )  (  p   q ) Distributive Law
 F  ( p  q ) Negation Law
 ( p  q )  F Commutative Law
 p   q Identity Law
= R.H .S
9/27/2020 CSC102 - Discrete Structures 40

Chapter Reading
• Chapter 1, Kenneth H. Rosen, Discrete Mathematics and
Its Applications, Section 1.2,1.3
9/27/2020 CSC102 - Discrete Structures 41

Chapter Exercise ( For Practice)


• Section 1.2: Question # 1, 2, 3, 4, 7, 8, 9, 10, 11 ,12
• Section 1.3: Question # 1, 6, 7, 8, 9, 10, 11, 12

You might also like