Set difference Created 2026-10-05 Updated 2026-10-14
The set difference keeps the set elements of that do not belong to :
Thus set difference combines logical conjunction (AND) with logical negation (NOT): pass the first condition and fail the second. The definition applies to any two sets; need not be a subset of .
For and , the two orders give different answers:
The common member is removed in both directions. A database filter illustrates the usefulness: if is the set of records matching the first condition and the set matching the second, selects records matching the first but not the second. The Venn diagram in set union shades both directions separately.
The name relative complement emphasizes that the ambient set is : is the complement of within . If a larger universal set contains and , then . Changing that larger universal set does not change the set difference, because membership still requires belonging to . In ZF the set difference exists by the axiom schema of separation. It also gives relative complements within a fixed tuple domain in finite relation closure for set-theoretic coding.
Set intersection Created 2026-09-24 Updated 2026-10-14
The intersection keeps exactly the set elements common to both sets:
Membership in an intersection therefore uses logical conjunction (AND). For and , the only shared member is , so . The Venn diagram in set union shades only the overlap for this operation.
An intersection is useful when every requirement must hold. If and are the sets of database records passing two separate conditions, their intersection gives the records passing both. Similarly, satisfying two equations requires belonging to the intersection of their solution sets. The same membership rule applies even when the objects have entirely different meanings.
For a family of sets, the intersection contains exactly the set elements belonging to every set :
Here universal quantification expresses “every”. If all the sets lie within a fixed universal set , the intersection over no indexing members is defined to be : there are no requirements to fail. This convention depends on specifying . By contrast, intersecting with the empty set always gives .
Set union Created 2026-09-24 Updated 2026-10-14
The union collects the set elements belonging to either set, including those belonging to both:
Thus membership in a union uses logical disjunction (OR). For and , the union is : the shared member occurs only once, because a set records membership without repeated entries.
Figure 1.
Union, intersection, and the two directions of set difference for the same numbered sets
. Details.
In this Venn diagram, belong only to , belongs to both sets, belongs only to , and belong to neither. The surrounding universal set is . Numbers are placed by membership; circle areas do not represent cardinalities. Each panel shades the region selected by its operation.
For a database illustration, let collect records matching one condition and collect records matching another. Their union selects records matching at least one condition, with a record satisfying both still appearing once. This interpretation turns an abstract operation into a reusable rule for combining selections. For an authored treatment of union, intersection, set difference, and complement, see Lehman, Leighton and Meyer, Mathematics for Computer Science (2015), Definition 4.1.1, pp. 82–83.
More generally, the union contains exactly the set elements belonging to at least one set :
The existential quantification expresses “at least one”. With no indexing members, the union is the empty set. Combining a set with the empty set leaves it unchanged: .