5

Most computer programming languages have constructs for managing arrays of data, including multiple-dimensional arrays, which are clearly useful when storing, manipulating and modelling mathematical arrays/matrices.

Most of these languages also support empty arrays, i.e. ones with a length of zero in at least one dimension.

Are such arrays useful in mathematics, or are they simply a programming nicety?

And do they have real-world applications?

ClickRick
  • 224
  • 6
    The empty set?? – AnonSubmitter85 Jun 24 '14 at 20:19
  • 5
    Perhaps more to the point, the trivial vector space. – Harald Hanche-Olsen Jun 24 '14 at 20:21
  • I think it is a program issue. An emprty array would not consume memory - and at run time one can add elements to the array... – johannesvalks Jun 24 '14 at 20:26
  • @AnonSubmitter85 I had considered the empty set, but arrays have specific handling which sets do not, and didn't know whether there would be an equivalent "usefulness" in an empty array. – ClickRick Jun 24 '14 at 20:28
  • @HaraldHanche-Olsen You'll have to forgive me, my last formal maths education was 35 years ago. Vector spaces? – ClickRick Jun 24 '14 at 20:29
  • 1
    Classical vector spaces include the Euclidean spaces, set of matrices, or higher dimensional tensor spaces – involving multidimensional arrays, if you wish. But also subspaces of these, which are the solution sets of systems of linear (homogeneous) equations. Sorry, this space is too small for a whole introduction to vector spaces. Try wikipedia, perhaps? Anyhow, the trivial vector space has only one member: The zero vector. – Harald Hanche-Olsen Jun 24 '14 at 20:33
  • @HaraldHanche-Olsen I don't think a zero-length array quite corresponds to a trivial vector space. A zero length array has zero elements. The trivial vector space has 1 element. If instead you want to correspond arrays to zero vectors themselves, this still doesn't quite make sense. A zero vector still has "coordinates." (Forgive me, I don't recall the formal term.) An empty array would correspond more closely to some sort of zero-dimensional vector. Or have I missed something? – jpmc26 Jun 24 '14 at 22:06
  • 1
    @Harald: More to the point? – Eric Stucky Jun 25 '14 at 06:08
  • 1
    @jpmc26: It is usually convention that the empty sum is equal to zero. By coordinates I assume you meant something like: choose a basis, write it in that basis, pick off the coefficients. But for the trivial vector space, the basis is the empty set, and the sum for an arbitrary component is the empty sum, so there are no coefficients. In that sense I would say that a zero vector actually does not have coordinates. (Hm, I guess would rather say: the number of coordinates it has is zero, which I'm not sure I want to mean the same thing. But that should still be enough to make the analogy.) – Eric Stucky Jun 25 '14 at 06:11
  • @jpmc26 I think Eric explains it well. That is what I had in mind. To expand a bit on it, don't confuse the “elements” (we should say coordinates) of an array with the elements of a vector space. A one-dimensional array of length one has one element, but it corresponds to a vector in a vector space with infinitely many elements. – Harald Hanche-Olsen Jun 25 '14 at 06:44
  • @Eric: Your point being? (I think you were making a joke, but I am too dense to get it.) – Harald Hanche-Olsen Jun 25 '14 at 06:45
  • Haskell has tuples of any nonnegative arity (except 1, as a 1-tuple is just conflated with the corresponding member). In particular, there is a zero-tuple, denoted by (). It is of a type also denoted () – this type has only one member. Is it useful? I haven't learned enough Haskell yet to judge. – Harald Hanche-Olsen Jun 25 '14 at 06:49
  • @Harald It's pretty much indispensable there. For example, the main function in a Haskell program has to be of type IO () (the type of potentially world-modifying actions that don't yield any useful value besides their side effects), which is just a special case of IO a (the type of potentially world-modifying actions that yield a value of type a in addition to their side effects). Without (), you'd have to define it as a separate type. – askyle Jun 25 '14 at 07:48
  • 1
    @Harald () is basically a better void: it still has no meaningful value, but it technically has a value. Why is it important? template<T,U,V> apply_two(T f(U), U g(V), V x) { return f(g(x)); } — good luck making it work if any T, U, or V is void. And yes, such problems are rather common in C++ template metaprogramming. – Joker_vD Jun 25 '14 at 08:09
  • Are you looking only for their pure mathematics usage or their programming usage? – Richard Tingle Jun 25 '14 at 10:12
  • @RichardTingle Pure mathematics and real world. As a programmer of cough years, I'm all too familiar with the uses of them in programming. – ClickRick Jun 25 '14 at 10:24

6 Answers6

6

The empty string $\epsilon \in \Sigma^*$ (the set of all strings with finite length) in automata theory and formal languages (theoretical CS). It is the neutral element of string concatenation.

Also if $L$ is a formal language, $L^0 = \{ \epsilon \}$ arises.

Addendum:

I was maybe exposed too much to C-like programming languages that I immediately associate arrays with strings. :-)

