Analytical theory of democracy : History, mathematics and applications.