5.2.7 minComSuperType

Introduction

The minComSuperType goal is used to find the minimum common supertype of two types.

Signature

minComSuperType(Type1,Type2,T)

Operation

This goal returns, in the variable T, the minimum common supertype of Type1 and Type2.

If Type1 and Type2 have no explicit minimum common supertype, then the built-in type "Universal" is returned.

Example

// Type hierarchy
Entity > Animal.
Animal > Mammal, Bird.
Mammal > Elephant, Cat.

This example is available in the AAU directory as minComSuperType.plgCG.

Explanation

This example only has a very simple type-hierarchy.

Usage

If we ask the following query:

?-minComSuperType(Mammal, Bird, T).

we get the following answer:

{T = Animal}

This is because the minimum common supertype of Mammal and Bird is Animal.

If we now ask the following query:

?-minComSuperType(Mammal, Cat, T).

we get the following answer:

{T = Mammal}

This is because Mammal is a supertype of Cat, but Mammal is also a supertype of itself. This is because any type is a supertype of itself. Thus Mammal is the minimum common supertype of Cat and Mammal.

Summary

Thus the minComSuperType goal finds the minimum common supertype of two types.


PrevLite: 5.2.6 maxComSubType
NextLite: 6 Prolog for CG users

Prev: 5.2.6 maxComSubType
Up: 5.2 Type goals
Next: 6 Prolog for CG users