This document describes a proposed design for implementing support for recursive queries in Glean.
With recursion comes the question of whether the query evaluation will ever finish and given the existence of negation we need to consider whether the result could be ambiguous. These questions are addressed in the sections on Termination and Negation.
Formally, Glean will calculate the well-founded partial model of a query, schema and database combination by calculating the least fixed point of such query. We require that schemas be stratified to guarantee that the well-founded partial model generated be two-valued and the only stable model for the program [1,2,4]. It can then be computed one stratum at a time, each stratum as the least fixed point of its rules given the strata below it.