sambayless / monosat

MonoSAT - An SMT solver for Monotonic Theories
MIT License
106 stars 29 forks source link

Connection to datalog? #15

Open copumpkin opened 6 years ago

copumpkin commented 6 years ago

With MonoSAT's graph operations, it feels vaguely like there might be a somewhat mechanical transformation from datalog to GNF and MonoSAT, but I haven't fleshed that out. Have you given it much thought, or is there any related work you know of in that space?

sambayless commented 6 years ago

I haven't thought too deeply about the Datalog/MonoSAT connection before; but it could be promising. Maybe something like: rules in data log become edges in a graph, facts are modeled as nodes (perhaps with a node 'true' always present), and we consider facts to be derivable if they are reachable from the true node. Each edge would have constraints on it ensuring that it can only be true if the body of one of its rules holds. Queries would be reachability predicates.

Is that similar to what you had in mind? It might be worth trying.

One thing to keep in mind: MonoSAT scales well for graphs with as many as a few million nodes, depending on how complex the constraints are. But it isn't going to handle billions of nodes. So you would only be able to apply this to problem domains where the total space of possibly-derivable-facts (each of which will become a node) is not too large.

The closest thing I'm aware of in that area would be Answer Set Programming, which is a logic programming language with constraints. High-performance ASP solvers typically use a modified SAT solver on the backend. I'm not sure how closely the semantics of datalog and ASP line up (ASP is based around a notion of 'stable models' that I think differs from datalog), but that might be another direction to explore if you wanted a SAT backend for datalog constraints. This paper discusses the semantics of datalog and ASP.