SCOTLAND’S attainment gap between rich and poor school children has blighted the nation’s education system for decades and is arguably a stain on all governments from both the post and pre devolution eras.

The issue has become a thorn in the side of the SNP. The party of government has pinned much of its policy to so-called 'progressive values' but if rich children are doing vastly better at school than poor children then those progressive values are not being turned into policy which is changing the lives of our less fortunate citizens for the better.

At the heart of the problem are statistics such as these: only 54 per cent of children from the poorest areas of Scotland in the final year of primary school meet the standard of writing expected for that age group by the SNP Government's own flagship Curriculum for Excellence (CfE). This is compared to 78 per cent of those in the wealthiest areas. And, only 58 per cent of P7 children in the most deprived areas meet the standard for numeracy compared to 80 per cent of youngsters in the best-off communities.

The figures are stark: an attainment gap exists, and it undermines the central principles of the SNP - but what can be done to fix the problem? The Sunday Herald spoke to some of the foremost experts in education to find out.

Academics, teaching unions and top educationalists are all warning that failing to get to grips with the attainment gap risks increased inequality, undermining the notion of a Scandinavian-style social democracy to which many Scots, including many members of the SNP, aspire.

These experts say poverty and entrenched levels of inequality during the early years of schooling are at the heart of what is arguably the biggest challenge facing the SNP government, aside from winning independence.

An intensive targeting of resources at socially deprived communities, the expansion of education in nurseries and a more extensive monitoring of how children from poorer backgrounds perform, are all ideas placed on at the top of the agenda by the experts we spoke to.

One of Scotland's leading educationalists outlined just how much is at stake, with a warning that the success or failure of ministers to get to grips with the attainment gap will determine the shape Scottish society takes in the coming decades.

Professor Sheila Riddell, director of the centre for research in education inclusion and diversity at the Moray House school of education, University of Edinburgh, said: "If you are going to resolve the problem of an attainment gap then you have to deal with inequality.

"The benefits you get are that it's a more cohesive society. That follows from having a better educated population and you have less disease and less violence."

In other words, closing the attainment gap is almost a form of social engineering which may well lead to fewer people in prison and a more healthy population.

Ministers were also warned that a failure to narrow the attainment gap would lead to "large-scale economic damage" by Russell Gunson, director of the left leaning think-tank, the Institute for Public Policy Research Scotland (IPPR).

As such, calls for resources to be targeted at nursery education and for less competition between schools, through league tables for example, were among the key asks from leading voices across the educational and political spectrum.

Both Scottish Tory education spokesperson Liz Smith and Scottish Labour's shadow education minister Daniel Johnson, backed calls for early years intervention - targeting resources at the poorest children - to narrow the attainment gap.

The backdrop to this critical challenge facing the SNP government in its third term in power was presented starkly in some of the worst findings about educational attainment - regardless of wealth - for Scotland in living memory.

Results from the 2015 Programme for International Student Assessments (Pisa) published last month showed that Scotland's scores for maths, reading and science all declined. It was the first time since the tests began in 2000 that all three subject areas were classed as "average", with none "above average".

Scotland is now third of the four UK home nations, according to the findings, which Education Secretary John Swinney said “undoubtedly make uncomfortable reading”.

Nicola Sturgeon fully comprehends the magnitude of the problem, and her appointment of Deputy First Minister Swinney - one of the most competent ministers of the devolution era - to the education brief shows her will to make a change.

Larry Flanagan, the leader of the EIS, Scotland's largest teaching union, says "all this focus on addressing that gap" suggests the SNP knows its reputation as a competent government is on the line over the issue.

Of course, the attainment gap among Scotland's pupils is nothing new and there were widespread disparities between the grades of pupils from affluent and deprived backgrounds under the eight years of Labour-Lib Dem rule, as well as during the long Tory dominated pre-devolution era.

Placing the blame for the attainment gap solely at the door of the SNP is therefore unfair. They inherited a problem that was mismanaged before they took office, but nonetheless the party has been in power for a long time now and given its talk of equality some improvement would have been hoped for by now.

