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: Thu, 17 Feb 2011 15:37:28 +0000

Hello,

Have you found the GNU Prolog for Java manual?
http://www.gnu.org/software/gnuprologjava/manual/ 

You can load prolog facts and rules using the ensureLoaded see 
http://www.gnu.org/software/gnuprologjava/manual/Setup.html#Setup and
http://www.gnu.org/software/gnuprologjava/api/gnu/prolog/vm/Environment.html#ensureLoaded(gnu.prolog.term.Term)

If you are asserting facts at runtime then you do this as normal in
Prolog using assertz or asserta or similar (having previously declared
it to by dynamic as usual in a prolog file which you then ensureloaded)
- you can find instructions on creating terms here:
http://www.gnu.org/software/gnuprologjava/manual/Constructing-Terms.html#Constructing-Terms
or if you want to construct a term from a string (if you already have
the data you want as a string representation of a prolog term) then you
might want to use
http://www.gnu.org/software/gnuprologjava/api/gnu/prolog/io/TermReader.html#stringToTerm(java.lang.String,
 gnu.prolog.vm.Environment) though it doesn't look like that has been 
documented properly yet. Sorry.

Apologies that you found the API documentation irritating. I will try to
get it improved in the next release.

I hope this helps,

Daniel

On Thu, 2011-02-17 at 15:52 +0100, Daniel Warzecha wrote:
> Hello,
> 
> 
> I hope someone can help me. I'm trying to understand how to use the
> API in a correct way and am a bit overwhelmed.
> 
> 
> The background: I'm trying to parse messages in UML Sequence Diagrams
> and transform their facts, i.e. the message data to Prolog. Then I
> want to pose questions to the Prolog interpreter in regards to the
> knowledge base.
> 
> 
> Okay, sadly I don't understand how to do the following basic things
> with the API:
> 
> 
> 1. Tell the environment (if that's right) that some predicates exist:
> e.g. key/1 or knows/2 .
> 2. Tell Prolog that some facts exist: e.g. key("key1") or
> knows("attacker","key1")
> 3. Tell Prolog that certain rules exist: e.g.
> knows("attacker","message") :- encrypted("message","key1"),
> symmetricKey("key1").
> 
> 
> Can somebody please help me? The API docs only irritated me even more.
> 
> 
> Thanks in advance,
> 
> 
> Daniel W.

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


reply via email to

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