The proper mathematical equivalent of an array is probably the sequence over some finite index set $I$ into some set $A$:

$$ (a_k)_{k \in I} \in A^I = \left\{ a \, \left| \, \right. a : I \to A \right\} $$

That definition should include the more general associative arrays, where $I$ is not some subset of $\mathbb{N}$.

If the index set is the empty set $I = \emptyset$, we got the empty array, like the map $b : \emptyset \to \mathbb{C}$. I see no exiting use for that one. We can define the concatenation of arrays, and have it be the neutral element. But we had this with strings already.

To represent a string, a list data structure $L = [a, b, c ]$ is sufficient, where direct access to all stored data is not necessary, just access at the head $L = [H|T]$ is enough and order is preserved (it is not just a set), the functional languages and PROLOG like this model. However there recursion is used regulary, and the empty list $[]$ occurs naturally, for example in a clause that does not spawn anymore recursive call, at the leaves of a recursive call tree for a function that works on lists.

mvw
  • 34,562
  • Looks like I've some light bed-time reading ahead of me! Can you recommend a good starting place, or is google's "I feel lucky" as good as anywhere? – ClickRick Jun 24 '14 at 20:33
  • 1
    The English language wikipedia article on concatenation is not that good (compare to this one: Konkatenation), but maybe this one might give a first start: Kleene Star or Formal Language. – mvw Jun 24 '14 at 20:38
  • 1
    My category theory is pretty sketchy, but I'm pretty sure that empty map is an initial (terminal?) object in some suitable category, and useful as such... – Steven Stadnicki Jun 25 '14 at 04:28
  • +1 for neutral element. It's generally a good idea to make your semigroups into monoids if you can get away with it :) – askyle Jun 25 '14 at 07:44
3

Mathematically, it is useful to have length be a nonnegative (not just positive) measurement. Then, we can do things like, given arrays $A,B$, define $C$ to be the largest array that agrees with both $A$ and $B$ for all its entries (agreement checked from the first entry onward). If $C$ cannot be empty, this definition can't be made.

vadim123
  • 82,796
1

If you're talking about applications in computer programming, suppose you initialize an array $A$ to the empty array, and then at some point in the program, which may be reached repeatedly, you do an operation that puts together the $n\times k$ array $A$ with the $n\times\ell$ array $B$, where the values of both of those change while the program is getting executed, to get the $n\times(k+\ell)$ array $[A, B]$.

I can imagine that being useful.

As for its utility in mathematics: I won't be surprised if in some situations it's useful, but I don't know what those are.

1

In programming it is useful for the Null Object Pattern. This simplifies the use of functions by mandating they always return a non-null value. Null values in programming an issue as they cannot be dereferenced without causing a runtime error as they point to literally nothing (apart from ruby)

e.g. With the function getValues() returning an empty array when there are no results

for (Integer value : getValues()) {
}

e.g. With the function getValues() returning NULL when there are no results forces us to make an extra check and complicates our code

Collection<Integer> values = getValues();
if (values != null) {
  for (Integer value : values) {
  }
}
Adam
  • 111
  • 2
0

In the category of Set, the empty set is the only initial object. I found that example, along with the fact that all one element sets are the terminal objects of Set, useful in understanding initial and terminal objects in general.

Also, it is possible to construct useful objects using nothing but the empty set and the basic operations of set theory: Set-theoretic definition of natural numbers

There are important differences between the concepts of arrays and of sets (sets have no order and contain no duplicates), but an empty set could still be thought of as analogous in some way to an empty array since they are both collections that contain no elements.

David
  • 297
  • 1
  • 6
  • Real world applications and talking about the category of Sets is quite an oxymoron. Not to mention that the OP pointed out that they have considered the empty set already. – Asaf Karagila Jun 25 '14 at 04:22
  • @AsafKaragila Oh I missed that part. He asked for applications in math too, which is why I mentioned category theory. Also, wouldn't an indexed family N -> X (for some X) be more or less equivalent to an array? And couldn't you consider an indexed family to be defined in terms of the set of its input/output pairs? In that case, it seems like an empty array would pretty much be an empty set, but maybe I'm stretching a little too far. – David Jun 25 '14 at 04:55
  • I meant to say "[...]an indexed family J -> X for some X and J being a subset of N (in this case, the empty set)[...]" – David Jun 25 '14 at 05:04
0

Imagine you have a function (either in programming or in mathematics) whose output is an array. It's easy to imagine that some inputs will naturally yield the empty array as an output -- but you may not know, at least at first, which inputs have this property.

It's very convenient not to have to keep checking whether or not you're removing the last element from an array.

swensonj
  • 458