DLV-Complex 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 command-line 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 DLV-Complex 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
DLV-EX
website.
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
2-1. #list
2-2. #last
2-3. #length
2-4. #head
2-5. #tail
2-6. #append
2-7. #select
2-8. #delete
2-9. #delNth
2-10. #member
2-11. #reverse
2-12. #memberNth
2-13. #insNth
2-14. #insLast
2-15. #subList
2-16. #flatten
3-1. #set
3-2. #card
3-3. #union
3-4. #intersection
3-5. #difference
3-6. #delete
3-7. #member
3-8. #insert
3-9. #subSet
-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 DLV-Complex program. It is enough to add as preamble the following
string:
#nofdcheck.
% disable finite-domain check
In order to exploit the built-in functions for list
and set manipulation collected in the provided (“ListAndSet”)
library, you must tell the system, while writing down a DLV-Complex 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 DLV-Complex stays. Furthermore, with the
following command-line option you can tell the system where to find libraries,
if somewhere else.
-libpath=path1[:path2[:...]] |
Set the paths including external built-in libraries.
|
You are strongly suggested to have a look at the
DLV-Complex tutorial for more details.
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);
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.
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.
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
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
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]
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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]
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);
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.
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.
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.
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.
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.
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.
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.
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.
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
The
following built-ins are available in order to ease the task of writing
DLV-Complex programs. Most of them are already available in DLV, and their
meaning is straightforward. It is worth remembering that, in general, these
built-ins 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 X-1=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=X-Y is true, iff
Z=X-Y 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 built-ins among terms. |
<= |
|
> |
|
>= |
|
!= [or <>] |
|
= [or ==, deprecated] |