The Evolution of Complexity in Human Societies and Its Mathematical Expression