In short
Given two sets A and B inside a universal set U, there are four basic ways to combine them. The union A \cup B collects everything that is in A or B (or both). The intersection A \cap B keeps only what is in both. The difference A - B keeps everything in A that is not in B. The complement A' (or A^c) is the difference U - A — everything in the universe that is not in A. Venn diagrams make all four operations visible at a glance. De Morgan's two laws connect complements to unions and intersections: (A \cup B)' = A' \cap B' and (A \cap B)' = A' \cup B'. These five ideas — union, intersection, difference, complement, and De Morgan — are the complete toolkit for combining sets.
Suppose you have two cricket teams in your school — the under-14 team and the under-16 team. Some students play on one team, some on the other, and a few talented players are on both. Now someone asks: "How many students play cricket?" The answer depends on exactly what you mean by combine. Do you want the list of all cricket-playing students (regardless of which team), or only the students who are on both rosters? These are two different questions, and each one defines a different way of combining the two sets.
Set operations are the formal names for these combinations. You already know what a set is from Sets — Introduction. This article is the next step: given two sets, what can you build out of them? The answer is surprisingly short — four operations cover essentially everything — and the resulting algebra is clean enough that you can prove powerful identities (like De Morgan's laws) in a handful of lines.
The universal set and complement
Before defining the four operations, fix a universal set U — the background set that contains every object under discussion. If you are talking about the integers from 1 to 10, then U = \{1, 2, 3, 4, 5, 6, 7, 8, 9, 10\}. Every set you define will be a subset of U.
The complement of a set A with respect to U is the set of all elements in U that are not in A:
Complement of a set
For a set A \subseteq U, the complement of A is
Other notations: A^c, \bar{A}, U - A. All mean the same thing.
If U = \{1, 2, 3, 4, 5\} and A = \{1, 3, 5\}, then A' = \{2, 4\}. The complement flips the membership: every element that was in switches to out, and vice versa. Two immediate consequences:
- (A')' = A — complementing twice gets you back to where you started.
- A \cup A' = U and A \cap A' = \varnothing — a set and its complement together cover the whole universe, with no overlap.
Union and intersection
Union
The union of two sets A and B is the set of all elements that belong to A or B (or both):
Intersection
The intersection of two sets A and B is the set of all elements that belong to A and B:
Take A = \{1, 2, 3, 4\} and B = \{3, 4, 5, 6\}. Then A \cup B = \{1, 2, 3, 4, 5, 6\} and A \cap B = \{3, 4\}. The union merges both lists (dropping duplicates, since sets don't repeat). The intersection keeps only the shared elements.
If two sets have no elements in common — that is, A \cap B = \varnothing — they are called disjoint. The sets \{1, 2\} and \{3, 4\} are disjoint; the sets \{1, 2, 3\} and \{3, 4\} are not (they share 3).
Both union and intersection satisfy the same structural rules that addition and multiplication do:
- Commutative. A \cup B = B \cup A and A \cap B = B \cap A.
- Associative. (A \cup B) \cup C = A \cup (B \cup C) and (A \cap B) \cap C = A \cap (B \cap C).
- Distributive. A \cap (B \cup C) = (A \cap B) \cup (A \cap C) and A \cup (B \cap C) = (A \cup B) \cap (A \cup C).
The distributive laws are the ones that surprise people — especially the second one, because addition does not distribute over multiplication in arithmetic, but union does distribute over intersection in set theory. The two algebras rhyme but are not identical.
Set difference
Set difference
The difference (or relative complement) of B from A is the set of elements in A that are not in B:
Some textbooks write A \setminus B instead of A - B.
With the same A = \{1, 2, 3, 4\} and B = \{3, 4, 5, 6\}: A - B = \{1, 2\} and B - A = \{5, 6\}. Notice that A - B \neq B - A in general — set difference is not commutative, just as subtraction of numbers is not commutative.
Also notice that the complement is a special case of difference: A' = U - A.
Venn diagrams
A Venn diagram is a picture that makes set operations visible. Draw two overlapping circles inside a rectangle (the rectangle is U). The left circle is A, the right is B. The four regions of the diagram correspond to the four possible membership combinations: in A only, in B only, in both, in neither.
Shading different regions of this diagram gives a picture of any set operation you like. Union is "everything inside at least one circle." Intersection is "only the overlap." Difference A - B is "the left crescent." The complement A' is "everything outside the left circle."
Here are all four operations side by side, each with its region shaded:
A counting formula: inclusion-exclusion
When A and B are finite sets, their sizes are connected by a clean formula:
The reason for the subtraction: when you count |A| and then |B|, every element in the overlap A \cap B gets counted twice. Subtracting |A \cap B| corrects the double count.
This is the inclusion-exclusion principle for two sets. If A has 15 elements and B has 12 elements and the overlap has 5, then |A \cup B| = 15 + 12 - 5 = 22.
Think of the cricket example from the opening. If 14 students are on the under-14 team, 11 are on the under-16 team, and 4 are on both, then the total number of cricket-playing students is 14 + 11 - 4 = 21. You subtract the 4 overlap because those students would otherwise be counted once in each team total.
De Morgan's laws
The deepest result in the algebra of set operations is a pair of identities that connect complement with union and intersection.
De Morgan's laws
For any sets A, B \subseteq U:
In words: the complement of the union is the intersection of the complements, and the complement of the intersection is the union of the complements. These two laws say that complementation "swaps" union and intersection.
The Venn diagrams make both laws visually obvious — shade the left-hand side and the right-hand side, and the shaded regions are identical. But a formal proof is more satisfying, because it works without pictures.
Proof of law (i): (A \cup B)' = A' \cap B'.
To show two sets are equal, show that each is a subset of the other.
Part 1: (A \cup B)' \subseteq A' \cap B'. Take any x \in (A \cup B)'. Then x \notin A \cup B, which means x \notin A and x \notin B (if x were in either one, it would be in the union). So x \in A' and x \in B', which means x \in A' \cap B'.
Part 2: A' \cap B' \subseteq (A \cup B)'. Take any x \in A' \cap B'. Then x \in A' and x \in B', so x \notin A and x \notin B. Since x is in neither A nor B, x \notin A \cup B, which means x \in (A \cup B)'.
Both directions hold, so (A \cup B)' = A' \cap B'.
Proof of law (ii): (A \cap B)' = A' \cup B'.
Part 1: (A \cap B)' \subseteq A' \cup B'. Take any x \in (A \cap B)'. Then x \notin A \cap B, which means it is not the case that x \in A and x \in B. So at least one of the two memberships fails: x \notin A or x \notin B. That is, x \in A' or x \in B', so x \in A' \cup B'.
Part 2: A' \cup B' \subseteq (A \cap B)'. Take any x \in A' \cup B'. Then x \in A' or x \in B', so x \notin A or x \notin B. In either case, the conjunction "x \in A and x \in B" fails, so x \notin A \cap B, which means x \in (A \cap B)'.
Both directions hold, so (A \cap B)' = A' \cup B'.
The structure of both proofs is the same: pick an arbitrary element, chase the definitions, arrive at the other side. This "element-chasing" technique is the standard way to prove set identities, and you will use it again in Relations and beyond.
Practical applications
Set operations appear constantly in real life, even when nobody calls them "set operations."
Database queries. Every time you search for "students who scored above 90 in maths AND above 85 in physics," you are computing an intersection. "Students who scored above 90 in maths OR above 85 in physics" is a union. "Students who did NOT score above 90 in maths" is a complement. SQL databases are built on exactly this algebra.
Eligibility filters. A scholarship requires: (a) income below ₹8 lakh, AND (b) marks above 75%, AND (c) domicile in UP or MP. Each condition defines a set. The eligible students are the intersection of all three. If a student fails any one condition, they fall outside the intersection.
Probability. An event in probability is a set of outcomes. "P(A \cup B) = P(A) + P(B) - P(A \cap B)" is literally the inclusion-exclusion formula for sets, applied to probability measures. Every probability rule you will learn in later chapters is a set-operation rule in disguise.
Survey problems. "In a class of 40 students, 25 like cricket, 18 like football, and 10 like both. How many like neither?" This is a direct application of inclusion-exclusion: |A \cup B| = 25 + 18 - 10 = 33, so 40 - 33 = 7 like neither. Problems like this appear on every competitive exam from NTSE to JEE.
Interactive Venn diagram
Drag the slider below to move the right circle closer to or farther from the left circle. As the overlap changes, the readouts show the sizes of the intersection and union for two specific sets.
Two worked examples
Example 1: Given $U = \{1, 2, 3, 4, 5, 6, 7, 8, 9, 10\}$, $A = \{1, 2, 3, 4, 5\}$, $B = \{3, 4, 5, 6, 7\}$, find $A \cup B$, $A \cap B$, $A - B$, $B - A$, $A'$, and verify inclusion-exclusion
Step 1. Find A \cup B — all elements in A or B or both.
Why: merge both lists and drop duplicates. The elements 3, 4, 5 appear in both sets but are listed only once in the union.
Step 2. Find A \cap B — elements in both A and B.
Why: check each element of A against B. Only 3, 4, and 5 appear in both.
Step 3. Find A - B and B - A.
Why: A - B keeps only the elements of A that are not in B, which are 1 and 2. Similarly, B - A keeps 6 and 7.
Step 4. Find A' — all elements of U not in A.
Why: go through U = \{1, \dots, 10\} and remove everything that appears in A. What remains is \{6, 7, 8, 9, 10\}.
Step 5. Verify inclusion-exclusion: |A \cup B| = |A| + |B| - |A \cap B|.
Result. A \cup B = \{1,2,3,4,5,6,7\}, A \cap B = \{3,4,5\}, A - B = \{1,2\}, B - A = \{6,7\}, A' = \{6,7,8,9,10\}, and inclusion-exclusion checks out.
The Venn diagram makes the double-counting visible. The three elements in the overlap would be counted once in |A| and again in |B|, which is why the formula subtracts them.
Example 2: In a class of $50$ students, $30$ study Hindi, $20$ study Sanskrit, and $10$ study both. How many study neither? Verify using De Morgan's first law.
Let H = set of Hindi students, S = set of Sanskrit students, and U = the whole class (|U| = 50).
Step 1. Apply inclusion-exclusion to find |H \cup S|.
Why: 10 students study both languages, so adding 30 and 20 counts them twice. Subtracting the overlap corrects the count.
Step 2. Find the number studying neither language — that is, |(H \cup S)'|.
Why: the complement of "study at least one language" is "study neither language." Since the whole class has 50 students and 40 study at least one, the remaining 10 study neither.
Step 3. Verify via De Morgan's first law: (H \cup S)' = H' \cap S'.
H' is the set of students who do not study Hindi: |H'| = 50 - 30 = 20. S' is the set of students who do not study Sanskrit: |S'| = 50 - 20 = 30.
Now H' \cap S' is the set of students who study neither Hindi nor Sanskrit. Using inclusion-exclusion on H' and S':
But H' \cup S'= (H \cap S)' (by De Morgan's second law), and |H \cap S| = 10, so |(H \cap S)'| = 50 - 10 = 40. Therefore:
This matches the answer from Step 2.
Result. 10 students study neither language, and De Morgan's law is consistent with the direct calculation.
Survey problems like this one appear on almost every competitive exam. The method is always the same: draw the Venn diagram, place the overlap first, fill the exclusive regions by subtraction, and compute the outside by subtracting from the total.
Common confusions
-
"A \cup B means the elements in A and B." Careful with the English word "and." In everyday language, "A and B" sounds like intersection, but A \cup B uses the logical or. An element is in A \cup B if it is in A or in B (or both). The intersection A \cap B is the one that requires both memberships.
-
"A - B = B - A." False in general. Set difference is not commutative. If A = \{1,2,3\} and B = \{2,3,4\}, then A - B = \{1\} but B - A = \{4\}. Different sets entirely.
-
"De Morgan's law says (A \cup B)' = A' \cup B'." No — the complement swaps the operation. The correct law is (A \cup B)' = A' \cap B'. The union on the left becomes an intersection on the right. Mixing up which operation gets swapped is the most common error when applying De Morgan.
-
"|A \cup B| = |A| + |B|." Only when A and B are disjoint (A \cap B = \varnothing). In general you must subtract the overlap: |A \cup B| = |A| + |B| - |A \cap B|. Forgetting the subtraction double-counts the shared elements.
-
"The complement of A depends only on A." No — it also depends on the universal set U. If A = \{1, 2\} and U = \{1, 2, 3\}, then A' = \{3\}. But if the same A lives inside U = \{1, 2, 3, 4, 5\}, then A' = \{3, 4, 5\}. The complement changes when the universe changes.
-
"Venn diagrams can handle any number of sets." For two sets, a Venn diagram has 4 regions. For three sets, it has 8 regions and still works cleanly. But for four or more sets, the standard overlapping-circles picture fails to create all the necessary regions, and you need more exotic shapes (like overlapping ellipses). In practice, Venn diagrams are used for two or three sets; beyond that, the algebra is cleaner than the picture.
Going deeper
If you came here for the four operations, the Venn diagrams, and the inclusion-exclusion formula, you have the complete working toolkit. The rest of this section is for readers who want to see the algebraic structure behind the operations and a connection to logic that will pay off in Logic and Propositions.
The algebra of sets is a Boolean algebra
The operations \cup, \cap, and ' on subsets of a universal set U form a structure called a Boolean algebra. It satisfies a package of identities — commutativity, associativity, distributivity (both ways), identity laws (A \cup \varnothing = A, A \cap U = A), and complement laws (A \cup A' = U, A \cap A' = \varnothing) — that together are exactly the axioms of a Boolean algebra. De Morgan's laws are theorems of this algebra, not extra rules.
The same Boolean algebra appears in Logic and Propositions, where \cup becomes \lor (or), \cap becomes \land (and), ' becomes \lnot (not), and De Morgan's laws become \lnot(p \lor q) \equiv (\lnot p) \land (\lnot q). It also appears in digital circuit design, where the operations are OR gates, AND gates, and NOT gates. The fact that the same algebra governs sets, logic, and circuits is one of the most useful structural coincidences in mathematics.
Symmetric difference
There is a fifth operation that textbooks sometimes mention: the symmetric difference A \triangle B = (A - B) \cup (B - A). This is the set of elements that belong to exactly one of the two sets — the "exclusive or" of set theory. The symmetric difference is commutative, associative, and has its own De Morgan-like identities. It shows up naturally in probability (the event "exactly one of A or B occurs") and in coding theory (where errors are symmetric differences of codewords).
Generalised inclusion-exclusion
For three sets, the inclusion-exclusion formula becomes:
The pattern alternates: add the singles, subtract the pairs, add the triple. For n sets, the formula has 2^n - 1 terms, alternating in sign. This generalised version is a workhorse in combinatorics — it is the key tool for counting objects that satisfy "at least one" of several conditions, and it appears regularly in JEE Advanced probability problems.
Where this leads next
Set operations are the grammar of mathematical reasoning — the same algebra shows up everywhere, in different clothes.
- Relations — a relation is a set of ordered pairs, and the operations of this article (union, intersection, complement) apply directly to relations.
- Logic and Propositions — the Boolean algebra of sets has an exact parallel in propositional logic, with De Morgan's laws carrying over symbol for symbol.
- Sets — Introduction — the prerequisite article, if you need to revisit the basics of set notation, subsets, and power sets.
- Number Systems — the nested number sets \mathbb{N} \subset \mathbb{Z} \subset \mathbb{Q} \subset \mathbb{R} are connected by exactly the subset and difference operations you met here.
- Real Numbers and Their Properties — the field axioms describe how operations on the elements of \mathbb{R} behave, while this article describes how operations on subsets of a universe behave. Both are algebraic structures, and the parallels are deliberate.