5.2.1 isSubType

Introduction

The isSubType goal is used to check whether one type is a subtype of another.

Signature

isSubType(T1,T2)

Operation

This goal checks whether T1 is a subtype of T2.

Example

// Type hierarchy
Entity > Animate, Inanimate.
Animate > Animal, Human.
Inanimate > Table, Chair, BeerMug.

// Rules
is_animate(T) :- isSubType(T, Animate).
is_inanimate(T) :- isSubType(T, Inanimate).

This is available in the AAU directory as isSubType.plgCG.

Explanation

First, we have the usual type-hierarchy.

Then we have two rules called "is_animate" and "is_inanimate". They both take one formal parameter called "T". The body of the rule then checks whether T is a subtype of "Animate" or "Inanimate" respectively.

Usage

If we ask the following query:

?- is_animate(Human).

we get the following answer:

{}

This means yes. This is because in the type-hierarchy, Human is is a subtype of Animate.

On the other hand, if we ask

?-is_animate(Table).

we get the following answer:

 no.

This is because in the type-hierarchy, Table is not a subtype of Animate.

Summary

Thus the isSubType goal is used to check whether one type is a subtype of another type.


PrevLite: 5.2 Type goals
NextLite: 5.2.2 isSuperType

Prev: 5.2 Type goals
Up: 5.2 Type goals
Next: 5.2.2 isSuperType