Dinosaur Problem

 

 

 

 

Contents

 

 

1 Introduction *

1.1 Assignment specification *

1.2 Structure of this report *

1.3 General introduction to all representations *

2 Semantic Networks (SN) *

2.1 SN: Description of Classification (Question 1) *

2.2 SN: Program listing and test runs (Question 3) *

2.2.1 SN: Program listing *

2.2.2 SN: Test Runs *

2.3 SN: Evaluation of the representation (Question 2) *

3 Frames (F) *

3.1 F: Description of Classification (Question 1) *

3.2 F: Program listing and test runs (Question 3) *

3.2.1 F: Program listing *

3.2.2 F: Test Runs *

3.3 F: Evaluation of the representation (Question 2) *

4 Production Rules (PR) *

4.1 PR: Description of Classification (Question 1) *

4.2 PR: Program listing and test runs (Question 3) *

4.2.1 PR: Program listing *

4.2.2 PR: Test Runs *

4.3 Evaluation of the representation (Question 2) *

5 Conclusion *

6 References *

 

 

< P> 

 

 

 

Dinosaur Problem

 

 

 

  1. Introduction
    1. Assignment specification
    2. The following account is about the knowledge representation of the dinosaur problem in Prolog. The given facts to represent are listed in a table.

      dinosaur

      eating

      habitat

      size

      neck

      stance

      horns
      /crests

      individual

      triceratops

      veg

      land

      large

      short

      quadruped

      3horns

      Trix

      ichthyosaur

      carnivore

      sea

      large

      none

      swimming

      none

      -

      pterodactyl

      carnivore

      air

      small

      short

      flying

      beak

      -

      brontosaurus

      veg

      swamp

      large

      long

      quadruped

      none

      Brix

      protoceraptos

      veg

      land

      small

      short

      quadruped

      beak

      Protox

       

      The given knowledge base is rather small. In larger knowledge base (KB), the advantages of different representations approaches would be more visible. There are no exceptions in our given set of facts, neither the properties of an individual in a class overrides the general set of prope rties. If we would admit such exceptions, than we could add special subclasses of Triceratopses or Trix could have one horn broken (accident in childhood) and it could have just 2 horns then. However, I will consider the exception problem in each representation.

       

    3. Structure of this report
    4.  

      In this report, there is a section for each representation. After a description of a representation follows the program listings and test runs. I found it better to list the program before I evaluate and asses the representation in the third part of each section.

      The Program listing and test runs, include also information, which could be stated in the Representation Description part, but it’s better to mention them together with the code or examples (comments in the program code and comments on individual the test runs).
      I use the abbreviations SN = Semantic Network, F = Frames, PR = Production Rules and KB = Knowledge Base.

       

    5. General introduction to all representations

 

All three implementation, implement the same structure of knowledge and the same properties of objects, in that structure involved. In my representation, new properties of any class, can be added easily. In the tes t runs, I demonstrate similar queries on each representation. I think, it’s the best way, how to compare those different strategies of representing the given problem. In the Test Runs part I compare following features in each representation:

 

 

The question: "What are all large-sized objects in your knowledge ?" is, according to me, an example of a hardest type of question, we would probably demand from an AI system to test it. This question goes across all the knowledge of such system. We can easily construct other similar questions, but to compar e the results, I used the same questions in each representation.

