Re: Question about representing frame information and unification in PL

Hans Chalupsky <[email protected]> Fri, 31 Oct 2008 12:03:08 -0800
Newsgroups gmane.comp.ai.powerloom
Message-ID <[email protected]>
As I said in my previous message, the right way to do this is via
defproposition which will be even better once I fix its shortcomings.

Another standard way of doing this is to use `retract-facts-of' which
will retract all propositions in which `joe' is an argument (the list
returned by `all-facts-of').

You can define a relation `person-assertion' as you suggest below,
e.g.,

(defrelation person-assertion (?name (?p proposition)))

Unfortunately, you'd have to write a little update demon that would
assert or retract the proposition ?p inside whenever person-assertion
gets asserted or retracted (you can't nest another assert the way you
had it).

Hans

>>>>> Srini Ram <[email protected]> writes:

> 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.

> 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)
>                  ....
> )))) 

> 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....

> Thanks
> Srini





> ________________________________
> From: Thomas Russ <[email protected]>
> To: Srini Ram <[email protected]>
> Cc: Hans Chalupsky <[email protected]>; [email protected]
> Sent: Thursday, October 30, 2008 2:40:28 PM
> Subject: Re: [PowerLoom Forum] Question about representing frame information and unification in PL


> On Oct 30, 2008, at 9:41 AM, Srini Ram wrote:

>> I wrote below
>> Is there any way to tag a set of assertions, so that you can  
>> just retract them as a group?
>> 
>> After reading the documentation for assert and destroy, I see that  
>> assert returns an object and destroy deletes an object.
>> Is it possible to store the return value of a compound assert, and  
>> later pass it to a destroy which will retract all the propositions  
>> contained in that assert in one step? I couldnt find any examples of  
>> the use of destroy in the documentation or in the demos directory...

> I don't think you want to use DESTROY.  But you could retract the  
> resulting proposition.

> The value returned by assert will be either a PROPOSITION object or a  
> LIST of PROPOSITIONS.  You could iterate through that and call RETRACT- 
> PROPOSITION on each item.

> The easiest way to do this would be to use the PowerLoom interface  
> functions to assert a sentence and then save the value for later  
> retraction.  You would presumably use the S-ASSERT-PROPOSITION and  
> RETRACT-PROPOSITION code.  From Java this would look like

>      String myModuleName = "PL-USER";
>      Module myModule = PLI.getModule(myModuleName, null);
>      PlIterator props = PLI.sAssertProposition("(and (c i1) (c i2) (r  
> i1 i2))", myModuleName, null);
>      ...
>      while (props.nextP()) {
>        p = ((Proposition)(props.value));
>        edu.isi.powerloom.PLI.retractProposition(p, myModule, null);
>      }

> Another option would be to use the context mechanism to spawn a new  
> reasoning context as a child of your current module and then just  
> destroy that context when you no longer need it.  This is a more  
> global and less selective strategy, but it frees you from having to  
> keep track of what it is you need to retract.

> That can be handy if you are trying alternate scenarios.  It also has  
> the advantage that you can keep multiple such scenarios around in  
> parallel and move between them.  There is even some query-level  
> support (the IST operator) that supports it.

> -Tom.


