Set theory is the mathematical language of computer science, used in database theory, formal languages, and algorithm analysis.

1. Basics of Sets

A set is a well-defined collection of distinct objects.

Types of Sets:

  • Null Set (Empty Set): A set containing no elements, denoted by \emptyset or {}\{\}.
  • Finite and Infinite Sets: Depending on whether the number of elements is countable or not.
  • Power Set: The set of all subsets of a set AA is called the power set P(A)P(A).
    • Rule: If a set AA has nn elements, then n(P(A))=2nn(P(A)) = 2^n.

2. Set Operations

Common operations used to manipulate sets:

A. Union (ABA \cup B)

Elements that are in AA, or in BB, or in both.

B. Intersection (ABA \cap B)

Elements that are in both AA and BB.

C. Difference (ABA - B)

Elements that are in AA but not in BB.

D. Symmetric Difference (AΔBA \Delta B)

Elements that are in AA or BB, but not in their intersection.
AΔB=(AB)(BA)=(AB)(AB)A \Delta B = (A - B) \cup (B - A) = (A \cup B) - (A \cap B)

3. Relations and Functions

A relation from AA to BB is a subset of A×BA \times B.

Functions:

A function f:ABf: A \to B is a special type of relation where every element in AA is mapped to exactly one element in BB.

  • Domain: The set AA.
  • Range: The subset of BB containing all images of elements in AA.

Summary

Mastering set operations and functions is essential for understanding data structures and relational databases.

Part1of1
Hi! Need help with studies? 👋
AI