VariableNode

From OpenCog
(Redirected from Variable)

A VariableNode is a kind of AnyNode used to represent a named "variable". It is meant to correspond to the ordinary notion of a "variable" symbol as commonly understood in term algebra, lambda calculus, first-orderlogic or model theory. VariableNodes are not like variables in C, C++, perl, python, java, scheme or lisp: they do not hold or contain values. Instead, they are declarative place-holders, used to locate or indicate a spot within whatever Link contains them. By definition, VariableNodes provide a name (a label) for the location that they indicate. Variables are almost always typed; truly untyped labels should use AnyNode instead. Anonymous (un-named, but typed) variables can be declared with the SignNode.

See LambdaLink, RuleLink, FilterLink, QueryLink, PutLink and MeetLink for usage examples.

By itself, a VariableNode is untyped, and so can be thought of implicitly ranging over all possible values in some universe. Note, however, that VariableNodes don't actually, explicitly range over anything; they are just symbols that are not constants. The semantics of the symbol depends on the context, and on the evaluator that is manipulating the expressions that contain variables in them. So, for example, when used in a RuleLink, a VariableNode plays more-or-less the same role that a 'bound variable' does in lambda calculus or proof theory.

VariableNodes are meant to be typed, by using the TypedVariableLink to specify the type. In this case, the variable is expected to behave in the same way that it would in type theory.

VariableNodes can be converted into constants by quoting them with a QuoteLink.

In the query engine, a single VariableNode can only be grounded by one Atom. The GlobNode can be used to perform wild-card matching for multiple atoms in a sequence (see glob on Wikipedia.)

VariableNodes are a special case of the AnyNode, used to provide a name to a Connector. See Connectors and Sections for details.

Variables give an explicit name to the location that is varying. An un-named, anonymous variable location can be specified with the SignNode or more generally with SignatureLinks.

Semantics

There are currently several different subsystems in OpenCog that use variables, these are:

Each of these systems give a different semantics to VariableNodes.

The natural language learning code uses AnyNode instead of VariableNode. Perhaps AnyNode should be made obsolete, and replaced by VariableNode.