Sets and Maps
1Introduction
This lecture defines the basic operations on sets and the principal properties of maps. These concepts provide the language for specifying algorithmic input and output and for defining the vertex set of a graph.
2Sets and inclusion
A set is a collection of objects called its elements. The notation states that is an element of , whereas states that it is not. The empty set, denoted by , has no elements.
A set is a subset of a set , written , if implies for every . The conjunction of and is equivalent to .
3Operations on sets
For sets and , their union, intersection, and difference are defined by
A complement requires a specified universal set containing the objects under consideration. For , the complement of is
Changing the universal set can therefore change the complement.
The Cartesian product of sets and is the set of ordered pairs
Order matters: in general, .
4Relations
A binary relation from a set to a set is a subset of their Cartesian product. If , we say that is related to by and may write . When , this is called a relation on .
The edge set of a directed graph is a binary relation on its vertex set . In an undirected graph, the order of endpoints is ignored, and a two-element subset is used as an edge. The following graph lecture defines this distinction precisely.
5Maps
For sets and , a map is a rule that assigns exactly one element of to every element of . The set is the domain, the set is the codomain, and the assigned element is denoted by . Thus every domain element must receive a value, and that value must be unique.
For and , the image of and the preimage of are
In particular, is the image of the map. Although , the image need not equal the codomain. The notation for a preimage remains valid even when has no inverse map.
6Injective, surjective, and bijective maps
A map is injective if
for all . Equivalently, distinct inputs have distinct outputs.
The map is surjective if, for every , there exists such that . This condition is equivalent to . A map that is both injective and surjective is bijective. Exactly for a bijection, there is an inverse map that assigns each its unique preimage.
7Example
Let and , and define
Then and . Because , the map is not injective. Because and do not belong to its image, it is not surjective either.
8Connections to computer science
An array of length can be represented as a map from the index set to a codomain of values. A deterministic algorithm whose output is uniquely determined for every input can be specified as a map from its set of admissible inputs to its set of outputs. When a problem permits more than one correct output, its output specification can instead be represented as a relation between inputs and admissible outputs. A graph is described by a vertex set and an edge set whose elements are ordered pairs in a Cartesian product or two-element subsets of .
data/lecture/information/algorithm/algorithms-portal.lecture.n.md data/lecture/information/graph/graph-basics.lecture.n.md9Summary
- A set is determined by element membership, and means that holds for every .
- A complement requires a universal set, while a Cartesian product distinguishes the order of its coordinates.
- A map assigns exactly one codomain element to every domain element.
- Under an injective map, distinct inputs have distinct outputs; under a surjective map, every codomain element lies in the image; and a bijection gives a one-to-one correspondence.