Computational reflection (sometimes just called reflection ) is a computer process involving self-awareness. Just as with humans, reflection depends on the capacity for independent reason, and particularly, reason about one's own processes. A reflective program has the ability to metaprogram : it can, itself, write programs. The capacity for reflection is one of the most important components of artificial intelligence ( AI ), and can be related to other aspects of AI such as fuzzy logic and neural networks .
When a reflective program operates, it does so in the same manner as a person. It takes variables, such as its own conditions, and contextual information into account. As an analogy, think of the operations involved in getting from your car to your house. If you see an obstacle in your path, you take in that information and adapt to it by either stepping around or over the object, or picking it up. When you get to your door, if you find it locked, usually you don't stop and stand there, continue to turn the knob, or turn around and walk away; usually you take out your key and unlock the door. In the same way, a reflective program has the ability to think about what is happening and to alter itself to address the circumstances.