FreeLink

From OpenCog
Jump to: navigation, search

A FreeLink is a type of Link that tracks the locations of VariableNodes in it. It serves as a base type for several link types, including EvaluationLink, DeleteLink, StateLink and FunctionLink. Its primary usefulness is in the C++ implementation of the atomspace, where it serves to cache (memoize) variable locations, for rapid beta-reduction and evaluation/execution.

Users should never use the FreeLink atom directly; rather, it is a point in the type hierarchy that provides tooling and functions for other atom types.

Note that free variables cannot be typed; that is, it is not legal to use a VariableList to explicitly declare a variable. If you want to declare variables, you need to use a LambdaLink instead.

Note that the implementation correctly handles both the QuoteLink, and any embedded LambdaLinks. That is, quoted variables are not variables at all, they're constants, and so cannot be considered to be "free". Likewise, and bound variables are not free, so any bound variables appearing underneath a nested LambdaLink will not be considered. One the other hand, any free variables inside a nested LambdaLink will be discovered (that is, any variables that are actually free, and not listed in the lambda variable declarations).