info-gnuprologjava
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Info-gnuprologjava] problem creating queries with NOT (negation as


From: Daniel Thomas
Subject: Re: [Info-gnuprologjava] problem creating queries with NOT (negation as failure)
Date: Mon, 07 May 2012 18:30:54 +0100

Hello,

Sorry for the long delay in getting back to you about this.

From: ISO/IEC CD 13211-1 : 1996(E)

8.15.1 fail_if/1

NOTE — A predicate with the same meaning as fail_if/1 is
implemented in many existing processors with a name not/1
which is misleading because the predicate gives negation by
failure rather than true negation. Other processors implement
this feature with a predicate \+/1.

Unfortunately it looks like GPJ does not provide the not/1 predicate and
that there is some misleading bug in runOnce where the wrong error
message can be shown (probably due to the finally being used for
clearup) and so the actual error message:
gnu.prolog.vm.PrologException: error(existence_error(procedure,not / 1),error)
        at gnu.prolog.vm.PrologException.getError(PrologException.java:129)
        at gnu.prolog.vm.PrologException.getError(PrologException.java:118)
        at 
gnu.prolog.vm.PrologException.existenceError(PrologException.java:155)
        at 
gnu.prolog.vm.UndefinedPredicateCode.execute(UndefinedPredicateCode.java:62)
        at 
gnu.prolog.vm.interpreter.InterpretedByteCode.execute(InterpretedByteCode.java:522)
        at 
gnu.prolog.vm.interpreter.Predicate_call.staticExecute(Predicate_call.java:144)
        at gnu.prolog.vm.Interpreter.execute(Interpreter.java:507)

gets hidden.

It also appears that GPJ does not provide fail_if, which is also an
error, we should probably support both fail_if/1 and not/1. In the
meantime you can trivially define them in terms of \+/1 and include that
in a file you ensureLoaded or define that from within GPJ in java.

Sorry for the delay in replying.

Daniel

On Fri, 2012-04-27 at 17:12 +0530, Suman Roy wrote:
> We are using gnuprolog 0.2.5 to create queries to fire onto Prolog.
> 
>  
> 
> We are unable to create queries which involve NOT as negation as
> failure like, "not( bird (cat) )". 
> 
> In order to form such query we tried implementing in the way as you
> mentioned previously .
> 
>  
> 
> Here is the code snippet  : 
> 
> ------------------
> 
>  
> 
>           Term t1[] = {  AtomTerm.get ( " cat " )  } ; 
> 
>  
> 
>    CompoundTerm ct1=new CompoundTerm ( " bird ", t1 ) ;
> 
>  
> 
>    CompoundTerm goalTerm=new
> CompoundTerm(CompoundTermTag.get("not",1),ct1);
> 
>  
> 
>             int rc = in.runOnce(goalTerm);
> 
>  
> 
> But we are getting a Java Exception :  “  Exception in thread "main"
> java.lang.IllegalArgumentException: The goal is not currently active
> ” .
> 
>  
> 
> Can anybody please provide some help? We need this urgently.
> 
>  
> 
> Suman Roy, Ph.D.
> Infosys LABS, 
> 
> Infosys Technologies Ltd.,
> 
> Bldg.-19, # 44 Electronics City, Hosur Road,
> Bangalore 560 100, India.
> Tel. +91 80 2852 0261 x 50850
>      +91 80 4116 3850 (D)
>      +91 80 2351 2373 (R)
>      +91 98860 23203 (M)
> Fax. +91 80 2852 0362
> E-mail address@hidden <mailto:address@hidden>
>        address@hidden <mailto:address@hidden>
> 
> 
> 
>  
> 
> 
> **************** CAUTION - Disclaimer *****************
> This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely 
> for the use of the addressee(s). If you are not the intended recipient, 
> please 
> notify the sender by e-mail and delete the original message. Further, you are 
> not 
> to copy, disclose, or distribute this e-mail or its contents to any other 
> person and 
> any such actions are unlawful. This e-mail may contain viruses. Infosys has 
> taken 
> every reasonable precaution to minimize this risk, but is not liable for any 
> damage 
> you may sustain as a result of any virus in this e-mail. You should carry out 
> your 
> own virus checks before opening the e-mail or attachment. Infosys reserves 
> the 
> right to monitor and review the content of all messages sent to or from this 
> e-mail 
> address. Messages sent to or from this e-mail address may be stored on the 
> Infosys e-mail system.
> ***INFOSYS******** End of Disclaimer ********INFOSYS***

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]