info-gnuprologjava
[Top][All Lists]
Advanced

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

Re: [Info-gnuprologjava] GPJ gives different results than GNU-Prolog


From: Burak Emir
Subject: Re: [Info-gnuprologjava] GPJ gives different results than GNU-Prolog
Date: Wed, 12 Sep 2012 23:49:18 +0200

P.S. I have reduced it to the following.
I guess one can reduce it further.
Could it be that something is wrong with the dynamic(hasCert/2) ?

-- Burak

/// code:

msg(2, subs, subsender, 'subscriptionConfirmation', [cert(subs)] ).
msg(3, subsender, sender, 'create', [cert(subs)] ).

:- dynamic(hasCert/2).

sendCert(Sender, Receiver, Cert):-
        hasCert(Sender, Cert),
        assertz(hasCert(Receiver, Cert)),
        write(Sender), write(' can send '), write(Cert),
     write(' to '), write(Receiver), write('\n').

sendCert(Sender, Receiver, cert(Sender)):-
        assertz(hasCert(Receiver, cert(Sender))),
        write(Sender), write(' is able to create '),
        write(cert(Sender)),
        write(' and to send it to '), write(Receiver), write('\n').

sendAllCerts(_, _, _, []).

sendAllCerts(Step, From, To, [F_Cert|Rest]):-
        sendCert(From, To, F_Cert),
        sendAllCerts(Step, From, To, Rest).

sendAllCerts(Step, From, To, [F_Cert|Rest]):-
        \+(sendCert(From, To, F_Cert)),
        sendAllCerts(Step, From, To, Rest),
        write('ERROR: '),
        write(From), write(' is not able to send '),
        write(F_Cert), write(' to '),
        write(To), write('\n').

run(Step, MaxSteps):- Step < MaxSteps,
        msg(Step, Sender, Receiver, Name , C_List),
        sendAllCerts(Step, Sender, Receiver, C_List),
        write(Sender), write(' can send message '),
        write(Name), write(' to '), write(Receiver), write('\n'),
        IPlus1 is Step + 1, run(IPlus1, MaxSteps).

run(Step, MaxSteps):-
        Step < MaxSteps,
    \+(msg(Step, _, _, _, _,_ )),
        IPlus1 is Step + 1, run(IPlus1, MaxSteps).

run(MaxSteps, MaxSteps).

run:-run(2,4).

/// GPJ output:
subs is able to create cert(subs) and to send it to subsender
subs can send message subscriptionConfirmation to subsender
ERROR: subsender is not able to send cert(subs) to sender
subsender can send message create to sender

/// GNU Prolog output:
subs is able to create cert(subs) and to send it to subsender
subs can send message subscriptionConfirmation to subsender
subsender can send cert(subs) to sender
subsender can send message create to sender



On Wed, Sep 12, 2012 at 7:33 PM, Burak Emir <address@hidden> wrote:
> Hey John,
>
> Looks interesting, probably a bug!
>
> Your example is still quite long though - is it possible to find a
> smaller program that still produces two different results?
>
> At the risk of stating the obvious, having the shortest program
> possible makes it much easier to debug.
>
> -- Burak Emir
>
> On Tue, Sep 11, 2012 at 3:19 PM, John Cheung <address@hidden> wrote:
>> Hello,
>>
>> i'm trying to run my prolog programm from Java with GPJ.
>>
>> The programm gives the correct result in GNU-Prolog, but GNU Prolog for Java
>> gives another
>> result. Can it be that GNU Prolog supports more or other commands than GPJ?
>> I don't see what's causing this problem.
>>
>>
>> I've attached the program and the different results for you. You can start
>> the Programm by
>> invorking "run." .
>>
>> I need this for my thesis, so I would be very grateful if you could help me.
>>
>> Thank You,
>>
>> John C.
>
>
>
> --
> Burak Emir
> --
> http://burak.emir.googlepages.com



-- 
Burak Emir
--
http://burak.emir.googlepages.com



reply via email to

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