# Set builder notation: Colon or Vertical Line

I remember once hearing offhandedly that in set builder notation, there was a difference between using a colon versus a vertical line, e.g. $\{x: x \in A\}$ as opposed to $\{x\mid x \in A\}$. I've tried searching for the distinction, but have come up empty-handed.

• It seems that some people use semicolon. Oct 28, 2015 at 15:00
• @MartinSleziak Yes; in a paper I was the copy editor of, all three notations were used. The paper had three authors. ;-) Oct 28, 2015 at 22:11
• No difference, as others have stated. Just be consistent: in a paper or book always use the same. Oct 28, 2015 at 22:12

There is no difference that I've ever heard of. I do strongly prefer "$\vert$" to "$\colon$", though, because I'm often interested in sets of maps, and e.g. $$\{f \mid f\colon \mathbb{R}\rightarrow\mathbb{C}\text{ with f(6)=24}\}$$ is easier to read than $$\{f: f\colon \mathbb{R}\rightarrow\mathbb{C}\text{ with f(6)=24}\}$$.

EDIT: Note that as Mike Pierce's answer shows, sometimes "$:$" is clearer. At the end of the day, use whichever notation is most clear for your context.

• Except perhaps if the conditions require absolute values… Oct 28, 2015 at 2:05
• @Bernard Certainly neither is perfect. (I rarely deal with absolute values, though.) I've seen a period, ".", used, and I like it - but I've never seen that used in a publication, so I wouldn't use it. Oct 28, 2015 at 2:09
• As an example where the colon might be preferable, take a set where membership is defined by divisibility conditions: $\{ d \in \mathbb{Z}^+: d|m \; \land \; d|n\}$. Oct 28, 2015 at 12:25
• $\{f \colon \mathbb{R} \to \mathbb{C} : f(6) =24 \}$ is also readable - double colon, but no double "f" Oct 28, 2015 at 16:25
• Oh, boy -- finally a legitimate excuse for me to drag out those $f \in \{ \mathbb{R} \to \mathbb{C} \}$ or $f \in \mathbb{C}^\mathbb{R}$ notations! (Admittedly the former involves adding more brackets, but for some reason it doesn't bother me in the least, I guess because the nesting is so shallow (edit: and because the enclosed expression is tiny).) Oct 28, 2015 at 19:15

There is no difference. The bar is just often easier to read than the colon (like in the example in Noah Schweber's answer). However in analysis and probability, the bar is used in other notation. In analysis it is used for absolute value (or distance or norms) and in probability it is used in conditional statements (the probability of $A$ given $B$ is $\operatorname{P}(A \mid B)$). So looking at bar versus colon in sets with these notations $$\{x \in X \mid ||x|-|y_0||<\varepsilon\} \quad\text{vs}\quad \{x \in X : ||x|-|y_0||<\varepsilon\}$$ $$\{A \subset X \mid \operatorname{P}(B \mid A) > 0.42\} \quad\text{vs}\quad \{A \subset X : \operatorname{P}(B \mid A) > 0.42\}$$ it can be better to use the colon just to avoid overloading the bar.

• In such cases I use different sizes of the vertical bar, e.g. $$\Big\{x\in X \ \Big|\ \big||x|-|y_0|\big| < \varepsilon \Big\}.$$ Oct 29, 2015 at 14:29
• @dtldarek, yeah, yours is clear to read (and I think looks better than with a colon). My only problem is that by making the bar taller, you can't really have this typed in-line or else the line-spread will start to look weird (like what happens when you see sums or products with $\sum$ or $\prod$ typed in-line). Oct 29, 2015 at 14:59

It seems many good answers and examples have been provided, but I didn't see it mentioned above that regardless of which symbol you choose to use, in the set builder context both would be read aloud as "such that".

As for my example of preference, I am often working in number theory so I use the colon, ":", to avoid the bar being misinterpreted as "divides", or aesthetic reasons if I am also going to use the bar to mean divides in the specification of the set.

Both are acceptable means and practices within the community. Most people I know prefer the line method because it provides a clear separation and can be used if you are defining your set on multiple lines of scratch work.

• There is also the semi-colon. Oct 28, 2015 at 2:06
• And there's the old Principia notation $\hat{x}(\phi)$ which doesn't allow decorating the $x$, but otherwise is as clear as the notation in $\phi$. Or would be if anyone still recognized it. Oct 28, 2015 at 9:34
• If anyone still recognized it, indeed Oct 28, 2015 at 16:26
• My multi-variable calculus professor used that notation last year. Haven't seen it pretty much anywhere else though :( Oct 29, 2015 at 1:49

I recently realized I read them differently. To me | acts more like a "filter" over a larger set, whereas : acts more like a "generator" from a smaller expression.
This isn't 100% accurate though. I'm usually fine with : acting like a filter as well... but less so with | acting like a generator.

For example, this looks jarring to me:

\begin{align} t^* = \max \left\{ t_i\ \middle|\ \frac{\partial f_i}{\partial x_i} = 0 \right\} \end{align}

whereas this looks fine to me:

\begin{align} t^* = \max \left\{ t_i : \frac{\partial f_i}{\partial x_i} = 0 \right\} \end{align}

This is because when I read $t_i\ |\ \ldots$ I expect the right-hand side to contain some constraints on the possible values of $t_i$, which I otherwise assume to be all reasonable values (e.g. all real numbers).
But when I read $t_i : \ldots$ I expect to see an expression that tells me how to generate the set of $t_i$, and that need not involve $t_i$ itself at all.

I don't know if everyone reads them like this, but for me they are not quite always interchangeable, even though they frequently are.

• Both look jarring, since $t_i$ is not even a variable in the RHS statement. Mar 3, 2017 at 6:59
• @AsafKaragila: Aw really? How would you have written it...? Mar 3, 2017 at 7:09
• I don't know what you're trying to write, so I can't quite tell you. Mar 3, 2017 at 9:18
• @AsafKaragila: I already have $t_1, \ldots, t_n$ and I have $f_i, \ldots, f_n$ and I have $x_1, \ldots, x_n$ (with the obvious correspondence across the sequences based on the indices). I'm trying to say "the $\max$ of all $t$'s corresponding to the $f$'s whose partial derivatives with respect to the corresponding $x$'s are zero". How would you say that? Mar 3, 2017 at 10:14
• Perhaps you could split it up: $\quad S = \{i \in 1..n : \frac{\partial f_i}{\partial x_i} = 0\}, \quad t^* = \underset{i \in S}{\max} \ t_i. \quad$ It makes sure $\max$ is used in the traditional way. But looking here, it looks like there's a few different notations you could use depending on the domain... Oct 18, 2020 at 8:23