Visual Tools
Calculators
Tables
Mathematical Keyboard
Converters
Other Tools


Set-Builder Notation Explorer


How to use
  1. The expression at the top is the set you are building. It always has the same two parts: a domain before the bar, and a condition after it.
  2. Pick the domain from the Domain panel — the natural numbers, the naturals with zero, the integers, or a finite set you type yourself.
  3. Add a condition with the Add condition button, then choose a test from the dropdown: comparisons, between, even, odd, prime, perfect square, divisibility, or x2<ax^2 < a.
  4. Conditions that need a number show a box for it. Change the number and the candidates re-filter as you type.
  5. With two or more conditions, the and / or switch decides whether a candidate must pass every test or just one of them.
  6. The candidate strip shows the domain. Green chips pass the condition and are in the set; grey chips are candidates that failed.
  7. A trailing ellipsis means the domain runs on past the chips shown — the strip is a window, not the whole domain.
  8. Click any candidate, or focus it and press Enter, to see it tested condition by condition with a tick or a cross for each.
  9. The Roster form panel lists the members in braces, or shows \varnothing when nothing passes and says so when the set is too big to list.
  10. The preset buttons load ready-made expressions, and the line under the builder reads the whole thing back to you in words.


The set

9 members
{ x : x is even ∧ x < 20 }
the set of all x in the natural numbers such that x is even and x is less than 20
123456789101112131415161718192021222324
Click a candidate to see it tested against each condition.

Roster form

{ 2, 4, 6, 8, 10, 12, 14, 16, 18 }

Finite, so roster form is exact. Both notations describe the same set.

Joining with and is intersection

Two conditions joined by and keep only the candidates passing both, which is exactly what \cap does:

{xN:P(x) and Q(x)}={xN:P(x)}{xN:Q(x)}\{x \in ℕ : P(x) \text{ and } Q(x)\} = \{x \in ℕ : P(x)\} \cap \{x \in ℕ : Q(x)\}


Of the 24 candidates shown, 9 pass both. Switch to or and the same two conditions give the union instead.

The bar notation and the operation symbols are not two topics. They are two ways of writing one filter.
Under and the set can only shrink as conditions are added, so an empty set stays empty. Learn more about joining with and · Joining conditions

Domain

Every set-builder expression needs a domain. Without one, "all x such that…" is not a set — that assumption is what Russell's paradox breaks.

Conditions

Join with

Examples







Getting Started

The expression across the top of the tool is the set you are building, and it never has more than two parts: a domain before the bar, and a condition after it.

Everything else on the page feeds those two. The Domain panel sets where candidates come from. The condition rows set the test they have to pass. The strip of chips shows the candidates, green for the ones in the set and grey for the ones that failed.

The fastest way in is the preset buttons, which load complete expressions you can then take apart. Under the builder line there is also a reading of the whole expression in plain words, which is worth glancing at whenever the symbols stop being obvious.

One thing to notice early: an expression with no condition at all is legal. It keeps the entire domain, which is a condition with nothing to test — legal, and pointless, and a useful thing to have seen once.

An Empty Condition

Remove every condition and the bar has nothing after it. Each candidate is tested against no requirement at all, so each one passes and the whole strip turns green.
{ x }123456789101112131415161718192021222324
No condition after the bar, frozen

Every candidate passes a test that asks for nothing, so the set is the domain itself.

The set here is the domain itself: {xN}=N\{x \in \mathbb{N}\} = \mathbb{N}. That is legal notation, and it is also pointless notation — a filter that filters nothing is a longer way of writing N\mathbb{N}.

It is worth seeing once because it isolates what the condition contributes. The domain alone gives you everything; the condition is the only thing that can take members away. Every set you build here is a subset of the domain, never larger, which is the shape of the whole notation in one picture.

Add a condition and candidates start failing immediately — the ordinary case is one condition and a finite answer.

Choosing the Domain

The Domain panel offers four choices, and they change the set even when the condition is untouched.

