Skip to content

Install

LEN is built from its source. With Rust installed, two commands do it:

git clone https://github.com/ewiger/len && cd len
cargo install --path crates/len-cli

Then check that it runs:

len --version
len 0.1.0

There is no release on crates.io yet and no ready-made binary. Both wait for the first release.

No Rust yet?

Get it from rustup.rs. LEN needs Rust 1.80 or newer.

A first project

A project is a folder with a .len/ directory. len init makes one:

mkdir family && cd family
len init
created .len/config.toml
added .len/state/ and .len/local.toml to .gitignore

len check needs no project: it reads the files it is given. len plan and len apply work on a project, because they compare what the sources ask for with the records the project already holds.

Put a program in family.len. A file opens with the name of its module:

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
}

Check it, plan it, and apply the plan:

len check family.len
len plan family.len
len apply family.len

len check prints nothing when it finds nothing wrong. len plan lists one run and one record to create, and runs nothing. len apply shows the same plan and asks before it acts; only yes is accepted. It then runs the proof and writes the record:

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.

Plan again, and there is nothing to do:

Plan: 0 to run, nothing to write.

Where to go next