Rules as Code

Right now, we build legal apps that do specific things and answer specific questions. What if you had a platform that could build the app for you? What if you could just supply the name of a law, and then ask a question using the terms defined in that law, and that was it? What if you could go from a complicated question from your client to a web application that can answer that question, in five minutes? What if implementing a new online government service took days instead of months?

Right now, written legal rules are a pain. Drafting mistakes are common, edge cases aren’t anticipated, and they tend not to integrate with one another easily. What if laws were better drafted? What if they were clearer, more consistent, and had fewer loopholes and errors? What if you could test laws for their policy effects? What if you could give something to legislative drafters that would make all that happen?

As it turns out, these things are possible. And one of them comes free if you solve for the other.

An Innovation in New Zealand

Some time ago, the Service Innovation Lab in New Zealand started looking at implementing new types of online government services in a client-centered way. They discovered that many services that a citizen requires come from different silos in government, each with its own methods of providing services online. Making those existing services cooperate was difficult because they were all built on different underlying technologies. The only realistic option for the Lab was to see if the technologies could be standardized.

The Lab did some experiments to test the viability of the idea, learned a great deal, found some problems it hadn’t anticipated, and fell on a revolutionary solution, dubbed “Rules as Code.”

Rules as Code is not a specific tool. It is not “automating legal services” as we would recognize it today. It is a methodology for creating and applying legal rules in the digital age. Some of the important features of Rules as Code are:

  • Legislation should be drafted in a natural language and in software code at the same time.
  • The encoding should be declarative - it should abstract “the rules” from any question or questions you might ask about them.
  • The platform on which the legislation is encoded should be open, accountable, transparent and standardized across government.
  • Definitions should be consistent across acts, not only within them. Each law should add to the shared dictionary of terms.

This is not an exhaustive list. Nor are the benefits hypothetical. The Lab tried it and got results. The experimental legislation was better drafted, testable for policy effects, and capable of being implemented in multiple different online tools quickly and easily. The automated services were more consistent with the policy intent of the law and more interoperable.

This set of experiments that began in New Zealand a few years ago has been spreading throughout commonwealth countries. Similar experiments have happened in New South Wales in Australia, and it has been promoted among legislative drafters in the United Kingdom. Pia Andrews, who led the original initiatives in New Zealand, was recently invited to Ottawa to discuss the topic at a Regulatory Innovation Showcase for Canadian federal public servants. Transport Canada, the federal department regulating road, rail, marine and air transportation in Canada, is working on a similar proof of concept.

Why This Matters

So, Rules as Code has momentum. Why does this matter to anyone except governments?

Imagine a legal service provider being asked by a corporate client to draft terms for a standard form contract that will be used with tens of thousands of customers. The firm’s drafters and coders work together to generate a natural language contract and an encoding of it. The difficulties in encoding reveal deficiencies in the natural language version, allowing both to be improved. The contract is tested against the client’s data about its customers, or random scenarios generated by the computer, or both. The service provider can define the effects that the client wants the contract to achieve and avoid as automated tests. The software automatically checks whether those effects still exist in the context of proposed amendments. The client receives a contract that it knows does exactly what it needs it to do.

Later, the client has a question about a complicated fact scenario under the contract. The client doesn’t call the legal service provider. Instead, through a page on the firm’s website, the client submits the terms of the contract, writes a question using those terms, and clicks a button. The website then asks the client all the relevant questions in a user-friendly way. The website drafts a memo that sets out the question that was being asked, the information that was provided, what the contract requires, and why. That memo is sent to the legal services provider for review, is amended as required and forwarded to the client.

The client then decides it wants to re-implement the contract as a smart contract. It takes just two weeks, since most of the work has already been done, because the underlying technologies of smart contracts and Rules as Code are the same.

As the law changes, staff at the legal service provider do research and write memos, but also propose changes to the firm’s Rules as Code database. When the database is updated, all of the tools provided to clients are automatically updated also. Clients that have received an answer in the past that has now changed get an automated update memo.

A “TurboTax” for Law?

