Most ontologies are described, not proved: OWL and SHACL tell you what a reasoner believes, but they do not hand you a certificate that you can check independently. This article builds a different foundation on lean-elpi, a native Lean 4 implementation of the ELPI dialect of λProlog: write the ontology and its rules as a higher-order logic program, and let the Lean kernel check every derived fact.

1. Why verifiable ontologies

A conventional ontology stack has three layers: a schema (OWL classes and properties), constraints (SHACL shapes), and rules (SWRL, Datalog, N3). Each layer has its own semantics, and the reasoner that glues them together is a large trusted program. When it says alice :Ancestor carol, you trust the engine.

A verifiable ontology changes the contract. Every inferred statement ships with a proof term, and a small kernel is the only thing you must trust. The reasoner can be arbitrarily clever, heuristic or buggy, because a wrong answer simply fails to check.

lean-elpi supplies all three ingredients inside one Lean 4 project:

  • An ELPI engine written in Lean. Typed clauses, pi and => goals, higher-order pattern unification, modes, constraints and CHR. No OCaml, no foreign process: it is a Lean library, a command-line tool, and a set of Lean commands and tactics.

  • Shared types with Lean. Lean inductives cross into ELPI with deriving Elpi, ELPI data types become Lean inductives with elpi_data, and Lean functions become ELPI predicates with elpi_extern.

  • An LF layer for certified search. A signature written in the Edinburgh Logical Framework records a proof term for every answer, exports to Lean inductives, and turns the answer into a theorem that the kernel accepts or rejects.

The central idea is proof-carrying inference: the search engine proposes, and the Lean kernel disposes.

A note on provenance: the lean-elpi syntax and commands in this article come from the project’s README and its online book (release 0.3.3). I couldn't install the Lean toolchain in my sandbox, so I haven't run the ontology examples. Where I give an expected result, treat it as what the documentation leads you to expect and check it against your build.

2. Lean 4 as the ontology host

Lean 4 gives an ontology three things OWL lacks: a type for every entity, a first-class notion of proof, and a kernel that checks it. The mapping from OWL vocabulary is direct:

  • Class becomes an Entity → Prop predicate, or a structure or subtype. Subclassing is then a theorem, not a convention.

  • Individual becomes a constructor or constant. Distinctness comes free from inductive.

  • Object property becomes a relation Entity → Entity → Prop. Property axioms become statements you can prove.

  • Data property becomes a function Entity → Value: total, computable, checkable by decide.

  • Axiom (for example TransitiveProperty) becomes a hypothesis or theorem about a relation, so a violation is a type error.

  • Rule (SWRL or Datalog) becomes a ∀-implication or an inductive family, and a derivation is a proof term.

Here is a minimal family ontology in Lean 4:

inductive Person | alice | bob | carol | dave
open Person

-- Asserted facts (the ABox) as a relation
inductive ParentOf : Person → Person → Prop
  | ab : ParentOf alice bob
  | bc : ParentOf bob carol

-- A rule (the TBox) as an inductive family: the least relation closed under the rules
inductive Ancestor : Person → Person → Prop
  | base {x y : Person}   : ParentOf x y → Ancestor x y
  | step {x y z : Person} : ParentOf x y → Ancestor y z → Ancestor x z

-- A derived fact, with its proof
theorem alice_anc_carol : Ancestor alice carol :=
  .step .ab (.base .bc)

Two design choices matter here.

Classes as predicates or as types. Predicates over a single Entity type keep multiple classification and class unions easy, which matches OWL’s open style. Structures and subtypes give stronger typing and make a mistaken assertion unrepresentable. A practical ontology usually uses predicates for classes and structures for reified n-ary relations.

Closed versus open world. Lean is constructive: a statement is true if you hold a proof, and ¬P needs its own proof. This is neither OWL’s open-world assumption nor Datalog’s closed-world negation as failure. Absence of a proof means “not derived”, and you choose per predicate whether to add a closure axiom (for example, ParentOf is complete) to license negative conclusions.

Property characteristics as definitions

OWL’s property axioms are one-line definitions in higher-order logic, quantifying over the relation itself:

variable {α β : Type}

def Transitive' (R : α → α → Prop) : Prop := ∀ {a b c}, R a b → R b c → R a c
def Symmetric'  (R : α → α → Prop) : Prop := ∀ {a b}, R a b → R b a
def Functional  (R : α → β → Prop) : Prop := ∀ {a b c}, R a b → R a c → b = c
def InverseOf   (R : α → β → Prop) (S : β → α → Prop) : Prop :=
  ∀ {a b}, R a b ↔ S b a
