Skip to content

Union

Prime #
1254
Origin domain
Mathematics
Subdomain
set theory → Mathematics
Also from
Computer Science & Software Engineering, Logic, Type Theory
Aliases
Inclusive Merge, Set Union, Disjunction

Core Idea

The union of several collections is the set of elements in at least one of them — the defining commitment is inclusive OR. It is associative, commutative, and idempotent, monotone upward (adding a contributor can only grow the result), and collapses the overlap (a multiply-included element appears once), so it is not concatenation or a sum.

How would you explain it like I'm…

The Big Combined Pile

If you dump your bag of marbles and your friend's bag of marbles into one big pile, the pile has every marble that was in either bag. If you both had a red marble, the pile still just shows red marbles — they don't get counted twice as a kind. The big pile is the 'union': everything that was in any of the bags.

Everything In Any Bag

The Union of some collections is the set of everything that's in at least one of them, poured together into a single group. The key word is 'or' — a thing belongs in the union if it's in any one collection; it doesn't have to be in all of them. Union's partner is intersection, which keeps only the things in all collections; union does the opposite and gathers the whole combined reach. Three handy facts: the order and grouping you combine them in don't matter, and re-adding a collection you already merged changes nothing. Also, if something is in several collections, it still appears only once — so a union isn't the same as just adding up counts.

Inclusive-OR Pooling

The Union of two or more collections is the set of elements that belong to at least one of them — everything in any contributing collection, pooled into a single result with contents preserved as members. The defining commitment is inclusive OR: not membership in all, not in a majority, but in any one is enough. Union is one half of the basic Boolean pair on collections; its dual is intersection, which takes AND. Where intersection narrows to the overlap, union enlarges to the combined whole — it gathers the total reach. The substrate (numbers, records, events, types) doesn't matter; only the at-least-one-membership test does. Three structural facts give it leverage: it's associative, commutative, and idempotent, so order, grouping, and re-inclusion don't change the result; it's monotone upward, so adding a collection can only grow the union; and overlap collapses — a shared element appears once, so the union's size equals the sum of parts only when the contributors are disjoint. So union answers 'what distinct things are in any of these?', not 'how many memberships total?'

 

The Union of two or more collections is the set of elements that belong to at least one of them — everything that is in any contributing collection, pooled into a single result with the contents preserved as members. The defining commitment is inclusive OR: not membership in all collections, not membership in a majority, but membership in any one is enough to qualify for the result. Once the candidate collections are fixed, the union is fully determined; nothing further needs specifying to read it off. Union is one half of the basic Boolean pair on collections, its dual being intersection, which takes AND. Where intersection narrows to the overlap, union enlarges to the combined whole: it gathers the total reach — the merged set, the pooled population, everything covered by any source. Whenever a problem asks 'find all cases satisfying any of these criteria,' 'describe what's true of either group,' or 'merge these into one,' the underlying operation is union. The substrate — numbers, records, events, types, capabilities — is irrelevant to the structure; only the at-least-one-membership test matters. Three structural facts give union its leverage. It is associative, commutative, and idempotent: order, grouping, and re-inclusion of an already-merged collection make no difference, so it can be reasoned about freely and applied repeatedly. It is monotone upward: adding another collection can only grow the result, never shrink it. And the overlap collapses: an element in several contributors appears once, so the union is not concatenation or a sum — duplicates are absorbed, and the union's size equals the sum of the parts only when contributors are disjoint. The contrast with a tally that counts multiplicities is sharp: union answers 'what distinct things are in any of these?', not 'how many memberships are there in total?'

Broad Use

  • Mathematics and logic: set union, the disjunction of predicates, and the lattice join.
  • Combinatorics: inclusion–exclusion, the canonical formula for the size of a union of overlapping sets.
  • Databases: the SQL UNION operator (deduplicating, where UNION ALL keeps every row).
  • Type theory: the sum/variant type — a value of A | B is an A or a B.
  • Probability: the event \(A \cup B\), with \(P(A \cup B) = P(A) + P(B) - P(A \cap B)\).
  • Access control: a principal's effective permissions are the union of those granted by each role, so adding a role can only expand capability.

Clarity

Converts vague phrasing into a precise question — "everyone affected by any of these policies" becomes "the union of the affected sets" — and corrects the most common error: double-counting the overlap by summing parts that share elements.

Manages Complexity

Collapses N membership questions into one, with closed-form lattice facts (order and grouping free, re-merging a no-op) and inclusion–exclusion turning "how big is the combined set?" into a structured alternating sum over the overlaps.

Abstract Reasoning

Trains a reasoner to decompose any "combined" or "either/or" requirement into named collections, expect growth as contributors accumulate, and correct for the overlap rather than naively summing.

Knowledge Transfer

  • Data integration → access control: the enumerate-grow-deduplicate-and-correct menu ports unchanged from merging record sets to combining role permissions.
  • Across domains: the diagnosis "our combined total is overstated because we summed overlapping sources" reads identically whether the sources are databases, roles, events, or taxa.

Example

A SQL UNION of regional customer queries consolidates the lists and deduplicates shoppers appearing in several regions to one row each — and inclusion–exclusion warns that the consolidated count is not the sum of the per-region counts.

Not to Be Confused With

  • Union is not Intersection because intersection takes AND (membership in every collection) and narrows to the overlap, whereas union takes OR (membership in any one) and enlarges to the combined whole — adding a contributor shrinks one but grows the other.
  • Union is not Aggregation because aggregation condenses to a summary value and counts multiplicities, whereas union merges into a set in which every member remains present and the overlap is absorbed.
  • Union is not Concatenation because concatenation (multiset sum) keeps every copy, whereas set union keeps one copy — the difference is exactly the over-counted overlap.