In SN and F, similar predicate names are used. Generaly, there is different predicate used, to show the results, which include inheritance. The firs is all_properties predicate, which include the outputs, informing the user about how program retrieves the structured date (with "going up…" outputs). The second (inheritance including) predicate is search, which has same code as all_properties, but without the text outputs, which would be redundant when searching through all the object in the KB.

  1. Semantic Networks (SN)
  2.  

    1. SN: Description of Classification (Question 1)
    2.  

      In my Dinosaur Semantic network I created a concept of an object, and it’s properties. This is represented as a predicate has_property(Node, RelationsipDescription, OtherNode). Semantic network is then build in Prolog using this predicate. The OtherNodes, which are common for certain dinosaurs, are of course in Prolog represented by the same predicate. This actually links different parts of dinosaur semantic net, and enables us to ask questions. The description pa rt is also included in the program code.

       

    3. SN: Program listing and test runs (Question 3)
      1. SN: Program listing
      2.  

        /*-------------------------------------- ----------------*//* semantic networks *//* */

        /* Vojtech Huser */

        /* dinosaur problem */

        /* */

        /*------------------------------------------------------*/

         

        /* KB definition--------------------------------------- */

        /*----------------- -------------------------------------*/

         

        /* properties of an ANIMAL */

        /*---------------------------------*/

        has_property(animal,can,live).

         

         

        /* properties of a DINOSAUR */

        /*---------------------------------*/

        has_property(dinosaur,isa,animal).

        has_property(dinosaur,lived,years_ago).

         

         

        /* properties of each dinosaur kind*/

        /*---------------------------------*/

        < P> 

        /* 1) properties of triceratops */

         

        has_property(triceratops,isa,dinosaur).

        has_property(triceratops,eating,veg).

        has_property(triceratops,habitat,land).

        has_property(triceratops,size,large).

        has_property(triceratops,neck,short).

        has_property(triceratops,stance,quadruped).

        has_property(triceratops,horns_crests,three_horns).

         

        /* 2) properties of ichtyosaur */

         

        has_property(ich tyosaur,isa,dinosaur).

        has_property(ichtyosaur,eating,carnivore).

        has_property(ichtyosaur,habitat,sea).

        has_property(ichtyosaur,size,large).

        has_property(ichtyosaur,neck,none).

        has_property(ichtyosaur,stance,swimming).

        has_property(ichtyosaur,horns_crests,none).

         

         

        /* 3) properties of pterodactyl */

         

        has_property(pterodactyl,isa,dinosaur).

        has_property(pterodactyl,eating,carnivore).

        has_ property(pterodactyl,habitat,air).

        has_property(pterodactyl,size,small).

        has_property(pterodactyl,neck,short).

        has_property(pterodactyl,stance,flying).

        has_property(pterodactyl,horns_crests,beak).

         

         

        /* 4) properties of brontosaurus */

         

        has_property(brontosaurus,isa,dinosaur).

        has_property(brontosaurus,eating,veg).

        has_property(brontosaurus,habitat,swamp).

        has_property(brontosaurus,size,large).< /P>

        has_property(brontosaurus,neck,long).

        has_property(brontosaurus,stance,quadruped).

        has_property(brontosaurus,horns_crests,none).

         

         

        /* 5) properties of protoceraptos */

         

        has_property(protoceraptos,isa,dinosaur).

        has_property(protoceraptos,eating,veg).

        has_property(protoceraptos,habitat,land).

        has_property(protoceraptos,size,small).

        has_property(protoceraptos,neck,short).

        has_property(pro toceraptos,stance,quadruped).

        has_property(protoceraptos,horns_crests,beak).

         

         

        /* definition of individual dinosaurs */

        /*------------------------------------*/

         

        has_property(trix ,isa,triceratops).

        has_property(brix ,isa,brontosaurus).

        has_property(protox,isa,protoceraptos).

         

         

        /* end of KB definition */

         

         

        /* inheritance procedure--------------- ----------------*/

        /*------------------------------------------------------*/

         

         

        /* named all_properties because it's more suitable */

        /* (I think). It returns all has_property properties */

        /* in KB given by programmer and derives */

        /* all other properties from all Superclasses */

        /* through recursion and isa property, */

        /* which is most crucial property */

        /*- --------------------------------------------------*/

         

        all_properties(Who,What,Value) :- has_property(Who,What,Value).

         

        all_properties(Who,What,Value) :-

        has_property(Who,isa,Superclass),

        nl,write('going up to a '),write(Superclass),nl,

        all_properties(Superclass,What,Value).

         

         

        %search function

        %---------------

        %used when the more complicated question is ask ed

        %basically is the same as all_properties, but without

        %text outputs, while in searching there are more of

        %them and they are not wanted

         

        search(Who,What,Value) :- has_property(Who,What,Value).

         

        search(Who,What,Value) :-

        has_property(Who,isa,Superclass),

        search(Superclass,What,Value).

         

      3. SN: Test Runs
      4. Here are the commands and its results, which check the whole program.

        1. SN:Beginning stage
        2. Here I demonstrate the properties of each object, which are given at the beginning in the knowledge base by the predicate has_property. No inheritance or non-programmer-given facts are present.

           

          ?- ['a:\pr.txt'].a:\pr.txt compiled, 0.01 sec, 0 bytes.

          Yes

           

          ?- has_property(animal,What,Value).What = canValue = live ;No

          ?- has_property(dinosaur,What,Value).What = isaValue = animal ;What = livedValue = years_ago ;No

          ?- has_property(protoceraptos,What,Value).What = isaValue = dinosaur ;

           

          What = eating

          Value = veg ;

           

          What = habitat

          Value = land ;

           

          What = size

          Value = small ;

           

          What = neck

          Value = short ;

           

          What = stance

          Value = quadruped ;

           

          What = horns_crests

          Value = beak ;

          No

           

          ##

          has_property(trix,What,Valu e).

           

        3. SN:Central Procedure
        4.  

          In the SN representatin, the is no need to run the any additional procedure to obtain the inheritance. This part of Central Procedure will be used in F and PR.

        5. SN:Checking inheritance

 

I’m using the all_properties predicate to retrieve the facts about the object. The "going up…" sentece i s there, just to demostrate, how the program gets the answer, which I found good to show.. It could be easily removed and it is removed in the search predicate, which is used later.

 

 

##

 

  • SN:Dinosaur

 

##

 

  • SN:Dinosaur kind

 

##

 

  • SN:Individual

 

In the SN representatin, we achieved for individual, to have the property isa(dinosaur-group)

 

?- all_properties(trix,What,Value).What = isaValue = triceratops ;going up to a triceratops

What = isaValue = din osaur ;What = eatingValue = veg ;What = habitatValue = land ;What = sizeValue = large ;What = neckValue = short ;What = stanceValue = quadruped ;What = horns_crestsValue = three_horns ;going up to a dinosaur

 

What = isa

Value = animal ;

 

What = lived

Value = years_ago ;

 

going up to a animal

 

What = can

Value = live ;

No

 

        1. Further Prolog questions

 

In following questions, I use the search predicate, which is same as all_properties, but without the text outputs, while we search the whole KB, and we would get unwanted amount of "going up…" outputs with all_properties predicate.

 

 

 

?- search(Who,size,large) .Who = triceratops ;Who = ichtyosaur ;Who = brontosaurus ;

Who = trix ;

Who = brix ;

No

 

  • SN:Who is animal ?

 

?- search(Who,isa,animal).Who = dinosaur ;Who = triceratops ;Who = ichtyosaur ;Who = pterodactyl ;Who = brontosaurus ;Who = protoceraptos ;Who = trix ;Who = brix ;Who = protox ;No

 

  • SN:Who can live ?

 

