In the original Star Trek, with the Starship Enterprise hurtling rapidly downward into the outer atmosphere of a star, Captain James T Kirk orders Lt Commander Montgomery Scott to restart the engines immediately and get the ship to safety. Scotty replies that he can’t do it. It’s not that he refuses to obey the Captain’s order or that he doesn’t happen to know how to restart the engines so quickly. It’s that he knows that doing so is impossible. ‘I can’t change the laws of physics,’ he explains.

We all understand Scotty’s point (although the Enterprise does somehow manage to escape). He cannot break the laws of nature. Nothing can. The natural laws limit what can happen. They are stronger than the laws of any country because it is impossible to violate them. If it is a law of nature that, for example, no object can be accelerated from rest to beyond the speed of light, then it is not merely that such accelerations never occur. They cannot occur.

There are many things that never actually happen but could have happened in that their occurrence would violate no law of nature. For instance, to borrow an example from the philosopher Hans Reichenbach (1891-1953), perhaps in the entire history of the Universe there never was nor ever will be a gold cube larger than one mile on each side. Such a large gold cube is not impossible. It just turns out never to exist. It’s like a sequence of moves that is permitted by the rules of chess but never takes place in the entire history of chess-playing. By contrast, if it is a law of nature that energy is never created or destroyed, then it is impossible for the total energy in the Universe to change. The laws of nature govern the world like the rules of chess determine what is permitted and what is forbidden during a game of chess, in an analogy drawn by the biologist T H Huxley (1825-95).

In our science classes, we all learned some examples of what scientists currently believe (or once believed) to be laws of nature. Some of these putative laws are named after famous scientists (such as Robert Boyle and Isaac Newton). Some are generally called ‘laws’ (such as the laws of motion and gravity), while others are typically called ‘principles’ (such as Archimedes’ principle and Bernoulli’s principle), ‘rules’ (such as Born’s rule and Hund’s rule), ‘axioms’ (such as the axioms of quantum mechanics), or ‘equations’ (such as Maxwell’s equations).

Laws of nature differ from one another in many respects. Some laws concern the general structure of spacetime, while others concern some specific inhabitant of spacetime (such as the law that gold doesn’t rust). Some laws relate causes to their effects (as Coulomb’s law relates electric charges to the electric forces they cause). But other laws (such as the law of energy conservation or the spacetime symmetry principles) do not specify the effects of any particular sort of cause. Some laws involve probabilities (such as the law specifying the half-life of some radioactive isotope). And some laws are currently undiscovered – though I can’t give you an example of one of those! (By ‘laws of nature’, I will mean the genuine laws of nature that science aims to discover, not whatever scientists currently believe to be laws of nature.)

What all of the various laws have in common, despite their diversity, is that it is necessary that everything obey them. It is impossible for them to be broken. An object must obey the laws of nature. In this respect, a law of nature differs from the fact that all gold cubes are smaller than a cubic mile, the fact that all the apples currently hanging on my apple tree are ripe, and other so-called ‘accidents’. Although this fact about gold cubes is as universal, general and exceptionless as any law, it is not necessary. It could have been false. It is not inevitable or unavoidable that all gold cubes are smaller than a cubic mile. It just turns out that way.

But although all these truisms about the laws of nature sound plausible and familiar, they are also imprecise and metaphorical. The natural laws obviously do not ‘govern’ the Universe in the way that the rules of chess govern a game of chess. Chess players know the rules and so deliberately conform to them, whereas inanimate objects do not know the laws of nature and have no intentions.

For 4 to be a prime number would require more than merely a violation of the laws of nature