Rules as Code techniques allow legal service providers to productize and capitalize on their knowledge about written legal rules. If the firm has a specialty, perhaps it generates its own encodings of the relevant statutes, allowing the firm to create the “TurboTax” of that area of law on demand.

Even in theory, Rules as Code is not a panacea, or cost-free. It works best for written rules that are relatively determinative, where the factors involved are discrete, knowable, and known by your client when the question is asked. Subjective determinations may be difficult or impossible to predict. Unusual scenarios may not be dealt with appropriately when factors like unconscionability come into play. People may need to be kept in the loop, and clients need to be made aware of the limitations.

Rules as Code also has talent requirements that most legal service providers would not now be able to meet. Taking advantage of the opportunity requires people who are willing to do different things and do things differently.

But the scope of what can be done is big and growing. The promise is real. With the push toward automation generally and the rise of smart contracts, we may be approaching a new normal where Rules as Code is the new legalese.

To Code or Not to Code

Much ink has been spilled on the question of whether lawyers should learn to code. Rules as Code might seem to revive that debate. The word “Code” is right there in the name.

The proponents of Rules as Code argue “no.” They say the diversity of perspective in the drafting phase improves the result, and you would lose that benefit if the drafter and the coder were the same person.

I’m skeptical. I think the history of expert systems in law, starting nearly 40 years ago, suggests that having the legal knowledge in one person and the programming knowledge in another person is a major source of failure. But the analogy may be imperfect. I could be wrong about that.

Here’s what I know for sure: The answer is yes, lawyers should learn to code. Or it’s no, they shouldn’t. Either way, it doesn’t matter.

In the 1970s, people might reasonably have asked whether accountants should learn to code. Computers were good at math, after all. But learning to get a computer to do complicated math in the 1970s meant learning a programming language, and that was too high a burden to expect.

Then, electronic spreadsheets became the “killer app” of personal computing. Less than 20 years later, proficiency in electronic spreadsheets is a basic competence of the accounting profession.

Electronic spreadsheets, as it happens, are a declarative programming environment for math. Using a spreadsheet is coding, but easier. No one today would argue about whether an accountant should use a computer to do math. And arguing over whether Excel is a programming tool is sophistry. Either all accountants are coders and should be, or not all accountants are coders and don’t need to be. In either case, everything is as it should be.

The Future Is Coming Fast

The difference between accounting and Rules as Code is that learning to use a spreadsheet is way easier than learning the programming languages that are best used for Rules as Code. But people are actively working on flattening the learning curve for Rules as Code, as they are for all programming tasks, and I see no obvious reason why those efforts will ultimately fail. It is a design problem, not a technological one.

My own attempt is called Blawx.com. It uses some of the same visual techniques that are regularly used to teach programming to children. I was invited to demonstrate it at the Regulatory Innovation Conference after Pia Andrews spoke. My demonstration showed how you could use the alpha version to build a new legal app to answer a question about a statute that someone else had encoded, in minutes.

The efforts to improve usability are ongoing. The tools for Rules as Code are not “there” yet, at least not any that are sufficiently affordable and open and transparent to be appropriate for use in the public sector.

When we get “there”—when the usability of Rules as Code tools approaches the usability of electronic spreadsheets —look out.

If spreadsheets are any indication, legal services will become better, faster and more varied, and demand for them will increase. In short order, the use of software for drafting, testing, and implementing Rules as Code will be a basic professional competence. Rules coding will be taught in first-year courses at law schools around the world. Legal knowledge management practices will be completely unrecognizable.

Maybe we will still have software developers in the room at the drafting phase. But the lawyers will be coders, too. Or they won’t. No one will care.

The printing press, personal computing, the web… the legal services industry has changed dramatically every time the technology used to record legal rules has changed. Rules as Code is the next iteration of that pattern. Digital is coming for the law.

About the Author

Jason Morris is a lawyer and programmer from Sherwood Park, Alberta, Canada. He operates his virtual firm Round Table Law from his home. He was an ABA Innovation Fellow for 2018/2019, where he developed software to automate legal reasoning by analogy to prior cases. Contact him on Twitter @RoundTableLaw.

Send this to a friend