rify
Rify is a forward chaining inference engine designed specifically for use on in-memory RDF graphs.
It accepts conjunctive rules with limited expressiveness so reasoning is bounded by O(n^k) in both memory and in computation where n is the number of nodes in the input RDF dataset.
Given premises and target statement[s], rify can generate a proof which can be used to quickly verify the result programatically.
Logical rules are defined as if-then clauses. Something like this:
// Notice it's `[Entity; 4]`, not `[Entity; 3]`. This reasoner operates on Rdf Quads, not triples.
// You can still reason over triples by binding a unique resource e.g. `RdfTerm::DefaultGraph`
// as the graph in all rules and all quads.
// actual definitions of these types are templated but this is the gist
// You get to define this type! Here is an example definition.
Rify doesn't care whether its input and output is valid rdf. For example, it will happily accept a quad whose predicate is a literal. https://www.w3.org/TR/rdf11-concepts/#section-triples
Use
Three functions are central to this library: prove, validate, and infer.
prove
use ;
// (?a, is, awesome) ∧ (?a, score, ?s) -> (?a score, awesome)
let awesome_score_axiom = create.expect;
assert_eq!;
validate
use ;
// same as above
let awesome_score_axiom = create.expect;
let proof = vec!;
let Valid = .expect;
// Now we know that under the given rules, if all quads in `assumed` are true, then all
// quads in `implied` are also true.
infer
use ;
// (?a, is, awesome) ∧ (?a, score, ?s) -> (?a score, awesome)
let awesome_score_axiom = create.expect;
let mut facts = vec!;
let new_facts = ;
facts.extend;
assert_eq!;
Recipes
In addition to normal cargo commands like cargo test and cargo check the ./justfile
defines some scripts which can be useful during development. For example, just js-test will
test the javascript bindings to this library. See ./justfile for more.
License
This project is licensed under either of Apache License, Version 2.0 or MIT license, at your option.