Questions tagged [iso-prolog]

ISO/IEC has standardized Prolog. The standard is maintained by ISO/IEC JTC1/SC22/WG17.

ISO/IEC has standardized Prolog. The standard is maintained by ISO/IEC JTC1/SC22/WG17.

The currently valid Prolog standard documents can be obtained from national member bodies like ANSI or directly from ISO. Overview of defined features.

Stack Overflow contributions about the standard documents:

143 questions
5
votes
3 answers

What does +,+ mode in Prolog mean?

So am being told a specific predicate has to work in +,+ mode. What does that mean in Prolog?
chutsu
  • 13,612
  • 19
  • 65
  • 86
5
votes
2 answers

Why does SWI-Prolog unify a quoted and unquoted string (without spaces) to the same rule?

Assume I have the following rules: unify('test', 'this is a test'). run :- write('Enter something: '), read(X), unify(X, Y), write('The answer is '), write(Y). And then I run it as follows: ?- ['unify.pl']. % unify.pl…
Vivin Paliath
  • 94,126
  • 40
  • 223
  • 295
5
votes
4 answers

How can I simulate a soft cut in Prolog?

How can I simulate a soft cut I *-> T; E in ISO Prolog? I has side effects, so I can not call it multiple times. Except for the last requirement, I think the following definition works: if_(I, T, E) :- not(not(I)) -> call((I, T)); …
Ed McMan
  • 521
  • 2
  • 15
5
votes
1 answer

Why did Technical Corrigendum 2 to ISO/IEC 13211-1:1995 omit "bar" from the "token" rule?

Cor.2 says (only) the following about clause 6.4: 6.4 Tokens Add as the last syntax rule: bar (* 6.4 *) = [ layout text sequence (* 6.4.1 *) ] , bar token (* 6.4.8 *) ; Surely another modification to 6.4 is intended, namely to add bar (*…
5
votes
4 answers

Implementing user-defined arithmetic functions

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…
repeat
  • 18,496
  • 4
  • 54
  • 166
5
votes
2 answers

How Prolog's logical update view works for assert and retract?

Can someone please explain the Prolog logical view about assert and retract in details? For example in code below, in the first run Prolog returns true and in subsequent runs returns false. I don't know why because of Prolog logical view when …
CoderInNetwork
  • 2,923
  • 4
  • 22
  • 39
5
votes
3 answers

What do Prolog implementations mean by "float"?

I was looking through the SICStus manual's syntax description and there is a definition of "float". However, there is no indication of what the implementation of "float" actually is. IEEE single or double precision? Maybe even a BigDecimal? In SWI…
David Tonhofer
  • 14,559
  • 5
  • 55
  • 51
5
votes
1 answer

Difference between two variant implementations

Is there any logical difference between these two implementations of a variant predicate? variant1(X,Y) :- subsumes_term(X,Y), subsumes_term(Y,X). variant2(X_,Y_) :- copy_term(X_,X), copy_term(Y_,Y), numbervars(X, 0, N), numbervars(Y, 0,…
S0rin
  • 1,283
  • 1
  • 10
  • 22
5
votes
3 answers

Why does Prolog operator definitions have xfx?

For languages such as Java and C which allow syntactic sugar with operators, i.e. infix, they use precedence and associativity. Prolog also uses associativity: left-associative - yfx right-associative - xfy but why is there xfx? The only thing I…
Guy Coder
  • 24,501
  • 8
  • 71
  • 136
5
votes
3 answers

Making Prolog code that works in GNU and SWI

I realize there are going to be limits to this, but is there a reasonable way to put in conditional directives in Prolog code so that it an work reasonably in either GNU or SWI? I'm thinking at least the simplest cases, where built-in predicates…
lurker
  • 56,987
  • 9
  • 69
  • 103
5
votes
1 answer

DCG for idiomatic phrase preference

I have a manually made DCG rule to select idiomatic phrases over single words. The DCG rule reads as follows: seq(cons(X,Y), I, O) :- noun(X, I, H), seq(Y, H, O), \+ noun(_, I, O). seq(X) --> noun(X). The first clause is manually made, since (:-)/2…
user502187
5
votes
4 answers

Does Prolog have a condition and restart system like Common Lisp?

Common Lisp allows exception handling through conditions and restarts. In rough terms, when a function throws an exception, the "catcher" can decide how/whether the "thrower" should proceed. Does Prolog offer a similar system? If not, could one…
mndrix
  • 3,131
  • 1
  • 30
  • 23
4
votes
1 answer

error while compling the metaprogram in prolog

I am trying to implement a meta-program in ECLiPSe Prolog, and here's the code that i have written - :- dynamic go/1. sol(true):- !. sol((A,B)):- !, sol(A), sol(B). sol(A):- clause(A, Body), sol(Body). go(X):- X is 5. Now when I query with…
kallakafar
  • 725
  • 3
  • 11
  • 27
4
votes
1 answer

Is !/0 supposed to cut through (\+)/1 or not?

On the one hand: $ sicstus SICStus 4.6.0 (x86_64-linux-glibc2.17): Mon Apr 6 09:23:37 PDT 2020 [...] | ?- \+ (!,false) ; X = 1. yes ... on the other hand ... $ gprolog GNU Prolog 1.4.5 (64 bits) [...] | ?- \+ (!,false) ; X = 1. true ? ; X =…
repeat
  • 18,496
  • 4
  • 54
  • 166
4
votes
2 answers

Disjunction G1 ; G2 vs. If-then-else Cond -> G1 ; G2

I encountered a Prolog program containing a nested if-then-else of the form p(X,Y) :- (cond1(X,Y) -> q(X)); true, (cond2(X,Y) -> q(Y)); true. that had unexpected answers. The reason for this behaviour is the same as in the following…
lambda.xy.x
  • 4,918
  • 24
  • 35