The isa Link

[@to be completed]

isa(mammal, animal).
isa(bird, animal).
isa(fish, animal).
isa(horse, mammal).
isa(dog, mammal).
isa(salmon, fish).
isa(shark, fish).
isa(canary, bird).
isa(ostrich, bird).

class(SubClass, SuperClass):-
isa(SubClass, SuperClass).
class(SubClass, SuperClass):-
isa(SubClass, Mid),
class(Mid, SuperClass).
class(ItSelf, ItSelf).

has_prop(animal, shell, skin).
has_prop(mammal, birth, live).
has_prop(bird, birth, egg).
has_prop(fish, birth, egg).
has_prop(mammal, covering, hair).
has_prop(bird, covering, feathers).
has_prop(fish, covering, scales).
has_prop(mammal, limbs, legs).
has_prop(bird, limbs, wings).
has_prop(fish, limbs, fins).
has_prop(mammal, travel_by, land).
has_prop(bird, travel_by, air).
has_prop(fish, travel_by, water).
has_prop(ostrich, travel, walk).
has_prop(fish, breathes, gills).

property(Slot, Object, Prop):-
has_prop(Slot, Object, Prop).
property(Slot, Object, Prop):-
class(Object, Z),
property(Slot, Z, Prop).

For further examples, we shall use the property inheritance mechanism to work out the fare to any station from Victoria Station, given the fare zone of the station.

In order to work out the fare for a London Underground journey, we need to know certain facts. These are:

  • London Underground stations are grouped into `fare zones'.
  • The fare for a journey depends on how many fare zones you pass through on the journey.
  • If you are at Victoria, in Zone 1, and you want to go to a station in some other zone, the fare depends upon the zone you are going to.
  • Starting from Victoria (in Zone 1), the fare to any station in Zone 2 is 1.00, and to any other station in Zone 1 is 90 pence.

We can represent this by a database containing entries with fares for particular fare zones, and the fare zone for each station.

fare(zone_1, 40).
fare(zone_2, 100).
fare(zone_3a, 120).

isa('Green Park', zone_1).
isa('Piccadilly Circus', zone_2).
isa('Wembley Central', zone_3b).
isa('Richmond', zone_3b). </<p>

Now we can ask "Is the fare to 1.00?", or in Prolog:

?- fare(`Brixton', 100). </<p>

In semantic network terms, the `Brixton' node has inherited the 100 pence fare property from the zone_2 node. It is more likely that the tourist in London will want to ask something like "What is the fare to Brixton?" in which case the second argument to the query will be a variable:

?- fare('Brixton', Fare).

The value of the variable is the required fare:

Fare = 100

Providing the database entries are in the appropriate form, then the Tourist Guide as it stands so far can be altered to carry out inferencing ...[@to be completed]