All solutions concurrent predicates

Author(s): Manuel Carro (concurrency-safeness).

This module implements thread-safe aggregation predicates. Its use and results should be the same as those in the aggregates library, but several goals can use them concurrently without the interference and wrong results (due to implementation reasons) aggregates might lead to. This particular implementation is completely based on the one used in the aggregates library (whose original authors were Richard A. O'Keefe and David H.D. Warren).

Usage and interface

Documentation on exports

PREDICATE

Usage:ISOfindall(Template,Generator,List)

A special case of bagof, where all free variables in the Generator are taken to be existentially quantified. Safe in concurrent applications.

  • The following properties should hold at call time:
    (term_typing:nonvar/1)Generator is currently a term which is not a free variable.
  • The following properties should hold upon exit:
    (basic_props:term/1)Template is any term.
    (basic_props:callable/1)Goal is a term which represents a goal, i.e., an atom or a structure.
    (basic_props:list/1)Set is a list.
  • The following properties should hold globally:
    (native_props:is_det/1)All calls of the form findall(Template,Generator,List) are deterministic.
Meta-predicate with arguments: findall(?,goal,?).

PREDICATE

Usage:ISOsetof(Template,Goal,Set)

Finds the Set of instances of the Template satisfying the Generator. The set is in ascending order (see compare/3 for a definition of this order) without duplicates, and is non-empty. If there are no solutions, setof/3 fails. setof/3 may succeed in more than one way, binding free variables in the Generator to different values. This can be avoided by using existential quantifiers on the free variables in front of the Generator, using ^/2. E.g., in A^p(A,B), A is existentially quantified. Safe in concurrent apllications.

  • The following properties should hold at call time:
    (term_typing:nonvar/1)Goal is currently a term which is not a free variable.
  • The following properties should hold upon exit:
    (basic_props:term/1)Template is any term.
    (basic_props:callable/1)Goal is a term which represents a goal, i.e., an atom or a structure.
    (basic_props:list/1)Set is a list.
  • The following properties should hold globally:
    (basic_props:not_further_inst/2)Template is not further instantiated.

PREDICATE

Usage:ISObagof(Template,Generator,Bag)

Finds all the instances of the Template produced by the Generator, and returns them in the Bag in the order in which they were found. If the Generator contains free variables which are not bound in the Template, it assumes that this is like any other Prolog question and that you want bindings for those variables. This can be avoided by using existential quantifiers on the free variables in front of the Generator, using ^/2. Safe in concurrent applications.

  • The following properties should hold at call time:
    (term_typing:nonvar/1)Generator is currently a term which is not a free variable.
  • The following properties should hold upon exit:
    (basic_props:term/1)Template is any term.
    (basic_props:callable/1)Goal is a term which represents a goal, i.e., an atom or a structure.
    (basic_props:list/1)Set is a list.
  • The following properties should hold globally:
    (basic_props:not_further_inst/2)Template is not further instantiated.

Known bugs and planned improvements

  • Thread-safe setof/3 is not yet implemented.
  • Thread-safe bagof/3 is not yet implemented.