Re: [PRD/FLD] aggregates

Hi Michael,

Thanks for getting the ball rolling.  I think this should work for PRD, 
but let me check that I understand your proposal.  An example rule for 
computing the average salary of employees grouped by department would be 
something like:

Forall ?deptno ?sal ?empId (
  AvgDeptSal(?deptno avg(?sal [ ?deptno ] | Emp(?empId ?deptno ?sal)))
)

And if PRD doesn't support group by (I don't know of any PR engines that 
do), we can simulate using

Deptno(?deptno) :- Emp(?empId ?deptno ?sal)
AvgDeptSal(?deptno ?avgSal) :- And( Deptno(?deptno) ?avgSal = avg(?sal | 
Emp(?empId ?deptno ?sal)))

Are the aggfuns the usual min, max, sum, avg, count?  (BTW, I don't 
think count needs a Var). 
Also nice to include list as an aggfun, that just returns a list of var 
bindings.  (Of course, we need to add lists)

Michael Kifer wrote:
> I sent this message at the end of the last f2f, but it doesn't seem to have been
> delivered. Only today I got a reply that it was rejected by the server.
> Anyway, here it goes again:
>
>     Since we did not have time to discuss the aggregates, let's start it by
>     email.  Basically, an aggregate is a term that includes a comprehension.
>     In addition, there is a need to be able to GROUP BY, as in databases.  (I
>     do not know if this latter thing is needed for PRD.)
>
>     So, the syntax I was thinking about is:
>
> 	aggfun{Var [ GroupvarList ] | CondFormula}
>
>     The symbols {,},[,],| here are the actual symbols, not metasymbols.
>     Var is the comprehension variable, i.e., {Var | CondFormula}.
>     GroupvarList is the list of vars to group by. The entire piece
>     "[ GroupvarList ]" is optional.
>
>     Note that I need the above general form for FLD. For PRD we might need
>     something less general. We just need to make sure that the
>     syntaxes are compatible.
>
>
> 	    --michael  
>
>   

Received on Monday, 13 October 2008 00:26:40 UTC