## LP with Flexible Grouping and Aggregates Using Modes

### BibTeX

@MISC{Czenko_lpwith,

author = {Marcin Czenko and Ro Etalle},

title = {LP with Flexible Grouping and Aggregates Using Modes},

year = {}

}

### OpenURL

### Abstract

Abstract. We propose a new grouping operator for logic programs based on the group_by operator of SQL. The novelty of our proposal lies in the use of modes, which allows us to relax some rather unpractical constraints on variable occurrences while retaining a straightforward semantics. Moreover, modes allow us to prove properties regarding groundness of computed answer substitutions and termination. The resulting class of programs enjoys a simple and intuitive semantics. 1

### Citations

1924 |
Foundations of logic programming
- Lloyd
- 1987
(Show Context)
Citation Context ...ion, which consists of the SLD-resolution combined with the leftmost selection rule. The reader is assumed to be familiar with the terminology and the basic results of the semantics of logic programs =-=[2,3,17]-=-. Here we adopt the notation of [3] in the fact that we use boldface characters to denote sequences of objects; therefore t denotes a sequence of terms while B is a sequence of atoms, i.e. a query (fo... |

1105 |
Principles of Database and Knowledge-base Systems, Volumes II: The New Technologies
- Ullman
- 1989
(Show Context)
Citation Context ...ops. In order to prevent this kind of problems, to guarantee termination we require programs to be aggregate stratified [14]. Aggregate stratification is similar to the concept of stratified negation =-=[2,23]-=-, and puts syntactical restrictions on the aggregate programs so that recursion through group_set does not occur. For the notation, we follow Apt et al. in [2]. Before we proceed to the definition of ... |

892 | Decentralized Trust Management
- Blaze, Feigenbaum, et al.
- 1996
(Show Context)
Citation Context ...ate functions are useful in practice, and paramount in database systems. Indeed, the reason why we address the problem here is of a practical nature: we are developing a language for trust management =-=[10,12,16]-=- based on (partially function-free) moded logic programming; this language is called TuLiP. To express trust management rules, TuLiP must be able to express statements such as “employee X will be gran... |

435 |
Logic Programming
- Apt
- 1990
(Show Context)
Citation Context ...ion, which consists of the SLD-resolution combined with the leftmost selection rule. The reader is assumed to be familiar with the terminology and the basic results of the semantics of logic programs =-=[2,3,17]-=-. Here we adopt the notation of [3] in the fact that we use boldface characters to denote sequences of objects; therefore t denotes a sequence of terms while B is a sequence of atoms, i.e. a query (fo... |

306 | Design of a role-based trust management framework
- Li, Mitchell, et al.
- 2002
(Show Context)
Citation Context ...ate functions are useful in practice, and paramount in database systems. Indeed, the reason why we address the problem here is of a practical nature: we are developing a language for trust management =-=[10,12,16]-=- based on (partially function-free) moded logic programming; this language is called TuLiP. To express trust management rules, TuLiP must be able to express statements such as “employee X will be gran... |

197 |
From Logic Programming to Prolog
- Apt
- 1997
(Show Context)
Citation Context ...ion, which consists of the SLD-resolution combined with the leftmost selection rule. The reader is assumed to be familiar with the terminology and the basic results of the semantics of logic programs =-=[2,3,17]-=-. Here we adopt the notation of [3] in the fact that we use boldface characters to denote sequences of objects; therefore t denotes a sequence of terms while B is a sequence of atoms, i.e. a query (fo... |

146 |
Equivalence of relational algebra and relational calculus query languages having aggregate functions
- KLUG
- 1982
(Show Context)
Citation Context ...ed in P1 ∪ · · · ∪ Pi, so that – by inductive hypothesis – we know that P ∪ Goal ′ terminates. Hence the thesis. 7 Related Work The first formal definition of aggregate functions was given by Klug in =-=[15]-=-. Klug also extends the relational algebra and relational calculus to support aggregate functions in a natural manner. In his approach, Klug avoids using multisets, and instead of defining aggregate f... |

126 | Reasoning about termination of pure Prolog programs
- Apt, Pedreschi
- 1993
(Show Context)
Citation Context ...he following example shows what can go wrong here. Example 4. Consider the following program: (1) p(X,Z) :- group_set(Y,[X],q(X,Y),Z). (2) q(X,Z) :- group_set(Y,[X],p(X,Y),Z). (3) q(a,1). (4) q(a,2). =-=(5)-=- q(b,3). (6) q(b,4). Here p and q are defined in terms of each other through the grouping operation. Therefore p(X,Z) cannot terminate until q(X,Y) terminates (clause 1). Computation of q(X,Y) in turn... |

124 | Beeri: On the Power of Languages for the Manipulation of Complex Objects INRIA Rapports de Recherche No. 846
- Abiteboul, C
- 1988
(Show Context)
Citation Context ...tionality as the classical built-in findall and x is instantiated to the list of instances of t corresponding to the computed answer substitutions of the query Goal: Q: group_set(Z,[],p(Y,Z),X). A: X==-=[1,2,3,4]-=-. On the other hand, if gl is not empty, then the computed answer substitutions to the Goal will be grouped in sets of answers with the following property: two computed answer substitutions σ1 and σ2 ... |

96 | Recursive aggregates in disjunctive logic programs: Semantics and complexity
- Faber, Leone, et al.
- 2004
(Show Context)
Citation Context ...They also examine different classes of aggregate programs: aggregate stratified, group stratified, magical stratified, and also monotonic and semi-ring programs. From a more recent work, Faber et al. =-=[16]-=- also rely on aggregate stratification and they define a declarative semantics for disjunctive programs with aggregates. They use the intensional set definition notation to specify the multiset for th... |

82 | Reasoning about Prolog programs: from Modes through Types to Assertions
- Apt, Marchiori
- 1994
(Show Context)
Citation Context ...he input and which are the output positions of each atom, and allow one to derive properties such as absence of run-time errors for Prolog built-ins, absence of floundering for programs with negation =-=[4]-=-. Definition 1 (Mode). Consider an n-ary predicate symbol p. By a mode for p we mean a function mp from {1, . . . , n} to {In, Out}. If mp(i) = In (resp. Out), we say that i is an input (resp. output)... |

82 | On the occur-check free Prolog program
- Apt, Pellegrini
- 1994
(Show Context)
Citation Context ...nt of a well-moded query and a well-moded clause that is variable-disjoint with it, is well-moded. As a consequence of Lemma 1 we have the following well-known properties. For the proof we refer to =-=[4]-=-. 1. Let P be a well-moded program and A be a well-moded query. Then for every computed answer σ of A in P , Aσ is ground. 2. LetH ← B1, . . . , Bn be a clause in a well-moded program P . IfA is a wel... |

66 | Semantics of Logic Programs with Aggregates
- Kemp, Stuckey
- 1991
(Show Context)
Citation Context ... set-valued attributes. Using set primitives as an alternative to using aggregate subgoals is also the approach used by Abiteboul and Beeri in [1]. However, as already observed by Kemp and Stuckey in =-=[14]-=-, sets are mostly used where aggregate subgoals could be used instead, while the latter seem to be easier to implement in the current logic programming systems. In the work of Özsoyoˇglu et al unsafe ... |

63 | Mercury: an efficient purely declarative logic programming language
- Somogyi, Henderson, et al.
- 1995
(Show Context)
Citation Context ... allowed to construct set-terms by “grouping” all instantiations of a term in the body of a rule, but they do not use aggregate subgoals explicitly. 13Moded Logic Programming is well-researched area =-=[18,4,7,22]-=-. However, to our best knowledge the modes has been never applied to aggregates. We also extend the standard definition of a mode to include the notion of local variables. By incorporating the mode sy... |

62 | The magic of duplicates and aggregates
- Pirahesh, Mumick, et al.
- 1990
(Show Context)
Citation Context ...her to express the statements we needed nor to demonstrate the correctness of Tulip rules containing aggregates. In particular, although grouping have been extensively studied in the past (see, e.g., =-=[19,14,8]-=-, and the Related Work section for further details), these approaches make strong assumptions on variable sharing we could not satisfy (in a grouping goal, non-aggregate variables may not be shared wi... |

53 | Strong termination of logic programs
- Bezem
- 1993
(Show Context)
Citation Context ...on 3. A well-moded program is called well-terminating iff all its LD-derivations starting in a well-moded query are finite. Termination of (well-moded) logic programs has been exhaustively studied in =-=[5,6,9,11,21,13]-=-. Here we follow the approach of Etalle, Bossi, and Cocco [13]. 4 Simple group_set queries The most intuitive (and modular) way of carrying out aggregate queries is to first collect all the answers to... |

49 | Ultimate well-founded and stable semantics for logic programs with aggregates
- Denecker, Pelov, et al.
(Show Context)
Citation Context ... and they define a declarative semantics for disjunctive programs with aggregates. They use the intensional set definition notation to specify the multiset for the aggregate function. Denecker et al. =-=[12]-=- point out that requiring the programs to be aggregate stratified might be too restrictive in some cases and they propose a stronger extension of the well-founded and stable model semantics for logic ... |

45 | Modular termination proofs for logic and pure Prolog programs
- Apt, Pedreschi
- 1994
(Show Context)
Citation Context ...on 3. A well-moded program is called well-terminating iff all its LD-derivations starting in a well-moded query are finite. Termination of (well-moded) logic programs has been exhaustively studied in =-=[5,6,9,11,21,13]-=-. Here we follow the approach of Etalle, Bossi, and Cocco [13]. 4 Simple group_set queries The most intuitive (and modular) way of carrying out aggregate queries is to first collect all the answers to... |

42 |
Norms on terms and their use in proving universal termination of a logic program
- Bossi, Cocco, et al.
(Show Context)
Citation Context ...on 3. A well-moded program is called well-terminating iff all its LD-derivations starting in a well-moded query are finite. Termination of (well-moded) logic programs has been exhaustively studied in =-=[5,6,9,11,21,13]-=-. Here we follow the approach of Etalle, Bossi, and Cocco [13]. 4 Simple group_set queries The most intuitive (and modular) way of carrying out aggregate queries is to first collect all the answers to... |

40 |
Automatic Generation of Mode Declarations for Prolog Programs (draft
- Mellish
- 1981
(Show Context)
Citation Context ... allowed to construct set-terms by “grouping” all instantiations of a term in the body of a rule, but they do not use aggregate subgoals explicitly. 13Moded Logic Programming is well-researched area =-=[18,4,7,22]-=-. However, to our best knowledge the modes has been never applied to aggregates. We also extend the standard definition of a mode to include the notion of local variables. By incorporating the mode sy... |

32 |
Sets and negation in a logical database language (LDLl
- Beeri
- 1987
(Show Context)
Citation Context ...her to express the statements we needed nor to demonstrate the correctness of Tulip rules containing aggregates. In particular, although grouping have been extensively studied in the past (see, e.g., =-=[19,14,8]-=-, and the Related Work section for further details), these approaches make strong assumptions on variable sharing we could not satisfy (in a grouping goal, non-aggregate variables may not be shared wi... |

32 | log}: A logic programming language with finite sets
- Dovier, Omodeo, et al.
- 1991
(Show Context)
Citation Context ...ves duplicates from m. Introducing (multi)sets to a pure logic programming language (i.e. not relying on a CLP scheme) is also a well-researched area. From the most prominent proposals, Dovier et al. =-=[13]-=- propose an extended logic programming language called {log} (read “setlog”) in which sets are first-class citizens. The authors introduce the basic set operations like set membership ∈ and set equali... |

28 | Termination of well-moded programs
- Etalle, Bossi, et al.
- 1999
(Show Context)
Citation Context |

6 |
Extended relational algebra and relational calculus with set-valued attributes and aggregate functions
- Özsoyoˇglu, Özsoyoˇglu, et al.
- 1987
(Show Context)
Citation Context ...f all relations. In his work, Klug eliminates the so called unsafe expressions that generate infinite number of tuples. This motivates the use of well-termination in our approach. Özsoyoˇglu et al in =-=[20]-=- further extends Klug’s algebra and calculus with set-valued attributes. Using set primitives as an alternative to using aggregate subgoals is also the approach used by Abiteboul and Beeri in [1]. How... |

5 |
Termination Proofs for Logic Programs, volume 446 of LNAI
- Plumer
- 1990
(Show Context)
Citation Context |

5 | Core TuLiP Logic Programming for Trust Management
- Czenko, Etalle
- 2007
(Show Context)
Citation Context ...l in practice, and paramount in database systems. In fact, the reason why we address the problem here is of a practical nature: we are developing a language for trust management [5,7,18] called TuLiP =-=[8,9,10]-=-. TuLiP is based on (partially function-free) moded logic programming, in which a logic program is augmented with an indication of which are the input and the output positions of each predicate. Modes... |

4 | A Logic Language based on GAMMA-like Multiset Rewriting
- Ciancarini, Fogli, et al.
(Show Context)
Citation Context ...ss citizens. The authors introduce the basic set operations like set membership ∈ and set equality = along with their negative counterparts /∈ and 6=. Concerning multisets directly, Ciancarini et al. =-=[6]-=- show how to extend a logic programming language with multisets. They strictly follow the approach of Dovier et al. [13]. Important to notice here, is that these earlier works of Dovier et al. and Cia... |

3 | Trust management in P2P systems using standard TuLiP
- Czenko, Doumen, et al.
- 2008
(Show Context)
Citation Context ...l in practice, and paramount in database systems. In fact, the reason why we address the problem here is of a practical nature: we are developing a language for trust management [5,7,18] called TuLiP =-=[8,9,10]-=-. TuLiP is based on (partially function-free) moded logic programming, in which a logic program is augmented with an indication of which are the input and the output positions of each predicate. Modes... |

1 |
TuLiP : Reshaping Trust Management
- Czenko
- 2009
(Show Context)
Citation Context ...l in practice, and paramount in database systems. In fact, the reason why we address the problem here is of a practical nature: we are developing a language for trust management [5,7,18] called TuLiP =-=[8,9,10]-=-. TuLiP is based on (partially function-free) moded logic programming, in which a logic program is augmented with an indication of which are the input and the output positions of each predicate. Modes... |

1 |
Approximations, Stable Operators, WellFounded Operators
- Denecker, Marek, et al.
- 2001
(Show Context)
Citation Context ... of the well-founded and stable model semantics for logic programs with aggregates (called ultimate well-founded and stable semantics). In their approach, Denecker et al. use the Approximation Theory =-=[11]-=-. The work of Denecker et al. is continued and further extended by Pelov et al. [20]. In the second approach, where the grouping is separated from aggregation (as in our approach), the grouping operat... |