30 using namespace opencog;
35 #define dbgprt(f, varargs...) printf(f, ##varargs)
37 #define dbgprt(f, varargs...)
45 _instor(&_temp_aspace),
79 return npat_h == nsoln_h;
99 if (pattype != VARIABLE_NODE)
return true;
113 const std::set<Type> &tset = it->second;
114 std::set<Type>::const_iterator allow = tset.find(soltype);
115 return allow != tset.end();
135 if (lpat == lsoln)
return true;
139 Type pattype = lpat->getType();
140 if (CHOICE_LINK == pattype)
return true;
142 if (lpat->getArity() != lsoln->getArity())
return false;
143 Type soltype = lsoln->getType();
146 return pattype == soltype;
163 return tv->getMean() >= 0.5;
194 if (ptrn->
getType() == VARIABLE_NODE and
195 grnd->
getType() == EVALUATION_LINK and
197 LinkCast(grnd)->getOutgoingAtom(0)->getType() ==
198 GROUNDED_PREDICATE_NODE)
200 dbgprt(
"Evaluate the grounding clause=\n%s\n",
212 dbgprt(
"clause_match evaluation yeilded tv=%s\n", tvp->toString().c_str());
217 bool relation_holds = tvp->getMean() > 0.5;
218 return relation_holds;
240 const std::map<Handle, Handle>& gnds)
251 dbgprt(
"Enter eval_term CB with virt=\n%s\n",
253 dbgprt(
"grounded by gvirt=\n%s\n",
254 gvirt->toShortString().c_str());
289 dbgprt(
"eval_term evaluation yeilded tv=%s\n", tvp->toString().c_str());
294 bool relation_holds = tvp->getMean() > 0.5;
295 return relation_holds;
308 const std::map<Handle, Handle>& gnds)
310 dbgprt(
"Enter eval_sentence CB with top=\n%s\n",
313 if (top->
getType() == VARIABLE_NODE)
320 throw InvalidParamException(TRACE_INFO,
321 "Not expecting a Node, here %s\n",
324 const HandleSeq& oset = ltop->getOutgoingSet();
325 if (0 == oset.size())
326 throw InvalidParamException(TRACE_INFO,
327 "Expecting logical connective to have at least one child!");
330 if (OR_LINK == term_type)
332 for (
const Handle& h : oset)
337 else if (AND_LINK == term_type or SEQUENTIAL_AND_LINK == term_type)
339 for (
const Handle& h : oset)
344 else if (NOT_LINK == term_type)
346 if (1 != oset.size())
347 throw InvalidParamException(TRACE_INFO,
348 "NotLink can have only one child!");
352 else if (EVALUATION_LINK == term_type or
357 throw InvalidParamException(TRACE_INFO,
358 "Unknown logical connective %s\n",
static TruthValuePtr do_evaluate(AtomSpace *, Handle)
virtual void set_pattern(const Variables &, const Pattern &)
std::set< Type > _connectives
virtual bool variable_match(const Handle &, const Handle &)
std::vector< Handle > HandleSeq
a list of handles
std::shared_ptr< TruthValue > TruthValuePtr
std::set< Handle > evaluatable_terms
virtual std::string toShortString(std::string indent="")=0
#define dbgprt(f, varargs...)
std::shared_ptr< Link > LinkPtr
ClassServer & classserver(ClassServerFactory *=ClassServer::createInstance)
virtual bool post_link_match(const LinkPtr &, const LinkPtr &)
DefaultPatternMatchCB(AtomSpace *)
static const Handle UNDEFINED
Handle instantiate(const Handle &expr, const std::map< Handle, Handle > &vars)
bool isA(Type sub, Type super)
virtual bool link_match(const LinkPtr &, const LinkPtr &)
static LinkPtr LinkCast(const Handle &h)
ClassServer & _classserver
bool eval_term(const Handle &pat, const std::map< Handle, Handle > &gnds)
virtual bool clause_match(const Handle &, const Handle &)
const std::set< Handle > * _dynamic
const VariableTypeMap * _type_restrictions
unsigned short Type
type of Atoms, represented as short integer (16 bits)
void clear()
Clear the atomspace, remove all atoms.
virtual bool node_match(const Handle &, const Handle &)
bool eval_sentence(const Handle &pat, const std::map< Handle, Handle > &gnds)
virtual bool optional_clause_match(const Handle &pattrn, const Handle &grnd)