Go to the first, previous, next, last section, table of contents.


Andorra execution

Author(s): Claudio Vaucheret, Francisco Bueno.

Version: 1.11#222 (2004/5/24, 13:8:7 CEST)

Version of last change: 1.7#144 (2001/11/12, 17:57:47 CET)

This package allows the execution under the Basic Andorra Model [War88]. The model classifies goals as a determinate goal, if at most one clause matches the goal, or nondeterminate goal, otherwise. In this model a goal is delayed until either it becomes determinate or it becomes the leftmost goal and no determinate goal is available. The implementation of this selection rule is based on the use of attributed variables [Hol92,Hol90].

In order to test determinacy we verify only the heads of clauses and builtins in the bodies of clauses before the first cut, if any. By default, determinacy of a goal is detected dynamically: when called, if at most one clause matches, it is executed; otherwise, it is delayed. For goals delayed the test is repeated each time a variable appearing in the goal is instantiated. In addition, efficiency can be improved by using declarations that specify the determinacy conditions. These will be considered for testing instead of the generic test on all clauses that can match.

As with any other Ciao package, the andorra computation rule affects only the module that uses the package. If execution passes across two modules that use the computation rule, determinate goals are run in advance within one module and also within the other module. But determinate goals of one module do not run ahead of goals of the other module.

It is however possible to preserve the computation rule for calls to predicates defined in other modules. These modules should obviously also use this package. In addition all predicates from such modules should imported, i.e., the directive :- use_module(module), should be used in this case instead of :- use_module(module,[...]). Otherwise calls to predicates outside the module will only be called when they became the leftmost goal.

Usage and interface (andorra)

Documentation on new declarations (andorra)

DECLARATION: determinate/2:

:- determinate(Pred, Cond).

Declares determinacy conditions for a predicate. Conditions Cond are on variables of arguments of Pred. For example, in:

:- determinate(member(A,B,C), ( A ?= term(B,[1])  ; C?=[_|_]) ).

member(A,[A|B],B).
member(A,[B|C],[B|D]) :-
        A==B,
        member(A,C,D).

the declaration states that a call member(A,B,C) is determinate when either A doesn't unify with the first argument of B or C doesn't unify with [_|_].

Usage: :- determinate(Pred, Cond).

Documentation on exports (andorra)

REGTYPE: detcond/1:

Defined by:

detcond(ground(X)) :-
        var(X).
detcond(nonvar(X)) :-
        var(X).
detcond(instatiated(A,Path)) :-
        var(A),
        list(Path,int).
detcond(?\=(Term1,Term2)) :-
        path(Term1),
        path(Term2).
detcond(?=(Term1,Term2)) :-
        path(Term1),
        path(Term2).
detcond(Test) :-
        test(Test).

Usage: detcond(X)

REGTYPE: path/1:

Defined by:

path(X) :-
        var(X).
path(X) :-
        list(X,int).

Other information (andorra)

The andorra transformation will include the following predicates into the code of the module that uses the package. Be careful not to define predicates by these names:


Go to the first, previous, next, last section, table of contents.