Set constructors in a logic database language

Catriel Beeri, Shamim Naqvi, Oded Shmueli, Shalom Tsur
1991 The Journal of Logic Programming  
parent(X, Y ). ancestor(X, Y 1 + parent(X, Z>, ancestor(Z, Y). excl_ancestor ( X, Y, Z 1 +-ancestor(X, Y), 7 ancestor-(X, Z). This program satisfies the restriction of layering, or stratification [2,14,42,261. It can be viewed as consisting of two layers: the first layer contains the first two ancestor rules and the parent base relation, and the second layer contains the excl_ancestor rule. Negation is applied to a predicate of the first layer, only to compute a predicate of the second layer,
more » ... the second layer may be unambiguously computed once the first one is fully computed. Thus, the program can be assigned a "natural" iterated fixpoint semantics, as described in those papers. SET CONSTRUCTORS IN A LOGIC DATABASE LANGUAGE 183 However, it is not always possible to associate such a semantics with a program that uses negation, as illustrated by the following program [s(X) denotes the successor of Xl: int(0). int(s(X)) + int(X>. euen(0). euen(s(X)) +-int(X), 7 even(X). In this program, the predicate even depends on a negative occurrence of itself, which implies that there is no partition of the rules (and predicates) of the program into layers, in the sense above. Sets and set manipulation occur naturally in many applications. In particular, query languages and data manipulation in database systems are set oriented. In classical logic-programming languages, sets can be represented only indirectly, by lists. This representation is awkward, and does not support optimization techniques such as those developed for Datalog. A primary goal of ._8_!3._& was to introduce sets and set operators as first-class citizens of the language. Sets can appear as elements of base relations, as proposed in nested-relations and complex-object models [l, 6,161. Predicates such as membership, union, and so on, can be used on such elements. Sets as arguments of predicates can also be generated by using appropriate constructors. The Boolean set operations are, of course, such constructors. In _&2_& two additional constructors are used: set enumeration and set grouping. Set enumeration is the process of constructing a set by enumerating its elements, as in the following example: Example. The relation book includes tuples whose first component is the title of a book, and whose second component is the price of the book. The relation book-deal is composed of tuples with a single (set) component. This set component includes the titles of three books whose total price is less than $100. The _&9._/ program defining the relation book-deal is shown below: book_deul({ X, Y, 2)) + book(X, Z?x), book(Y, f!~), book(Z, Pz), X# Y, xzz, Y#Z,
doi:10.1016/0743-1066(91)90036-o fatcat:cdnhxoguobeszegm5suzf4zcoe