Lecture # 2+3 Ds
Lecture # 2+3 Ds
LECTURE # 2
The Course
Course Title: Discrete structures
Instructor: MUHAMMAD AWAIS
Semester : 1st
Duration: 16 Weeks
Conditional statement
It corresponds to English “if p then q” or “p implies q.”
Conditional: Let p and q be two 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.
Example: If it is raining, then it is cloudy.
p q p→q
If I am elected, then I will lower taxes. T T T
T F F
Truth table for implication: F T T
F F T
Special definitions
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 contrapositive of p → q.
Ex. p → q: “If it is noon, then I am hungry.”
¬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 noon, then I am hungry.”
¬p → ¬q: “If it is not noon, then I am not hungry.”
p → q has same truth values as ¬q → ¬p
Biconditional statement
It corresponds to English “p if and only if q”.
Biconditional: Let p and q be two propositions. The biconditional
statement (bi-implication) 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, otherwise false.
p ↔ q has same truth value as (p→ q) ∧ (q → p).
p q p↔q
Example: p: “You can take the flight”.
q : “You buy a ticket” T T T
T F F
p ↔ q : “You can take the flight F T F
if and only if you buy a ticket” F F T
Propositional logic
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.
Tautologies
A Tautology is a formula which is always true for every value of its
propositional variables.
Example − Prove [ ( A → B ) ∧ A ] → B is a tautology
[ ( A → B ) ∧ A ] → B is tautology.
Contradiction
A Contradiction is a formula which is always false for every value of its
propositional variables.
Example − ( A ∨ B ) ∧ [ ( ¬ A ) ∧ ( ¬ B ) ] is a contradiction
( A ∨ B ) ∧ [ ( ¬ A ) ∧ ( ¬ B ) ] is contradiction.
Contingency
A Contingency is a formula which has both some true and some false
values for every value of its propositional variables.
Example − (A ∨ B) ∧ (¬ A) is a contingency
A B A∨B ¬A (A ∨ B) ∧ (¬ A)
T T T F F
T F T F F
F T T T T
F F F T F
(A ∨ B) ∧ (¬ A) is a contingency.
Propositional logic compound
Construct truth table for (p ∨ ¬q) → (p ∧ q).
p q ¬q p∨ p∧q (p ∨ ¬q) → (p ∧ q)
¬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
Q3. Construct truth table for
1. (p ∨ ¬q) ↔ (p ∧ q).
2. (p ⊕ ¬q) → (p ⊕ q).
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.
Two Types:
•The truth tables of each statement have the same truth values.
¬ (A ∨
A B A∨B ¬A ¬B [(¬ A) ∧ (¬ B)]
B)
T T T F F F F
T F T F F T F
F T T F T F F
F F F T T T T
Biconditional is tautology
Prove ¬(A∨B)and[(¬A)∧(¬B)]are equivalent
Domination laws
p ν T ≡ T and p Λ F ≡ F
Idempotent laws
p ν p ≡ p and p Λ p ≡ p
Commutative laws
p ν q ≡ q ν p and p Λ q ≡ q Λ p
Associative laws
(p ν q) ν r ≡ p ν (q ν r) and (p Λ q) Λ r ≡ p Λ (q Λ r)
Distributive laws
p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r)
p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r)
De Morgan’s laws
¬(p ν q) ≡ ¬p Λ ¬q and ¬(p Λ q) ≡ ¬p ν ¬q
Absorption laws
p ∨ (p ∧ q) ≡ p and p ∧ (p ∨ q) ≡ p
Prove the equivalnces
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”
example
⮚ 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”
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.
Predicates and Quantifiers
⮚ The statements “x > 3”,“x = y + 3”, and “computer x is functioning
properly” are not propositions
⮚ 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?
Existential Quantifiers
⮚ Def: The existential quantification of P(x) is the statement
“There exists an element x in the domain such that P(x)”. The
notation ∃ x P(x) denotes the existential quantification of P(x). Here
∃ is called existential quantifier.
⮚ 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.
Existential quantifiers
⮚ Example: Let P(x) =“x = x+1”. What is the truth value of the
quantification ∃ x P(x), where the domain consists of all real
numbers?
⮚ Sol: Because P(x) is false for every real number x, the
quantification ∃ x P(x) is false.
⮚ 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?