swi-prolog

Does a JSON-RPC server exist for answering general Prolog queries?

一笑奈何 提交于 2019-12-24 11:18:13
问题 I saw this tutorial for writing a JSON-RPC server for SWI-Prolog. Unfortunately, all it does is add two numbers. I'm wondering if there exists a RPC server for SWI-Prolog that can define new rules and answer general Prolog queries, returning JSON lists, etc? 回答1: When you take a tour on SWI-Prolog website, proudly self-powered, you can see at work some of the features offered by http package. It's a fairly large range of tools, and to grasp the basic of the system, the easiest way it's to

Unit Tests in SWI-Prolog: Visibility of User Predicates from within a Module

别等时光非礼了梦想. 提交于 2019-12-24 10:48:41
问题 I want to write unit tests in SWI-Prolog (version 7.6.4) in order to streamline and automate testing, which is currently done only in a manual, ad-hoc fashion. The files to be tested contain complex algorithms that make use of predicates from modules, which in turn operate on user-defined predicates (that serve as input data or problem instance). As a minimal example, consider the following: File ' graph.pl ' (input data and algorithm): :- use_module(path). edge(a,b). edge(b,c). edge(c,d).

Error related to Microsoft.VisualStudio.TestTools.UnitTesting namespace

人走茶凉 提交于 2019-12-24 10:38:27
问题 I am developing a windows store app which take the user input(mathematical question),process it using prolog and output the answer. I have add Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll as an reference to my windows Store app. I refer https://github.com/SWI-Prolog/contrib-swiplcs/blob/master/TestSwiPl/PlQuery.cs This reference creates two errors, 1.Cannot resolve Assembly or Windows Metadata file 'System.Configuration.dll' 2.Type universe cannot resolve assembly: System

Foreach not working in Prolog

寵の児 提交于 2019-12-24 09:49:11
问题 I am trying following code, where foreach and string_codes are working separately: 7 ?- string_codes("acid", D). D = [97, 99, 105, 100]. 8 ?- string_codes(S, [116, 101, 115, 116]). S = "test". 15 ?- foreach(member(S, ["test", "acid"]), writeln(S) ). test acid true. But not together: 14 ?- foreach(member(S, ["test", "acid"]), string_codes(S, X) ). false. 17 ?- foreach(member(X,[[116, 101, 115, 116], [97, 99, 105, 100]]), string_codes(S, X)). false. Only first letter is printed with this code:

Prolog SWI : Logtalk, How do I load my own project files?

蹲街弑〆低调 提交于 2019-12-24 09:00:39
问题 so this week consisted of me installing Logtalk, one of the extensions for Prolog. In this case I'm using Prolog SWI, and I've run into a little snag. I'm not sure how to actually consult my own projects using Logtalk. I have taken a look at the examples that Logtalk comes with in order to understand the code itself, and in doing so I've been able to load them and execute them perfectly. What I don't understand though is what is actually going on when logtalk is loading a file, and how I can

SWI-Prolog - Unit testing library plunit - How is forall option used?

若如初见. 提交于 2019-12-24 00:24:23
问题 For my lexer (tokenizer) all of the ASCII 7-bit characters (0x00 to 0x7F) have a specific token. As SWI-Prolog supports Unicode, the character codes go from 0x0000 to 0xFFFF. In my lexer, since there are many characters that will not map to a specific token there is an unknown token (tokUnknown). To ensure that all of the characters with code between 0 and 127 (0x00 to 0x7F) do not have tokUnknown , test cases are needed. The test case needs a simple lexer to convert the character to a token.

Querying Prolog variables with JPL

感情迁移 提交于 2019-12-23 19:49:35
问题 I want to make a query to use Prolog in java through JPL, I read the documentation (http://www.swi-prolog.org/packages/jpl/java_api/getting_started.html) The prolog predicates are these: child_of(joe, ralf). child_of(mary, joe). child_of(steve, joe). child_of(steve, ralf). descendent_of(X, Y) :- child_of(X, Y). descendent_of(X, Y) :- child_of(Z, Y), descendent_of(X, Z). My code looks like this Variable X = new Variable(); Query q4 = new Query( "descendent_of", new Term[] {X,new Atom("joe")} )

Creating a saved state in SWI-Prolog

核能气质少年 提交于 2019-12-23 19:04:45
问题 I am trying to create a saved state from toplevel in Windows, but I keep getting this error: 1 ?- qsave_program('U:/boo64.prc'). % library(broadcast) compiled into broadcast 0.00 sec, 7,504 bytes % library(debug) compiled into prolog_debug 0.00 sec, 21,544 bytes % library(option) compiled into swi_option 0.00 sec, 14,416 bytes % library(arithmetic) compiled into arithmetic 0.00 sec, 33,872 bytes % library(settings) compiled into settings 0.00 sec, 120,152 bytes % c:/program files/swi-prolog

Logtalk : what is the best way to run all test suites?

拟墨画扇 提交于 2019-12-23 17:22:02
问题 In Logtalk code examples, each example provides its own test suite which is runnable in a "standalone" mode (one test suite at once). But, as the title says, I'm interested in the best approaches of testing all test suites (all loaded objects inheriting lgtunit in my app) at once, and having one single summary of all tests execution at the end (total passed / skipped / failed). For example, in SWI-Prolog, run_tests/0 run all test-units. 回答1: For automation, there's a logtalk_tester Bash shell

Structuring SWI-Prolog Code into Modules for Unit Testing for Varying Data Sets and Module Implementations

对着背影说爱祢 提交于 2019-12-23 16:04:02
问题 To elaborate on a discussion in the comments below my last question: I am looking for suggestions on techniques or best practices for structuring SWI-Prolog code in order to be able to use and test alternative, interchangeable implementations of algorithms and their supporting modules. The current situation can be illustrated using the following small, ficticous example: The user provides some input data (file data.pl ) and loads a module with an algorithm to be applied (file graph.pl ). The