• The natural numbers, starting at 1.
• The naturals including zero.
• The integers, which bring negative candidates into play.
• A finite set you type yourself, entered as numbers separated by commas.

The domain is the first of two gates. It decides which things are even eligible for testing, and anything outside it is never considered at all — not rejected, simply absent. That case has its own frame at a number outside the domain.

The chips shown are a window onto the domain rather than the whole of it. An infinite domain ends the strip with an ellipsis, because the candidates continue past what the panel can hold. A finite domain you type is shown in full.

Switching domains keeps your conditions intact, which makes the comparison easy to run: build an expression over the naturals, then switch to the integers and watch negative candidates arrive and be judged by the same test. Any selected candidate is cleared on the switch, since a pick made in one domain means nothing in another.

A Number Outside the Domain

With the domain set to N\mathbb{N} and the condition x<10x < 10, the number 4-4 satisfies the condition perfectly. It is still not in the set, and it is not even on the strip.
{ x : x < 10 }123456789101112131415161718192021222324-4not in ℕ — never tested
−4 against a domain of ℕ, frozen

It satisfies x < 10 and is still excluded, because the domain never offers it for testing.

This is the case people skip. A set-builder expression has two gates, and the domain is the first one. Something can pass the condition and still be excluded for coming from the wrong place, because the condition is never applied to it at all.

Switch the domain to Z\mathbb{Z} without touching the condition and 4-4 appears among the candidates and passes. Same condition, different set — which is the whole argument for why the domain matters, and the practical face of the restriction that keeps the notation free of paradox.

The distinction is worth stating in three parts, because the middle one is easy to lose: a number can be outside the domain, or inside the domain and failing, or inside and passing. Only the last is a member.

Adding Conditions

Add condition creates a row, and the dropdown in that row chooses the test. The available predicates cover most of what elementary set-builder expressions need:

• Comparisons — less than, at most, greater than, at least, equal, not equal.
• A between test, taking two bounds at once.
• Parity — even and odd.
• Number properties — prime, perfect square, and divisibility by a chosen number.
• A squared comparison, x2<ax^2 < a.

Tests that need a number show a box for it, and the candidates re-filter as you type rather than on submit, so you can watch the set change digit by digit.

Each row has a cross that removes it. Removing the last one takes you back to the no-condition case, and the whole domain floods green.

Conditions are independent of each other. Nothing stops you from adding two that overlap, or two that contradict, and the tool will not warn you — it simply reports what survives, which is the honest behaviour and occasionally a surprise.

The ordinary situation — one condition, a finite answer — is frozen at the ordinary bounded case.

The Ordinary Bounded Case

One condition, x<4x < 4, over the naturals. Three candidates pass, the rest go grey, and the roster panel can print the answer in full: {1,2,3}\{1, 2, 3\}.
{ x : x < 4 }123456789101112131415161718192021222324
x < 4 over the naturals, frozen

Three green chips, and a roster short enough to print. Both notations describe this set equally well.

This is the case where both notations are available, and comparing them is the point. {xN:x<4}\{x \in \mathbb{N} : x < 4\} and {1,2,3}\{1, 2, 3\} are the same set. Not equivalent, not corresponding — the same, and a set does not remember which notation named it.

Which one to write is a question of what you can afford. Roster form is concrete and needs no reading; builder form is compact and survives the set getting large. For three members the roster wins on clarity. Push the bound to x<4000x < 4000 and it stops being an option while the builder expression does not change shape at all.

That is the ordinary working state of the notation, and everything else on this page is a way it can go differently: nothing passing, one thing passing, or too many things passing to write down.

Joining Conditions with And or Or

With two or more conditions a switch appears: and or or.

Joined by and, a candidate has to pass every test. Joined by or, passing one is enough. The switch changes nothing about the conditions themselves — only how their verdicts are combined — and flipping it back and forth over the same two tests is the clearest demonstration in the tool.

The two settings are exactly intersection and union, which is the point:

{xD:P(x) and Q(x)}={xD:P(x)}{xD:Q(x)}\{x \in D : P(x) \text{ and } Q(x)\} = \{x \in D : P(x)\} \cap \{x \in D : Q(x)\}


