Introduction to
Logic Programming
What
versus
How
 

Exercise 11.5 - Operation Definition


Consider a type hierarchy like the one shown below.

subtype(giraffe,mammal)
subtype(rabbit,mammal)
subtype(mammal,vertebrate)
subtype(earthworm,vertebrate)
subtype(vertebrate,animal)
subtype(invertebrate,animal)

Define an operation classify that takes an object and a type as arguments and adds factoids stating that the object has that type and all supertypes of that type. For example, executing the action classify(george,giraffe) should result in the following factoids being added to the dataset.

type(george,giraffe)
type(george,mammal)
type(george,vertebrate)
type(george,animal)