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

#include <Instantiator.h>

+ Collaboration diagram for opencog::Instantiator:

Public Member Functions

 Instantiator (AtomSpace *as)
 
Handle instantiate (const Handle &expr, const std::map< Handle, Handle > &vars)
 
Handle execute (const Handle &expr)
 

Private Member Functions

Handle walk_tree (const Handle &tree)
 

Private Attributes

AtomSpace_as
 
const std::map< Handle, Handle > * _vmap
 
bool _halt = false
 

Detailed Description

Definition at line 42 of file Instantiator.h.

Constructor & Destructor Documentation

opencog::Instantiator::Instantiator ( AtomSpace as)
inline

Definition at line 67 of file Instantiator.h.

Member Function Documentation

Handle opencog::Instantiator::execute ( const Handle expr)
inline

Definition at line 70 of file Instantiator.h.

References instantiate().

+ Here is the caller graph for this function:

Handle Instantiator::instantiate ( const Handle expr,
const std::map< Handle, Handle > &  vars 
)

instantiate – create a grounded expression from an ungrounded one.

Given a handle to an ungrounded expression, and a set of groundings, this will create a grounded expression.

The set of groundings is to be passed in with the map 'vars', which maps variable names to their groundings – it maps variable names to atoms that already exist in the atomspace. This method will then go through all of the variables in the expression, and substitute them with their values, creating a new expression. The new expression is added to the atomspace, and its handle is returned.

Definition at line 194 of file Instantiator.cc.

References _as, _vmap, opencog::AtomSpace::add_atom(), opencog::Handle::UNDEFINED, and walk_tree().

+ Here is the caller graph for this function:

Handle Instantiator::walk_tree ( const Handle tree)
private

Recursively walk a tree starting with the root of the hypergraph to instantiate (typically an ExecutionOutputLink).

Return the current result of the execution. If the node is an ExecutionOutputLink then it returns the final result. If the node is another list (typically a ListLink) it returns a copy of it, replacing the variables in its outgoing by their respective groundings.

See also the related function VariableList::substitute(), which will simply perform a substitution, without performing any execution. See also PutLink, which does substituion. (actually, beta reduction).

Definition at line 33 of file Instantiator.cc.

References _as, _halt, _vmap, opencog::AtomSpace::add_atom(), opencog::classserver(), createExecutionOutputLink, createLink, createPutLink, opencog::FunctionLink::factory(), opencog::FunctionLinkCast(), opencog::Atom::getTruthValue(), opencog::Atom::getType(), opencog::LinkCast(), opencog::PutLinkCast(), python.stop_go::red, opencog::AtomSpace::remove_atom(), opencog::satisfying_set(), python.undocumented.blocksworld::t, and opencog::Handle::UNDEFINED.

+ Here is the caller graph for this function:

Member Data Documentation

AtomSpace* opencog::Instantiator::_as
private

Definition at line 45 of file Instantiator.h.

bool opencog::Instantiator::_halt = false
private

Definition at line 47 of file Instantiator.h.

const std::map<Handle, Handle>* opencog::Instantiator::_vmap
private

Definition at line 46 of file Instantiator.h.


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