welcome: please sign in
location: Diff for "dlt/dltManual"
Differences between revisions 1 and 14 (spanning 13 versions)
Revision 1 as of 2006-02-28 10:35:53
Size: 93
Comment:
Revision 14 as of 2006-03-03 20:27:04
Size: 9934
Comment:
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
Inserisci una descrizione per dlt/dltManual ||<tablewidth="100%":>'''DLT USER MANUAL'''||

 
=== Overview ===

DLT is a front-end for disjunctive datalog, extending the DLV system with Template predicates. Template predicates can be seen as a way to define intensional predicates by means of a subprogram, where the subprogram is generic and reusable as many times is necessary. The language implemented by the DLT system is named DLP^T^.[[BR]]

More information (including an online version of this manual and an online tutorial) and the executable program for Linux platform are available at the DLT homepage (http://gibbi.com).[[BR]]

=== Chapter 1. Getting Started ===

You can invoke the DLT system directly from the command-line, after the prompt of the system, as well the DLV system.

'''Note:''' All the DLV options can be supplied at the command line.

If you do not specify any options or files, DLT will just print some informational output and an empty model ({ }):

 {{{ $ }}}'''{{{dlt }}}'''

 {{{ DLV with Templates [build BEN/Oct 29 2003 gcc 3.2.2 (Mandrake Linux 9.1 3.2.2-3mdk)] }}}

 {{{ {} }}}

The first line shows, first of all, the name of the executable program (DLT), then it gives information about the version of the executable program, the date when the binary was built and the identifier of the compiler. The identifier {{{BEN}}}, which stands for "benchmark version".

'''Note:''' Versions other than {{{BEN}}} should only be used for development purposes!

Usually, you will not have to bother with these gory details, but please include this information when you are reporting a bug or asking for support.

If you do not want to see this status line, use the -silent option, which suppresses various informational output and blank lines.

 {{{ $ }}}'''{{{dlt -silent}}}'''

 {{{ {} }}}

    

From now on, all examples will include the {{{-silent}}} option.

=== Chapter 2. DLP^T Language ===

DLT’s native language is ''DLV'' extended with Template predicates. We remember that DLV’s native language is ''Disjunctive Datalog'' extended with constraints, true negation, aggregates and queries.

===== Section 2.1. Template Definition =====

A template definition D consists of a template header and an associated DLP^T^ subprogram closed into parenthesis curly braces.

'''Example 2-1.''' The following is a template definition:

 '''{{{ #template }}}'''{{{max[p(1)](1) }}}

 '''{{{ { }}}'''

 {{{ max(X) :- p(X), not exceeded(X). }}}

 {{{ exceeded(X) :- p(X), p(Y), Y > X. }}}

 '''{{{ } }}}'''

This template introduces a generic template program, defining the predicate max, intended to compute the maximum value over the domain of a generic unary predicate p. In this example we have that

 '''{{{ #template }}}'''{{{max[p(1)](1) }}}

is the template header, and

 '''{{{ { }}}'''

 {{{ max(X) :- p(X), not exceeded(X).}}}

 {{{ exceeded(X) :- p(X), p(Y), Y > X.}}}

 '''{{{ } }}}'''

is a DLP^T^ subprogram. ''max'' is the template name; ''p'' is a predicate name, called ''formal predicate''. The arity of formal predicate ''p'' is 1 and the ''output arity'' of template definition is 1.

'''Note:''' The DLP^T^ subprogram may contain disjunctive rules, constraints, weak constraints, aggregates, built-in predicates, negative literals, true negation, template atoms (or invocations), and it do not contains template definitions.

'''Example 2-2.''' Wrong Template Definition

The following is not a valid template definition:

 '''{{{ #template }}}'''{{{wrong_definition[p(1)](1) }}}

 '''{{{ { }}}'''

 '''{{{ template }}}'''{{{max[h(1)](1) }}}

 {{{ < }}}'''{{{other rules}}}'''{{{ > }}}

 '''{{{ } }}}'''

===== Section 2.2. Template Atom =====

A template definition may be instantiated as many times as necessary, trough ''template atoms''. The template atom or ''invocation'' consists of a template name, a list of atom and a list of variables and/or constants (literal constants and numerical constants).

'''Example 2-3.''' The followings are template atoms:

 {{{ max[weight(}}}'''{{{*}}}'''{{{)](M) }}}

 {{{ max[student($,Sex,}}}'''{{{*}}}'''{{{)](Age) }}}

''max'' is the template name; ''weight'' and ''student'' are predicate names, called ''actual predicates''; variables and constants are called ''standard'' terms (''Sex'' is a standard term); the dollar ‘$’ symbol is called ''projection term'' and the symbol ‘*’ is called ''parameter term''. ''M'' and ''Age'' are a list of usual terms (i.e. either variables or constants), and are called ''output lists''.

We note that the template definitions may be unified with a template atom in many ways. The above example contains a plain invocation (max[weight(*)](M)), and a compound invocation (max[ student($,Sex,*) ](Age)). Intuitively, projection terms (‘$’ symbols) are intended in order to indicate attributes of an actual predicate which have to be ignored. A standard term (a constant or a variable) within an actual atom indicates a ‘group-by’ attribute, whereas parameter terms (‘*’ symbols) indicate attributes to be considered as parameter.

For example, the template atom ''max[student($,Sex,*)](Age)'' allows to employ the definition of the template predicate ''max'' on a ternary predicate ''student'', discarding the first attribute of ''student'', and grouping by values of the second attribute. The intuitive meaning of this invocation is to define a predicate computing the student with maximum value of the ‘Age’ attribute (the third attribute of the ''student'' predicate), grouped by the ‘Sex’ attribute (the second one), ignoring the first attribute. The computed values of ''Age'' are returned through the output list.

'''Example 2-4.''' We consider the following EDB:

 {{{ person(riccy,f,26). }}}

 {{{ person(kali,f,26). }}}

 {{{ person(peppe,m,26). }}}

 {{{ person(gibbi,m,29). }}}

 {{{ person(paddy,f,27). }}}

it represents a set of persons of which it is known name, sex and age. We consider the template definition of ''max'' given in Example 2-1. The following:

 {{{ older_sex(Name,Sex,Age):- max[person($,Sex,*)](Age), }}}

 {{{ person(Name,Sex,Age). }}}

is a template atom that compute the oldest person with grouping on the sex attribute, that is the person of age greater than female sex and that one of male sex. Launching dlt from command line, as it follows:

 {{{ $ dlt -silent -nofacts programFileName }}}

we obtain the model

 {{{ {older_sex(paddy,f,27),older_sex(gibbi,m,29)} }}}

Therefore paddy is the greatest person of female sex, while gibbi is the greateest person of male sex.

===== Section 2.3. Negative Rules with Template Atoms and True Negation =====

Template atoms can be used also as negated and negative atoms in the generic rules of the program. Then we can use a template atom after the “negation as failure” symbol ('''not''') as it happens for the usual atoms.

'''Example 2-5.''' The following is an example of negated and negative template atom, respectively.

 '''{{{ not }}}'''{{{max[student(Sex,$,*)](Age) }}}

Negation for template atoms is treated as well negation for DLV atom. For more information about “negation as failure” and true negation we send back at the DLV user manual available at the DLV homepage (http://www.dbai.tuwien.ac.at/proj/dlv/).

===== Section 2.4. Template Definition with Global Predicates =====

Template programming can become a very useful feature in applications where it is necessary to compact repetitive pieces of code. We consider a planning program for the Space Shuttle Reaction Control System. Here is a sketch from the program:

'''{{{ #template }}}'''{{{ready_to_fire_conditions[propulsor_type(2)](2) }}}

'''{{{ GLOBAL }}}'''{{{time_slot, tank, is_pressurized_by, is_damaged }}}

{{{ { }}}

{{{ ready_to_fire_conditions(J,T) :- propulsor_type(J,R), }}}}

{{{ time_slot(T),tank(TK1,R), }}}}

{{{ tank(TK2,R), TK1 != TK2, }}}

{{{ is_pressurized_by(J,TK1,T), }}}

{{{ is_pressurized_by(J,TK2,T), }}}

{{{ not is_damaged(J). }}}

{{{ } }}}

