On the mathematics of biodiversity