def Domain (R : α → β → Prop) (C : α → Prop) : Prop := ∀ {a b}, R a b → C a
def Range  (R : α → β → Prop) (C : β → Prop) : Prop := ∀ {a b}, R a b → C b

This is the key point for the rest of the article. Transitive' takes a relation as an argument: that is second-order quantification, impossible in plain first-order Datalog and awkward in OWL DL. Lean treats it as ordinary. Rules about properties (”if R is transitive and R a b and R b c, then R a c“) are then theorems that apply to any relation carrying the characteristic, instead of being re-stated per predicate.

3. ELPI deep dive I: λProlog and higher-order logic

ELPI (Embeddable λProlog Interpreter) is a dialect of λProlog designed by Enrico Tassi to be embedded inside other systems; its best-known host is Coq through Coq-Elpi. λProlog extends Prolog from Horn clauses over first-order terms to higher-order hereditary Harrop formulas over simply typed λ-terms. lean-elpi targets the ELPI 1.18 dialect and compares its answers with the real ELPI on a shared test corpus. Four extensions do the work:

  • λ-terms as data. x\ body is a term, not a program, so terms may contain binders. x\ f x x is a function from x to f x x.

  • Universal goals. pi x\ G proves G for a fresh, opaque x (an eigenvariable).

  • Hypothetical goals. H => G proves G with the clause H available only inside G.

  • Higher-order unification. The equation F x = app x x solves with F := y\ app y y, so unknowns can stand for functions and relations.

Binders without bookkeeping: HOAS

In higher-order abstract syntax (HOAS), object-language binders are represented by meta-language λ. Variable capture, α-equivalence and substitution are inherited from the host, so you never write them. The classic demonstration, and the first example on the lean-elpi home page, is type inference for the simply typed λ-calculus:

kind tm type.   kind ty type.
type app tm -> tm -> tm.     type lam (tm -> tm) -> tm.
type arr ty -> ty -> ty.     type nat ty.

pred of i:tm, o:ty.
of (app M N) B :- of M (arr A B), of N A.
of (lam F) (arr A B) :- pi x\ of x A => of (F x) B.

Read the last clause aloud: to type lam F, take a fresh x, assume x : A, and check the body F x. The assumption is scoped, so it vanishes on exit. There is no environment data structure and no capture-avoiding substitution.

Higher-order unification and the pattern fragment

Full higher-order unification is undecidable and has no most general unifiers. Miller’s pattern fragment (Lλ) restricts flexible terms F x1 … xn so that the xi are distinct bound variables. Within it, unification is decidable and gives a unique most general solution. lean-elpi keeps unification inside this fragment by scoping unification variables with de Bruijn levels, which is one of the engine’s central design decisions.

For an ontology this is the mechanism that makes rule schemata over properties work. A goal such as holds R a c, where R is an unknown relation, is an ordinary flexible-head query rather than an escape into meta-programming.

Types, modes and cut

ELPI programs declare types with kind and type, and modes with pred. A mode (i: input, o: output) says which arguments are matched and which are built, so it documents intent and lets the checker catch mistakes before anything runs. The #mode and #total directives of the LF layer (section 6) strengthen this idea into checked claims. ELPI keeps Prolog’s cut ! for pruning search.

Constraints and CHR

ELPI also embeds Constraint Handling Rules (CHR). A goal that cannot proceed yet, such as an unresolved unification variable, can be suspended and resumed when other facts constrain it. lean-elpi implements delayed goals and CHR as part of its engine. For ontologies this gives a principled hook for deferred checks, such as cardinality or disjointness constraints that only make sense once enough of the ABox is known.

Why this beats Datalog for ontology rules

  • Rules about relations. transitive R is a fact about R, and one rule uses it for every transitive relation. Datalog needs a copy of the rule per predicate.

  • Binders in class expressions. OWL’s ∃R.C is the λ-term x\ ∃y\ R x y ∧ C y. In HOAS this is native.

  • Scoped assumptions. H => G is a clean way to ask “what follows if this fact were added?” without mutating the knowledge base.

  • Proof-relevant search. Because search is backward chaining, the derivation tree of a successful goal is already the skeleton of a proof.

