Skip to main content

Crate oxilite_datalog

Crate oxilite_datalog 

Source
Expand description

Datalog over oxilite: recursive rules with stratified negation, constraints and aggregation, compiled to SQL.

SPARQL and openCypher both stop at the same wall — recursion beyond a property path — and the only rules oxilite has are the fixed RDFS/OWL-RL set hard-coded in the core. This crate makes a rule a first-class thing: named, composable, and evaluated where the data is, which on Cloudflare D1 means inside the database rather than over the network.

@prefix ex: <http://example.org/> .

ancestor(?x, ?y) :- ex:parent(?x, ?y).
ancestor(?x, ?z) :- ex:parent(?x, ?y), ancestor(?y, ?z).

adult(?x, ?y) :- ancestor(?x, ?y), ex:age(?y, ?a), ?a >= 18.
orphan(?x)     :- ex:Person(?x), not ancestor(?x, _).

?- adult(?x, ?y).

A program is parsed, checked (safety and stratification), and compiled to one SQL statement whenever its recursion is linear — the same one-round-trip invariant SPARQL and Cypher hold.

Re-exports§

pub use ast::Program;
pub use ast::Rule;
pub use error::DatalogError;
pub use error::Result;
pub use exec::DatalogJob;
pub use exec::DatalogResult;
pub use materialize::plan as materialize_plan;
pub use materialize::MaterializeJob;
pub use materialize::MaterializeStats;
pub use parser::parse;
pub use program::Analysis;
pub use program::Shape;
pub use program::Stratum;
pub use sql::Compiled;
pub use sql::Fixpoint;
pub use sql::FixpointPhase;
pub use sql::Options;

Modules§

ast
The Datalog abstract syntax tree.
error
Errors raised while parsing, checking and compiling a Datalog program.
exec
Running a compiled program: the sans-IO step machine and result decoding.
host
Host functions in Datalog: rules that call application code.
lexer
Tokenizer for the Datalog dialect.
materialize
Storing what a program derives, as inferences.
parser
Recursive-descent parser for the Datalog dialect.
program
Program analysis: dependency graph, strongly connected components, stratification, safety, and the recursion shape of each component.
sql
Compiles a checked program to SQL over the term-id encoding.

Enums§

ProgramJob
A program ready to run: plain, or with rules that call host functions (see host).

Functions§

compile
Parses, checks and compiles a program.
explain
Describes how a program runs: its strata, the strategy chosen for each recursive component, and the SQL it compiles to.
prepare
Prepares a program for execution.
prepare_program
Prepares a program, with the host functions of options callable from it.
version_of
The version a program reads: the as_of option, else its @version directive.
version_refs
Every version a program names: its as_of / @version first (if any), then the at "REF" of its atoms, deduplicated.