Innocent until proven guilty. Beyond reasonable doubt. Judged according to the evidence by a jury of your peers. Isn't that how it works? Not quite. The procedures and rules of evidence applied by Scots law are exemplary, more or less. They are certainly preferable to most continental models. But the ignominious collapse of the trial of Angus Sinclair, the killer tied to the World's End murders, suggests that even a fine old legal tradition, however refined, is still susceptible to spectacular failures. That won't do.

It won't do because justice is a political matter. I don't mean, necessarily, that courts are under overt external pressure. I mean that judges and juries apply the laws of the land, laws arrived at by a political process. The procedures governing trials, equally, and the operations of the Crown Office are expressions of democratic decisions. One way or another, this affects all of us.

It can make a true separation of powers tricky. The Lord Advocate, responsible for the legal system, is a member of the government (though not, currently, of its cabinet). The Crown Office, responsible for bringing the case against Sinclair, therefore has a political aspect. Anyone who followed the Shirley McKie affair, with every important question left unanswered, knows what "political" can sometimes mean.

In the case of the World's End murders it means that important issues are laid at parliament's door. The outcome of the failed trial will not be altered. Sinclair cannot be retried for the deaths of Christine Eadie and Helen Scott in 1977, whatever police, lawyers, forensic scientists and every outside observer happens to believe. That need not be the end of the matter.

Sinclair cannot be retried, in fact, despite what is known about his DNA, his belated confession of sexual intercourse with the girls, his connection to a host of near-identical killings and his predictable decision to lay all blame on a dead brother-in-law. Yet as Margo MacDonald, independent MSP for the Lothians, has already argued, baffling decisions by the prosecution in failing to lead evidence merit a parliamentary inquiry. Justice and politics are never discrete entities.

The prosecution's failure to offer sufficient evidence that "ligatures" used to kill the girls were linked to Sinclair was crucial in the mind of Lord Clarke, the judge. DNA samples on knotted tights might have persuaded a jury, but Alan Mackay, advocate depute, did not avail himself of the opportunity. That is barely credible. It suggests that after years of police effort the Crown Office was incapable of putting together a prosecution. But it also overlooks the judge.

Most reports yesterday seemed to say that he had no choice in the matter. Such is the convention, after all. He alone was the fit and proper person to assess the evidence led and he found it inadequate. Sinclair's acquittal followed "inevitably". Even if justice miscarries, that is how the system works.

The fact is, however, that a different judge could have reached an entirely different decision. A different judge could have elected, given the long and controversial history of the murder case, to allow a jury to decide whether the evidence did or did not stack up. Given the prosecution's apparent disastrous inability to recognise the importance of the evidence available, this would have been a risk. Another judge might have decided, nevertheless, that it was a risk worth allowing.

What do we say to that? What political answer is there, if any, when the possibility arises that both judge and prosecution, in their different ways, made questionable decisions? The usual short answer is that politicians can never be allowed to interfere with the courts. For most purposes, that will do. But we risk forgetting that miscarriages of justice come in a variety of forms, and are not always inflicted on the accused. Christine Eadie, Helen Scott and their families have not had justice, or anything like it.

If Sinclair happened to be innocent, why hinder a jury from establishing the fact? Equally, if there was strong circumstantial evidence to link this proven sex killer to four Glasgow murders, as we reported yesterday, why did that fact - pointing to near identical methods for murder - not figure in the World's End trial? Only the judge could answer the first question, though he will not. Only the Crown Office can resolve the second (political) puzzle, though it is unlikely to do so willingly. None of this is satisfactory.

Lord Clarke sent Sinclair back to Peterhead to resume a sentence earned for still other, disgusting crimes. The judge stopped a trial scheduled to last six weeks after a mere eight days because the defence said there was no case to answer. Whatever his view of the prosecution's evidence, did the judge really believe that eight days were sufficient after 30 years of controversy, suspicion, repeated investigations and pain?

Judges are not called before parliamentary inquiries. There are very good reasons for that. The Crown Office, meanwhile, will no doubt be asking hard questions of itself today behind closed doors. There are less good reasons for allowing soul-searching in private when such a case has been forfeited in such a manner. Sensible people grow nervous, rightly, when politicians seek to influence the court system. If offends a fundamental principle and the results, invariably, are disastrous. Yet where, in this case, does that leave us?

The separation of powers leaves us with a problem. We elect politicians; we do not, mercifully, elect prosecutors and judges. So how are we supposed to respond when bizarre cock-ups confound our desire for justice and an immense quantity of police work? The Lothian and Borders force does not believe it got the wrong man. The forensic scientists do not believe they got the wrong man. Neither is judge, neither is jury: that's as it should be. The fact remains that Sinclair has been acquitted and there is no mechanism, none whatever, by which the opinion of a single judge can be challenged.

Parliament needs to think about these matters. It needs to think about retrials and double jeopardy. It needs to apply itself to the issue of previous convictions and their admissibility. Crown appeals and judicial independence need to be considered, along with the relationship of law officers to the political process. The competence and efficiency of the Crown Office requires investigation. Procedure in criminal trials and the rules of evidence need to be reviewed more often, or at least more intensively.

The authority of any legal system depends on the respect it commands. This does not mean that every decision has to be popular. It does mean that decisions should be comprehensible. Sinclair's guilt for the murders of Christine Eadie and Helen Scott has not been proven. What you or I happen to believe is, like it or not, of no account. Just as important, however, is the fact that vast doubts still hang over Sinclair's innocence. The old formula does not apply.

Confidence in the courts and the Crown Office has been undermined badly. Neither institution is entitled to behave as though the fact is of no account in its august proceedings. The public, whom justice serves, has been insulted. What might we do about that?