A mathematical theory of social change