One morning after her accident, a woman I’ll call Kate awoke in a daze. She looked at the man next to her in bed. He resembled her husband, with the same coppery beard and freckles dusted across his shoulders. But this man was definitely not her husband.

Panicked, she packed a small bag and headed to her psychiatrist’s office. On the bus, there was a man she had been encountering with increasing frequency over the past several weeks. The man was clever, he was a spy. He always appeared in a different form: one day as a little girl in a sundress, another time as a bike courier who smirked at her knowingly. She explained these bizarre developments to her doctor, who was quickly becoming one of the last voices in this world she could trust. But as he spoke, her stomach sank with a dreaded realisation: this man, too, was an impostor.

Kate has Capgras syndrome, the unshakeable belief that someone – often a loved one, sometimes oneself – has been replaced with an exact replica. She also has Fregoli syndrome, the delusion that the same person is taking on a variety of shapes, like an actor donning an expert disguise. Capgras and Fregoli delusions offer hints about an extraordinary cognitive mechanism active in the healthy mind, a mechanism so exquisitely tuned that we are hardly ever aware of it. This mechanism ascribes to each person a unique identity, and then meticulously tracks and updates it. This mechanism is crucial to virtually every human interaction, from navigating a party to navigating a marriage. Without it, we quickly fall apart.

A classic philosophical thought experiment poses the following paradox. Imagine a ship, let’s call it the Nina, whose planks are replaced, one by one, as they age. Eventually every original part is changed, resulting in a boat made of entirely new materials. Our intuition that this is the same ship becomes problematic when the builders reassemble all the Nina’s original parts into a second ship. The Nina’s identity is tied up inextricably with her physicality.

Personal identity does not work this way. As Nina-the-person ages, almost all the cells of her body get replaced, in some cases many times over. Yet we have no trouble seeing present-day Nina as the same person. Even radical physical transformations – puberty, surgery, infirmity, some future world where her consciousness is preserved on a hard drive – will not obliterate the Nina we know. The personal identity detector is not concerned with continuity of matter, but continuity of mind. As the cognitive scientist Daniel Dennett wryly observed in his essay ‘Where Am I?’ (1978), the brain is the only organ where it is preferable to be the donor than the recipient.

This distinction, between mind and body, begins early in development. In a 2012 study by Bruce Hood at the University of Bristol and colleagues, children aged five to six were shown a metal contraption, a ‘duplication device’ that creates perfect replicas of whatever you put inside. When asked to predict what would happen if a hamster were duplicated, the children said the clone would have the same physical traits as the original, but not its memories. In other words, children were locating the unique essence of the hamster in its mind.

For Nina-the-ship, no part of the vessel is especially Nina-like; her identity is distributed evenly across every atom. We might wonder whether the same applies to people – does their continued identity depend only on the total number of cognitive planks replaced? Or are some parts of the mind particularly essential to the self?

The 17th-century philosopher John Locke thought autobiographical memories were the key to identity, and it’s easy to see why: memories provide a continuous narrative of the self and they serve as a record of a person’s idiosyncratic history. But evidence in favour of the memory criterion is mixed at best. People who have lost large hunks of memory through retrograde amnesia tend to report that, while the reel of their life feels blank, their sense of self remains intact. Nor is memory deterioration from dementia a reliable predictor of feeling like a diﬀerent person. Caretakers for these patients often say they can still perceive the same person persisting beneath radical memory loss. If people have an essence that lends them their identity, memory might not be the most promising candidate.

One day not too long ago, a friend came to me with a problem. His wife of many years had begun to change. Once mousy, she was now poised and assertive. Her career had been important to her, now her interests had turned inward, domestic. And while the changes were not so dramatic that they fundamentally altered the woman he had fallen in love with, he was apprehensive about the possibility.

The danger of befriending psychologists is they will use you as their test subjects: I inquired what kind of change would render her unrecognisable. My friend responded without hesitation: ‘If she stopped being kind. I would leave her immediately.’ He considered the question a few moments more. ‘And I don’t mean, if she’s in a bad mood or going through a rough time. I’m saying if she turned into a permanent bitch with no explanation. Her soul would be diﬀerent.’

