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 Details

    • registerForNotification

      void registerForNotification(Term queryTerm, ai.thinkingrobots.trade.TRADEServiceInfo callback)
      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

      void unregisterForNotification(Term queryTerm, ai.thinkingrobots.trade.TRADEServiceInfo callback)
      Unregister to be notified by Belief for a particular query term.
      Parameters:
      queryTerm -
      callback -
    • assertBeliefs

      void assertBeliefs(Set<Term> beliefs, MemoryLevel memoryLevel)
      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

      void assertBeliefs(Set<Term> beliefs)
    • assertBelief

      void assertBelief(Term belief, MemoryLevel memoryLevel)
      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

      void assertBelief(Term belief)
    • retractBeliefs

      void retractBeliefs(Set<Term> beliefs, MemoryLevel memoryLevel)
      Removes the beliefs in the argument from the Belief State of the agent.
      Parameters:
      beliefs - : set of beliefs to be removed
    • retractBeliefs

      void retractBeliefs(Set<Term> beliefs)
    • retractBelief

      void retractBelief(Term belief, MemoryLevel memoryLevel)
      Removes a single belief from the Belief State of the agent.
      Parameters:
      belief -
    • retractBelief

      void retractBelief(Term belief)
    • assertRule

      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.
      Parameters:
      head -
      body -
    • assertRule

      void assertRule(Term head, List<Term> body)
    • retractRule

      void retractRule(Term head, List<Term> body, MemoryLevel memoryLevel)
      Retracts a rule containing any number of premises and any number of conclusions.
      Parameters:
      head -
      body -
    • retractRule

      void retractRule(Term head)
      Retracts a rule by its head.
      Parameters:
      head -
    • retractRule

      void retractRule(Term head, List<Term> body)
    • getFacts

      List<Term> getFacts(MemoryLevel memoryLevel)
      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

      List<Term> 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

      List<org.apache.commons.lang3.tuple.Pair<Term,List<Term>>> getRules(MemoryLevel memoryLevel)
      Returns list of current rules in predicate form, head first (conclusion) and then body (premises).
      Returns:
      List of pairs of rulehead and rulebody.
    • getRules

      List<org.apache.commons.lang3.tuple.Pair<Term,List<Term>>> getRules()
    • getHistory

      List<org.apache.commons.lang3.tuple.Pair<Term,org.apache.commons.lang3.tuple.Pair<Symbol,Symbol>>> getHistory(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

      List<org.apache.commons.lang3.tuple.Pair<Term,org.apache.commons.lang3.tuple.Pair<Symbol,Symbol>>> getHistory()
    • queryBelief

      List<Map<Variable,Symbol>> 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.
      Parameters:
      query - : a query in Term format
      Returns:
      an ArrayList of bindings: here represented as a HashMap from Variables to Symbols
    • queryBelief

      List<Map<Variable,Symbol>> queryBelief(Term query)
    • queryBelief

      List<List<Map<Variable,Symbol>>> queryBelief(List<Term> queries, MemoryLevel memoryLevel)
      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

      List<List<Map<Variable,Symbol>>> queryBelief(List<Term> queries)
    • querySupport

      Boolean querySupport(Term query, MemoryLevel memoryLevel)
      Make query and return if query has support (is true).
      Parameters:
      query -
    • querySupport

      Boolean querySupport(Term query)
    • querySupportWithExplanation

      org.apache.commons.lang3.tuple.Pair<Boolean,Map<Term,Boolean>> querySupportWithExplanation(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

      org.apache.commons.lang3.tuple.Pair<Boolean,Map<Term,Boolean>> querySupportWithExplanation(Term query)
    • queryRecentFacts

      List<Map<Variable,Symbol>> 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).
      Returns:
      Query results
    • queryAtTime

      List<Map<Variable,Symbol>> queryAtTime(Term query, Long time)
      Make query using all facts that were true at time t.
      Returns:
      Query results
    • queryFactsInTimeframe

      List<Map<Variable,Symbol>> queryFactsInTimeframe(Term query, Long start, Long end)
      Make query using facts which were true from start to end of timeframe.
      Returns:
      Query results
    • queryRecency

      Map<Term,List<org.apache.commons.lang3.tuple.Pair<Long,Long>>> queryRecency(Term query)
      Query for how long ago a belief was asserted and retracted.
      Returns:
      Query results
    • clear

      void clear()
    • clear

      void clear(MemoryLevel memoryLevel)
      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: