Re: Question about representing frame information and unification in PL

Thomas Russ <[email protected]> Thu, 30 Oct 2008 12:38:21 -0700
Newsgroups gmane.comp.ai.powerloom
Message-ID <[email protected]>
On Oct 30, 2008, at 12:02 PM, Srini Ram wrote:

> Thanks Tom.
>
> I am not looking to try alternate scenarios, I am trying to ease the  
> maintainability of managing complex objects.
>
> Lets say I have person joe. Joe has a large number of moving parts:  
> hands, feets, eyes, bowels :-) etc.
> When I retract person joe, I want to automatically retract all these  
> assertions about his hands, feets as well as assertions about their  
> sub-parts
> such as fingers, toes and so on. I dont want to have to retract them  
> one by one (similar to having a destructor method that deletes sub- 
> objects).
> Advantage is that one will never attempt to retract something that  
> wasnt asserted as could happen if there is separate assertion and  
> retraction code.
>
> Storing the assertion in the PowerLoom interface is not useful,  
> since I cannot then query in KIF to find all the complex assertions.  
> The storage of the assertions  is not expressed in KIF itself.

So what you want to have is some interactive way of doing this?   
Instead of using a programming interface?

Well, I did just remember that you are using the Lisp version of  
PowerLoom, so you can use Lisp to come to your rescue for this  
particular case.  I had actually done my initial investigation using  
Lisp and then translated some code to Java.

> I would like to say something like
> (assert
>    (person-assertion joe-facts                <-meta assertion?
>        (assert
>            (and
>                 (person joe)
>                 (hands joe 2)
>                 (legs joe 2)
>                 (exists (?h) (and (hand joe ?h) (nails ?h 5))   <-  
> assertion about nails cant be found by (get-propositions-of joe) or  
> (all-facts-of joe)
>                  ....
> ))))

You can just save the results of an ASSERT statement in a lisp  
variable and then iterate over the contents.

STELLA> (setq joes-facts
	      (assert (and (c Joe)
			   (r Joe Jim)
			   (exists (?h) (and (r Joe ?h) (r ?h something-else))))))

(|P|(C JOE) |P|(R JOE JIM) |P|(R JOE sk53) |P|(R sk53 SOMETHING-ELSE))
STELLA> (retrieve all (r ?x ?y))
There are 5 solutions:
   #1: ?X=sk53, ?Y=SOMETHING-ELSE
   #2: ?X=JOE, ?Y=sk53
   #3: ?X=JOE, ?Y=JIM
   #4: ?X=JOHN, ?Y=MIKE
   #5: ?X=JOHN, ?Y=BILL
STELLA> (cl:dolist (p joes-facts)
	  (cl:print p)
	  (pli:retract-proposition p null null))
|P|(C JOE)
|P|(R JOE JIM)
|P|(R JOE sk53)
|P|(R sk53 SOMETHING-ELSE)
COMMON-LISP:NIL
STELLA> (retrieve all (r ?x ?y))
There are 2 solutions:
   #1: ?X=JOHN, ?Y=MIKE
   #2: ?X=JOHN, ?Y=BILL
STELLA>

>
>
> and subsequently do
> (retract-from-query  (retrieve (person-assertion joe-facts)) -> all  
> assertions about joe , and his hands and feet and their sub-assertions
>                                                                                 are 
>  retracted
>
> I guess what I am asking is...can the argument of a relation be a  
> logic-object (which is what assert returns)?
> If yes, then the above should be possible....

Well, that is an interesting suggestion for some meta-relations.  We  
don't really have that supported right now.  The real problem is that  
ASSERT is a command rather than an operator in the logic language  
itself, so you can't really use it inside of logical sentences.  So  
there isn't any way of getting the value to assert for person- 
assertion into the assertion.