SWI-Prolog Service Implmentation
Pavan Kumar <[email protected]> Thu, 24 Apr 2014 20:05:59 -0500
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <CAFVqwvgzDWv9n_RACKnZzLo6KNaqkYs6upiNAxu+sODz_9sBsg@mail.gmail.com> |
A more precise description of our problem and approach is given below Problem ----------------- Write a java program which continuously sends (different) queries to SWI-prolog and capture the execution result. One proposed approach as suggested by Jan and several other people ------------------- We will use socket programming: write a server using SWI-Prolog and write a client using Java. An example of the interaction of the java client and server is as follows. ========================================================== 1. The Client(Java Program) should send to the server: use_module(library(clpfd)) 2. The server will send back the execution result (by swi-prolog): *% library(occurs) compiled into occurs 0.00 sec, 14 clauses* *% library(apply_macros) compiled into apply_macros 0.02 sec, 44 clauses* *% library(assoc) compiled into assoc 0.00 sec, 103 clauses* *% library(clpfd) compiled into clpfd 0.25 sec, 2,683 clauses* 3. The Client then send the following Query to the server: Z#=X*Y+X+1,[Y, X] ins 0..10,0500, Z in 1..5\/10\/12. 4. The server will send to the client the following execution result: *Z in 1..5\/10\/12,* *_G576+1#=Z,* *_G576 in 0..4\/9\/11,* *_G606+X#=_G576,* *_G606 in 0..11,* *X*Y#=_G606,* *X in 0..11,* *Y in 0..100500* 5. The interaction between the client and the server will repeat as above. Here is our attempt and questions to write this server: ------------------------------------------------------------------------- 1. Let the Query from the client be a string 2. How to translate this string to a *goal *and Execute the goal on the SWI-Prolog Engine? 3. How to capture the SWI-Prolog output from the execution of the goal (say as a string P)? 4. Send the string P to the client. Or the above pseudo code is completely out of track? Is it possible for anyone of your provide a sample code (with needed built-in predicates on the critical steps so that we can study them from the menu for the right use of them). -------------- next part -------------- HTML attachment scrubbed and removed