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

#include <PutLink.h>

+ Inheritance diagram for opencog::PutLink:
+ Collaboration diagram for opencog::PutLink:

Public Member Functions

 PutLink (const HandleSeq &oset, TruthValuePtr tv=TruthValue::NULL_TV(), AttentionValuePtr av=AttentionValue::DEFAULT_AV())
 
 PutLink (const Handle &a, TruthValuePtr tv=TruthValue::NULL_TV(), AttentionValuePtr av=AttentionValue::DEFAULT_AV())
 
 PutLink (Link &l)
 
virtual ~PutLink ()
 
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)
 
Handle substitute_nocheck (const Handle &, const HandleSeq &) const
 
Handle do_reduce (void) const
 
 PutLink (Type, const HandleSeq &oset, TruthValuePtr tv=TruthValue::NULL_TV(), AttentionValuePtr av=AttentionValue::DEFAULT_AV())
 
 PutLink (Type, const Handle &a, TruthValuePtr tv=TruthValue::NULL_TV(), AttentionValuePtr av=AttentionValue::DEFAULT_AV())
 
 PutLink (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...
 

Additional Inherited Members

- Protected Types inherited from opencog::Atom
typedef std::shared_ptr< InSetInSetPtr
 
- Protected Attributes inherited from opencog::Atom
UUID _uuid
 
AtomTable_atomTable
 
Type _type
 
char _flags
 
TruthValuePtr _truthValue
 
AttentionValuePtr _attentionValue
 
std::mutex _mtx
 
InSetPtr _incoming_set
 

Detailed Description

The PutLink implements a beta redex; it is similar to an imperative version of MemberLink, with argumets reversed.

A beta redex is a concatentation or composition of two expressions, one with N free variables in it, and a list of N values for those variables. The natural form for a beta redex is in the unreduced form: the values are not (yet) substituted for the variables; they are simply sitting there, ready and waiting for that reduction to happen.

Thus, the PutLink makes use of the FreeLink to identify the free variables. It also overloads it's reduce() method, which implements the actual beta reduction. The reduce() method only performs the substitution; it does not attempt to execute or evaluate the resulting expression.

Definition at line 52 of file PutLink.h.

Constructor & Destructor Documentation

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

Definition at line 45 of file PutLink.cc.

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

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

Definition at line 55 of file PutLink.cc.

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

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

Definition at line 65 of file PutLink.cc.

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

PutLink::PutLink ( const HandleSeq oset,
TruthValuePtr  tv = TruthValue::NULL_TV(),
AttentionValuePtr  av = AttentionValue::DEFAULT_AV() 
)

Definition at line 29 of file PutLink.cc.

References init().

PutLink::PutLink ( const Handle a,
TruthValuePtr  tv = TruthValue::NULL_TV(),
AttentionValuePtr  av = AttentionValue::DEFAULT_AV() 
)

Definition at line 37 of file PutLink.cc.

References init().

PutLink::PutLink ( Link l)

Definition at line 75 of file PutLink.cc.

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

virtual opencog::PutLink::~PutLink ( )
inlinevirtual

Definition at line 79 of file PutLink.h.

Member Function Documentation

Handle PutLink::do_reduce ( void  ) const
protected
void PutLink::init ( void  )
protected

PutLink expects a very strict format: an arity-2 link, with the first part being a pattern, and the second a list or set of values. If the pattern has N variables, then the seccond part must have N values. The following formats are understood:

PutLink <pattern with 1 variable> <any single="" atom>="">

PutLink <pattern with="" n="" variables>=""> ListLink ;; must have arity N <atom 1> ... <atom n>="">

The below is a handy-dandy easy-to-use form. When it is reduced, it will result in the creation of a set of reduced forms, not just one (the two sets haveing the same arity). Unfortunately, this trick cannot work for N=1.

PutLink <pattern with="" n="" variables>=""> SetLink ;; Must hold a set of ListLinks ListLink ;; must have arity N <atom 1> ... <atom n>="">

Definition at line 115 of file PutLink.cc.

References opencog::Link::_outgoing, opencog::FreeLink::_varseq, opencog::FreeLink::build_index(), opencog::FreeLink::find_vars(), opencog::Atom::getType(), and opencog::LinkCast().

+ Here is the caller graph for this function:

Handle PutLink::reduce ( void  )
virtual

Reimplemented from opencog::FreeLink.

Definition at line 253 of file PutLink.cc.

References do_reduce().

Handle PutLink::substitute_nocheck ( const Handle term,
const HandleSeq args 
) const
protected

Perform the actual beta reduction –

Substitute values for the variables in the pattern tree. This is a lot like applying the function fun to the argument list args, except that no actual evaluation is performed; only substitution. The resulting tree is NOT placed into any atomspace, either. If you want that, you must do it youself. If you want evaluation or execution to happen during or after sustitution, use either the EvaluationLink, the ExecutionOutputLink, or the Instantiator.

So, for example, if this PutLink looks like this:

PutLink EvaluationLink PredicateNode "is a kind of" ListLink VariableNode $a ConceptNode "hot patootie" ConceptNode "cowpie"

then the reduced value will be

EvaluationLink PredicateNode "is a kind of" ListLink ConceptNode "cowpie" ConceptNode "hot patootie"

Again, only a substitution is performed, there is no evaluation. Note also that the resulting tree is NOT placed into any atomspace!

Definition at line 198 of file PutLink.cc.

References opencog::FreeLink::_index, createLink, opencog::Atom::getType(), opencog::Atom::Handle, and opencog::LinkCast().

+ Here is the caller graph for this function:


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