ArticlePDF Available

# Ultimate Well-founded and Stable Semantics for Logic Programs with Aggregates

Authors:

## Abstract

. In this paper, we propose an extension of the well-founded and stable model semantics for logic programs with aggregates. Our approach uses Approximation Theory, a xpoint theory of stable and wellfounded xpoints of non-monotone operators in a complete lattice. We dene the syntax of logic programs with aggregates and dene the immediate consequence operator of such programs. We investigate the wellfounded and stable semantics generated by Approximation Theory. We show that our approach extends logic programs with stratied aggregation and that it correctly deals with well-known benchmark problems such as the shortest path program and the company control problem. 1
Ultimate Well-founded and Stable Semantics for
Logic Programs with Aggregates
Marc Denecker
a
Nikolay Pelov
b
Maurice Bruynooghe
b
a
Universit´e Libre de Bruxe lles, Bld du Triomphe CP 212, 1050 Brussels, Belgium
b
K.U.Leuven, Celestijnenlaan 200A, 3001 Heverlee, Belgium
In [3] we investigate the problem of deﬁning a well-founded and stable s e -
mantics for programs with aggregates. Our work is based on Approximation The-
ory [1] which is a general algebraic framework for approximating non-monotone
operators on a complete lattice L by approximating operators o n the bi-lattice L
2
.
The theory identiﬁes basic properties of the approximating operators and gives
a method to construct a stable ope rator and their associated ﬁxpoints - Kripke-
Kleene (KK), well-founded (WF), and set of stable ﬁxpoints. The authors then
show that the diﬀerent ﬁxpoints enjoy similar properties and relationships a s the
corresponding semantics in standard logic programming. For example the WF
ﬁxpoint is mo re precise than the KK ﬁxpoint and a lso approximates every stable
ﬁxpoint. Moreover, stable ﬁxpoints are always minimal ﬁxpoints.
In a mo re recent paper [2] the authors study the concept of precision of an
approximating oper ator. They show that more precise approximating operators
have mo re precise KK and WF ﬁxpoints and a larger number of stable ﬁxpoints.
Moreover, there exists a most-precise approximating operator which they call the
ultimate approximation. In contrast with other approximating op e rators which
have to be deﬁned explicitly, the construction of the ultimate approximating oper-
ator is entirely algebraic and depends only on the original non-monotone oper ator.
This makes it particularly well-suited for our purposes be cause deﬁning a T
P
oper-
ator for programs with aggregates is relatively straightforward. Another advantage
of the ultimate approximation is that in cases where T
P
is monotone the ultimate
well-founded model will be 2-valued and will coincide with the least ﬁxpoint of
T
P
. This is not the case for the standard well-founded semantics. For example in
the standard well-founded model of the pr ogram:
p ¬p.
p p.
p is undeﬁned while the associated T
P
operator is monotone and p is true in the
ultimate well-founded model.
One disadvantage of using the ultimate semantics is that it has a higher com-
putational cost even for programs without aggregates. The complexity goes one
level higher in the polynomial hierarchy to
p
2
for the well-founded model and to
Σ
p
2
for a stable model which is also complete for this cla ss [2]. Fortunately, by
adding aggregates the complexity does not increase further.
To g ive an example of a logic program with aggregates we consider the problem
of computing the length of the shortest path between two nodes in a directed graph.
The graph is represented with a set of edge(X, Y, W ) facts meaning that there is
an edge between X and Y with weight W . The program consists of a single rule:
sp(X, Y, L) min({C | edge(X, Y, C)
Z, C
1
, C
2
. (sp(X, Z, C
1
) edge(Z, Y, C
2
)
C = C
1
+ C
2
)}, L).
This program shows the syntax which we use. First of all, we allow arbitrary
ﬁrst-order fo rmulas in the bodies of rules and in the conditions of set expressions.
Unlike most o f the previous work o n aggregates, we use an explicit notation for set
expressions {X | ϕ[X]} denoting the set of all elements d for which the condition
ϕ[d] is true. Aggregate functions are written in a form of atoms like f(s, t) where
F is an aggregate function, s is a set expression, and t is a term. It will evaluate
to true if the aggregate function f applied to the set denoted by s is equal to the
interpretation of the term t.
Having deﬁned a 2-valued semantics fo r formulas containing aggregate atoms
it is easy to extend the deﬁnition of the 2-valued van Emden-Kowalski immediate
consequence operator T
P
for programs with a ggregates. Constructing the ultimate
approximating operator of T
P
we obtain an ultimate well-founded and ultimate
stable semantics for pro grams with aggregates. The two semantics have all the
properties which we discussed earlier. In addition for aggregate stratiﬁed programs
the ultimate well-founded model will be 2-valued and will coincide with the unique
ultimate stable model.
Our current research is focused on deﬁning a less precise a pproximating oper-
ator for programs with aggregates which extends the s tandard well-founded and
stable semantics for programs without aggregates. Although the complexity of
this operator will still be the same as the the complexity of the ultimate approx-
imation, if we limit our language to some speciﬁc aggregate functions we can stay
in the complexity classes o f the standard semantics - P for the well-founded model
and NP for the stable models.
References
[1] M. Denecker, V. Marek, and M. Truszczy´nski. Approximating operators, stable
operators, well-founded ﬁxpoints and applications in non-monotonic reasoning.
In J . Minker, editor, Logic-based Artiﬁcial Intelligence, pages 127–144. Kluwer
[2] M. Denecker, V. Marek, and M. Truszczy´nsky. Ultimate approximations in
nonmonotonic knowledge representation systems. In, KR’02, pages 17 7–188.
Morgan Ka ufmann, 2002.
[3] M. Denecker, N. Pelov, and M. Br uy nooghe. Well-founded and stable model
semantics for logic programs with aggregates. In P. Codognet, editor, ICLP’01,
volume 2237 of LNCS, pages 212–226. Springer-Verlag, 2001.
... The theory has been applied to a range of non-monotonic logics to characterize existing as well as new semantics: for example, LP and ASP as shown in the paper by Denecker et al. (2012), autoepistemic and default logic as shown in the paper by Denecker et al. (2003), higher order LP as shown in the paper by Charalambidis et al. (2018), argumentation frameworks and abstract dialectal frameworks as shown in the papers by Strass (2013) and Bogaerts (2019). AFT has been applied to aggregate LP and ASP resulting in the ultimate stable and well-founded semantics in the work by Denecker et al. (2001) and the broader framework in the paper by Pelov et al. (2007) where stable and well-founded semantics are induced by a choice of a 3-valued truth function. ...
... However, the semantics described by Gelfond and Zhang (2019) does not allow negation by default inside an aggregate atom, therefore we only consider positive conditions for this specific case. It is shown that not only the semantics of Denecker et al. (2001), Pelov et al. (2007 but also those of Liu et al. (2010) and Gelfond and Zhang (2019) are instances of our framework. But not all proposed semantics for aggregate ASP semantics belong to our framework; for example those of Ferraris (2011), Remmel (2004), Faber et al. (2011). ...
... One way is to use A P = Ult(T P ), the most precise approximator of T P in L c leading to ultimate versions of the family of AFT semantics as described by Denecker et al. (2004) and used by Denecker et al. (2001) for defining semantics of Aggregate LP. This is the most precise approach, but computationally costly. ...
Article
Full-text available
Aggregates provide a concise way to express complex knowledge. The problem of selecting an appropriate formalization of aggregates for answer set programming (ASP) remains unsettled. This paper revisits it from the viewpoint of Approximation Fixpoint Theory (AFT). We introduce an AFT formalization equivalent with the Gelfond–Lifschitz reduct for basic ASP programs and we extend it to handle aggregates. We analyze how existing approaches relate to our framework. We hope this work sheds some new light on the issue of a proper formalization of aggregates.
... The language of ASP offers several constructs to ease the representation of practical knowledge. Aggregate expressions received particular interest by ASP designers (Bartholomew et al. 2011;Denecker et al. 2001;Faber et al. 2011;Ferraris 2011;Gebser et al. 2015a;Gelfond and Zhang 2019;Liu et al. 2010;Marek and Remmel 2004;Pelov et al. 2007;Simons et al. 2002), and the utility of their incorporation in the modeling language has been realized almost simultaneously with the inception of the first ASP solving systems. In fact, aggregate expressions provide a natural syntax for expressing properties on sets of atoms collectively, which is often desired when modeling complex knowledge. ...
... Under this syntactic restriction, FFLP-answer sets can be defined as ⊆-minimal models of a program reduct obtained by deleting rules with false bodies, as in the aggregate-free case. Other prominent seman- tics (Denecker et al. 2001;Gelfond and Zhang 2019;Liu et al. 2010;Marek and Remmel 2004;Pelov et al. 2007) adopt constructive procedures for checking the provability of true atoms. While some of these semantics were originally defined via a notion of reduct in the non-disjunctive case, they can be viewed as semantics based on different extensions of the immediate consequence operator (van Emden and Kowalski 1976;Lloyd 1987). ...
... In order to characterize the similarities and differences between the main aggregate semantics proposed for propositional logic programs (Denecker et al. 2001;Faber et al. 2011;Ferraris 2011;Gelfond and Zhang 2019;Liu et al. 2010;Marek and Remmel 2004;Pelov et al. 2007), 2 we consider a set P of propositional atoms. An aggregate expression has the form AGG[w 1 : p 1 , . . . ...
Preprint
Full-text available
Answer Set Programming (ASP) emerged in the late 1990ies as a paradigm for Knowledge Representation and Reasoning. The attractiveness of ASP builds on an expressive high-level modeling language along with the availability of powerful off-the-shelf solving systems. While the utility of incorporating aggregate expressions in the modeling language has been realized almost simultaneously with the inception of the first ASP solving systems, a general semantics of aggregates and its efficient implementation have been long-standing challenges. Aggregates have been proposed and widely used in database systems, and also in the deductive database language Datalog, which is one of the main precursors of ASP. The use of aggregates was, however, still restricted in Datalog (by either disallowing recursion or only allowing monotone aggregates), while several ways to integrate unrestricted aggregates evolved in the context of ASP. In this survey, we pick up at this point of development by presenting and comparing the main aggregate semantics that have been proposed for propositional ASP programs. We highlight crucial properties such as computational complexity and expressive power, and outline the capabilities and limitations of different approaches by illustrative examples.
... • IDP-Z3 goes beyond inference engines of the third kind by allowing reasoning not only with deterministic rulebased definitions, but also with non-deterministic axioms describing possible worlds. Our result further justifies the revival of interest in the seminal papers on the integration of rule-based languages and classical logic (Denecker (2000), 20-year Test-of-Time award at ICLP 2020, and Denecker, Pelov, and Bruynooghe (2001), 20-year Testof-Time award at ICLP 2021). ...
Preprint
Full-text available
FO(.) (aka FO-dot) is a language that extends classical first-order logic with constructs to allow complex knowledge to be represented in a natural and elaboration-tolerant way. IDP-Z3 is a new reasoning engine for the FO(.) language: it can perform a variety of generic computational tasks using knowledge represented in FO(.). It supersedes IDP3, its predecessor, with new capabilities such as support for linear arithmetic over reals and quantification over concepts. We present four knowledge-intensive industrial use cases, and show that IDP-Z3 delivers real value to its users at low development costs: it supports interactive applications in a variety of problem domains, with a response time typically below 3 seconds.
... Fuzzy set theory: [8,9,65,70,76,77,78,110,123,124,132,141,154,200,207,217,218,223,233,245,246,247,300,305,307,308,309,310,316] Multi-valued logic: [69,82,83,84,85,86,87,88,89,90,91,92,93,98,99,100,101,102,116,117,118,119,120,127,150,151,152,153,159,160,161,162,180,181,182,183,184,185,186,187,188,191,193,194,196,198,199,202,203,204,205,209,210,211,212,213,214,227,228,229,230,231,236,242,243,244,265,266,267,270,271,272,274,276,277,278,286,293,295,303] Basically [177], a Datalog program P is made out by a set of rules and a set of facts. ...
Technical Report
Full-text available
We present the state of the art in representing and reasoning with fuzzy knowledge in Semantic Web Languages such as triple languages RDF/RDFS, conceptual languages of the OWL 2 family and rule languages. We further show how one may generalise them to so-called annotation domains, that cover also e.g. temporal and provenance extensions.
... However it used different lattices for different aggregates and thus incurred in the problems described in (Van Gelder 1993). Therefore, the search for general solutions has motivated several approaches that have addressed the problem using powerful semantics, such as answer-set semantics, that however require higher levels of computational complexity (Pelov et al. 2007; Son and Pontelli 2007; Swift andWarren 2010;Faber et al. 2011;Gelfond and Zhang 2014). Recently, the explosion of activity on Big Data has produced a revival of interest in Datalog as a parallelizable language for expressing and supporting efficiently Big Data Analytics (Seo et al. 2013;Shkapsky et al. 2013;Wang et al. 2015). ...
Article
Full-text available
A very desirable Datalog extension investigated by many researchers in the last thirty years consists in allowing the use of the basic SQL aggregates min, max, count and sum in recursive rules. In this paper, we propose a simple comprehensive solution that extends the declarative least-fixpoint semantics of Horn Clauses, along with the optimization techniques used in the bottom-up implementation approach adopted by many Datalog systems. We start by identifying a large class of programs of great practical interest in which the use of min or max in recursive rules does not compromise the declarative fixpoint semantics of the programs using those rules. Then, we revisit the monotonic versions of count and sum aggregates proposed in (Mazuran et al. 2013b) and named, respectively, mcount and msum. Since mcount, and also msum on positive numbers, are monotonic in the lattice of set-containment, they preserve the fixpoint semantics of Horn Clauses. However, in many applications of practical interest, their use can lead to inefficiencies, that can be eliminated by combining them with max, whereby mcount and msum become the standard count and sum. Therefore, the semantics and optimization techniques of Datalog are extended to recursive programs with min, max, count and sum, making possible the advanced applications of superior performance and scalability demonstrated by BigDatalog (Shkapsky et al. 2016) and Datalog-MC (Yang et al. 2017).
Article
Answer set programming (ASP) emerged in the late 1990s as a paradigm for knowledge representation and reasoning. The attractiveness of ASP builds on an expressive high-level modeling language along with the availability of powerful off-the-shelf solving systems. While the utility of incorporating aggregate expressions in the modeling language has been realized almost simultaneously with the inception of the first ASP solving systems, a general semantics of aggregates and its efficient implementation have been long-standing challenges. Aggregates have been proposed and widely used in database systems, and also in the deductive database language Datalog, which is one of the main precursors of ASP. The use of aggregates was, however, still restricted in Datalog (by either disallowing recursion or only allowing monotone aggregates), while several ways to integrate unrestricted aggregates evolved in the context of ASP. In this survey, we pick up at this point of development by presenting and comparing the main aggregate semantics that have been proposed for propositional ASP programs. We highlight crucial properties such as computational complexity and expressive power, and outline the capabilities and limitations of different approaches by illustrative examples.
Chapter
Full-text available
This chapter is a survey of the history and the main concepts of Datalog.We begin with an introduction to the language and its use for database definition and querying. We then look back at the threads from logic languages, databases, artificial intelligence, and expert systems that led to the emergence of Datalog and reminiscence about the origin of the name. We consider the interaction of recursion with other common data language features, such as negation and aggregation, and look at other extensions, such as constraints, updates, and object-oriented features.We provide an overview of the main approaches to Datalog evaluation and their variants, then recount some early implementations of Datalog and of similar deductive database systems.We speculate on the reasons for the decline in the interest in the language in the 1990s and the causes for its later resurgence in a number of application areas.We conclude with several examples of current systems based on or supporting Datalog and briefly examine the performance of some of them.
Conference Paper
The paper continues the investigation of Poincare and Russel’s Vicious Circle Principle (VCP) in the context of the design of logic programming languages with sets. We expand previously introduced language $$\mathcal {A}log$$ with aggregates by allowing infinite sets and several additional set related constructs useful for knowledge representation and teaching. In addition, we propose an alternative formalization of the original VCP and incorporate it into the semantics of new language, $$\mathcal {S}log^+$$, which allows more liberal construction of sets and their use in programming rules. We show that, for programs without disjunction and infinite sets, the formal semantics of aggregates in $$\mathcal {S}log^+$$ coincides with that of several other known languages. Their intuitive and formal semantics, however, are based on quite different ideas and seem to be more involved than that of $$\mathcal {S}log^+$$.
Chapter
The aim of this chapter is to present a detailed, self-contained and comprehensive account of the state of the art in representing and reasoning with fuzzy knowledge in Semantic Web Languages such as triple languages RDF/RDFS, conceptual languages of the OWL 2 family and rule languages. We further show how one may generalise them to so-called annotation domains, that cover also e.g. temporal and provenance extensions.
Chapter
Logic programming systems with tabling and constraints (TCLP, tabled constraint logic programming) have been shown to be more expressive and in some cases more efficient than those featuring only either tabling or constraints. Previous implementations of TCLP systems which use entailment to determine call / answer subsumption did not provide a simple, uniform, and well-documented interface to facilitate the integration of additional constraint solvers in existing tabling systems, which would increase the application range of TCLP. We present the design and an experimental evaluation of Mod TCLP, a framework which eases this integration. Mod TCLP views the constraints solver as a client of the tabling system. The tabling system is generic w.r.t. the constraint solver and only requires a clear, small interface from the latter. We validate our design by integrating four constraint solvers: a re-engineered version of a previously existing constraint solver for difference constraints, written in C; the standard versions of Holzbauer's CLP(Q) and CLP(R), written in Prolog; and a new constraint solver for equations over finite lattices. We evaluate the performance of our framework in several benchmarks using the aforementioned constraint solvers. All the development work and evaluation was done in Ciao Prolog.
Conference Paper
Full-text available
A generalization of logic program rules is proposed where rules are built from weight constraints with type information for each predicate instead of simple literals. These kinds of constraints are useful for concisely representing different kinds of choices as well as cardinality, cost and resource constraints in combinatorial problems such as product configuration. A declarative semantics for the rules is presented which generalizes the stable model semantics of normal logic programs. It is shown that for ground rules the complexity of the relevant decision problems stays in NP. The first implementation of the language handles a decidable subset where function symbols are not allowed. It is based on a new procedure for computing stable models for ground rules extending normal programs with choice and weight constructs and a compilation technique where a weight rule with variables is transformed to a set of such simpler ground rules.
Article
Full-text available
Abstract In this paper, we present a framework for the semantics and the computation of aggregates in the context of logic programming. In our study, an aggregate can be an arbitrary interpreted second order predicate or function. We define extensions of the Kripke-Kleene, the well-founded and the stable semantics for aggregate programs. The semantics is based on the concept of a three-valued immediate consequence operator of an aggregate program. Such an operator approximates the standard two-valued immediate consequence operator of the program, and induces a unique Kripke-Kleene model, a unique well-founded model and a collection of stable models. We study different ways of defining such operators and thus obtain a framework of semantics, offering different trade-offs between precision and tractability. In particular, we investigate conditions on the operator that guarantee that the computation,of the three types of semantics remains on the same level as for logic programs without aggregates. Other results show that, in practice, even efficient threevalued immediate consequence operators which are very low in the precision hierarchy, still provide optimal precision. KEYWORDS: Logic Programming, Aggregates.
Article
Full-text available
Logic programming with the stable model semantics is put forward as a novel constraint programming paradigm. This paradigm is interesting because it bring advantages of logic programming based knowledge representation techniques to constraint programming and because implementation methods for the stable model semantics for ground (variable‐free) programs have advanced significantly in recent years. For a program with variables these methods need a grounding procedure for generating a variable‐free program. As a practical approach to handling the grounding problem a subclass of logic programs, domain restricted programs, is proposed. This subclass enables efficient grounding procedures and serves as a basis for integrating built‐in predicates and functions often needed in applications. It is shown that the novel paradigm embeds classical logical satisfiability and standard (finite domain) constraint satisfaction problems but seems to provide a more expressive framework from a knowledge representation point of view. The first steps towards a programming methodology for the new paradigm are taken by presenting solutions to standard constraint satisfaction problems, combinatorial graph problems and planning problems. An efficient implementation of the paradigm based on domain restricted programs has been developed. This is an extension of a previous implementation of the stable model semantics, the Smodels system, and is publicly available. It contains, e.g., built‐in integer arithmetic integrated to stable model computation. The implementation is described briefly and some test results illustrating the current level of performance are reported.
Article
Full-text available
This paper investigates the problem and proposes an alternative epistemological foundation for the canonical model approach, which is not based on common sense but on a solid mathematical information principle. The thesis is developed that logic programming can be understood as a natural and general logic of inductive denitions. In particular, logic programs with negation represent non-monotone inductive denitions. It is argued that this thesis results in an alternative justication of the well-founded model as the unique intended model of the logic program. In addition, it equips logic programs with an easy to comprehend meaning that corresponds very well with the intuitions of programmers. Categories and Subject Descriptors: D.1.6 [Programming Techniques]: Logic Programming; D.3.1 [Programming Languages]: Formal Denitions and Theory|Semantics; F.3.2 [Logics And Meanings Of<F10.
Article
We propose a semantics for aggregates in deductive databases based on a notion of minimality. Unlike some previous approaches, we form a minimal model of a program component including aggregate operators, rather than insisting that the aggregate apply to atoms that have been fully determined or that aggregate functions are rewritten in terms of negation. In order to guarantee the existence of such a minimal model we need to insist that the domains over which we are aggregating are complete lattices and that the program is in a sense mono- tonic. Our approach generalizes previous approaches based on the well-founded semantics and various forms of stratification. We are also able to handle a large variety of monotonic (or pseudo-monotonic) aggregate functions.
Article
Bilattices, due to M. Ginsberg, are a family of truth-value spaces that allow elegantly for missing or conflicting information. The simplest example is Belnap's four-valued logic, based on classical two-valued logic. Among other examples are those based on finite many-valued logics and on probabilistic-valued logic. A fixed-point semantics is developed for logic programming, allowing any bilattice as the space of truth values. The mathematics is little more complex than in the classical two-valued setting, but the result provides a natural semantics for distributed logic programs, including those involving confidence factors. The classical two-valued and the Kripke-Kleene three-valued semantics become special cases, since the logics involved are natural sublogics of Belnap's logic, the logic given by the simplest bilattice.
Article
We present facilities for computing aggregate functions over sets of tuples and along paths in a database graph. We show how Datalog can be extended to compute a large class of queries with aggregates without incurring the large expense of a language with general set manipulation capabilities. In particular, we aim for queries that can be executed efficiently in parallel, using the class nc and its various subclasses as formal models of low parallel complexity. Our approach retains the standard relational notion of relations as sets of tuples, not requiring the introduction of multisets. For the case where no rules are recursive, the language is exactly as expressive as Klug's first order language with aggregates. We show that this class of non-recursive programs cannot express transitive closure (unless logspace=nlogspace), thus providing evidence for a widely believed but never proven folk result. We also study the expressive power and complexity of languages that support aggregation over recursion. We then describe how these facilities, as well as manipulating the length of paths in database graphs, are incorporated into our visual query language GraphLog. While GraphLog could easily be extended to handle all the queries described above, we prefer to restrict the language in a natural way to avoid explicit recursion; all recursion is expressed as transitive closure. We show that this guarantees all expressible queries are in nc. We analyze other proposals and show that they can express queries that are logspace-complete for p and thus unlikely to be parallelizable efficiently.
Conference Paper
Common aggregation predicates have natural definitions in logic, either as first order sentences (min, max, etc.), or with elementary induction over a data structure that represents the relation (sum, count, etc.). The well-founded semantics for logic programs provides an interpretation of such definitions. The interpretation of first-order aggregates seems to be quite natural and intuitively satisfying, even in the presence of recursion through aggregation. Care is needed to get useful results on inductive aggregates, however. A basic building block is the “subset” predicate, which states that a data structure represents a subset of an IDB predicate, and which is definable in the well-founded semantics. The analogous “superset” is also definable, and their combination yields a “generic” form of findall. Surprisingly, findall must be used negatively to obtain useful approximations when the exact relation is not yet known.Extensions to the semantics, restrictions on the input, and other supplementary requirements proposed in earlier studies appear to be unnecessary for the purpose of attaching a meaning to a program that involves recursion through aggregation. For example, any reasonable definition of “shortest paths” tolerates negative weight edges, correctly computes shortest paths that exist, and leave tuples undefined where negative-weight cycles cause the shortest path not to exist. Other examples exhibit similarly robust behavior, when defined carefully. Connections with the generic model of computation are discussed briefly.
Conference Paper
As a foundation for providing semantics for aggregation within recursion, the structure of subsets of partially ordered domains is studied. We argue that the underlying cause of many of the difficulties encountered in extending deductive database semantics to include aggregation is that set construction does not preserve the structure of the underlying domain very well. We study a binary relation that is stronger than the standard , contrasting its properties on domains with differing amounts of structure. An analogous is defined that is more appropriate than R[ for minimization problems. A class of aggregate functions, based on structural recursion, is defined formally. Proposed language constructs permit users to define their own interpreted functions and aggregates. Several relational algebra operations are not monotonic w.r.t. . To overcome this problem, unfolding is proposed to bury the nonmonotonic operations inside aggregation.