OpenCog Framework
Branch: master, revision 6f0b7fc776b08468cf1b74aa9db028f387b4f0c0
|
#include <DefaultForwardChainerCB.h>
Public Member Functions | |
HandleSeq | substitute_rule_part (AtomSpace &as, Handle hrule, const std::set< Handle > &vars, const std::vector< std::map< Handle, Handle >> &var_groundings) |
DefaultForwardChainerCB (AtomSpace &as, source_selection_mode ts_mode=TV_FITNESS_BASED) | |
virtual vector< Rule * > | choose_rules (FCMemory &fcmem) |
virtual HandleSeq | choose_premises (FCMemory &fcmem) |
virtual Handle | choose_next_source (FCMemory &fcmem) |
virtual HandleSeq | apply_rule (FCMemory &fcmem) |
![]() | |
ForwardChainerCallBack (AtomSpace *as) | |
virtual | ~ForwardChainerCallBack () |
Public Attributes | |
std::map< Handle, std::vector < Handle > > | rule_derivations |
Private Member Functions | |
Handle | gen_sub_varlist (const Handle &parent, const Handle &parent_varlist) |
HandleSeq | unify (Handle source, Handle target, Rule *rule) |
HandleSeq | subatom_unify (Handle source, Rule *rule) |
bool | is_valid_implicant (const Handle &h) |
Private Attributes | |
AtomSpace & | _as |
ForwardChainerPMCB | _fcpm |
source_selection_mode | _ts_mode |
Friends | |
class | ::DefaultForwardChainerCBUTest |
Definition at line 36 of file DefaultForwardChainerCB.h.
DefaultForwardChainerCB::DefaultForwardChainerCB | ( | AtomSpace & | as, |
source_selection_mode | ts_mode = TV_FITNESS_BASED |
||
) |
Definition at line 41 of file DefaultForwardChainerCB.cc.
apply chosen rule. the default will wrap a custom PM callback class. i.e invokes _pattern_matcher.
Make sure the inferences made are new.
Implements opencog::ForwardChainerCallBack.
Definition at line 255 of file DefaultForwardChainerCB.cc.
References _fcpm, opencog::BindLinkCast(), createBindLink, opencog::FCMemory::get_cur_rule(), opencog::Rule::get_handle(), opencog::ForwardChainerPMCB::get_products(), opencog::Implicator::implicand, opencog::FCMemory::isin_potential_sources(), opencog::LinkCast(), and opencog::ForwardChainerPMCB::set_fcmem().
choose next source from the source list
Choose a new source that has never been chosen before. xxx FIXME since same handle might be chosen multiple times the following code doesn't guarantee all sources have been exhaustively looked.
Implements opencog::ForwardChainerCallBack.
Definition at line 211 of file DefaultForwardChainerCB.cc.
References _as, _ts_mode, opencog::FCMemory::get_potential_sources(), opencog::FCMemory::isin_selected_sources(), opencog::STI_BASED, python.undocumented.blocksworld::t, opencog::URECommons::tournament_select(), opencog::URECommons::tv_fitness(), opencog::TV_FITNESS_BASED, and opencog::Handle::UNDEFINED.
Choose additional premises for the rule. an object holding the current source/target and other inform ation of the forward chaining instance.
Implements opencog::ForwardChainerCallBack.
Definition at line 186 of file DefaultForwardChainerCB.cc.
References _as, opencog::FCMemory::get_cur_source(), opencog::get_distant_neighbors(), and opencog::URECommons::get_root_links().
Choose rules based on implicant member of rule matching the source. Whenever a matching rule is found, it derives new rules by substituting bound variables of the rule with the source. All derived rules are then kept in the global variable
rule_derivations. | |
fcmem | Forward chainer's working memory |
Implements opencog::ForwardChainerCallBack.
Definition at line 59 of file DefaultForwardChainerCB.cc.
References opencog::FCMemory::get_cur_source(), opencog::FCMemory::get_rules(), rule_derivations, opencog::Handle::UNDEFINED, and unify().
|
private |
Definition at line 281 of file DefaultForwardChainerCB.cc.
References createVariableList, opencog::LinkCast(), opencog::FindAtoms::search_set(), python.undocumented.blocksworld::t, and opencog::FindAtoms::varset.
|
private |
Checks whether an atom can be used to generate a bindLink or not.
h | The atom handle to be validated. |
Definition at line 372 of file DefaultForwardChainerCB.cc.
References opencog::Atom::getType(), opencog::FindAtoms::search_set(), and opencog::FindAtoms::varset.
Tries to unify sub atoms of implicant lists in
rule | with |
source. | |
source | An atom that might bind to variables in |
rule. | |
rule | The rule object whose implicants are to be sub atom unified. |
Definition at line 166 of file DefaultForwardChainerCB.cc.
References opencog::get_all_unique_atoms(), opencog::Rule::get_implicant_seq(), python.bindlink::result, and unify().
HandleSeq DefaultForwardChainerCB::substitute_rule_part | ( | AtomSpace & | as, |
Handle | hrule, | ||
const std::set< Handle > & | vars, | ||
const std::vector< std::map< Handle, Handle >> & | var_groundings | ||
) |
Derives new rules from
hrule | by replacing variables with their groundings. |
as | An atomspace where the handles dwell. |
hrule | A handle to BindLink instance |
vars | The grounded var list in |
hrule | |
var_groundings | The set of groundings to each var in |
vars |
Definition at line 320 of file DefaultForwardChainerCB.cc.
References opencog::BindLinkCast(), opencog::contains_atomtype(), createBindLink, gen_sub_varlist(), opencog::LinkCast(), and opencog::Substitutor::substitute().
Tries to unify the
source | with target and derives new rules using |
rule | as a template. |
source | An atom that might bind to variables in |
rule. | |
target | An atom to be unified with |
source | rule The rule object whose implicants are to be unified. |
rule | with their mapped bindings. |
Definition at line 102 of file DefaultForwardChainerCB.cc.
References _as, opencog::AtomSpace::add_atom(), createBindLink, gen_sub_varlist(), opencog::Rule::get_handle(), opencog::Rule::get_vardecl(), is_valid_implicant(), opencog::FindAtoms::search_set(), substitute_rule_part(), and opencog::FindAtoms::varset.
|
friend |
Definition at line 38 of file DefaultForwardChainerCB.h.
|
private |
Definition at line 39 of file DefaultForwardChainerCB.h.
|
private |
Definition at line 40 of file DefaultForwardChainerCB.h.
|
private |
Definition at line 41 of file DefaultForwardChainerCB.h.
Definition at line 60 of file DefaultForwardChainerCB.h.