CO2 Discrete Mathematics Notes 2
Table of contents
- Sets, Subsets, Power Sets, Set Operations, Set Identities
- Cartesian Product, Cardinality, Inclusion–Exclusion Principle
- Relations, Properties, Matrix & Digraph Representation
- Equivalence Relations, Partial Orders, Hasse Diagrams
- Functions, Floor, Ceiling, Modulo, Hashing, Pigeonhole Principle
- Quick Revision Summary — CO-2
1. Sets, Subsets, Power Sets, Set Operations, Set Identities
1.1 What is a set? 3
A set is a well-defined, unordered collection of distinct objects, called elements or members. Sets are typically denoted by capital letters and their elements are enclosed in curly braces.
- Elements: Objects within a set.
- Notation:
A = {1, 2, 3}means 1, 2, and 3 are elements of set A. - Membership:
3 ∈ Ameans 3 is an element of A;6 ∉ Ameans 6 is not an element of A. - Real-life examples: Contacts list, students enrolled in a class, fruits in a basket 3.
| Representation Method | Description | Example |
|---|---|---|
| Roster / Tabular form | List all elements explicitly | A = {2, 4, 6, 8, 10} |
| Set-builder form | Describe a property elements must satisfy | A = {x |
| Venn diagram | Pictorial representation using closed curves | Circle labelled A containing dots for elements |
- Special sets:
- Empty / Null set (∅ or {}): A set with no elements.
- Finite set: Has a countable number of elements.
- Infinite set: Has unlimited elements.
- Universal set (U): The "parent" set containing all objects under discussion.
- Singleton set: A set with exactly one element 3.
1.2 Subsets
A set A is a subset of set B (A ⊆ B) if every element of A is also an element of B. If A is not equal to B, it is a proper subset (A ⊂ B).
- Example: A = {1, 2}, B = {1, 2, 3, 4}. A ⊆ B and A ⊂ B.
- Real-life examples: Students in a class who play cricket is a subset of all students; "Read-only users" is a subset of "All registered users." 3.
📝 Let A = {1, 2} and B = {1, 2, 3, 4}. Every element of A is in B, so A ⊆ B. Since A ≠ B, A is also a proper subset: A ⊂ B.
1.3 Power Set
The power set of a set A, denoted P(A), is the set of all possible subsets of A. If a set A has n elements, its power set has 2n subsets.
- Example: For A = {a, b, c} (n=3), P(A) = {∅, {a}, {b}, {c}, {a,b}, {a,c}, {b,c}, {a,b,c}}. |P(A)| = 23=8.
- Real-life example: Possible topping combinations for a pizza (including no topping and all toppings) correspond to the power set of the available toppings 3.
1.4 Set Operations 4
Let U be the universal set and A, B be subsets of U.
| Operation | Notation | Meaning |
|---|---|---|
| Union | A ∪ B | Elements in A, or B, or both |
| Intersection | A ∩ B | Elements common to both A and B |
| Difference | A − B | Elements in A but not in B |
| Complement | A′ or Ac | Elements in U but not in A |
| Symmetric Difference | A △ B | Elements in exactly one of A, B (not both) |
- Worked Example: U = {1,...,10}, A = {1,2,3,4,5}, B = {4,5,6,7,8}.
- A ∪ B = {1,2,3,4,5,6,7,8}.
- A ∩ B = {4,5}.
- A − B = {1,2,3}.
- B − A = {6,7,8}.
- A′ = {6,7,8,9,10}.
- A △ B = {1,2,3,6,7,8}.
- Real-life example: "Mutual friends" is an intersection; "students in Physics or Chemistry" is a union; "products on sale AND in stock" is an intersection 5.
1.5 Set Identities (Laws of Set Algebra) 5
These laws provide algebraic rules for manipulating sets.
| Law | Identity |
|---|---|
| Idempotent | A ∪ A = A; A ∩ A = A |
| Identity | A ∪ ∅ = A; A ∩ U = A |
| Domination | A ∪ U = U; A ∩ ∅ = ∅ |
| Commutative | A ∪ B = B ∪ A; A ∩ B = B ∩ A |
| Associative | (A ∪ B) ∪ C = A ∪ (B ∪ C) |
| Distributive | A ∪ (B ∩ C) = (A ∪ B) ∩ (A ∪ C) |
| De Morgan's Laws | (A ∪ B)′ = A′ ∩ B′; (A ∩ B)′ = A′ ∪ B′ |
| Complement | A ∪ A′ = U; A ∩ A′ = ∅ |
| Double Complement | (A′)′ = A |
| Absorption | A ∪ (A ∩ B) = A; A ∩ (A ∪ B) = A |
-
Real-life example: De Morgan's Law is used in programming logic (
!(A && B) == (!A ||!B)) and digital circuit design to simplify logic gates 5. -
Case Study 1.1 — College Club Membership: This case study applies set operations to find the number of students in at least one club, neither club, or exactly one club, using the principle of inclusion-exclusion for unions 6.
2. Cartesian Product, Cardinality, Inclusion–Exclusion Principle
2.1 Cartesian Product
The Cartesian product of two sets A and B, denoted A × B, is the set of all ordered pairs (a, b) where a is from A and b is from B. The number of elements in A × B is the product of the number of elements in A and B.
- Definition: A × B = {(a, b) | a ∈ A, b ∈ B}.
- Example: A = {1, 2}, B = {x, y}. A × B = {(1,x), (1,y), (2,x), (2,y)}. Note that A × B ≠ B × A.
- Cardinality: |A × B| = |A| × |B|.
- Real-life example: Product variants in an online store (Size × Colour); a deck of cards (Ranks × Suits) 7.
2.2 Cardinality
The cardinality of a set A, denoted |A|, is the number of elements in the set. For finite sets, it's a simple count.
- Example: A = {2, 4, 6, 8} has |A| = 4. The empty set ∅ has |∅| = 0.
- Real-life example: Number of rows in a database query result; number of active users reported by a company 7.
📝 A = {1, 2}, B = {x, y}. A × B = {(1,x), (1,y), (2,x), (2,y)}. Note that A × B ≠ B × A 7.
2.3 Inclusion–Exclusion Principle
This principle is used to count the number of elements in the union of multiple sets by adding individual set sizes, subtracting pairwise intersections, adding back triple intersections, and so on, alternating signs.
-
Two sets: |A ∪ B| = |A| + |B| − |A ∩ B|.
-
Three sets: |A ∪ B ∪ C| = |A| + |B| + |C| − |A∩B| − |B∩C| − |A∩C| + |A∩B∩C| 7.
-
Real-life example: Calculating unique customer reach across multiple marketing channels; HR analytics for employee language skills 8.
-
Case Study 2.1 — Language Survey: This case study applies the Inclusion–Exclusion Principle for three sets to determine the number of employees speaking at least one language and those speaking none.
-
Case Study 2.2 — Product Catalogue: This case study uses the Cartesian product to calculate the total number of distinct product variants (SKUs) based on multiple attributes like size, color, and material 8.
3. Relations, Properties, Matrix & Digraph Representation
3.1 What is a Relation?
A binary relation R from set A to set B is a subset of the Cartesian product A × B (R ⊆ A × B). If (a,b) ∈ R, it means 'a is related to b'.
A relation on A is a subset of A × A.
- Example: On A = {1,2,3,4}, R = {(a,b) | a divides b} includes pairs like (1,1), (1,2), (2,2), (2,4).
- Real-life example: "Is a friend of" on social media; "is a prerequisite for" between courses; "reports to" in an organization 9.
3.2 Properties of Relations 9
Relations can possess several properties that define their behavior.
| Property | Condition (for all a, b, c ∈ A) | Everyday meaning |
|---|---|---|
| Reflexive | (a,a) ∈ R for every a | Every element relates to itself |
| Irreflexive | (a,a) ∉ R for any a | No element relates to itself |
| Symmetric | (a,b) ∈ R ⟹ (b,a) ∈ R | Relation works both ways |
| Antisymmetric | (a,b)∈R and (b,a)∈R ⟹ a=b | No two-way relation unless same element |
| Transitive | (a,b)∈R and (b,c)∈R ⟹ (a,c)∈R | Chains carry through |
- Real-life examples:
- Reflexive: "has the same birthday month as".
- Symmetric: "is a sibling of".
- Antisymmetric: "≤" on numbers; "is a subordinate of".
- Transitive: "is an ancestor of" 9.
📝 The relation "≤" on numbers is antisymmetric because if a ≤ b and b ≤ a, then it must be that a = b 9.
3.3 Matrix Representation of a Relation
A relation R on a set A = {a₁,..., aₙ} can be represented by an n×n Boolean matrix M, where M[i][j = 1 if (aᵢ,aⱼ) ∈ R, and 0 otherwise 9.
3.4 Digraph (Directed Graph) Representation
A relation can be visualized as a directed graph where elements of A are vertices, and an arrow from a to b exists if (a,b) ∈ R. Self-loops represent reflexive pairs.
-
Example: A digraph showing R = {(1,1),(1,2),(2,1),(2,3),(3,4),(4,4)}.
-
Real-life example: Road networks (Google Maps); social network "follows" graphs (Twitter/X); used internally by computers for graph storage and algorithms 10.
-
Case Study 3.1 — Course Prerequisite System: This case study uses relations and digraphs to model course prerequisites, checking for transitivity and determining if a course can be taken based on its prerequisites 10.
4. Equivalence Relations, Partial Orders, Hasse Diagrams
4.1 Equivalence Relations
An equivalence relation is a relation that is reflexive, symmetric, and transitive. It partitions a set into disjoint subsets called equivalence classes, where each class contains elements related to each other.
- Definition: The equivalence class of an element a, denoted [a, is {x ∈ A | x R a}.
- Example: Congruence modulo 3 (a ≡ b mod 3) on integers partitions them into and 1 2.
- Real-life example: "Has the same blood group as"; "is in the same time zone as"; grouping files by extension 11.
4.2 Partial Order Relations
A partial order relation is reflexive, antisymmetric, and transitive. A set with a partial order is called a poset.
Not all pairs of elements need to be comparable.
- Example: "a divides b" on the positive divisors of 30 is a partial order. Elements 2 and 3 are incomparable.
- Real-life example: "Is a subset of" (⊆) on sets; "is a prerequisite for" in a curriculum; task dependencies in project management 11.
4.3 Hasse Diagrams
A Hasse diagram is a simplified graphical representation of a finite poset. It omits self-loops, transitive edges, and arrowheads, with elements arranged vertically to imply direction.
-
Key terms: Maximal element, minimal element, upper bound, lower bound, Least Upper Bound (LUB/Join), Greatest Lower Bound (GLB/Meet).
-
Real-life example: Organization charts; software version dependency graphs; taxonomic classification 12.
-
Case Study 4.1 — Software Build Dependencies: This case study uses partial orders and Hasse diagrams to represent software module dependencies and determines a valid build order (topological sort), identifying parallel compilation opportunities 12.
📝 The relation "a divides b" on the set of positive divisors of 30, {1,2,3,5,6,10,15,30}, is a partial order. For example, 2 and 3 are incomparable because neither 2 divides 3 nor 3 divides 2. 11
5. Functions, Floor, Ceiling, Modulo, Hashing, Pigeonhole Principle
5.1 Functions 13
A function f from set A (domain) to set B (codomain) assigns exactly one element of B to each element of A. The range is the set of actual outputs.
| Type | Condition | Everyday meaning |
|---|---|---|
| Injective (One-to-One) | a₁≠a₂ ⟹ f(a₁)≠f(a₂) | No two inputs share an output |
| Surjective (Onto) | Every b∈B has some a with f(a)=b | Every possible output is used |
| Bijective | Both injective and surjective | Perfect one-to-one pairing |
- Real-life example: Aadhaar number to citizen (injective); student to exam room (surjective if all rooms used); seat assignment (bijective) 13.
5.2 Floor and Ceiling Functions
The floor function ⌊x⌋ gives the greatest integer less than or equal to x (rounds down). The ceiling function ⌈x⌉ gives the smallest integer greater than or equal to x (rounds up).
- Examples: ⌊4.7⌋ = 4, ⌈4.2⌉ = 5, ⌊−2.3⌋ = −3, ⌈−2.3⌉ = −2.
- Real-life example: Elevator trips needed (ceiling); cloud billing rounding up usage; website pagination 13.
5.3 Modulo (Modular Arithmetic)
a mod n is the remainder when integer a is divided by n. Two integers a and b are congruent modulo n (a ≡ b mod n) if they have the same remainder.
- Example: 9 + 5 = 14, and 14 mod 12 = 2 (like a 12-hour clock).
- Real-life example: Clock time (mod 12 or 24); days of the week (mod 7); checksums (e.g., Luhn algorithm, mod 10); cryptography 14.
📝 On a 12-hour clock, 9 + 5 = 14, which is 2 o'clock, because 14 mod 12 = 2 14.
5.4 Hashing
A hash function maps data (keys) to a fixed range of table indices, often using modulo arithmetic (h(k) = k mod m). Collisions occur when different keys map to the same index.
- Example: Hashing student IDs into a table of size 7 using h(k) = id mod 7; collisions occur when multiple IDs map to the same slot.
- Real-life example: Password storage; hash maps/dictionaries in programming; Git commit identification; load balancing 14.
5.5 Pigeonhole Principle
If n items are placed into m containers and n > m, at least one container must hold more than one item. The Generalized Pigeonhole Principle states at least one container holds at least ⌈n/m⌉ items.
-
Example: Among any 13 people, at least two share a birth month (13 people, 12 months).
-
Real-life example: In a room of 367 people, at least two share a birthday; hash table collisions; data compression theory 15.
-
Case Study 5.1 — Hash Table Collision Analysis: This case study uses the Pigeonhole Principle to predict and then verify hash table collisions for a given set of product IDs and a hash function.
-
Case Study 5.2 — Exam Seat Allocation: This case study explains why a bijective function is essential for assigning unique seats to students, ensuring no empty seats and no double bookings 15.
6. Quick Revision Summary — CO-2
This section provides a concise overview of the key concepts covered in the preceding units.
- Sets: Unordered collections of distinct elements; subsets (⊆); power sets (2n elements).
- Operations: Union (∪), intersection (∩), difference (−), complement, symmetric difference (△), governed by set identities.
- Cartesian Product: A × B creates ordered pairs; |A×B| = |A|·|B|; forms the basis of relations.
- Cardinality: |A| is the number of elements; Inclusion–Exclusion Principle avoids double-counting in unions.
- Relations: Subsets of A×B; characterized by reflexive, symmetric, antisymmetric, and transitive properties; represented by matrices or digraphs.
- Equivalence Relations: Reflexive, symmetric, and transitive relations that partition a set into equivalence classes.
- Partial Orders: Reflexive, antisymmetric, and transitive relations forming a poset, visualized with Hasse diagrams.
- Functions: Map every input to exactly one output; classified as injective, surjective, or bijective.
- Floor/Ceiling/Modulo: Rounding and remainder operations fundamental to hashing and cryptography.
- Pigeonhole Principle: Guarantees that if n items are in m < n holes, at least one hole has ≥ ⌈n/m⌉ items, ensuring collisions or repeats 16.
© 2026 Maeve. All rights reserved. This content is protected by copyright.