?- search(Who,can,live).Who = animal ;Who = dinosaur ;Who = triceratops ;Who = ichtyosaur ;Who = pterodactyl ;Who = brontosaurus ;Who = protoceraptos ;Who = trix ;Who = brix ;Who = protox ;No

 

  • SN:Who is dinosaur ?

 

?- search(W ho,isa,dinosaur).Who = triceratops ;Who = ichtyosaur ;Who = pterodactyl ;Who = brontosaurus ;Who = protoceraptos ;Who = trix ;Who = brix ;Who = protox ;No

 

  • SN:Who lived years_ago ?

?- search(Who,lived,years_ago).Who = dinosaur ;

Who = triceratops ;

Who = ichtyosaur ;

Who = pterod actyl ;

Who = brontosaurus ;

Who = protoceraptos ;

Who = trix ;

Who = brix ;

Who = protox ;

No

    1. SN: Evaluation of the representation (Question 2)

In the SN it was very straightforward, to implement recursion through recursion There was no need for any central procedure or asserting any additional knowledge to the KB. (expressive adequacy). On the other hand, the programer-given facts at the beginning, do not include any structure. The only demand is to have the isa property present. The only exception is the beginning object (in SN it is an animal). We were able for individuals to achieve in the list of all properties the isa(dinosaur-group) property. It we would define any other additional properties not overriding present general pr operties, we could easy do it. Overriding the general properties, would result into double presence of that property. However, the individual different property, would be listed first, and we could include the procedure, which would operate on the final list of properties, and which would delete the second occurrence. But this was not part of the assignment and that’s why I did not write appropriate Prolog code for it.
From [1] we make add some more SN advantages and disadvantages.

  1. Frames (F)
  2.  

    1. F: Description of Classification (Question 1)
    2.  

      In my Dinosaur Frames model I created a the same concepts of anima, dinosaur, dinosaur-kind and individual. The frames are in Prolog implemente d as a predicate frame(name(xxx),isa(yyyy),[property1(value1), property2(value2),…]). The individuals can have their additional propertis added to their properties. They also can override general properties, but the same problem arises as in the SN representation. Because the isa property is separated from other propertis, I introduced additional predicates (x-versions and predicate put_isa_into_properties) to enable all types of questions. This is more explained in the following section.

       

    3. F: Program listing and test runs (Question 3)
      1. F: Program listing
      2.  

        /*------------------------------------------------------*/

        /* frames */

        /* */

        /* Vojtech Huser */

        /* dinosaur problem */

        /* */

        /*------------------------------------------------------*/

         

        /* KB definition--------------------------------------- */

        /*----------------------------------------------- -------*/

         

        /* frame ANIMAL */

        /*---------------------------------*/

        frame(name(animal),isa(creature),[can(live)]).

         

         

        /* frame DINOSAUR */

        /*---------------------------------*/

        frame(name(dinosaur),isa(animal),[lived(years_ago)]).

         

         

        /* frames of each dinosaur kind*/

        /*---------------------------------*/

         

        /* 1) triceratops */

         

        frame (name(triceratops),isa(dinosaur),

        [ eating(veg),

        habitat(land),

        size(large),

        neck(short),

        stance(quaruped),

        horns_crests(three_horns)

        ]).

         

        /* 2) ichtyosaur */

         

        frame(name(ichtyosaur),isa(dinosaur),

        [ eating(carnivore),

        habitat(sea),

        size(large),

        neck(none),

        stance(swimming),

        horns_crests(none)

        < P> ]).

         

        /* 3) pterodactyl */

         

        frame(name(pterodactyl),isa(dinosaur),

        [ eating(carnivore),

        habitat(air),

        size(small),

        neck(short),

        stance(flying),

        horns_crests(beak)

        ]).

         

        /* 4) brontosaurus */

         

        frame(name(brontosaurus),isa(dinosaur),

        [ eating(veg),

        habitat(swamp),

        size(large),

        neck(l ong),

        stance(quadruped),

        horns_crests(none)

        ]).

         

        /* 5) protoceraptos */

         

        frame(name(protoceraptos),isa(dinosaur),

        [ eating(veg),

        habitat(land),

        size(small),

        neck(short),

        stance(quadruped),

        horns_crests(beak)

        ]).

         

        /* definition of individual dinosaurs */

        /*------------------------------------*/

         

        frame(name(trix) ,isa(triceratops) ,[]).

        frame(name(brix) ,isa(brontosaurus) ,[]).

        frame(name(protox),isa(protoceraptos),[]).

         

         

        /* end of KB definition */

         

        /* inheritance and search procedure--------------------*/

        /*------------------------------------------------------*/

         

        /* ineritance procedure is named all_properties */

        /* It returns all properties */

        /* in KB given by programmer and derives */

        /* all other properties from all Superclasses */

        /* through isa property of a frame */

        /*---------------------------------------------------*/

         

        all_properties(Fact,About_what) :-

        frame(name(About_what),_,Properties),

        member(Fact,Properties).

        /* using swi-prolog built-in predicate member*/

         

        all_properties(Fact ,Child) :-

        frame(name(Child),isa(Parent_of_child),_),

         

        nl,write('going up to a frame '),

        write(Parent_of_child),nl,

         

        all_properties(Fact,Parent_of_child).

         

        /* search procedure is used in */

        /* the example runs. It is basically */

        /* same as all_properties procedure, */

        /* but without some text outputs. */

         

         

        search(Fact,About_what) :-

        frame(name(About_what),_,Properties),

        member(Fact,Properties).

         

        search(Fact,Child) :-

        frame(name(Child),isa(Parent_of_child),_),

        search(Fact,Parent_of_child).

         

         

        /* isa property problem related procedures ------------*/

        /*------------------------------------------------------*/

         

        %following procedure corrects the problem with isa property

        %which is in frame implemented separately from

        %other properties and creates new set of xframes

        %as modified frames by putting the isa property

        %together with other properties

         

        put_isa_into_properties(X) :- frame(name(X),isa(Y),Properties),

        assert(xframe(name(X),isa(Y),[isa(Y)|Properties])).

         

         

        %---------------------------------------------

        %xall_properties is same as all _properties, but it uses

        %xframes, so that it includes the isa property

        %---------------------------------------------

         

        xall_properties(Fact,About_what) :-

        xframe(name(About_what),_,Properties),

        member(Fact,Properties).

        /* using swi-prolog built-in predicate member*/

         

        xall_properties(Fact,Child) :-

        xframe(name(Child),isa(Parent_of_child),_),

         

        nl,writ e('going up to a xframe '),

        write(Parent_of_child),nl,

         

        xall_properties(Fact,Parent_of_child).

         

        %-------------------------------------

        %xsearch is same as search, but it uses

        %xframes, so that it includes the

        %isa property. With xsearch we can perform

        %also questions about isa property

         

        xsearch(Fact,About_what) :-

        xframe(name(About_what),_,Properties),

        member(Fact,Properties).

         

        xsearch(Fact,Child) :-

        xframe(name(Child),isa(Parent_of_child),_),

        xsearch(Fact,Parent_of_child).

         

         

      3. F: Test Runs
      4. Here are the commands and its results, which check the whole program.

        1. F:Beginning stage
        2. After compiling we can list our knowledge, and check that, the knowledge we are going to add is not yet present. (No predicate xframe so far exist).

           

          ?- ['a:\fr.txt'].a:\fr.txt compiled, 0.02 sec, 4,752 bytes.?- listing(frame).frame(name(animal), isa(creature), [can(live)]).frame(name(dinosaur), isa(animal), [lived(years_ago)]).frame(name(triceratops), isa(dinosaur), [eating(veg), ha bitat(land), size(large),
          neck(short), stance(quaruped), horns_crests(three_horns)]).

          frame(name(ichtyosaur), isa(dinosaur), [eating(carnivore), habitat(sea), size(large),
          neck(none), stance(swimming), horns_crests(none)]).

          frame(name(pterodactyl), isa(dinosaur), [eating(carnivore), habitat(air), size(small),
          neck(short), stance(flying), horns_crests(beak)]).

          frame(name(brontosaurus), isa(dinosaur), [eating(veg), habitat(swamp), size(large),
          neck(long), stance(quadruped), horns_crests(none)]).

          frame(name(protoceraptos), isa(dinosaur), [eating(veg), habitat(land), size(small),
          neck(short), stance(quadruped), horns_crests(beak)]).

          frame(name(trix), isa(triceratops), []).

          frame(name(brix), isa(brontosaurus), []).

          frame(name(protox), isa(protoceraptos), []).

          Yes

           

          ?- listing(xframe).

          Corr ect to `frame'? no

          [WARNING: No predicates for `xframe']

          No

           

        3. F:Central Procedure
        4.  

          In F representation, there is no need to have any central procedure to produce the inheritance. The inheritance is defined recursively. But because of the isa property, being implemented separately in a from other properties, I created the put_isa_into_properties predicate, which creates new set of xframes, with isa< /I> property being included in the set of properties. (as we can see in the listing) The xframes and x-versions of the predicates, will enable us later to ask question about the isa property.

           

          ?- put_isa_into_properties(X).

          X = animal ;

          X = dinosaur ;

          X = triceratops ;

          X = ichtyosaur ;

          X = pterodactyl ;

          X = brontosaurus ;

          X = protoceraptos ;

          X = trix ;

          X = brix ;

          X = protox ;

          No

           

          ?- listing(xframe).

          xframe(name(animal), isa(creature), [isa(creature), can(live)]).

          xframe(name(dinosaur), isa(animal), [isa(animal), lived(years_ago)]).

          xframe(name(triceratops), isa(dinosaur), [isa(dinosaur), eating(veg), habitat(land),
          size(large), neck(short), stance(quaruped), horns_crests(three_horns)]).

          xframe(name(ichtyosaur), isa(dinosaur), [isa(dinosaur), eating(carnivore),
          habitat(sea), size(large), neck(none), stance(swimming), horns_crests(none)]).

          xframe(name(pterodactyl), isa(dinosaur), [isa(dinosaur), eating(carnivore),
          habitat(air), size(small), neck(short), stance(flying), horns_crests(beak)]).

          xframe(name(brontosaurus), isa(dinosaur), [isa(dinosaur), eating(veg), habitat(swamp),
          size(large), neck(long), stance(quadruped), horns_crests(none )]).

          xframe(name(protoceraptos), isa(dinosaur), [isa(dinosaur), eating(veg), habitat(land),
          size(small), neck(short), stance(quadruped), horns_crests(beak)]).

          xframe(name(trix), isa(triceratops), [isa(triceratops)]).

          xframe(name(brix), isa(brontosaurus), [isa(brontosaurus)]).

          xframe(name(protox), isa(protoceraptos), [isa(protoceraptos)]).

          Yes

        5. F:Checking inheritance

 

