My friend Bertrand can easily imagine never meeting his wife, Laura. The circumstances were peculiar. He was visiting an unfamiliar town for work, not too far from his home. An acquaintance who happened to be there at the same time invited him out to a dance club in yet another neighborhood he otherwise wouldn't have visited. At the last minute he decided to go.

He arrived late, so he had to wait in line in the wintry cold. Next to him stood a group of people waiting for a cab, including Laura. He and Laura both cupped their hands and blew warm air into them at the same time. “It is cold,” they said in unison, then laughed. They chitchatted briefly. A cab soon arrived, and Laura left. Bertrand couldn't get her off his mind.

Early the next morning Bertrand was sitting on a bench, waiting for a bus that would take him home. It was running late. In front of him a bike stopped sharply at a red light—it was Laura. He ran up to her, and she recognized him immediately. Bertrand convinced her to exchange phone numbers with him. They married two years later and have been together for nine years. They recently welcomed their first child.

When Bertrand tells this story, it is impossible not to wonder what would have happened if his friend had not been in town that day, or if Bertrand had decided to go to the club earlier, or if the bus had been on time, or if the light hadn't turned red so Laura would have just zoomed by, unnoticed. Would they still have met? Would they be married today? The human tendency to mentally replay past events while varying one or two critical details, letting the scenario unfold for a few seconds into the mysterious realm of the what-if, is known as counterfactual thinking because it involves mulling over something that is not true or is “contrary to fact.”

We use our imagination in many ways. Novelists rely on it to dream up plots, characters and scenes. Artists use it to conjure new works. Children entertain themselves by weaving fantastical worlds in their minds. For adults, however, one of the most common—and underappreciated—uses of imagination is counterfactual thinking. We dip into alternative realities with a frequency and ease that suggest this habit is core to the human experience. Yet imagination has long been seen as random, obeying no principles and resting outside the scope of science. That view began to change in the early 1980s, after cognitive scientist Douglas R. Hofstadter offered a tantalizing insight. Hofstadter suggested that the mind has a series of what, in a 1982 Scientific American column, he called “fault lines” where things can shift. When we muse about the different ways an event might have unfolded, we tend to be predictable: we alter certain parameters but not others. Ever since Hofstadter's insight, cognitive scientists have been mapping these fault lines and discerning their purpose. Imagination, it seems, helps us transcend the reality of the immediate present to come to grips with our past and prepare for the future. Exploring the unreal may be an important step in finding meaning in, and shaping the narrative of, our everyday lives.

Playing with reality

In the spirit of Hofstadter's conjecture, Nobel Prize–winning psychologist Daniel Kahneman, now at Princeton University, along with Amos Tversky of Stanford University and Dale Miller, now at Stanford, conducted pioneering studies in the 1980s to investigate whether people behaved predictably when imagining variants of common events. In one of these studies, by Kahneman and Tversky, participants read a vignette depicting the tragic story of a teenager who, while driving under the influence of drugs, crashed into a man's car, killing him instantly. The story is full of “junctures”: causally relevant events that, had they been different, would have prevented the accident from occurring. When Kahneman and Tversky asked their subjects to revise the story so as to avoid the accident, they found that participants were overwhelmingly more likely to imagine undoing rare or abnormal events (such as deciding to take an unusual route) rather than ordinary, frequent events (such as leaving the office at a regular hour).

Ever since, some psychologists have engaged in a kind of cognitive geology (call it psysmology?) to map the fault lines of our imagination. We have learned, for example, that when people imagine alternatives to a given event, they are more likely to mutate actions rather than inactions, causes rather than background conditions and controllable events over uncontrollable ones. Our wishful thinking also tends to focus on altering recent events over bygone ones and morally or socially unacceptable occurrences over less offensive ones. Taken together, these findings supported an explanation proposed by Kahneman and Miller in 1986, called norm theory. The idea was that we derive from our experiences a series of templates, or “norms,” against which we compare imagined alternative realities. Because in day-to-day life we are more likely to arrive at a destination early or late than we are to show up and find it closed, we are more inclined to imagine Bertrand never meeting Laura because he waltzed into the venue without waiting in line rather than because he found the club shut down.

Not every facet of norm theory has stood the test of time, but the gist of it—that there is some order to the way people imagine scenarios—has remained. In fact, as psychologist Ruth M. J. Byrne of Trinity College Dublin has suggested, our imagination may closely resemble rational thinking, which is highly predictable and subject to relatively strict rules. Just as there is a logic to how we reason, there is a logic to what we imagine.

Preparing for the future

