This year is the 40th anniversary of the publication of one of the cult books of my generation: Gödel Escher Bach by Douglas Hofstadter. This Pulitzer prize-winning tome was essential reading in the 1980s for emerging geeks like me. But, despite its name, it is not a book about the composer Bach, the artist Escher or even the mathematician Kurt Gödel. It is about consciousness and Hofstadter’s belief that this elusive concept is related to the idea of what he calls “a strange loop”.

To celebrate the anniversary, I am staging a triptych of events at the Barbican in London called Strange Loops, looking at the impact of technology on what it means to be human. I believe that the ideas in the book are now more relevant than at any point over the past four decades. The strange-loop concept may be the key to understanding when and whether the fast-evolving AIs we are creating might become conscious.

What makes a loop “strange”? A strange loop is a cyclical structure that goes through several layers of a hierarchical system to find itself back at the beginning. One layer is contained inside another to permit a strange crossing of these levels so that the higher one suddenly appears embedded in the lower. This is why Hofstadter chose Escher as the perfect illustration of the idea of a strange loop.

Think about the famous Escher image of the monks climbing a quadrangle of squares that seem to keep climbing and yet, at full circle the monks step on to the stair they started from. Or the image of two hands each drawing the other. An image of a hand drawing a hand seems to imply the first hand is in a world above the drawn hand. And yet the image confuses us because we can’t work out which is the primary layer.

Hofstadter admitted, when I interviewed him for the Barbican project, that the book was going to have an academic title about the human brain that did not refer to Escher or Bach. But when his father read the first draft he complained that there were no pictures. Hofstadter realised he had had Escher’s images in his mind as he wrote about loops that climb yet return to the beginning. Thus Escher is there to help the reader see the concept of a strange loop. One strand of our triptych at the Barbican explores visual feedback in an interactive installation created by the artist Ben Kreukniet.

There are interesting examples of strange loops in sound. An illusion called a Shepard tone consists of notes that seem to get higher and higher in pitch yet never seem to go beyond audible frequencies. The sound is looped but the frequencies are cleverly chosen to given an illusion of the pitch continually climbing. Bach uses a similar idea in a variation in The Musical Offering. The theme seems to repeat itself, climbing a note higher each time it is played. Yet at a certain point the theme hits the octave and the piece sounds as if it is beginning again.

The variations that make up The Musical Offering illustrate how Bach loved to use algorithms to create complex music from a simple theme. Indeed, I like to call Bach the first musical coder. But Bach’s use of code raises an interesting challenge. How much might artificial intelligence understand Bach’s code and produce its own music in the same style? I have been exploring this idea in my new book The Creativity Code. And, in the second part of the Barbican triptych on 9 March we will explore whether an audience can tell the difference between music created by humans or AI, with the help of harpsichordist Mahan Esfahani.

But the ideas of the Austrian-born logician Kurt Gödel, the third character Hofstadter chose, are most relevant to why a strange loop might be the key to consciousness in humans, and maybe one day, machines. And it was encountering Gödel’s as a student that first inspired Hofstadter to write his book.

Gödel proposed one of the most extraordinary theorems in mathematics. Ever since the time of the ancient Greeks we have been taking true statements about numbers and giving logical proofs about their truth. It was thought that if a statement about numbers were true, then there would always be a proof of that. But in 1931, Gödel showed that within any mathematical system there will always be true statements about numbers that cannot be proved true within that system. Called the incompleteness theorem, it revealed limits to what mathematics can know.

The way Gödel proved his theorem was to show that mathematics was rich enough to be able to talk about itself. He constructed a numerical code – the Gödel coding – that meant any statement about numbers had its own code number. But this meant that numbers could stand for two things: numbers in their own right or code for statements *about* numbers. Using this coding he was able to turn the seemingly paradoxical statement “This statement has no proof” into an equation about numbers.

Now, either an equation is true or false. If this particular equation is false it means the statement does have a proof, but proof implies truth. So it can’t be false. That means the equation and therefore the statement must be true. Which in turn means here is a true statement in mathematics with no proof. By using self reference, Gödel has made mathematics prove its limitations.

Hofstadter believes that, just as mathematics is rich enough to talk about itself using this mixing of levels, the brain’s ability to be conscious of itself may be because of a similar ability. The human brain, he thinks, has achieved sufficient complexity to code up knowledge about itself. Just as Gödel showed mathematics can talk about itself using these logical strange loops, for Hofstadter the “I” we call consciousness is the result of a strange loop in the brain’s network. This idea is what inspired the name of the play that forms the third strand to my Barbican triptych: “I” is a strange loop.

Strange Loops is at the Barbican, London, from 9-23 March, part of the Life Rewired festival. Marcus du Sautoy is professor for the public understanding of science at the University of Oxford and the author of The Creativity Code.