Modifier and Type | Class and Description |
---|---|
private static class |
ArrayListKBaseImpl.DataStorage |
Modifier and Type | Field and Description |
---|---|
(package private) Term |
agentName
All the beliefs of this KBase have the form (B agentName ...)
|
private Formula |
belNotOPattern |
private Formula |
belOPattern |
private Formula |
bPattern |
private ArrayList |
closedPredicateList
List of patterns which are closed
|
private ArrayListKBaseImpl.DataStorage |
dataStorage
Storage of beliefs
|
private Formula |
iPattern |
private Formula |
ireFormula |
private Logger |
logger
Logger
|
private Formula |
notBelOPattern |
private Formula |
notBPattern |
private Formula |
notIPattern |
private Formula |
notUPattern |
private Formula |
notURefPattern |
private ArrayList |
observers
List of observers
|
(package private) HashSet |
observersToApplied
HashSet of Observations which contains the observers to trigger when a
formula is asserted
|
private Formula |
uPattern
Patterns for assertion and query methods
|
private Formula |
URefPattern |
private KBase |
wrappingKBase
The wrapping KBase
|
Constructor and Description |
---|
ArrayListKBaseImpl(Term agentName)
Creates a new belief base.
|
ArrayListKBaseImpl(Term agentName,
KBase wrappingKBase)
Creates a new belief base.
|
Modifier and Type | Method and Description |
---|---|
void |
addClosedPredicate(Formula pattern)
Define a new pattern of closed formula.
|
void |
addObserver(Observer obs)
Adds a new Observer in the observer table
|
void |
assertFormula(Formula formula)
Tries to assert the formula.
|
Term |
eval(Term expression) |
Term |
getAgentName()
Get the name of the agent (given as a FIPA-SL term representing his AID)
owning this
KBase instance. |
Logger |
getLogger() |
KBase |
getWrappingKBase()
The
KBase mechanism follows the decoration design pattern. |
boolean |
isClosed(Formula pattern,
QueryResult b)
Return
true if a given pattern of formula is closed on a
given domain of values, and false otherwise. |
QueryResult |
query(Formula formula)
Check wether a given fact is believed by the agent owning this
KBase
instance. |
QueryResult |
query(Formula formula,
ArrayList reasons)
Queries directly the belief base.
|
ListOfTerm |
queryRef(IdentifyingExpression expression)
Deprecated.
|
Term |
queryRef(IdentifyingExpression expression,
ArrayList falsityReasons) |
Term |
queryRefSingleTerm(IdentifyingExpression expression)
Allways returns a single term depending on the IRE
and the result list returned by queryRef.
|
void |
removeClosedPredicate(Finder finder)
Remove the definition of a pattern of closed formula.
|
void |
removeFormula(Finder finder)
Deprecated.
use retractFormula(Formula) instead
|
boolean |
removeFormula(Formula formula)
Removes the specified formula from the base.
|
void |
removeObserver(Finder finder)
Removes from the KBase the observers detected by the finder.
|
void |
removeObserver(Observer obs)
Removes the given observer
|
void |
retractFormula(Formula formula)
It retracts the formula given in parameter from the belief base by
asserting (not (B ??myself ??formula)).
|
void |
setAgentName(Term agent)
Modify the agent (given as a FIPA-SL term representing his AID) the
beliefs stored in this
KBase instance belong to. |
void |
setWrappingKBase(KBase kbase)
Set the most enclosing
KBase . |
ArrayList |
toStrings()
For debugging purpose only
|
void |
updateObservers(Formula formula)
Update the status of all observers concerned by a given formula.
|
private KBase wrappingKBase
Term agentName
private ArrayListKBaseImpl.DataStorage dataStorage
private ArrayList closedPredicateList
private ArrayList observers
private final Formula uPattern
private final Formula notUPattern
private final Formula iPattern
private final Formula notIPattern
private final Formula bPattern
private final Formula notBPattern
private final Formula belOPattern
private final Formula belNotOPattern
private final Formula notBelOPattern
private final Formula notURefPattern
private final Formula URefPattern
private final Formula ireFormula
private Logger logger
HashSet observersToApplied
public ArrayListKBaseImpl(Term agentName)
remoteAgent
- the owner of the basepublic KBase getWrappingKBase()
KBase
KBase
mechanism follows the decoration design pattern.
A KBase
instance can be enclosed within another KBase
instance, wich can in turn be enclosed in another KBase
instance
and so on.getWrappingKBase
in interface KBase
KBase
instance, on which to proceed
assertion and query operations. This also corresonds to the
KBase
instance attached to the semantic capabilities of
an agent. It can be this KBase
object.public void setWrappingKBase(KBase kbase)
KBase
KBase
. This method is for internal use
only, and should never be called by the JSA programmer.setWrappingKBase
in interface KBase
public Term getAgentName()
KBase
KBase
instance. Note that a KBase
instance
stores the beliefs of only one agent, even if these beliefs may
concern beliefs on other agents.getAgentName
in interface KBase
KBase
object.public void setAgentName(Term agent)
KBase
KBase
instance belong to.setAgentName
in interface KBase
agent
- the agent the beliefs of this KBase
object belong to.public void assertFormula(Formula formula)
AtomicFormula
assertFormula
in interface KBase
formula
- the formula to assert in the belief basepublic void updateObservers(Formula formula)
KBase
A null
formula forces all observers to be updated.
This operation is needed to trigger the observers even when an assertion does not lead to an actual assertion in the belief base.
updateObservers
in interface KBase
formula
- a formula that has just been asserted.Observer
@Deprecated public ListOfTerm queryRef(IdentifyingExpression expression)
queryRefSingleTerm(IdentifyingExpression)
or
queryRef(IdentifyingExpression, ArrayList)
instead.public Term queryRef(IdentifyingExpression expression, ArrayList falsityReasons)
public Term queryRefSingleTerm(IdentifyingExpression expression)
queryRefSingleTerm
in interface KBase
expression
- an Identifying Referential Expression describing one or
more objects to find within the agent's beliefs.null
if
there is no such object according to the agent's beliefs.KBase.queryRef(IdentifyingExpression)
public QueryResult query(Formula formula)
KBase
KBase
instance.
If the fact is not believed by the agent, the method returns null
.
The queried fact may include meta-references. In this case, the
method returns all bindings of these meta-references, for which the
corresponding instantiated fact is believed by the agent.
These bindings are returned using a QueryResult
instance.
If the queried fact include no meta-reference and is actually believed,
the returned QueryResult
object is an empty list equal
to QueryResult.KNOWN.
(age john 25)
, (age mary 25)
and
(age peter 20)
are believed by the agent, querying for
(age ??who 25)
will return a list of two
MatchResult
objects containing
respectively the bindings (??who
=john
) and
(??who
=mary
).query
in interface KBase
formula
- a fact to retrieve in the belief base (may include meta-
references)null
(QueryResult.UNKNOWN) if the agent doesn't
know about this fact,
public QueryResult query(Formula formula, ArrayList reasons)
public boolean removeFormula(Formula formula)
formula
- a formula@Deprecated public void removeFormula(Finder finder)
KBase
removeFormula
in interface KBase
finder
- a finder to identify formulas to remove from the belief base.public void retractFormula(Formula formula)
retractFormula
in interface KBase
formula
- the formula to retract from the belief basepublic ArrayList toStrings()
public void addObserver(Observer obs)
addObserver
in interface KBase
o
- the observer to addpublic void removeObserver(Finder finder)
removeObserver
in interface KBase
finder
- the finderpublic void removeObserver(Observer obs)
removeObserver
in interface KBase
obs
- the observer to be removedpublic void addClosedPredicate(Formula pattern)
KBase
If there is no instance of this pattern, which is already believed by
the agent owning the belief base, this is equivalent to assert
(= (all ??VARS ??pattern) (set))
, where ??VAR
is a sequence of all meta-references occurring in the pattern.
addClosedPredicate
in interface KBase
pattern
- the pattern of formula to declare as closed.KBase.isClosed(Formula, QueryResult)
public void removeClosedPredicate(Finder finder)
KBase
Finder
object.removeClosedPredicate
in interface KBase
finder
- a finder identifying the pattern of closed formula to remove.KBase.isClosed(Formula, QueryResult)
public boolean isClosed(Formula pattern, QueryResult b)
KBase
true
if a given pattern of formula is closed on a
given domain of values, and false
otherwise.
A pattern of formula is considered as closed on a set of values if and only if:
iota
and the all
IRE quantifiers. For example, the belief
(B ??myself (= (all ?x (age ?x 25)) (set john mary)))
is actually stored in the belief base as the formula
(age ??x 25)
closed on the domain (john
,
mary
). This makes it possible to retrieve implicit entailments
such as (B ??myself (not (age peter 25)))
(without the closed
formula mechanism, one could only entail
(not (B ??myself (age peter 25)))
).
Consequent to the formal definition of the underlying logical model for
agents' beliefs, all patterns of mental attitudes of the agent owning
the belief base (that is all patterns logically equivalent to a formula
of the form (B ??myself ??PHI)
) are necessarily closed. In
other words, agents know exactly what are all their mental attitudes, they
cannot not be aware of them.
Closed formulas can be defined and undefined using the
KBase.addClosedPredicate(Formula)
and KBase.removeClosedPredicate(Finder)
methods.
isClosed
in interface KBase
pattern
- the pattern of closed formula to check.b
- the domain of values to used to check the closure.
null
value does not check the values, only
the registration of the pattern as a closed formula.true
if the pattern is closed on the given domain,
false
otherwise.public Logger getLogger()