>       <html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:arial,helvetica,sans-serif;font-size:10pt"><div>Thanks Tom.<br><br>I am not looking to try alternate scenarios, I am trying to ease the maintainability of managing complex objects.<br><br>Lets say I have person joe. Joe has a large number of moving parts: hands, feets, eyes, bowels :-) etc.<br>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<br>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).<br>Advantage is that one will never attempt to retract something that wasnt asserted as could h
 appen if there is separate assertion and retraction code.<br><br>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&nbsp; is not expressed in KIF itself.<br><br>I would like to say something like<br>(assert <br>&nbsp;&nbsp; (person-assertion joe-facts &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;-meta assertion?<br>&nbsp;&nbsp; &nbsp; &nbsp; (assert <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (and <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (person joe) <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (hands joe 2)&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (legs joe 2)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
 ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (exists (?h) (and (hand joe ?h) (nails ?h 5))&nbsp;&nbsp; <span style="color: rgb(128, 0, 0);">&lt;- assertion about nails cant be found
>  by (get-propositions-of joe) or (all-facts-of joe)</span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ....<br>)))) <br><br>and subsequently do<br>(retract-from-query&nbsp; (retrieve (person-assertion joe-facts)) -&gt; all assertions about joe , and his hands and feet and their sub-assertions <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; are retracted<br><br>I guess what I am asking is...can the argument of a relation be a logic-object (which is what assert returns)? <br>If
>  yes, then the above should be possible....<br><br>Thanks<br>Srini<br><br></div><div style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"><br><div style="font-family: arial,helvetica,sans-serif; font-size: 13px;"><font face="Tahoma" size="2"><hr size="1"><b><span style="font-weight: bold;">From:</span></b> Thomas Russ &lt;[email protected]&gt;<br><b><span style="font-weight: bold;">To:</span></b> Srini Ram &lt;[email protected]&gt;<br><b><span style="font-weight: bold;">Cc:</span></b> Hans Chalupsky &lt;[email protected]&gt;; [email protected]<br><b><span style="font-weight: bold;">Sent:</span></b> Thursday, October 30, 2008 2:40:28 PM<br><b><span style="font-weight: bold;">Subject:</span></b> Re: [PowerLoom Forum] Question about representing frame information and unifi
 cation in PL<br></font><br>
> <br>On Oct 30, 2008, at 9:41 AM, Srini Ram wrote:<br><br>&gt; I wrote below<br>&gt;&nbsp; &nbsp;  Is there any way to tag a set of assertions, so that you can&nbsp; <br>&gt; just retract them as a group?<br>&gt;<br>&gt; After reading the documentation for assert and destroy, I see that&nbsp; <br>&gt; assert returns an object and destroy deletes an object.<br>&gt; Is it possible to store the return value of a compound assert, and&nbsp; <br>&gt; later pass it to a destroy which will retract all the propositions&nbsp; <br>&gt; contained in that assert in one step? I couldnt find any examples of&nbsp; <br>&gt; the use of destroy in the documentation or in the demos directory...<br><br>I don't think you want to use DESTROY.&nbsp; But you could retract the&nbsp; <br>resulting proposition.<br><
 br>The value returned by assert will be either a PROPOSITION object or a&nbsp; <br>LIST of PROPOSITIONS.&nbsp; You could iterate through that and call RETRACT-
>  <br>PROPOSITION on each item.<br><br>The easiest way to do this would be to use the PowerLoom interface&nbsp; <br>functions to assert a sentence and then save the value for later&nbsp; <br>retraction.&nbsp; You would presumably use the S-ASSERT-PROPOSITION and&nbsp; <br>RETRACT-PROPOSITION code.&nbsp; From Java this would look like<br><br>&nbsp; &nbsp;  String myModuleName = "PL-USER";<br>&nbsp; &nbsp;  Module myModule = PLI.getModule(myModuleName, null);<br>&nbsp; &nbsp;  PlIterator props = PLI.sAssertProposition("(and (c i1) (c i2) (r&nbsp; <br>i1 i2))", myModuleName, null);<br>&nbsp; &nbsp;  ...<br>&nbsp; &nbsp;  while (props.nextP()) {<br>&nbsp; &nbsp; &nbsp;  p = ((Proposition)(props.value));<br>&nbsp; &nbsp; &nbsp;  edu.isi.powerloom.PLI.retractProposition(p, myModule, null);<br>&
 nbsp; &nbsp;  }<br><br>Another option would be to use the context mechanism to spawn a new&nbsp; <br>reasoning context as a child of your current module and then
>  just&nbsp; <br>destroy that context when you no longer need it.&nbsp; This is a more&nbsp; <br>global and less selective strategy, but it frees you from having to&nbsp; <br>keep track of what it is you need to retract.<br><br>That can be handy if you are trying alternate scenarios.&nbsp; It also has&nbsp; <br>the advantage that you can keep multiple such scenarios around in&nbsp; <br>parallel and move between them.&nbsp; There is even some query-level&nbsp; <br>support (the IST operator) that supports it.<br><br>-Tom.<br><br></div></div></div><br>

>       </body></html>