How to make communication between java in prolog?

2

Good morning!

I need to develop a specialist system like college work. I thought about doing it using java to create the interface and prolog as an inference engine and fact base. But the links I found about a JPL library are broken and I do not know how to do the communication between these two technologies. Can someone give a light?

ps: Using ubuntu 14.04

    
asked by anonymous 16.07.2016 / 15:43

1 answer

3

An alternative is the library tuProlog I used na to make a game of chess using java for the interface and prolog as an inference engine

In the Java file would have something like:

static Prolog engine = new Prolog();
engine.setTheory(new Theory(new FileInputStream("prolog/xadrez.pl")));
engine.solve("iniciarJava.");
info = engine.solve("mostrartab(T).");

In the prolog file the rules and logic:

mostrartab(T):-
  findall((P,Cl,(L,C)),p_atual(P,Cl,(L,C)),T).

/*carrega a base de fatos que será o tabuleiro durante a partida*/
iniciarJava:- retractall(p_atual(_,_,(_,_))),retractall(cemiterio(_,_)),
assert(p_atual('T','B',(1,1))),assert(p_atual('H','B',(1,2))),
assert(p_atual('B','B',(1,3))),assert(p_atual('Q','B',(1,4))),
assert(p_atual('K','B',(1,5))),assert(p_atual('B','B',(1,6))),
assert(p_atual('H','B',(1,7))),assert(p_atual('T','B',(1,8))),
assert(p_atual('T','W',(8,1))),assert(p_atual('H','W',(8,2))),
assert(p_atual('B','W',(8,3))),assert(p_atual('Q','W',(8,4))),
assert(p_atual('K','W',(8,5))),assert(p_atual('B','W',(8,6))),
assert(p_atual('H','W',(8,7))),assert(p_atual('T','W',(8,8))),
assert(p_atual('P','B',(2,1))),assert(p_atual('P','B',(2,2))),
assert(p_atual('P','B',(2,3))),assert(p_atual('P','B',(2,4))),
assert(p_atual('P','B',(2,5))),assert(p_atual('P','B',(2,6))),
assert(p_atual('P','B',(2,7))),assert(p_atual('P','B',(2,7))),
assert(p_atual('P','W',(7,1))),assert(p_atual('P','W',(7,2))),
assert(p_atual('P','W',(7,3))),assert(p_atual('P','W',(7,4))),
assert(p_atual('P','W',(7,5))),assert(p_atual('P','W',(7,6))),
assert(p_atual('P','W',(7,7))),assert(p_atual('P','W',(7,8))),
assert(p_atual(' ',' ',(_,_))).

To get the prolog return:

info.getVarValue("T")
    
16.07.2016 / 16:46