Psychologists figured out fairly early on that counterfactual thinking serves a purpose—it girds us for the future. Most of our counterfactual thoughts occur when we fail to obtain a desired goal: passing an exam, scoring a goal, finishing a task on time. And usually when we fail, we imagine undoing a certain action and achieving the desired effect: “Had I gone to bed earlier last night, I wouldn't have slept through the exam this morning.” These kinds of counterfactuals, in which we imagine a better alternative to a bad event, are called upward counterfactuals (the dreamed-up scenario is better than reality), and they tend to elicit negative feelings, predominantly regret. When we contemplate worse versions of good outcomes (“Had I missed that shot we would have lost the game”), we are entertaining downward counterfactuals, which tend to be associated with positive feelings, such as relief. Considering other ways things could have gone might give us a leg up the next time we face a similar task.

For example, in one 1994 study by psychologists Neal J. Roese of Northwestern University and James M. Olson of the University of Western Ontario, participants tackled several anagrams, mostly unsuccessfully. Half of them were asked to imagine what they might have done differently. When the participants again saw a similar set of puzzles, only the individuals who had reflected on other approaches performed better on the new anagrams.

Yet letting your imagination run wild isn't always productive. In 2003 psychologists Keith Markman of Ohio University and Matthew N. McMullen of Montana State University Billings revealed that upward counterfactuals can also elicit positive feelings. For example, a person who considers what it might have taken to avoid bombing a test might decide that failure was acceptable, rather than feeling regret and a desire to try harder next time. Likewise, downward counterfactuals can produce negative feelings, too. Consider the case of Kim Stroka, then a flight attendant for United Airlines who was scheduled to work on the ill-fated Flight 93 on September 11, 2001. The day before, she switched shifts—a move that saved her from perishing when the plane crashed in a field in Pennsylvania. Yet Stroka became haunted by downward counterfactual thoughts, which led her to seek treatment for post-traumatic stress disorder. She sought workers' compensation for her stress, but United fought back. An appellate court eventually ruled that although the plane crash may well have been the cause of her PTSD, her condition was not the result of an accident that occurred in the course of her workday. Even so, her downward counterfactual rumination was severely debilitating.

We also generate counterfactual thoughts about events that we know are never going to happen again—another strike against the idea that this form of thinking always prepares us for the future. I have a friend, Peter, who one day had a spirited argument with his father. His dad stormed out of the door, hopped in his car and drove up the road, only to fatally crash into a truck after failing to notice a red light at a busy intersection. Peter cannot help but imagine how things would have turned out if only he hadn't upset his dad or if he had urged him to calm down before driving away. Or consider the case of Anastasia, a young gymnast who repeatedly undoes in her imagination the terrible mistake that left her paraplegic.

Why would Peter's imagination so constantly and frequently slip into these alternative worlds? Is it because he's rehearsing for the next time he'll talk to his dad? That can't happen. Maybe he's doing it for the next time he faces a similar situation with a loved one. But then what about Anastasia? She won't be able to move again, much less do gymnastics. What kind of future event is she planning to improve on? Perhaps the reason these cases appear puzzling is because we are thinking about their functional benefits in the wrong way: we may not always engage in counterfactual thinking to anticipate the future—perhaps we also do it to work through what has already happened.

Making sense of memories

We spend an enormous amount of time reminiscing about the events of our lives. Sometimes we do so in solitude; other times we discuss them with friends and loved ones. And we do more than replay past experiences unchanged. We ponder them, draw connections between events and, of course, imagine counterfactual alternatives.

Whenever Bertrand tells the story of how he met Laura, listeners inevitably start imagining scenarios in which they fail to meet. It is common to hear them follow their counterfactual thoughts with expressions such as “It was meant to be!” or even “It was destiny!” What happens next is also interesting: Bertrand and Laura hold hands or look at each other lovingly. Psychologist Adam Galinsky, now at Columbia University, along with Roese, Katie Liljenquist, now at Brigham Young University, and Laura Kray of the University of California, Berkeley, thinks counterfactual thoughts might enhance the importance we attach to past events.

To test this hypothesis, in 2010 Kray and her co-workers asked participants to write a short essay about a meaningful event in their life (such as getting into college). Next, half of the participants were instructed to describe all the ways things could have turned out differently. People who did so reported, on various scales (one to seven for the essays about college), that the past experience was more meaningful or significant to them than did individuals who did not engage in counterfactual simulation. The psychologists got a similar result in a follow-up experiment, in which they compared participants who engaged in counterfactual thinking with people who mentally replayed the events exactly as they had occurred. Imagination made the outcome seem almost destined to happen.

These mental exercises may serve an even more general and powerful role. Engaging in counterfactual thinking about our past may actually improve our well-being. In 2013 a study by Samantha Heintzelman, then a psychology graduate student at the University of Missouri, and her colleagues compared participants who imagined alternative versions of the events that led up to either their own birth or the election of Barack Obama. Both groups then answered questions about how meaningful and satisfying they found their life. The people who dreamed up stories relating to their birth reported higher ratings of well-being, purposefulness and satisfaction than did participants who mulled variations on Obama's election.

