Cog-evaluate!

From OpenCog
(Redirected from Evaluate)
Jump to: navigation, search

The cog-evaluate! function is a scheme function that is able to evaluate EvaluationLinks and return a TruthValue and is part of (opencog exec) module. This page attempts to explain what cog-evaluate! does today. This may change over time. cog-evaluate should be distinguished from cog-execute!, which is able to execute functions that return generic Values or Atoms.

There are two basic types of links that can be evaluated: "black-box" links, and "clear-box" links. Black-box links can execute arbitrary scheme or python code (returning a TruthValue). Because of this, black-box links cannot be used for symbolic reasoning, inference or reduction. Examples of "clear-box" evaluatable links include GreaterThanLink and EqualLink. Evaluatable links can be composed with AndLink, OrLink and NotLink to propagate crisp-logic boolean truth values. The can be combined with PlusLink and TimesLink, to perform numeric computations on the TruthValues. See PredicateFormulaLink for a detailed example.

The cog-evaluate! function can evaluate all clear-box links, and those EvaluationLinks that use a GroundedPredicateNode to specify a scheme or python function to evaluate.

Example

(cog-evaluate!
   (GreaterThanLink
      (PlusLink
         (NumberNode 2)
         (NumberNode 2))
      (TimesLink
         (NumberNode 3)
         (NumberNode 0.5))))

will yield

(SimpleTruthValue 1 1)

when evaluated at the guile prompt.

Future directions

Both atoms and truth values are special cases of values. As such, cog-evaluate could be updated to return values in general, and therefore, return both truth values and atoms as special cases. Exactly how this could work is not yet known. Currently, only cog-execute! returns generic values; we may want to alter cog-evaluate! to return only crisp binary true/false values ...

See also