Not a developer? The initiative, the legal questions and the community of scientists and legal experts are at lextml.org
LexTMLdev

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"
}
Placeholder notation from the specification. The grammar is not written yet, and the Ukrainian provision in this example has not been confirmed against the official text.
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.

Legal texts, referenced by identifier and edition
Registers of dated values and recorded acts, read through extractors
LexTML program
Front end and checker (Rust)
Computed rulesCatala core, emitting Rust through a new back end
Everything elseCore runtime (Rust)
Results, each with its kind, status labels and a trace
  • computed
  • decided
  • advisory
Python tooling on Rust bindings: judgement calls, golden sets, test authoring
ComponentLanguageWhy
Front end and checker: parsing, types, assembly of open methods, conflict norms, label trackingRustSum types and exhaustive matching suit compilers. One static binary gives reproducible builds.
Core runtime: decisions, effects, the advisory boundary, tracingRustNo implementation inheritance and immutability by default.
Computed rulesCatala's core, emitting Rust through a new back endCatala supports back ends as plugins without changes to its compiler.
Judgement calls, golden-set tooling, test authoringPython on top of Rust bindingsThe machine-learning ecosystem is in Python, and these parts are experimental by default.
Throwaway prototype for the first pilotPythonThe 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

    Rust

    Turn the placeholder notation into a formal grammar with one fixed keyword set. Braces or indentation is still an open choice.

    Not started

  • Type checker

    Rust

    Units 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

    Rust

    An 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

    Rust

    Resolution 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

    Rust

    Decisions, typed effects over intervals, the advisory boundary and traces. Failures are typed results and are never thrown.

    Not started

  • Catala back end

    OCaml, Rust

    A plugin back end that makes Catala's core emit Rust. Numeric results must match Catala's runtime exactly.

    Not started

  • Registers and extractors

    Rust

    The 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

    Open

    Resolve identifiers of legal texts and their editions, one resolver per legal order. Ukraine comes first.

    Not started

  • Judgement-call tooling

    Python

    Bind a model to a judgement call, record the binding with every result, and measure how stable the answers are.

    Not started

  • Test tooling

    Python

    Test 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

    Python

    A 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 hypotheses

Ground 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.

Join

Join as a contributor

Take a work area

Work areas that interest me
Languages I work in

Developer mailing list

Updates when a work area opens or a first version of a component is published.

Here for the legal and conceptual work? Go to lextml.org