info-gnuprologjava
[Top][All Lists]
Advanced

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

Re: [Info-gnuprologjava] FW: problem in creating complex prolog queries


From: Suman Roy
Subject: Re: [Info-gnuprologjava] FW: problem in creating complex prolog queries , queries created by conjugating more that 5 simple queries .
Date: Thu, 24 May 2012 15:56:12 +0530

Hi,

We have tried using PrepareGoal, But gnu prolog is showing an error message, “ 
Exception in thread "main" gnu.prolog.vm.PrologException: 
error(system_error,'java.lang.StackOverflowError') ” . 

Unfortunately, the documentation does not have these details about using 
PrepareGoal. It would be better if we know a little more about it. 

Query intended to construct  :   :-  p(x) , q(y) , r(z),s(l). 



rules_01.pl file  :
--------
p (x).
q(y).
r(z).
s(l ).

Code snippet : 
-----------------

Term t1[]={AtomTerm.get("x")};
Term t2[]={AtomTerm.get("y")};
  Term t3[]={AtomTerm.get("z")};
    Term t4[]={AtomTerm.get("l")};


CompoundTerm ct1=new CompoundTerm("p",t1); 
 CompoundTerm ct2=new CompoundTerm("q",t2);
CompoundTerm ct3=new CompoundTerm("r",t3);
CompoundTerm ct4=new CompoundTerm("s",t4);

String functor = ",";
CompoundTerm mt1 = new CompoundTerm(functor, 2);
mt1.args[0]=ct1;
mt1.args[1]=ct2;
CompoundTerm mt2 = new CompoundTerm(functor, 2);

mt2.args[0]=mt1;
mt2.args[1]=ct3;

CompoundTerm mt3 = new CompoundTerm(functor, 2);
mt3.args[0]=mt2;
mt3.args[1]=ct4;


Goal prepareGoal1 = in.prepareGoal(mt3);


  int chk =in.execute(prepareGoal1);

           if (chk == PrologCode.SUCCESS || chk == PrologCode.SUCCESS_LAST) {
                System.out.println("Succesful execution ");
            }
           else {
                System.out.println("Failed execution ");
           }


Regards and thanks,
--Suman

Suman Roy, Ph.D.
Infosys LABS, 
Infosys Technologies Ltd.,
Bangalore, India.     
Mob. +91 98860 23203 



-----Original Message-----
From: Daniel Thomas [mailto:address@hidden 
Sent: Wednesday, May 23, 2012 2:10 PM
To: Suman Roy
Cc: address@hidden; Jagadish Koneti
Subject: Re: FW: problem in creating complex prolog queries , queries created 
by conjugating more that 5 simple queries .

Sorry.

I think that the error message is misleading and due to a bug in the way I used 
finally in my implementation of runOnce. Try using prepareGoal and then execute 
(which is essentially what runOnce does) as then you should hopefully get the 
correct error message when prepareGoal fails which should help with working out 
what the actual problem is.

Daniel

On Thu, 2012-05-17 at 14:12 +0530, Suman Roy wrote:
>  
> 
> Hello ,
> 
>  
> 
>    I want to construct a complex prolog query with the help of  “ gnu 
> prolog “  jar file  , which will be conjugation of 5 simple prolog 
> queries .
> 
>  
> 
> For instance :   :-   p (a) ,  q(b), r(c), s(d ), l(e )  .
> 
>  
> 
>   But gnu prolog is showing an error message , “ The goal is not 
> currently active  ”. Can you please let me what can be done to create 
> such queries?
> 
>  
> 
>  
> 
> rules_01.pl file  :
> 
> --------
> 
> p (a).
> 
> q(b).
> 
> r(c).
> 
> s(d ).
> 
> l(e )  .
> 
>  
> 
> Code snippet : 
> 
> -----------------
> 
>  
> 
> Term t1[] =  {AtomTerm.get("a")};
> 
> Term t2[] =  {AtomTerm.get("b")};
> 
>   Term t3[] =  {AtomTerm.get("c")};
> 
>   Term t4[] =  {AtomTerm.get("d")};
> 
>   Term t5[] = {AtomTerm.get("e”)};
> 
>  
> 
> CompoundTerm ct1=new CompoundTerm("p",t1);
> 
>  CompoundTerm ct2=new CompoundTerm("q",t2);
> 
> CompoundTerm ct3=new CompoundTerm("r",t3);
> 
> CompoundTerm ct4=new CompoundTerm("s",t4);
> 
> CompoundTerm ct5=new CompoundTerm("l",t5);
> 
>  
> 
> String functor = ",";
> 
> CompoundTerm mt1 = new CompoundTerm(functor, 2);
> 
> mt1.args[0]=ct1;
> 
> mt1.args[1]=ct2;
> 
> CompoundTerm mt2 = new CompoundTerm(functor, 2);
> 
>  
> 
> mt2.args[0]=mt1;
> 
> mt2.args[1]=ct3;
> 
>  
> 
> CompoundTerm mt3 = new CompoundTerm(functor, 2);
> 
> mt3.args[0]=mt2;
> 
> mt3.args[1]=ct4;
> 
>  
> 
> CompoundTerm mt4 = new CompoundTerm(functor, 2);
> 
> mt3.args[0]=mt3;
> 
> mt3.args[1]=ct5;
> 
>  
> 
>  
> 
>             int rc = in.runOnce(mt4);
> 
>  
> 
>  
> 
>  
> 
>  
> 
>  
> 
> =======================================
> 
>  
> 
> 
> **************** 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***


reply via email to

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