Package edu.tufts.hrilab.belief
Interface BeliefInterface
- All Known Implementing Classes:
BeliefComponent
public interface BeliefInterface
Note: The maps of bindings from Variables to Lists of Symbols are here
represented by
HashMap<Variable, ArrayList<Symbol>>
.-
Method Summary
Modifier and TypeMethodDescriptionvoid
assertBelief
(Term belief) void
assertBelief
(Term belief, MemoryLevel memoryLevel) Adds a single belief to the Belief State of the agent.void
assertBeliefs
(Set<Term> beliefs) void
assertBeliefs
(Set<Term> beliefs, MemoryLevel memoryLevel) Adds the beliefs in the argument to the Belief State of the agent.void
assertRule
(Term head, List<Term> body) void
assertRule
(Term head, List<Term> body, MemoryLevel memoryLevel) Asserts a rule with one premise and a set of conclusions into the Belief State of the agent.void
clear()
void
clear
(MemoryLevel memoryLevel) Clear beliefs at specified memory level only.Copy the prover and sql state to a new BeliefComponent instance and return it.getFacts()
Returns list of current facts in predicate form.getFacts
(MemoryLevel memoryLevel) Returns list of current facts in predicate form.getHistory
(MemoryLevel memoryLevel) Returns list of past facts in predicate form, paired with their assertion and retraction times.getRules()
getRules
(MemoryLevel memoryLevel) Returns list of current rules in predicate form, head first (conclusion) and then body (premises).queryAtTime
(Term query, Long time) Make query using all facts that were true at time t.queryBelief
(Term query) queryBelief
(Term query, MemoryLevel memoryLevel) Queries the Belief State about the term in the argument, and a set of bindings corresponding to all of the found answers.queryBelief
(List<Term> queries) queryBelief
(List<Term> queries, MemoryLevel memoryLevel) Queries the Belief State with N independent queries, and returns N binding lists.queryFactsInTimeframe
(Term query, Long start, Long end) Make query using facts which were true from start to end of timeframe.queryRecency
(Term query) Query for how long ago a belief was asserted and retracted.queryRecentFacts
(Term query, int n) Make query using last n facts most recently asserted to the database (out of all facts, not necessarily currently true ones).querySupport
(Term query) querySupport
(Term query, MemoryLevel memoryLevel) Make query and return if query has support (is true).querySupportWithExplanation
(Term query) querySupportWithExplanation
(Term query, MemoryLevel memoryLevel) Queries true or falsevoid
registerForNotification
(Term queryTerm, ai.thinkingrobots.trade.TRADEServiceInfo callback) Register to be notified by Belief whenever the query term is true.void
retractBelief
(Term belief) void
retractBelief
(Term belief, MemoryLevel memoryLevel) Removes a single belief from the Belief State of the agent.void
retractBeliefs
(Set<Term> beliefs) void
retractBeliefs
(Set<Term> beliefs, MemoryLevel memoryLevel) Removes the beliefs in the argument from the Belief State of the agent.void
retractRule
(Term head) Retracts a rule by its head.void
retractRule
(Term head, List<Term> body) void
retractRule
(Term head, List<Term> body, MemoryLevel memoryLevel) Retracts a rule containing any number of premises and any number of conclusions.void
unregisterForNotification
(Term queryTerm, ai.thinkingrobots.trade.TRADEServiceInfo callback) Unregister to be notified by Belief for a particular query term.
-
Method Details
-
registerForNotification
Register to be notified by Belief whenever the query term is true. The callback method must have the following method signature to receive callbacks:callbackMethod(Term queryTerm, List<Map<Variable, List<Symbol>>> bindings)
If the query contains no variables, a list containing one empty map will be returned for true queries.- Parameters:
queryTerm
-callback
-
-
unregisterForNotification
Unregister to be notified by Belief for a particular query term.- Parameters:
queryTerm
-callback
-
-
assertBeliefs
Adds the beliefs in the argument to the Belief State of the agent. Note: new beliefs are added such that they take priority in unification to old beliefs. queryBelief() will still return all asserted and inferred bindings.- Parameters:
beliefs
- : set of beliefs to add to the Belief State.
-
assertBeliefs
-
assertBelief
Adds a single belief to the Belief State of the agent. Note: new beliefs are added such that they take priority in unification to old beliefs. queryBelief() will still return all asserted and inferred bindings.- Parameters:
belief
-
-
assertBelief
-
retractBeliefs
Removes the beliefs in the argument from the Belief State of the agent.- Parameters:
beliefs
- : set of beliefs to be removed
-
retractBeliefs
-
retractBelief
Removes a single belief from the Belief State of the agent.- Parameters:
belief
-
-
retractBelief
-
assertRule
Asserts a rule with one premise and a set of conclusions into the Belief State of the agent.- Parameters:
head
-body
-
-
assertRule
-
retractRule
Retracts a rule containing any number of premises and any number of conclusions.- Parameters:
head
-body
-
-
retractRule
Retracts a rule by its head.- Parameters:
head
-
-
retractRule
-
getFacts
Returns list of current facts in predicate form. This returns facts that are explicitly true, and facts that are true as a result of inference, using facts and rules from specified MemoryLevel.- Returns:
- Facts
-
getFacts
Returns list of current facts in predicate form. This returns facts that are explicitly true, and facts that are true as a result of inference.- Returns:
- Facts
-
getRules
Returns list of current rules in predicate form, head first (conclusion) and then body (premises).- Returns:
- List of pairs of rulehead and rulebody.
-
getRules
-
getHistory
List<org.apache.commons.lang3.tuple.Pair<Term,org.apache.commons.lang3.tuple.Pair<Symbol, getHistorySymbol>>> (MemoryLevel memoryLevel) Returns list of past facts in predicate form, paired with their assertion and retraction times.- Returns:
- List of pairs of facts and start/end times.
-
getHistory
-
queryBelief
Queries the Belief State about the term in the argument, and a set of bindings corresponding to all of the found answers.- Parameters:
query
- : a query in Term format- Returns:
- an ArrayList of bindings: here represented as a HashMap from Variables to Symbols
-
queryBelief
-
queryBelief
Queries the Belief State with N independent queries, and returns N binding lists.- Parameters:
queries
- : a list of N queries in Term format- Returns:
- an List of N lists of bindings: here represented as a HashMap from Variables to Symbols
-
queryBelief
-
querySupport
Make query and return if query has support (is true).- Parameters:
query
-
-
querySupport
-
querySupportWithExplanation
org.apache.commons.lang3.tuple.Pair<Boolean,Map<Term, querySupportWithExplanationBoolean>> (Term query, MemoryLevel memoryLevel) Queries true or false- Parameters:
query
-- Returns:
- True or false, paired with a map of facts and booleans which lead to the original query being true or false.
-
querySupportWithExplanation
-
queryRecentFacts
Make query using last n facts most recently asserted to the database (out of all facts, not necessarily currently true ones).- Returns:
- Query results
-
queryAtTime
Make query using all facts that were true at time t.- Returns:
- Query results
-
queryFactsInTimeframe
Make query using facts which were true from start to end of timeframe.- Returns:
- Query results
-
queryRecency
Query for how long ago a belief was asserted and retracted.- Returns:
- Query results
-
clear
void clear() -
clear
Clear beliefs at specified memory level only.- Parameters:
memoryLevel
-
-
createClone
BeliefInterface createClone()Copy the prover and sql state to a new BeliefComponent instance and return it. This should not automatically register the new component with TRADE, and is up to the caller to register if desired.- Returns:
-