BCA151 Discrete Structure

Discrete StructureUnit 29 min read

Set Theory & Functions: Operations, Mappings, and Cardinality

Unit 2 of Discrete Structure: Explores set theory (operations, relations, cardinality) and functions (types, composition, inverses) with proofs, examples, and real-world applications in algorithms, databases, and Nepalese apps like eSewa and Daraz.

TAKEAWAYS

  • Sets are collections of distinct objects; operations like union, intersection, and complement are fundamental for modeling data (e.g., user groups in eSewa).
  • Functions map inputs to outputs; injective, surjective, and bijective functions are critical for algorithms (e.g., sorting, encryption).
  • Cardinality quantifies set size; countable vs. uncountable sets underpin database indexing and computational complexity.
  • Function composition chains operations (e.g., Daraz’s order processing pipeline: user → cart → payment → delivery).
  • Proof techniques (direct, contradiction) validate set/function properties, essential for exam questions.
  • Real-world ties: eSewa’s transaction validation uses set operations; Pathao’s route optimization relies on graph theory (covered later).

1. Sets: Definitions and Operations

A set is a well-defined collection of distinct objects. Objects are called elements or members.

1.1 Notation and Representation

  • Roster form: List elements explicitly.
  • Set-builder notation: Describe a property.
UAB1, 23, 45, 67, 8
Example of sets A = {1, 2, 3, 4} and B = {3, 4, 5, 6} with universal set U

1.2 Basic Operations

Operation Symbol Definition Example
Union ∪ Combines all distinct elements from sets A and B.
Intersection ∩ Elements common to both A and B.
Difference \ Elements in A but not in B.
Complement Elements not in A (relative to a universal set U). If ,

1.3 Venn Diagrams for Operations

Each operation is visualized separately to show inclusion/exclusion:

UABC156324
A ∩ B ∩ C = ∅ (no common elements in all three sets)

1.4 Laws of Set Theory

Prove using Venn diagrams and truth tables:

  • Commutative:
  • Associative:
  • Distributive:

Worked Example (eSewa Transactions): eSewa categorizes transactions into:

  • A: Successful payments (e.g., bills, transfers).
  • B: Failed payments (e.g., insufficient funds).
  • C: Refunded transactions.

Question: Find the set of transactions that were either successful or refunded but not failed. Solution:


2. Cardinality and Special Sets

2.1 Cardinality

  • Finite set: Countable elements (e.g., for ).
  • Infinite set: Uncountable (e.g., real numbers ).
  • Countable vs. Uncountable:
    • Countable: Can list elements (e.g., integers ).
    • Uncountable: Cannot list (e.g., between 0 and 1).

2.2 Power Set

The set of all subsets of a set is called the power set, denoted . For , .

2.3 Cartesian Product

For sets and , the Cartesian product is the set of ordered pairs: Example: If and , then:

ABCD
Cartesian product A × B where A = {1, 2}, B = {3, 4} (edges represent ordered pairs)

Real-World Tie (Pathao Drivers): Pathao’s driver assignment can be modeled as a Cartesian product:

  • Drivers (A):
  • Routes (B):
  • Assignments:

3. Functions: Definitions and Types

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

3.1 Types of Functions

Type Definition Example Visualization
Injective Distinct inputs map to distinct outputs (one-to-one). Injective function graph
Surjective Every element in codomain is mapped (onto). with Surjective mapping
Bijective Both injective and surjective. Bijective function
-2-1.5-1-0.50.511.52-2-11234xyf(x) = x (Injective)g(x) = x² (Not injective)h(x) = √x (Not defined for x < 0)(1, 1)(-1, 1)
Graphs of injective, non-injective, and restricted functions

3.2 Function Composition

If and , then:

  • (read as "f of g of x").
  • .

Worked Example (Daraz Order Processing): Let:

  • = Apply discount to item .
  • = Calculate shipping cost for .

Question: If a customer buys item , what is the final cost after discount and shipping? Solution: If (20% discount) and (shipping), then:


4. Relations and Partial Orders

4.1 Relations

A relation from set to is a subset of . Example: For , , .

4.2 Partial Orders

A relation on a set is a partial order if it is:

  1. Reflexive: for all .
  2. Antisymmetric: If and , then .
  3. Transitive: If and , then .

Example (Nepalese Cities by Elevation): Let with:

  • (lower elevation).
  • . This defines a partial order.

5. Proof Techniques for Sets and Functions

5.1 Direct Proof

Show by assuming and deriving . Example: Prove . Proof: Assume . Then and . Since , . But , so . Thus, .

UBAx ∈ Ay ∈ B but y ∉ A
Proving A ⊆ B: Every element of A must also be in B

5.2 Proof by Contradiction

Assume the opposite of what you want to prove and find a contradiction. Example: Prove is irrational. Proof: Assume is rational, so where are integers with no common factors. Then , implying is even, so is even. Let . Then , so is even. This contradicts having no common factors. Hence, is irrational.


In the Real World

  1. eSewa Transaction Validation

    • Idea: Set operations filter transactions.
    • How: eSewa uses to find duplicate transactions (where = all transactions, = recent transactions).
    • Example: If a user transfers ₹100 twice, flags the second entry.
  2. Daraz Order Queue

    • Idea: Functions model order processing.
    • How: Orders pass through stages: cart → checkout → payment → delivery. This is a composition of functions .
    • Worked Example: If 100 orders arrive, and (checkout) processes 50 orders/hour, the queue length is (where is time in hours).
  3. NTC Network Routing

    • Idea: Graph theory (covered later) models network paths, but set theory defines available routes.
    • How: NTC’s routers use to combine primary and backup paths for reliability.
    • Example: If primary path fails, NTC switches to backup , ensuring connectivity via .

Exam Tip

  • Focus on definitions: Always define terms like injective, surjective, and partial order clearly with examples.
  • Practice proofs: Expect 1–2 proof questions per exam. Use Venn diagrams for set proofs and logical steps for function proofs.
  • Function composition: Memorize and practice swapping order (e.g., unless and commute).
  • Cardinality: Know when to use for finite sets and when to discuss countable vs. uncountable.
  • Real-world mapping: Relate set operations to apps (e.g., eSewa’s for failed transactions) to score extra marks.
  • Time management: Spend 10–15 minutes per question. For proofs, write each step clearly with justifications.

Based on the TU BCA syllabus for Discrete Structure (BCA151), unit 2.

Discussion

Loading…