This encounter is instructive for a few reasons (not least of which is the intriguing term ‘permanent bitch’) but let’s start with my friend’s invocation of the soul. He is not religious and, I suspect, does not endorse the existence of a ghost in the machine. But souls are a useful construct, one we can make sense of in fiction and fantasy, and as a shorthand for describing everyday experience. The soul is an indestructible wisp of ether, present from birth and surviving our bodies after death. And each soul is one of a kind and unreplicable: it bestows upon us our unique identity. Souls are, in short, a placeholder notion for the self.

But the soul is something else, too. The soul describes a person’s moral sensibility. A flourishing soul, according to Aristotle, was one in the habit of virtuous acts. When the soul is sick, we feed it chicken soup in the form of bite-sized inspirational stories. History’s great psychopaths, its serial killers and genocidal maniacs, are seen as soulless. So are the animate creatures in popular lore: the golems, the Frankensteins, the HALs. The sentient computer who runs amok is a trope of the genre – so much so that, in his short story ‘Runaround’ (1942), Isaac Asimov felt it necessary to propose Three Laws of Robotics to specify ethical guidelines for the wayward robot. Why do we assume that a being without a soul will turn against us? On some level, we must endorse the idea that, without a soul, moral action is not possible.

And where does the soul go when we die? In Western religions, either to a place for the morally good (heaven) or the morally bad (hell). There is no afterlife for good or bad bowlers, the sharp and the dull-witted, the glamorous and the frumpy. Eastern traditions that subscribe to a belief in reincarnation specify that the soul is reincarnated according to the person’s moral behaviour (karma). It is our moral selves that survive us in death.

a world filled with more empathy and kindness would be a better place to live, but we are apparently uninterested in swallowing this solution in a pill

Recent studies by the philosopher Shaun Nichols at the University of Arizona and myself support the view that the identity-conferring part of a person is his moral capacities. One of our experiments pays homage to Locke’s thought experiment by asking subjects which of a slew of traits a person would most likely take with him if his soul moved to a new body. Moral traits were considered more likely to survive a body swap than any other type of trait, mental or physical. Interestingly, certain types of memories – those involving people – were deemed fairly likely to survive the trip. But generic episodic memories, such as one’s commute to work, were not. People are not so much concerned with memory as with memory’s ability to connect us to others and our capacity for social action.

In another study, subjects read about a patient who experiences one of a variety of cognitive impairments, including amnesia for his past life, losing the ability to recognise objects, his desires, and his moral compass. The majority of people responded that the patient was the least like himself after losing his moral faculties.

This is consistent with some of the more widely discussed case studies from the annals of neurology. Phineas Gage was a 19th-century US railroad worker who miraculously survived an explosion that saw an iron rod shoot through his skull. Previously mild-mannered and industrious, Gage emerged from the accident obstinate, capricious and foul-mouthed. His friends were horrified and said he was ‘no longer Gage’.

Other types of brain damage might seem to threaten identity, but are far less potent. In ‘The Lost Mariner’ (1984), Oliver Sacks describes Jimmie, a man with near-total memory loss caused by Korsakoff’s syndrome, a brain disorder associated with heavy alcohol consumption. Sacks worries that his patient has become ‘de-souled’, but reconsiders when he observes how Jimmie is transported while singing hymns and taking the sacrament at Mass. He recalls the Soviet psychologist Alexander Luria’s insight: ‘A man does not consist of memory alone. He has feeling, will, sensibility, moral being… It is here… you may touch him, and see a profound change.’

I have limited my discussion here to third-person accounts: what leads us to consider another person as no longer the same. One might think that a diﬀerent set of rules applies to assessments of one’s own continuity – perhaps episodic memory is paramount from this perspective. However, new research by myself and the psychologists Larisa Heiphetz and Liane Young at Boston College has found that the single most important mental trait in judging self-identity is one’s deeply held moral convictions. We are not only concerned with moral character when constructing an identity for others, but when doing so for ourselves.

