Hacker News new | past | comments | ask | show | jobs | submit login

Yes, those two facts about zero/empty cases (and so many more) are definitely related, and this class of facts is one of my favourites! Usually, if you're dealing with something algebraic in flavour (which is a very vague concept, sorry), there will be a sensible way to define the zero/empty case. This is often a good test of whether you have a uniform concept that works for all n without corner cases.

It almost irritates me when I read a book or a paper and they say that the zero/empty case is "by convention". I almost want to yell, "no! it's because that's how you make the definition uniform!"

Addition is usually defined as a binary operation, a+b, but really it should be defined as an n-ary operation; associativity tells us that doing "two layers" of addition should boil down to doing a single layer of addition on the concatenated list of operands. That forces 0-ary addition to be zero, which can always be added to the list of operands without affecting the result.

Something similar happens with empty products (which explains the factorial), empty spans, etc. In all cases, the trick is to figure out, what is the equivalent of associativity? What "syntactic" operations on the inputs (for example, concatenating a list of lists of operands) correspond to operations on the outputs (you can get the total sum by first computing partial sums)?

A fun puzzle, if you enjoy this kind of thing: what's the determinant of the 0x0 matrix (over your favourite field or ring)? For all (square) sizes, the determinant of the zero matrix is zero, but the determinant of the identity matrix is one, and the 0x0 matrix is kind of both. So which pattern should win? Which one is stronger? I know my own answer ;)




I was also puzzled by det(0x0) being 1, because I had built an intuition that determinant of a matrix was the volume of the parallelepiped represented by the matrix. I made my peace by accepting that my intuition on volume implies that volume is defined in a space that has positive dimensions, and by treating zero space as an algebraic construct.


Now you're reminding me of a wacky math conversation I had at Mathcamp [1] with a much smarter guy, who was talking about more esoteric definitions of volume in euclidean space. Something like:

- n-dimensional volume is a function from (some) subsets of space to real numbers

- it should be additive under union

- it should scale by t^n when you scale the space by a factor of t

I think the upshot of the conversation was that 0-dimensional volume of a shape should be its Euler characteristic. In the simple case of a finite set of points, the "volume" would be the number of points.

And by your earlier comment, span({}) consists of a single point, so its volume should be 1. It all works!

[1] https://www.mathcamp.org/


> what's the determinant of the 0x0 matrix (over your favourite field or ring)?

1, because 0x0 seems like a more elegant base case for the recursive det formula than 1x1.


Yeah, it took a while to sink into my head that many of these "wait, why is span({}) = {0}?" kinds of cases have answers that sum up as "because anything else means other rules are inconsistent, and the whole thing is either less useful or useless". It's "arbitrary", but it's either the only useful option, or sometimes a simple(st) one of many.

Even just one number theory course helped a lot, since it brought that kind of consistency into its own concept, where [this set of rules] forms a ring, and [this set] forms a field, etc.


To be fair, in this case the rule is not quite arbitrary, because it, in fact, follows from the definition of span (as a subspace).


Define the determinant to live in the ring quotiented by the annihilator of the module. Then the determinant of the 0 by 0 matrix is both 0 and 1.


Couple more fun examples:

all([]) == True

any([]) == False


This is a bit intuitive:

all: no false elements any: not all false elements


Plenty of things are intuitive if you have the right mental model backing it. I'd wager some folks thing of all/any as "at least one True"/"Everything is true", which makes it a trickier think.

Mental models often get spicy with empty/"corner" cases. This isn't quite the same, but a lot of kids struggle with division as sharing rather than division as measuring, which makes division by a number less than 1 conceptually difficult. http://langfordmath.com/ECEMath/Multiplication/DivModels.htm...


> there will be a sensible way to define the zero/empty case. This is often a good test of whether you have a uniform concept that works for all n without corner cases.

And so, begun the array indexing war has.


A polynomial always includes a member (monomial) with the power zero. It seems natural, therefore, to index the coefficients correspondingly. In other situations, 1 may be the more natural starting index.


The useful corner case/"neutral element" for array indexing is the zero-width interval in an arbitrary position.


Fourier coefficients need a zeroth element too.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: