Search Mailing List Archives
[protege-owl] How to define a rule in JessTab detecting and changing relation between two instances?
swt at stanford.edu
Tue Apr 24 13:18:28 PDT 2007
> Hi everyone,
> I do appreciate your help.
> I am using JessTab to run rules,I have written a rule to change the
> value(string) of an instance :
> (defrule Rule-1 ?obj1 <-(object (is-a Customer) (is-a-name "Customer")
> (:NAME "Customer_Inst") (hasState "Ready" )) => (slot-set ?obj1 hasState
> But now I want to introduce (Ready, Waiting) as intsances of class
> "State".I have done it and now I have two instances Ready and Waiting .
> Also I have defined "hasState" as a slot of type of State.
> But now I wonder how can I write similar rule (as above) to change the
> relation between Customer and Ready to a relation between Customer and
?obj1 <- (object ...) gives you a binding to a fact, not the object. You
need to match (OBJECT ?obj1) as part of the pattern.
Assuming that you have a Jess function (isState ?state ?stateName) that
determines whether an individual ?state is a state with ?stateName
(e.g., "Ready"), and a function (getState ?stateName) that returns a
state individual with name ?stateName, you can write your rule as
(object (is-a Customer) (is-a-name "Customer")
(:NAME "Customer_Inst") (OBJECT ?obj1)
(hasState ?state&:(isState ?state "Ready")))
=> (slot-set ?obj1 hasState (getState "Waiting")))
Samson Tu email: swt at stanford.edu
Senior Research Scientist web: www.stanford.edu/~swt/
Stanford Medical Informatics phone: 1-650-725-3391
Stanford University fax: 1-650-725-7944
More information about the protege-owl