In treating the sick, the use of psychopharmaceuticals is plagued by the persistent worry that these drugs will lead to a crisis of authenticity. A 2008 study by Jason Riis, then at New York University, and colleagues found that people were least willing to take psychoactive drugs that threatened their personal identity. And what drugs were those? The ones that enhanced their moral traits, of course: kindness, empathy. People were perfectly willing to take drugs that would enhance memory or wakefulness. Surely a world filled with more empathy and kindness would be a better place to live, but we are apparently uninterested in swallowing this solution in a pill which seems to threaten our authentic selves.

Organic transformations can be no less sensational. A notable example from recent memory takes place in the US TV series Breaking Bad, which tracks Walter White as he morphs from put-upon suburban chemistry teacher to ruthless tyrant kingpin of a meth empire – the eponymous ‘breaking bad’. Under his ominous nerd alter ego Heisenberg, it is all but impossible to see him as the man he once was. His increasingly distraught wife finds herself living with a stranger, and Walter confirms what the viewer already realises: ‘If you don’t know who I am, then maybe your best course would be to tread lightly.’ Meanwhile, White’s accomplice Jesse Pinkman undergoes the reverse transformation – the burnout junkie who is revealed to have a heart of gold. These sorts of twists are endlessly fascinating because they show personal transformation at its most absolute. Flipping back through the great metamorphoses of fiction and history, we discover they are predominantly moral: think of the brothers Karamazov, of Scrooge and Schindler, Don Corleone and Darth Vadar.

Why does our identity detector place so much emphasis on moral capacities? These aren’t our most distinctive features. Our faces, our fingertips, our quirks, our autobiographies: any of these would be a more reliable way of telling who’s who. Somewhat paradoxically, identity has less to do with what makes us diﬀerent from other people than with our shared humanity. Consider the reason we keep track of individuals in the first place. Most animals don’t have an identity detector. Those that share our zeal for individual identification have one thing in common: they live in societies, where they must co‑operate to survive. Evolutionary biologists point out that the ability to keep track of individuals is required for reciprocal altruism and punishment to emerge. If someone breaks the rules, or helps you out of a bind, you need to be able to remember who did this in order return the favour later. Without the ability to distinguish among the members of a group, an organism cannot recognise who has co‑operated and who has defected, who has shared and who has been stingey.

Nor can you have formal moral systems without identity. The 18th-century philosopher Thomas Reid observed that the fundaments of justice – rights, duty, responsibility – would be impossible without the ability to ascribe stable identity to persons. If nothing connects a person from one moment to the next, then the person who acts today cannot be held responsible by the person who has replaced him tomorrow. Our identity detector works in overdrive when reasoning about crimes of passion, crimes under the influence, crimes of insanity: for if the person was beside himself or out of his mind when he committed his crime, how can we identify who has committed the act, and hold him responsible for it?

If we had no scruples, we’d have precious little need for identities

Moral features are the chief dimension by which we judge, sort and choose social partners. For men and women alike, the single most sought-after trait in a long-term romantic partner is kindness – beating out beauty, wealth, health, shared interests, even intelligence. And while we often think of our friends as the people who are uniquely matched to our shared personality, moral character plays the largest role in determining whether you like someone or not (what social psychologists call impression formation), and predicts the success and longevity of these bonds. Virtues are mentioned with more frequency in obituaries than achievements, abilities or talents. This is even the case for obituaries of notable luminaries, people who are being written about because of their accomplishments, not their moral fibre.

The identity detector is designed to pick up on moral features because this is the most important type of information we can have about another person. So we’ve been thinking about the problem precisely backwards. It’s not that identity is centred around morality. It’s that morality necessitates the concept of identity, breathes life into it, provides its raison d’être. If we had no scruples, we’d have precious little need for identities. Humans, with their engorged and highly complex socio-moral systems, have accordingly inflated egos.

‘Know thyself’ is a flimsy bargain-basement platitude, endlessly recycled but maddeningly empty. It skates the very existential question it pretends to address, the question that obsesses us: what is it to know oneself? The lesson of the identity detector is this: when we dig deep, beneath our memory traces and career ambitions and favourite authors and small talk, we find a constellation of moral capacities. This is what we should cultivate and burnish, if we want people to know who we really are.