The activation synthesis theory of dreaming was first suggested by J. Allan Hobson and Robert McCarley in 1977, and has since been elaborated on due to newer research and more advanced brain imaging techniques. The theory proposes that the content of dreams is synthesized in cortical areas, by fitting experiental data to spontaneous activity taking place in deeper areas of the brain during sleep.
Hobson J. A., McCarley R.W. (1977) “The brain as a dream state generator: an activation-synthesis hypothesis of the dream process” (pdf). Am J Psychiatry. Dec;134(12):1335-48
See lectures related to dreaming: