Observers constantly build and update internal models of their environment, which are used to guide action. One challenge faced by these observers is to balance the need to construct stable models, based on a long history with data, against the need to be adaptable to possible changes in the environment. In this talk I will discuss situations in which there is a need to maintain flexibility in internal models (Computational Theory), how this flexibility can be expressed mathematically (algorithm) and possible neural mechanisms (implementation) using data from human neuroimaging and behaviour in learning tasks.