I’m using the all_properties predicate to retrieve the facts about the object. The "going up…" sentece is there, just to demostrate, how the program gets the answer, which I found good to show.. It could be easily removed and it is removed in the search predicate, which is used later.

 

  • F:Animal

 

We can see here the difference, between the results of all_properties and its x-version.

 

?- all_properties(Fact,animal).Fact = can(live) ;going up to a frame creatureNo

?- xall_properties(Fact,animal).Fact = isa(creature) ;Fact = can(live) ;going up to a xframe creatureNo

 

  • F:Dinosaur

 

The x-version results are more complete.

 

?- all_properties(Fact,dinosaur).

Fact = lived(years_ago) ;

going up to a frame animal

Fact = can(live) ;

going up to a frame creature

No

 

?- xall_properties(Fact,dinosaur).Fact = isa(animal) ;Fact = lived(years_ago) ;going up to a xframe animal

Fact = isa(creature) ;

Fact = can(live) ;

going up to a xframe creature

No

 

  • F:Dinosaur kind

 

On the examples of Dinosaur, and Animal, we can see the difference in output between all_properties and xall_properties. In the Dinosaur kind example, I will demonstrate the xall_properties only, as the result is more complete.

 

?- xall_properties(Fact,brontosaurus).Fact = isa(dinosaur) ;Fact = eating(veg) ;Fact = habitat(swamp) ;Fact = size(large) ;Fact = neck(long) ;Fact = stance(quadruped) ;Fact = horns_crests(none) ;

