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.
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.
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:
TypedAtomLink GroundedPredicateNode "scm:compute-truthiness" ArrowLink ListLink ;; The input: a list of exactly two concepts TypeNode "ConceptNode" TypeNode "ConceptNode" TypeNode "TruthValue" ;; This is what is returned.