Are WOQL queries just Prolog unification under the hood?

A query in Prolog can be thought of as a form of pattern matching. Is a WOQL query (usually prefixed with a just a thin wrapper around Prolog’s unification, or is there more going on here?

On a high level, I can see that a WOQL query takes three inputs:

  • A database of triples (TerminusDB itself)
  • A list of variables to be returned in the result (the “select”)
  • A set of constraints on variables of interest (everything else in the query)

…and produces a table as the output.

My guess is that a WOQL query is a Prolog-backed pattern matching followed by a relational-ish projection?

If not, I’d love to know the exact mathematical/conceptual foundation of WOQL (link papers or blog posts if you have em).

Yes, Unification is the core principle of WOQL which enables all else. There is a little more to it though -there is also a schema - a set of OWL axioms - which globally constrains the shape of the database according to pretty much anything you can express in first order logic and there’s lots of complexity of transactional logic which is not so much a concern in Prolog.

We now have a proper formal ontology describing WOQL:

In terms of papers, we have a few but mostly they deal with the mathematical underpinnings rather than WOQL itself. We’ve only just arrived at a place where we consider WOQL is more or less complete (we anticipate that what we have now will continue to be extended but the basics will not change for a long time). With the formal ontological description and much better documentation coming on line, we will hopefully get a chance to write down the internal concepts in a more accessible way. In the meantime, it’s all in the terminus-server prolog repo - again that’s not for the faint heated though - the first paper below contains a formalism of the schema constraint mechanism.