Concepts Related to Sets

Before discussing various set operations, we first introduce the basic concepts of sets and the definitions of different set operations.

Concept of a Set

A set is a collection composed of specified objects, and each member of the collection is called an element. A set is like a dictionary with only keys; internal elements cannot be repeated. Elements in a set have no inherent order and cannot be indexed. We can add elements to a set or remove elements from it, but we cannot modify the value of an element. For multiple sets, we can perform set operations to compute their intersection, union, difference, etc.

Set Operations

As shown in Figure 9-1, circular regions A and B represent two sets. Their intersection is the overlapping dark region in the middle, i.e., region C. Their union is all shaded regions combined.

Document Image

Figure 9-1

Document Image

Figure 9-2

Document Image

Figure 9-3

Document Image

Figure 9-4

As shown in Figure 9-2, circular regions A and B represent two sets. Their difference

is obtained by subtracting the intersection of

and

from

, corresponding to the dark part of region

.

As shown in Figure 9-3, circular regions A and B represent two sets. Their symmetric difference is a new set obtained by subtracting their intersection from their union, corresponding to the shaded region in the figure.

As shown in Figure 9-4, circular regions A and B represent two sets. If

overlaps with

or

is contained within

, then the set represented by

is a subset of the set represented by

, and the set represented by

is a superset of the set represented by

. If we exclude the case where they are the same size and overlap (i.e.,

is completely contained within

), then the set represented by

is a proper subset of the set represented by

, and the set represented by

is a proper superset of the set represented by