Furthermore, there are lots of things that we would describe appropriately (in a given conversational context) as ‘impossible’ but that do not violate the laws of nature. It is impossible for me to wish you ‘Good morning’ in Finnish because I do not speak Finnish, to borrow an example from the philosopher David Lewis (1941-2001). But my doing so would not violate a law of nature: I could learn Finnish. My car cannot accelerate from 0 to 60 mph in less than 5 seconds, but that impossibility is not the same as the kind of impossibility involved in my car accelerating from 0 to beyond the speed of light. Now we are using the laws of nature to help us understand the kind of impossibility that is supposed to distinguish the laws of nature. We have gone around in a tight circle rather than put our finger on what makes a fact qualify as a law rather than an accident.

Moreover, although accidents lack the kind of necessity that laws of nature possess, there are other facts that possess the kind of necessity that laws possess but are not laws – or, more accurately, they are not merely laws. While accidents are too weak to be laws because it would have been too easy to make them false, certain other facts are too strong to be merely laws because they are harder to break than even the laws themselves. For instance, the fact that all objects either contain some gold or do not contain any gold is a fact that has even more necessity than a law of nature does. It is still a fact even in the Star Trek universe, where the laws of nature are different (since starships routinely accelerate beyond the speed of light). For 4 to be a prime number is likewise impossible even in the Star Trek universe. It would require more than merely a violation of the laws of nature.

The laws of nature, then, fall somewhere between the accidental facts (which lack the laws’ necessity) and the facts that possess a stronger variety of necessity than the laws do. The laws are distinguished by having the variety of necessity that distinguishes the laws. But we must do better than that if we are to understand what a law of nature is.

Philosophers do not aim to discover the laws of nature. That’s a job for scientists. What philosophers aim to do is to figure out what sort of thing scientists are discovering when they discover the laws of nature. The philosopher’s aim is not to help scientists do their job. Instead, the philosopher’s aim is to better understand the job that scientists are doing. For instance, when scientists explain why something happens by appealing to a law of nature that they have discovered, what makes a law able to answer such a ‘Why?’ question? To understand scientific understanding is a job for the philosophy of science.

Of course, it can be difficult to reach this philosophical understanding, and I will ask you to bear with me as I guide you – step by step – towards understanding what a law of nature is. I hope that as a useful byproduct, you will also enjoy seeing how a philosopher utilises a few bits of logic (paging Mr Spock!) to grapple with the question ‘What is a law of nature?’ Hold on: I hope you will find the final result to be elegant and illuminating.

To begin understanding the variety of necessity that distinguishes the natural laws (which, for simplicity, I will call ‘natural necessity’), let’s unpack the laws’ necessity in terms of the fact that the laws not only are true, but also would still have been true under various hypothetical circumstances. For instance, since it is a law that no object is accelerated from rest to beyond the speed of light, this cosmic speed limit would still have been unbroken even if the Stanford Linear Accelerator had now been cranked up to full power. On the other hand, since it is merely an accident that every apple currently on my tree is ripe, this pattern would have been broken if (for instance) the weather this past spring had been much cooler.

I have just compared two ‘conditionals’ (that is, two if-then statements) that state facts about what would have happened under various circumstances that did not actually occur – that is, two ‘counterfactual’ conditionals. We often assert counterfactual conditionals, as in ‘If I had gone to the market today, then I would have bought a quart of milk.’ (That I went to the market today – the falsehood in the ‘if’ position of the conditional – is the ‘counterfactual antecedent’.) The laws, having natural necessity, would still have been true even if other things had been different, whereas an accident is less resilient under counterfactual antecedents.

An accident is invariant (that is, would still have been true) under some counterfactual antecedents. For instance, all of the apples on my tree would still have been ripe even if I had been wearing a red shirt this morning. But an accident seems to have less invariance in some respect than a law. After all, we use the laws to figure out what would happen if we were to pursue various possible courses of action – for instance, what would happen to an object’s acceleration if we doubled the object’s mass or doubled the force on the object. We can rely on the laws to tell us what would have happened under various hypothetical circumstances because the laws are invariant (that is, would have remained true) under those circumstances.

No matter what, the laws would still have held. (As Scotty says, nothing can break the laws of physics)

