IT235 Discrete Structure

Discrete StructureUnit 214 min read

Set Theory & Relations: Sets, Operations, Relations, Functions & Equivalence

Unit 2 of Discrete Structure covers foundational set theory (operations, power sets, Cartesian products) and relations (types, properties, closure, matrices), with applications to real-world systems like databases, networks, and equivalence classes. Mastering these concepts is critical for algorithms, logic, and proble

TAKEAWAYS:

  • Sets are collections of distinct objects; operations like union, intersection, and complement are visualized via Venn diagrams and inclusion-exclusion principles.
  • Relations (binary, n-ary) can be represented as matrices, digraphs, or tables, and their properties (reflexive, symmetric, transitive) determine equivalence classes and partitions.
  • Functions (injective, surjective, bijective) map sets and are critical for algorithms, encryption, and data modeling.
  • Equivalence relations partition sets into disjoint subsets, used in error-correction codes, social networks (friend groups), and traffic routing.
  • Boolean matrices compactly represent relations, enabling efficient computation in pathfinding (e.g., shortest paths in Kathmandu traffic) and database queries.
  • Closure properties (reflexive, symmetric, transitive) define when a relation can form a valid structure like a graph or equivalence class.

1. Sets: Definitions and Basic Operations

1.1 What is a Set?

A set is a well-defined collection of distinct objects, called elements or members. Sets are denoted by capital letters (e.g., ), and elements by lowercase letters (e.g., ).

  • Roster method: List all elements explicitly. Example: .
  • Set-builder notation: Define properties elements must satisfy. Example: .

1.2 Types of Sets

Type Definition Example
Finite Set Has a limited number of elements.
Infinite Set Has unlimited elements. (natural numbers)
Empty Set Contains no elements. or
Universal Set Contains all objects under consideration.
Subset All elements of are in .
Proper Subset but .

1.3 Set Operations

Visualize operations using Venn diagrams (shaded regions show results):

UAB1, 2, 34, 5, 6
A ∪ B = {1, 2, 3, 4, 5, 6} (A only: 1,2; B only: 4,5; A ∩ B: 3)
  • Union (): All elements in or . . Example: .

  • Intersection (): Elements in both and . . Example: .

  • Complement ( or ): Elements not in but in the universal set . . Example: If , .

  • Difference (): Elements in but not in . Example: .

  • Symmetric Difference (): Elements in either or but not both. . Example: .

1.4 Laws of Set Theory

Law Statement
Idempotent ,
Commutative ,
Associative
Distributive
De Morgan’s ,

1.5 Power Set and Cartesian Product

  • Power Set (): Set of all subsets of . Example: If , then . Size: If , then .
UP(A) = {∅, {1}, {2}, {1,2}}A = {1, 2}1, 2∅, {1}, {2}, {1,2}
Power set P(A) contains all subsets of A
  • Cartesian Product (): Set of all ordered pairs where and . Example: . Size: .

2. Relations: Definitions and Properties

2.1 What is a Relation?

A relation from set to set is a subset of the Cartesian product .

  • Binary Relation: (relation on a single set).
  • Representation:
    • Roster form: List of ordered pairs. Example: .
    • Matrix form: Boolean matrix where if , else .
    • Digraph: Directed graph where nodes are elements and edges represent pairs.

2.2 Properties of Relations

Property Definition Example
Reflexive . on is reflexive.
Symmetric . If , then .
Transitive and . If and , then .
Antisymmetric and . Used in "less than or equal to" ().

2.3 Types of Relations

Type Definition Example
Equivalence Relation Reflexive, symmetric, and transitive. Partitions into equivalence classes. "Congruence modulo " ().
Partial Order Reflexive, antisymmetric, and transitive. "Divisibility" ().
Function Every element in domain maps to exactly one in codomain. .

2.4 Closure of Relations

Given a relation on and a property (e.g., reflexive), the closure is the smallest relation containing that satisfies .

  • Reflexive Closure: Add all pairs for .
  • Symmetric Closure: Add for every .
  • Transitive Closure: Add if and .

