[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Info-gnuprologjava] Adding facts to environment dynamicly
From: |
Dominik Schmeiser |
Subject: |
Re: [Info-gnuprologjava] Adding facts to environment dynamicly |
Date: |
Tue, 7 Jun 2011 16:46:31 +0200 |
User-agent: |
RoundCube Webmail/0.1 |
Hi Daniel,
thanks for your quick reply.
Unfortunately it still does not work. We have two Prolog-Files.
File 1:
foo(bar1).
File 2:
:- dynamic(foo/1).
invoke(R) :- assert[a/z](foo(bar2)).
Both files are loaded to the environment (using
environment.ensureLoaded(AtomTerm.get(<path>))) and we have still an
existence error for "assert" and the permission error for asserta & -z when
we try to use invoke.
We were not sure if the dynamic-predicate is really used, so we extended
the file to
invokeD(R) :- dynamic(foo/1).
When we then called the invokeD we got an existence-error, too:
gnu.prolog.vm.PrologException: error(existence_error(procedure,dynamic /
1),error)
We're using verion 0.2.6.
We looked through some bug reports and found minimal examples like this:
:- dynamic(aFoo/1).
:- initialization(assertz(aFoo(1)),aFoo(1),assertz(aFoo(2)),aFoo(2)).
Our experience implies that this - especially the ":-
dynamic(aFoo/1)."-part - works not in our environment.
Is there probably something we're missing in our Java-code?
environment = new Environment();
environment.ensureLoaded(AtomTerm.get(<path1>));
environment.ensureLoaded(AtomTerm.get(<path2>));
interpreter = environment.createInterpreter();
environment.runInitialization(interpreter);
VariableTerm v = new VariableTerm("vTerm");
Term[] a = {v};
CompoundTerm c = new CompoundTerm("invoke", a);
Interpreter.Goal goal = interpreter.prepareGoal(c);
int result = interpreter.execute(goal);
We really have no idea where we're going wrong.
Thanks for your time and help! :-)
Dominik
On Mon, 06 Jun 2011 13:20:40 +0100, Daniel Thomas <address@hidden> wrote:
> Hello,
>
> Before you can use assert[a,z] on a predicate you first need to declare
> it to be dynamic e.g.
> :- dynamic(foo/1).
>
> I hope that helps,
>
> Daniel
>
> On Sun, 2011-06-05 at 14:32 +0200, Dominik Schmeiser wrote:
>> Hi all,
>>
>> Me and my collegue are working with GPJ on an project for the
> university.
>> we have a Prolog-Environment which already loaded some facts. (using
>> environment.ensureLoaded(...))
>>
>> e.g.
>> foo(bar1).
>> foo(bar2).
>>
>> Now we try to invoke a rule (using interpreter.execute(...)).
>> This rule should create some new facts in the environment,
>>
>> e.g.
>> invoke :- assert( foo(bar3) ).
>>
>> Our problem:
>> When we use the predicate "assert" t is not recognized:
>> - gnu.prolog.vm.PrologException: error(existence_error(procedure,assert
> /
>> 1),error)
>> When we try "asserta" or "assertz" we have another error that implies we
>> would like to override the facts which are already in the environment:
>> - gnu.prolog.vm.PrologException:
>> error(permission_error(modify,static_procedure,foo / 1),error)
>>
>> Our question:
>> Is there any possibility to add facts to the environment dynamicly?
>>
>> Please note that I'm not on the mailing list so please reply directly.
>>
>> TIA
>>
>> Dominik
>>
>>
>>
>>