the above template is employed to remove a set of repeated rules, which are changed this way

{{{ fire_jet(J,T) :- ready_to_fire_conditions[jet(*,*)](J,T). }}}

{{{ fire_vernier(J,T) :- ready_to_fire_conditions[vernier(*,*)](J,T). }}}


Chapter 3. Safety

Safety of variables in template atom follows the usual criterion. We suppose to have in the body of a generic rule a negated invocation; then must be valid the following condition must be valid:

 

Safety for the Negated Template Atom

Each variable occurring in the output list of the given invocation also occurs in at least one non-comparative positive literal in the body of the same rule (resp. the same constraint).

 

Example 3-1. Unsafe Rules and Constraints

u1: head(Y) :- not template_name[p(M,$,*)](const).

u2: :- not template_name[p($,M,*)](X).

u1 is unsafe because the variable ‘Y’ that appear in the head of the rule does not appear in at least a positive atom of the body of the same rule.

u2 is unsafe because the variable ‘X’ in the output list of the given invocation does not appear in at least a positive atom of the body of the same rule.

 

Example 3-2. Safe Rules and Constraints

s1: head(Y) :- not template_name[p(M,$,*)](const),

           predicate(_,_,Y).

s2: :- not template_name[p($,M,*)](X), predicate(_,_,X).

