Theory of Mind
The Theory of Mind (ToM) is a branch in cognitive science that looks to define a framework that describes the underlying process and mechanism to how we ascribe mental states to other persons and how we use such states to explain and predict the actions of those other persons. It investigates our ability to mindread and/or mentalize. There are two established contrasting theories within this branch, which actually takes its name from the earliest established theory  - theory of mind (theory-theory). From the theory-theory perspective our ability to read minds is based on somewhat detached theoretical process that is innate. This ability rests upon knowledge of a theory, although we’re not actually aware of the laws which comprise the theory. The knowledge that this theory represents holds much the same structure as a scientific theory in its acquisition and storage, and is used in much the same manner in a formulation of a question, hypothesis and prediction, and then its revision in light of new evidence.

“Mind reading is the ability to attribute goals and motivations to others based on the observation of their behavior.”

Simulation Theory
The second theory and the focus of this article is the simulation theory. This theory suggests that we understand others through our own mental apparatus. We form predictions and explanations of someone by putting ourselves in the shoes of another person and simulating them. The simulation generates pretend mental states, which are expected to correspond to those of the target. The simulation then feeds the pretend states into a suitable cognitive mechanism that is taken “offline” in that the motor control system (actions) is disengaged. Finally the simulation projects states onto the target.

“The simulation theory holds that humans anticipate and make sense of the behavior of others by activating mental processes that, if carried into action, would produce similar behavior. This includes intentional behavior as well as the expression of emotions.”

http://www.jinspired.com/site/mirroring-mindreading-and-simulation-of-the-java-virtual-machine