Example: Let , .

  • Reflexive Closure: .
  • Transitive Closure: is already transitive (no new pairs).

2.5 Equivalence Relations and Partitions

An equivalence relation partitions a set into disjoint equivalence classes.

  • Example: Let , .
    • Equivalence classes: , .

Visualization:

{1, 3}{2, 4}
Partition of A into equivalence classes: {1,3} and {2,4} (disjoint sets)

3. Functions: Types and Properties

3.1 Definition of a Function

A function from set (domain) to set (codomain) assigns to each exactly one .

  • Notation: , .
-2-1.5-1-0.50.511.52-3-2-112345xyf(x) = x²g(x) = 2x + 1f(1) = 1g(1) = 3
Graph of two functions: f(x) = x² (parabola) and g(x) = 2x + 1 (line)

3.2 Types of Functions

Type Definition Example
Injective (One-to-One) . No two elements map to the same output. (domain: reals).
Surjective (Onto) Every is mapped by some . where .
Bijective Both injective and surjective. where .

3.3 Composition of Functions

If and , then the composition is defined by .

Example: Let where , and where . Then .


4. Applications in the Real World

4.1 Set Theory in Everyday Systems

  1. eSewa and Khalti (Digital Payments):

    • Set Operations: Transactions are grouped into sets (e.g., all payments to a merchant). Union operations combine transaction logs, while intersections identify duplicate payments.
    • Cartesian Product: Used to generate all possible user-merchant pairs for fraud detection (e.g., ).
  2. Pathao (Ride-Hailing):

    • Relations: Represents "driver available at location " as a relation .
    • Equivalence Classes: Groups users by pickup zones (e.g., all users near Thapathali form one class).
  3. NTC (Telecom Network Routing):

    • Graph Theory: Networks are modeled as graphs where nodes are switches and edges are connections. Relations define reachability between nodes.
    • Transitive Closure: Computes all possible paths between any two switches to optimize routing.

4.2 Worked Example: Kathmandu Traffic Routes

Problem: Model traffic routes in Kathmandu as a relation and find the transitive closure to determine all possible paths between major intersections. Assumptions:

  • Sets: .
  • Initial relation .

Steps:

  1. Reflexive Closure: Add , etc.
  2. Transitive Closure: Add because and .

Result:

original relationoriginal relationadded in transitive closureThapathaliKantipathBaneshwor
Transitive closure adds (Thapathali, Baneshwor) because Kantipath connects them

4.3 Relations in Databases

  • Foreign Keys: Represent relations between tables (e.g., Orders and Customers).
  • Equivalence Classes: Used in data deduplication (e.g., grouping similar customer records).

5. Exam Tip: How to Score Full Marks

  1. For Set Operations:

    • Always draw Venn diagrams to visualize unions/intersections.
    • Use inclusion-exclusion for proofs: .
    • Memorize De Morgan’s laws for negations.
  2. For Relations:

    • Prove properties step-by-step:
      • Reflexive: Show for all .
      • Symmetric: For every , show .
      • Transitive: For and , show .
    • Boolean matrices: Construct them systematically (rows = domain, columns = codomain).
  3. For Functions:

    • To prove injective, assume and show .
    • To prove surjective, show for every , there exists such that .
  4. Common Pitfalls:

    • Confusing subset () with proper subset ().
    • Forgetting to include all pairs in reflexive/symmetric closures.
    • Misapplying transitive closure (only add pairs if intermediate steps exist).
  5. Past Exam Patterns:

    • Brief Questions: Define terms like "equivalence relation," "Boolean matrix," or "ceiling function."
    • Proofs: Always start with "Let ..." and proceed logically.
    • Applications: Relate to databases, networks, or traffic systems (as above).

6. Practice Problems

  1. Let , . Find:
    • , , , .
  2. Define a relation on by . Is reflexive? Symmetric? Transitive?
  3. Prove that the relation on integers is an equivalence relation.
  4. Given defined by , determine if is injective, surjective, or bijective.
  5. Find the transitive closure of on .

Based on the TU BITM syllabus for Discrete Structure (IT235), unit 2.

Discussion

Loading…