Schema for toys and toy parts:

Note that the schema above can be modelled in semAuth also like this:

Some toy parts:

The part list of a fire engine:

Note that in our ontology erniesFireEngine does *not* have a wheel *directly*. Instead the fire engine has a driveSystem, which in turn has a wheel as it's part.

The part list of our horse:

ex#horse : ex#Pet .

turtle: ex#horse rdf:type ex#Pet .

ex#horse [ ex#hasPart -> ex#head ] .

ex#horse [ ex#hasPart -> ex#hair ] .

If we now query for toys with wheels we don't get a single answer! (The answer to the next query is *not* given already in the fact base because "wheel" is not directly a part of the fire engine, but part of the drive system instead)

@{ toysWithWheels } ?-
?X : ex#Toy and ?X [ ex#hasPart -> ex#wheel ] .

What we need to do here is to gather and collect all *indirect* parts of toys. This is the place where a handy crafted rule comes into place. We get the expected result "erniesFireEngine" if we add a rule to the ontology which inferences all subparts of a toy.

@{ hasSubPart } ?-
?X [ ex#hasPart -> ?Z ] .

@{ hasSubPartRule }
?X [ ex#hasPart -> ?Z ] :-
?X [ ex#hasPart -> ?Y ] and ?Y [ ex#hasPart -> ?Z ] .

In order to make all the toys with wheels easily accesible we again define them via a classification rule: