Formal agent-based models of social systems