{xD:P(x) or Q(x)}={xD:P(x)}{xD:Q(x)}\{x \in D : P(x) \text{ or } Q(x)\} = \{x \in D : P(x)\} \cup \{x \in D : Q(x)\}


The asymmetry between them is worth holding onto. Under and, every condition you add can only remove candidates, so the set shrinks or stays put. Under or, every condition you add can only admit candidates, so the set grows or stays put. Neither can do both.

Both are frozen below, over the same pair of conditions: joined by and and joined by or.

Two Conditions Joined by And

Even numbers below twelve: two conditions, joined by and, so a candidate has to pass both. Five chips survive out of the window shown.
{ x : x is even and x < 12 }123456789101112131415161718192021222324
Even and below twelve, frozen

Five survivors. Under and, each extra condition is another way to be excluded, so the set can only shrink.

Joining with and is intersection, exactly:

{xD:P(x) and Q(x)}={xD:P(x)}{xD:Q(x)}\{x \in D : P(x) \text{ and } Q(x)\} = \{x \in D : P(x)\} \cap \{x \in D : Q(x)\}


The left-hand side filters once with a compound test; the right-hand side filters twice and keeps what both runs agree on. Same members, and the equality is not a rule to memorise so much as a restatement of what "and" does.

Adding a condition under and can only shrink the set or leave it unchanged, never grow it — each new test is another way to be excluded. That monotonicity is worth carrying around: if a set is already empty, no further and condition will repopulate it.

Flip the switch and the same two conditions give the union instead.

Two Conditions Joined by Or

The same two conditions — even, and below twelve — joined by or. Now passing either one is enough, and eighteen of the twenty-four candidates survive.
{ x : x is even or x < 12 }123456789101112131415161718192021222324
Even or below twelve, frozen

Eighteen survivors. Candidates passing both tests are green once — sets carry no multiplicities.

Joining with or is union:

{xD:P(x) or Q(x)}={xD:P(x)}{xD:Q(x)}\{x \in D : P(x) \text{ or } Q(x)\} = \{x \in D : P(x)\} \cup \{x \in D : Q(x)\}


The or here is inclusive: a candidate passing both tests is still in the set, and still counted once. Sets carry no multiplicities, so there is nothing to double up.

That single fact is the reason counting unions needs a correction term while counting a filtered list does not. AB=A+BAB|A \cup B| = |A| + |B| - |A \cap B| subtracts the overlap precisely because the union already merged it, and the chips show why — the numbers that are both even and below twelve are green once, not twice.

Compare the same pair under and, where the five overlapping candidates are the entire set rather than the part that needs correcting.

Testing a Candidate

Click any chip — or focus it and press Enter — and the panel underneath tests that number condition by condition, a tick or a cross for each, with the verdict at the top.

This is the membership test made visible. Asking whether something belongs to a set defined this way is never a matter of looking it up in a list; it is a matter of running the condition. That is exactly why the notation can describe sets nobody could finish writing down.

With more than one condition the panel also restates how the verdicts combine, because a candidate can fail one test and still be in the set when the join is or.

Testing candidates one at a time is also the fastest way to debug an expression that is returning the wrong set. Pick a number you expected to be a member, read which condition rejected it, and the mistake is usually in that row rather than anywhere else.

Clicking the same chip again clears the selection. Both outcomes have their own frame: a candidate that passes and a candidate that fails.

A Candidate That Passes

With the primes selected, clicking 77 tests it and reports the verdict: a tick against the condition, and 77 is in the set.
{ x : x is prime }123456789101112131415161718192021222324
7 tested against the primes, frozen

The chip is outlined and the verdict is a tick: 7 comes from the domain and satisfies the condition.

This is the entire membership test, performed rather than looked up. 77 comes from the domain, the condition is applied to it, and the answer decides membership. There is no list being consulted anywhere.

