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
76
votes
10 answers

'if' in prolog?

Is there a way to do an if in prolog, e.g. if a variable is 0, then to do some actions (write text to the terminal). An else isn't even needed, but I can't find any documentation of if.
jreid9001
  • 1,207
  • 2
  • 10
  • 8
57
votes
2 answers

What is the difference between ' and " in Prolog?

I am new to Prolog and noticed that ' and " give different behavior, but am curious as to why. Specifically, when loading a file, ?- ['test1.pl']. works, while ?- ["test1.pl"]. doesn't.
astay13
  • 6,857
  • 10
  • 41
  • 56
57
votes
4 answers

Rearranging variable_names

How to write in a standard conforming manner avs_term_rearranged(AVs, T, AVsR) with given AVs and T such that AVsR is a permutation of AVs with the elements arranged in same order as their variables occur in left-to-right order in T. AVs is a list…
false
  • 10,264
  • 13
  • 101
  • 209
38
votes
5 answers

Unification with STO detection

In ISO Prolog unification is defined only for those cases that are NSTO (not subject to occurs-check). The idea behind is to cover those cases of unifications that are mostly used in programs and that are actually supported by all Prolog systems.…
false
  • 10,264
  • 13
  • 101
  • 209
35
votes
2 answers

Prolog: Clauses are not together in source-file

I have this piece of code: % Family tree female(pen). male(tom). male(bob). female(liz). female(pat). female(ann). male(jim). parent(pam, bob). parent(tom, bob). parent(tom, liz). parent(bob, ann). parent(bob, pat). parent(pat, jim). I get this…
intelis
  • 7,829
  • 14
  • 58
  • 102
33
votes
8 answers

How to define (and name) the corresponding safe term comparison predicates in ISO Prolog?

Standard term order (ISO/IEC 13211-1 7.2 Term order) is defined over all terms — including variables. While there are good uses for this — think of the implementation of setof/3, this makes many otherwise clean and logical uses of the built-ins in…
false
  • 10,264
  • 13
  • 101
  • 209
26
votes
3 answers

Prolog - unusual cons syntax for lists

I have come across an unfamiliar bit of Prolog syntax in Lee Naish's paper Higher-order logic programming in Prolog. Here is the first code sample from the paper: % insertion sort (simple version) isort([], []). isort(A.As, Bs) :- isort(As,…
Nick Knowlson
  • 7,185
  • 6
  • 47
  • 63
21
votes
2 answers

Safer type tests in Prolog

ISO-Prolog (ISO/IEC 13211-1:1995 including Cor.1:2007, Cor.2:2012) offers the following built-in predicates for testing the type of a term: 8.3 Type testing 1 var/1. 2 atom/1. 3 integer/1. 4 float/1. 5 atomic/1. 6 compound/1. 7 nonvar/1.…
false
  • 10,264
  • 13
  • 101
  • 209
18
votes
4 answers

Equality of two lists of variables

How to define a meta-logical predicate that tests (thus succeeds or fails only) if two lists of unique variables contain exactly the same variables using the built-ins from the current ISO standard (ISO/IEC 13211-1:1995 including Cor.2). Stated…
false
  • 10,264
  • 13
  • 101
  • 209
17
votes
2 answers

Union of two variable sets

Given two lists of variables, what is the most compact and canonical way in ISO Prolog to determine the union of both? That is, we want a definition for the (meta-logical) predicates varset_union(VarSet1, VarSet2, Union) and for a list of…
false
  • 10,264
  • 13
  • 101
  • 209
17
votes
6 answers

Variable occurrence in a list of variables

Consider a (meta-logical) predicate var_in_vars(Var, Vars) which takes a variable Var and a list of variables Vars and succeeds if Var occurs in Vars. So we do not need to ensure that Var is a variable, nor that Vars is a list of variables. What is…
false
  • 10,264
  • 13
  • 101
  • 209
17
votes
1 answer

Prolog systems in Javascript

Javascript seems to become popular as an implementation language for other programming languages. The article Lightweight compilation of (C)LP to JavaScript. ICLP 2012 drew my attention on this. There are a lot of proof-of-concept prototypes for…
false
  • 10,264
  • 13
  • 101
  • 209
16
votes
3 answers

sort/2, keysort/2 vs. samsort/3, predsort/3

ISO-Prolog provides sort/2 and keysort/2 which relies on term order (7.2) often called "standard term order". The common way to sort a list with a different order is to map each element El of that list somehow to a list of pairs XKey-El and then…
false
  • 10,264
  • 13
  • 101
  • 209
14
votes
2 answers

Why are round brackets not needed for atoms that are high priority operators?

In older textbooks1 one frequently encounters operator declarations like the following: ?- op(1200,fx,(:-)). ^ ^ These round brackets used to be necessary. But today, they are no longer needed: | ?- writeq(op(1200,fx,(:-))). …
false
  • 10,264
  • 13
  • 101
  • 209
14
votes
3 answers

Meaning of instantiation mode indicators in arguments of Prolog predicates

Looking at Prolog documentation, predicate signatures are sometimes written as following: foo(:Bar, +Baz, -Qux, ?Mop) What are :, +, - and ? for and how do I interpret them? Also, are these the only ones that exist or are there more of them?
user797257
1
2 3
9 10