Re: Question about representing frame information and unification in PL

Srini Ram <[email protected]> Wed, 29 Oct 2008 11:20:51 -0700 (PDT)
Newsgroups gmane.comp.ai.powerloom
Message-ID <[email protected]>
Actually I made a mistake by defining car-engine as a function. Of course, it would always return one value.

Here is the new code

(defconcept Car)
(defconcept Size (?x)
  :axioms ( and
                (Size large)
                (Size small)
                (Size medium)
                (closed Size)))
    
(defconcept Power (?x)
  :axioms ( and
                (Power lots)
                (Power little)
                (Power medium)
                (closed Power)))
 
(defconcept Car-Part)
(defconcept Engine (?x Car-Part))
(defrelation car-engine ((?x Car) (?y Engine)))
(deffunction part-size ((?x Car-Part)) :-> (?y Size))
(deffunction part-power ((?x Car-Part)) :-> (?y Power))

(defconcept Big-Car (?x Car)
   :=>  (exists (?y) (and (car-engine ?x ?y) (= (part-size ?y) large))))

(defconcept Powerful-Car (?x Car)
   :=>  (exists (?y) (and (car-engine ?x ?y) (= (part-power ?y) lots))))


;;; "Suburbans are both big and powerful cars."
;;; KM> (Suburban has (superclasses (Big-Car Powerful-Car)))

(defconcept Suburban (?x Big-Car Powerful-Car))

;; Create one car

(assert (Suburban t1))


;; Now ask about its engine
(retrieve all (Car-Engine t1 ?x))
There are 2 solutions:
  #1: ?X=sk18
  #2: ?X=sk20

Voila...the unification does not seem to have taken place. Should I add an axiom that every car has at most one engine? I guess this may not force unification -- what it would would cause some kind of warning/error..

Srini



________________________________
From: Srini Ram <[email protected]>
To: [email protected]
Sent: Wednesday, October 29, 2008 1:49:59 PM
Subject: Question about representing frame information and unification in PL


I found the following example in the documentation for the Knowledge Machine from UOfTexas...


;;; "Every big car has a large engine."
KM> (every Big-Car has 
           (parts ((a Engine with 
                      (size (*Large))))))

;;; "Every powerful car has a powerful engine."
KM> (every Powerful-Car has     
           (parts ((a Engine with 
                      (power (*Lots))))))

Question 1: How would we we represent above in Powerloom
  Here is my shot at it

(defconcept Car)
(defconcept Size (?x)
  :axioms ( and
                (Size large)
                (Size small)
                (Size medium)
                (closed Size)))
    
(defconcept Power (?x)
  :axioms ( and
                (Power lots)
                (Power little)
                (Power medium)
                (closed Power)))
  


(defconcept Car-Part)
(defconcept Engine (?x Car-Part))
(deffunction car-engine ((?x Car)) :-> (?y Engine))
(deffunction part-size ((?x Car-Part)) :-> (?y Size))
(deffunction part-power ((?x Car-Part)) :-> (?y Power))
;; the above is not quite correct...some parts may have only a size or a power, but not both
;; every part must have one of the two properties..not sure how i say this in a meta-relation. I can then
;; use the meta-relation to say that engine has size as well as power relations, tire has size but not
;; power etc.

(defconcept Big-Car (?x Car)
   :=>  (= (part-size (car-engine ?x)) large))

(defconcept Powerful-Car (?x Car)
   :=>  (= (part-power (car-engine ?x)) lots))
 
It is more verbose than the KM version and less intuitive. Could I have used some PL features e.g definstance to make the code more readable?

;; The KM example continues as follows
;;; "Suburbans are both big and powerful cars."
KM> (Suburban has (superclasses (Big-Car Powerful-Car)))

I defined this in PL as :

(defconcept Suburban (?x Big-Car Powerful-Car))



;; KM then shows its unification powers
;;; "What are the parts of a Suburban?"
KM> (the parts of (a Suburban))
(COMMENT: (_Engine7 && _Engine8) unified to be _Engine7)
(_Engine7)

Question 2: Would the unification work the same way in PowerLoom or is the behavior slightly different
The output from PL code above is:


STELLA> (retrieve all (= ?x (Car-Engine t1)))
There is 1 solution:
  #1: ?X=|SK|(CAR-ENGINE T1)                                         ;; Seems to work ok...there is only one engine not two
STELLA> (retrieve all (= ?sz (part-size (Car-Engine t1))))
There is 1 solution: 
  #1: ?SZ=LARGE                                                            ;; and that engine has the correct
STELLA> (retrieve all (= ?sz (part-quantity (Car-Engine t1))))
There is 1 solution:
  #1: ?SZ=LOTS                                                                ;; properties


KM has some other frame features that are useful to make the code clearer /concise
1. Embedded frames
;;; "Joe is a person, and owns a red car."
KM> (*Joe has 
          (instance-of (Person))
          (owns ((a Car with 
                    (color (*Red))))))

Not sure if this can be done in PL without creating a PL instance of car and using the owns relation to relate Joe to that car instance i.e we cannot have embedded powerloom instances... I may be missing the proper use of the frame syntax of PowerLoom that makes this possible.

Thanks
Srini

_______________________________________________
powerloom-forum mailing list
[email protected]
http://mailman.isi.edu/mailman/listinfo/powerloom-forum