DM Unit 1 Notes
DM Unit 1 Notes
in
1.2.1. Logic
Statements / Propositions
A statement is a declarative sentence which is either true or false but not both. The truth or falsity of a
statement is called its truth value. The truth value of a true statement is denoted by 'T' and the false statement
is denoted by 'F'. They are also denoted by 1 or 0. Statements are usually denoted by A, B, C, ....... or a, b, c
Logical Connectives
Logical connectives are symbols used to combine or modify propositions to form compound statements.
1. Negation ( ~ )
Negation of a proposition p is a statement that reverses the truth value of p.
Truth Table:
p ~p
T F
F T
Example:
If p: “It is raining”
Then ~p: “It is not raining”
2. Conjunction ( ∧ )
Conjunction of two propositions p and q is true only when both p and q are true.
Truth Table:
p q p∧ q
T T T
T F F
F T F
F F F
Example:
p: “Student studied”
q: “Student attended exam”
p ∧ q: “Student studied and attended exam”
3. Disjunction ( ∨ )
Disjunction of two propositions p and q is true if at least one of them is true.
Truth Table:
p q p∨ q
T T T
T F T
F T T
F F F
Example:
p: “Student passed theory”
q: “Student passed practical”
p ∨ q: “Student passed theory or practical”
4. Conditional ( → )
Conditional statement p → q means if p is true, then q must be true.
Truth Table:
p q p→q
T T T
T F F
F T T
F F T
Example:
p: “Student submits assignment”
q: “Student is allowed to appear for exam”
p → q: “If student submits assignment, then student is allowed to appear for exam”
5. Biconditional ( ↔ )
Biconditional statement p ↔ q is true when both p and q have the same truth value.
Truth Table:
p q p↔q
T T T
T F F
F T F
F F T
Example:
p: “Student passes exam”
q: “Student gets certificate”
p ↔ q: “Student passes exam if and only if student gets certificate”
Special Propositions
If p → q is a conditional statement, then
1. q → p is called its converse
2. ~p → q ~ is called its inverse
3. ~ q → ~p is called its contrapositive
Compound Statements
A statement which is formed from primary statements by using logical connectives is called a compound
statement.
e.g. If p : I am studying in SE computer class
q : I am learning discrete structure subject
Example:
Let p denote the statement, "The material is interesting'. q denote the statement, "The exercises are
challenging", and r denote the statement, "The course is enjoyable".
Write the following statements in symbolic form:
i) The material is interesting and exercises are challenging.
ii) The material is interesting means the exercises are challenging and conversely.
iii) Either the material is interesting or the exercises are not challenging but not both.
iv) If the material is not interesting and exercises are not challenging, then the course is not enjoyable.
v) The material is uninteresting, the exercises are not challenging and the course is not enjoyable.
are challenging and course is not
the
Solution:
3. Tautology
A statement formula that is true for all possible values of its propositional variables is called tautology.
Example: 𝑝 ∨ ~𝑝
Truth Table Proof:
p ~p p ∨ ~p
T F T
F T T
4. Contradiction
A statement formula that is false for all possible values of its variables is called a contradiction (or
absurdity).
Example: 𝑝 ∧ ~𝑝
Truth Table Proof:
p ~p p ∧ ~p
T F F
F T F
5. Contingency
A statement formula which is neither a tautology nor a contradiction is called a contingency.
Example: 𝑝 → 𝑞
Truth Table Proof:
p q p→q
T T T
T F F
F T T
F F T
6. Precedence Rule
When brackets are not present, logical connectives are applied in the following order:
1. Negation ~
2. Conjunction ∧
3. Disjunction ∨
4. Conditional →
5. Biconditional ↔
Remark:
• If ∨ and ⊕ (exclusive OR) appear together, apply the leftmost first.
• Same rule applies for → and ↔.
7. Logical Equivalence
Two statement formulas P and Q are said to be logically equivalent if they have the same truth value for
all possible truth values of their variables.
If 𝑃 ↔ 𝑄is a tautology, then P and Q are logically equivalent.
Symbol
• 𝑃≡𝑄
• or 𝑃 ↔ 𝑄(as a tautology)
Examples
1. 𝑝 → 𝑞 ≡ ~𝑝 ∨ 𝑞
2. ~(𝑝 ∧ 𝑞) ≡ ~𝑝 ∨ ~𝑞
8. Logical Identities
Name Identity
Idempotent (∨) 𝑝∨𝑝 ≡𝑝
Idempotent (∧) 𝑝∧𝑝 ≡𝑝
Commutative (∨) 𝑝∨𝑞 ≡𝑞∨𝑝
Commutative (∧) 𝑝∧𝑞 ≡𝑞∧𝑝
Associative (∨) (𝑝 ∨ 𝑞) ∨ 𝑟 ≡ 𝑝 ∨ (𝑞 ∨ 𝑟)
Associative (∧) (𝑝 ∧ 𝑞) ∧ 𝑟 ≡ 𝑝 ∧ (𝑞 ∧ 𝑟)
Distributive (∧ over ∨) 𝑝 ∧ (𝑞 ∨ 𝑟) ≡ (𝑝 ∧ 𝑞) ∨ (𝑝 ∧ 𝑟)
Distributive (∨ over ∧) 𝑝 ∨ (𝑞 ∧ 𝑟) ≡ (𝑝 ∨ 𝑞) ∧ (𝑝 ∨ 𝑟)
De Morgan’s ~(𝑝 ∨ 𝑞) ≡ ~𝑝 ∧ ~𝑞
De Morgan’s ~(𝑝 ∧ 𝑞) ≡ ~𝑝 ∨ ~𝑞
Absorption 𝑝 ∨ (𝑝 ∧ 𝑞) ≡ 𝑝
Absorption 𝑝 ∧ (𝑝 ∨ 𝑞) ≡ 𝑝
9. Duality Principle
Two statement formulas are said to be duals of each other if one can be obtained from the other by
replacing:
o ∧↔∨
o 𝑇↔𝐹
(Variables and negations remain unchanged.)
Examples
1. Original: 𝑝 ∧ 𝑞
Dual: 𝑝∨𝑞
2. Original: 𝑝 ∨ 𝑇
Dual: 𝑝∧𝐹
Solution:
i) p : There are many clouds in the sky
q : It rain
p ∧~q
Solution:
a) ~ r → q
English sentence: If I am not in a good mood, then I will go to a movie.
b) ~ q ∧ p
English sentence: I will not go to a movie and I will study discrete mathematics.
c) q → ~ p
English sentence: If I go to a movie, then I will not study discrete mathematics.
d) ~ p → ~ r
English sentence: If I do not study discrete mathematics, then I am not in a good mood.
Example
Prove that:
𝑛(𝑛 + 1)
1 + 2 + 3 + ⋯+ 𝑛 = , for all 𝑛 ∈ ℕ
2
Solution
Let 𝑃(𝑛)be the statement
𝑛(𝑛 + 1)
1+ 2+ 3+ ⋯+ 𝑛 =
2
Now consider:
1 + 2 + 3 + ⋯ + 𝑘 + (𝑘 + 1)
Using (1),
𝑘(𝑘 + 1)
= + (𝑘 + 1)
2
𝑘(𝑘 + 1) + 2(𝑘 + 1)
=
2
(𝑘 + 1)(𝑘 + 2)
=
2
Thus,
𝑃(𝑘 + 1) is true
Example
Prove that:
𝑛5 − 𝑛 is divisible by 5 for all 𝑛 ∈ ℕ
Solution
Let 𝑃(𝑛)be the statement that 𝑛5 − 𝑛is divisible by 5.
Step 1: Basis of Induction
For 𝑛 = 1:
15 − 1 = 0
which is divisible by 5.
Hence, 𝑃(1)is true.
Now consider:
(𝑘 + 1)5 − (𝑘 + 1)
= 𝑘 5 + 5𝑘 4 + 10𝑘 3 + 10𝑘 2 + 5𝑘 + 1 − 𝑘 − 1
= (𝑘 5 − 𝑘) + 5(𝑘 4 + 2𝑘 3 + 2𝑘 2 + 𝑘)
By induction hypothesis, 𝑘 5 − 𝑘is divisible by 5, and the remaining term is also divisible by 5.
Hence,
(𝑘 + 1)5 − (𝑘 + 1) is divisible by 5
Examples:
1) The set of letters forming the word "MATHEMATICS"
2) The set of students in a class SE Computer Engineering
3) s = {1, 2, 3, 4, 5, 6}
2 Statement Form
- A set is described by stating a common property of its elements.
- Useful when elements have a clear common characteristic.
Examples:
1. The set of all even integers
2. The set of all Prime Ministers of India
2. Integers
𝑍 = {… , −3, −2, −1,0,1,2,3, … }
3. Whole Numbers
𝑍 + = {0,1,2,3, … }
4. Rational Numbers
5. Real Numbers
𝑅
6. Complex Numbers
𝐶
1.4.4. Subsets
• A set A is a subset of B if every element of A is also an element of B.
• Denoted by:
𝐴⊆𝐵
• If 𝐴 ⊆ 𝐵, then B is called the superset of A.
1. Proper Subset
A set A is a proper subset of B if:
1. 𝐴 ⊆ 𝐵
2. At least one element of B is not in A
Notation:
𝐴⊂𝐵
Example:
If 𝐴 = {1,2,3}, 𝐵 = {1,2,3,4,5}, then A is a proper subset of B.
2. Improper Subsets
• Every set is a subset of itself.
• The null set is a subset of every set.
• These are called improper subsets.
3. Equal Sets
• Two sets A and B are equal if:
𝐴 ⊆ 𝐵 and 𝐵 ⊆ 𝐴
• Denoted by:
𝐴=𝐵
2) Singleton Set
• A set containing only one element.
Examples:
• {5}
• {∅}
3) Finite Set
• A set having a finite number of elements.
• Number of elements is called cardinality, denoted by ∣ 𝐴 ∣.
Example:
• 𝐴 = {1,2,3,4,5}, then ∣ 𝐴 ∣= 5
4) Infinite Set
• A set having infinitely many elements.
Example:
• 𝑁(set of natural numbers)
5) Power Set
• The set of all subsets of a set A.
• Denoted by:
𝑃(𝐴)
• If ∣ 𝐴 ∣= 𝑛, then:
∣ 𝑃(𝐴) ∣= 2𝑛
Examples:
• If 𝐴 = {𝑎, 𝑏}
𝑃(𝐴) = {∅, {𝑎}, {𝑏}, {𝑎, 𝑏}}
• 𝑃(∅) = {∅}
7) Element vs Subset
Let 𝐴 = {𝑥, 𝑦}
• 𝑥 ∈ 𝐴→ True
• 𝑥 ⊆ 𝐴→ False
• {𝑥} ⊆ 𝐴→ True
• {𝑥} ∈ 𝐴→ False
• ∅ ⊆ 𝐴→ True
8) Countable Set
o A set is called countable if its elements can be put in one-to-one correspondence with a subset of
natural numbers.
Example:
The set {2, 4, 6, 8}is countable.
Example:
▪ Consider a list of real numbers between 0 and 1.
▪ By changing the digits along the diagonal of the list, a new real number is obtained which
is not present in the list.
▪ Therefore, the set of real numbers is uncountable
Rules:
1. Universal set is shown by a rectangle.
2. Subsets are shown by circles.
3. If 𝐴 ⊆ 𝐵, circle A lies inside circle B.
4. Disjoint sets have no common area.
5. Non-disjoint sets have overlapping regions.
Examples
1. A = {1, 2, 3, 4}, B = {x, y, z}
𝐴 ∪ 𝐵 = {1,2,3,4, 𝑥, 𝑦, 𝑧}
2. A = {1,2,3,4,5,6,7,8,9,10}, B = {2,3,5,7,11,13}
𝐴 ∪ 𝐵 = {1,2,3,4,5,6,7,8,9,10,11,13}
Examples
1. A = {1,2,3,4,5}, B = {1,4}
𝐴 ∩ 𝐵 = {1,4}
2. 𝐴∩∅=∅
3. A = {a,b,c}, B = { x, y }
𝐴∩𝐵 =∅
3. Disjoint Sets
Two sets A and B are said to be disjoint if they have no common elements.
Condition:
𝐴∩𝐵 =∅
Example:
A = {1,2}, B = { x , y } are disjoint sets.
4. Complement of a Set
Let A be a subset of the universal set U.
The complement of A consists of all elements of U which are not in A.
Notation:
𝐴′ or 𝐴ˉ
Definition:
𝐴′ = {𝑥 ∣ 𝑥 ∈ 𝑈 and 𝑥 ∉ 𝐴}
Examples
1. If A = set of even numbers and U = set of integers
Then A′ = set of odd numbers
2. U = {1,2,3,…,15}, A = {1,2,3,4,5,6,7}
𝐴′ = {8,9,10,11,12,13,14,15}
Properties of Complement
1. 𝑈 ′ = ∅, ∅′ = 𝑈
2. ( 𝐴′ )′ = 𝐴
3. 𝐴 ∪ 𝐴′ = 𝑈, 𝐴 ∩ 𝐴′ = ∅
4. 𝐴 ∪ 𝑈 = 𝑈, 𝐴 ∩ 𝑈 = 𝐴
5. Difference of a Sets
Let A and B be two sets.
The difference A − B is the set of elements that are in A but not in B.
Definition:
𝐴 − 𝐵 = {𝑥 ∣ 𝑥 ∈ 𝐴 and 𝑥 ∉ 𝐵}
It is also called the relative complement of B in A.
Similarly,
𝐵 − 𝐴 = {𝑥 ∣ 𝑥 ∈ 𝐵 and 𝑥 ∉ 𝐴}
Examples
1. A = {1,2,3,4,5}, B = {3,4,5,6,7}
𝐴 − 𝐵 = {1,2}, 𝐵 − 𝐴 = {6,7}
Properties of Difference
1. 𝐴′ = 𝑈 − 𝐴
2. 𝐴 − 𝐴 = ∅, ∅ − 𝐴 = ∅
3. 𝐴−∅=𝐴
4. 𝑈−∅=𝑈
5. 𝐴 − 𝐵 = 𝐴 ∩ 𝐵′
6. 𝐴−𝐵 =𝐵−𝐴 ⟺ 𝐴 =𝐵
7. 𝐴−𝐵 =∅ ⟺ 𝐴⊆𝐵
Examples
1. A = {1,2,3,4,5,6}, B = {3,4,5,6,7,8}
𝐴 △ 𝐵 = {1,2,7,8}
2. 𝐴 △ ∅ = 𝐴
Theorem 1
If 𝐴 = ∅, then ∣ 𝐴 ∣= 0
Theorem 2
If 𝐴 ⊆ 𝐵, then ∣ 𝐴 ∣≤∣ 𝐵 ∣
Example : Among the integers 1 to 300 find how many are not divisible by 3, not by 5. Find also how many
are divisible by 3 but not by 7.
Solution:
Let A denote the set of integers from 1 to 300 divisible by 3,
B denote the set of integers from 1 to 300 divisible by 5,
and C denote the set of integers from 1 to 300 divisible by 7.
300
∣ A ∣= ⌊ ⌋ = 100
3
300
∣ B ∣= ⌊ ⌋ = 60
5
300
∣ C ∣= ⌊ ⌋ = 42
7
300 300
∣ A ∩ B ∣= ⌊ ⌋=⌊ ⌋ = 20
3×5 15
Hence, 160 integers between 1 and 300 are not divisible by 3 and not divisible by 5.
Hence, 86 integers between 1 and 300 are divisible by 3 but not divisible by 7.
1.5. Multiset
We know that a set is a collection of well-defined distinct objects.
However, in many practical situations, objects are not distinct. Such collections are called multisets.
Examples:
1. Collection of alphabets in the word “MISSISSIPPI”
𝑚, 𝑖, 𝑖, 𝑖, 𝑖, 𝑠, 𝑠, 𝑠, 𝑝, 𝑝
2. Birth months of students in a class.
Definition:
A collection of objects in which repetition of elements is allowed is called a multiset (or M-set).
To distinguish a set from a multiset, elements of a multiset are written in square brackets.
Example: 𝑎, 𝑎, 𝑏
Multiplicity of an Element
Let S be a multiset and 𝑥 ∈ 𝑆.
The multiplicity of x is the number of times x occurs in S.
It is denoted by 𝜇(𝑥).
Example:
S = 𝑎, 𝑏, 𝑐, 𝑑, 𝑑, 𝑑, 𝑒, 𝑒
μ(a)=1, μ(b)=1, μ(c)=1, μ(d)=3, μ(e)=2
Equality of Multisets
Two multisets A and B are said to be equal iff
𝜇𝐴 (𝑥) = 𝜇𝐵 (𝑥)for all elements x.
Example:
𝑎, 𝑏, 𝑎, 𝑏= 𝑎, 𝑎, 𝑏, 𝑏
but 𝑎, 𝑎≠ 𝑎
Subset of Multisets
A multiset A is said to be a sub-multiset of B if the multiplicity of each element in A is less than or equal
to its multiplicity in B.
Example:
𝑎⊆ 𝑎, 𝑎
𝑎, 𝑏, 𝑎, 𝑏, 𝑎⊆ 𝑎, 𝑎, 𝑎, 𝑏, 𝑏, 𝑏
Difference of Multisets
Let A and B be multisets.
The difference A − B is a multiset where the multiplicity of x is
𝜇𝐴 (𝑥) − 𝜇𝐵 (𝑥), if this value is positive.
Examples:
1. A = 𝑎, 𝑎, 𝑏, 𝑎, B = 𝑎, 𝑏
A − B = 𝑎, 𝑎
2. A = 1,2,3,4,2,2,3,3
B = 1,1,1,2,2,2,3,3,3,3,4
A − B = [ \ ] (empty multiset)
Sum of Multisets
The sum of two multisets A and B is denoted by A + B.
Multiplicity of x in A + B is the sum of multiplicities of x in A and B.
Example:
A = 𝑎, 𝑏, 𝑐, 𝑐
B = 𝑎, 𝑎, 𝑏, 𝑏, 𝑐, 𝑐
A + B = 𝑎, 𝑎, 𝑎, 𝑏, 𝑏, 𝑏, 𝑐, 𝑐, 𝑐, 𝑐
Applications of Multisets
1. Used to represent roots of polynomial equations.
Example: Roots of 𝑥 3 + 1 = 0are −1, −1, −1
Multiset: −1, −1, −1
2. Used to represent prime factorization of numbers.
Example: Prime factors of 72 are 2 × 2 × 2 × 3 × 3
Multiset: 2,2,2,3,3
3. Used in computer science in searching and sorting applications.