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 is not expressed in KIF itself.<br><br>I would like to say something like<br>(assert <br> (person-assertion joe-facts <-meta assertion?<br> (assert <br> (and <br> (person joe) <br> (hands joe 2) <br> (legs joe 2)<br>   ; (exists (?h) (and (hand joe ?h) (nails ?h 5)) <span style="color: rgb(128, 0, 0);"><- assertion about nails cant be found > by (get-propositions-of joe) or (all-facts-of joe)</span><br> ....<br>)))) <br><br>and subsequently do<br>(retract-from-query (retrieve (person-assertion joe-facts)) -> all assertions about joe , and his hands and feet and their sub-assertions <br> 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 <[email protected]><br><b><span style="font-weight: bold;">To:</span></b> Srini Ram <[email protected]><br><b><span style="font-weight: bold;">Cc:</span></b> Hans Chalupsky <[email protected]>; [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>> I wrote below<br>> Is there any way to tag a set of assertions, so that you can <br>> just retract them as a group?<br>><br>> After reading the documentation for assert and destroy, I see that <br>> assert returns an object and destroy deletes an object.<br>> Is it possible to store the return value of a compound assert, and <br>> later pass it to a destroy which will retract all the propositions <br>> contained in that assert in one step? I couldnt find any examples of <br>> the use of destroy in the documentation or in the demos directory...<br><br>I don't think you want to use DESTROY. But you could retract the <br>resulting proposition.<br>< br>The value returned by assert will be either a PROPOSITION object or a <br>LIST of PROPOSITIONS. 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 <br>functions to assert a sentence and then save the value for later <br>retraction. You would presumably use the S-ASSERT-PROPOSITION and <br>RETRACT-PROPOSITION code. From Java this would look like<br><br> String myModuleName = "PL-USER";<br> Module myModule = PLI.getModule(myModuleName, null);<br> PlIterator props = PLI.sAssertProposition("(and (c i1) (c i2) (r <br>i1 i2))", myModuleName, null);<br> ...<br> while (props.nextP()) {<br> p = ((Proposition)(props.value));<br> edu.isi.powerloom.PLI.retractProposition(p, myModule, null);<br>& nbsp; }<br><br>Another option would be to use the context mechanism to spawn a new <br>reasoning context as a child of your current module and then > just <br>destroy that context when you no longer need it. This is a more <br>global and less selective strategy, but it frees you from having to <br>keep track of what it is you need to retract.<br><br>That can be handy if you are trying alternate scenarios. It also has <br>the advantage that you can keep multiple such scenarios around in <br>parallel and move between them. There is even some query-level <br>support (the IST operator) that supports it.<br><br>-Tom.<br><br></div></div></div><br> > </body></html>