The premise is startlingly ambitious: what if we could think our way into Alan Turing’s dreams? It’s the sort of thing Turing himself might have attempted as he tried to move between minds, questing for the limits of shared comprehension. But a novelist imagining the unconscious of a genius and finding words for his visions – can that be wise? Yes, if the writer is Will Eaves. Scrupulous, humane, sad and strange, this fifth novel by the author of The Oversight and The Absent Therapist is as bracingly intelligent as it is brave.

Murmur is based on Turing’s experience during the period of his punishment for gross indecency, when he went to hospital weekly and quietly submitted himself to the injection of hormones that effected chemical castration. As his body and mind underwent disturbing changes, he talked to the Jungian therapist Franz Greenbaum. In the sessions of analysis and outside them, in sleep and waking, Turing pressed towards an understanding of singular and multiple identity, memory and desire. The cryptanalyst who, at Bletchley, had programmed machines to break the German naval code now applied himself to the cipher of his own trance-like visions.

Turing was a philosopher, psychologist, mathematician and biologist – Eaves's narrative experiments honour that legacy

It’s hard to imagine a more challenging subject for a novel. The nature of consciousness is at the heart of it, inseparable from the exploration of sexuality and artificial intelligence. But in fact there is nobody called Turing or Greenbaum in the novel. Instead there is a fictional Alec Pryor and his analyst Stallbrook (who doubles, in the book’s mirror world, as a schoolmaster who in Pryor’s youth played an analogous role as observer and examiner). Eaves liberates himself from the ethical difficulty of giving people words they did not use and works with a kind of shadow history. Like the many reflected or “transposed” images in Turing-Pryor’s dreams, these characters have lives of their own but they emanate from real people and bend the light back to illuminate history’s questions.

The first part of Murmur, which was shortlisted for the BBC national short story award, invents Alec Pryor’s personal journal. There follows a series of dream narratives framed by letters to and from Alec’s former fiancee, June (a movingly portrayed version of the woman who was briefly Turing’s fiancee, Joan Clarke). Each of these sections might work autonomously, though the novel accrues and arcs to become much more than the sum of its story’s parts.

The most beautiful section is Alec’s dream of watching himself as a boy at school, swimming across a lake by night with the fellow pupil he loves. Shivering in their nakedness they reach the far shore, where raspberries grow, and spend the night side by side in a summerhouse. As Pryor’s body changes, he examines the constancy of this first and defining love, which has been sent underground, “culverted”, buried like Roman bullion. All the novel’s allusions to Ovid’s Metamorphoses concern the steadfastness with which love persists through bodily transformation. They are also about loneliness. Pryor considers the possibility of a shared mind, but he is an unreachably lonely ghost haunting his own past.

There is little expression of anger at what is being done to him, and no thought of revenge. There is no self-pity. Everything about Pryor is more generous and far-sighted than that – so far-sighted that his thoughts move back through geological time (“ice calls to ice”) even as he hears the murmur of the future’s machines holding their secret council. The mechanical arm of a funfair octopus ride is also a primeval mollusc, scooping him up and away through time. “Progressives and atavists are aspects of the same person and ghost each other,” he observes. He understands the death of the man he loved as both an ancient tragedy and as the “set of instructions” that programmed the machine of his mind. The dreams are themselves instructions, reconfiguring the brain.

The imagery is extravagant, as one might expect from a novel engaged with Jungian analysis. The boy in the forbidden garden puts on a deer’s skull, turns to the rising sun, and becomes a chimerical shaman. In the ordinary family house, where the parquet flooring matches the chevrons on Pryor’s socks, his mother appears in a red cape, mixing henbane. Some of these passages, painted, might resemble the vividly intricate surrealist work of Leonora Carrington or Dorothea Tanning. But what’s most gripping is the careful, calm, modest voice in which these weird scenes are related and analysed. One hears, at every turn, the formal grammar of a Latinist and the strenuous logic of the exceptional mathematician.

Huge efforts are being made in contemporary universities to foster dialogues between arts and sciences. In this, as in most things he touched, Turing leapt over boundaries, barely noticing that they were there. He was a philosopher and a psychologist, as well as a computational mathematician and biologist. Eaves conducts narrative experiments that honour that legacy. He knows that Turing’s theories of consciousness have implications for fiction, and that fiction can operate at the frontiers of what we know about the workings of our minds.

• Alexandra Harris’s Weatherland: Writers and Artists under English Skies

is published by Thames & Hudson.

To buy Murmur go to CB Editions.com.