Attachment 'dlvcomplexguide20100303.html'
DownloadIntroduction
DLVComplex is an Answer Set Programming system based on DLV. It fully supports Disjunctive Logic Programming with function symbols under Answer Set Semantics, and provides also support for complex terms such as lists and sets, as well as a rich library for their manipulation.
The system is shipped as a commandline binary, and it works exactly as DLV. For more details about the use of such systems, we refer to the DLV official website and the material (manuals, tutorials, examples) which can be easily found there. This quick reference guide provides the necessary information about what DLVComplex offers in addition to standard DLV features. The interested reader may found also useful information about the external predicates framework exploited in order to embed functions into DLV on DLVEX website.
Installation Guide
Just download the DLVComplex executable and, if you need it, the list and set library, that suit your operating system. You can execute DLVComplex as any other commandline tool. The only detail you must take care of is the position of the list and set library, if the logic program you want to compute imports it. By default, libraries are supposed to be found in ./LIB folder, where “.” is the folder where the executable binary of DLVComplex stays. You can refer to the instructions below in order to modify this.
Table of Contents
1. Synopsis and System Options
2.1. #list(Elem_1,..., Elem_n, List)
2.2. #last(List, Elem)
2.3. #length(List, Int)
2.4. #head(List, Elem)
2.5. #tail(List1, List2)
2.6. #append(List1, List2, List3)
2.7. #select(Elem, List, Rest)
2.8. #delete(List1, Elem, List2)
2.9. #delNth(List1, Pos, List2)
2.10. #member(Elem, List)
2.11. #reverse(List1, List2)
2.12. #memberNth(List, Pos, Elem)
2.13. #insNth(List1, Elem, Pos, List2)
2.14. #insLast(List1, Elem, List2)
2.15. #subList(Sublist, List)
2.16. #flatten(List1, List2)
3.1. #set(Elem_1,..., Elem_n, Set)
3.2. #card(Set, Int)
3.4. #intersection(Set1, Set2, Set3)
3.5. #difference(Set1, Set2, Set3)
3.6. #delete(Set1, Elem, Set2)
3.7. #member(Elem, Set)
3.8. #insert(Set1, Elem, Set2)
3.9. #subSet(Subset, Set)
A. List of Examples
21. #list
22. #last
23. #length
24. #head
25. #tail
26. #append
27. #select
28. #delete
29. #delNth
210. #member
211. #reverse
212. #memberNth
213. #insNth
214. #insLast
215. #subList
216. #flatten
31. #set
32. #card
33. #union
34. #intersection
35. #difference
36. #delete
37. #member
38. #insert
39. #subSet
Chapter 1. Synopsis and System Options
You can invoke DLVComplex directly on the commandline (for a brief list of commandline options, specify “help”).
In addition to the DLV standard ones (please refer to the official DLV documentation, see the website here), the following options allows for modifying the behavior of the system in presence of complex terms.
nofdcheck 
Skip finite domain check. 
MAXNL=<N> 
Maximum nesting level allowed for function terms. Default is '0' (no limits). 
If you don’t want to specify the “nofdcheck” option on the command line, you can do it within a DLVComplex program. It is enough to add as preamble the following string:
#nofdcheck. % disable finitedomain check
In order to exploit the builtin functions for list and set manipulation collected in the provided (“ListAndSet”) library, you must tell the system, while writing down a DLVComplex program, to include the library itself. It is enough to add the line
#include<ListAndSet>
at the very beginning of the program (as a preamble). By default, libraries are supposed to be found in ./LIB folder, where “.” is the folder where the executable binary of DLVComplex stays. Furthermore, with the following commandline option you can tell the system where to find libraries, if somewhere else.
libpath=path1[:path2[:...]] 
Set the paths including external builtin libraries. 
You are strongly suggested to have a look at the DLVComplex tutorial for more details.
Chapter 2. List builtin functions
A list is a collection of elements, in case empty, where the order of elements is meaningful; so, two lists having the same elements but with a different order are considered to be different.
There are two ways to represent a list:
· listing its elements, comma separated, in brackets: [t1, t2, . . . , tn] where each element is a term (in case a list);
· with an “à la Prolog” notation: [head  tail] where head is a term (in case a list) while tail needs to be a list (in case empty);
2.1. #list(Elem_1,..., Elem_n, List)
Return List whose elements are ordinately Elem_1,..., Elem_n
Pattern
iro (i.e. zero or more input arguments and then an output argument)
Elem_1,..., Elem_n terms must be bound to a constant value.
2.2. #last(List, Elem)
Return in Elem the last element of List.
Pattern
io (i.e. one input argument and one output argument)
The List term must be bound to a constant value.
2.3. #length(List, Int)
Return in Int the number of elements of List.
Pattern
io (i.e. one input argument and one output argument)
The List term must be bound to a constant value.
List = [a,b,c] > Int = 3
2.4. #head(List, Elem)
Return in Elem the first element of List.
Pattern
io (i.e. one input argument and one output argument)
The List term must be bound to a constant value.
List = [a,b,c] > Elem = a
2.5. #tail(List1, List2)
Return in List2 the list obtained deleting the first element from List1.
Pattern
io (i.e. one input argument and one output argument)
The List1 term must be bound to a constant value.
List1 = [a,b,c] > List2 = [b,c]
2.6. #append(List1, List2, List3)
Append List2 to List1 and return the result in List3.
Pattern
iio (i.e. two input arguments and one output argument)
List1 and List2 terms must be bound to a constant value.
2.7. #select(Elem, List, Rest)
Select the first occurrence of Elem from List leaving Rest.
Pattern
iio (i.e. two input arguments and one output argument)
Elem and List terms must be bound to a constant value.
2.8. #delete(List1, Elem, List2)
Delete all occurrences of Elem in List1 and return the result in List2.
Pattern
iio (i.e. two input arguments and one output argument)
List1 and Elem terms must be bound to a constant value.
2.9. #delNth(List1, Pos, List2)
Delete the element of List1 in position Pos and return the result in List2.
Pattern
iio (i.e. two input arguments and one output argument)
List1 and Pos terms must be bound to a constant value.
2.10. #member(Elem, List)
Check whether Elem occurs in List.
Pattern
ii (i.e. two input arguments)
Both Elem and List terms must be bound to a constant value.
2.11. #reverse(List1, List2)
Reverse the order of the elements in List1 and return the result in List2.
Pattern
io (i.e. one input argument and one output argument)
The List1 term must be bound to a constant value.
2.12. #memberNth(List, Pos, Elem)
Return the element Elem in position Pos in List.
Pattern
iio (i.e. two input arguments and one output argument)
List and Pos terms must be bound to a constant value.
2.13. #insNth(List1, Elem, Pos, List2)
Insert the element Elem in the position Pos of List1 and return the result in List2.
Pattern
iiio (i.e. three input arguments and one output argument)
List1, Elem and Pos terms must be bound to a constant value.
2.14. #insLast(List1, Elem, List2)
Insert the element Elem in the last position of List1 and return the result in List2.
Pattern
iio (i.e. two input arguments and one output argument)
List1 and Elem terms must be bound to a constant value.
2.15. #subList(Sublist, List)
Check whether Sublist is a sublist of List.
Pattern
ii (i.e. two input arguments)
Sublist and List terms must be bound to a constant value.
2.16. #flatten(List1, List2)
Flatten out all nested lists in List1 and return the result in List2, where only individual elements will occurr.
Pattern
io (i.e. one input argument and one output argument)
The List1 term must be bound to a constant value.
List1 = [[a,b],c,[d,[e,f,g]]] > List2 = [a,b,c,d,e,f,g]
Chapter 3. Set builtin functions
A set is a collection of elements, in case empty, where the order of elements is meaningless; so, two lists with the same elements but with a different order represent the same set. Furthermore duplicate elements are not allowed.
A set is represented listing its elements, comma separated, in braces: {t1, t2, . . . , tn} where each element is a term (in case a set);
3.1. #set(Elem_1,..., Elem_n, Set)
Return Set whose elements are Elem_1,..., Elem_n
Pattern
iro (i.e. zero or more input arguments and then an output argument)
Elem_1,..., Elem_n terms must be bound to a constant value.
3.2. #card(Set, Int)
Return in Int the number of elements of Set.
Pattern
io (i.e. one input argument and one output argument)
The Set term must be bound to a constant value.
3.3. #union(Set1, Set2, Set3)
Set3 is the set resulting from the union of Set1 with Set2.
Pattern
iio (i.e. two input arguments and one output argument)
Set1 and Set2 terms must be bound to a constant value.
3.4. #intersection(Set1, Set2, Set3)
Set3 is the set resulting from the intersection of Set1 with Set2.
Pattern
iio (i.e. two input arguments and one output argument)
Set1 and Set2 terms must be bound to a constant value.
3.5. #difference(Set1, Set2, Set3)
Set3 is the set resulting from the difference between Set1 and Set2.
Pattern
iio (i.e. two input arguments and one output argument)
Set1 and Set2 terms must be bound to a constant value.
3.6. #delete(Set1, Elem, Set2)
Delete the element Elem in Set1 and return the result in Set2.
Pattern
iio (i.e. two input arguments and one output argument)
Set1 and Elem terms must be bound to a constant value.
3.7. #member(Elem, Set)
Check whether Elem occurs in Set.
Pattern
ii (i.e. two input arguments)
Both Elem and Set terms must be bound to a constant value.
3.8. #insert(Set1, Elem, Set2)
Insert Elem in Set1 and return the result in Set2.
Pattern
iio (i.e. two input arguments and one output argument)
Set1 and Elem terms must be bound to a constant value.
3.9. #subSet(Subset, Set)
Check whether Subset is a subset of Set.
Pattern
ii (i.e. two input arguments)
Both Subset and Set terms must be bound to a constant value.
Subset = {c,f}
Set = {a,b,c,e,f,g} > true
Chapter 4. List of Arithmetic and Comparison builtins
The following builtins are available in order to ease the task of writing DLVComplex programs. Most of them are already available in DLV, and their meaning is straightforward. It is worth remembering that, in general, these builtins requires “#maxint” (the upper integer limit) to be set, by means of either the option “N=x” on the command line, or the “#maxint=x.” preamble.
We refer to the DLV manual for further information.
#int 
#int(X) is true, iff X is a known integer (i.e. 0 <= X <= #maxint). 
#succ 
#succ(X, Y) is true, iff X+1=Y holds. 
#prec 
#prec(X, Y) is true, iff X1=Y holds. 
#mod 
#mod(X,Y,Z) is true, iff X/Y has remainder Z. 
+ 
+(X,Y,Z), or alternatively: Z=X+Y is true, iff Z=X+Y holds. 
 
(X,Y,Z), or alternatively: Z=XY is true, iff Z=XY holds. 
* 
*(X,Y,Z), or alternatively: Z=X*Y is true, iff Z=X*Y holds. 
/ 
/(X,Y,Z), or alternatively: Z=X/Y is true, iff Z=X/Y holds. 
< 
Comparisons builtins among terms. 
<= 

> 

>= 

!= [or <>] 

= [or ==, deprecated] 
Attached Files
You are not allowed to attach a file to this page.