OpenCog Framework  Branch: master, revision 6f0b7fc776b08468cf1b74aa9db028f387b4f0c0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
opencog::BindLink Class Reference

#include <BindLink.h>

+ Inheritance diagram for opencog::BindLink:
+ Collaboration diagram for opencog::BindLink:

Public Member Functions

 BindLink (const HandleSeq &, TruthValuePtr tv=TruthValue::DEFAULT_TV(), AttentionValuePtr av=AttentionValue::DEFAULT_AV())
 
 BindLink (Link &l)
 
bool imply (PatternMatchCallback &, bool check_connectivity=true)
 
const Handleget_implicand (void)
 
- Public Member Functions inherited from opencog::Atom
virtual ~Atom ()
 
Type getType () const
 
bool isType (Type t, bool subclass) const
 
Handle getHandle ()
 
AttentionValuePtr getAttentionValue ()
 
void setAttentionValue (AttentionValuePtr)
 Sets the AttentionValue object of the atom. More...
 
AttentionValue::sti_t getSTI ()
 Handy-dandy convenience getters for attention values. More...
 
AttentionValue::lti_t getLTI ()
 
AttentionValue::vlti_t getVLTI ()
 
void setSTI (AttentionValue::sti_t stiValue)
 
void setLTI (AttentionValue::lti_t ltiValue)
 
void incVLTI ()
 
void decVLTI ()
 
TruthValuePtr getTruthValue ()
 
void setTruthValue (TruthValuePtr)
 Sets the TruthValue object of the atom. More...
 
void merge (TruthValuePtr)
 
Handle tvmerge (TruthValuePtr tv)
 
size_t getIncomingSetSize ()
 Get the size of the incoming set. More...
 
IncomingSet getIncomingSet ()
 
template<typename OutputIterator >
OutputIterator getIncomingSet (OutputIterator result)
 
template<class T >
bool foreach_incoming (bool(T::*cb)(const Handle &), T *data)
 
template<typename OutputIterator >
OutputIterator getIncomingSetByType (OutputIterator result, Type type, bool subclass=false)
 
IncomingSet getIncomingSetByType (Type type, bool subclass=false)
 

Protected Member Functions

void init (void)
 
void extract_variables (const HandleSeq &oset)
 
 BindLink (Type, const HandleSeq &, TruthValuePtr tv=TruthValue::DEFAULT_TV(), AttentionValuePtr av=AttentionValue::DEFAULT_AV())
 
- Protected Member Functions inherited from opencog::Atom
 Atom (Type t, TruthValuePtr tv=TruthValue::DEFAULT_TV(), AttentionValuePtr av=AttentionValue::DEFAULT_AV())
 
void keep_incoming_set ()
 
void drop_incoming_set ()
 
void insert_atom (LinkPtr)
 Add an atom to the incoming set. More...
 
void remove_atom (LinkPtr)
 Remove an atom from the incoming set. More...
 

Protected Attributes

Handle _implicand
 The rewrite term. More...
 
- Protected Attributes inherited from opencog::Atom
UUID _uuid
 
AtomTable_atomTable
 
Type _type
 
char _flags
 
TruthValuePtr _truthValue
 
AttentionValuePtr _attentionValue
 
std::mutex _mtx
 
InSetPtr _incoming_set
 

Additional Inherited Members

- Protected Types inherited from opencog::Atom
typedef std::shared_ptr< InSetInSetPtr
 

Detailed Description

Definition at line 33 of file BindLink.h.

Constructor & Destructor Documentation

BindLink::BindLink ( Type  t,
const HandleSeq hseq,
TruthValuePtr  tv = TruthValue::DEFAULT_TV(),
AttentionValuePtr  av = AttentionValue::DEFAULT_AV() 
)
protected

Definition at line 49 of file BindLink.cc.

References init().

BindLink::BindLink ( const HandleSeq hseq,
TruthValuePtr  tv = TruthValue::DEFAULT_TV(),
AttentionValuePtr  av = AttentionValue::DEFAULT_AV() 
)

