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

#include <FreeLink.h>

+ Inheritance diagram for opencog::FreeLink:
+ Collaboration diagram for opencog::FreeLink:

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 HandleSeqget_vars (void)
 
virtual Handle reduce (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 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())
 
- 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

HandleSeq _varseq
 
std::map< Handle, unsigned int > _index
 
- 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

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.

Constructor & Destructor Documentation

FreeLink::FreeLink ( Type  t,
const HandleSeq oset,
TruthValuePtr  tv = TruthValue::NULL_TV(),
AttentionValuePtr  av = AttentionValue::DEFAULT_AV() 
)
protected

Definition at line 45 of file FreeLink.cc.

References opencog::classserver(), and init().

FreeLink::FreeLink ( Type  t,
const Handle a,
TruthValuePtr  tv = TruthValue::NULL_TV(),
AttentionValuePtr  av = AttentionValue::DEFAULT_AV() 
)
protected

Definition at line 58 of file FreeLink.cc.

References opencog::classserver(), and init().

FreeLink::FreeLink ( Type  t,
const Handle a,
const Handle b,
TruthValuePtr  tv = TruthValue::NULL_TV(),
AttentionValuePtr  av = AttentionValue::DEFAULT_AV() 
)
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().

virtual opencog::FreeLink::~FreeLink ( )
inlinevirtual

Definition at line 89 of file FreeLink.h.

Member Function Documentation

void FreeLink::build_index ( void  )
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.

+ Here is the caller graph for this function:

void FreeLink::find_vars ( std::set< Handle > &  varset,
const HandleSeq oset 
)
protected

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.

+ Here is the caller graph for this function:

const HandleSeq& opencog::FreeLink::get_vars ( void  )
inline

Definition at line 91 of file FreeLink.h.

References _varseq.

+ Here is the caller graph for this function:

void FreeLink::init ( void  )
protected

Definition at line 139 of file FreeLink.cc.

References opencog::Link::_outgoing, build_index(), and find_vars().

+ Here is the caller graph for this function:

Handle FreeLink::reduce ( void  )
virtual

Reimplemented in opencog::PutLink, opencog::FoldLink, and opencog::ArithmeticLink.

Definition at line 146 of file FreeLink.cc.

Member Data Documentation

std::map<Handle, unsigned int> opencog::FreeLink::_index
protected

Definition at line 63 of file FreeLink.h.

HandleSeq opencog::FreeLink::_varseq
protected

Definition at line 62 of file FreeLink.h.


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