TypedAtomLink

From OpenCog
Jump to: navigation, search

The TypedAtomLink is a kind of UniqueLink that can be used to associate a type to an atom. The association is globally valid, and must be unique; it is not possible to associate two different types to an atom. If polymorphism is desired, use the TypeChoice link. The TypedAtomLink resembles the TypedVariableLink, except that the typing of variables is always local in scope, whereas the typing of atoms is always global and unique. That is, only bound variables can be typed, and the type definition of a bound variable does not escape the scope of the binding. Free variables cannot be typed at all. as a corollary, the TypedVariableLink can only be used on variables, and the TypedAtomLink can only be used on atoms that are not variables.

Examples

See ArrowLink for an example of a TypedAtomLink in use, as well as a motivation for its usefulness.

It is anticipated that the TypedAtomLink will play an important role in the unified rule engine, to assign types to rules, and thus help constrain which rules can be chained together.

Implementation Notes

The AtomSpace will throw an exception if an attempt is made to link a second conflicting type to an atom. This is similar to the behavior of DefineLink. To change an atom type, the current TypedAtomLink must fist be deleted.