Expand description
Synalog over oxilite: the Datalog-family language for AI agents, as an optional second rule
dialect beside oxilite-datalog.
Synalog (a Rust rewrite of Logica) has named
arguments, full expressions, head aggregation, functors, @OrderBy/@Limit and a verifier
whose errors are written for a model to read. It compiles to SQL. This crate uses its parser,
verifier and compiler unchanged, two ways:
- on its own:
checkandcompile_for_engine, for any engine Synalog supports; - over the triple store:
compile/preparepresent the store as relational tables —triples(subject, predicate, object, kind, datatype, lang, graph)plus the predicate and class tables a program declares — and make the SQL run on every backend, D1 included.
# @table parent <http://example.org/parent>
@Recursive(Ancestor, 10);
Ancestor(x:, y:) distinct :- parent(subject: x, object: y);
Ancestor(x:, y:) distinct :- Ancestor(x:, y: m), parent(subject: m, object: y);
Adult(name:) distinct :- triples(subject: p, predicate: "http://example.org/age", object: age),
triples(subject: p, predicate: "http://example.org/name", object: name),
age >= 18;Re-exports§
pub use error::Result;pub use error::SynalogError;pub use exec::SynalogJob;pub use exec::SynalogResult;pub use tables::Table;pub use synalog;
Modules§
- error
- Errors raised while checking, compiling and running a Synalog program.
- exec
- Running a compiled program: one read request, whose rows are already SQL values.
- rewrite
- Making Synalog’s SQLite output portable: runtime helpers rewritten to plain SQL, what has no SQL form rejected, and the backend’s limits checked — all before a request is sent.
- tables
- The store as relational tables:
triples, plus predicate and class tables a program declares, each a common table expression over the quad table with terms decoded to native SQL values.
Structs§
- Compiled
- A program compiled for the store.
- Options
- Options for running a program on the store. The scope defaults match SPARQL’s: the default graph only, no inferences, the current state.
Enums§
- SqlValue
- A SQL value, the subset of SQLite storage classes oxilite uses.
Constants§
- ENGINES
- The engines
compile_for_engineaccepts.
Functions§
- check
- Runs the Synalog verifier:
Okwhen the program is valid, else every error it reports. - compile
- Compiles one predicate to a statement over the store’s tables.
- compile_
for_ engine - Compiles one predicate for one engine, exactly as Synalog does: the dialect without a store.
- prepare
- Compiles a predicate into a job that runs it.