info-gnuprologjava
[Top][All Lists]
Advanced

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

Re: [Info-gnuprologjava] Problems understanding the usage of the GNU Pro


From: Daniel Thomas
Subject: Re: [Info-gnuprologjava] Problems understanding the usage of the GNU Prolog API
Date: Fri, 25 Feb 2011 10:09:17 +0000

Hello,

There shouldn't be any real differences in syntax between SWI-Prolog and
GNU Prolog for Java - they are both fairly standards compliant (I like
to think that GNU Prolog for Java is slightly better at that).


> knows(hash(Data),Depth) :-
> Depth > 1,
> DepthMinus1 is Depth - 1,
> knows(Data,DepthMinus1).
This rule will never be true as it has no base case. I take it that the
purpose is to check that the number of hashes on the first argument is
the number specified by the second argument. (It won't calculate it for
you as the second argument won't instantiate in time)

If there is a syntax error being generated could I see it? Something
should be stored in the getLoadingErrors().

I hope this helps,

Daniel


On Wed, 2011-02-23 at 00:12 +0100, Daniel Warzecha wrote:
> And again a hello,
> 
> 
> 
> thanks for the advice. I've probably doused the "infinite" problem
> adding a depth rule (the infinite problem being exactly what you
> described).
> Anyways, the Prolog code I'm re-using was written for SWI-Prolog. That
> probably brings additional problems with it (it also explains why the
> dynamic rules were written as they were).
> It seems that the interpreter throws an error when it tries to use the
> following rule:
> 
> 
> knows(hash(Data),Depth) :-
> Depth > 1,
> DepthMinus1 is Depth - 1,
> knows(Data,DepthMinus1).
> 
> 
> Is there a GNU Prolog specific syntax error in there, or should this
> normally work?
> 
> 
> Greetings,
> Daniel Warzecha
> 
> 2011/2/22 Daniel Thomas <address@hidden>
>         Hello,
>         
>         You might want to look at the listing/1 or findall/3
>         predicates for
>         looking at what knowledge has been gained thus far.
>         
>         > Also it seems that my prolog rules generate infinite
>         knowledge. Do you
>         > perhaps know of an inbuilt predicate to prevent this?
>         
>         
>         I am not quite sure what you mean by infinite knowledge? Do
>         you mean
>         that it is creating an infinite number of predicate values and
>         hence not
>         terminating? In that case you probably want to alter your
>         rules so that
>         doesn't happen. If you are not sure how to do so then you
>         probably need
>         to find some guide to help teach you prolog. I had the
>         advantage of
>         lectures on it http://www.cl.cam.ac.uk/teaching/0910/Prolog/
>         was a very
>         good and well taught course but just reading the lecture notes
>         probably
>         doesn't help as much as one might like.
>         
>         You can put write/1 instructions or use listing/1 or findall/3
>         at
>         various different points in your prolog to see what is
>         happening there.
>         It would be neater if trace/0 was working but I don't think
>         that it is.
>         You might try debugging your prolog using a normal prolog
>         interpreter
>         such as gnuprolog or swiprolog.
>         
>         I hope this helps,
>         
>         Daniel
>         
>         
>         On Tue, 2011-02-22 at 22:03 +0100, Daniel Warzecha wrote:
>         > Hello again,
>         >
>         >
>         > thank you for your help so far.
>         >
>         >
>         > I started producing goal results. Now is the time to debug
>         my prolog
>         > rules.
>         >
>         >
>         > Is there some way to print the knowledge that has been
>         gained so far?
>         >
>         >
>         > So I could trace a goal like this?
>         >
>         >
>         > isKey(X)?
>         >
>         >
>         > X -> isSymKey(X) -> isKey(X).
>         >
>         >
>         > Also it seems that my prolog rules generate infinite
>         knowledge. Do you
>         > perhaps know of an inbuilt predicate to prevent this?
>         > (Do not feel that you need to answer this, this is just from
>         a
>         > relatively new prolog user to someone who maintains a
>         problem domain
>         > library)
>         >
>         >
>         > Greetings,
>         >
>         >
>         > Daniel Warzecha
>         
>         
> 

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


reply via email to

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