going up to a xframe dinosaur

Fact = isa(animal) ;

Fact = lived(years_ago) ;

going up to a xframe animal

Fact = isa(creature) ;

Fact = can(live) ;

going up to a xframe creature

No

 

  • F:Individual

 

Here I will use both predicates: all_properties and xallproperties. We can notice, that the xall_properties, answers also, that Trix is triceratops. We were able to get this answer also in SN representation.

 

?- all_properties(Fact,trix).going up to a frame triceratopsFact = eating(veg) ;

Fact = habitat(land) ;

Fact = size(large) ;

Fact = neck(short) ;

Fact = stance(quaruped) ;

Fact = horns_crests(three_horns) ;

going up to a frame dinosaur

Fact = lived(years_ago) ;

going up to a frame animal

Fact = can(live) ;

going up to a frame creature

No

 

?- xall_properties(Fact,trix).

Fact = isa(triceratops) ;

going up to a xframe triceratops

Fact = isa(dinosaur) ;

Fact = eating(veg) ;

Fact = habitat(land) ;

Fact = size(large) ;

Fact = neck(short) ;

Fact = stance(quaruped) ;

Fact = horns_crests(three_horns) ;

going up to a xframe dinosaur

Fact = isa(animal) ;

Fact = lived(years_ago) ;

going up to a xframe animal

Fact = isa(creature) ;

Fact = can(live) ;

going up to a xframe creature

No

 

        1. F: Further Prolog quest ions

 

In following questions, I use the search or xsearch predicate, which is same as all_properties, but without the text outputs, while we search the whole KB, and we would get unwanted amount of "going up…" outputs with all_properties predicate.

 

  • F:Who is large ?

 

?- search(size(large),Who).

Who = triceratops ;

Who = ichtyosaur ;

Who = brontosaurus ;

Who = trix ;

Who = brix ;

No

 

  • F:Who is animal ?

 

We need to use the xsearch version for this question.

 

?- xsearch(isa(animal),Who).

Who = dinosaur ;

Who = triceratops ;

Who = ichtyosaur ;

Who = pterodactyl ;

Who = brontosaurus ;

Who = protoceraptos ;

Who = trix ;

Who = brix ;

Who = protox ;

No

 

  • F:Who can live ?

 

Search and xsearch version produce the same relust, as we do not ask about isa property of an object.

 

?- search(can(live),Who).

Who = animal ;

Who = dinosaur ;

Who = triceratops ;

Who = ichtyosaur ;

Who = pterodactyl ;

Who = brontosaurus ;

Who = protoceraptos ;

Who = trix ;

Who = brix ;

Who = protox ;

No

 

  • F:Who is dinosaur ?

 

?- xsearch(isa(dinosaur),Who).

Who = triceratops ;

Who = ich tyosaur ;

Who = pterodactyl ;

Who = brontosaurus ;

Who = protoceraptos ;

Who = trix ;

Who = brix ;

Who = protox ;

No

 

  • F:Who lived years_ago ?

 

?- search(lived(years_ago),Who).

Who = dinosaur ;

Who = triceratops ;

Who = ichtyosaur ;

Who = pterodactyl ;

Who = bro ntosaurus ;

Who = protoceraptos ;

Who = trix ;

Who = brix ;

Who = protox ;

No

    1. F: Evaluation of the representation (Question 2)

 