That is the property that lets set-builder notation describe sets no one could write down. Membership in {xN:x is prime}\{x \in \mathbb{N} : x \text{ is prime}\} is decidable for any candidate you name, however large, even though the set is infinite and no roster exists.

Note also what the tick does *not* say. It reports that this candidate satisfies the condition, not that the condition is a good description of the set you had in mind. The tool checks your expression; it cannot check your intention. The opposite verdict is at a candidate that fails.

A Candidate That Fails

Clicking 99 with the same condition gives a cross. It is a perfectly good natural number, and it is not in the set.
{ x : x is prime }123456789101112131415161718192021222324
9 tested against the primes, frozen

A good natural number, rejected. Grey chips were tested and failed — they are not outsiders.

Being in the domain and being in the set are different things, and the failing chips are the difference made visible. Grey candidates are not errors and not outsiders — they were tested and rejected.

That is the second gate at work. The domain decided 99 was worth testing; the condition decided it does not stay. Both gates are needed, and skipping the distinction is what makes set-builder expressions confusing to read at first.

With several conditions the panel names which ones failed, which matters when the join is or, because failing one test is survivable there and fatal under and.

A third possibility exists and looks similar at a glance: a number that never gets tested at all, at a number outside the domain.

Reading the Roster Panel

The Roster form panel writes the finished set out in braces — the same set the builder expression describes, in the other notation.

Three things can appear there, and each says something different:

• A list of members, when the set is finite and small enough to print.
• The empty-set symbol, when nothing passed. That is an answer, not a failure — see nothing passes the filter.
• A note that the set cannot be listed, when the condition leaves the domain unbounded.

The panel is the honest check on whether you have built what you meant. An expression can look right and produce a roster you did not expect, and the roster is the one that is telling the truth.

It is also the panel that shows how much the two notations differ in reach. For a small finite set the roster is the friendlier of the two; the moment the condition stops bounding the domain, the roster has nothing to offer and the builder expression carries the whole description on its own.

Watch for the single-member case in particular, where the braces matter: exactly one survivor.

Nothing Passes the Filter

Ask for numbers that are both even and odd and every chip stays grey. No candidate in the domain survives, so the roster panel shows the empty-set symbol.
{ x : x is even and x is odd }123456789101112131415161718192021222324
Even and odd at once, frozen

Not one chip survives. Two conditions that cannot both hold give the empty set however large the domain is.

An empty result is an answer rather than an error, and the distinction matters. The expression is well formed, the domain is populated, the conditions are meaningful — they simply cannot hold at once.

Conditions joined by and make this easy to arrange, because two incompatible tests give the empty set however large the domain is. Parity is the cleanest example: no integer is both even and odd, so the size of the domain is irrelevant.

This is also how the empty set is usually *proved* to be empty in practice. You rarely check every candidate; you show that the conditions are contradictory, and emptiness follows. Clicking any chip shows the same thing case by case — see a candidate that fails.

Exactly One Survivor

Ask for numbers that are prime and even and exactly one chip lights up. Two is the only even prime, so the set has a single member.
{ x : x is prime and x is even }123456789101112131415161718192021222324
Prime and even, frozen

One chip. Two is the only even prime, so the set is a singleton — and {2} is not the same object as 2.

The roster form is {2}\{2\}, and the braces are not decoration. 22 is a number; {2}\{2\} is a set whose only member is that number, and the two are not interchangeable.

2{2}is true2={2}is not2 \in \{2\} \quad \text{is true} \qquad 2 = \{2\} \quad \text{is not}


A set with one member is called a singleton, and confusing it with its member is one of the most common slips in early set theory. The distinction becomes unavoidable later: {}\{\varnothing\} is a singleton whose member is the empty set, so it has one member while \varnothing has none.

The result here is also a small theorem rather than an accident. Every even number beyond 22 has 22 as a proper divisor, so none of them can be prime.

What Set-Builder Notation Is

Set-builder notation defines a set by a rule its members satisfy, rather than by listing them. The standard shape is

{xD:P(x)}\{x \in D : P(x)\}


