This paper invstigates the optimisation of aggregation functions in the context of computationally complete programming languages and aims to generalise and porvide a unifying formal foundation for previous work.Wde define a 'fold' operator #pha# over collection types in terms of which operations such as selection.proejections such as sum,max and min.We introduce two equivaliences for #pha# which respectively govern the ocmmuting and colalescing of applciations of #pha#.Form htese tow equivalences wwe then formally drerive equievalences governing the commuting and coalescing of iteration operations over collectios,the mapping of aggregation functios over grouped collections,the introduction and elimination of aggregation funcitons,and the promotion of aggregation funcitons through iteration operaitons.We also show how osme of these equivalences cna be used to optimise comprehensions,a high-levle query construct supported by man data base languages.
展开▼