Of course, we can find some counterfactual antecedents under which the laws are not invariant. Obviously, the laws would not still have remained true under counterfactual antecedents with which the laws are logically inconsistent (that is, under antecedents contradicting the laws). For example, the laws would have been different if an object had been accelerated from rest to beyond the speed of light. But presumably, the laws would still have held under any counterfactual antecedent that is logically consistent with all of the laws. No matter what circumstances permitted by the laws may come about, the laws would still have held. (As Scotty says, nothing can break the laws of physics.) By contrast, for any accident, there is some hypothetical circumstance that is permitted by the laws and under which that accident would not still have held. After all, if it is an accident that p, then not-p (ie, that p is false) is a circumstance that is permitted by the laws and under which p would not still have held.

I’ll use lower-case letters for statements that make no reference to lawhood, necessity, counterfactual conditionals, and so forth – what I will call ‘sub-nomic’ claims. (For instance, p could be the claim that all emeralds are green, but p could not stand for ‘It is a law that all emeralds are green.’) We have arrived at the following proposal for distinguishing laws from accidents: m is a law if and only if m would still have been true if p had been true, for any p that is logically consistent with all the facts n (taken together) where n is a law.

Let’s step back and take a look at what this means. This proposal captures an important difference between laws and accidents in their resilience – that is, in their range of invariance under counterfactual antecedents. However, this proposal cannot tell us much. That is because the laws appear in it on both sides of the ‘if and only if’. The proposal picks out the laws by their invariance under a certain range of counterfactual antecedents p, but this range of antecedents, in turn, is picked out by the laws. (It consists of the antecedents that are logically consistent with the laws.) Therefore, this proposal fails to tell us what it is that makes m a law.

This proposal also fails to tell us what makes the laws so important. The laws’ invariance under the particular range of counterfactual antecedents that the proposal mentions makes the laws special only if there is already something special about having this particular range of invariance. But the laws are what pick out this range. So if there is no prior, independent reason why this particular range of counterfactual antecedents is special, then the laws’ invariance under these antecedents fails to make the laws special. They merely have a certain range of invariance (just as a given accident has some range of invariance).

In short, we have not yet managed to avoid the circularity that hobbled our initial thoughts about the laws’ particular brand of necessity. But we have made progress: now we can see precisely what problem we have to overcome!

There is a way to overcome this problem. Our proposal was roughly that the laws form a set of truths that would still have held under every antecedent with which the set is logically consistent. In contrast, take the set containing exactly the logical consequences of the accident that all gold cubes are smaller than a cubic mile. This set’s members are not all invariant under every antecedent that is logically consistent with this set’s members. For instance, if a very rich person had wanted to have constructed a gold cube exceeding a cubic mile, then such a cube might well have existed, and so not all gold cubes would have been smaller than a cubic mile. Yet the antecedent p that a very rich person wants such a cube constructed is logically consistent with (that is, does not contradict) all gold cubes being smaller than a cubic mile.

Let’s capture this idea by defining what it would be for a set of facts to qualify as ‘stable’. Suppose we are talking about a (non-empty) set 𝚪 (gamma) of sub-nomic truths that is ‘closed’ under logical implication. (In other words, the set contains every sub-nomic logical consequence of its members.) 𝚪 is ‘stable’ if and only if for each member m of 𝚪 and for any p that is logically consistent with 𝚪’s members, m would still have held if p had held. In short, a set of truths is ‘stable’ exactly when its members would all still have held under any counterfactual antecedent with which they are all logically consistent.

In contrast to our previous proposal, stability does not use the laws to pick out the relevant range of counterfactual antecedents. Stability avoids privileging the range of counterfactual antecedents that is logically consistent with the laws. Rather, each set of truths picks out for itself the range of counterfactual antecedents under which it must be invariant in order for it to qualify as stable. The fact that the laws form a stable set is therefore an achievement that the laws can ‘brag about’ without presupposing that there is already something special about being a law.

