swi-prolog

how to redirect the console output of prolog inclusive trace or write(…) to c++ Variable

做~自己de王妃 提交于 2019-12-11 23:25:21
问题 I hope someone can help me and thanks a lot to anybody who have an idea :) this question is related to another one for same project but thematically slightly different thats why seperated it . Project in shortform: Prolog is Solving an existing 2D puzzle which i wrot a logic for. visual studio(VS) cli visualize the puzzle/parts. And finaly the interface should be used to display the Solving process (via prolog trace or "write()")step by step in VS Goal : Get the output from Prolog code

Interface from C-Programm in XCode to SWI-Prolog

随声附和 提交于 2019-12-11 19:07:20
问题 i want to interface from c-code using XCode IDE under MAC OS X to SWI-Prolog. I´ve included the header files and use the following sample code: #include <stdio.h> #include <SWI-Prolog.h> #include <SWI-Stream.h> int main(int argc, const char * argv[]) { char *av[10]; int ac = 0; av[ac++] = "/opt/local/lib/swipl-6.2.2/bin/i386-darwin12.2.1/swipl"; av[ac++] = "-x"; av[ac++] = "mystate"; av[ac] = NULL; #ifdef READLINE /* Remove if you don't want readline */ PL_initialise_hook(install_readline);

An easy to implement prolog graphical interface [closed]

懵懂的女人 提交于 2019-12-11 07:37:40
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 10 months ago . So, I have a college project now that uses Prolog, I'm not the first one to work on the code so it's already pretty huge, but I have to put it working with a Prolog graphical interface, so my question is: is there any Prolog graphical interface that doesn't require me to change the code that's already written?

how to consult file as a module in jpl

我只是一个虾纸丫 提交于 2019-12-11 06:27:13
问题 I am trying to consult Prolog file as a module, since jpl does not support multiple prolog vms. In swipl console, I can do something like this successfully ?- consult(mod1:'data/load.pro') . In java (well, it is actually scala, but they are all on top of jvm), I can consult file directly w/o issue scala> import jpl._ scala> val q = new Query("consult", Array[Term](new Atom("data/load.pl"))) scala> q.query() ... true however, when I tried to consult the file as module, I always get the

Turning a text file into a list using prolog. Using the split_string predicate

时间秒杀一切 提交于 2019-12-11 05:18:26
问题 I am trying to use the split_string/4 predicate to turn a string into a list of strings. I want the string separated by each newline. This is what my code looks like main(Argv) :- [InputFilename|OutputFileName] = Argv, read_file_to_string(InputFilename, InputFileString,[]), split_string(InputFileString,"\n", "\n", InputFileList), write(InputFileList). But it is not writing anything to the console. However if I put write(InputFileString) It prints the contents of the file just fine. What am I

Can you use clpfd to implement a coverage algorithm?

自作多情 提交于 2019-12-11 03:54:24
问题 Say I want to find the set of features/attributes that differentiate two classes in a simple matching manner can I use clpfd in prolog to do this? c_s_mining(Features,Value):- Features = [F1,F2,F3,F4], Features ins 0..1, ExampleA = [A1,A2,A3,A4], ExampleB =[B1,B2,B3,B4], ExampleC =[C1,C2,C3,C4], A1 #=0, A2#=1,A3#=0,A4#=1, B1 #=0, B2#=1,B3#=0,B4#=1, C1 #=1, C2#=0,C3#=0,C4#=1, ExampleD =[D1,D2,D3,D4], ExampleE =[E1,E2,E3,E4], ExampleQ =[Q1,Q2,Q3,Q4], D1#=1,D2#=0,D3#=1,D4#=0, E1#=1,E2#=0,E3#=1

how to get the result (two prolog lists ) from prolog, given via “c++ Interface to SWI-Prolog” , and store them in a variable in c++

瘦欲@ 提交于 2019-12-11 02:12:44
问题 Hello to everyone :) The Problem i have is how to get and store(Variable X and Y) from Prolog (via interface from swi-prolog) into a variable (c++) in visual studio In short: I transfered a Puzzle with triangular puzzle parts into Prolog representation. This puzzle is solved by prolog. This works so far. The visual representation with each puzzle tile is done in visual studion. This is working also. Now i want to call via Interface the prolog engine and this will return the Solution and each

invoking swi-prolog from php

大憨熊 提交于 2019-12-11 02:06:02
问题 I am trying to invoke swi-prolog from within a php script like : exec("start plwin.exe -f C:\\path\\load.pl -g run_from_file.", $os1); print_r($os1); I can see that prolog window gets opened and complies the file, but immediately exits displaying an exit status as 1. I am sure that it is not executing the predicate I want to to execute. Is there any other to invoke prolog with appropriate parameters and keep the window open without automatically exiting? UPDATE : I configured the system env

What makes a DCG predicate expensive?

纵然是瞬间 提交于 2019-12-11 01:57:09
问题 I'm building a Definite Clause Grammar to parse 20,000 pieces of semi-natural text. As the size of my database of predicates grows (now up to 1,200 rules), parsing a string can take quite a long time -- particularly for strings that are not currently interpretable by the DCG, due to syntax I haven't yet encoded. The current worst-case is 3 minutes for a string containing 30 words. I'm trying to figure out how I can optimize this, or if I should just start researching cloud computing. I'm

Prolog memory issues

点点圈 提交于 2019-12-10 21:13:11
问题 I'd like to find a way to profile the memory usage of a predicate (a huge one) I've written in prolog. I'm currently running it with swi and yap and I can see from those processes memory consumption that a big chunk of memory gets allocated. The problem is that it does not get deallocated/freed/garbage collected when the predicate terminates (I have to halt the interpreter to see it back) plus the amount of memory only keeps growing while the predicate is running (wheather it shall not since