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

A' = \{x \in U \mid x \notin A\}

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:

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):

A \cup B = \{x \mid x \in A \text{ or } x \in B\}

Intersection

The intersection of two sets A and B is the set of all elements that belong to A and B:

A \cap B = \{x \mid x \in A \text{ and } x \in 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:

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:

A - B = \{x \mid x \in A \text{ and } x \notin 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.

Two-set Venn diagram showing four regionsA rectangle labelled U contains two overlapping circles. The left circle is labelled A and the right circle is labelled B. Four regions are visible: the left crescent labelled A minus B, the overlap labelled A intersection B, the right crescent labelled B minus A, and the area outside both circles labelled A prime intersection B prime. U A B A − B A ∩ B B − A (A ∪ B)′
The standard two-set Venn diagram. Every element of $U$ lives in exactly one of the four regions. The left crescent is $A - B$ (in $A$, not in $B$). The overlap is $A \cap B$ (in both). The right crescent is $B - A$ (in $B$, not in $A$). The area outside both circles is $(A \cup B)'$ (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:

Four Venn diagrams showing union intersection difference and complementFour small Venn diagrams arranged in a two-by-two grid. Top left shows A union B with both circles shaded. Top right shows A intersection B with only the overlap shaded. Bottom left shows A minus B with only the left crescent shaded. Bottom right shows A complement with everything outside the left circle shaded. A ∪ B A B A ∩ B A B A − B A B A′ A B
The four basic operations, visualised. In each diagram, the shaded region is the resulting set. Top-left: $A \cup B$ shades both circles. Top-right: $A \cap B$ shades only the overlap. Bottom-left: $A - B$ shades the part of $A$ outside $B$. Bottom-right: $A'$ shades everything outside $A$ (including the part of $B$ that is not in $A$).

A counting formula: inclusion-exclusion

When A and B are finite sets, their sizes are connected by a clean formula:

|A \cup B| = |A| + |B| - |A \cap B|

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:

\text{(i)}\quad (A \cup B)' = A' \cap B'
\text{(ii)}\quad (A \cap B)' = A' \cup B'

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.

Venn diagram verification of De Morgan's first lawTwo Venn diagrams side by side. On the left, the complement of A union B is shaded — the region outside both circles. On the right, A prime intersection B prime is shaded — also the region outside both circles. The two shaded regions are identical, confirming the equality. (A ∪ B)′ A B = A′ ∩ B′ A B
De Morgan's first law, verified visually. On the left, the shaded region is $(A \cup B)'$ — everything outside both circles. On the right, the shaded region is $A' \cap B'$ — the intersection of "outside $A$" and "outside $B$," which is exactly the same region. The pictures are identical because the law is true.

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.

Interactive slider controlling overlap between two sets on a number lineA horizontal number line from 0 to 10. Two red points can be dragged along the line. The left point represents the upper bound of set A which is the interval from 1 to the left point value. The right point represents the lower bound of set B which is the interval from the right point value to 9. Readouts show the current sizes of A, B, their intersection, and their union computed by inclusion-exclusion. 0 1 2 3 4 5 6 7 8 9 10 drag the red points to change A and B
Set $A = [1, a]$ and set $B = [b, 9]$ on the number line. Drag the two red points to change the upper bound of $A$ and the lower bound of $B$. When the intervals overlap, the intersection is the interval $[b, a]$ with length $a - b$, and the union length equals $|A| + |B| - |A \cap B|$ by inclusion-exclusion. When the intervals don't overlap, the intersection is empty and the union length is simply $|A| + |B|$.

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.

A \cup B = \{1, 2, 3, 4, 5, 6, 7\}

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.

A \cap B = \{3, 4, 5\}

Why: check each element of A against B. Only 3, 4, and 5 appear in both.

Step 3. Find A - B and B - A.

A - B = \{1, 2\} \qquad B - A = \{6, 7\}

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.

A' = \{6, 7, 8, 9, 10\}

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|.

|A| = 5, \quad |B| = 5, \quad |A \cap B| = 3, \quad |A \cup B| = 7
5 + 5 - 3 = 7 \quad \checkmark

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.

Venn diagram for Example 1 with elements placed in regionsA rectangle labelled U contains two overlapping circles A and B. In the left crescent are the numbers 1 and 2. In the overlap are 3, 4, and 5. In the right crescent are 6 and 7. Outside both circles are 8, 9, and 10. U = {1, …, 10} A B 1 2 3 4 5 6 7 8, 9, 10 |A ∪ B| = 5 + 5 − 3 = 7 ✓
Every element of $U$ sits in exactly one region of the Venn diagram. The overlap region $\{3, 4, 5\}$ is the intersection, the left crescent $\{1, 2\}$ is $A - B$, the right crescent $\{6, 7\}$ is $B - A$, and the outside $\{8, 9, 10\}$ is $(A \cup B)'$. Inclusion-exclusion: $5 + 5 - 3 = 7$ matches the seven elements inside the two circles.

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|.

|H \cup S| = |H| + |S| - |H \cap S| = 30 + 20 - 10 = 40

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)'|.

|(H \cup S)'| = |U| - |H \cup S| = 50 - 40 = 10

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':

|H' \cap S'| = |H'| + |S'| - |H' \cup 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:

|H' \cap S'| = 20 + 30 - 40 = 10

This matches the answer from Step 2.

Result. 10 students study neither language, and De Morgan's law is consistent with the direct calculation.

Venn diagram for the Hindi-Sanskrit survey problemA rectangle labelled U with 50 students contains two overlapping circles. The left circle is labelled H for Hindi with 20 in its exclusive region. The right circle is labelled S for Sanskrit with 10 in its exclusive region. The overlap shows 10. Outside both circles the number 10 appears for students studying neither language. U (50 students) H (Hindi) S (Sanskrit) 20 10 10 10 neither 30 + 20 − 10 = 40 study at least one
The four regions account for all $50$ students: $20$ study only Hindi, $10$ study only Sanskrit, $10$ study both (the overlap, highlighted in red), and $10$ study neither. The numbers in the four regions sum to $50$, confirming that every student is accounted for exactly once.

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

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:

|A \cup B \cup C| = |A| + |B| + |C| - |A \cap B| - |A \cap C| - |B \cap C| + |A \cap B \cap C|

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.