Here in this program, the sum function is made that adds the contents of list. The first segment ( i.e the Domains section ) defines or declares the space dynamically for integer list. Then the predicate sum is defined that takes integer list and a Integer as arguments. The next clause section provides the necessary reasoning and facts to find the solution to the problem. Here the predicate sum is called recursively until it gets the last element of the list which is the empty list itself and returns 0 if empty list is encountered. The add predicate else adds the first element to the solution repeatedly to find the solution.
int_list = integer*