Logic & Sets

Set Notation: Symbols, Meaning and Worked Examples

Set notation writes a collection of objects between curly braces, either by listing them, {2,4,6}\{2, 4, 6\}, or by stating a rule, {x∈Z∣x is even, 0<x<8}\{x \in \mathbb{Z} \mid x \text{ is even},\ 0 < x < 8\}. The rule form reads “the set of all integers xx such that xx is even and between 0 and 8.”

{ x∈D∣P(x) }\{\,x \in D \mid P(x)\,\}

Both versions name the same set. Everything else in the notation (membership, subsets, unions, intervals) is a short list of symbols that describe how sets relate. Each symbol below is tied to an idea you can test, along with the traps that cost the most points.

What does set notation mean and how do you read it?

A set is a collection of distinct objects, and the braces say “gather these.” Order carries no information and repeats add nothing, so {1,2,3}\{1, 2, 3\}, {3,2,1}\{3, 2, 1\} and {1,1,2,3}\{1, 1, 2, 3\} are one and the same set. That separates a set from an ordered pair or a sequence, where (1,2)(1, 2) and (2,1)(2, 1) are different. By convention, capital letters name sets and lowercase letters name elements, as in A={1,2,3}A = \{1, 2, 3\}.

The symbols you need first:

  • 2∈A2 \in A means 2 is an element of AA, and 5∉A5 \notin A means 5 is not.
  • ∣A∣|A| or n(A)n(A) is the number of distinct elements, called the cardinality. Here ∣A∣=3|A| = 3.
  • ∅\emptyset or { }\{\ \} is the empty set, with no elements.
  • UU is the universal set, everything under discussion.
  • N\mathbb{N}, Z\mathbb{Z}, Q\mathbb{Q}, R\mathbb{R} are the natural numbers, integers, rationals and reals.

Textbooks disagree on whether N\mathbb{N} starts at 0 or 1, and it changes answers. The set {x∈N∣x<3}\{x \in \mathbb{N} \mid x < 3\} is {1,2}\{1, 2\} in one convention and {0,1,2}\{0, 1, 2\} in the other, so check which one your course uses.

Elements can themselves be sets. The set {1,{2,3}}\{1, \{2, 3\}\} has two elements, the number 1 and the set {2,3}\{2, 3\}, not three. A Venn diagram draws a set as a region, which is a useful way to see all of this before the symbols get heavier.

Quick check

How many elements does {4,7,7,2}\{4, 7, 7, 2\} have?

Roster form vs set-builder notation: how do you convert?

Roster form lists the elements. Set-builder notation states a rule, and it has three parts: a variable, a separator (a vertical bar or a colon, both meaning “such that”), and a condition. A domain such as x∈Zx \in \mathbb{Z} usually sits before the bar.

The domain is the part students drop, and it changes the set. The set {x∣1<x<2}\{x \mid 1 < x < 2\} has infinitely many elements if xx is real, such as 1.51.5 and 1.011.01, but no elements at all if xx must be an integer. Without a stated domain, the notation is ambiguous.

Going from a list to a rule means spotting the pattern. For {3,6,9,12,15}\{3, 6, 9, 12, 15\}, the elements are 3k3k for k=1k = 1 to 55, so {3k∣k∈Z, 1≤k≤5}\{3k \mid k \in \mathbb{Z},\ 1 \le k \le 5\} works. Going the other way, expressions can appear left of the bar, which is where repeats sneak in.

Worked example. Write {n2∣n∈Z, −2≤n≤2}\{n^2 \mid n \in \mathbb{Z},\ -2 \le n \le 2\} in roster form.

  1. List the allowed values of nn: −2,−1,0,1,2-2, -1, 0, 1, 2.
  2. Square each one: 4,1,0,1,44, 1, 0, 1, 4.
  3. Remove repeats, since a set lists each element once.

{n2∣n∈Z, −2≤n≤2}={0,1,4}\{n^2 \mid n \in \mathbb{Z},\ -2 \le n \le 2\} = \{0, 1, 4\}

The set has 3 elements, not 5. Squaring sends both −2-2 and 22 to 4, and both −1-1 and 11 to 1.

Inequalities in set notation and interval notation

Interval notation is a compact way to write a set of real numbers that forms an unbroken stretch of the number line. A parenthesis excludes an endpoint and a square bracket includes it. Infinity is not a number you can reach, so it always gets a parenthesis.

