Image copyright Getty Images

US presidential hopeful Ben Carson has attracted attention and some ridicule this week for saying Egypt's pyramids were built to store grain. As most schoolchildren know, they were actually tombs for pharaohs. But where did the granary idea come from, and would it even have worked?

Egyptian history isn't something American presidential candidates are usually quizzed about on the campaign trail, but this week Republican Ben Carson faced a barrage of questions after it emerged he believed the pyramids were built by the Biblical figure Joseph for storing grain.

This was revealed on Wednesday when Buzzfeed published a video of Carson addressing students at a Michigan university affiliated with his Seventh-day Adventist Church 17 years ago. But the famed neurosurgeon, currently the frontrunner for the Republican nomination, told inquisitive journalists that his views had not changed.

So where does this granary theory come from?

In the Old Testament, Joseph is sold into slavery in Egypt by his brothers, where he later interprets a pharaoh's dreams and helps the Egyptians survive a seven-year famine - by storing grain. There is no mention of pyramids in the Bible's version of the story but in the Middle Ages people started to write them into the story.

Image copyright Getty Images Image caption Carson is a member of the Seventh-day Adventist Church

"If you go to St Mark's cathedral in Venice, there's a medieval depiction showing people using the three great pyramids of Giza as granaries in Joseph's story," says John Darnell, a professor of Egyptology at Yale University.

"If you didn't have access to the structures, the idea had some currency."

It's like saying the Tower of London was built as a granary store James Allen, Brown University

The belief was also popularised by Saint Gregory of Tours, a sixth century Frankish bishop, who wrote: "They are wide at the base and narrow at the top in order that the wheat might be cast into them through a tiny opening, and these granaries are to be seen to the present day."

The Book of John Mandeville, a popular 14th Century travel memoir, also referred to "Joseph's Granaries, which he had made to store the wheat for hard times".

But Darnell says the idea began to fall out of favour during the Renaissance, when people made more detailed studies of the pyramids.

"Now of course we know the pyramids were burial chambers - albeit just one element of far greater complexes. The architectural predecessors and descendants of pyramids, their internal passageways and the function of their spaces can be traced right through the period into the new Kingdom of Egypt," he says.

The story of Joseph is supposedly set in the time of Egypt's Middle Kingdom, Darnell points out, which is centuries after the pyramids of Giza were built.

Image copyright The Trustees of the British Museum. Image caption A painted wooden model of a granary from Egypt in around 2200 BC

Egyptologists have also questioned other aspects of Carson's pyramid theory. Whatever held Joseph's grain "would have to be something awfully big if you stop and think about it", he said in his 1998 lecture.

It wouldn't make sense to build gigantic monumental granaries John Darnell, Yale University

He added: "And when you look at the way that the pyramids are made, with many chambers that are hermetically sealed, they'd have to be that way for various reasons."

His argument appears to have been that the chambers were hermetically sealed to preserve grain. But Darnell rejects this logic.

"The major internal element of the pyramids is stone and brick - there wouldn't be much space for grain, and it would be huge waste of power and engineering," he says. "Plus we know ancient granaries tended to beehive-shaped and quite small. It wouldn't make sense to build gigantic monumental granaries - it would take ages to grain in, and smother everyone when it poured out."

Egyptologist James Allen of Brown University agrees. "There's no way in the world an ounce of grain would be stored in a structure like that," he says. "It would be totally impractical. It's like saying the Tower of London was built as a granary store."

Image copyright Getty Images Image caption Ben Carson has become known for his controversial comments

This is only one of a number of comments from Carson that have taken some Americans aback. Others include his suggestion that being gay is a choice, that Muslims aren't qualified to seek the US presidency, and President Barack Obama's healthcare reform was "the worst thing" since slavery . However, none of these statements appears to have affected his poll rating.

Darnell argues that the pyramid theory is "somewhat surprising and scary", coming from a leading contender for the presidency, but he also sees this as an opportunity.

"Egyptology isn't known as being a major topic in politics. But we are actually facing some remarkably similar situations to then - a jockeying for power and influence in the world, a rising power in what is now Turkey, a political and military vacuum in what is now coastal Syria and Lebanon," he says.

"If candidates would take a closer look at ancient Egypt… it might contribute to how they approach problems today, and that would make me very happy."