Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

Introduction to

Discrete
Structures

Tahir Iqbal Bahria


University Lahore
Campus
1
Propositional Logic – Precedence

➢ Precedence of Logical Operators: Operator Precedence


¬ 1
p p p  p p  p Λ 2
ν 3
F T T F
→ 4
T F T F
↔ 5
➢ A compound proposition that is:
(1) always true is called a tautology
(2) always false is called a contradiction
(3) neither a tautology nor a contradiction is called
contingency or satisfiable.
Tahir Iqbal Bahria University 2
Lahore Campus
Propositional Logic – Compound
Propositions
➢ Construct truth table for (p  q) → (p  q).
p q q p  q p  q (p  q) → (p  q)
F F T T F F
T F T T F F
F T F F F T
T T F T T T

➢ Q3: Construct truth table for


➢ (p  q) ↔ (p  q).
➢ (p ⊕ q) → (p ⊕ q).

Tahir Iqbal Bahria University 3


Lahore Campus
Propositional Equivalences – Logical
Equivalences
➢ Equivalence: The compound propositions p and q are
logically equivalent if p↔q is a tautology. In other
words, p and q are logically equivalent if their truth
tables are the same. We write p  q.
➢ Example: (p  q)  p  q.
➢ Truth tables for (p  q) and p  q :

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

Tahir Iqbal Bahria University 4


Lahore Campus
Propositional Equivalences – Logical
Equivalences
➢ Example: p → q  p  q.
➢ Truth tables for p → q and p  q:

p q p→q p p  q
F F T T T
T F F F F
F T T T T
T T T F T

➢ Q4: Show that p  (q  r)  (p  q)  (p  r)

Tahir Iqbal Bahria University 5


Lahore Campus
Propositional Equivalence – Prove the
following Logical Equivalences
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
p ν ¬p  T and p Λ ¬p  F
Tahir Iqbal Bahria University Negation laws 6
Lahore Campus
Propositional Equivalence – Prove the
following Logical Equivalences

Tahir Iqbal Bahria University 7


Lahore Campus
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”

Tahir Iqbal Bahria University 8


Lahore Campus
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”
➢ Q5: 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”
Tahir Iqbal Bahria University 9
Lahore Campus
Propositional Equivalences – Logic and
Bit Operations
➢ Bit: A bit is a symbol with two possible values,
namely, 0 (zero) and 1 (one).
➢ A bit can be used to represent a truth value as 1 for
T and 0 for F
➢ Bit string: A bit string is a sequence of bits. The
length of the string is number of bits in the string.
➢ Example: 10101001 is a bit string of length eight
➢ We define the bitwise OR, AND, and XOR of two
strings of same length to be the strings that have as
their bits the OR, AND, and XOR of the
corresponding bits in the two strings, respectively.
➢ We use the symbols , , and ⊕ to represent bitwise
OR, AND, and XOR, respectively.
Tahir Iqbal Bahria University 10
Lahore Campus
Propositional Equivalences – Logic and
Bit Operations
➢ Truth table for bitwise OR, AND, and XOR:
xy xy x⊕
x y
y
0 0 0 0 0
0 1 1 0 1
1 0 1 0 1
1 1 1 1 0

➢ Q6: Find bitwise OR, AND, and XOR of the bit


strings
➢ 01 0011 0100 and 10 1001 0101
➢ 00 1011 1010 and 11 1010 0101
➢ 11 0101 0110 and 10 1101 0010
Tahir Iqbal Bahria University 11
Lahore Campus

You might also like