Sets, Functions, Sequences, and Cardinality
An introduction to sets, set operations, functions, sequences, recurrence relations, summations, cardinality, countability, and uncountable sets in discrete mathematics.
Introduction
Did you know that the total number of fractions in existence is exactly the same size as the set of counting numbers, but the set of real numbers between 0 and 1 is strictly larger than both? Welcome to the foundational landscape of discrete mathematics, where simple collections of objects open the door to understanding algorithms, data structures, and the boundaries of computer computation.
By the end of this lesson, you will be able to:
- Formulate and evaluate sets, subsets, power sets, and Cartesian products using standard mathematical notation.
- Apply set operations and verify set identities using direct proofs, membership tables, and bit string representations.
- Classify functions as injective, surjective, or bijective, and calculate function inverses and compositions.
- Analyze sequences, solve recurrence relations through iteration, and evaluate finite and infinite summations.
- Distinguish between countable and uncountable infinite sets using Cantor's diagonalization argument and Hilbert's Grand Hotel model.
The Language of Sets and Subsets
At the bedrock of discrete mathematics lies the concept of a set. Intuitively defined by Georg Cantor in 1895, a set is an unordered collection of distinct objects called elements or members. We write to indicate that is an element of set , and when it is not.
There are two primary ways to describe sets:
- Roster Method: Listing all members explicitly between curly braces. For example, the vowels in the English alphabet are written as . Ellipses can be used for obvious patterns, such as .
- Set-Builder Notation: Specifying the property that elements must satisfy: . For instance, the odd positive integers under 10 are expressed as .
Certain sets occur so frequently that they are assigned dedicated boldface symbols:
- N = , the set of natural numbers.
- Z = , the set of integers.
- Z+ = , the set of positive integers.
- Q = , the set of rational numbers.
- R, the set of real numbers, and C, the set of complex numbers.
We also frequently work with intervals on the real line. The closed interval includes its endpoints, whereas the open interval excludes them.
It is crucial to distinguish between the empty set (or null set), denoted by or , which contains zero elements, and the singleton set . A helpful mental model is to picture folders on a computer file system: is an empty folder, while is a folder containing a single item—which happens to be an empty folder!
When every element of a set is also an element of set , we say is a subset of , written . To prove , you must show that if , then . To prove , you only need a single counterexample: an such that . Every nonempty set has at least two subsets: (proved vacuously) and . If but , we call a proper subset of , denoted .
To build more complex structures from a set , we use two essential constructions:
- Power Set: The power set is the set of all subsets of . If , then . For example, if , then .
- Cartesian Product: Order matters in many computing tasks. An ordered -tuple maintains strict order. The Cartesian product is the set of all ordered pairs. Note that unless , , or . A subset is called a relation from to .
Set Operations and Computer Representations
Just as basic arithmetic allows us to add and multiply numbers, set theory provides operations to combine sets in precise ways:
- Union (): The set containing elements that are in , in , or in both: .
- Intersection (): The set containing elements in both and : . Sets with no common elements () are called disjoint.
- Difference ( or ): The set containing elements in but not in : .
- Complement (): Given a universal set , the complement of is .
When counting the total number of elements in a union of two finite sets, simply adding overcounts the elements residing in both sets. Correcting for this double-counting yields the fundamental Principle of Inclusion-Exclusion:
Set operations satisfy several universal laws (known as Set Identities), such as Domination, Idempotent, Commutative, Associative, Distributive, and De Morgan's Laws:
We can establish set identities using three primary techniques:
- Subset Method: Show that each side is a subset of the other (i.e., show and ).
- **Set Builder Nota****tion & Logical Equivalences:** Transform set definitions step-by-step using propositional logic equivalences.
- Membership Tables: Test all combinations of element membership across atomic sets using (belongs) and (does not belong), directly analogous to truth tables.
In computer applications, sets drawn from a finite universal set can be stored efficiently as bit strings of length . The -th bit is set to if is in the subset, and otherwise. Under this representation:
- The Union corresponds to a bitwise OR.
- The Intersection corresponds to a bitwise AND.
- The Complement corresponds to a bitwise NOT.
When duplicate elements matter, we step outside ordinary sets into multisets. A multiset assigns a multiplicity to each element. For multisets and , the union uses the maximum multiplicity , the intersection uses the minimum , and the difference uses .
Functions: Mappings, Types, and Compositions
A function from set to set (written ) is an assignment of exactly one element of to each element of . If , is the domain, is the codomain, is the image of , and is a preimage of . The range (or image of ) is the set of all actual outputs , which is a subset of the codomain.
Functions are categorized by how they map elements:
- One-to-One (Injective): never maps two distinct domain elements to the same codomain element. That is, . Functions that are strictly increasing () or strictly decreasing are always injective.
- Onto (Surjective): Every element of the codomain is the image of at least one element of . That is, .
- One-to-One Correspondence (Bijective): is both injective and surjective. When domain and codomain sets and are finite, a function can be bijective only if .
If is a bijection, it is invertible. Its inverse function satisfies if and only if . If a function is not bijective, an inverse cannot be defined without restricting the domain or codomain.
Given two functions and , the composition is defined by . Note that composition is not commutative ( in general), but applying a bijective function and its inverse in sequence yields the identity function: .
Two essential functions in algorithm analysis and discrete computing are:
- Floor Function (): Assigns to real number the largest integer .
- Ceiling Function (): Assigns to real number the smallest integer .
For example, to determine how many 53-byte ATM cells are needed to transmit bits of data, we calculate bytes, demonstrating how ceiling functions model discrete container allocation in real-world engineering.
Finally, mathematical models often encounter partial functions , which are defined only on a subset of (called the domain of definition). If is defined for all elements in , it is a total function.
Sequences and Summations
A sequence is a function from a subset of integers (usually or ) to a set . We write to represent the image of integer , and to denote the sequence itself.
Two classic standard sequence types include:
- Geometric Progression: Form , with initial term and common ratio .
- Arithmetic Progression: Form , with initial term and common difference .
Finite sequences of characters or bits are called strings, and the string with zero characters is the empty string .
Rather than explicit formulas, sequences are frequently defined recursively via a recurrence relation, which expresses using one or more preceding terms (). Combined with initial conditions, a recurrence relation uniquely specifies a sequence.
Famous recurrence examples include:
- Factorial Sequence: with , yielding .
- Fibonacci Sequence: with .
- Compound Interest: with initial deposit .
To convert a recurrence relation into a closed formula, we can use iteration. In backward substitution, we express in terms of , then substitute with its expression in terms of , stepping downward until hitting the initial condition. In forward substitution, we calculate from initial conditions upward to deduce the general pattern.
When we need to add consecutive terms of a sequence, we use summation notation: where is the index of summation, is the lower limit, and is the upper limit.
Key summation closed forms include:
- Sum of Geometric Series: (for ).
- Sum of First Positive Integers: .
- Infinite Geometric Series: for .
The Horizon of Infinity: Cardinality and Uncountable Sets
How do we measure the size of a set when its elements never end? Cantor established that two sets and have the same cardinality () if and only if there exists a one-to-one correspondence (bijection) between them.
A set is called countable if it is finite or has the exact same cardinality as the set of positive integers . When an infinite set is countable, its cardinality is written as ("aleph null"). An infinite set is countable if and only if its elements can be listed in an infinite sequence .
Infinite sets exhibit mind-bending properties that defy finite intuition. Consider Hilbert's Grand Hotel, a hypothetical hotel with a countably infinite number of occupied rooms (Room 1, Room 2, Room 3, ...). When a new guest arrives, the hotel manager does not evict anyone; instead, the manager moves the guest in Room to Room for all . This vacates Room 1 for the newcomer, demonstrating that an infinite set can accommodate additions without changing its size class!
Using explicit bijections, we can establish surprising countability results:
- Odd Positive Integers: Map connects to odd positive integers.
- All Integers (Z): We can list all integers in a single sequence by alternating signs: .
- Rational Numbers (Q+): By arranging all fractions in a 2D grid and tracing diagonals while bypassing fractions already listed in reduced form (), we prove that is countable!
Are all infinite sets countable? No. Georg Cantor proved that the set of real numbers is uncountable using the famous Cantor Diagonalization Argument.
Suppose the real numbers between 0 and 1 were countable and could be listed in a sequence :
Now construct a new real number where if , and if . This new number differs from in the 1st decimal place, from in the 2nd place, and from in the -th place. Thus, cannot be anywhere on the list! This contradiction proves that is uncountable.
Finally, the Schröder-Bernstein Theorem provides a powerful tool for proving cardinality equality: If and , then .
This distinction between countable and uncountable sets has profound consequences for computer science. Because every computer program written in any language can be represented as a finite string of bits, the set of all computer programs is countable. However, the set of all functions from to is uncountable. Therefore, there are infinitely more mathematical functions than there are computer programs—proving the existence of uncomputable functions that no computer can ever evaluate!
Summary
Discrete mathematics provides the foundational language for computer science by organizing objects into sets, mapping relationships via functions, modeling discrete growth with sequences and recurrences, and uncovering the profound mathematical boundaries of infinity.
Key Takeaways:
- Sets & Operations: A set is an unordered collection of distinct elements. Basic operations (union, intersection, difference, complement) can be represented using Venn diagrams, membership tables, logic proofs, or computer bit strings.
- Function Dynamics: Functions assign exactly one output to each input. They are classified as injective (one-to-one), surjective (onto), or bijective (both). Only bijections possess true inverse functions.
- Sequences & Recurrences: Discrete growth patterns are modeled as arithmetic or geometric progressions, or defined recursively. Iterative methods (forward and backward substitution) resolve recurrence relations into closed formulas.
- Summation Formulas: Standard closed forms exist for sums of integers, geometric series, and polynomial powers, enabling rapid evaluation of algorithmic step counts.
- Cardinality & Uncomputability: Infinite sets are countable () if they can be placed in a bijection with (like and ). Uncountable sets like are strictly larger, proving that uncomputable functions exist because computer programs are countable while functions are uncountable.