s3: head(X) :- not template_name[p(M,$,*)](Y),

          predicate(_,X,Y).

s4: :- template_name[p(M,$,*)](X).

s5: :- not template_name[p(M,$,*)](const).

 

DLT USER MANUAL

Overview

DLT is a front-end for disjunctive datalog, extending the DLV system with Template predicates. Template predicates can be seen as a way to define intensional predicates by means of a subprogram, where the subprogram is generic and reusable as many times is necessary. The language implemented by the DLT system is named DLPT.BR

More information (including an online version of this manual and an online tutorial) and the executable program for Linux platform are available at the DLT homepage (http://gibbi.com).[[BR]]

Chapter 1. Getting Started

You can invoke the DLT system directly from the command-line, after the prompt of the system, as well the DLV system.

Note: All the DLV options can be supplied at the command line.

If you do not specify any options or files, DLT will just print some informational output and an empty model ({ }):

  •  $ dlt 

     DLV with Templates [build BEN/Oct 29 2003 gcc 3.2.2 (Mandrake Linux 9.1 3.2.2-3mdk)] 

     {} 

The first line shows, first of all, the name of the executable program (DLT), then it gives information about the version of the executable program, the date when the binary was built and the identifier of the compiler. The identifier BEN, which stands for "benchmark version".

Note: Versions other than BEN should only be used for development purposes!

Usually, you will not have to bother with these gory details, but please include this information when you are reporting a bug or asking for support.

If you do not want to see this status line, use the -silent option, which suppresses various informational output and blank lines.

  •  $ dlt -silent

     {} 

From now on, all examples will include the -silent option.

Chapter 2. DLP^T Language

DLT’s native language is DLV extended with Template predicates. We remember that DLV’s native language is Disjunctive Datalog extended with constraints, true negation, aggregates and queries.

Section 2.1. Template Definition

A template definition D consists of a template header and an associated DLPT subprogram closed into parenthesis curly braces.

Example 2-1. The following is a template definition:

  •  #template max[p(1)](1) 

       { 

       max(X) :- p(X), not exceeded(X). 

       exceeded(X) :- p(X), p(Y), Y > X. 

       } 

This template introduces a generic template program, defining the predicate max, intended to compute the maximum value over the domain of a generic unary predicate p. In this example we have that

  •  #template max[p(1)](1) 

is the template header, and

  •  { 

     max(X) :- p(X), not exceeded(X).

     exceeded(X) :- p(X), p(Y), Y > X.

     } 

is a DLPT subprogram. max is the template name; p is a predicate name, called formal predicate. The arity of formal predicate p is 1 and the output arity of template definition is 1.

Note: The DLPT subprogram may contain disjunctive rules, constraints, weak constraints, aggregates, built-in predicates, negative literals, true negation, template atoms (or invocations), and it do not contains template definitions.

Example 2-2. Wrong Template Definition

The following is not a valid template definition:

  •  #template wrong_definition[p(1)](1) 

     { 

     template max[h(1)](1) 

      < other rules > 

     } 

Section 2.2. Template Atom

A template definition may be instantiated as many times as necessary, trough template atoms. The template atom or invocation consists of a template name, a list of atom and a list of variables and/or constants (literal constants and numerical constants).

Example 2-3. The followings are template atoms:

  •  max[weight(*)](M) 

     max[student($,Sex,*)](Age) 

max is the template name; weight and student are predicate names, called actual predicates; variables and constants are called standard terms (Sex is a standard term); the dollar ‘$’ symbol is called projection term and the symbol ‘*’ is called parameter term. M and Age are a list of usual terms (i.e. either variables or constants), and are called output lists.

We note that the template definitions may be unified with a template atom in many ways. The above example contains a plain invocation (max[weight(*)](M)), and a compound invocation (max[ student($,Sex,*) ](Age)). Intuitively, projection terms (‘$’ symbols) are intended in order to indicate attributes of an actual predicate which have to be ignored. A standard term (a constant or a variable) within an actual atom indicates a ‘group-by’ attribute, whereas parameter terms (‘*’ symbols) indicate attributes to be considered as parameter.

For example, the template atom max[student($,Sex,*)](Age) allows to employ the definition of the template predicate max on a ternary predicate student, discarding the first attribute of student, and grouping by values of the second attribute. The intuitive meaning of this invocation is to define a predicate computing the student with maximum value of the ‘Age’ attribute (the third attribute of the student predicate), grouped by the ‘Sex’ attribute (the second one), ignoring the first attribute. The computed values of Age are returned through the output list.

Example 2-4. We consider the following EDB:

  •  person(riccy,f,26). 

     person(kali,f,26). 

     person(peppe,m,26). 

     person(gibbi,m,29). 

     person(paddy,f,27). 

it represents a set of persons of which it is known name, sex and age. We consider the template definition of max given in Example 2-1. The following:

  •  older_sex(Name,Sex,Age):- max[person($,Sex,*)](Age), 

                               person(Name,Sex,Age). 

is a template atom that compute the oldest person with grouping on the sex attribute, that is the person of age greater than female sex and that one of male sex. Launching dlt from command line, as it follows:

  •  $ dlt -silent -nofacts programFileName 

we obtain the model

  •  {older_sex(paddy,f,27),older_sex(gibbi,m,29)} 

Therefore paddy is the greatest person of female sex, while gibbi is the greateest person of male sex.

Section 2.3. Negative Rules with Template Atoms and True Negation

Template atoms can be used also as negated and negative atoms in the generic rules of the program. Then we can use a template atom after the “negation as failure” symbol (not) as it happens for the usual atoms.

Example 2-5. The following is an example of negated and negative template atom, respectively.

  •  not max[student(Sex,$,*)](Age) 

Negation for template atoms is treated as well negation for DLV atom. For more information about “negation as failure” and true negation we send back at the DLV user manual available at the DLV homepage (http://www.dbai.tuwien.ac.at/proj/dlv/).

Section 2.4. Template Definition with Global Predicates

Template programming can become a very useful feature in applications where it is necessary to compact repetitive pieces of code. We consider a planning program for the Space Shuttle Reaction Control System. Here is a sketch from the program:

 #template ready_to_fire_conditions[propulsor_type(2)](2) 

 GLOBAL time_slot, tank, is_pressurized_by, is_damaged 

    { 

    ready_to_fire_conditions(J,T) :- propulsor_type(J,R), }

                                     time_slot(T),tank(TK1,R), }

                                     tank(TK2,R), TK1 != TK2, 

                                     is_pressurized_by(J,TK1,T), 

                                     is_pressurized_by(J,TK2,T), 

                                     not is_damaged(J). 

    } 