These results strongly suggest that engaging in counterfactual thinking about past events can influence our personal narrative. But how? Recent clues are emerging from a different line of research, on a related cognitive faculty: memory. For decades researchers thought that once a memory was established—consolidated—it remained fixed, unchanged. Recent discoveries have shown, however, that when we recall a memory, it becomes prone to modification, until it returns to mental storage in a reconsolidated form. When you imagine alternative versions of a memory, the original recollection gets updated and sometimes tweaked. The next time the memory gets called up, some of its content might have been “edited.”

Karl Szpunar, now at the University of Illinois at Chicago, Daniel Schacter of Harvard University and I started to explore the idea of using imagination to edit memories after we obtained a striking result a couple of years back. We had asked participants in one of our studies to engage in counterfactual thinking about past personal events while we scanned their brain activity in a functional MRI machine. Some of their imaginings were more plausible, others more fanciful. We noticed that when a person envisions more likely alternatives to a personal anecdote, his or her brain behaves very much as if it was remembering, whereas implausible counterfactuals do not produce that pattern of activity.

We started thinking that there must be some important connection between remembering and imagining believable, as opposed to far-fetched, counterfactuals. So we followed up on this idea using a well-known method for making an event seem more likely to a person: repetition. Previous research has shown that when people repeatedly imagine something that might happen in the future—such as their getting a promotion at work or a state revoking a certain law—that scenario begins to seem more realistic.

In this study, published in 2013, participants again conjured different versions of some past events. Our subjects then reimagined half of those counterfactuals three times. A day later they came back to the laboratory and reimagined one last time all the counterfactuals they had created. We reached a counterintuitive result: repeatedly simulating those false versions of reality led people to think that they were less plausible than counterfactuals they simulated only once. Imagining the future, for which we lack strong templates (per Kahneman and Miller's norm theory), and reworking the past, for which a clear norm does exist—namely our actual memory—obey different rules. We interpreted this finding as suggesting that imagining around a memory helps us to come to grips with the past. To avoid wallowing in regret, say, our brain downplays repeated what-ifs about bygone times. As a result, you spend less time mulling them over, and you settle into a sense of acceptance.

Unfortunately, this pattern doesn't hold for everyone. Individuals with depression and anxiety may suffer from a tendency to mentally rehearse, over and over, the same imaginary alternative to a past experience. Several studies have shown that this habit is not only strongly associated with anxiety and depression but also is one of these disorders' most debilitating traits. Because sufferers are incapable of banishing such unwanted thoughts, they are less able to move forward with their plans.

Tinkering with emotions

At this point, the question seems obvious: What makes certain kinds of counterfactual simulations beneficial and others harmful? Inklings of an answer come from recent proposals looking at real-world situations in which imagination and autobiographical recollection interact. One such situation is psychotherapy. Earlier this year psychologists Richard Lane, Lee Ryan and Lynn Nadel, all at the University of Arizona, and Leslie Greenberg of York University in Ontario theorized that the most effective psychological therapies—in particular, cognitive-behavior therapy—leverage the power of imagination to modify harmful memories. They suggest that a therapist helps a patient create an imaginative context in which the client can modify the emotional content of memories to edit the past and remove its sting.

In the past year, in collaboration with memory researchers Peggy St. Jacques of the University of Sussex in England and Schacter, I have explored the effects of reactivating a memory while pondering its what-ifs. Though preliminary, our results suggest that when we visit a memory, the intensity of the original emotion tends to weaken the more often you remember it. That is, negative memories deliver less of a punch the next time around, and positive memories lose some of their sheen. But remembering an event while imagining a different version of it tends to preserve its original intensity: negative memories feel just as bad the next time, and positive memories continue to bring joy. We will need to explore carefully the relation between imagination, emotion and memory to make the most of it in a therapeutic context. Suffice it to say, for now, that imagination interferes with the changes that typically befall emotional memories.

Returning to the mundane circumstances in which counterfactual thinking and autobiographical memory collide and to my friend Bertrand's improbable love story, consider the conditions in which Bertrand tends to revisit the events that led up to meeting Laura. He does so usually in the presence of his wife, surrounded by friends or family, in social situations in which memory and imagination intertwine. The result of this nearly ritualistic conversation seems to be inevitably the same: both smile and gaze at each other fondly, and you can almost see their relationship growing stronger.

As these studies suggest, the more Bertrand and Laura imagine how the improbable events preceding their exchanging phone numbers could have turned out differently, the more likely they are to think of that moment as bound to happen. The act of remembering each event while imagining how easily it could have gone otherwise preserves the intensity of the emotion of the original memory—and who wouldn't want to preserve the happiness of such moments, untainted? So maybe here is the reason our mind wanders into possible what-ifs so often and so naturally: imagination not only helps us plan for a better future and ease the burden of our personal past. It may also help our memory preserve those emotions we most want to keep.