Is Law Code?

According to Wikipedia, source code is:

“any collection of computer instructions (possibly with comments) written using some human-readable computer language, usually as text.”

Some people consider law to be the “source code” (or sometimes, the “operating system”) of a democracy. Source code is a good metaphor for law, but not a perfect one.

What Kind of Code is Law?

Sure, law is code. Obviously. But what kind of code is law?

Two plus two will always equal four. That is mathematical code — the kind of thing you can build software around. Software code is, essentially, just math and logic. A set of inflexible rules that tell machines what to do.

Ancient Greek sculptors believed they could sculpt a perfectly-proportioned male figure. Around 440 BCE, Polykleitos did it:

The Doryphoros, or Canon, is the embodiment of the Greeks’ concept of perfect male form, cast in bronze. But later Greek sculptors deviated from the perfection as outlined in the Canon (also a written treatise), treating it as a set of guidelines rather than hard-and-fast rules. They realized, I think, that “imperfections” are just as much a part of beauty as the canonical form. The resulting sculptures are, at least to my untrained eye, far more compelling. Like one of my favorite ancient sculptures, Hermes and the Infant Dionysus:


The idea of code as guidelines rather than strict rules is probably best explained by a pirate:

So if law is code, is it more like mathematical instructions, or more like what you call guidelines than actual rules (like the pirate code), or is it more like the rhyme and meter of poetry or the Canon? That is, could you plug a legal problem into a sufficiently-powerful computer running sufficiently-sophisticated software and get The Answer to that problem, or are legal problems more nuanced?

I think the answer should be obvious. Law is not math. Well, most law is not math, anyway. Even if some law can be accurately reduced to mathematical calculations, law as a whole is nothing like math.

2 + 2 = $150 Plus Attorney Fees

In law, two plus two sometimes equals four, but sometimes it is closer to 4.03, or $150 plus attorney fees, or even -5×103. It all depends on the size and shape of each two, on whether the first two used cocaine within the last 5 years, and on whether the second two told the truth when asked earlier in the deposition whether it was a prime number.

First, the law rarely means exactly what it says. If it did, we would not need courts. To every statutory provision are attached a long list of “buts” — some in the statute itself, some that have been clarified by various courts, and some not yet discovered.

Second, the facts are never entirely clear. In order to come up with correct outcomes, we need to know all the pertinent facts. That is, we have to know all the facts relevant to a particular provision of law and all the facts relevant to all of the “buts” that go with that particular provision of law. We also need to know all the facts relevant to a lot of other stuff, like related policies, the personalities of the parties involved, political realities, and more (so much more). We even have to have a strategy for the things that might matter, but that we don’t know about, yet.

This is why lawyers always answer “it depends” when asked a legal question. Because it does. Interpretations of law depend on a near-infinite string of variables‚ many of which are unknown. And, of course, there is rarely one Answer to a legal problem.

So sure, law is code. But not the kind of code that can be easily reduced to software.

Machines that Think Like Lawyers

Analyzing legal problems requires someone who (or something that) can integrate all those known and unknown variables into a cohesive legal analysis. It is hard to imagine how an algorithm could do this unless it was so sophisticated as to be indistinguishable from an intelligent mind trained in law.

Given Moore’s Law, it is not hard to imagine computers capable of this kind of sophisticated legal reasoning. (Maybe they will even be able to write poetry.) But as I have said before, I don’t think we should worry about it, because when that happens, none of us will have jobs:

It looks like you’ve got at least 4 or 5 years to find another job, but probably not much more than 15 or 20.

Featured image: “Modern cyber woman with matrix eye concept” from Shutterstock.


  1. I’ve always analogized contract drafting (a subset of law) to a source code draft — The breakdown in the metaphor is that the only debugger we drafters have is in a court of law some years later. (oops. missed that contingency…) If only we had a good contract debugger we could compile at the time we write the damned things…

    • Avatar Jonathan Kleiman says:

      A huge aspect of contract drafting is contract negotiating. I’d like to see two computers negotiate and come back with a deal. It would be like how real estate seems to work.

  2. Avatar Matt James says:

    We used to have the theory that the law was code. Natural law jurisprudence just a few centuries back believed the law to be a moral science, in which laws could be uncovered with reason. Of course, that kind of thinking got pitched out with everything modernist or structuralist in the middle of the last century.

    Chess is unique among games in that there is no element of luck or randomness. Jeopardy is the same way: there is a right answer to every question. The law is different. There are elements of luck and randomness in the law. There are also elements of psychology as the decision makers in the law are human beings. It is because the law is NOT a code that means, in my mind, that the law will be one of the last professions to be replaced by computer overlords.

    However, even if and when computers are capable of such a thing, remember the “Law of Microsoft”: technology must be released in small bits to maximize profits. Adding this into the mix would at least double the time frame.

  3. Those interested in whether Law can exist as something other than a set of rules or norms might be interested in Kenneth Culp Davis book “Discretionary Justice” and Lloyd Fallers book “Law Without Precedent”. When I was teaching and trying to do some research and writing in the area of AI and Law I wrote several articles centering around the idea of a Simple Law Machine. They can be found on line by searching my name in Google Scholar.

  4. Avatar Jonathan Kleiman says:

    Compuers remove the crucial aspect of the opportunity to take our grievances to rational, subjective decision makers

  5. Avatar Gwynne says:

    No Lessig references yet…interesting….

  6. Avatar Larry Port says:

    If law was code then there would be no need for judges or a court system. Code is completely deterministic and will execute the same way every time given the same input.

Leave a Reply