the above template is employed to remove a set of repeated rules, which are changed this way

 fire_jet(J,T) :- ready_to_fire_conditions[jet(*,*)](J,T). 

 fire_vernier(J,T) :- ready_to_fire_conditions[vernier(*,*)](J,T). 

Chapter 3. Safety

Safety of variables in template atom follows the usual criterion. We suppose to have in the body of a generic rule a negated invocation; then must be valid the following condition must be valid:

Safety for the Negated Template Atom

Each variable occurring in the output list of the given invocation also occurs in at least one non-comparative positive literal in the body of the same rule (resp. the same constraint).

Example 3-1. Unsafe Rules and Constraints

u1: head(Y) :- not template_name[p(M,$,*)](const).

u2: :- not template_name[p($,M,*)](X).

u1 is unsafe because the variable ‘Y’ that appear in the head of the rule does not appear in at least a positive atom of the body of the same rule.

u2 is unsafe because the variable ‘X’ in the output list of the given invocation does not appear in at least a positive atom of the body of the same rule.

Example 3-2. Safe Rules and Constraints

s1: head(Y) :- not template_name[p(M,$,*)](const),

  • predicate(_,_,Y).

s2: :- not template_name[p($,M,*)](X), predicate(_,_,X).

s3: head(X) :- not template_name[p(M,$,*)](Y),

  • predicate(_,X,Y).

s4: :- template_name[p(M,$,*)](X).

s5: :- not template_name[p(M,$,*)](const).

mwiki: dlt/dltManual (last edited 2010-10-26 10:19:44 by localhost)