Set-Builder Notation Converter & Set Operations Calculator

Convert between set-builder and roster notation, perform union/intersection/difference, test membership, and explore set theory interactively.

Set-Builder Notation Converter & Operations

e.g. x > 0 && x <= 10, x % 2 === 0, isPrime(x)
Set-Builder Notation
{ x | x > 0 && x <= 10, x ∈ ℤ }
Rule-based definition
Roster Notation
{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }
Enumerated members
Cardinality |S|
10
10 elements found
Range (interval)
[1, 10]
Smallest to largest member
Is Empty?
No
10 elements found
Domain Searched
ℤ ∩ [−100, 200]
Finite search window for integer sets

Members Grid

12345678910

Set Notation Reference

NotationNameMeaningExample
{ x | P(x) }Set-builderAll x satisfying P(x){ x | x > 0, x ∈ ℤ }
{ 1, 2, 3 }RosterExplicit list{ 1, 2, 3 }
A ∪ BUnionIn A or B{ 1,2 } ∪ { 2,3 } = { 1,2,3 }
A ∩ BIntersectionIn both A and B{ 1,2 } ∩ { 2,3 } = { 2 }
A \ BDifferenceIn A but not B{ 1,2 } \ { 2,3 } = { 1 }
A △ BSymmetric DiffIn A or B, not both{ 1,2 } △ { 2,3 } = { 1,3 }
x ∈ AMembershipx is in A2 ∈ { 1,2,3 }
|A|CardinalityNumber of elements|{ 1,2,3 }| = 3
Planning notes, formulas, and examples

About the Set-Builder Notation Converter & Set Operations Calculator

Set theory is the foundation of modern mathematics — every mathematical structure from numbers to functions to topological spaces is ultimately built on sets. Two fundamental ways to describe a set are roster notation (listing elements: {1, 2, 3}) and set-builder notation (defining by a rule: {x | x ∈ ℤ, 0 < x ≤ 3}). Converting between them, and performing operations like union, intersection, and difference, are core skills in discrete math, logic, and computer science.

It gives three modes: (1) convert set-builder rules to explicit rosters by evaluating the rule over a specified domain, (2) perform classic set operations (union A ∪ B, intersection A ∩ B, difference A \ B, symmetric difference A △ B) with visual breakdown, and (3) test element membership. Presets cover common cases — even numbers, primes, perfect squares — and you can write any JavaScript-style rule for custom sets.

Whether you are studying for a discrete mathematics exam, teaching set theory to beginners, or just need to compute the intersection of two data sets, this page makes set operations visual and easy to inspect.

When This Page Helps

Set theory notation can be confusing for students encountering it for the first time. Converting between representations, performing operations, and testing membership by hand is tedious. This page automates the mechanical work so you can focus on understanding the concepts.

It is also useful for quick data-set comparisons: paste two comma-separated lists and inspect what is shared, what is unique to each, and what belongs to the combined set.

How to Use the Inputs

  1. Choose a mode: Set-Builder → Roster, Set Operations, or Membership Test.
  2. For set-builder mode, enter a rule as a JavaScript expression (e.g., x > 0 && x <= 10). Use isPrime(x) for primes.
  3. Select the domain: Integers (ℤ) or Naturals (ℕ).
  4. For operations, enter two comma-separated sets A and B.
  5. For membership, enter set A and a test element.
  6. Read output cards for the results. Examine the Venn diagram breakdown for operations.
  7. Use the notation reference table as a quick cheat sheet.
Formula used
A ∪ B = {x | x ∈ A or x ∈ B}. A ∩ B = {x | x ∈ A and x ∈ B}. A \ B = {x | x ∈ A and x ∉ B}. A △ B = (A \ B) ∪ (B \ A). |A ∪ B| = |A| + |B| − |A ∩ B|.

Example Calculation

Result: Union = {1,2,3,4,5,6,7}, Intersection = {3,4,5}, Difference = {1,2}

Union combines all elements. Intersection finds common elements. A\B removes B's elements from A.

Tips & Best Practices

  • For primes, use the built-in isPrime(x) function: "isPrime(x) && x >= 2 && x <= 50".
  • Combine conditions with && (and) and || (or): "x % 2 === 0 && x >= 1 && x <= 20".
  • Perfect squares: "Math.sqrt(x) === Math.floor(Math.sqrt(x)) && x >= 1".
  • Use the operations mode to verify homework on union/intersection problems.
  • The inclusion-exclusion formula |A ∪ B| = |A| + |B| − |A ∩ B| is shown in the output.
  • Check the notation reference table for symbols like ∈, ∪, ∩, \, △.

Set Theory Foundations

Georg Cantor founded set theory in the 1870s–1880s. His work on infinite sets — showing that the reals are uncountable (the diagonal argument) while the rationals are countable — is one of the most profound results in mathematics. Modern set theory (ZFC: Zermelo–Fraenkel with Choice) provides the axiomatic foundation for virtually all of mathematics. Even numbers, functions, and relations are defined as sets: an ordered pair (a,b) is {{a},{a,b}}, a function is a set of ordered pairs satisfying the vertical line test, and so on.

Notation Systems

Roster notation is concrete: {2, 4, 6, 8, 10}. Set-builder notation is abstract: {x ∈ ℤ | x is even, 0 < x ≤ 10}. Interval notation works for subsets of ℝ: (0, 10] is all reals between 0 (exclusive) and 10 (inclusive). Each notation has strengths — rosters are unambiguous for finite sets, set-builder works for infinite sets, and intervals are compact for contiguous real ranges.

Applications in Computer Science

Sets are ubiquitous in CS. SQL's UNION, INTERSECT, and EXCEPT mirror ∪, ∩, and \. Python's set type provides O(1) membership testing. In formal language theory, a language is a set of strings over an alphabet. Type systems use set-theoretic operations (union types, intersection types). And complexity classes like P, NP, and PSPACE are sets of decision problems. Understanding set theory is not optional — it is the language of computer science.

Sources & Methodology

Last updated:

Frequently Asked Questions

  • A way to define a set by a rule: {x | condition(x)} means "the set of all x satisfying the condition." For example, {x | x ∈ ℤ, x > 0} is the positive integers.