Package jason.stdlib


package jason.stdlib
Internal actions of Jason.

BDI

Belief base

  • abolish: removes some beliefs.
  • belief: consults some beliefs.
  • findall: finds all answers for a query.
  • setof: finds a set of answers for a query.
  • count: counts the number of solutions of some query.
  • namespace: checks whether the argument is a name space.
  • relevant_rules: gets a list of rules.
  • list_rules: prints out the rules in the current belief base.

Plan Library

Communication

  • send: send messages.
  • broadcast: broadcast messages.
  • my_name: get the agent's name.
  • all_names: get the names of all agents in the system.
  • df_register: register a service in the Directory Facilitator.
  • df_deregister: removes a service in the Directory Facilitator.
  • df_search: search for a service in the Directory Facilitator.
  • df_subscribe: subscribe for new providers of a service in the Directory Facilitator.

Lists, Sets and other collections

  • member: list members.
  • length: size of lists.
  • empty: check whether the list is empty.
  • concat: concat lists.
  • delete: delete members of a lists.
  • reverse: reverse lists.
  • shuffle: shuffle the elements of a list.
  • nth: nth element of a lists.
  • max: maximum value of a lists.
  • min: minimum value of a lists.
  • sort: sort lists.
  • list: check whether an argument is a list.
  • suffix: suffixes of a list.
  • prefix: prefixes of a list.
  • sublist: sublists of a list.
  • difference: difference of sets.
  • intersection: intersection of sets.
  • union: union of sets.

Java Sets

Java Sets can be manipulated in Jason by some internal actions (these sets are represented by a variable). Example:
.set.create(S);                // S = {}
.set.add(S,a);                 // S = {a}
.set.add_all(S,[5,b,p(2),a]);  // S = {5,a,b,p(2)}
.set.remove(S,b);              // S = {5,a,p(2)}
.set.union(S,[a,1]);           // S = {1,5,a,p(2)}
.length(S,X);                  // X = 4
.type(S,T);                    // T = set
.set.difference(S,[1,a]);      // S = {5,p(2)}
.findall(K, .member(K,S), LL)  // LL = [5,p(2)]
.set.add(S,5);
.set.intersection(S,V);        // S = {5}
for ( .member(V,S) ) {         // iteration
   .print(K,V);
}.
.set.clear(S);                 // S = {}

Java Queues

Java Queues can be manipulated in Jason by some internal actions (these queues are represented by a variable). Example:
.queue.create(Q);                // Q = []
.queue.add(Q,a);                 // Q = [a]
.queue.add(Q,b);                 // Q = [a, b]
.queue.add_all(Q,[c,d,e]);       // Q = [a, b, c, d, e]
.queue.head(Q,H);                // H = a
.queue.remove(Q,H);              // H = a, Q = [b, c, d, e]
.length(Q,X);                    // X = 4
.type(Q,T);                      // T = queue
for ( .member(V,Q) ) {           // iteration
   .print(V);
}.
.queue.clear(Q);

.queue.create(Q,priority);       // Q = [] queue with priority (the queue is kept sorted)
.queue.add(Q,d);                 // Q = [d]
.queue.add(Q,c);                 // Q = [c, d]
.queue.add_all(Q,[b,d,a]);       // Q = [a, b, c, d, e]
.queue.head(Q,H);                // H = a

Java Maps

Java Maps can be manipulated in Jason by some internal actions (these maps are represented by a variable). Example:
.map.create(M);                  // M = {}
.map.put(M,a,10);                // M = {a->10}
.map.put(M,b,ok);                // M = {a->10, b->ok}
.map.put(M,a,20);                // M = {a->20, b->ok}
.length(M,X);                    // X = 2
.type(M,T);                      // T = map
.map.key(M,a)                    // true
.map.key(M,V)                    // unifies V with all keys of M
.map.value(M,10)                 // true
.map.value(M,V)                  // unifies V with all values of M
.findall(K, .map.key(M,K), LL)   // LL = [a,b]
.findall(V, .map.value(M,V), LL) // LL = [20,ok]
.findall([K,V], .map.key(M,K) invalid input: '&' .map.get(M,K,V), LL)
                                 // LL = [[a,30],[d,ok(3)]]
.map.get(M,a,V);                 // V = 20
.map.get(M,c,V);                 // fail
.map.get(M,c,V,0);               // V = 0
.map.remove(M,a,V);              // M = {b->ok} V = 20
for ( .map.key(M,K) invalid input: '&' .map.get(M,K,V) ) { // iteration
   .print(K,V);
}.
.map.clear(M);                   // M = {}

String

Execution control

  • if: implementation of if.
  • while: implementation of while.
  • for: implementation of for.

Meta programming

  • atom: check whether an argument is an atom (p).
  • structure: check whether an argument is a structure (p(t1,t2), [a,b]).
  • literal: check whether an argument is a literal (p(t1,t2), ~p(t1,t2), p(t1,t2)[a1,a2]).
  • list: check whether an argument is a list ([a,b]).
  • ground: check whether an argument is ground.
  • number: check whether an argument is a number (1, 2.3).
  • string: check whether an argument is a string ("s").
  • type: gets the type of a term.
  • add_nested_source: add a source in a literal.
  • eval: evaluates a logical expression.

Miscellaneous