TypeInhNode

From OpenCog
Jump to: navigation, search

The TypeInhNode is a node specifying type inheritance. It is a special kind of TypeNode that accepts type matches for the indicated type, or any derived type.

This is best explained by example. Consider the following structure:

TypedVariableLink
    VariableNode "$foo"
    TypeInhNode "UnorderedLink"

If the above is used with the pattern matcher, then any atom that was an UnorderedLink, or anything derived from it, such as SetLink, AndLink, OrLink, etc. would be considered to be matches.

Observe that the TypeInhNode behaves as if it were a kind-of PredicateNode, in that it will evaluate to true, if the variable is of the indicated type, else it will evaluate to false.

The inverted inheritance relation is supplied by the TypeCoInhNode. Note that the TypeInhNode can be thought of as a "greatest lower bound" for the type hierarchy.

Type ranges

A range of types can be specified by using the TypeSetLink, to form a conjunction. Thus, for example, to force the variable "$foo" to be a SetLink, an UnorderedLink, or any type in between, one could write

TypedVariableLink
    VariableNode "$foo"
    TypeSetLink
        TypeInhNode "UnorderedLink"
        TypeCoInhNode "SetLink"

The above requires that "$foo" have at least the type UnorderedLink, but nothing derived from SetLink. Recall that SetLink is a special case of an UnorderedLink.