Our great sponsors
-
cozo
A transactional, relational-graph-vector database that uses Datalog for query. The hippocampus for AI!
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
-
codeql
CodeQL: the libraries and queries that power security researchers around the world, as well as code scanning in GitHub Advanced Security
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
One of the most interesting Datalog systems I have seen is Mangle:
https://github.com/google/mangle
It was previously discussed here:
https://news.ycombinator.com/item?id=33756800
The system is quite unique among those systems that call themselves Datalog because it is one of the few that actually supports Datalog syntax, as a proper subset of all features it supports. This means that you can truly write and run Datalog programs which can be read and interpreted also with every Prolog system.
you can use Datalig within Flix https://flix.dev/
While not trivial because it is not documented, you can create your a database with your own facts. Some of the extractors that create the required files are open source https://github.com/github/codeql/blob/main/ruby/extractor/sr...
Souffle and Cozo mentioned below already implement the whole of "traditional" datalog.
Percival (https://github.com/ekzhang/percival) has some very nice examples showing how you can interactively write and test rules on top of a datalog interpreter.
Bud (http://bloom-lang.net/bud/) is Hellerstein's proof of concept playground. It has bit-rotted in the past few years, but the examples are readable even if you can't easily get it working.
The complexity can be quite good. You can syntactically determine when you've written linear recursion (equivalent to a for loop) vs not. Otherwise, the complexity is what you'd expect from incremental view maintenance in a normal SQL database. Which is to say O(n^k) with k being the number of relations joined, but usually much, much less with appropriate indexes and skew in the data. All the usual tricks concerning data normalization and indexes from databases apply.
> Datomic has a notion of rules which are mostly syntax sugar and do not support this sort of recursive reasoning.
> Why is that a big deal? When rules are run automatically, you can build live, reactive systems, not just a database that sits around waiting for you to query it.
There was at least one serious attempt to bring these worlds together: https://github.com/sixthnormal/clj-3df
One of the easiest to get started on Datalog in my opinion is really clingo https://potassco.org/clingo/ , which can be pip installed and has python bindings. Answer Set Programming goes beyond datalog, but it holds datalog semantics as a sublanguage. It is unfortunate this is not well advertised.
```
Related posts
- Datalog in 100 lines of JavaScript (2022)
- Introduction to Datalog
- Soufflé: A Datalog Synthesis Tool for Static Analysis
- Percival: Web-based, reactive Datalog notebooks for data analysis and visualization, written in Rust and Svelte
- Show HN: Percival – Web-based reactive Datalog notebooks, made with Rust+Svelte