std.db

Datalog/Prolog-style relations layered on top of fact tables, with optional SLG-style tabling for recursive rules.

(import std.db)

Relation definition

SymbolDescription
(defrel name arity)Declare a relation.
(defrel-clause name (head ...) body ...)Add a rule clause.
(tabled name arity)Declare a tabled (memoising) relation.
(tabled-clause name (head ...) body ...)Add a clause to a tabled relation.

Facts

SymbolDescription
(assert-fact! name args)Insert a ground fact.
(retract-fact! name args)Remove a ground fact.
(retract-all name)Remove all facts and rules for name.
(index-rel! name cols)Build an index on the named relation.

Querying

SymbolDescription
(call-rel name args)Goal that succeeds for each matching tuple.
(call-rel? name args)True when at least one tuple matches.

Deprecated

SymbolReplacement
assertassert-fact!.
retractretract-fact!.