For developers · Nothing is built yet
Build the toolchain for law as a typed program.
LexTML is a typed language for the decision logic of law. The design is at version 0.2. There is no grammar, no compiler and no runtime yet. If you want to shape a language toolchain from its first commit, this is where it starts.
- Design
- version 0.2
- Grammar
- not written
- Compiler
- not started
- Licence
- Apache 2.0
The language
What a clause looks like
clause annul_after_audit
of SingleTaxPayer.annul_registration
from TaxCode art 299.11 @ 2025-04-01
duty
{
requires group within { First, Second, Third }
requires fact violation : established by AuditAct
outcome Annulled(from: d) where d = first_day_of_month_after(quarter_of(violation.date))
effects
ends SimplifiedSystemMember(payer, group) at d
starts BarredFromSimplifiedSystem(payer)
from d until end_of(4 quarters after decision.date)
choice "'is carried out by decision' is read as a duty once a violation is established" by "encoder to be named"
}from ... @ date- Every clause is bound to a legal source and to one edition of it. Legal text stays outside the program.
duty- Every decision clause states whether it is a duty or a discretion. Where the text is ambiguous, the encoder's choice is recorded.
effects- Outcomes start and end legal positions over intervals. State is derived from the record of acts. There is no mutable state.
Architecture
Three parts, none built
The language has its own front end and checker, reuses Catala's core for computed rules, and runs everything else on its own runtime.
- computed
- decided
- advisory
| Component | Language | Why |
|---|---|---|
| Front end and checker: parsing, types, assembly of open methods, conflict norms, label tracking | Rust | Sum types and exhaustive matching suit compilers. One static binary gives reproducible builds. |
| Core runtime: decisions, effects, the advisory boundary, tracing | Rust | No implementation inheritance and immutability by default. |
| Computed rules | Catala's core, emitting Rust through a new back end | Catala supports back ends as plugins without changes to its compiler. |
| Judgement calls, golden-set tooling, test authoring | Python on top of Rust bindings | The machine-learning ecosystem is in Python, and these parts are experimental by default. |
| Throwaway prototype for the first pilot | Python | The fastest way to test the design's working assumptions before a compiler exists. |
Work areas
Eleven places to start
Every area is at its beginning. Pick the one that matches what you know.
Grammar and parser
RustTurn the placeholder notation into a formal grammar with one fixed keyword set. Braces or indentation is still an open choice.
Not started
Type checker
RustUnits for money and time, kinds of result declared as upper bounds, and the assembly of a method from clauses spread across the program.
Not started
Label tracking
RustAn information-flow check. A result is never more trustworthy than what it depends on, and an advisory result needs a recorded adoption before it reaches a binding output.
Not started
Exceptions and conflicts
RustResolution in a fixed order: validity, exceptions stated by the text, conflict norms, explicit override, open conflict. Bounded detection of collisions between norms.
Not started
Core runtime
RustDecisions, typed effects over intervals, the advisory boundary and traces. Failures are typed results and are never thrown.
Not started
Catala back end
OCaml, RustA plugin back end that makes Catala's core emit Rust. Numeric results must match Catala's runtime exactly.
Not started
Registers and extractors
RustThe interface to dated values kept outside the language. An extractor returns the value, its legal source, its validity interval and the state of the register, and can replay a value as it was known at a given time.
Not started
Source resolver
OpenResolve identifiers of legal texts and their editions, one resolver per legal order. Ukraine comes first.
Not started
Judgement-call tooling
PythonBind a model to a judgement call, record the binding with every result, and measure how stable the answers are.
Not started
Test tooling
PythonTest authoring, golden sets, a record of which tests exercise which clauses, readings and exceptions, and differential runs between two editions of the law.
Not started
Prototype
PythonA throwaway prototype for the first pilot, to test the design's working assumptions before a compiler exists. It lives in its own repository and will be retired.
Not started
Open problems
Questions that code will settle
The specification holds 97 open hypotheses, each with a test and a workaround. These are among the ones that engineering decides. Confirming or refuting one is a result either way.
- H54Can a whole legal order be checked as one program at practical cost?
- H63Do whole-program checks stay fast when any clause can change a method?
- H68Can a Rust back end for Catala be written and maintained at acceptable cost?
- H69Does the runtime match Catala's numeric results exactly?
- H70Are three toolchains manageable: OCaml, Rust and Python?
- H71Does the Python prototype stay a throwaway?
- H72Does label tracking catch real mistakes, with messages that people can read?
- H74Are run-time checks and tests enough in place of static range proofs?
The runtime outside Catala's core has no formal semantics yet.
All hypothesesGround rules
How the work is run
The specification is the source of truth.
A change to the language starts as a proposal in the specification repository, with its evidence and its limitations.
Limitations are hypotheses.
Each has a test and a workaround, and they are listed in public.
One language.
There are no dialects per country or legal family, and one keyword set everywhere.
Open licences.
All code is under Apache 2.0, and the documents are under CC BY 4.0.
Code
Repositories
- lextmlThe toolchain: front end, checker, runtime, Catala back end and Python tooling.
- lextml-specThe specification, the implementation guide, the pilot plan and the hypothesis register.
- lextml-law-uaThe program of the Ukrainian legal order, starting with the tax pilot.
- lextml-prototypeThe throwaway Python prototype for the first pilot.
Join
Join as a contributor
Here for the legal and conceptual work? Go to lextml.org