In the franes representation I defined the creature object, while the frame form of defining the initial knowledge ex pects the isa property. On the other hand, rhis unified form of a frames is unifying the knowledge base, but on the other hand could be a limitation. (when information is not required, not known or uncertain). Also in this representation we were able to implement individuals with separate properties, as it was possible in SN. (expressive adequacy). It’s important to state, that in this program, the most important fature of frames is not used – the methods ! That’s why the capabilities of the F were not grea ter that those of SN ! Frames methods enable than many additional features (not found in SN). In [2] other advantages and disadvantages of frames a listed:

  • Methods of a frame include procedural code attached to an object
  • The unified structure of a frame (some properties, may be included in a frame structure itself. (in our example, we could include the size property, as we included the isa property).
  • The information in such slots, may not be always filled in. But by sta ting these default properties, we can at least retreive the names of propertis (if not their values). This might be a form of a representing some default information about an object (represented as a frame of a particular structure.)
  • However, frame structure have to be designed by a programmer. (incompleteness)
  • More sophisticated relationships can be implemented in frames network (compared to SN). A frame property, can be a pointer to another frame. By having information encapsulated in a frame, there is no danger of spreading to a wrong part of a frame net. (unlike SN). (reasoning efficiency).

 

  1. Production Rules (PR)
  2.  

    1. PR: Description of Classification (Question 1)
    2.  

      When I was creating the Prolog programs for each representation, I found the Production rules the hardest one and I spend more time with it, compared with SN or F.

      In my Dinosaur Frames model I created a concept of an animal and it’s properties..

      The program starts with initial knowledge and the rules are used to asses the new knowledge into the Prolog KB. (see comments in program code).

      In my program, the inherita nce is implemented in the rules themselves. That’s why the is an OR condition in each rule is at the beginning. When rules are applied, it’s important, that they are applied in bottom up order. The brontosaur than becomes dinosaur in his brontosaur rule. Next dinosaur rule, makes that brontosau (because it is dinosaur from previous rule) also an animal, etc.... That’s the inheritance inclusion in the rules and that’s why we need OR condition at the beginning of each rule.

      This OR is not necessary a t the bottom of our structure, however I kept it there. Later we might enlarge the depth of our structure and than we won’t have to change the each dinosaur-kind rule. The problem if individuals and rules for individuals is noticed in the section Program runs and is evaluated in the third part.

       

    3. PR: Program listing and test runs (Question 3)
    4. < OL>
    5. PR: Program listing
    6.  

      /*------------------------------------------------------*//* production rules */

      /* */

      /* Vojtech Huser */

      /* dinosaur problem */

      /* */

      /*------------------------------------------------------*/

       

       

      /* KB definition--------------------------------------- */

      /*------------------------------------------------------*/

       

       

       

      %definition of our objects of interest and

      %the initial knowledge about them, which will enable

      %us apply the rules.

      /*---------------------------------*/

       

      exist(animal,animal_group).

      exist(dinosaur,dinosaur_group).

       

      exist(triceratops,triceratops_group).

      exist(ichtyosaur,ichtyosaur_group).

      exist(pterodactyl,pterodactyl_group).

      exist(brontosaurus,brontosaurus_group).

      exist(protoceraptos,protoceraptos_group).

       

      exist(trix, triceratops_group).

      exist(brix, brontosaurus_group).

      exist(protox,protoceraptos_ group).

       

       

       

       

      %rules definition

      %-----------------

      %all rules and new infered knowledge make sence,%only when they are%applied on existing objects and when they are%applied on the right existing objects (object_group)%rules than add new knowledge to the KB (assert(fact...))

      %rules include in themselves the inheritance

      /*---------------------------------*/

       

       

      %animal rule

      % ---------------------------------

       

      animal_rule(X) :- (exist(X,animal_group) ; fact(X,isa,animal)), %this OR is commented in description

      assert(fact(X,can,live)),

       

      %adding the isa fact (important for inheritance in other rules !)

      assert(fact(X,isa,creature)).

       

       

      %dinosaur rule

      %---------------------------------

       

      dinosaur_rule(X) :-

      (exist(X,dinosaur_group) ; fact(X,isa,dinosaur)),

      %this OR is commented in description

      assert(fact(X,lived,years_ago)),

       

      %adding the isa fact (important for inheritance in other rules !)

      assert(fact(X,isa,animal)).

       

       

      %each dinosaur-kind rules

      %---------------------------------

      % 1) triceratops

      %----------------

      triceratops_rule(X) :- (exis t(X,triceratops_group) ; fact(X,isa,triceratops)), % inheritance assert(fact(X,eating,veg)), assert(fact(X,habitat,land)),

      assert(fact(X,size,large)),

      assert(fact(X,neck,short)),

      assert(fact(X,stance,quadruped)),

      assert(fact(X,horns_crests,three_horns)),

       

      %adding the isa fact (important for inheritance in other rules !)

      assert(fact(X,isa,dinosaur)).

       

       

      % 2) ichtyosaur

      %----------------

      ichtyosaur_rule(X) :- (exist(X,ichtyosaur_group) ; fact(X,isa,ichtyosaur)), % inheritance assert(fact(X,eating,carnivore)), assert(fact(X,habitat,sea)), assert(fact(X,size,large)),

      assert(fact(X,neck,none)),

      assert(fact(X,stance,swimming)),

      assert(fact(X,horns_crests,none)),

       

      %adding the isa fact (important for inheritance in other rules !)

      assert(fact(X,isa,dinosaur)).

       

       

      % 3) pterodactyl

      %----------------

      pterodactyl_rule(X) :- (exist(X,pterodactyl_group) ; fact(X,isa,pterodactyl)), % inheritance assert(fact(X,eating,carnivore)), assert(fact(X,habitat,air)), assert(fact(X,size,small)), assert(fact(X,neck,short)),

      assert(fact(X,stance,flying)),

      assert(fact(X,horns_crests,beak)),

       

      %adding the isa fact (important for inheritance in other rules !)< /P>

      assert(fact(X,isa,dinosaur)).

       

       

      % 4) brontosaurus

      %----------------

       

      brontosaurus_rule(X) :- (exist(X,brontosaurus_group) ; fact(X,isa,brontosaurus)), % inheritance assert(fact(X,eating,veg)), assert(fact(X,habitat,swamp)), assert(fact(X,size,large)), assert(fact(X,neck,long)),

      assert(fact(X,stance,quadruped)),

      assert(fact(X,horns_crests,none)),

       

      %ad ding the isa fact (important for inheritance in other rules !)

      assert(fact(X,isa,dinosaur)).

       

       

       

      % 5) protoceraptos

      %----------------

      protoceraptos_rule(X) :-

      (exist(X,protoceraptos_group) ; fact(X,isa,protoceraptos)), % inheritance

      assert(fact(X,eating,veg)),

      assert(fact(X,habitat,land)),

      assert(fact(X,size,small)),

      assert(fact(X,neck,short)),

      assert(fact(X,stance,quadruped)),

      assert(fact(X,horns_crests,beak)),

       

      %adding the isa fact (important for inheritance in other rules !)

      assert(fact(X,isa,dinosaur)).

       

      /*------------------------------------------------------*/

      /* end of KB definition */

       

       

      /* rule usage -----------------------------------------*//*------------------------------------------------------*/

      %apply rules to infer new knowledge%rules applied in bottom up order ! important !

      %only then inheritance can occur !/*-----------------------------------------------------*/

       

      apply_rules(X) :-

      nl,write('-----------------applying individual dinosaur rules'),nl,

      write('------triceratops rule'),

      triceratops_rule(X);

       

      nl,write('------ichtyosaur rule'),

      ichtyosaur_rule(X);

      &nb sp;

      nl,write('------pterodactyl rule'), pterodactyl_rule(X);

      nl,write('------brontosaurus rule'), brontosaurus_rule(X);

      nl,write('------protoceraptos rule'),

      protoceraptos_rule(X);

       

      nl,write('-----------------applying dinosaur rule'),nl,

      dinosaur_rule(X);

       

      nl,write('-----------------applying animal rule'),nl,

      animal_rule(X).

       

    7. PR: Test Runs
    8. Here are the commands and its results, which check the whole program.

      1. PR:Beginning stage
      2. By following two commands, we demostrate the initial state, before running the central procedure of applying the rules. The fact predicate is used, when applying the rules and adding new knowledge to the knowledge base. After consulting, there is no fact predicate in KB, which is logically correct. By third query, we list, the defined object, which we are interested in. We can easily add some more, if we want.

         

        ?- ['a:\pr.txt'].

        a:\pr.txt compiled, 0.01 sec, 6,440 bytes.

         

        Yes

        ?- listing(fact).

        [WARNING: No predicates for `fact']

         

        No

        ?- listing(exist).

        exist(animal, animal_group).

        exist(dinosaur, dinosaur_group).

        exist(triceratops, triceratops_group).

        exist(ichtyosaur, ichtyosaur_group).

        exist(pterodactyl, pterodactyl_group).

        exist(brontosaurus, brontosaurus_group).

        exist(protoceraptos, proto ceraptos_group).

        exist(triceratopsx, triceratops_group).

        exist(brix, brontosaurus_group).

        exist(protox, protoceraptos_group).

        Yes

         

      3. PR:Central Procedure
      4. Next step is naturally, runing the central procedure of applying the rules and adding the results into the KB, using predicate fact. In the apply_rules procedure, rules add new knowledge. Rules are applied in bottom up order, which is important for inherit ance, which can that occur.

         

        ?- apply_rules(X).

        -----------------applying individual dinosaur rules

        ------triceratops rule

        X = triceratops ;

        X = trix ;

        ------ichtyosaur rule

        X = ichtyosaur ;

        ------pterodactyl rule

        X = pterodactyl ;

        ------brontosaurus rule

        X = brontosaurus ;

        X = brix ;

        ------protoceraptos rule

        X = protoceraptos ;

        X = protox ;

        -----------------applying dinosaur rule

        X = dinosaur ;

        X = triceratops ;

        X = trix ;

        X = ichtyosaur ;

        X = pterodactyl ;

        X = brontosaurus ;

        X = brix ;

        X = protoceraptos ;

        X = protox ;

        -----------------applying animal rule

        X = animal ;

        X = dinosaur ;

        X = triceratops ;

        X = trix ;

        X = ichtyosaur ;

        X = pterodactyl ;

        X = brontosaurus ;

        X = brix ;

        X = protoceraptos ;

        X = protox ;

        No

      5. PR:Checking inheritance

 

  • PR:Animal

 

?- fact(animal,What,Value).What = canValue = live ;What = isaValue = creature ;No

 

  • PR:Dinosaur

 

?- fact(dinosaur,What,Value).What = livedValue = years_ago ;

 

What = isa

Value = animal ;

 

What = can

Value = live ;

 

What = isa

Value = creature ;

 

No

 

  • PR:Dinosaur kind

 

?- fact(ichtyosaur,What,Value).What = eatingValue = carnivore ;What = habitatValue = sea ;What = sizeValue = large ;

 

What = neck

Value = none ;

 

What = stance

Value = swimming ;

 

What = horns_crests

Value = none ;

 

What = isa

Value = dinosaur ;

 

What = lived

Value = years_ago ;

 

What = isa

Value = animal ;

 

W hat = can

Value = live ;

 

What = isa

Value = creature ;

 

No

 

  • PR:Individual

 

As I will discuss in the Evaluation part, the implementation of Individuals (I mean individuals, as with possible additional properties or some overridden general properties) is in PR hard to do. That’s why for example the property Isa,brontosaurus is missing, as it is easy poss ible in SN or F and the properties are the same as the ones of a brontosaur. See evaluation for explanation.

 

?- fact(brix,What,Value).

What = eatingValue = veg ;What = habitatValue = swamp ;What = sizeValue = large ;What = neckValue = long ;What = stanceValue = quadruped ;

What = horns_crests

Value = none ;

 

What = isa

Value = dinosaur ;

 

What = lived

Value = years_ago ;

 

What = isa

Value = animal ;

 

What = can

Value = live ;

 

What = isa

Value = creature ;

No

        1. Further Prolog questions

 

  • PR:Who is large ?

 

?- fact(Who,size,large).

Who = triceratops ;

Who = trix ;

Who = ichtyosaur ;

Who = brontosaurus ;

Who = brix ;

No

 

  • PR:Who is animal ?

 

?- fact(Who,isa,animal).Who = dinosaur ;Who = triceratops ;Who = trix ;Who = ichtyosaur ;Who = pterodactyl ;

Who = brontosaurus ;

Who = brix ;

Who = protoceraptos ;

Who = protox ;

No

 

  • PR:Who can live ?

Animal is included in the list, unlike the above list, which is correct.

 

?- fact(Who,can,live).

Who = animal ;

Who = dinosaur ;

Who = triceratops ;

Who = trix ;

Who = ichtyo saur ;

Who = pterodactyl ;

Who = brontosaurus ;

Who = brix ;

Who = protoceraptos ;

Who = protox ;

No

 

  • PR:Who is dinosaur ?

Again, list of object, does not include dinosaur itself.

 

?- fact(Who,isa,dinosaur).

Who = triceratops ;

Who = trix ;

Who = ichtyosaur ;

Wh o = pterodactyl ;

Who = brontosaurus ;

Who = brix ;

Who = protoceraptos ;

Who = protox ;

No

 

  • PR:Who lived years_ago ?

Unlike above list, here dinosaur itself must be included.

 

?- fact(Who,lived,years_ago).

Who = dinosaur ;

Who = triceratops ;

Who = trix ;

Who = ichtyos aur ;

Who = pterodactyl ;

Who = brontosaurus ;

Who = brix ;

Who = protoceraptos ;

Who = protox ;

No

    1. Evaluation of the representation (Question 2)

 

As I stated at the beginning, the PR implemen tation of a dinosaur problem was the hardest. It due to the fact that PR are designed rather for reasoning and expert systems processes and that’s why it’s not so suitable for a knowledge representation

Another feature of my PR implementaion is, that the information is asserted by rules to the KB in the same fact structure. In output, we can not distinguish between the properties easily, from what structure level it comes. (as in SN of F "going up…") (incompleteness). The possible solution would be, to include the rule name, when asserting the facts. Then a different procedure of all_properties could be defined, operating on the structure of rule_fact(rule_used, What, About_Who).
I have to explain yet, why the my PR representation does not include the individuals and their structures. It would be possible for each individual (trix, brix, protox) to define their own rules and include the trix_individual_rule, etc… at the beginning of the apply_rules predicate. But in order to do that, would have to define the trix_individal predicate to declare exist(trix,trix_individual_group) and the trix_individual_rule would be able to recognize trix from the other existing object, which is necessary for applying the rule to the right object. But than we would have group and rule for each individual, which is definitely not at all the brilliant stategy, how to represent individuals. So I state, that the representation of an individual is not easy in PR and can not be done by using the same technique as for other object in our knowledge. This is, on the contraty, possible in SN and F ! (expressive adequacy).

Despite those limitations, with my Prolog program for PR, we can achieved to answer all the four testing questions correclty, which proves same reasoning efficiency for the PR.

Other features of PR can be found in [3] such as:

  • In PR we can achieve unique separation of KB and knowledge manipulation (exist predicate and rules)
  • Rules can include aditional code manipulating the given fact more that the recursion procedures. (e.g. other possible actions than asserting (heuristic search) or other types of fact predicate)
  • We can easily implement meta-rules (rules for applying other rules) to decide the way of a reasoning or inferring process.
  • Disadvantage of rules is, that they mostly have to be fitted into a IF- THEN form (our problem with trix_individual_group and rule)
  • Luger (1993) in [3] (and I totally agree) includes PR as definitely part of some level of a model of a human reasoning.

 

  1. Conclusion
  2.  

    After creating all three implementation, I think that neither of the three representation is the one, how is actually given knowledge stored in human brain. Above three representations are, in fact, attempts to copy the actual human storage structure. Each representation has it’s advantages and disadvantages and the ideal knowledge structure would probably contain features from all of them and would be a their combination and probably include even some additional features, not mentioned at all. (e.g. probability reasoning, uncertainty, update processes)

    Another problem is with the representation of language statements. Some of them might be ambiguous. In our given facts about dinosaurs, this problem is not present, but it definitely exist in real knowledge and possible AI system must somehow deal with it.

     

     

     

  3. References

 

 

  1. Luger, G.F., Stubblefield, W.A. (1993) Artificial Intelligence: Structures and strategies for complex problem solving p. 361-5 (2nd edition), Benjamin/Cummings Publishing
  2. Luger, Stubblefield, (1993) Artificial Intelligence: Structures and strategies for complex problem solving p.379-382
  3. Luger, Stubblefield, (1993) Artificial Intelligence: Structures and strategies for complex problem solving p.177-9,337
  4. AI lecures of CM 3231-2 module and given prolog manual