2
$\begingroup$

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.

  • 5
    Define *access*.2017-01-16
  • 0
    @DanRust by acces I mean index the elements.2017-01-16
  • 0
    Why do you need to index them? If you want to take a specific element, you just take that element ("we have $3 \in A$"). If you want to take an arbitrary element, you just give it a name ("we have some $\alpha \in A$").2017-01-17
  • 0
    @MorganRodgers How do you write this algorithm? 1. Let $A$ be the set of admissible clients. 2. $S\gets\emptyset$. 3. for $i = 1$ to $|A|$ do $S\gets A(i)$ and calculate $f(S)$. 4. If $f(S)=0$, remove $A(i)$ from $A$. I can write it in English language but not in mathematical language because there no $A(i)$ in a set and there is no remove in a set.2017-01-17
  • 0
    1. Define $A$. 2. $S = \emptyset$. 3./4. (done as a single loop over the elements of $A$) for $\alpha \in A$: $S = S \cup \{\alpha\}$, if $f(S) = 0$ then $A = A \setminus \{\alpha\}$.2017-01-17
  • 0
    But really your algorithm is not well-defined, because it depends on the order that you use to loop through elements of $A$. Sets are by their nature unordered, so if you want to make sure you loop through your elements in a *specific* order, you should use a sequence.2017-01-17
  • 0
    Thank you. I just write an example of an algorithm (so probably not well defined) but I will look for the suggestion _sequence_.2017-01-17

3 Answers 3

7

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
    Thank you. If I let $A=(1,2,3)$ then how to tell, in notation, the cardinality of $A$? I mean, what I have is this: Let $A$ be a list of elements (to index them I choose as you suggested a _tuple_). Now I need to define the cardinality of $A$, is it $|A|$?2017-01-16
  • 0
    @Zir I think if you said "$|A|$ is the length of the list", that would be understood perfectly well and considered a natural notation. I hardly ever see it though - it's pretty common, however, to say, "Let $x=(x_1,\ldots,x_n)$ be a tuple" or something like that, where $n$ is just implicitly defined as the length. Or "If $A$ is an $n$-tuple..." has a similar effect. However, if you have lots of lists to work with, these aren't really good options and just defining $|A|$ as you have would be better.2017-01-16
4

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.

3

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.