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
7
votes
1 answer

Complexity of ISO Prolog predicates

Are there any guarantees for upper bounds on the time complexity of the standard Prolog predicates? For example: is it certain that sort(+List, ?SortedList) runs in O(nlog(n)) time (n being the length of List) in any standard compliant Prolog…
Tudor Berariu
  • 4,910
  • 2
  • 18
  • 29
7
votes
3 answers

Minor inconsistency due to different operator precedence of ** and ^

Why is argument precendence of **/2 (xfx) and (^)/2 (xfy) not the same in Prolog? This causes minor inconsistencies, such as the following: ?- X = 1, Y is 1 ^ -X. X = Y, Y = 1. and: ?- Y is 1 ** -1. Y = 1. but: ?- X = 1, Y is 1 ** -X. ERROR:…
Wouter Beek
  • 3,307
  • 16
  • 29
7
votes
3 answers

Is an infinite list of ones sane?

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…
Kijewski
  • 25,517
  • 12
  • 101
  • 143
7
votes
1 answer

GNU Prolog assert error

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:…
zpavlinovic
  • 1,507
  • 1
  • 17
  • 36
7
votes
1 answer

What are the minimum/maximum integers in gprolog?

What are the minimum/maximum integers in gprolog? Is there a way to reference these numbers without using a "magic number"?
user2309462
  • 126
  • 8
6
votes
2 answers

Equivalence of disjunction operator and definition with several rules

I just stumbled over the definition of ;/2 in the SWI Prolog Manual which states: The `or' predicate is defined as: Goal1 ; _Goal2 :- Goal1. _Goal1 ; Goal2 :- Goal2. Wouldn't that mean that ;/2 behaves exactly as if we wrote our own helper…
lambda.xy.x
  • 4,918
  • 24
  • 35
6
votes
2 answers

Is it possible to preserve variable names when writing and reading term programatically?

I'm trying to write an SWI-Prolog predicate that applies numbervars/3 to a term's anonymous variables but preserves the user-supplied names of its non-anonymous variables. I eventually plan on adding some kind of hook to term_expansion (or something…
ksoo
  • 434
  • 1
  • 3
  • 15
6
votes
1 answer

Prolog error arguments

I'm wondering how to go about adding error checking in Prolog. For instance I have a program that will find how long a list is: listlen([],0). listlen([_|T],N) :- listlen(T,X), N is X+1. How would I print out an error like "The 1st argument…
Asia x3
  • 606
  • 2
  • 16
  • 37
6
votes
4 answers

Intersection of two lists of variables

How to define in ISO Prolog a (meta-logical) predicate for the intersection of two lists of variables that runs in linear time? The variables may appear in any determined order. No implementation dependent property like the "age" of variables must…
false
  • 10,264
  • 13
  • 101
  • 209
6
votes
3 answers

Will using member within a forall clause in SWI-Prolog always output the elements in the same order?

Having recently got into Prolog I've been using it for a few simple tasks and began to wonder about using member within forall loops like the one in the trivial example below: forall(member(A,[1,2,3,4]), print(A)). In the case that you do something…
Jonathan Rainer
  • 144
  • 1
  • 14
6
votes
2 answers

What does a clause without a head mean in prolog?

In the beginning of a Prolog program I see: :-dynamic(path/1). It seems to be a clause that doesn't have a head. What does it mean?
hpn
  • 2,222
  • 2
  • 16
  • 23
6
votes
1 answer

DCG Expansion: Is Steadfastness ignored?

Assume I have the following DCG rule: factor(X) --> "(", expr(X), ")". Normally this would be translated to: factor(X, A, B) :- [40|C] = A, expr(X, C, D), [41|B] = D. Would a Prolog system be allowed to translate it as follows, i.e. to merge…
user502187
6
votes
2 answers

Legitimate uses of (\+)//1

In grammar rules (dcg), there are several predefined constructs: (',')//2 meaning concatenation, ('|')//2 meaning alternation etc. One construct which is supported by several but not all Prolog systems is (\+)//1. Personally, I have used it only for…
false
  • 10,264
  • 13
  • 101
  • 209
6
votes
3 answers

Extension to CFG, what is it?

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,…
false
  • 10,264
  • 13
  • 101
  • 209
6
votes
5 answers

How to find string length using prolog

I have got a method length(list,var) which gives me the length of a list but i want to find the length of a String, anyone with a solution ?
Rishabh
  • 3,752
  • 4
  • 47
  • 74
1 2
3
9 10