Photo: K.Arran /Getty Images

The earliest recorded dream is from the Sumerian king Dumuzi of Uruk, who ruled just before Gilgamesh, sometime around 2500 BC. “An eagle seizes a lamb from the sheepfold,” a translation reads. “A falcon catches a sparrow on the reed fence … The cup lies on its side; Dumuzi lives no more. The sheepfold is given to the winds.” The king was freaked out about his dream, and occasioned the first recorded dream interpretation, care of his sister, who was evidently a professional at these things. Sister’s advice: Some bad shit is about to go down, so you’d do well to hide.

If you’ve ever been befuddled by a dream, take heart: You’re following a 4,000-year tradition of confusion. Over that time, humanity — in the form of religion, philosophy, psychology, neuroscience — has actually come to somewhat understand what exactly the mind is doing in its slumbering states.

To that end, here are five of the leading theories for what dreams are and what they do to us:

Dreams are pragmatic prophecies.

Queen Maya, the mother of Siddhartha Gautama, dreamt of a white elephant entering her side, foretelling of her son becoming the Buddha, around 500 BC. In Genesis, Pharaoh dreams of seven sickly cows devouring seven handsome ones and seven sickly ears of grain devouring seven handsome ones; he calls in Joseph, who brushes aside the sycophantic necromancers and lets the Pharaoh know that Egypt’s in for seven years of plenty and seven years of famine. To Kelly Bulkeley, author of Big Dreams: The Science of Dreaming and the Origins of Religion, such divination is a metaphysical framing of what he takes to be one of dreaming’s most adaptive traits: helping people to prepare. “We’re doing that when we’re awake all the time,” he says. “We have a capacity for forethought — it’s going to get cold in the winter, so we better store up food. All sorts of things we do depend on the capacity to predict the future. I see the mind and the brain as a 24-hour system and that same kind of [preparatory] thinking is happening in sleep as well.”

To Bulkeley, the shortest definition of dreaming is that it’s “imaginative play,” and often one that’s future-oriented. No mysticism required. “Aristotle made the argument that during sleep, when we’re detached from the hurly-burlies of the waking world, the subtle impressions are able to give us a better sense of the future,” he says. Interestingly enough, that matches up pretty well with a field that sprang up 2,000 years later: evolutionary psychology, which reasons that since the world is full of potential threats, your mind visualizes them during sleep so that you’re alert to them in waking life — whether you recall the dream itself or not.

Dreams tell you what to do.

In the 17th century, René Descartes, the great doubter, had his life course shifted by a series of dreams he had one November evening. In Soul Machine: The Invention of the Modern Mind, historian-psychiatrist George Makari reports that Descartes had a series of sleeping visions that prompted him to realize that “spatial problems could become algebraic, which crystallized a vision of a natural world underwritten by mathematical laws,” thereby changing his life and eventually the popular, scientific conception of reality. Freud himself was driven to write The Interpretation of Dreams after he had a powerful dream the night before his father’s funeral, in October 1896, wherein he saw a printed notice with the forbidding message “You are requested to close the eye(s).” Abraham Lincoln was an active dreamer: He reported having vivid dreams the night before any “great and important event of the war,” as a colleague of Lincoln’s noted in his diary; he telegraphed his wife to put their sons’ pistols away after an “ugly” dream; and he reportedly dreamt of a White House funeral just a few days before his assassination.

Dreams are communications from the unconscious mind.

Around the turn of the 20th century, Sigmund Freud, the father of psychoanalysis, who happened to also have a fetish for mommy-daddy issues, thought that dreams were messages from the unconscious, which he fancied himself the discoverer of. “The interpretation of dreams is the royal road to a knowledge of the unconscious activities of the mind,” he wrote. The purpose of dreams, he maintained, was to fulfill repressed wishes, and you could tease apart their individual meaning through associations. His mentee and later rival Carl Jung took a more future-oriented perspective: Dreams, he said, are a way for the parts of you beyond your conscious awareness to get you to notice things, delivered to you through universal, yet personal, symbols. So a dream of the girl or guy that got away could be read as a sign that you’re letting an opportunity slip away. Jungian analyst Maxson McDowell, who uses dream interpretation in his therapy practice of 29 years, told me that a dream is “a communication to consciousness of some insights that the wider personality feels is important and necessary,” a bid from “the wider personality to get consciousness to expand a little bit, understanding something more about itself.”

Dreams are data.

Dreaming started to really fall under empirical scrutiny in the 1950s, with the discovery of what would become known as the rapid-eye-movement (REM) phase of sleep by University of Chicago researchers Eugene Aserinsky and Nathaniel Kleitman. Today, brain scans are beginning to detect the subject matter of dreams by training algorithms to recognize what people’s brain activity looks like while awake. Meanwhile, dream recorders are coming down the line. Bulkeley, the dream researcher, has launched the Sleep and Dream Database, which has crowdsourced some 20,000 dreams from volunteers around the world. Already, he says, psychological themes are emerging, such as that people are rarely alone in dreams, and that they tend to dream of people they’re emotionally close to. “Dreams reflect the emotional concerns we have in our relationships,” he says.”Dreaming is really a resource for exploring the qualities of our relationships, who we care about, where we struggle.” It’s kind of like the function of anxiety — a way of assessing (possibly healthy, intimacy-promoting) vulnerability, and prompting action.

Dreams are your memories in action.

For over a century, researchers have been uncovering how sleep promotes memory, specifically the formation of long-term memories, and now neuroscientists are increasingly finding that the kaleidoscopic imagery in dreams is a by-product of the memory-making process. When your different threads of experience are bound together, the result is as familiar as it is alien. “This often bizarre, composite image has not been present to the senses,” argues University of Manchester researcher Sue Llewellyn in a 2013 paper. “It is not ‘real’ because it hyper-associates several memories. During REM sleep, on the phenomenological level, this composite image is experienced as a dream scene.” Memories are bound with memories, and zany imagery ensues.

So does learning. When study participants were asked to navigate a virtual maze, and then take a nap, the people who dreamt of what they learned the first time around did better in the retest. Similarly, birds aren’t born knowing how to sing; they have to learn how. Biologist Daniel Margoliash and his lab at the University of Chicago have peered into the brains of sleeping male zebra finches, and they’ve found that the same patterns of neurons fire while they’re asleep as when they’re singing, trying to attract a mate. While you can’t exactly ask a finch what it experienced the night before, it looks like the birds practice their songs.