iso-prolog

GNU Prolog assert error

ⅰ亾dé卋堺 提交于 2019-12-28 06:59:06
问题 I am new to Prolog, but I am stuck at this supposedly simple command. I have loaded a knowledge base with no errors, and whenever I try do assert (and even help ) I get the following message: uncaught exception: error(existence_error(procedure,assert/1),top_level/0) {2} What am I exactly missing? Appreciated. 回答1: Use assertz/1 or asserta/1 instead. GNU-Prolog does not provide assert/1 because only asserta/1 and assertz/1 are defined in the standard. Note that while asserta/1 always had one

Is this Prolog terminology correct?

泪湿孤枕 提交于 2019-12-23 12:46:13
问题 Getting the terminology correct is part of the success to communicating a concept and when the wrong terminology is used here at SO with the Prolog tag the respondents nicely point out the mistake. In reading "Clause and Effect - Prolog Programming for the Working Programmer" by William F. Clocksin in 1997 (WorldCat) is the paragraph A Prolog program consists of a collection of procedures . Each procedure defines a particular predicate , being a certain relationship between its arguments . A

Is an infinite list of ones sane?

戏子无情 提交于 2019-12-23 08:17:01
问题 In Prolog, is the unification X = [1|X] a sane way to get an infinite list of ones? SWI-Prolog does not have any problem with it, but GNU Prolog simply hangs. I know that in most cases I could replace the list with one(1). one(X) :- one(X). but my question is explicitly if one may use the expression X = [1|X], member(Y, X), Y = 1 in a "sane" Prolog implementation. 回答1: In Prolog, is the unification X = [1|X] a sane way to get an infinite list of ones? It depends on whether or not you consider

Implementing user-defined arithmetic functions

偶尔善良 提交于 2019-12-22 07:09:07
问题 How can I add a function (e.g., hammingweight) and use it in expressions occuring in the right-hand side is some (is)/2 goal? Could something like goal_expansion or term_expansion help here? I acknowledge that this is not a big feature, but it could increase readability of some of my Prolog programs. Writing a custom (is)/2 predicate (implementing a custom expression evaluator) is do-able, but I would like to keep runtime overhead low, as I don't want to sacrifice readability for runtime

How is a integer created as a character code constant?

蹲街弑〆低调 提交于 2019-12-20 02:28:37
问题 I am building some test cases for integer/1 using SWI-Prolog. ISO/IEC 13211-1 gives a BNF definition for integer and one of the alternatives for integer is for a character code constant . I am able to create and test examples of all the other alternatives using integer/1 but for character code constant I cannot create a valid example. (see below) How is an integer as a character code constant created that will return true using integer/1? Answer Thanks to @false. integer(0'0). true. integer(0

throw without catch in ISO Prolog

为君一笑 提交于 2019-12-20 01:55:09
问题 I am struggling with what is the precise semantics of throw/1 without a suitable catch/3 in ISO Prolog. I am reading the ISO Prolog specification, and it seems to me that the execution will end up in an infinite recursion. (Note that you must have access to the ISO Prolog standard in order to interpret this question). Step 1. Let's say we call throw(unknown), and there is no catch/3 on the stack whatsoever. Step 2. It will end up in 7.8.10.1 c), saying that it will be an system error (7.12.2

Hilog terms in (XSB) Prolog

那年仲夏 提交于 2019-12-19 16:19:30
问题 Are Hilog terms (i.e. compounds having as functors arbitrary terms) still regarded as a powerful feature in XSB Prolog (or any other Prolog) ? Are there many XSB projects currently using this feature ? which of them for example ? I ask since as far as I understand higher order programming is equally possible using the ISO built-in call/N. Specifically, I would like to understand if XSB is using Hilog terms just for historical reasons or if Hilog terms have considerable advantages in

Extension to CFG, what is it?

限于喜欢 提交于 2019-12-19 02:22:19
问题 Consider the following extension to context-free grammars that permits rules to have in the left-hand side, one (or more) terminal on the right side of the non-terminal. That is, rules of the form: A b -> ... The right-hand side may be anything, like in context-free grammars. In particular, it is not required, that the right-hand side will have exactly the same terminal symbol at the end. In that case, this extension would be context-sensitive. But the terminal is not just a context.

What does +,+ mode in Prolog mean?

吃可爱长大的小学妹 提交于 2019-12-18 07:02:11
问题 So am being told a specific predicate has to work in +,+ mode. What does that mean in Prolog? 回答1: When one wants to give information on a predicate in prolog, those conventions are often used : arity : predicate/3 means predicate takes 3 arguments. parameters : predicate(+Element, +List, -Result) means that Element and List should not be free variables and that Result should be a free variable for the predicate to work properly. ? is used when it can be both, @ is mentionned on the above

What does +,+ mode in Prolog mean?

你说的曾经没有我的故事 提交于 2019-12-18 07:01:09
问题 So am being told a specific predicate has to work in +,+ mode. What does that mean in Prolog? 回答1: When one wants to give information on a predicate in prolog, those conventions are often used : arity : predicate/3 means predicate takes 3 arguments. parameters : predicate(+Element, +List, -Result) means that Element and List should not be free variables and that Result should be a free variable for the predicate to work properly. ? is used when it can be both, @ is mentionned on the above