Have you heard the one about the librarian getting a request for a book about Pavlov's dog and Schrodinger's cat? They said it rang a bell, but didn't know if it was there or not.

If you didn't find that joke funny, scientists have applied the logic commonly used in quantum mechanics to explain our sense of humour, and it could one day help us make sense of how our brains react to both good and bad attempts at making us laugh.

Nothing sucks the humour from a joke quite as fast as analysing it. But that's just what a pair of Canadian and Australian researchers did by applying mathematical generalisations from quantum mechanics to a list of jokes.

Several hypotheses of humour have been proposed in the past in an attempt to explain why our brains react as they do to awkward or odd situations, with most expressing it as a way to makes us feel better about language or events that we find unusual or uncomfortable.

Take, for example, words or sounds with multiple meanings that depend on their context, such as the number 8, which can also sound like the verb 'ate'.

Ask a five-year-old "Why was 6 afraid of 7?", and say "Because 7-8-9!" and watch as you suddenly become their favourite stand up comic. 

For adults, humour can help us feel better about taboo or macabre situations.

Recent research uncovered a relationship between 'dark' humour and higher intelligence, suggesting that complex information processing was required to appreciate a sick joke.

This new study attempts to explore the core elements of humour, and apply a new way of mapping and evaluating the components of humour to determine exactly what makes a joke funny.

"Funniness is not a pre-existing 'element of reality' that can be measured; it emerges from an interaction between the underlying nature of the joke, the cognitive state of the listener, and other social and environmental factors," says Liane Gabora from the University of British Columbia in Canada.

If you think using the mathematics behind quantum theory to analyse a social behaviour sounds a bit, well, strange, it's actually a common application in fields of psychology.

"Quantum formalisms are highly useful for describing cognitive states that entail this form of ambiguity," says Gabora.

This isn't to say the mathematics is describing physical properties of our brains, but rather that the logical constructs that allow physicists to model multiple dimensions in what's called Hilbert space can also be used to describe relationships between variables in other complex, multilayered systems, such as the processes of decision making or in social interactions.

To test their so-called quantum theory of humour, the researchers broke the construct of a joke down into its components, including the setup, the person who is telling the joke, their relationship with the audience, and the surroundings.

Using the resulting formula, the researchers applied various scores to weight the joke's components and predict how people might find the overall structure funny.

They then came up with a list of 35 jokes and created a number of variants for each one, such as delivering the punchline without a setup, or by presenting it with a modification on its script.

For example, one type of variant to "Why was 6 afraid of 7?" was "Because 7 was a six offender."

The jokes and their variants were tested on 85 undergraduate students, who gave them each a rating based on how funny they thought the joke was.

For the most part, the variants weren't considered as funny as the original joke, but they did help the researchers pinpoint what exactly the audience found funny.

Previous attempts to understand why puns makes our lips pull back into a grin, our diaphragm spasm in laughter, and our brain release endorphins, assumed the sudden change in meaning as the joke resolved was to blame.

For example, "time flies like an arrow" establishes the meaning of the words "flies" and "like", while following it with "but fruit flies like a banana" requires contrasting definitions, producing humour.

The researchers concluded it's not the switch that creates the "ha!" moment, but rather the need for our brains to embrace both concepts at the same time in a quantum-like entangled state of meaning.

For what it's worth, rather than to provide ground-breaking revelations that could help you win over your work-mates, the study demonstrates how a model based on quantum mathematics could be more useful than traditional models of humour analysis.

The relatively small sample size and diversity, and simplicity of the researchers' model, mean we should take their conclusions with a grain of salt, but the new approach does pave the way for more research in the future into the so-far intangible quality of a good joke.

"The cognitive process of 'getting' a joke is a difficult process to model, and we consider the work in this paper to be an early first step toward an eventually more comprehensive theory of humour that includes predictive models," says Gabora.

A 'quantum theory of humour' might not help us craft the perfect pun, but it could go some way in helping us understand more about our funny brains.

This research was published in Frontiers in Physics.