How to access an element of a set?

3.1k Views Asked by At

Let us say that I have a set $A=\{1,2, 3\}$. Now I need to access, say, the element $3$ of $A$. How do I achieve this?

I know that sets are unordered list of elements but I need to access the elements of a set. Can I achieve this with a tuple? Like $A=(1, 2, 3)$, should I write $A(i)$ to access the i-th element of $A$? Or is there any other notation?

If I have a list of elements, what is the best mathematical object to represent it so that I can freely access its elements and how? In programming, I would use arrays.

3

There are 3 best solutions below

2
On BEST ANSWER

You are speaking of the index operator one often finds in programming when using arrays. Given that sets are unordered, it does not make sense to do this with sets, as $\{1,2\}=\{2,1\}$.

You probably want to use a tuple, which is just a (finite) sequence of elements, and is denoted as you wrote $A$. If $A=(1,2,3)$ is a tuple, then I think the most common way to index it is to use subscripts - so $A_1=1$ and $A_2=2$ and so on, though one sometimes sees $A(1)$ and $A(2)$ as well, since one can think of $A$ as a function from the set $\{1,2,3\}$ to $\mathbb R$. Occasionally, one even sees $A^1$ and $A^2$. Really, what matters is that you are consistent and clear in how you write indexing.

0
On

In a general set, there is no indexing, except the trivial one: a set $A$ is indexed by itself, that is, $A=\{x_a: a\in A\}$ where $x_a=a$.

Indeed, in set theory without the axiom of choice, there can be sets which are impossible to "index nicely," although of course this takes work to be made precise.

So the general task you describe is either trivial (if you allow a set to index itself) or impossible.

That said, in restricted contexts we can do better. For instance, suppose we're looking exclusively at finite sets of real numbers. Then any such set is naturally ordered by cardinality, that is, we may speak of the $k$th smallest element of a set.

0
On

The fact that a set is "unordered" by definition doesn't prevent you from defining an ordering on it. Indeed, by the Axiom of Choice, any set can be indexed by an ordinal number.