Had the price of steel been different, the engine might have been different. This ripple effect propagates endlessly

In contrast to the set containing all and only the laws, consider the set containing all and only the fact that all gold cubes are smaller than a cubic mile (together with its logical consequences). That set is unstable: its members are all logically consistent with some very rich person wanting a gold cube larger than a cubic mile, and yet (as we saw earlier) the set’s members are not all invariant under this counterfactual antecedent.

Let us look at another example. Take the accident g (for ‘gas’) that whenever a certain car is on a dry flat road, its acceleration is given by a certain function of how far its gas pedal is being pressed down. Had the gas pedal on a certain occasion been depressed a bit farther, then g would still have held. Can a stable set include g? Such a set must also include the fact that the car has a four-cylinder engine, since had the engine used six cylinders, g might not still have held. (Once the set includes the fact that the car has a four-cylinder engine, the counterfactual antecedent that the engine has six cylinders is logically inconsistent with the set, so the set does not have to be invariant under that antecedent in order to be stable.) But since the set includes a description of the car’s engine, its stability also requires that it include a description of the engine factory, since had that factory been different, the engine might have been different. Had the price of steel been different, the engine might have been different. And so on.

This ripple effect propagates endlessly. Take the following antecedent (which, perhaps, only a philosopher would mention!): had either g been false or there been a gold cube larger than a cubic mile. Under this antecedent, is g preserved? Not in every conversational context. This counterfactual antecedent pits g’s invariance against the invariance of the fact about gold cubes. It is not the case that g is always more resilient. Therefore, to be stable, a set that includes g must also include the fact that all gold cubes are smaller than a cubic mile (making the set logically inconsistent with the antecedent I mentioned, and so the set does not have to be invariant under that antecedent in order to be stable). A stable set that includes g must also include even a fact as remote from g as the fact about gold cubes. The only set containing g that might be stable is the set of all sub-nomic truths. (Let’s call it the ‘maximal’ set.)

Every non-maximal set of sub-nomic truths containing an accident is unstable. We have now found a way to understand what makes a truth qualify as a law rather than an accident: a law belongs to a non-maximal stable set. No set containing an accident is stable (except, perhaps, for the maximal set, considering that the range of antecedents under which it must be invariant in order to be stable does not include any false antecedents, since no falsehood is logically consistent with all of this set’s members).

We saw earlier that the sub-nomic facts that are laws should be distinguished from two other sorts of sub-nomic facts. On the one hand, accidents are easier to break than laws. Unlike the accidents, laws possess natural necessity. On the other hand, some facts are even more necessary (harder to break) than the laws, such as the fact that all objects either contain some gold or do not contain any gold. Such a fact possesses an even stronger variety of necessity than natural necessity. (Let’s call it ‘broadly logical’ necessity.) By thinking of natural laws in terms of stability, we can understand how the laws differ from both the accidents and the broadly logical necessities.

Let’s investigate whether there are any other non-maximal stable sets besides the set of laws. Consider the set of all and only the sub-nomic truths possessing broadly logical necessity. It includes the truths of mathematics and logic. This set is stable since its members would all still have held under any broadly logical possibility. For instance, 2 plus 3 would still have been equal to 5 even if there had been a gold cube larger than a cubic mile – and even if there had been a means of accelerating an object from rest to beyond the speed of light.

There is a nice little argument demonstrating that, for any two stable sets, one of them must entirely contain the other. The stable sets, however many there are, must fit one inside the other like a series of matryoshka dolls. The argument’s strategy is to consider a counterfactual antecedent like the one involving g (concerning the gas pedal) and the fact about gold cubes – namely, an antecedent pitting the invariance of the two sets against each other. Here’s how the argument goes.

First, assume that there are two stable sets, 𝚪 and 𝚺 (sigma), where neither set fits completely inside the other. In particular, suppose that t is a member of 𝚪 but not of 𝚺, and s is a member of 𝚺 but not of 𝚪. Now we can show that this assumption must be false because it leads to a contradiction. (Ready? Here we go…)

