The principle of legality is the legal ideal that requires all law to be clear, ascertainable and non-retrospective. It requires decision makers to resolve disputes by applying legal rules that have been declared beforehand, and not to alter the legal situation retrospectively by discretionary departures from established law. It is closely related to legal formalism and the rule of law and can be traced from the writings of Feuerbach, Dicey and Montesquieu.
The principle has particular relevance in criminal and administrative law. In criminal law it can be seen in the general prohibition on the imposition of criminal sanctions for acts or omissions that were not criminal at the time of their commission or omission. The principle is also thought to be violated when the sanctions for a particular crime are increased with retrospective effect.
In administrative law it can be seen in the desire for state officials to be bound by and apply the law rather than acting upon whim. As such advocates of the principle are normally against discretionary powers.
The principle can be varyingly expressed in Latin phrases such as Nullum crimen, nulla poena sine praevia lege poenali (No crime can be committed, nor punishment imposed without a pre-existing penal law), nulla poena sine lege (no penalty without law) and nullum crimen sine lege (no crime without law).
There is some debate about whether this is really a true exception or not. Some people would argue that it is a derogation or - perhaps somewhat more harshly - an infringement of the principle of legality. While others would argue that crimes such as genocide are contrary to natural law and as such are always illegal and always have been. Thus imposing punishment for them is always legitimate. The exception and the natural law justification for it can be seen as an attempt to justify the Nuremberg trials and the trial of Adolf Eichmann, both of which were criticised for applying retrospective criminal sanctions.
In contrast many written constitutions prohibit the creation of retrospective (normally criminal) laws. However the possibility of statutes being struck down creates its own problems. It is clearly more difficult to ascertain what is a valid statute when any number of statutes may have constitutional question marks hanging over them. When a statute is declared unconstitutional, the actions of public authorities and private individuals which were legal under the invalidated statute, are retrospectively tainted with illegality. Such a result could not occur under parliamentary sovereignty (or at least not before Factortame) as a statute was law and its validity could not be questioned in any court.