OpenCog Framework
Branch: master, revision 6f0b7fc776b08468cf1b74aa9db028f387b4f0c0
|
#include <BindLink.h>
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()) | |
![]() | |
void | extract_variables (const HandleSeq &oset) |
void | init_scoped_variables (const Handle &hvar) |
void | unbundle_clauses (const Handle &body) |
void | validate_clauses (std::set< Handle > &vars, HandleSeq &clauses) |
void | extract_optionals (const std::set< Handle > &vars, const std::vector< Handle > &component) |
void | unbundle_virtual (const std::set< Handle > &vars, const HandleSeq &clauses, HandleSeq &concrete_clauses, HandleSeq &virtual_clauses, std::set< Handle > &black_clauses) |
void | trace_connectives (const std::set< Type > &, const HandleSeq &clauses) |
void | make_connectivity_map (const HandleSeq &) |
void | check_connectivity (const std::vector< HandleSeq > &) |
void | make_map_recursive (const Handle &, const Handle &) |
void | make_term_trees () |
void | make_term_tree_recursive (const Handle &, const Handle &, PatternTermPtr &) |
void | init (void) |
void | common_init (void) |
void | setup_components (void) |
The second half of the common initialization sequence. More... | |
PatternLink (Type, const HandleSeq &, TruthValuePtr tv=TruthValue::DEFAULT_TV(), AttentionValuePtr av=AttentionValue::DEFAULT_AV()) | |
![]() | |
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... | |
![]() | |
Handle | _body |
Variables | _varlist |
Pattern | _pat |
HandleSeq | _fixed |
size_t | _num_virts |
HandleSeq | _virtual |
size_t | _num_comps |
std::vector< HandleSeq > | _components |
std::vector< std::set< Handle > > | _component_vars |
HandleSeq | _component_patterns |
![]() | |
HandleSeq | _outgoing |
![]() | |
UUID | _uuid |
AtomTable * | _atomTable |
Type | _type |
char | _flags |
TruthValuePtr | _truthValue |
AttentionValuePtr | _attentionValue |
std::mutex | _mtx |
InSetPtr | _incoming_set |
Additional Inherited Members | |
![]() | |
typedef std::shared_ptr< InSet > | InSetPtr |
![]() | |
static void | prt (const Handle &h) |
Definition at line 33 of file BindLink.h.
|
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().
BindLink::BindLink | ( | Link & | l | ) |
Definition at line 56 of file BindLink.cc.
References opencog::classserver(), opencog::Atom::getType(), opencog::ClassServer::getTypeName(), init(), and python.undocumented.blocksworld::t.
|
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().
|
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().
|
protected |
Definition at line 33 of file BindLink.cc.
References opencog::PatternLink::_body, opencog::Link::_outgoing, opencog::PatternLink::_pat, opencog::PatternLink::common_init(), extract_variables(), opencog::Pattern::redex_name, opencog::PatternLink::setup_components(), and opencog::PatternLink::unbundle_clauses().
|
protected |
The rewrite term.
Definition at line 39 of file BindLink.h.