Let’s start with 𝚪. Since s is not a member of 𝚪, the counterfactual antecedent not-s is logically consistent with 𝚪, and hence so is the counterfactual antecedent (not-s or not-t). Therefore, since 𝚪 is stable, as we have assumed, every member of 𝚪 would still have been true, if (not-s or not-t) had been true. In particular, t would still have been true, if (not-s or not-t) had been true. So t and (not-s or not-t) would both have been true, if (not-s or not-t) had been true. Hence, if (not-s or not-t) had been true, then not-s would have been true; s would have been false.

Laws of nature can explain why something failed to happen by revealing that it cannot happen

Now we can make the analogous argument regarding 𝚺. Since t is not a member of 𝚺, the counterfactual antecedent not-t is logically consistent with 𝚺, and hence so is the counterfactual antecedent (not-s or not-t). Therefore, since 𝚺 is stable, as we have assumed, no member of 𝚺 would have been false, if (not-s or not-t) had been true. In particular, it is not the case that s would have been false, if (not-s or not-t) had been true. But now we have arrived at a contradiction with the result reached at the end of the previous paragraph. So we have proved that the initial assumption is impossible: there cannot be two stable sets, 𝚪 and 𝚺, where neither fits completely inside the other.

What we have just demonstrated is that the stable sets must form a nested hierarchy. There are at least three members of this hierarchy: the truths with broadly logical necessity (the smallest of the three), the set of laws (which also contains all the broadly logical necessities), and the maximal set (which contains all the sub-nomic truths). There are no stable sets larger than the set of laws but smaller than the maximal set, since any such set would have to contain accidents, but we have already seen that no set containing accidents (except for the maximal set) is stable.

We can now understand what makes the natural laws necessary and how their variety of necessity differs from broadly logical necessity. By the definition of ‘stability’, the members of a stable set would all still have held under any sub-nomic counterfactual antecedent with which they are all logically consistent. That is, a stable set’s members would all still have held under any sub-nomic counterfactual antecedent under which they could (ie, without contradiction) all still have held. In other words, a stable set’s members are collectively as resilient under sub-nomic counterfactual antecedents as they could collectively be. They are maximally resilient. That is what makes them necessary.

There is a one-to-one correspondence between non-maximal stable sets and varieties of necessity. A smaller stable set is associated with a stronger variety of necessity because the range of antecedents under which a smaller stable set’s members are invariant, in connection with that set’s stability, is wider than the range of antecedents under which a larger stable set’s members are invariant, in connection with that set’s stability. Stability associated with greater invariance corresponds to a stronger variety of necessity – that is, greater unavoidableness.

Scientists discover laws of nature by acquiring evidence that some apparent regularity is not only never violated but also could never have been violated. For instance, when every ingenious effort to create a perpetual-motion machine turned out to fail, scientists concluded that such a machine was impossible – that energy conservation is a natural law, a rule of nature’s game rather than an accident. In drawing this conclusion, scientists adopted various counterfactual conditionals, such as that, even if they had tried a different scheme, they would have failed to create a perpetual-motion machine. That it is impossible to create such a machine (because energy conservation is a law of nature) explains why scientists failed every time they tried to create one.

Laws of nature are important scientific discoveries. Their counterfactual resilience enables them to tell us about what would have happened under a wide range of hypothetical circumstances. Their necessity means that they impose limits on what is possible. Laws of nature can explain why something failed to happen by revealing that it cannot happen – that it is impossible.

We began with several vague ideas that seem implicit in scientific reasoning: that the laws of nature are important to discover, that they help us to explain why things happen, and that they are impossible to break. Now we can look back and see that we have made these vague ideas more precise and rigorous. In doing so, we found that these ideas are not only vindicated, but also deeply interconnected. We now understand better what laws of nature are and why they are able to play the roles that science calls upon them to play.