How to use set-builder notation for creating lists

elementary-set-theorynotation

I am trying to formalize an algorithm using the set-builder notation.
Having an array B of values $d$:
$$
B = [d_1,d_2, \ldots,d_n]
$$

For instance, I want to define a new list $A$ containing the values $d$ that are greater than a value $h$. The order is important and there could be also values with the same distances. So the following expression using the set-builder notation is wrong:
$$
A = \{\ d_i \ |\ d_i \in\ B , \ d_i >h \}
$$

Can I use the set-builder notation for creating list of values? So far I though this could be a solution, but I don't know if it is acepted:
$$
A = (\ d_i \ |\ d_i \in\ B , \ d_i >h )
$$

Best Answer

Ultimately notation is not so much about being technically correct, it is about being understood. Set builder notation is so standard, that any mathematically educated person reading it will understand what it means, which makes it a good notation (this is also what makes it meaningful to speak of "correct" and "incorrect" set builder notation).

Since you are not looking to define a set, set builder notation is not really what you are looking for. The question is: how can you succinctly express what you are going for without being confusing?

Your original notation $$ A = (d_i \mid d_i \in B, d_i > h) $$ is not standard. However, I would likely understand it if it was clear from context that $A$ should be an array (or sequence) and that the ordering of $A$ matters. Personally I think this notation could be improved by replacing $d_i \in B$ with $1 \leq i \leq n$; because $B = [d_1\ \ldots d_n]$, the fact that $d_i \in B$ is essentially redundant, and anyway $d_i \in B$ is not really standard notation when $B$ is not a set.

An equally formal definition of $A$ would be: "$A$ is the subsequence of $B$ consisting of all entries in $B$ which are larger than $h$". Since there is less possibility of misunderstanding in this English sentence than in the mathematical expression, this is arguably more formal, not less, even though it is written in natural language rather than in mathematical symbols.

Related Question