LEN¶
A declarative language for reasoning about knowledge.
Model a domain as types, relations and facts, state what you claim about it, and say what each claim means in a logic or in a programming language. LEN works out what has to be proved, tested or judged, does it, and keeps every result with what it rested on. When something changes, it shows which conclusions no longer stand.
git clone https://github.com/ewiger/len && cd len
cargo install --path crates/len-cli
LEN is at 0.1.0 and is being built. What works today says how far each part reaches.
module family
type Person
const Alice, Bob, Carol: Person
rel parent(x: Person, y: Person)
rel ancestor(x: Person, y: Person)
fact parent(Alice, Bob)
fact parent(Bob, Carol)
claim AliceAncestorOfCarol {
ancestor(Alice, Carol)
}
context Family {
logic: horn
use Person, parent, ancestor
facts: parent(*, *)
}
define ancestor in Family {
ancestor(x, y) :- parent(x, y).
ancestor(x, z) :- parent(x, y), ancestor(y, z).
}
formal AliceAncestorOfCarol in Family {
ancestor(Alice, Carol).
}
goal AncestryOfCarol {
prove AliceAncestorOfCarol in Family
conclude AliceAncestorOfCarol in Family
}
len plan family.len
len will perform the following actions on target local (/home/ada/family):
Run:
> run prove AliceAncestorOfCarol in Family backend horn
= 0 results current
Write:
+ create len/claims/family/AliceAncestorOfCarol.record.yaml record claim/family.AliceAncestorOfCarol
known after apply: prove AliceAncestorOfCarol in Family
= 0 resources unchanged
Plan: 1 to run, 1 to create.
len apply family.len
Ran:
> prove AliceAncestorOfCarol in Family backend horn satisfied: proved in 2 clause steps
derivation sha256:0f63251c40dd6ed601695fe454eda659ef6b89fb61eb9608584c3912fdd0fcb7
Wrote:
created len/claims/family/AliceAncestorOfCarol.record.yaml record claim/family.AliceAncestorOfCarol
Apply: 1 run, 1 written, 0 skipped, 0 failed.
# A record written by `len apply`. The `len` key is its stamp: an edit to
# anything below it is detected by the next `len plan`.
len:
resource: claim/family.AliceAncestorOfCarol
digest: sha256:ed99f8ec5334fef6ffa5fa3e83264ead689dfcf9f6c4d9daed3d701d07ff21a6
inputs: sha256:8e5800bb9275df355c792e58b5f96c481aa4a45161d276604519fa5217239df6
applied: 2026-11-30T09:33:53Z
claim: AliceAncestorOfCarol
module: family
atom: ancestor(Alice, Carol)
results:
- obligation: prove AliceAncestorOfCarol in Family
context: Family
backend: horn
version: 0.1.0
inputs: sha256:7796d6ac120798ba056afe91c36cf4aa24c75fcd96c60c6a1bc3cf026a39cdf8
outcome: satisfied
artifact: sha256:0f63251c40dd6ed601695fe454eda659ef6b89fb61eb9608584c3912fdd0fcb7
kind: derivation
summary: proved in 2 clause steps
conclusions:
- context: Family
value: 'true'
from: prove AliceAncestorOfCarol in Family
artifact: sha256:0f63251c40dd6ed601695fe454eda659ef6b89fb61eb9608584c3912fdd0fcb7
Remove fact parent(Bob, Carol) and plan again. The proof rested on
that fact, so it is listed to run once more.
Run:
> run prove AliceAncestorOfCarol in Family backend horn
= 0 results current
Write:
~ update len/claims/family/AliceAncestorOfCarol.record.yaml record claim/family.AliceAncestorOfCarol
known after apply: prove AliceAncestorOfCarol in Family
= 0 resources unchanged
Plan: 1 to run, 1 to update.
One claim, end to end¶
A claim goes through the same stages every time. Nothing is run until a goal asks for it, and nothing is written until a plan has listed it.
Stated
- type
- const
- rel
- fact
- claim
What exists, what is asserted, and what is only put forward.
Given meaning
- context
- define
- formal
- assume
A context names a logic, its truth values and its premises.
Wanted
- goal
- prove
- conclude
Work that is desired and has not happened.
Run
- len plan
- len apply
The plan lists the runs with their backends. The apply runs them.
Recorded
- record
- stamp
The outcome, the artifact and a digest of every input.
Stale. When a fact, a definition or a context changes, the stamp of a record no longer matches, and the next plan lists the run again.
A claim is not a fact¶
A fact is taken as given. A claim is open until work settles it, and a
statement of what the claim means is not evidence for it.
Truth belongs to the context¶
A result is about one context. A proof in a Horn context with its facts is not a proof in first-order logic, and LEN never treats it as one.
A result says what it rested on¶
Every record carries the obligation, the backend, the artifact and a digest of its inputs. An edit to a record is detected by the next plan.
Where the ideas come from¶
LEN brings together three practices that are usually kept apart: relational modelling of a domain, formal verification by proof, and verification of software by design and by test. It borrows from four languages to do it.
- Prolog and Datalog A domain is relations and facts. A definition in Horn clauses is already a program, and running it to a fixed point is a proof.
- Terraform
You declare what is wanted.
planshows what would be done,applydoes it, and what was recorded tells the next plan what has changed. - Lean A claim can be stated as a type, and a term the checker accepts is its proof.
- Rust A strict checker that reports precisely, before anything runs. LEN is also written in Rust.
LEN is developed together with HyperMarkDown, the format of the knowledge base it maintains, and HQL, the query language that reads it.
What works today¶
LEN is young, and this site says so in each place. Built means it runs in the current source. In part means some of it does. Design means it is specified, or being specified, and not built.
- The ontology level
type,const,relwith its forms,factandclaim, checked bylen check. built - Modules
module,importandfrom, module roots, visibility and cycles, for.lenfiles. built - Contexts and meaning
context,define,formalandassumeare parsed and name-checked. Only Horn bodies are read. in part - Goals
goalandneedsare checked.proveandconcludehave behaviour; the other verbs are reserved. in part - Plan and apply
For
provein a Horn context, andconcludein a two-valued one. in part - Records and stale results One record for each claim, with its stamp. A changed input lists the run again. in part
- First-order logic
A frontend for
folcontexts, and a prover behind it. design - Evidence and four truth values
evidence,justify, and conclusions that aretrue,false,bothorneither. design - Programs as results A context in a programming language, where a passing test is evidence for a claim. design
The full table lists every stage and every reserved word.
How LEN compares¶
| What it is | What a statement can be | Evidence that conflicts or is missing | What a result keeps | |
|---|---|---|---|---|
| LEN | Language for claims and the work that settles them | A truth value of its context: two in a logic, four over evidence (design) | both and neither are truth values (design) |
Obligation, context, backend, artifact and a digest of inputs |
| Lean | Proof assistant and programming language | A type, established by a term the kernel checks | Outside the language | The checked term |
| Datalog | Logic programming over facts and rules | Derived, or not derived | Outside the language | The derived facts |
| OWL | Ontology language of the semantic web | Entailed, or not entailed, under an open world | An inconsistent ontology entails everything | What a reasoner inferred |
| Unit tests | Code that checks code | Passed, or failed | Left to the reader of the report | A report of one run |
| HQL | Typed expression and query language | It reads results; it does not reason | Not its subject | Reads the records LEN writes (design) |
LEN and HQL work on the same knowledge base. HQL reads it. LEN produces and maintains what HQL reads.
The book¶
- 1 The language The constructs: what exists, what it means, what is wanted. A context is a logic or a programming language, and one claim can be stated in both. in part
- 2 Verification by design Requirements from software, established by a proof and by a program with its tests. The example is an order placed once, by an idempotency key. design
- 3 Advanced reasoning LEN in a knowledge base: HyperMarkdown vaults, HQL, reasoners and judges as extensions, and the life of a result. design
One section is written so far: A first ontology.
Read the examples¶
The repository keeps a corpus of examples, and the tests run every one of them. An example that must be rejected carries the diagnostic it expects.
git clone https://github.com/ewiger/len && cd len
cargo build
target/debug/len check examples/formal/contexts.len
Community¶
Questions, bugs and proposals go to GitHub issues. LEN is a sibling of HQL and HyperMarkDown.