# Simple set-builder notation for counting pairs

Today I was curious about writing a simple expression using set-builder notation. The expression is the number of integer pairs $(a, b)$ such that $a \mid n$, $b \mid n$, and $a \mid b$. My attempt is $$|\{(a,b)\mid \exists a,b:(a,b \mid n \ \land a \mid b)\}|$$

I would like to know if this is correct and if there any alternate representations.

• Are you using $|$ to mean "such that" as well as to mean "divides", then as well as $:$ to mean "such that"? – marshal craft Jul 20 '16 at 6:22
• @marshalcraft yes. The outermost set of bars is for cardinality. – qwr Jul 20 '16 at 6:28

This is not correct: you should not have the $\exists a,b$. Indeed, reading your set $$\{(a,b)\mid \exists a,b:(a,b \mid n \ \land a \mid b)\}$$ aloud, it is $$\text{the set of (a,b) such that there exist a and b such that a and b divide n and a divides b.}$$ This doesn't make sense! You can't say "there exist $a$ and $b$" because you already have some specific $a$ and $b$ in mind, namely the $(a,b)$ which you are testing for membership in the set.

With the existential quantifier dropped, your notation is correct: $$|\{(a,b)\mid a,b \mid n \ \land a \mid b\}|.$$ However, this is rather confusing because $\mid$ is being used both as "such that" in the set-builder notation and to mean "divides". So it would be clearer to write one of these usages differently. You could write $$|\{(a,b): a,b \mid n \ \land a \mid b\}|$$ or $$|\{(a,b)\mid \text{a and b divide n and a divides b}\}|,$$ for instance.