Datalog in Rust

34 points by asb


chc4

One of the big improvements for Datalog-shaped program analysis is supporting semilattice types, ime. egglog and ascent have them, and even Souffle has them now, and they’re a natural fit for “iterate to fixpoint” style abstract interpretation that comes up a lot. Even things like the points-to analysis in the article I usually think of in terms of saturating the points-to set instead of adding tuples over free variables, although they can obviously express the same thing.

The demand driven part is neat, and something that I never actually looked into in Datalog engines before! Practically every post I’ve seen previously have only talked about how to more quickly saturate the dataset, not how to more efficiently compute only the queried rows. I’ve used CodeQL in the past, which compiles down to Souffle, and had a lot of issues with its query planner ballooning intermediate table results computing facts that aren’t actually relevant, or that should be pared down by later negative rules, and having a more intelligent Datalog engine I think would be a lot better for program analysis than a faster one. CodeQL has the Klee star operator as a first-class language primitive which is cute, but I’ve never even seen the “transpose” operator before!

I’m also curious why no Datalog engines ever talk about doing perfect optimal multijoins as part of their query planning. Most rules have conjunctive queries that result in joins and semijoins (or, in this case, equijoins) over multiple tables and something like Yannakaki’s algorithm seems like it would be better in an algorithmic complexity case, especially if your query plan is able to re-use the intermediate join tables across multiple rules, or do the incremental updating thing using them for semi-naive evaluation.

dotemacs

Some prior work, in Datalog & Rust, that unfortunately is no longer maintained: https://github.com/mozilla/mentat

tobin_baker

I have to be missing something obvious but the body of tri() doesn’t appear to form a 3-cycle?