Source: https://www.cs.toronto.edu/kr/publications/agentprog.pdf