gnu-prolog

uncaught exception: error(existence_error(procedure,likes/0),friend/0) (Seven Languages)

女生的网名这么多〃 提交于 2019-12-10 15:59:34
问题 Currently working through the Seven Languages in Seven Weeks book, and am stuck on getting the first prolog examples to run. This concerns the same code piece as this question; however I believe my question is quite different. I have defined likes and friend as in the book; my friends.pl: likes(wallace, cheese). likes(grommit, cheese). likes(wendolene, sheep). friend(X, Y) :- \+(X = Y), likes(X, Z), likes(Y, Z). I am using gnu prolog (v1.4.5, on Ubuntu 18.10), and I can load the friends.pl

Simple PROLOG issue: How do you test multiple queries against your Prolog database?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-08 21:22:47
问题 I have a Prolog database file (test_inserts.p) that I used to insert all my data. I also have a Prolog query file (test_queries.pl) that has all of the Prolog queries I wrote up to receive specific information from my database. I was wondering how to actually use the test_queries.pl queries against my test_inserts.p database file when using gprolog? I was hoping there would be a way to load both at the same time, and somehow be able to command which query to run, instead of having to re-type

Problem with `\\+` in Prolog queries with variables

假如想象 提交于 2019-12-05 12:29:43
I'm reading "Seven languages in seven weeks" atm, and I'm stumped over some Prolog query that I don't understand the 'no' response to. The friends.pl file looks like this: likes(wallace, cheese). likes(grommit, cheese). likes(wendolene, sheep). friend(X, Y) :- \+(X = Y), likes(X, Z), likes(Y, Z). I can do some trivial queries on it, such as: | ?- ['friends']. compiling /home/marc/btlang-code/code/prolog/friends.pl for byte code... /home/marc/btlang-code/code/prolog/friends.pl compiled, 12 lines read - 994 bytes written, 8 ms yes | ?- friend(wallace,grommit). yes | ?- friend(wallace,wendolene).

How to list all predicates that has an specific atom?

大憨熊 提交于 2019-12-01 00:04:49
another way to ask the question is: How I can list all the properties of an atom? For example: movie(agora). director(agora, 'Alejandro Amenabar') duration(agora, '2h'). so, I will like to receive all the predicates that has agora for argument. In this case it will be: movie, director, duration, with the other parameters ('Alejandro Amenabar', '2h'). I found: this , and this questions, but I couldn't understand well. I want to have value of false in the "variable Answer" if PersonInvited doesn't like something about the movie. My query will be: answer(Answer, personInvited,

How to list all predicates that has an specific atom?

梦想与她 提交于 2019-11-30 18:50:01
问题 another way to ask the question is: How I can list all the properties of an atom? For example: movie(agora). director(agora, 'Alejandro Amenabar') duration(agora, '2h'). so, I will like to receive all the predicates that has agora for argument. In this case it will be: movie, director, duration, with the other parameters ('Alejandro Amenabar', '2h'). I found: this, and this questions, but I couldn't understand well. I want to have value of false in the "variable Answer" if PersonInvited doesn

Prolog - generating numbers fitting given range

丶灬走出姿态 提交于 2019-11-30 13:42:11
I'd like to use predicates like: range(X,0,5) range(X,4,200) range(X,-1000000,1000000) dom_range(X,-1000000,1000000) with meaning : range(X,0,5) :- member(X,[0,1,2,3,4,5]). range(X,4,200) :- member(X,[4,5,6...198,199,200]). range(X,-1000000,1000000) :- member(X,[-1000000,...,1000000]). dom_range(X,-1000000,1000000) :- domain(X, [-1000000,...,1000000]). How to code it in Prolog nicely (taking solution performance into account - depth of recursion etc) ? Solution is expected to run on GNU-Prolog. P.S. Question inspired with this question . SWI-Prolog has the predicate between/3 . so you would

Prolog - generating numbers fitting given range

浪子不回头ぞ 提交于 2019-11-29 19:15:30
问题 I'd like to use predicates like: range(X,0,5) range(X,4,200) range(X,-1000000,1000000) dom_range(X,-1000000,1000000) with meaning : range(X,0,5) :- member(X,[0,1,2,3,4,5]). range(X,4,200) :- member(X,[4,5,6...198,199,200]). range(X,-1000000,1000000) :- member(X,[-1000000,...,1000000]). dom_range(X,-1000000,1000000) :- domain(X, [-1000000,...,1000000]). How to code it in Prolog nicely (taking solution performance into account - depth of recursion etc) ? Solution is expected to run on GNU

Prolog Compatibility Layers - available programming libraries

两盒软妹~` 提交于 2019-11-29 07:36:46
There is a lack of some predicates in one Prolog implementations, that are available in others. We can implement lacking predicates, let's call this "Prolog Compatibility Layer". Do you know "Prolog Compatibility Layers" for Prolog (especially for GNU-Prolog) ? Please structure answers in following way: Title with link. "Implemented for" - prolog implementation you might like to use "Compatibility with" - prolog implementation for which compatibility layer is done "Functions" - list of compatibility functions (you can bold yours favourites) "Additional info" - comments, requirements,

Prolog Compatibility Layers - available programming libraries

我只是一个虾纸丫 提交于 2019-11-28 01:19:34
问题 There is a lack of some predicates in one Prolog implementations, that are available in others. We can implement lacking predicates, let's call this "Prolog Compatibility Layer". Do you know "Prolog Compatibility Layers" for Prolog (especially for GNU-Prolog) ? Please structure answers in following way: Title with link. "Implemented for" - prolog implementation you might like to use "Compatibility with" - prolog implementation for which compatibility layer is done "Functions" - list of

gprolog: Getting a stacktrace after an exception

吃可爱长大的小学妹 提交于 2019-11-26 16:45:29
While using gprolog I often have exceptions without any kind of line numbers or context like this one: uncaught exception: error(instantiation_error,(is)/2) Without any kind of context. I know I can do a trace but it would take very long to debug it with trace since I need to execute a lot of things before getting to the place where the error occur. Any idea on how to have this stacktrace ? Or a dynamic trace / notrace ? EDIT: Or just automate the printing of the whole trace output. @gusbro's answer ( s(X) ) shows you how you somewhat solve this with GNU's debugger. However, if you cannot