## Iterative search using Prolog

search.pl solve(P) :- start(Start), search(Start,[Start],Q), reverse(Q,P). search(S,P,P) :- goal(S), !. /* done */ search(S,Visited,P) :- next_state(S,Nxt), /* generate next state */ ...
more »

## Prolog DCG set_prolog_flag double_quotes source code directive location matters; documentation?

I learned the hard way that with SWI-Prolog the location for the Prolog directive set_prolog_flag matters in a source code file. The only documentation I found of value about loading source code files with directives was in Loading Prolog source fil...
more »

## Using embedded R tool in Prolog

I know with using pack 'real', we can use embedded R in Prolog. But I met problems to use this pack. And I didn't find simple examples of using this pack. Can somebody give a simple example of this pack? e.g. Loading Prolog values on to R variable...
more »

## Is "Greedy Search using Heuristic Values" the same as "Heuristic Depth First Search"?

Title says it all really, essentially. Basically, I'm given a search tree and tasked with finding how the solution to a goal node is reached using a "Greedy search using Heuristic Values". I would assume that it is the same as a Heuristic Depth-Fir...
more »

## Prolog: Write code to manipulate a graph to find a solution at a depth of 2 when Goal Node is at a depth of 3

I'm trying to write depth limited code that will manipulate the graph here and find the solution node G at a depth of 2. I'm also trying to get the code to return the cost of the solution path. So far I've gotten this: solve( Node, Solution) :- ...
more »

## Prolog - days of the week

I'm new at prolog and it is messing up my head. Could you guys give me a simple example like.. the days of the week! Let's say I have a day(mon, tue, wed, thu, fri). and I wanna know in which day of the week I'm on (assuming on start it'll akways...
more »

## Prolog: How to get a path from a start node to a Goal Node

I'm trying to write a prolog program that will represent a goal node G and will return a list of nodes from a predicate called something like get_path(StartNode, Path) from the start node to the goal node. I have a set of nodes, each with a heuristi...
more »

## prolog - BFS algorithm to solve rubik cube issue

I'm wondering how to run BFS algorithm for rubik cube that is an input parameter of my function. So far I have created functions rotateUp(cubeIn, cubeOut), rotateDown(cubeIn, cubeOut2), rotateFront(cubeIn, cubeOut), rotateBack(cubeIn, cubeOut), rotat...
more »

## How would I create a DCG to parse queries about a database?

I'm just playing around with learning Prolog and am trying to build a database of information and then use natural English to query about relationships. How would I go about doing this? Example: %facts male(bob). female(sarah). male(timmy). femal...
more »

## A* search in Prolog

I tried implementing a 15puzzle solver in prolog as a way to try and learn the language and take advantage of the native backtracking. I followed a few online resources and wrote this simple version of the A* algorithm. All it does is generate all t...
more »

## Does a Dictionary<List<_>> qualify as semipersistent?

In Extended Abstract: A Functional Derivation of the Warren Abstract Machine, Maciej PirĀ“og and Jeremy Gibbons describe a data structure as semi-persistent [7] " if we can backtrack to its previous versions, but we never simultaneously keep two dif...
more »

## prolog avoiding duplicate predicates

I was wondering whether it is possible to test whether a predicate already exists (with the same information) to then avoid the user being able to input the same information again. I have already managed to do it for a single predicate: :- dynamic(...
more »

## Generate predicates from Json

I have a WEB API done in Asp.Net that returns some points of interest in JSON. In prolog I obtain it by doing this: poi(X):- http_client:http_get('http://localhost:XXXXX/api/PontosInteresse',X,[]). This returns something of the sort: X = '[{"ID":...
more »

## Error trying to install jpl library. jpl.dll: Can't find dependent libraries

I have a problem installing jpl library. I installed the latest swipl version (but I tried also unstable versions before): SWI-Prolog 7.2.3 for Windows 7/8/10 64-bit edition Then I added dependent paths to environment variables: Variable: SWI_H...
more »

## write queries results into a file in prolog

Here is my prolog database code. :- dynamic myTable/2. init :- removeAll, asserta(myTable('avalue', 'another value')), asserta(myTable('avalue1', 'another value 1')), asserta(myTable('avalue2', 'another value 2')), asserta(m...
more »

## List finding in a list of lists in Prolog

I want to find a specific list inside a list of lists in prolog, let's say the list is: L[L1,L2,L3......] every list inside L is in the format: L1[A,B,C,D] I want to find a Ln with the smallest A, how can I do it? ...
more »

## Prolog how to find sum of elements matrix

I have matrix size [n,n]. I need to find sum For example 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 sum = 3+4+7+8 I need to find sum of elements of first quadrant matrix ...
more »

## A positive_integer/1 predicate that works for big numbers

In my Prolog-inspired language Brachylog, there is the possibility to label CLP(FD)-equivalent variables that have potentially infinite domains. The code that does this labelization can be found here (thanks to Markus Triska @mat). This predicate re...
more »

## Is debugger feature only supported by Amzi! prolog Commercial version?

I installed Eclipse Neon + Amzi! Prolog (win64+10.0.4) a few days ago. But when I tries to debug my prolog program, the IDE cries "This feature is not available in the edition you are running ..." with a "Yes" button to redirect to a webpage seems ou...
more »