fluree / db

Fluree database library
https://fluree.github.io/db/
Other
337 stars 21 forks source link

Datalog reasoner #741

Closed bplatz closed 5 months ago

bplatz commented 7 months ago

This adds a query-based datalog reasoner as an initial step to chunk up work. This is not optimized via caching, and other optimizations around rule parsing can also be had. See fluree.db.reasoner.datalog-test for various tests and usage. It should be considered experimental until further optimizations are done.

Key features: 1) reasoning rules can be provided by any DB (the target db by default), or just plain JSON-LD 2) Reasoning creates a new db object - the regular db is still available for queries as it always has been 3) Recursive reasoning rules are supported 4) Reasoned flakes have the reasoning rule @id as part of their meta .-m allowing every flake to be traced back to the reasoning rule that created it 4) reasoner-max option will terminate after provided rounds of reasoning have been achieved. Recursive reasoning can cause an infinite reasoning loop if not cautious 5) 3 new APIs, reason, which creates the reasoned db, reasoned-count provides a count of reasoned facts when provided a reasoned db as the arg, reasoned-facts returns a vector all reasoned facts in a reasoned db as 4-tuples of [subject property object rule-iri] where rule-iri is the rule that created the fact.