Package jason.stdlib
Class findall
java.lang.Object
jason.asSemantics.DefaultInternalAction
jason.stdlib.findall
- 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
-
Constructor Summary
Constructors Constructor Description findall()
-
Method Summary
Modifier and Type Method Description protected void
checkArguments(Term[] args)
java.lang.Object
execute(TransitionSystem ts, Unifier un, Term[] args)
Executes the internal action.int
getMaxArgs()
int
getMinArgs()
Term[]
prepareArguments(Literal body, Unifier un)
Prepare body's terms to be used in 'execute', normally it consist of cloning and applying each termMethods inherited from class jason.asSemantics.DefaultInternalAction
canBeUsedInContext, destroy, suspendIntention
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
findall
public findall()
-
-
Method Details
-
getMinArgs
public int getMinArgs()- Overrides:
getMinArgs
in classDefaultInternalAction
-
getMaxArgs
public int getMaxArgs()- Overrides:
getMaxArgs
in classDefaultInternalAction
-
prepareArguments
Description copied from interface:InternalAction
Prepare body's terms to be used in 'execute', normally it consist of cloning and applying each term- Specified by:
prepareArguments
in interfaceInternalAction
- Overrides:
prepareArguments
in classDefaultInternalAction
-
checkArguments
- Overrides:
checkArguments
in classDefaultInternalAction
- Throws:
JasonException
-
execute
public java.lang.Object execute(TransitionSystem ts, Unifier un, Term[] args) throws java.lang.ExceptionDescription copied from interface:InternalAction
Executes the internal action. It should return a Boolean or an Iterator. A true boolean return means that the IA was successfully executed. An Iterator result means that there is more than one answer for this IA (e.g. see member internal action). - Specified by:
execute
in interfaceInternalAction
- Overrides:
execute
in classDefaultInternalAction
- Throws:
java.lang.Exception
-