OpenCog Framework
Branch: master, revision 6f0b7fc776b08468cf1b74aa9db028f387b4f0c0
|
#include <FreeLink.h>
Public Member Functions | |
FreeLink (const HandleSeq &oset, TruthValuePtr tv=TruthValue::NULL_TV(), AttentionValuePtr av=AttentionValue::DEFAULT_AV()) | |
FreeLink (const Handle &a, TruthValuePtr tv=TruthValue::NULL_TV(), AttentionValuePtr av=AttentionValue::DEFAULT_AV()) | |
FreeLink (Link &l) | |
virtual | ~FreeLink () |
const HandleSeq & | get_vars (void) |
virtual Handle | reduce (void) |
![]() | |
Link (Type t, const HandleSeq &oset, TruthValuePtr tv=TruthValue::DEFAULT_TV(), AttentionValuePtr av=AttentionValue::DEFAULT_AV()) | |
Link (Type t, const Handle &h, TruthValuePtr tv=TruthValue::DEFAULT_TV(), AttentionValuePtr av=AttentionValue::DEFAULT_AV()) | |
Link (Type t, const Handle &ha, const Handle &hb, TruthValuePtr tv=TruthValue::DEFAULT_TV(), AttentionValuePtr av=AttentionValue::DEFAULT_AV()) | |
Link (Type t, const Handle &ha, const Handle &hb, const Handle &hc, TruthValuePtr tv=TruthValue::DEFAULT_TV(), AttentionValuePtr av=AttentionValue::DEFAULT_AV()) | |
Link (Type t, const Handle &ha, const Handle &hb, const Handle &hc, const Handle &hd, TruthValuePtr tv=TruthValue::DEFAULT_TV(), AttentionValuePtr av=AttentionValue::DEFAULT_AV()) | |
Link (Link &l) | |
~Link () | |
Arity | getArity () const |
const HandleSeq & | getOutgoingSet () const |
Handle | getOutgoingAtom (Arity pos) const throw (RuntimeException) |
template<class T > | |
bool | foreach_outgoing (bool(T::*cb)(const Handle &), T *data) |
std::string | toString (std::string indent="") |
std::string | toShortString (std::string indent="") |
bool | isSource (Handle) const throw (InvalidParamException) |
bool | isSource (size_t) const throw (IndexErrorException, InvalidParamException) |
bool | isTarget (Handle) const throw (InvalidParamException) |
bool | isTarget (size_t) const throw (IndexErrorException, InvalidParamException) |
virtual bool | operator== (const Atom &) const |
virtual bool | operator!= (const Atom &) const |
![]() | |
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 | find_vars (std::set< Handle > &, const HandleSeq &) |
void | build_index (void) |
FreeLink (Type, const HandleSeq &oset, TruthValuePtr tv=TruthValue::NULL_TV(), AttentionValuePtr av=AttentionValue::DEFAULT_AV()) | |
FreeLink (Type, const Handle &a, TruthValuePtr tv=TruthValue::NULL_TV(), AttentionValuePtr av=AttentionValue::DEFAULT_AV()) | |
FreeLink (Type, const Handle &a, const Handle &b, TruthValuePtr tv=TruthValue::NULL_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 | |
HandleSeq | _varseq |
std::map< Handle, unsigned int > | _index |
![]() | |
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 |
The FreeLink records all of the free variables that occur within (underneath) it, in traversal order. Those variables are placed in sequential order in _varseq. An index is placed in _index. That is, given a variable, its ordinal number is placed in _index.
The FreeLink, as a base class, also provides an important method: reduce()
The reduce() method takes the given expression, and applies term reduction rules to obtain a smaller but equivalent expression. Ideally, the reduced expression is the "minimal" such expression. There is no guarantee that reduce is normalizing or strongly normalizing, but that does seem like a desirable goal.
An expression that contains free variables will contain the same free variables (or a subset of them) after reduction.
Note that both EvaluationLinks and ExecutionOutputLinks are reducible, and the result of reduction is always another Atom. This is in contrast to the concept of evaluation/execution: EvaluationLinks, when evaluated, yield truth values, while ExecutionOutputLinks, when executed, yield Atoms.
Definition at line 59 of file FreeLink.h.
|
protected |
Definition at line 45 of file FreeLink.cc.
References opencog::classserver(), and init().
|
protected |
Definition at line 58 of file FreeLink.cc.
References opencog::classserver(), and init().
|
protected |
Definition at line 71 of file FreeLink.cc.
References opencog::classserver(), and init().
FreeLink::FreeLink | ( | const HandleSeq & | oset, |
TruthValuePtr | tv = TruthValue::NULL_TV() , |
||
AttentionValuePtr | av = AttentionValue::DEFAULT_AV() |
||
) |
Definition at line 29 of file FreeLink.cc.
References init().
FreeLink::FreeLink | ( | const Handle & | a, |
TruthValuePtr | tv = TruthValue::NULL_TV() , |
||
AttentionValuePtr | av = AttentionValue::DEFAULT_AV() |
||
) |
Definition at line 37 of file FreeLink.cc.
References init().
FreeLink::FreeLink | ( | Link & | l | ) |
Definition at line 84 of file FreeLink.cc.
References opencog::classserver(), opencog::Atom::getType(), and init().
|
inlinevirtual |
Definition at line 89 of file FreeLink.h.
|
protected |
Build the index from variable name, to its ordinal number. The index is needed for variable substitution, i.e. for the reduce() method. The specific sequence order of the variables is essential for making substitution work.
Definition at line 129 of file FreeLink.cc.
References _index, and _varseq.
Create an ordered set of the free variables in this link.
By "ordered set" it is meant: a list of variables, in traversal order (from left to right, as they appear in the tree), with each variable being named only once. The varset is only used to make sure that we don't name a variable more than once; that's all.
Definition at line 103 of file FreeLink.cc.
References _varseq, opencog::LinkCast(), and python.undocumented.blocksworld::t.
|
inline |
Definition at line 91 of file FreeLink.h.
References _varseq.
|
protected |
Definition at line 139 of file FreeLink.cc.
References opencog::Link::_outgoing, build_index(), and find_vars().
|
virtual |
Reimplemented in opencog::PutLink, opencog::FoldLink, and opencog::ArithmeticLink.
Definition at line 146 of file FreeLink.cc.
|
protected |
Definition at line 63 of file FreeLink.h.
|
protected |
Definition at line 62 of file FreeLink.h.