Set-builder Interval Number line
{x∣x>3}\{x \mid x > 3\} (3,∞)(3, \infty) open dot at 3, arrow right
{x∣x≥3}\{x \mid x \ge 3\} [3,∞)[3, \infty) closed dot at 3, arrow right
{x∣−1<x≤4}\{x \mid -1 < x \le 4\} (−1,4](-1, 4] open at −1-1, closed at 4
{x∣x≠2}\{x \mid x \ne 2\} (−∞,2)∪(2,∞)(-\infty, 2) \cup (2, \infty) everything except 2

One trap: (−1,4)(-1, 4) is also how an ordered pair is written. Context decides, and a quick glance at whether the problem is about points or about solutions usually settles it.

The same idea describes geometry. The set of acute angles is {θ∣0∘<θ<90∘}\{\theta \mid 0^\circ < \theta < 90^\circ\}, which is the interval (0∘,90∘)(0^\circ, 90^\circ), and a right angle is the single-element set {90∘}\{90^\circ\}. The types of angles are really named intervals. Domains work the same way: since the input of a log must be positive, the domain of log⁡bx\log_b x is (0,∞)(0, \infty), a fact the logarithm rules rely on constantly.

Worked example. Solve −2x+5≥1-2x + 5 \ge 1 and write the answer in set notation.

  1. Subtract 5 from both sides: −2x≥−4-2x \ge -4.
  2. Divide by −2-2 and flip the inequality: x≤2x \le 2.
  3. Write the set: {x∈R∣x≤2}=(−∞,2]\{x \in \mathbb{R} \mid x \le 2\} = (-\infty, 2].

Check: x=2x = 2 gives −4+5=1≥1-4 + 5 = 1 \ge 1, which is true, and x=3x = 3 gives −1≥1-1 \ge 1, which is false.

Try this: Write the set of all xx with ∣x∣<3|x| < 3 in both set-builder and interval notation. Then test x=3x = 3, x=0x = 0 and x=−3x = -3 to see which endpoints belong.

Element of or subset of: what is the difference?

The symbol ∈\in connects a thing to a set. The symbol ⊆\subseteq connects a set to a set. With A={1,2,3}A = \{1, 2, 3\}, the statements 2∈A2 \in A and {2}⊆A\{2\} \subseteq A are true, while 2⊆A2 \subseteq A is meaningless and {2}∈A\{2\} \in A is false. A quick test: if the left side is a set, use ⊆\subseteq, and if it is a single object, use ∈\in.

Sets can be elements of other sets, which is the only time a set belongs after ∈\in. For C={{1,2},3}C = \{\{1, 2\}, 3\}, the statement {1,2}∈C\{1, 2\} \in C is true because that set is one of the two elements of CC.

Counting subsets

Each of the nn elements is either in a subset or out, two choices each, so there are 2n2^n subsets. The set {a,b,c}\{a, b, c\} has 23=82^3 = 8 of them, including ∅\emptyset and the set itself, and 23−1=72^3 - 1 = 7 are proper.

The empty set is a subset of every set. To fail ∅⊆B\emptyset \subseteq B there would have to be an element of ∅\emptyset missing from BB, and ∅\emptyset has no elements to be missing. Also keep ∅\emptyset and {∅}\{\emptyset\} apart: the first is an empty box, the second is a box holding an empty box, so ∣∅∣=0|\emptyset| = 0 but ∣{∅}∣=1|\{\emptyset\}| = 1.

A proper subset is written A⊊BA \subsetneq B and means A⊆BA \subseteq B with A≠BA \ne B. Some books use ⊂\subset for a plain subset and others use it for proper, so match your course.

Quick check

True or false: {3}∈{1,2,3}\{3\} \in \{1, 2, 3\}.

Union, intersection and complement in set notation

Rows of numbered cells showing sets A and B overlap in 4, 5, 6 and the union has 8 elements
Sets A and B share 4, 5 and 6, so the union has 6 + 5 − 3 = 8 elements.

