HELP WHICH_VALUES                                  Aaron Sloman Oct 1996

This procedure has been introduced to replace "which" for use in
connection with the pattern prefix "!", described in HELP * READPATTERN

which_values(<variable list>, <list of patterns >) -> <list of bindings>

This is a bit like FOREVERY except that for each way that all the
patterns can consistently match items in the database it saves the
values of the variables specified in the first argument, and returns
a list of all the combinations of values.

The first argument is a list giving the variables for which you want all
the possible matching values to be included in the result OUT.

The second argument is a list of patterns, which should include some of
those variables as pattern variables. It's because the second argument
is a list of patterns that it has an extra pair of square brackets, even
though in this case the list contains only one pattern.

Both the variable list and the pattern list can be preceded by "!" to
make the variables work as lvars.

Examples:

    vars database;

    [[joe isa man]
     [jill isa woman]
     [joe lives_in london]
     [jill lives_in brighton]
     [bill isa man]
     [sue isa woman]
     [bill lives_in london]
     [sue lives_in paris]] -> database;
    database ==>

vars x, y;
which_values(! [?x ?y], ! [[?x lives_in ?y]])==>
** [[joe london] [jill brighton] [bill london] [sue paris]]

which_values(![?person], ! [[?person isa woman]])==>
** [[jill] [sue]]

;;; Now find where all the men live. This requires two patterns.

vars person, place;
which_values(
    ![?person ?place],
    ! [[?person isa man][ ?person lives_in ?place]])==>
** [[joe london] [bill london]]

Change the above to find where all the women live.

NB inside a procedure definition, change the "vars" declarations to
"lvars". See TEACH * MATCHES, HELP * LVARS.


--- $poplocal/local/help/which_values
--- Copyright University of Birmingham 1996. All rights reserved. ------
