The Mathematics of Emergence