From OpenCog

The GroundedPredicateNode (or GPN) is used to specify a scheme or python function that determines the virtual existence of an EvaluationLink. It is intended that they are to be used to interface to external data systems, for example, to robot motor control systems, or to sensory input systems. They can execute arbitrary code.

Because GPN's can be used to execute arbitrary code, they are effectively "black-boxes". This prevents them from being used in symbolic reasoning, inference or reduction. Thus, it is recommended that they be used only to interface to external systems, and not for general-purpose computing within the AtomSpace.

The "black-box" behavior can be contrasted to the "clear-box" Atoms, such as EqualLink, GreaterThanLink, and so on. The clear-box links can be used to represent knowledge, as a graph, in the AtomSpace, and they can also be evaluated. As a knowledge-graph, they are well-defined, and can be reasoned about in a symbolic fashion. As evaluatable links, they can also process data: thus, the graph is like a collection of pipes, through with values flow. The GPN is like a pipe-endpoint: values can flow through it, but all reasoning and inference halt at the GPN end-point.

The GPN can also be understood as a form of virtual link; 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.


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:
     (GroundedPredicateNode "scm: compare-stuff")
        (Concept "foo")
        (Concept "bar"))))

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

For more examples, see behavior tree, and the tutorials in the /examples directory.


The signature of a GroundedPredicateNode can be specified by using a TypedAtomLink together with an ArrowLink. Such functions generally accept a list of atoms as input, and return a single truth value. Since truth values, as values in general, are part of the type hierarchy, a signature can be specified as follows:

   GroundedPredicateNode "scm:compute-truthiness"
      ListLink             ;; The input: a list of exactly two concepts
         TypeNode "ConceptNode"
         TypeNode "ConceptNode"
      TypeNode "TruthValue"        ;; This is what is returned.

See also