FunctionLink

From OpenCog
Jump to: navigation, search

The FunctionLink is a kind of FreeLink that provides a method that allows the link to be executed; by definition, FunctionLinks are exactly those link types that can be executed (with the cog-execute! call). Executing a FunctionLink always results in the "return" of an Atom (and NOT a TruthValue or something else). This distinguishes FunctionLinks from those atoms that return TruthValues when evaluated (with cog-evaluate). Thus, FunctionLinks can be used where-ever an Atom is expected as an argument, whereas evaluatable atoms are to be used for generating TruthValues.

FunctionLinks come in three basic forms: "black box", "clear box" and "defined". The basic "black box" link is the ExecutionOutputLink that invokes a scheme or python function (that returns an atom). Its a "black box" as there is no way to automatically reason about what the function is doing; the function definition is opaque to the atomspace. By contrast, the "defined" ExecutionOutputLink uses a DefineLink to define a DefinedSchemaNode to express the function in atomese. Such defined functions can be analyzed and reasoned about, as they are specified entirely in terms of atoms whose behaviors and function is known.

The "clear box" links are those links whose behavior is predefined, and thus also can be reasoned over: for example, PlusLink, TimesLink, FoldLink and DeleteLink. Other notable FunctionLinks are RandomChoiceLink, RandomNumberLink and SleepLink.