Complement of a set Created 2026-10-05 Updated 2026-10-14
The complement of a subset within a specified universal set contains exactly the set elements of excluded from :Here depends on the chosen universal set. Within , taking a complement performs logical negation (NOT) on membership. Writing keeps the ambient set visible when there could be ambiguity.
For , , and :If the universal set grows to , the same sets have different complements: and . In a database illustration, “records that fail this condition” therefore requires deciding which records are eligible to begin with; those eligible records form .
For subsets , De Morgan's laws exchange union and intersection when taking complements:For the same example, failing both conditions leaves . Failing at least one condition leaves . This is useful for rewriting exclusion rules into separate membership tests. The symmetry is also pleasing: exchanging union with intersection turns one rule into its partner.
De Morgan's laws: excluding a union means failing both tests, while excluding an intersection means failing at least one
. Details. A brief membership proof works in classical propositional logic. For any , let mean and mean . The truth table below checks all four possibilities, with meaning true and false:Each paired column agrees. Translating logical disjunction (OR), logical conjunction (AND), and logical negation (NOT) back into membership proves the two set equalities. For the general method of reducing set equalities to equivalences in propositional logic, see Lehman, Leighton and Meyer, Mathematics for Computer Science (2015), §4.1.5 and Problem 4.5.
A historical perspective appears in Augustus De Morgan's [ref]
https://en.wikisource.org/wiki/Page:Formal_Logic_(1847,_De_Morgan).djvu/8. Formal Logic (1847), preface
: he describes treating each name together with its contradictory name. In the membership viewpoint here, a set and its complement likewise pair a condition with its logical negation. De Morgan's laws Created 2026-09-28 Updated 2026-10-14
De Morgan's laws exchange logical conjunction and logical disjunction when a logical negation moves across them:Here denotes logical equivalence: the two propositional formulas agree under every Boolean valuation.[ref]
3.1 Propositional Logic. Discrete Mathematics: An Open Introduction (3rd edition) by Oscar Levin; Discrete Mathematics: An Open Introduction, 3rd edition by Oscar Levin, §3.1, Logical Equivalence: definition, Example 3.1.3 and De Morgan's Laws box
A complete verification uses the four rows of a truth table. In input order , both sides of the first logical equivalence have output sequence ; both sides of the second have . A proof in words is equally short: failure of “both” means at least one failure, whereas failure of “at least one” means both fail. The differing middle rows explain why simply pushing logical negation inward without changing AND to OR is wrong.
For the events in Boolean operations on events, the corresponding set identities areOne can prove these identities by checking an arbitrary set element : its two membership truth values obey De Morgan's laws. The same reasoning works for any two subsets of a common universal set.
De Morgan's laws shade the same set whether a compound event is complemented first or its component events are complemented first
. Details. For a nested program test, let mean “backup recent”, mean “backup verified”, and mean “manual override authorized”. Rejecting when neither an acceptable backup nor an override is present givesThe transformed condition reads “backup stale or unverified, and no override”. Apply the second of De Morgan's laws at the outside, then the first at the inner logical conjunction. For it rejects; changing only to one makes it accept. With Boolean operands in Python,
not ((recent and verified) or override) and ((not recent) or (not verified)) and (not override) have the same result and inspect the operands in the same order, with the same skipped operands. Negation Created 2026-09-24 Updated 2026-10-14
Logical negation exchanges zero and one: and . For a numerical bit , this is ; applying logical negation twice restores . It acts on the entire propositional formula in its scope. Parentheses therefore matter: says that neither condition holds, while also accepts every case where holds. At their values are zero and one.
On a set, logical negation becomes taking a complement in a fixed universal set. In Boolean operations on events, “not even” selects . “Not both even and at least four” selects ; it does not require both qualifications to fail. De Morgan's laws make the scope of these compound negations precise.
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.
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: .
Venn diagram 2026-10-14
A Venn diagram represents sets by closed curves, with each region recording a possible pattern of membership. For two sets, the regions mean “first only”, “both”, “second only”, and “neither”; the enclosing rectangle can represent the universal set. Shading regions displays union, intersection, set difference, or complement. In the numbered examples in set union and complement, positions encode membership, while curve shapes and region areas do not encode cardinalities.