read as "the set of all xx in DD such that P(x)P(x)". The bar is sometimes written as a colon and sometimes as a vertical stroke; they mean the same thing, and this tool uses the colon.

Three pieces do the work. The variable xx stands for a candidate. The domain DD says where candidates come from. The predicate P(x)P(x) is the test — a statement about xx that is either true or false for each one.

The set is exactly the candidates that make the predicate true. Nothing else is implied: the notation does not order the members, does not count repeats, and does not care which rule you used if two rules pick out the same things. For the underlying vocabulary, see set theory definitions.

Why the Domain Matters

Dropping the domain and writing "all xx such that P(x)P(x)" looks like a harmless abbreviation. It is not, and the reason is one of the more famous results in the subject.

Unrestricted comprehension — the assumption that any property whatsoever carves out a set — produces Russell's paradox. Take the property of not containing yourself, form the set of everything with that property, and ask whether that set contains itself. Either answer contradicts itself.

The repair adopted by modern set theory is exactly the domain in front of the bar: you may separate out the members of an existing set that satisfy a property, but you may not conjure a set from a property alone. Written properly, every set-builder expression names the set its candidates are drawn from.

The practical consequence is smaller but constant. {xN:x2<10}\{x \in \mathbb{N} : x^2 < 10\} and {xZ:x2<10}\{x \in \mathbb{Z} : x^2 < 10\} are different sets with identical conditions — the second has four negative members the first cannot reach.

Conditions as Set Operations

Every logical connective in a condition corresponds to an operation on sets, which is why the bar notation and the operation symbols are not separate topics.

Joining with and gives intersection; joining with or gives union. Negating a condition gives the complement relative to the domain:

{xD:not P(x)}=D{xD:P(x)}\{x \in D : \text{not } P(x)\} = D \setminus \{x \in D : P(x)\}


That last one is why the complement always needs a domain to be taken relative to. There is no absolute complement, because there is no set of everything.

Difference follows from the same pattern, since AsetminusBA setminus B keeps what is in AA and not in BB — a conjunction with a negation in it, exactly as the condition would be written.

The correspondence runs in both directions and is worth using deliberately. A set expression that is awkward to read as operations is often obvious written as a condition, and the reverse happens just as often. For the operations in their own right, see set operations.

When Roster Form Runs Out

Roster form — listing members between braces — works only while there are few enough members to write.

Past that point it starts leaning on an ellipsis, and an ellipsis is an appeal to the reader to guess the rule. {2,4,6,}\{2, 4, 6, \ldots\} probably means the positive even numbers, but nothing in the notation says so; it could be powers of two continuing 8,168, 16. The rule is doing the work either way, and roster form leaves it unstated.

Set-builder notation states the rule instead, so nothing is left to guess:

{xN:x is even}\{x \in \mathbb{N} : x \text{ is even}\}


This is why the notation is not merely a convenience. Every infinite set you meet is named by a rule like this one, because there is no alternative once the elements run out of room.

The limitation is not really about infinity, either. A finite set of ten thousand members has a roster form in principle and none in practice, and the builder expression that describes it is no longer than the one for three members. The frozen case is a set too big to list.

A Set Too Big to List

Ask for the even naturals and the filter keeps passing candidates for as long as the strip runs, then the ellipsis says what the strip cannot: the domain continues, and so does the set.
{ x : x is even }123456789101112131415161718192021222324
The even naturals, frozen

Every second chip is green and the ellipsis carries the pattern past the window. No list can finish this set.

Nothing bounds this condition. Every candidate is tested and infinitely many pass, so no list can finish and the roster panel says so rather than pretending otherwise.

This is where the notation stops being a convenience and becomes a necessity. {xN:x is even}\{x \in \mathbb{N} : x \text{ is even}\} names this set exactly, in eight symbols, with nothing left implicit. Roster form can only gesture at it.

The strip is worth reading carefully here, because it makes the pattern visible without claiming to be complete: every second chip is green, forever. A window onto an infinite set is not the set, and the ellipsis is the tool being honest about the difference. The argument in full is in when roster form runs out.