Re: Question about representing frame information and unification in PL

Thomas Russ <[email protected]> Thu, 30 Oct 2008 11:40:28 -0700
Newsgroups gmane.comp.ai.powerloom
Message-ID <[email protected]>
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.