Skip to content
Glacius
FoundationsConcept reference

Set intersection

The intersection of two sets consists of objects that belong to both sets.

On this page 7 sections
  1. Overview
  2. The intersection keeps objects that belong to both sets
  3. If the sets share no members, the result is the empty set
  4. Check your understanding
  5. Key takeaway
  6. Sources & further reading
  7. Concept connections

01The intersection keeps objects that belong to both sets#

The intersection keeps objects that belong to both sets. Here A={2,4,6}A=\{2,4,6\} and B={4,6,8}B=\{4,6,8\}.

A contains 2, 4, 6. B contains 4, 6, 8. Labels 4 and 6 lie in both enclosures. The intersection includes only 4 and 6.A contains 2, 4, 6. B contains 4, 6, 8. Labels 4 and 6 lie in both enclosures. The intersection includes only 4 and 6.
Figure 1The intersection is {4,6}\{4,6\}.
Link to this figure ↗Download SVGDownload PNG

For A={2,4,6}A=\{2,4,6\} and B={4,6,8}B=\{4,6,8\}, the labels 44 and 66 are shared. The label 22 appears only in AA; 88 appears only in BB.

Collect the qualifying labels.

AB={4,6}A\cap B=\{4,6\}

A match in one set is not enough. Compare both rosters before keeping a label. A shared label is written once, even though it appears in both source sets.

Check your reasoning

A={1,4}A=\{1,4\} and B={4,7}B=\{4,7\}. Build ABA\cap B.

Show answer and explanation

The intersection is {4}\{4\}. Check the stated membership rule for each candidate.

02If the sets share no members, the result is the empty set#

If the sets share no members, the result is the empty set. An empty result does not mean that each original set was empty.

A disjoint example.

{1,3}{2,4}=\{1,3\}\cap\{2,4\}=\varnothing
Check your reasoning

A lists {csv, json}; B lists {json, xml}. A transfer needs support in both. Which formats work?

  1. A{json}
  2. B{csv, json, xml}
  3. C{csv, xml}
Show answer and explanation
{json}

Only json is shared.

03Check your understanding#

Check your reasoning

What is {3,9}\{3,9\}\cap\varnothing?

  1. A{3,9}\{3,9\}
  2. B\varnothing
  3. C{0}\{0\}
Show answer and explanation
\varnothing

No object belongs to the empty set, so no object belongs to both.

Key takeaway

Check each distinct object against the two sets. Keep an object only when it occurs in both; no shared objects gives an empty set.

  • Form the intersection of two finite sets

Sources & further reading

  1. [1]

Reference this concept

Link to this page, a section, or an individual figure.

Glacius. “Set intersection.” Math behind ML. /learn/f-intersection