Definition at line 42 of file BindLink.cc.

References init().

Member Function Documentation

void BindLink::extract_variables ( const HandleSeq oset)
protected

Find and unpack variable declarations, if any; otherwise, just find all free variables.

On top of that initialize _body and _implicand with the clauses and the rewrite rule.

Definition at line 78 of file BindLink.cc.

References opencog::PatternLink::_body, _implicand, opencog::PatternLink::_varlist, opencog::FreeLink::get_vars(), and opencog::PatternLink::init_scoped_variables().

+ Here is the caller graph for this function:

const Handle& opencog::BindLink::get_implicand ( void  )
inline

Definition at line 58 of file BindLink.h.

References _implicand.

bool BindLink::imply ( PatternMatchCallback pmc,
bool  check_conn = true 
)

Ground (solve) a pattern; perform unification. That is, find one or more groundings for the variables occuring in a collection of clauses (a hypergraph). The hypergraph can be thought of as a a 'predicate' which becomes 'true' when a grounding exists.

The predicate is defined in terms of two hypergraphs: one is a hypergraph defining a pattern to be grounded, and the other is a list of bound variables in the first.

The bound variables are, by convention, VariableNodes. (The code in the pattern match engine doesn't care whether the variable nodes are actually of type VariableNode, and so can work with variables that are any kind of node. However, the default callbacks do check for this type. Thus, the restriction, by convention, that the variables must be of type VariableNode.) The list of bound variables is then assumed to be listed using the ListLink type. So, for example:

ListLink VariableNode "variable 1" VariableNode "another variable"

The pattern hypergraph is assumed to be a list of "clauses", where each "clause" should be thought of as the tree defined by the outgoing sets in it. The below assumes that the list of clauses is specified by means of an AndLink, so, for example:

AndLink
   SomeLink ....
   SomeOtherLink ...

The clauses are assumed to be connected by variables, i.e. each clause has a variable that also appears in some other clause. Even more strongly, it is assumed that there is just one connected component; the code below throws an error if there is more than one connected component. The reason for this is to avoid unintended combinatoric explosions: the grounding of any one (connected) component is completely independent of the grounding of any other component. So, if there are two components, and one has N groundings and the other has M groundings, then the two together trivially have MxN groundings. Its worse if there are 4, 4... components. Rather than stupidly reporting a result MxNx... times, we just throw an error, and let the user decide what to do.

The grounding proceeds by requiring each clause to match some part of the atomspace (i.e. of the universe of hypergraphs stored in the atomspace). When a solution is found, PatternMatchCallback::solution method is called, and it is passed two maps: one mapping the bound variables to their groundings, and the other mapping the pattern clauses to their corresponding grounded clauses.

Note: the pattern matcher itself doesn't use the atomspace, or care if the groundings live in the atomspace; it can search anything. However, the default callbacks do use the atomspace to find an initial starting point for the search, and thus the search defacto happens on the atomspace. This restriction can be lifted by tweaking the callback that initially launches the search.

At this time, the list of clauses is understood to be a single disjunct; that is, all of the clauses must be simultaneously satisfied. A future extension could allow the use of MatchOrLinks to support multiple exclusive disjuncts. See the README for more info. Evaluate a BindLink

Given a BindLink containing variable declarations, a predicate and an implicand, this method will "evaluate" the implication, matching the predicate, and creating a grounded implicand, assuming the predicate can be satisfied. Thus, for example, given the structure

BindLink ListLink VariableNode "$var0" VariableNode "$var1" AndList etc ...

Evaluation proceeds as decribed in the "do_imply()" function below. The whole point of the BindLink is to do nothing more than to indicate the bindings of the variables, and (optionally) limit the types of acceptable groundings for the variables.

Definition at line 315 of file PatternMatch.cc.

References opencog::PatternLink::_components, opencog::PatternLink::_virtual, and opencog::PatternLink::satisfy().

Member Data Documentation

Handle opencog::BindLink::_implicand
protected

The rewrite term.

Definition at line 39 of file BindLink.h.


The documentation for this class was generated from the following files: