Package jason.stdlib

Class findall

java.lang.Object
All Implemented Interfaces:
InternalAction, java.io.Serializable

@Manual(literal=".findall(term,query,result)",
        hint="builds a List of all instantiations of referred term which make query a logical consequence of the agent\'s BB",
        argsHint={"the variable or structure whose instances will \"populate\" the list","the formula used to find literals in the belief base","the result list populated with found solutions for the query"},
        argsType={"variable or structure","logical formula","list"},
        examples={".findall(X,a(X),L): assuming current BB with {a(30),a(20),b(1,2),b(3,4),b(5,6)}, L unifies with [30,20]",".findall(c(Y,X),b(X,Y),L): assuming current BB with {a(30),a(20),b(1,2),b(3,4),b(5,6)}, L unifies with [c(2,1),c(4,3),c(6,5)]",".findall(r(X,V1,V2), (a(X) & b(V1,V2) & V1*V2 < X), L): assuming current BB with {a(30),a(20),b(1,2),b(3,4),b(5,6)}, L unifies with [r(30,1,2),r(30,3,4),r(20,1,2),r(20,3,4)]",".findall(X, c(X), L): assuming current BB with {c(100),c(200),c(100)}, L unifies with [100,200,100]"},
        seeAlso={"jason.stdlib.count","jason.stdlib.setof"})
public class findall
extends DefaultInternalAction

Internal action: .findall(Term,Query,List).

Description: builds a List of all instantiations of Term which make Query a logical consequence of the agent's BB.

Parameters:

  • + term (variable or structure): the variable or structure whose instances will "populate" the list.
  • + query (logical formula): the formula used to find literals in the belief base; is has the same syntax as the plan context.
  • +/- result (list): the result list populated with found solutions for the query.

Examples assuming the BB is currently {a(30),a(20),b(1,2),b(3,4),b(5,6),c(100),c(200),c(100)}:

  • .findall(X,a(X),L): L unifies with [30,20].
  • .findall(c(Y,X),b(X,Y),L): L unifies with [c(2,1),c(4,3),c(6,5)].
  • .findall(r(X,V1,V2), (a(X) & b(V1,V2) & V1*V2 < X), L): L unifies with [r(30,1,2),r(30,3,4),r(20,1,2),r(20,3,4)].
  • .findall(X,c(X),L): L unifies with [100,200,100].
  • See Also:
    count, setof, Serialized Form