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.

$\endgroup$
  • 6
    $\begingroup$ Define access. $\endgroup$ – Dan Rust Jan 16 '17 at 21:50
  • $\begingroup$ @DanRust by acces I mean index the elements. $\endgroup$ – Zir Jan 16 '17 at 21:53
  • $\begingroup$ 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$"). $\endgroup$ – Morgan Rodgers Jan 17 '17 at 3:07
  • $\begingroup$ @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. $\endgroup$ – Zir Jan 17 '17 at 16:18
  • $\begingroup$ 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\}$. $\endgroup$ – Morgan Rodgers Jan 17 '17 at 20:09
7
$\begingroup$

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.

| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ 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|$? $\endgroup$ – Zir Jan 16 '17 at 22:29
  • $\begingroup$ @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. $\endgroup$ – Milo Brandt Jan 16 '17 at 22:32
4
$\begingroup$

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.

| cite | improve this answer | |
$\endgroup$
3
$\begingroup$

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.

| cite | improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.