4. lean-elpi deep dive II: the engine and its Lean integration

Coq-Elpi runs ELPI as a guest inside Coq. lean-elpi makes a different choice: it is a clean-room implementation of ELPI written in Lean 4, so the logic program and the proof assistant share one process, one runtime and one type system.

How the engine is built

The design follows five stages. A source file (an ELPI program or an #lf signature) goes through a front end that parses and type-checks it. An explicit abstract machine over a persistent store runs it. A set of solvers handles delayed goals, CHR, native handlers and unification hooks. The Lean layer on top provides reflection, tactics, commands and the kernel connection.

Two decisions matter for ontology work. First, the machine’s state lives in persistent data structures, so backtracking is simply keeping an older version of the state. Second, unification variables are scoped by de Bruijn levels, which keeps unification inside the decidable pattern fragment from section 3.

Five ways to run it

  • Standalone. The lean-elpi executable is a λProlog interpreter and REPL (lean-elpi program.elpi -test).

  • As a library. Program.load compiles a source string and solve yields a lazy stream of solutions, from ordinary Lean code that does not need MetaM.

  • Inside Lean. elpi_program, #elpi, elpi_tactic and elpi_command embed programs, queries, tactics and commands.

  • From Python, Node.js and Rust. One native library serves three bindings: load a program once, extend it, and query it many times.

  • The LF layer. lf_signature and lf_certify turn proof search into kernel-checked theorems (section 6).

A first program inside Lean

Programs are declared, extended and queried with three commands. A type error in the ELPI source is reported as a Lean error at that position, because programs are compiled when declared:

import Elpi
open Elpi.Cmd

elpi_program family
elpi_accumulate family lp%{
  kind person type.
  type ann, bob person.
  pred parent o:person, o:person.
  parent ann bob.
}%

#elpi family lp%{ parent ann X }%

The same program is available from Python without installing Lean (the package ships the Lean runtime inside a shared library):

from leanelpi import Program

p = Program("pred n o:int.\nn 1.\nn 2.")
[s["X"] for s in p.solve("n X")]     # ['1', '2']

Lean terms inside λProlog

Lean expressions are reflected as higher-order ELPI terms (lam, app, const, sort, lit), with binders handled by the logic. You rarely write these by hand: the quotation {{ … }} elaborates ordinary Lean syntax into such a term, and lp:{{ X }} splices an ELPI variable back in. With accumulate lean. a program also gets builtins such as lean.infer and lean.add_decl, which run in MetaM and see your environment.

This is the binder translation that a bridge would otherwise have to build and maintain. Here it is part of the engine, and both sides see the same environment.

Sharing types and functions

Ontology data usually already lives in Lean types. Three declarations connect it to ELPI without glue code:

  • deriving Elpi on a Lean inductive generates the matching ELPI kind and type declarations, plus conversions in both directions. Parametric and recursive types work.

  • elpi_data lp%{ … }% goes the other way: write the data type in ELPI and get a Lean inductive, with deriving Elpi included. Constructors with binders, such as lam, are rejected, because a Lean inductive cannot contain that function type. Use term or the LF layer for binders.

  • elpi_extern f turns a typed Lean function into an ELPI predicate. A total function gives one solution, elpi_extern partial f gives at most one, and elpi_extern many f as "name" gives one solution per element of the returned list.

The trust boundary

Whatever ELPI produces is a candidate. A tactic written in λProlog returns goals and terms that Lean checks as usual, so a wrong tactic cannot prove a false theorem. The same holds for commands: lean.add_decl and lean.add_inductive send their results through the kernel. Consequently:

  • The ELPI interpreter, the unifier and your rules are outside the trusted base. A bug yields a failed check, never a false theorem.

  • The trusted base is Lean’s kernel plus the axioms you explicitly declare.

  • Rules can be heuristic and fast, because soundness is no longer their job.

Maturity, in the project’s own numbers

The README reports that all 24 of ELPI’s own performance programs run on release 0.3.3. Compared with ELPI 1.18, lean-elpi is about 2.4 times slower by geometric mean on the programs where ELPI takes more than 0.1 s, and 6.2 times slower at worst. It passes 52 of the 114 applicable upstream tests and 38 of 40 corpus programs. Memory use is 50 to 200 MB, except map on long lists, which reached 1.4 GB. Read this as a young engine that is already useful for modest rule bases and certification, not as a drop-in replacement for ELPI on heavy workloads.

5. Rules and property characteristics in ELPI

The rule engine has one design principle: relations are data. A relation name such as ancestor is an ordinary ELPI constant, so “ancestor is transitive” is a plain fact, and one generic rule serves every transitive relation. The engine returns an explicit proof object alongside each answer. This first version runs as an ordinary lean-elpi program; section 6 replaces the hand-made proof objects with LF certificates that the kernel checks.

import Elpi
open Elpi.Cmd

elpi_program onto
elpi_accumulate onto lp%{
  kind ind, rel, cls, pf type.
  type alice, bob, carol, dave ind.
  type parentOf, hasParent, ancestor, spouse rel.
  type person, parent-role cls.

  % Proof objects. Constructors carry the relations and midpoints they used.
  type ax    string -> pf.             % a named fact
  type sub   rel -> pf -> pf.          % sub-property step
  type inv   rel -> pf -> pf.          % inverse-property step
  type sym   pf -> pf.                 % symmetry step
  type trans ind -> pf -> pf -> pf.    % transitivity step (midpoint)
  type dom   rel -> pf -> pf.          % domain typing step

  % ABox: asserted facts
  pred fact o:rel, o:ind, o:ind, o:string.
  fact parentOf alice bob "ab".
  fact parentOf bob carol "bc".

  % TBox: characteristics of relations, stated as data
  pred transitive i:rel.
  transitive ancestor.
  pred symmetric i:rel.
  symmetric spouse.
  pred inverse-of o:rel, i:rel.
  inverse-of parentOf hasParent.
  pred subprop o:rel, i:rel.
  subprop parentOf ancestor.
  pred domain o:rel, i:cls.
  domain parentOf parent-role.
}%

Now the generic rules. They never mention ancestor or parentOf:

elpi_accumulate onto lp%{
  % One step: asserted, symmetric, inverse, or via a sub-property
  pred step i:rel, i:ind, o:ind, o:pf.
  step R A B (ax N)         :- fact R A B N.
  step R A B (sym (ax N))   :- symmetric R, fact R B A N.
  step R A B (inv S (ax N)) :- inverse-of S R, fact S B A N.
  step R A B (sub S P)      :- subprop S R, step S A B P.

  % Reachability: right-recursive, so the search is guarded by a real step
  pred holds i:rel, i:ind, i:ind, o:pf.
  holds R A B P             :- step R A B P.
  holds R A C (trans B P Q) :- transitive R, step R A B P, holds R B C Q.

  % Domain typing: anything with an outgoing R-edge is in the domain class
  pred instance i:cls, i:ind, o:pf.
  instance C A (dom R P)    :- domain R C, step R A _ P.
}%

#elpi onto lp%{ holds ancestor alice carol P }%

The query should return P = trans bob (sub parentOf (ax "ab")) (sub parentOf (ax "bc")). The engine found the path, and the proof object records which rule justified each edge and which midpoint it used.

How each characteristic maps

  • SubPropertyOf is the step … (sub S P) clause. Lean-side obligation: ∀ a b, S a b → R a b.

  • Transitive is the holds … (trans B P Q) clause. Obligation: Transitive' R.

  • Symmetric is the step … (sym P) clause. Obligation: Symmetric' R.

  • InverseOf is the step … (inv S P) clause. Obligation: InverseOf S R.

  • Domain is the instance … (dom R P) clause. Obligation: Domain R C.

  • Functional derives B = C from R A B and R A C. Obligation: Functional R.

Declaring transitive ancestor here is only a claim. In the plain program nothing proves it. That gap is exactly what the LF layer closes.

Design notes

  • Termination. Plain backward chaining does not table, so holds terminates only on acyclic data. For cyclic data, thread a visited list through holds, or bound the depth. Left-recursive variants such as holds R A C :- holds R A B, holds R B C loop immediately, which is why the transitive rule above recurses on the right and starts with a step.

  • Modes. Input arguments are matched, not unified, so a call that leaves an input unbound fails fast instead of silently enumerating.

  • Negation. ELPI supports negation as failure, but it is not a proof. Keep it for search control and require a Lean-checked closure axiom before reading any failure as a theorem.

  • Constraints as checks. Disjointness and cardinality are better modeled as obligations that must be proved or refuted than as rules that merely fail.

6. Certified ontologies with the LF layer

Section 5 produced proof objects by hand. lean-elpi’s LF layer produces them for you and sends them to the kernel. In the Edinburgh Logical Framework a judgment such as “alice is an ancestor of carol“ is a type, each inference rule is a constant, and a derivation is a term. A derivation found by search is therefore an object that can be checked.

The ontology as an LF signature

Opt in with #lf as the first line. Declarations are c : A., the arrow is A -> B, and B <- A reads the same thing backwards. Uppercase variables are implicitly bound and their types are reconstructed. Save this as onto.elpi:

#lf
#strategy iddfs

person   : type.
rel      : type.
alice    : person.
bob      : person.
carol    : person.
parentOf : rel.
ancestor : rel.
spouse   : rel.

holds : rel -> person -> person -> type.
ab : holds parentOf alice bob.
bc : holds parentOf bob carol.

% Characteristics of relations, stated as proof-carrying facts
sub        : rel -> rel -> type.
transitive : rel -> type.
symmetric  : rel -> type.
parent_in_ancestor : sub parentOf ancestor.
ancestor_trans     : transitive ancestor.
spouse_sym         : symmetric spouse.

% Generic rules: they mention no particular relation
r_sub   : holds R A B <- sub S R <- holds S A B.
r_trans : holds R A C <- transitive R <- holds R A B <- holds R B C.
r_sym   : holds R B A <- symmetric R <- holds R A B.

Relations are data again: rel is an ordinary LF type, and holds R A B is the single judgment that every relation shares. That is how LF, which is first-order in this respect, still gives you one transitivity rule for all transitive relations. The #strategy iddfs line selects iterative deepening, which the book says finds proofs that depth-first search misses when a recursive rule comes first. r_trans is exactly such a rule.

From the command line, ask for a proof:

lean-elpi --lf-proof 'holds ancestor alice carol' onto.elpi

The output pairs the answer with a proof term. Following the documented format, expect a term that names the rule used with its implicit arguments, followed by the proofs of its premises: here r_trans, then ancestor_trans, then two r_sub steps resting on parent_in_ancestor, ab and bc.

From a proof term to a kernel-checked theorem

Inside Lean, load the signature, run the query, export it, and certify:

import Elpi
open Elpi.Cmd

lf_signature onto "onto.elpi"
#lf_query onto lp%{ holds ancestor alice carol }%

lf_export onto
lf_certify onto alice_anc_carol lp%{ holds ancestor alice carol }%
#print axioms alice_anc_carol

lf_export generates Lean declarations in the namespace Onto: following the pattern the book shows for its λ-calculus signature, LF types become Lean inductives and the judgment holds becomes a Prop-valued family with one constructor per rule and per fact. lf_certify runs the query, translates the proof term into a Lean term, and asks the kernel to accept the theorem. If the kernel rejects it, the command reports the error and adds nothing. In the book’s own example, #print axioms reports no axioms for the certified theorem, and the same audit applies here.

What the kernel and the checker catch

The interesting failures are errors, not wrong answers:

  • A malformed ontology. A fact such as ab : holds parentOf alice. (one argument missing) is rejected when the signature loads, with a position, the expected type and the found type.

  • A characteristic with no proof. Remove ancestor_trans and the query holds ancestor alice carol has no derivation, so lf_certify has nothing to certify and adds no theorem. Declaring a characteristic is a fact with a name, and a rule that needs it cannot fire without it.

  • A rejected certificate. Whatever the search produced, the kernel has the last word. A bug in the engine can cost you an answer; it cannot cost you soundness.

  • A hidden assumption. #print axioms alice_anc_carol lists any axiom the theorem depends on. A trustworthy derived fact depends only on the axioms you chose.

Checking that rules are usable: modes and totality

Two directives turn good habits into checked claims. #mode states which arguments are inputs (+) and which are outputs (-), and the checker verifies, clause by clause, that inputs are ground when used. A violation names the clause, premise, argument and variable:

#mode holds +R +A -B.

If you add this line, I would expect the checker to flag r_sym, because its premise holds R A B needs A as an input while the head only produces it. That is a useful finding: it tells you the symmetry rule is not usable in the “enumerate B” direction and needs an explicit guard. Check the exact report on your build.

#total goes further: #total N (plus N _ _). checks coverage and termination, and when the claim passes, lf_export adds a theorem such as Arith.plus_total proved by structural induction and checked by the kernel. For ontologies, totality is how you certify that a functional data property (every person has exactly one birth year) is defined everywhere. The book notes the current limit: totality theorems are built for a single designated argument.

Lean computes, ELPI reasons

LF’s #bridge and the type bridge let Lean do arithmetic and lookups inside the same derivation. For plain (non-certified) programs, deriving Elpi and elpi_extern share Lean data directly. Here a Lean function supplies a data property, and an ELPI rule uses it:

inductive Person | alice | bob | carol
  deriving Elpi

def birthYear : Person → Nat
  | .alice => 1960
  | .bob   => 1985
  | .carol => 2010
elpi_extern birthYear

elpi_program ages
elpi_accumulate ages lp%{
  accumulate lean.
  pred older i:person, i:person.
  older X Y :- birthYear X A, birthYear Y B, A < B.
}%

#elpi ages lp%{ older alice carol }%

The derived declarations make person and its constructors visible to ELPI, and elpi_extern gives birthYear the signature person -> int, so the ELPI type checker rejects a call with the wrong argument type when the program loads. The rule older is ordinary λProlog over a value Lean computed.

7. Trust, limits and roadmap

The approach trades throughput for an auditable guarantee. Against the usual stacks:

  • Against OWL and SHACL reasoners. You give up open-world entailment out of the box, and gain second-order statements about relations, native binders, and a proof term for every answer. The trusted base shrinks from the whole reasoner to Lean’s kernel plus declared axioms.

  • Against Datalog engines. You give up billions-of-tuples scale. You gain rules that quantify over relations, scoped hypotheses with =>, and certificates.

  • Against Lean alone. You gain a logic-programming search language, with unification, backtracking and CHR, in which rule bases are short and readable. Lean’s own tactics and instance search are not designed as a general λProlog.

  • Against Coq-Elpi. You gain a single-language stack, with no OCaml and no foreign process, and the Python, Node.js and Rust bindings. You give up Coq’s maturity, and the speed gap in section 4 is real.

Limits to plan for

  • Scale and proof size. Every certified fact carries a proof term that the kernel re-checks. Use the engine as a certifying layer over a fast store: let a conventional reasoner do bulk materialization, and certify the facts that matter (decisions, compliance results, anything audited).

  • Search control. Backward chaining without tabling diverges on cyclic data. Production rules need visited sets, depth bounds, or the #strategy iddfs and #strategy bounded directives of the LF layer.

  • Open-world semantics. If you need OWL’s open-world reasoning, model it explicitly with a separate “known false” relation. Do not read negation as failure as falsity.

  • Exporter coverage. The project documents that the LF exporter covers one assumption family and binders over the family being defined, that totality theorems are built for a single designated argument, and that bridged functions return Nat.

  • Type classes are not bridged yet. The interop chapter lists this as a natural next step. Until then, characteristics are LF facts rather than Lean instances, which is why section 6 stated them as signature constants.

  • Engine maturity. Release 0.3.3 is 2.4 times slower than ELPI by geometric mean, and it passes 52 of the 114 applicable upstream tests. Keep the rule base small and the conformance suite in view.

  • Examples are untested by me. The syntax comes from the repository’s README and book, but I could not install the Lean toolchain in my sandbox, so I have not run any of the ontology programs. Expect to adjust small details, such as exact output formats and the generated Lean names.

A practical roadmap

  1. 1.

    Model one real ontology fragment as an #lf signature: individuals as constants, relations as rel constants, one holds judgment.

  2. 2.

    State each property characteristic as a named fact and write the generic rules once.

  3. 3.

    Add #mode and #total where a rule or a data property should be directional or defined everywhere, and read the checker’s complaints as design feedback.

  4. 4.

    Run lf_signature, lf_export and lf_certify for the decisions that matter, and put #print axioms in CI.

  5. 5.

    Use deriving Elpi and elpi_extern to bring existing Lean data and computed properties into the same rules.

  6. 6.

    Add search control, then a scale strategy that certifies selected facts rather than all of them.

Takeaway

ELPI gives you the search a rule language needs, with binders and relation variables as first-class citizens. Lean gives you the truth that a rule language cannot give itself. lean-elpi puts both in one language and one process, and its LF layer makes the boundary explicit: untrusted, fast and expressive on one side, small and checked on the other. A verifiable ontology is what you get when every inference must cross that boundary as a proof.

Originally published on Sovereign Agentic AI on Substack.