Algernon Tutorial 3.a
:OR, :TAXONOMY and :RETRIEVE


previous   next

These exercises and examples use the newspaper project included in the examples folder of your Protege installation.

The :OR command

:OR allows alternate paths to be explored if one path fails. Usually it is used to determine whether one situation or another exists. Any number of optional paths can be specified. They are tried in order. :OR succeeds if any of the paths succeed. The bindings from the first succeeding path are returned. Each path is executed independently, so the same variable can be used in different paths. Side-effects from executing a failed path are not deleted from the KB when that path fails.
Examples:
  Either Joey has a buddy, Carol knows who Joey's buddy
  should be, or we need to assign him a buddy.

  ((:OR ((buddy Joey ?x))
        ((BuddySet Carol ?buddies)
         (Member ?buddies ?x)
         (BuddyOf ?x Joey))
        ((:ADD-INSTANCE (?x Buddies) (buddy Joey ?x)))
        )
   )

:TAXONOMY

Creates a taxonomy of classes and instances in one command. The root of the taxonomy must be an existing class. The syntax is:
  ((:TAXONOMY (existing-class
                 (subclass-1
                   (subclass-1.1  instance-1.1a instance-1.1b ...)
                   (subclass-1.2)
                   ...)
                 (subclass-2
                   (subclass-2.1 ...)
                   )
                   )))
  ((:TAXONOMY (:THING
                (Plants
                  (FloweringPlants
                    (Roses)
                    (Begonias Moms-Begonia-1)
                    (Tulips Tulip-1 Tulip-2 Tulip-3)
                    ))
                (Animals
                  (Reptiles
                    (Alligators)
                    (Turtles))
                  (Mammals
                    (Lions Simba Nala)
                    (Tigers)
                    (Bears)
                    ))
                )))

:RETRIEVE

Retrieves information from the KB without triggering backward-chaining rules. This is useful as an efficiency measure if you are really trying to squeeze execution cycles from the system, or if you want to prevent some side-effects from happening.

Algernon guarantees that each query will only invoke rules once, so the second time the same query is processed, rules won't be fired anyway.

  -- retrieve the current salary.  Don't let
  -- any potential salary increase rules fire.
  ((:RETRIEVE (salary instance_00045 ?salary)))

previous   next
Author: Micheal S. Hewett
Email: hewett@cs.stanford.edu
Last Updated: Monday, February 10, 2003