Motivation

Law and rules as code

Laws, regulations, and public policies are inherently textual. For centuries, they have been drafted in natural language, debated by legislators, interpreted by lawyers, and applied by human administrators. Today, however, the execution of these rules has fundamentally shifted. The vast majority of legal, administrative, and regulatory decisions are now carried out by software.

This transition has exposed a critical structural flaw in how we govern digital systems. There is a profound mismatch between how a law is written and how a machine operates. Furthermore, laws are deeply bound to time: they change, they have effective dates, and they often apply retroactively. Standard software, however, struggles to manage the dimension of time gracefully.

This article explores the specific friction between legal drafting and technical execution. It examines the "translation gap" that silently alters the meaning of rules, the complex challenge of applying rules across different points in time, and how a true "rules as code" approach can ensure that the law remains accurate, continuous, and faithful to its original intent.

Lost in translation

When a parliament passes a new law or an enterprise adopts a new compliance framework, that text must eventually be translated into operational reality. Today, that means updating IT systems.

This introduces a perilous translation gap. A policy expert or legal drafter writes the rule using language that accommodates nuance, exceptions, and principles. A business analyst then attempts to translate that text into a list of technical requirements. Finally, a software engineer translates those requirements into application code, perhaps Python, Java, or C#.

Code, however, cannot tolerate ambiguity. Where a legal text is open to interpretation, the software developer must make a definitive, binary choice to make the code compile and function. This translation process is not a neutral act of digitization; it is an act of interpretation.

Every time a rule is handed off from a lawyer to an analyst to a developer, fidelity is lost. The people who write the software inadvertently become the de facto arbiters of how the law is applied. Because legal and policy experts cannot read the resulting application code, they lose the ability to verify if the system actually reflects the legislation. The rule has been successfully digitized, but its exact legal meaning has been obscured.

The problem of time

The translation gap is compounded by a second, equally complex challenge: temporality.

Laws and business rules are not static. They govern time. A new tax bracket might take effect on January 1st. An environmental regulation might have a three-year phase-in period. A contract might be governed by the policies that were active on the exact date it was signed, regardless of what the current policy states.

Traditional application code is notoriously bad at handling the passage of time. Most software is designed to execute the current state of the system. To accommodate historical rules, developers are forced either to build bespoke solutions that add complexity or to rely on deeply nested if/else branches. Over years of legislative changes, these temporal logic branches become impossibly complex.

When a citizen appeals a decision made today about an event that happened three years ago, the system must evaluate the data using the rules exactly as they existed three years ago. In standard codebases, maintaining this kind of rigorous historical accuracy is incredibly difficult and highly sensitive to error. Old rules are often accidentally overwritten by new updates, destroying the temporal integrity of the system.

A shared language for rules

The concept of "Rules as Code" (RaC) emerged to solve these exact problems. The goal is to draft rules in a format that is simultaneously readable by humans and executable by machines.

However, simply writing "better application code" does not close the translation gap, nor does it solve the problem of time. True Rules as Code requires a fundamental shift in how logic is expressed. It requires a domain-specific approach that meets two strict criteria:

  • High-fidelity expression: The code must read like the rules themselves. It must be legible to domain experts (lawyers, policymakers, and compliance officers) so they can directly review and validate the logic without needing an engineering background.
  • Native temporality: The system must treat time as a fundamental dimension, not an afterthought. It must automatically resolve which version of a rule applies based on the effective date of an event, without requiring complex code branching.

Lemma for rules as code

This is the specific challenge Lemma was designed to solve. Lemma is an open-source, declarative language that acts as a bridge between textual policy and executable software.

Lemma significantly narrows the translation gap because it flows like natural language. Rules in Lemma are written in a structured, transparent syntax ("In principle X applies, unless Y, unless Z") that mirrors how legal and business documents are naturally drafted. This allows legal teams and software engineers to finally look at the exact same artifact. The rule specification is the code.

Crucially, Lemma features built-in temporal versioning. Multiple versions of a rule can coexist peacefully. You simply ask the Lemma engine to evaluate a dataset with an --effective date flag. The engine automatically routes the request to the correct historical, current, or future version of the rule. There are no tangled if/else date branches; the temporality is handled safely by the engine itself.

LemmaBase builds upon this by providing the registry and governance platform for these rules. It allows institutions to publish, version, and manage their legal logic over time. Instead of relying on a developer's memory or a fractured git history to know what a rule looked like in 2024, LemmaBase provides a queryable, continuous, and absolute record of the rules across their entire lifecycle.

Lemma

Open-source, declarative language that bridges textual policy and executable software, with built-in temporal versioning.

Read the docs

LemmaBase

Registry and governance platform to publish, version, and manage legal logic over time.

About LemmaBase

A continuous source of truth

The transition from textual law to digital execution does not have to mean a loss of fidelity. We do not have to accept a world where the meaning of a law is lost in translation, or where historical rules are accidentally erased by technical updates.

By adopting a true Rules as Code approach, organizations can eliminate the friction between legal intent and technical reality. Lemma expresses rules that both lawyers and machines understand; LemmaBase publishes and organises them while perfectly preserving the dimension of time.

The result is a system where the law remains accurate, continuous, and completely faithful to its original intent, no matter how much time passes or how complex the digital landscape becomes.