Hartmann is a psychiatrist and the director of the Sleep Disorders Center at Newton Wellesley Hospital in Boston, but notes that the exact function of dreaming is still largely a mystery, but summarises his recent popular scientific theory of its purpose.
Therefore I will try to explain a current view of dreaming and its possible functions, developed by myself and many collaborators, which we call the Contemporary Theory of Dreaming. The basic idea is as follows: activation patterns are shifting and connections are being made and unmade constantly in our brains, forming the physical basis for our minds. There is a whole continuum in the making of connections that we subsequently experience as mental functioning. At one end of the continuum is focused waking activity, such as when we are doing an arithmetic problem or chasing down a fly ball in the outfield. Here our mental functioning is focused, linear and well-bounded. When we move from focused waking to looser waking thought–reverie, daydreaming and finally dreaming–mental activity becomes less focused, looser, more global and more imagistic. Dreaming is the far end of this continuum: the state in which we make connections most loosely.
Link to Scientific American article ‘Why do we dream?’.