Four operations cover most problems. The union A∪BA \cup B collects everything in either set. The intersection A∩BA \cap B keeps what is in both. The difference A∖BA \setminus B keeps what is in AA but not in BB. The complement AcA^c (also written A′A') is everything in the universal set that is not in AA. For worked cases beyond these, see union and intersection of sets.

The complement is the only operation that cannot be computed without a universe. Asking for AcA^c without UU has no answer, because “not in AA” could mean anything.

Worked example. Let U={1,2,…,9}U = \{1, 2, \dots, 9\}, A={1,2,3,4,5,6}A = \{1, 2, 3, 4, 5, 6\} and B={4,5,6,7,8}B = \{4, 5, 6, 7, 8\}. Find A∪BA \cup B, A∩BA \cap B, A∖BA \setminus B, (A∪B)c(A \cup B)^c and test the counting rule.

  1. Union: A∪B={1,2,3,4,5,6,7,8}A \cup B = \{1, 2, 3, 4, 5, 6, 7, 8\}.
  2. Intersection: A∩B={4,5,6}A \cap B = \{4, 5, 6\}.
  3. Difference: A∖B={1,2,3}A \setminus B = \{1, 2, 3\}.
  4. Complement of the union: (A∪B)c={9}(A \cup B)^c = \{9\}.

The counting rule says the overlap is counted twice if the sizes are simply added:

∣A∪B∣=∣A∣+∣B∣−∣A∩B∣=6+5−3=8|A \cup B| = |A| + |B| - |A \cap B| = 6 + 5 - 3 = 8

That matches the 8 elements in step 1. De Morgan’s law also checks out: Ac={7,8,9}A^c = \{7, 8, 9\} and Bc={1,2,3,9}B^c = \{1, 2, 3, 9\}, and Ac∩Bc={9}A^c \cap B^c = \{9\}, the same as (A∪B)c(A \cup B)^c.

One habit prevents a common slip: the union symbol ∪\cup is a rounded cup, while UU is the universal set. In handwriting the two look alike, so write the universal set as UU with a serif or say it aloud.

How does set notation connect to logic?

Every set operation is a logical connective in disguise. Membership in A∩BA \cap B means x∈Ax \in A AND x∈Bx \in B. Membership in A∪BA \cup B means x∈Ax \in A OR x∈Bx \in B, with “or” being inclusive. Membership in AcA^c means NOT x∈Ax \in A. The truth tables for the five logical connectives are the same information as the Venn diagram regions.

Subset is an implication. The statement A⊆BA \subseteq B says: if x∈Ax \in A then x∈Bx \in B. So the contrapositive must also be true: if x∉Bx \notin B then x∉Ax \notin A, which is Bc⊆AcB^c \subseteq A^c. For example, the multiples of 6 are a subset of the multiples of 3. The converse fails, since 9 is a multiple of 3 but not of 6.

Proving two sets equal

To show A=BA = B, prove A⊆BA \subseteq B and B⊆AB \subseteq A. One direction alone proves only containment.

That two-direction requirement is a biconditional statement in set form: x∈Ax \in A if and only if x∈Bx \in B. It is also why De Morgan’s laws for sets and for logic are the same law: “not (P or Q)” matches “not P and not Q” exactly as (A∪B)c=Ac∩Bc(A \cup B)^c = A^c \cap B^c.

How do you write a solution set in set notation?

A solution set collects every value that makes a statement true, and the domain you solve over changes the answer. Over the reals, x2−5x+6=0x^2 - 5x + 6 = 0 factors as (x−2)(x−3)=0(x - 2)(x - 3) = 0, so the solution set is {2,3}\{2, 3\}. For x2+1=0x^2 + 1 = 0, the real solution set is ∅\emptyset, but over the complex numbers it is {i,−i}\{i, -i\}. The discriminant, which the quadratic formula practice problems use, tells you whether the real solution set has two elements, one or none.

Inequalities give intervals. For x2−5x+6<0x^2 - 5x + 6 < 0, the parabola opens upward and crosses zero at 2 and 3, so it is negative between them:

{x∈R∣2<x<3}=(2,3)\{x \in \mathbb{R} \mid 2 < x < 3\} = (2, 3)

A quick check: x=2.5x = 2.5 gives 6.25−12.5+6=−0.256.25 - 12.5 + 6 = -0.25, which is negative.

Graphs are sets too. A line like y=2x−1y = 2x - 1 is the set {(x,y)∈R2∣y=2x−1}\{(x, y) \in \mathbb{R}^2 \mid y = 2x - 1\}, and its form is explored in slope-intercept form. Solving a system is then intersecting two such sets. For y=2x−1y = 2x - 1 and y=−x+5y = -x + 5, set the right sides equal: 2x−1=−x+52x - 1 = -x + 5, so 3x=63x = 6 and x=2x = 2, then y=3y = 3. The intersection is the single-element set {(2,3)}\{(2, 3)\}. Parallel lines would give ∅\emptyset.

Quick check

What is {x∈R∣x2=−4}\{x \in \mathbb{R} \mid x^2 = -4\}?

How can you check an answer written in set notation?

Four quick tests catch nearly every error:

  1. Read it aloud. Translate the symbols into “the set of all … such that …” and see whether it matches the question.
  2. Test the boundary. Plug each endpoint into the original statement to decide between a bracket and a parenthesis.
  3. Test one member and one non-member. A value inside should satisfy the original condition, and a value outside should fail it.
  4. Count. For two finite sets, compare ∣A∪B∣|A \cup B| with ∣A∣+∣B∣−∣A∩B∣|A| + |B| - |A \cap B|.

The boundary test is the fastest fix for the most common lost point. For x2−x−6≤0x^2 - x - 6 \le 0, the endpoints are the roots −2-2 and 33. Plugging in x=3x = 3 gives 9−3−6=09 - 3 - 6 = 0, and 0≤00 \le 0 is true, so the endpoint stays in: [−2,3][-2, 3]. With a strict inequality <<, the same plug-in gives 0<00 < 0, which is false, so the interval would be open.

Also check that the notation itself is legal. Braces belong around sets, so {2,3}\{2, 3\} is correct for a list of solutions, but 2,32, 3 alone is not a set. And a stray repeat like {0,1,1,4}\{0, 1, 1, 4\} is not wrong, only redundant, but counting it as four elements is.

Where is set notation used in real problems?

Probability is built on it. Rolling a die has sample space S={1,2,3,4,5,6}S = \{1, 2, 3, 4, 5, 6\}. The event “roll an even number” is E={x∈S∣x is even}={2,4,6}E = \{x \in S \mid x \text{ is even}\} = \{2, 4, 6\}, and when outcomes are equally likely:

P(E)=∣E∣∣S∣=36=12P(E) = \frac{|E|}{|S|} = \frac{3}{6} = \frac{1}{2}

Events combine with the same operations: “even or greater than 4” is a union, and “even and greater than 4” is an intersection.

Databases use the same ideas. A table is a set of rows, and the SQL commands UNION and INTERSECT do exactly what ∪\cup and ∩\cap do, including removing duplicate rows. Programming languages such as Python have a built-in set type where order is ignored and repeats collapse, matching the rules from the first section.

In algebra, the notation shows up whenever a function’s domain and range are stated, for example {x∈R∣x≠0}\{x \in \mathbb{R} \mid x \ne 0\} for 1x\frac{1}{x}. Reading that line aloud is all it takes: every real number except zero.

Practice problems

0 of 5 solved

  1. Write A={x∈Z∣−2<x≤3}A = \{x \in \mathbb{Z} \mid -2 < x \le 3\} in roster form.

  2. Write (−∞,4](-\infty, 4] in set-builder notation.

  3. Let A={1,3,5,7,9}A = \{1, 3, 5, 7, 9\} and B={3,6,9,12}B = \{3, 6, 9, 12\}. Find A∪BA \cup B and A∩BA \cap B.

  4. Let U={1,2,…,10}U = \{1, 2, \dots, 10\}, A={x∈U∣x is even}A = \{x \in U \mid x \text{ is even}\} and B={x∈U∣x>6}B = \{x \in U \mid x > 6\}. Find Ac∩BA^c \cap B.

  5. Solve x2−x−6≤0x^2 - x - 6 \le 0 and write the answer in set-builder and interval notation.

Common questions

What does the symbol ∈ mean in set notation?

The symbol ∈\in means 'is an element of'. Writing 5∈A5 \in A says that 5 is one of the members of set AA, and 5∉A5 \notin A says it is not.

How do you read {x | x > 3}?

Read it as 'the set of all xx such that xx is greater than 3'. The vertical bar means 'such that', and it is the same as a colon in {x:x>3}\{x : x > 3\}. In interval notation the same set is (3,∞)(3, \infty).

What is the difference between roster form and set-builder notation?

Roster form lists every element, as in {1,2,3}\{1, 2, 3\}. Set-builder notation states a rule that decides membership, as in {x∈N∣x≤3}\{x \in \mathbb{N} \mid x \le 3\}. Set-builder is the only practical choice for large or infinite sets.

Does the order of elements matter in a set?

No. {1,2,3}\{1, 2, 3\} and {3,2,1}\{3, 2, 1\} are the same set, and repeating an element changes nothing. Order does matter in ordered pairs and sequences, which use parentheses instead of braces.

What is the symbol for the empty set?

The empty set is written ∅\emptyset or { }\{\ \}. It has no elements and is a subset of every set. Do not confuse it with {∅}\{\emptyset\}, which has one element.

What is the difference between a subset and a proper subset?

A subset A⊆BA \subseteq B allows AA to equal BB. A proper subset A⊊BA \subsetneq B requires BB to contain at least one element that AA lacks. Some textbooks write ⊂\subset for either one, so check which meaning your course uses.

Up next