Switch to dark mode

A declarative language for business rules

Lemma is a pure, declarative and open source programming language for business rules, that is easy to read for non-technical stakeholders. Rules are written in Specs that humans can read and systems can evaluate precisely and deterministically. Lemma validates Rules before they can be evaluated. Invalid Specs are rejected at planning time; after that, each Rule returns a value or Veto, and optionally an explanation when you ask for one (--explain / explain: true).

spec pricing 2026-01-01
"""
Applies a tiered discount and VAT to the base price, 
effective from 2026-01-01.
"""

data base_price: 100
data is_member:  false
data quantity:   number

rule discount: 0%
  unless quantity >= 10  then 10%
  unless quantity >= 50  then 15%
  unless is_member       then 20%

rule discount_amount: base_price * discount
rule discounted_price: base_price - discount_amount

rule vat: discounted_price * 21%
rule total: discounted_price + vat

Get started

If you have Cargo installed, you can run:

cargo install lemma

If you are using npm:

npm install -g lemma

Precompiled binaries for Linux, macOS, and Windows are included in the npm package automatically. Docker images are also available. See Installation for all options.

Writing your first Spec

Write a .lemma file and run it. The Learn guide walks you through everything from your first Spec to composing Rules across time and registries. You'll be productive in minutes.

Documentation

  • Learn: guided path from first spec to composing specs
  • Reference: operators, types, syntax, CLI, registry, test coverage, benchmarks
  • Tools & SDKs: Rust, Elixir, JavaScript/TypeScript, and more
  • Community: contributing and publishing specs
  • LLMs.txt: authoring Lemma from business logic