GroundedPredicateNode

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

The GroundedPredicateNode is used to specify a scheme or python function that determines the virtual existence of an EvaluationLink.

An atom is "real" if it can be directly found in the atomspace. It is "virtual" if it cannot be, but still should be considered to exist if the predicate is true. Currently, there are three ways of working with virtual atoms: using the scheme cog-evaluate! function, using the pattern matcher, which is sensitive to them, and using C++ code in /opencog/execution/EvaluationLink.h

GPN's are used to create "black-box" evaluation links, about which it is impossible to reason about, without actually evaluating the given function. Because of this, a core set "clear-box" links, such as EqualLink, GreaterThanLink, AbsentLink and DeleteLink have been defined, which behave link EvaluationLinks with GPN's in them but whose behavior is "obvious" and can be reasoned about.

See the virtual links article for more details.

To search for patterns that contain GroundedPredicateNode's, without actually evaluating them, use the QuoteLink to escape the node.

Examples

A scheme example follows:

; Define some function that does something. This one always
; returns a simple truth value of true.
(define (compare-stuff a b) (cog-new-stv 1 1))

; Now, performn an evaluation:
(cog-evaluate! 
  (EvaluationLink
     (GroundedPredicateNode "scm: compare-stuff")
     (ListLink
        (ConceptNode "foo")
        (ConceptNode "bar"))))

The result of this will be the truth value returned by "compare stuff".

For more examples, see behavior tree.

See also