It's a point that Riddell of the University of Edinburgh is quick to make, saying: "It's not as if (an attainment gap) suddenly sprung up. It's well known that Labour and the Lib Dems recognised the problem and tried to do something about it."

Riddell suggested the longevity of the problem could be why Sturgeon has taken such a keen interest in an initiative to boost attainment levels in London schools.

The First Minister has said that the London Challenge, introduced in 2003, has led to “sustained” improvements in pupils’ performances, and stressed ministers would not shy away from learning lessons from such a scheme.

However, Riddell said the Scottish Government would need to come up with its own distinctive plan to halt the alarming growth in the attainment gap.

Riddell said: "We do have some evidence from other parts of the UK about how funds need to be targeted at pupils from poorer backgrounds, but we must couple that with the need to closely monitor attainment data. The London challenge was quite successful in doing that."

She went onto say that such educational inequalities were less pronounced in Scandinavian countries. Riddell said: "There are no easy answers to this. The targeting of resources is needed, coupled with a much better tracking of pupils data. That's really essential

"Every single developed country in the world has these problems, although social class inequalities are less of a problem in Scandinavia. Systems that have higher rates of inequality tend to have more inequality in their education systems."

So a more unequal society has more unequal outcomes in education. That makes sense - but if that is the case just how does the SNP resolve this seemingly intractable Catch-22 problem of needing to narrow the attainment gap in order to tackle inequality in wider society, while this same endemic inequality across society is what leaves children from poorer backgrounds disadvantaged from day one?

EIS general secretary Flanagan, says the inequalities take hold during the nursery school years, when children are often in non-educational environments more focussed on child minding. Flanagan said more affluent areas tended to have better nursery school provision, with early educational development for children.

Backing the formal integration of nursery schools into primary schools, he said: "One of the main ways of addressing the attainment gap is to prevent that gap developing in the first place."

He added: "What you can have at the moment is playgroup provision that's not led by teachers. The curriculum goes from three to 18, but a lot of under 5s don't access that because they are not in an educational environment. They are in pre-nurseries.

"But some of the more affluent areas have strong nursery provision. Where kids are not in high quality nursery provision, the bigger the (attainment) gap is likely to be."

However, Flanagan welcomed the Scottish Government's overall commitment to tackle the attainment gap, saying: "It's positive that there's all this focus on addressing that gap as it's not so long ago that we used to send kids to different types of schools and when I started teaching in 1979 kids were sometimes put in remedial classes and stayed there.

"But we are fighting a battle all the way through school trying to direct resources to stop the gap happening in the first place. Schools can make a big difference in working to overcome poverty, which creates big barriers. If you set homework with an assumption about the level of resources for children, such as that there is a computer at home, you are inadvertently creating barriers."

Gunson, director of IPPR Scotland, said the Curriculum for Excellence had not cut the attainment gap. He said: "Curriculum for Excellence is aimed at improving outcomes for all, but inequality across the board is rising. If it can be resolved it could lead to large areas of economic growth or large areas of economic damage if we don't."

The leader of the union that represents teachers in Scotland's secondary school teachers, said his members taught children at an age when the attainment gap was becoming more pronounced.

Seamus Searson, general secretary of the Scottish Secondary Teachers' Association, said ministers had to ensure additional funding was in place to support children from poverty-stricken backgrounds.

He said: "It's about trying to level up the playing field. Supporting parents on low incomes is a critical issue and something like breakfast clubs is a good investment.

"There's nothing worse than teaching a child whose hungry. We also need to move away from a situation where schools are competing with each other."

Swinney, in response, said the SNP had committed £750 million of Scottish Attainment Challenge funding over the course of this parliament. He said: "We are determined to resolve this long-standing issue as part of our effort to tackle inter-generational poverty. This government is taking action to ensure that every child, no matter their background, has the chance to succeed by implementing a range of measures to strengthen our education system and putting substantial new resources in place."