Design and Implementation of Aggregate Functions in the DLV System