Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

About DCG ,CLP written in ISO-Prolog

493 views
Skip to first unread message

ken...@gmail.com

unread,
May 19, 2018, 5:14:54 AM5/19/18
to
Hello

Please tell me.
Is there a DCG, CLP code written within the ISO-Prolog standard?

Kenichi Sasagawa

burs...@gmail.com

unread,
May 19, 2018, 5:48:51 AM5/19/18
to
For DCG you need expansion hooks etc... Not
covered by the ISO core standard.

There is a DCG draft although, see here:
N267 DCG WDTR 2015-11-10.
https://www.complang.tuwien.ac.at/ulrich/iso-prolog/doclist

For CLP you need attribute variables etc... Not
covered by the ISO core standard. For type 1 or 2
attribute variables you need a module system...
Not covered by the ISO core standard.

For modules there is a separate ISO standard,
which gives some hints about modules. But I guess
the Quintus, SWI-Prolog path (and if you would
like local modules Jekejeke) is more relevant.

Just yesterday I did a lot of fixes and improvements
for local modules, since I was retesting them in
hierarchical knowledge bases. So far they work also
for hierarchical knowledge bases.

But I have premiered yesterday some test cases
that for the first time use local modules, just to
have quickly a module taxomony and that I can test
the new predicates
- sys_subclass_of/2
- sys_get_module/2
- sys_instance_of/2

This is to use ordinary module system in an object
oriented way with a (::)/2 operator, so that no
Logtalk rewriting is used. The trick is to use
the reexport/1 directive for module taxonomies.

Here is some new test cases:
https://github.com/jburse/jekejeke-samples/blob/master/jekdev/compfreq/system/proxy.p

The other test files have also to do with module
system, and especially with the module notation.
Besides local modules there is a further extra like
array notation, because I am using modules

also to address Java classe. So you can for example
by 'String' address the ordinary Java class
'java.lang.String', and by {int} the array Java class
'int[]'. For this new module notation test cases I
made a post on Google+ already a few days ago:

Here is a post about beginning testing modules:
https://plus.google.com/+JekejekeCh/posts/FE3a8C12W24

burs...@gmail.com

unread,
May 19, 2018, 6:17:52 AM5/19/18
to
Attribute variables are nice for the CLP(X)
scheme of programming. But possibly there are
also totally different approaches around. You
might consider type 1 and type 2 attribute variables.

There was heavy discussion about type 1 and type
2 attribute variables here on comp.lang.prolog
last year, and ECLiPSe Prolog did also a rework
of their libraries.

Maybe you can do type 1 and type 2 attribute
variables without modules or with a very simple
module system. Just in case you are currious how
I did my module system, it happens that since

yesterday I made also open source some of the
native implemented code that does the module search.
The module search is allowed to be expensive, since
it is anyway polymorphic inline cache. So thats why

I permitted the luxury of local modules. They give
rise to an additional search path along the parent
relationshipt between an inner module and an outer module.
But for a simple module system you might not need it.

Open Source: Predicate Search, Local Model Parent Search
https://github.com/jburse/jekejeke-devel/blob/master/jekrun/headless/jekpro/model/molec/CachePredicate.java#L437

But I consider everything prototypical. There are
a lot of complications, not only the upcoming
hierarchical knowledge bases, but also the already
existing multi-threading. So you find some mutex locking

here and then, which might change in the future...

burs...@gmail.com

unread,
May 19, 2018, 6:22:00 AM5/19/18
to
Last remark: There are also infinite ways to further
improve the module system. Like detecting ambigious
imports and showing a warning or an error.

SWI-Prolog or other Prolog systems, or existing
programming languages such as Java, etc... are
actually better in this respect sometimes...

More warnings and errors can mean a more helpful
programming environment and less brittle code.

ken...@gmail.com

unread,
May 19, 2018, 7:23:34 AM5/19/18
to
Thank you very much.

Kenichi Sasagawa

burs...@gmail.com

unread,
May 19, 2018, 5:31:51 PM5/19/18
to
A good start for CLP could be the implementation of
a freeze/2 predicate. This is usually done by a Type 1
API. I made a short note on what is going on here:

Prolog delayed evaluation: LIFO or FIFO wake-up?
https://stackoverflow.com/questions/35120332/prolog-delayed-evaluation-lifo-or-fifo-wake-up/50429621#50429621

Unfortuntely I don't have a source code of a freeze/2
predicate that really uses the usual Type 1 API,
since my Type 1 API came later. This is the Type 1 API:

Type 1 API, needs modules
http://www.jekejeke.ch/idatab/doclet/blog/en/docs/15_min/02_reference/term/unify.html

What I did, before I had Type 1 API and modules, I
implemented it without module callbacks in a much
lower level API. The result is seen here:

freeze/2 lowly implemented
http://www.jekejeke.ch/idatab/doclet/blog/en/docs/15_min/02_reference/term/suspend.html

Peter Ludemann

unread,
May 19, 2018, 7:38:27 PM5/19/18
to
Here is a Prolog implementation of extended DCGs, which works nicely for SWI-Prolog:
https://github.com/mndrix/edcg

Here is a simple CLP implementation, using attributed variables:
http://www.swi-prolog.org/pldoc/man?section=attvar

(freeze/2 can be implemented using attributed variables)

burs...@gmail.com

unread,
May 19, 2018, 8:20:23 PM5/19/18
to
Yes, thats the Type 1 API Post-Unify (SWI-Prolog section
attvar). But let me reiterate a nifty detail. Its all
module based, you can see this in the API signature:

put_attr(+Var, +Module, +Value)
get_attr(+Var, +Module, -Value)
Etc..

So what do you do if your Prolog system doesn't have
modules? How do you implement attribute variables
without modules? Well its possible, but the attvar

API will look slighly different. If I look here:

O-Prolog - Kenichi Sasagawa
http://eisl.kan-be.com/library/oprolog1.html

I don't see yet modules.

burs...@gmail.com

unread,
May 19, 2018, 8:32:28 PM5/19/18
to
Historically the attvar API was such that
the module was not an explizit parameter.
So basically the calls were:

put_attr(+Var, +Value)
get_attr(+Var, -Value)
Etc..

And the module needed an attribute variable
declaration. You find this still in ECLiPSe
Prolog. See for example here:

add_attribute(Var, Attr).
http://www.eclipseclp.org/doc/userman/umsroot099.html

The attribute variable declaration was there
so that the compiler could determine some layout
for the attribute variable, ids for the keys, etc..

Only this paper permitted a rethinking:

Dynamic attributes, their hProlog implementation,
and a first evaluation - Bart Demoen
Report CW 350, October 2002
https://pdfs.semanticscholar.org/3104/a69b2ed0bc58d67678c6b91eb3d864fe1de2.pdf

ken...@gmail.com

unread,
May 19, 2018, 8:40:04 PM5/19/18
to

ken...@gmail.com

unread,
May 19, 2018, 8:55:34 PM5/19/18
to
I am currently implementing modules
with ISO-Prolog compatibility.

kenichi Sasagawa
-----
:- module(my_list_stuff).
:- export([last/2,my_reverse/2]).

:- begin_module(my_list_stuff).

last([E],E).
last([_|E],Last) :- last(E,Last).

my_reverse(List1,List2) :- reverse_aux(List1,[],List2).

reverse_aux([H|T],Stack,Result) :-
reverse_aux(T,[H|Stack],Result).
reverse_aux([],Result,Result).

:- end_module.

O-Prolog Ver0.85
| ?- consult('module.pl').
yes
| ?- last([1,2,3],X).
X = 3
yes
| ?- my_reverse([1,2,3],X).
X = [3,2,1]
yes
-------------

Ulrich Neumerkel

unread,
May 20, 2018, 4:33:44 AM5/20/18
to
For DCGs, there is a working draft N267.

For CLP, there is no standard. However, you can add such as an
implementation specific feature. Good examples for CLP-implementations
that fit into ISO are library(clfd) and library(clpz) of SICStus and SWI.
Most notable is the precise way of error handling.

If you consider to add attributed variables to your system, rather stick
to the way this is done in SICStus and not in SWI. There are a lot
of very fine details that are very easy to miss in the beginning.

burs...@gmail.com

unread,
May 20, 2018, 6:03:37 AM5/20/18
to
The modern way would be without
begin_module/end_module, see also:

http://www.swi-prolog.org/pldoc/man?section=defmodule

ken...@gmail.com

unread,
May 20, 2018, 7:39:42 PM5/20/18
to
Thank you, Mr. Nuemerkel.

In the first step I will implement a modular system
that is faithful to ISO-Prolog.
I am currently trying to link image recognition
by AI chip with Prolog.
The ISO-Prolog function is sufficiently useful for this goal.
I will extend a little bit.

burs...@gmail.com

unread,
May 21, 2018, 8:03:41 AM5/21/18
to
Ulrich Neumerkel wrote:
"Most notable is the precise way of error handling."

Doesn't this error handling impede a CLP(FD) to
CLP(B) translation. Lets say if you would add the
same error handling to a CLP(B) solver?

I am not sure. But how would you do a "safe"
CLP(FD) to CLP(B) translation. Is this even
possible? All your "safety" assumes

that what is given in the code at compile time,
is also what is given at runtime. But for a
translator code this not the case.

For example I translate (#=)/2 simply as follows:

X #= Y :-
bitexpr(X, A),
bitexpr(Y, B),
biteq(A, B, T),
sat(T).

https://gist.github.com/jburse/3e081f01c7de5c725e8b94e4e8f14e76#file-finsat-p-L109

Neither X,Y nor T are given at compile time.
What "safety" would you apply, where, how
and why?

burs...@gmail.com

unread,
May 21, 2018, 8:08:05 AM5/21/18
to
On the other hand this error handling,
like here, for a CLP(B), is pretty standard,
every system should be able to do that:

?- sat(X+Y), X=a+b.
Error: Argument should be boolean value, found a+b.
= /2

I only allow this "glitch", namely that
the solver can forget, that it wants a
boolean variable.

?- sat(X=:=X), X=a+b.
X = a+b

burs...@gmail.com

unread,
May 21, 2018, 8:17:30 AM5/21/18
to
SWI-Prolog allows a+b, since it also allows
atoms as (boolean) variables. But it disallows f(a,b),
since it doesn't now about a function f.

?- sat(X+Y), X=a+b.
X = a+b,
sat(Y=\=Y*a#Y*a*b#Y*b#a#a*b#b).

?- sat(X+Y), X=f(a,b).
ERROR: Domain error: `clpb_expr' expected, found `f(a,b)'

?- sat(X=:=X), X=f(a,b).
ERROR: Domain error: `clpb_expr' expected, found `f(a,b)'

But allowing X=a+b, and instantiating the variable
X by the expression a+b is interesting. I dunno
yet what the semantics should be.

But unfortunately this feature is not monotonic,
and I guess it might be barred in the future, if
Ulrich Neumerkel would lay hand on CLP(B) and

?- X=a+(~a), sat(X).
X = a+ ~a.

?- sat(X), X=a+(~a).
false.

add "Most notable is the precise way of error
handling." also to CLP(B)...

Ulrich Neumerkel

unread,
May 21, 2018, 10:40:34 AM5/21/18
to
burs...@gmail.com writes:
>But unfortunately this feature is not monotonic,
>and I guess it might be barred in the future, ...

Recommended reading: CLP(B)'s documentation:

Set the flag `clpb_monotonic` to `true` to make CLP(B) *monotonic*. If
this mode is enabled, then you must wrap CLP(B) variables with the
functor `v/1`.

burs...@gmail.com

unread,
May 21, 2018, 11:02:04 AM5/21/18
to
Ha Ha, you must be joking.

But this flag is complete nonsense. You have
to rewrite your code then. Like for example
the CLP(FD) to CLP(B) translator

I just made. It will not anymore work I guess.
That was my fear that your "Most notable is
the precise way of error handling." breaks

code. I see for example:

?- sat(X=:=Y).
X = Y,
sat(Y=:=Y).

?- set_prolog_flag(clpb_monotonic, true).
true.

?- sat(X=:=Y).
ERROR: Arguments are not sufficiently instantiated

?- sat(v(X)=:=v(Y)).
X = Y,
sat(Y=:=Y).

But for this more common error, you only
need to do something less drastic. Namely
you need only to make a check in

the unify hook. So to throw an error message
here, in this situation, only a tiny
check in the unify hook is needed:

?- sat(X), X=a+(~a).
false. /* you only need to a add small check in the
unify hook of the CLP(B) library, you don't
need to break existing code by a flag */

burs...@gmail.com

unread,
May 21, 2018, 11:38:22 AM5/21/18
to
Corr.: my bad, the example sat(X), X=a+(~a) is
a helpless case, since without the flag we get
X=1. What I mean is the following:

?- sat(X+Y), X=a+b.
X = a+b, /* you only need to a add small check in the
unify hook of the CLP(B) library, you don't
need to break existing code by a flag */
sat(Y=\=Y*a#Y*a*b#Y*b#a#a*b#b).

But I am also now exploring your v(X). It
changes the situation for the a+(~a). I now
get with the flag the following results:

?- set_prolog_flag(clpb_monotonic, true).
true.

?- X=a+(~a), sat(X).
X = a+ ~a.

?- sat(X), X=a+(~a).
ERROR: Arguments are not sufficiently instantiated

?- sat(X).
ERROR: Arguments are not sufficiently instantiated

So basically the error happens much earlier.
Since variables are not anymore allowed to
be denoted by variables itself.

But unfortunately this breaks existing code,
and existing examples.

burs...@gmail.com

unread,
May 21, 2018, 2:12:42 PM5/21/18
to
Sometimes its also useful to have frozen variables,
to implement solvers. Not to be confused with freeze/2,
which delays a goal.

I don't know how this could be done by other means,
than a set of special builtins. Maybe some other
"Non-logical operations on terms" can archive the same.

You find frozen variables in Qu-Prolog:

"When a variable is frozen, it cannot be instantiated.
Rewrite rules can be controlled by freezing the
variables in the term to be simplified. This implements
one-sided unification."
http://staff.itee.uq.edu.au/pjr/HomePages/QPFiles/main.pdf

And you find frozen variables in Racklog:

The goal (%freeze S F) unifies with F a new frozen
version of the structure in S. Freezing implies that
all the unbound variables are preserved. F can henceforth
be used as bound object with no fear of its variables
getting bound by unification.
http://docs.racket-lang.org/racklog/glossary.html#%28def._%28%28lib._racklog%2Fmain..rkt%29._~25freeze%29%29

I am currently researching whether frozen variables
can replace the variable indexes in BDD trees, to
make a different SAT solver. Currently I am using
integers and not yet frozen variables,

since frozen variables currently cause a new cell
on the stack I am avoiding them. But if the attributed
variable remembers the associated cell on the stack, a
lot of cells could be spared and something maybe

superior to integer indexes could be craated. Ongoing
investigation in connection with a new
call_residue_vars/2 for the SAT solver ...

Am Samstag, 19. Mai 2018 11:14:54 UTC+2 schrieb ken...@gmail.com:

burs...@gmail.com

unread,
May 21, 2018, 2:22:11 PM5/21/18
to
Disclaimer: Not sure whether Qu-Prolog and racklog
share the same semantics. Also my own lib of frozen
variables is currently a little different, more simpler.
The following is interesting, but I cannot do it,

there are other intentions, from Qu-Prolog docu:

one_sided_unify(T1, T2) :-
freeze_term(T1, FrozenVars),
T1 = T2,
thaw_term(FrozenVars).

My intentions in my lib are different, that my own
builtins do not intend to change the given term and
change all variables in the term. My lib only returns
an opaque handle to the given term(*).

There are also some applications areas of such handles,
but I guess one sided unification is not...

(*) Thats why I should rename the builtins to
wrap_*/* and unwrap_*/*.

Ulrich Neumerkel

unread,
May 22, 2018, 4:09:25 AM5/22/18
to
ken...@gmail.com writes:
>In the first step I will implement a modular system
>that is faithful to ISO-Prolog.

Do you intend to implement an ISO conforming system?
At least for syntax there are many things open. Like

http://www.complang.tuwien.ac.at/ulrich/iso-prolog/conformity_testing#1

O-Prolog Ver0.80
| ?- writeq('\n').
'
'yes
|

ken...@gmail.com

unread,
May 22, 2018, 5:42:11 AM5/22/18
to
I will refer to it.

Thank you very much.

Kenichi Sasagawa

burs...@gmail.com

unread,
May 22, 2018, 6:25:39 AM5/22/18
to
There are many dead Prolog systems now. Lets
call a Prolog system dead if it didn't have
an update in the last 24 months.

Then these systems are all dead or historical:

Ciao Prolog:
CiaoDE 1.15-1781-g328b907 (released on 2013-06-12 16:45:13 +0200)

B-Prolog:
Feb. 23, 2014, Version 8.1

GNU Prolog:
Fri Apr 12 17:17:50 CEST 2013

IF Prolog
Java Interface is from 2001

YAP Prolog
Latest commit SourceForge 2016-02-11

Minerva
HTTP Status 404

IV
PrologIA ne sont plus maintenus

But why do conformity test with already dead
Prolog systems? The only alive Prolog systems

on your list seem to be:
- SWI-Prolog
- ECLiPSe Prolog
- SICStus
- XSB.

What does it buy you testing these historical
Prolog systems. Some insight? What insight is

needed, you test anyway against the ISO core standard.

burs...@gmail.com

unread,
May 22, 2018, 6:27:42 AM5/22/18
to
I guess B-Prolog is discontinued since they
are working on Picat now.

burs...@gmail.com

unread,
May 22, 2018, 6:35:30 AM5/22/18
to
Should invent a "ping" page, showing which Prolog
systems are still alive and which arent.

Also the comp.lang.prolog monthly Forum post is
full of dead Prolog systems.

What do we know of the conformance of these systems:
- Strawberry Prolog
- CxProlog
- JIProlog
- LeanProlog
- Qu-Prolog

Except for Strawberry Prolog, they appear on
the Logtalk list. So they are probably more or
less Prolog systems.

https://logtalk.org/compatibility.html

burs...@gmail.com

unread,
May 22, 2018, 6:38:42 AM5/22/18
to
But also these Prolog systems are dead, by my
24 month criteria, Strawberry Prolog and LeanProlog.

Ulrich Neumerkel

unread,
May 22, 2018, 1:54:53 PM5/22/18
to
burs...@gmail.com writes:
>But why do conformity test with already dead
>Prolog systems?
...
>
>What does it buy you testing these historical
>Prolog systems. Some insight? What insight is
>needed, you test anyway against the ISO core standard.
>
>Am Dienstag, 22. Mai 2018 10:09:25 UTC+2 schrieb Ulrich Neumerkel:
...
>> http://www.complang.tuwien.ac.at/ulrich/iso-prolog/conformity_testing#1

Systems listed on this comparison have been (self-) declared as conforming.
Therefore, code was written for such systems that was considered to be
conforming.

Additionally systems are added that have developers that participate or
participated in WG17 when preparing Cor.2 and expressed the intention
to become conforming.

When issuing a corrigendum one has to take such systems into account.

burs...@gmail.com

unread,
May 22, 2018, 3:41:22 PM5/22/18
to
There are many more Prolog systems that declare themselves
ISO conforming. At least many Prolog systems that mention
ISO in some way or the other.

For example JIProlog (which was on the Logtalk page), has
a Wikipedia article that says (dislaimer I did only
an arbirary pick):

"JIProlog is full ISO Prolog compliant"
https://en.wikipedia.org/wiki/JIProlog

How can this more easily be monitored. I think you already
publish your test suite, I remember some posts some
months ago.

Here are some suggestions:
- Decide upon a copyright license, and add it to
your conformity suite.
- Upload the conformity suite including harness
to GitHub, sourceforge or BitBuket, etc...
- Add a GitHub or sourceforge link on this page here:
http://www.complang.tuwien.ac.at/ulrich/iso-prolog/conformity_testing#1

I am pretty sure more Prolog systems will test themselves.

And I guess there will be no harm to your intellectual
property, if you think about a copyright license first,
and add it everywhere to your conformity suite and harness.

Or is there already a GitHub, sourceforge
or BitBuket link somewhere? A self test is nice,
for example ECLiPSe did:

http://eclipseclp.org/Specs/Rel70/table_iso_spec_iso_strict.html

But scrapping the test cases from your web site
is annoying. Why is this like a hidden secret, and
not provided as Prolog code?

Am I missing something?

burs...@gmail.com

unread,
May 22, 2018, 3:55:24 PM5/22/18
to
Problem is, even if somebody scraps the test cases
from your web site. Every time you change it or
extend it, he has to scrap again.

So what would be easier, would be a Prolog primary
single source. I guess you also generate the table
automatically from some Prolog facts, and

running your tests. So if these Prolog facts
that represent the tests would be available,
this could safe a lot of work,

and nowadays pushing content to GitHub etc.. is
very easy. Well I guess it can be scrapped with
XML and/or XPath and/or XSL.

Scraping it just like that from the browser
gives the following, but I guess it needs
encoding to turn it into Prolog facts:

1 writeq('\n').
2 '
3 )
261 )
'
4 .
5 writeq(' '). % horiz. tab
177 0'\t=0' . % horiz. tab
6 writeq('
').
7 writeq('\
'). % "\\\n"
8 writeq('\
a'). % "\\\na"
9 writeq('a\
b'). % "a\\\nb"
10 writeq('a\
b'). % "a\\\n b"
11 writeq('\ ').
193 writeq('\
'). % "\\ \n"
12 writeq('\ '). % "\\\t"
13 writeq('\t').
14 writeq('\a').
15 writeq('\7\').
16 writeq('\ca').
241 writeq('\d').
17 writeq('\e').
18 writeq('\033\').
19 char_code('\e',C).
21 char_code('\d',C).
22 writeq('\u1').
23 X = 0'\u1.
24 writeq('
25 writeq(.
26 '\
''.
210 X = 0'\.
211 X = 0'\. .
222 writeq((-)-(-)).
223 writeq(((:-):-(:-))).
27 writeq((*)=(*)).
28 writeq([:-,-]).
29 writeq(f(*)).
30 writeq(a*(b+c)).
31 writeq(f(;,'|',';;')).
32 writeq([.,.(.,.,.)]).
33 writeq((a :- b,c)).
34 write_canonical([a]).
35 writeq('/*').
203 writeq(//*).
282 writeq(//*.*/).
36 writeq('/**').
37 writeq('*/').
38 "\'\`\"" = "'`""". % "
179 "\'\"" = "'""". % "
178 "\`" = "`".
39 '\'\`\"' = '''`"'.
40 writeq('\'\`\"\"').
41 ('\\') = (\).
42 op(1,xf,xf1).
1xf1 = xf1(1).
43 X = 0X1.
44 float(.0).
45 op(100,xfx,.).
functor(3 .2,F,A).
46 float(- .0).
47 float(1E9).
48 integer(1e).
49 op(9,xf,e9).
1e9 = e9(1).
50 op(9,xf,e).
1e-9 = -(e(1),9).
51 /**/ 1.0e- 9 = -(e(1.0),9).
204 /**/ writeq(1e).
220 /**/ writeq(1.0e).
52 op(9,xfy,e).
1.2e 3 = e(X,Y).
53 writeq(1.0e100).
54 float(1.0ee9).
286 (- (1)) = -(1).
287 (- -1) = -(-1).
288 (- 1^2) = ^(-1,2).
56 integer(- 1).
57 integer('-'1).
58 integer('-' 1).
59 integer(- /*.*/1).
60 integer(-/*.*/1).
61 integer('-'/*.*/1).
62 atom(-/*.*/-).
63 op(0,fy,-).
180 /**/ integer(-1).
64 /**/ integer(- 1).
135 writeq(-(1)).
136 op(0,fy,-),writeq(-(1)).
182 writeq(-(-1)).
183 writeq(-(1^2)).
260 writeq(-(a^2)).
139 writeq(-((a,b))).
218 writeq(-(1*2)).
140 writeq(-a).
184 writeq(-(-)).
185 writeq(-[-]).
188 writeq(-p(c)).
189 writeq(-{}).
190 writeq(-{a}).
191 writeq(-(-a)).
192 writeq(-(-(-a))).
216 writeq(-(-(1))).
215 op(100,yfx,~).
writeq(-(1~2~3)).
248 /**/ writeq(- (1~2)).
249 /**/ writeq(1~2).
278 op(9,xfy,.), writeq(-[1]).
279 op(9,xf,'$VAR'), writeq(- '$VAR'(0)).
55 op(1,yf,yf1).
{-1 yf1}={yf1(X)}.
65 compound(+1).
66 compound(+ 1).
277 writeq(+1^2).
257 writeq([+{a},+[]]).
67 op(0,fy,+).
compound(+1).
68 [(:-)|(:-)]=[:-|:-].
69 X=[a|b,c].
70 op(1000,xfy,',').
71 op(1001,xfy,',').
72 op(999,xfy,'|').
73 /**/ X=[a|b].
285 /**/ X=[(a|b)].
219 /**/ [a|[]]=[a].
74 /**/ X=[a|b|c].
75 var(a:-b).
76 :- = :- .
77 - = - .
78 * = * .
79 current_op(200,fy,-).
80 current_op(200,fy,+).
81 {- - c}={-(-(c))}.
82 (- -) = -(-).
83 (- - -) = -(-(-)).
84 (- - - -) = -(-(-(-))).
85 {:- :- c} = {:-(:-,c)}.
86 {- = - 1}={(-(=)) - 1}.
87 write_canonical((- = - 1)).
88 write_canonical((- = -1)).
89 write_canonical((-;)).
90 write_canonical((-;-)).
91 write_canonical((:-;-)).
92 [:- -c] = [(:- -c)].
93 writeq([a,b|,]).
94 X ={,}.
95 {1} = {}(1).
96 write_canonical({1}).
97 '[]'(1) = [ ](X).
98 X = [] (1).
99 op(100,yfy,op).
100 '''' = '\''.
101 a = '\141\'.
102 a = '\141'.
103 X = '\141\141'.
104 X = '\9'.
105 X = '\N'.
106 X = '\\' .
107 X = '\77777777777\'.
108 a = '\x61\'.
109 atom_codes('\xG\',Cs).
110 atom_codes('\xG1\',Cs).
111 atom(`).
112 atom(`+).
113 X = `a`.
114 integer(0'\').
115 integer(0''').
116 0''' = 0'\'.
117 integer(0'').
195 op(100,xf,'').
205 /**/ (0 '') = ''(X).
196 /**/ writeq(0 '').
197 /**/ writeq(0'').
118 op(100,xfx,'').
119 /**/ functor(0 ''1, F, A).
120 /**/ functor(0''1, F, A).
206 op(100,xf,f).
writeq(0'f').
207 /**/ writeq(0'f'f').
209 /**/ writeq(0'ff).
256 /**/ writeq(0f).
208 op(100,xf,'f ').
writeq(0 'f ').
121 X = 2'1.
122 op(100,xfx,'1').
functor(2'1'y, F, A).
262 /**/ functor(2 '1'y, F, A).
123 X =0'\x41\ .
124 X =0'\x41\.
125 X =0'\x1\.
127 X is 16'mod'2.
128 X is 37'mod'2.
129 X is 0'mod'1.
130 X is 1'+'1.
212 X is 1'\
+'1.
213 X is 0'\
+'1.
259 X = 0'\
+'/*'. %*/1.
214 X is 0'\
126 X = 0'\
.\
131 op(100,fx,' op').
132 /**/ writeq(' op' '1').
133 /**/ writeq(' op'[]).
134 op(1,xf,xf1).
writeq({- =xf1}).
137 writeq(- (a*b)).
138 writeq(\ (a*b)).
141 current_op(P,xfy,.).
142 op(100,xfy,.).
143 /**/ writeq(1 .2).
144 /**/ writeq([1]).
283 /**/ writeq(-[1]).
221 /**/ X = 1.e.
258 /**/ writeq(ok).%
1 = X.
145 write_canonical('$VAR'(0)).
146 write_term('$VAR'(0),[]).
244 writeq('$VAR'(0)).
245 writeq('$VAR'(-1)).
246 writeq('$VAR'(-2)).
247 writeq('$VAR'(x)).
289 writeq('$VAR'('A')).
147 op(9,fy,fy),op(9,yf,yf).
write_canonical(fy 1 yf).
148 /**/ write_canonical(fy yf).
149 /**/ writeq(fy(yf(1))).
150 /**/ writeq(yf(fy(1))).
151 op(9,fy,fy),op(9,yfx,yfx).
write_canonical(fy 1 yfx 2).
152 /**/ writeq(fy(yfx(1,2))).
153 /**/ writeq(yfx(fy(1),2)).
154 op(9,yf,yf),op(9,xfy,xfy).
write_canonical(1 xfy 2 yf).
155 /**/ writeq(xfy(1,yf(2))).
156 /**/ writeq(yf(xfy(1,2))).
157 op(0,xfy,:-).
current_op(P,xfx,:-).
158 op(0,xfy,',').
159 op(9,fy,f),op(9,yf,f).
write_canonical(f f 0).
201 /**/ writeq(f(f(0))).
202 /**/ write_canonical(f 0 f).
160 /**/ write_canonical(0 f f).
161 /**/ write_canonical(f f).
162 op(9,fy,p),op(9,yfx,p).
write_canonical(1 p p p 2).
163 op(9,fy,p),op(9,xfy,p).
write_canonical(1 p p p 2).
164 op(7,fy,p),op(9,yfx,p).
write_canonical(1 p p p 2).
165 atom('.''-''.').
166 op(0,xfy,'|').
167 /**/ writeq((a|b)).
168 op(0,xfy,.),op(9,yf,.).
169 /**/ writeq(.(.)).
194 op(0,xfy,.),writeq((.)+(.)).
170 set_prolog_flag(
double_quotes,chars).
171 /**/ writeq("a").
229 /**/ writeq("\z").
172 X is 10.0** -323, writeq(X).
173 1.0e-323=:=10.0** -323.
174 -1 = -0x1.
175 T = t(0b1,0o1,0x1).
176 X is 0b1mod 2.
217 op(1105,xfy,'|').
181 /**/ writeq((a-->b,c|d)).
290 /**/ writeq([(a|b)]).
186 X/* /*/=7.
187 X/*/*/=7.
198 atom($-).
199 atom(-$).
200 op(900, fy, [$]).
write_canonical($a+b).
224 \ .
225 char_code(C,0), writeq(C).
250 writeq('\0\').
226 write_canonical(_+_).
227 write_canonical(B+B).
228 writeq(0'\z).
230 char_code('\^',X).
231 writeq(0'\c).
232 writeq(0'\ ).
233 writeq(nop (1)).
234 op(400,fx,f).
writeq(f/*.*/(1,2)).
235 /**/ writeq(1 = f).
236 write_canonical(a- - -b).
237 op(699,xf,>).
238 /**/ writeq(>(>(a),b)).
239 /**/ write_canonical(a> >b).
242 /**/ write_canonical(a> =b).
243 /**/ write_canonical((a>,b)).
240 /**/ write_canonical(a>).
251 op(9,yfx,[bop,bo,b,op,xor]).
writeq(0bop 2).
263 /**/ writeq(0 bop 2).
252 /**/ writeq(0bo 2).
253 /**/ writeq(0b 2).
254 /**/ writeq(0op 2).
255 /**/ writeq(0xor 2).
264 writeq('^`').
265 op(9,yf,[b2,o8]).
266 /**/ writeq(0b2).
267 /**/ writeq(0o8).
268 op(500, xfy, {}).
269 writeq('\b\r\f\t\n').
270 get_char(C). %a
271 get_char(C).%a
272 writeq(0B1).
274 op(20,fx,--),writeq(--(a)).
275 /**/ op(0,fy,--),writeq(--(a)).
276 writeq(0xamod 2).
280 writeq(00'+'1).
281 writeq(00'a).
284 writeq('\^J').
291 Finis ().

But for testing, either use term_atom/2, or
with_input_from/2 and with_output_to/2, etc..
as a harness.

Ulrich Neumerkel

unread,
May 22, 2018, 4:10:42 PM5/22/18
to
burs...@gmail.com writes:
>There are many more Prolog systems that declare themselves
>ISO conforming. At least many Prolog systems that mention
>ISO in some way or the other.
>
>For example JIProlog (which was on the Logtalk page), has
>a Wikipedia article that says (dislaimer I did only
>an arbirary pick):
>
>"JIProlog is full ISO Prolog compliant"
>https://en.wikipedia.org/wiki/JIProlog

Please refer to "Deviation from the standard" on page

https://github.com/jiprolog/jiprolog/wiki/Standards-compliance

"In general, no type-checking is applied to output arguments..."

No need to continue. In any case, I just reported two cases I came across:

https://github.com/jiprolog/jiprolog/issues/6

You said "many more Prolog systems". Which one do you mean?

>...
>and add it everywhere to your conformity suite and harness.

The harness is the biggest problem. There are already tests by Peter Szeredi
using some harness. Only GNU & SICStus took these tests serious. One
reason is the complexity of adapting the harness.

On page http://www.complang.tuwien.ac.at/ulrich/iso-prolog/conformity_testing
you can just copy-paste a case into your system. No porting whatsoever.

>A self test is nice, for example ECLiPSe did:
>
>http://eclipseclp.org/Specs/Rel70/table_iso_spec_iso_strict.html

This self-test does not test the same. It provides EOF after each input text and
thus cannot test for waiting systems.

>But scrapping the test cases from your web site
>is annoying. Why is this like a hidden secret, and
>not provided as Prolog code?
>
>Am I missing something?

There is nothing hidden, my "source" is just this page that you can download.
In this manner versioning is trivial with RCS, and I distrust anything more
complex.


burs...@gmail.com

unread,
May 22, 2018, 4:13:57 PM5/22/18
to
Scrapping is also not feasible, since each of
your test does something else. Sometimes your read.
Sometimes you write.

So any time you change the list, you would need
to know the delta, and from this manually update
your test suite.

Its not extremly friendly to automatic scrapping.
On the other hand the scrapping result has not a lot
of demands. There are a lot of elaborate test

frameworks around, but the easiest is just executing
a goal, I have a couple of syntax test cases that
are directly derived from ISO/IEC-13211-1 what is

written in the standard, you find them here, for
example ISO core standard term reading and term
writing, they are very easy to understand:

https://github.com/jburse/jekejeke-samples/blob/master/jekdev/compliance/stream/read.p#L43

They just go:

runner:case(write, 1, stream_read, 'ISO 6.3.4.3, XLOG 1') :-
op(9, fy, fy),
op(9, yf, yf),
with_output_to(atom(X), write(yf(fy(1)))),
X == '(fy 1)yf'.

Etc.. Etc.. You see a reference to the ISO section, and
as promised each test case is just a goal, respectively
a conjunction of goals.

But I kept it short, there are only 35 test cases
in the section term reading and term writing,
not 350 test cases.... :-) :-(

Predikate Ok Nok
write/1 6 0
writeq/1 3 0
write_canonical/1 3 0
write_term/2 6 0
read/1 9 1
read_term/2 6 1
Total 33 2

http://www.jekejeke.ch/idatab/doclet/prod/en/docs/10_dev/15_stdy/07_compliance/09_results/05_stream/package.html?hash=read

Ulrich Neumerkel

unread,
May 22, 2018, 4:16:33 PM5/22/18
to
burs...@gmail.com writes:
>So what would be easier, would be a Prolog primary
>single source. I guess you also generate the table
>automatically from some Prolog facts, and
>running your tests. So if these Prolog facts
>that represent the tests would be available,
>this could safe a lot of work,
>and nowadays pushing content to GitHub etc.. is
>very easy. Well I guess it can be scrapped with
>XML and/or XPath and/or XSL.

You are suggesting using Prolog to store the data. That means,
that a conforming system is needed to read such facts. One more
link in the chain to break.

>Scraping it just like that from the browser...

Save the document as html!

burs...@gmail.com

unread,
May 22, 2018, 4:21:51 PM5/22/18
to
Dont tell me your conformance test suite cannot
be converted in a set of such goals. I take
this as a complete lie.

The problem can be that target systems do not
have predicates such as with_output_to, or
with_input_from.

But the last I did, was bootstrapping them
from memory streams and try_call_finally.
Its not perfect, but

even a primitive Prolog system should be
able to implement them. They are in a new
module library(charsio):

http://www.jekejeke.ch/idatab/doclet/blog/en/docs/10_dev/02_reference/system/charsio.html

ken...@gmail.com

unread,
May 25, 2018, 6:25:18 AM5/25/18
to
Please give me advice.

I am debugging O-Prolog.
Why is the syntax error for the next example?

#47
float(1E9).

> http://www.complang.tuwien.ac.at/ulrich/iso-prolog/conformity_testing#1
>

ken...@gmail.com

unread,
May 25, 2018, 6:49:14 AM5/25/18
to
I reread A.1.4(Numbers). And I understood.
I'm sorry.

Kenichi Sasagawa

Ulrich Neumerkel

unread,
May 25, 2018, 7:34:19 AM5/25/18
to
A.1.4? Not sure what you are referrin to.

The reason why 1E9 is not a valid token is because of

float number token (* 6.4.5 *)
= integer constant (* 6.4.4 *),
fraction (* 6.4.5 *),
[ exponent (* 6.4.5 *) ] ;

fraction (* 6.4.5 *)
= decimal point char (* 6.4.5 *),
decimal digit char (* 6.5.2 *),
{ decimal digit char (* 6.5.2 *) } ;

So a decimal point and a digit thereafter is always needed.

---

Actually, the reason is that 1E9 is tokenized as "1" "E9" which
in this sequence can never be part of valid Prolog text

ken...@gmail.com

unread,
May 25, 2018, 7:44:14 AM5/25/18
to
I refer to the following documents.
I can not get the latest documents now.

http://fsl.cs.illinois.edu/images/9/9c/PrologStandard.pdf

Ulrich Neumerkel

unread,
May 25, 2018, 7:58:43 AM5/25/18
to
Contrary to it's name, this is **not** the standard.
Its title reads:

ISO Prolog: A Summary of the Draft Proposed Standard

The actual standard is different in many respects.

You really need the actual standard.

Michael Ben Yosef

unread,
May 25, 2018, 8:38:54 AM5/25/18
to
Do you know why the final draft standard was never released for free, as is common practice for other programming language standards?

As you can probably agree, this has done immeasurable damage to the Prolog community, and not only because this outdated document, _ISO Prolog: A Summary of the Draft Proposed Standard_, is the closest thing people can find to a freely, legally available ISO/IEC 13211 document. I have noticed a lot of Prolog programmers don't know what's in the standard and what's not - you routinely see answers given on SO that are implementation dependent when they could easily have been expressed in strictly conforming ISO Prolog.

As another example, Tau Prolog still cites (http://tau-prolog.org/documentation) the above-mentioned document and J. P. E. Hodgson's old "bips.html" as references for ISO Prolog. I'm guessing they didn't even _know_ about TC1, TC2 and TC3 until you told them about these, if you have: they don't implement any of the new predicates from TC2 as built-ins.

burs...@gmail.com

unread,
May 25, 2018, 9:07:05 AM5/25/18
to
Michael A. Covington paper is not bad, for
example for newbie teaching. But its
clearly marked as

"Draft Proposed Standard",

means its somewhere at the beginning of the
life-cycle of an ISO document. On the other
hand the real standard is marked:

"First Edition 1995-06-01"

I find the life-cycle documented here:

https://www.iso.org/sites/directives/directives.html#toc_marker-20

Proposal stage seems to be very early. Even not
a working draft. I seems that it took 3 years
from the prosal stage to the publication stage.

The proposal stage says "then optionally a decimal
point". The publication stage made the decimal
point mandatory.

In as far the Tau Prolog practice makes no sense,
they write "Note that there is no reference
implementation for ISO Prolog, so we've used the

following documents as references:". And they
refer Covington, but yes, correctly Covington
is not some valid reference (for example the

decimal point problem). What is the problem with
Hodgson? Anybody spotted some differences
to the standard?

Ulrich Neumerkel

unread,
May 25, 2018, 9:25:36 AM5/25/18
to
Michael Ben Yosef <mby...@gmail.com> writes:
>On Friday, 25 May 2018 13:58:43 UTC+2, Ulrich Neumerkel wrote:
>> You really need the actual standard.
>
>Do you know why the final draft standard was never released for free, as
>is common practice for other programming language standards?

Are you sure? For C, I definitely do know that the FDIS is only
availabe to actual ISO members. For disbanded groups, some documents
are put into the open.

>As you can probably agree, this has done immeasurable damage to the
>Prolog community

No, I don't. People do not read documents. If they have to pay for
it, they are at least somewhat committed.

Or take the test suite by Peter Szeredi. Only two systems have used
it (SICStus and GNU) of which one (de facto) paid for its development.
This was completely free to all. The published results about other
systems were even ignored ...

Same is true for http://www.complang.tuwien.ac.at/ulrich/iso-prolog/conformity_testing
100% free. Still rarely used. Just look at the "recent improvements" line ....

Same is true for Koen DeBosschere's Prolog parser which is close to perfection
http://www.complang.tuwien.ac.at/ulrich/prolog.parser/PROLOG-PARSER-HEADER.html
and available since the publication of the standard. It has been actually
used by SPIDER (SICStus IDE), and one other system which managed to make
it non-conforming ...

>As another example, Tau Prolog still cites (http://tau-prolog.org/documentation)
>the above-mentioned document

At least, the title is now correct ...

>I'm guessing they didn't even _know_ about TC1, TC2 and TC3
>until you told them about these, ...

It's Cor.1, Cor.2, Cor.3. No, I did not. I am waiting what they say about
their committment to the standard.

burs...@gmail.com

unread,
May 25, 2018, 9:34:10 AM5/25/18
to
One of the bloopers of the ISO core standard
is the built-in current_predicate/1.
This predicate is usually not used as the
authors have intended, and has usually a

different semantics. In most Prolog systems
it covers system and user predicates,
and can be more generally test the existence
of a predicate. For example in SWI-Prolog

I can do:

Welcome to SWI-Prolog (threaded, 64 bits, version 7.7.14)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.

?- current_predicate(write/1).
true.

?- current_predicate(write/X).
X = 1 ;
X = 2 .

Why this diverging from the standard?
write/1 is not a user predicate. Well one
wants to write conditional code, which
can check whether some predicates are defined

or not, and for these checks its often
irrelevant to check whether a predicate
exists only in user space. I don't know
whether there is already a TC, that would

correct this blooper. The blooper went into
ISO 8.8.2 current-predicate/l, there is even
an insect test case, and is also found in
Hodgson, he writes "current_predicate(PI)

is true if and only if PI is a predicate
indicator for one of the user-defined procedures
in the database." which is not current Prolog
system practice (if we measure SWI-Prolog).

There are also Prolog systems which implement
it half heartedly (the SWI-Prolog logic):

YAP 6.3.3 (i686-mingw32): Sun Jan 20 18:27:56 GMTST 2013
?- current_predicate(write/1).
yes
?- current_predicate(write/X).
no

And there are also Prolog systems which implement
it not (the SWI-Prolog logic, and do the ISO logic):

Ciao 1.15-1781-g328b907: Wed Jun 19 00:06:05 PST 2013
?- current_predicate(write/1).
no
?- current_predicate(write/X).
no

Julio Di Egidio

unread,
May 25, 2018, 9:36:47 AM5/25/18
to
On Friday, 25 May 2018 15:25:36 UTC+2, Ulrich Neumerkel wrote:
> Michael Ben Yosef <mby...@gmail.com> writes:
<snip>
> > As you can probably agree, this has done immeasurable damage to the
> > Prolog community
>
> No, I don't. People do not read documents. If they have to pay for
> it, they are at least somewhat committed.

Nonsense: as a software engineer, a spec is *the first* thing I look for.
And that a language that is almost unknown to the industry and not only
has a paid standard is indeed just nonsense, too.

(Not to mention, the problems with the Prolog standard are not even just those,
the grammar is not even fully consistent...!)

Julio

burs...@gmail.com

unread,
May 25, 2018, 9:43:43 AM5/25/18
to
Why do you title your conformity test with
"Works for ISO/IEC JTC1 SC22 WG17"

What should this even mean?

Just currious. Some days ago you posted
this link as the way to reference the standard.

https://stackoverflow.com/tags/iso-prolog/info

Shouldnt your conformity test also say the
same. Or do you test whether the Working

group drinks its coffee correctly?

burs...@gmail.com

unread,
May 25, 2018, 9:45:16 AM5/25/18
to
Ok, I see you were busy with other stuff,
as the log of the document says:

2017-08-07: revision 1.209 renamed to conformity_testing

burs...@gmail.com

unread,
May 25, 2018, 9:46:45 AM5/25/18
to
You see kids, thats why you should never take
drugs or work in a standards commitee,

time gets distorted, what got done in a few
minutes before, now takes years and ages...

burs...@gmail.com

unread,
May 25, 2018, 9:49:18 AM5/25/18
to
"Works for ..." is very confusing. Does it
mean "this is a work product for ..."?

Or does it mean "the tests work for ..."?
Both don't make any sense.

Was this conformity test once a
work product of some sort?

burs...@gmail.com

unread,
May 25, 2018, 9:59:06 AM5/25/18
to
I guess in general an ISO WG (work group) can
work on more than one standard. I guess there
is a 1 to many relation ship between work

group and work products. There are also multiple
work products already for the Prolog work group:
- The core published standard
- published corrigendum 1
- published corrigendum 2
- Upcoming corrigenda
- The module published standard
- There DGC draft, not or never published

So whats the scope of the conformity test? I
find some footnotes:

² including Cor.2 (from approved DTC2)
³ including Cor.3 (from WDCor.3)
° most recent finds, for WDCor4

Is there a floating scope? My expectation would
be that the scope is the core standard with
all the publish corrigenda.

Otherwise showing around the conformity test
doesn't make any sense. Also work in progress,
like a corrigendum 3 can be misleading since

its not published. Just imagine that an implementor
might invest resources when making his code work
for your conformity tests.

And the corrigenda footnotes have
extremly small font...

Ok I see the second column says:

13211-1:1995
²: Cor.2, ³: Cor.3

Hm... Oki Doki

Ulrich Neumerkel

unread,
May 25, 2018, 10:08:12 AM5/25/18
to
Julio Di Egidio <ju...@diegidio.name> writes:
>(Not to mention, the problems with the Prolog standard are not even just those,
>the grammar is not even fully consistent...!)

Do you have a concrete example for this?

Michael Ben Yosef

unread,
May 25, 2018, 10:34:33 AM5/25/18
to
On Friday, 25 May 2018 15:25:36 UTC+2, Ulrich Neumerkel wrote:
> Michael Ben Yosef <...@gmail.com> writes:
> >On Friday, 25 May 2018 13:58:43 UTC+2, Ulrich Neumerkel wrote:
> >> You really need the actual standard.
> >
> >Do you know why the final draft standard was never released for free, as
> >is common practice for other programming language standards?
>
> Are you sure? For C, I definitely do know that the FDIS is only
> availabe to actual ISO members. For disbanded groups, some documents
> are put into the open.

For C, see here: http://www.open-std.org/JTC1/SC22/WG14/www/standards

"The latest publically available version of the C11 standard is the document WG14 N1570, dated 2011-04-12. This is a WG14 working paper, but it reflects what was to become the standard at the time of issue."

The link to "n1570.pdf" is given.

> >As you can probably agree, this has done immeasurable damage to the
> >Prolog community
>
> No, I don't. People do not read documents. If they have to pay for
> it, they are at least somewhat committed.

Surely you don't expect that level of commitment from every Prolog programmer? Lacking any knowledge of what is and isn't in the standard, "Prolog" is to them whatever their chosen Prolog implementation offers.

How do you expect to persuade such a Prolog programmer with an argument like this? [https://www.complang.tuwien.ac.at/ulrich/iso-prolog/SWI7_and_ISO] You are essentially saying, "the system you use every day deviates from a standard you've never seen before." What does this mean to them?

> Or take the test suite by Peter Szeredi. [...]

Where is the code?

> Same is true for Koen DeBosschere's Prolog parser which is close to perfection
> http://www.complang.tuwien.ac.at/ulrich/prolog.parser/PROLOG-PARSER-HEADER.html
> [...]

Where is the code?

I think a _Summary of ISO Prolog_ that is complete and correct up to Cor. 3 would be a valuable document to produce and make freely available on the web. It doesn't have to be as exhaustive as the official documents themselves and it must not violate their copyright, but it should allow every Prolog programmer to freely see what Standard Prolog actually is.

I may write such a thing if I continue to work with Prolog. It would be better if you, Markus Triska, Stefan Kral, or one of your other students could do it in the near future.

Ulrich Neumerkel

unread,
May 25, 2018, 11:19:16 AM5/25/18
to
Michael Ben Yosef <mby...@gmail.com> writes:
>On Friday, 25 May 2018 15:25:36 UTC+2, Ulrich Neumerkel wrote:
>> Michael Ben Yosef <...@gmail.com> writes:
>> >On Friday, 25 May 2018 13:58:43 UTC+2, Ulrich Neumerkel wrote:
>> >> You really need the actual standard.
...
>For C, see here:

Mnmn. No. No longer (since ~ 5 years).

>Surely you don't expect that level of commitment from every Prolog
>programmer? Lacking any knowledge of what is and isn't in the standard,
>"Prolog" is to them whatever their chosen Prolog implementation offers.

That's why I do have concrete pages of comparison where one can check
with minimal effort. That is, without installing some complex suite. Just
copy-paste it.

>How do you expect to persuade such a Prolog programmer with an argument
>like this? [https://www.complang.tuwien.ac.at/ulrich/iso-prolog/SWI7_and_ISO]
>You are essentially saying, "the system you use every day deviates from a
>standard you've never seen before." What does this mean to them?

That they are informed, that the system is no longer conforming in
the way it did prior to SWI7. So "never seen before" is not true.
It was seen before.

>> Or take the test suite by Peter Szeredi. [...]
>Where is the code?

http://www.complang.tuwien.ac.at/ulrich/iso-prolog/#hu2006

That entry is there since 2011.

https://web.archive.org/web/20110531205615/http://www.complang.tuwien.ac.at/ulrich/iso-prolog/

> I think a _Summary of ISO Prolog_ that is complete and correct up to Cor. 3
> would be a valuable document to produce and make freely available on the
> web.

Here it is:

http://www.complang.tuwien.ac.at/ulrich/iso-prolog/prologue#status_quo

Anything more detailed would not be read anyway. Yes, it would help
a lot if systems would adopt the same numbering such that it is
easier to compare.

burs...@gmail.com

unread,
May 25, 2018, 11:48:46 AM5/25/18
to
The SWI7_and_ISO rant should be rewritten. It
doesn't distinguish properly between changes in
the core and simple extensions which are maybe
still buggy and need improvement.

- Changes in the core:
====================
Mostlike call((fail,\+1)) should fail, if we
do not allow extensions of body conversion.
Also [A|B] == '.'(A,B) could maybe already be
found in the core, not sure.

- Simple extensions which are buggy:
==================================
Having a string data type is a legal extension,
and found in a couple of other Prolog systems.
If this is inconsistently or buggy done,
no need for a rant, just raise a bug report.

For example the strings flags are really buggy,
here is my expectation:

Jekejeke Prolog 2, Runtime Library 1.2.6
(c) 1985-2018, XLOG Technologies GmbH, Switzerland

?- set_prolog_flag(single_quotes, chars).
Yes

?- set_prolog_flag(double_quotes, atom).
Yes

?- X = "Foo".
X = "Foo"

?- X = 'Foo'.
X = ["F",o,o]

And this is what SWI-Prolog does, flags are ignored
during write_term, maybe also during read_term:

Welcome to SWI-Prolog (threaded, 64 bits, version 7.7.1)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.

?- set_prolog_flag(single_quotes, chars).
true.

?- set_prolog_flag(double_quotes, atom).
true.

?- X = "Foo".
X = 'Foo'.

?- X = 'Foo'.
X = 'Foo'.

So I raised an issue:
https://github.com/SWI-Prolog/swipl-devel/issues/302

I don't think this belongs to a SWI7 vs ISO core
discussion. ISO core allows extra data types.
It should allow backquoted strings etc..

And it already has a double_quotes flag:

double_quotes
Possible values: chars, codes, atom
** Default value: implementation defined **
Changeable: Yes

Determines the syntax of a double quoted list.
Adding a new enumeration value "string" to such
a flag, and having more flags, should be allowed.

burs...@gmail.com

unread,
May 25, 2018, 11:59:42 AM5/25/18
to
This already existing ISO double_quotes
flag is very appreciated, see also:
https://stackoverflow.com/a/50456198/502187

And adding single_quotes flag and back_quotes
flag could be the logical evolution. I don't
think the SWI7 vs ISO cuts through the meat

concerning syntax, its rather a waste of
time reading the pamphlet. Add these flags
to the Corr.3, and we are done:

- single_quotes /* new flag, optional but if present
should work as expected */
- back_quotes /* new flag, optional but if present
should work as expected */

Mention that implementation specific values
like "string" are possible. Thats it. But
that in minimum these values need to be

supported for all flags:

- chars /* minimum, also for new flags */
- codes /* minimum, also for new flags */
- atom /* minimum, also for new flags */

So that any Prolog system can be set back to
some class room specific behaviour. BTW I
am also supporting a value "variable",

so that for example a Asia Prolog user
has an alternative mode to input variables.
I am not 100% happy with the solution,

I wonder how a solution would look like
that has even a richer variety of quote
characters that can balance an input token.

burs...@gmail.com

unread,
May 25, 2018, 12:25:20 PM5/25/18
to
The rant SWI7 vs ISO is baseless, because we
cannot much infer how a flag would impact writing.
The ISO core standard is in the lucky situation,

that the double_quotes flag and the values it
provides, chars, codes and atom, usually doesn't
affect writing. Usally all different modes

can be written without double_quotes:

Case 1: codes, no doubles quotes in output:

?- set_prolog_flag(double_quotes, codes).
Yes
?- X="abc".
X = [97,98,99]

Case 2: chars, no double quotes in output:

?- set_prolog_flag(double_quotes, chars).
Yes
?- X="abc".
X = [a,b,c]

Case 3: atom, no double quotes in output:

?- set_prolog_flag(double_quotes, atom).
Yes
?- X="abc".
X = abc

So the double_quotes flag is in the lucky position
that it only impacts read term, but not write
term. So its a little unfair to demand some
behaviour, which is possibly unspecified or

wasn't considered in the ISO core standard.
I am not sure. Maybe we can deduce somewhere
some behaviour from ISO alone if there were
also other flags, like single_quotes and

back_quotes and/or other flag values like
string and variable. But my impression is rather
that this is one of the usual surprises of
a change avalanche cause by a little change.

But such unexpected additional cost, when
introducing a new feature happen all the them.
So what should be done about it? Leave everything
in a mess. I agree that the situation is unsatisfactory

but at the same time the ISO core standard does
not really offer a solution. How do you add a
data type string thoroughly, maybe change default
quoting even similar like ISO allows for double

quote, but allow the end-user to switch back,
so that maybe he can follow a text book? ISO doesn't
offer a solution because it has never dealt
exactly with this problem. The double_quotes

flag is not the same, like other new flags.

I only find curated nonsense like:

10. Strings.
The first thing to be understood about strings is that
STRINGS ARE WRONG!
https://www.complang.tuwien.ac.at/ulrich/iso-prolog/pllib-2013-12-17#strs

But this is not the modern view. Even in Java there
is now a base class of the usual String data type,
namely the class CharSequence, and you find all kind
of implementations for this class,

to cater for different demands. Same in Prolog. Usally
atoms polute the atoms table. SWI7 has decided to
add strings. Its not so much about what new built-ins
were added. More can we reset configure the syntax?

Ulrich Neumerkel

unread,
May 25, 2018, 12:33:18 PM5/25/18
to
burs...@gmail.com writes:
>Add these flags to the Corr.3, and we are done:
>
>- single_quotes /* new flag, optional but if present
> should work as expected */

With this flag canonical syntax would no longer be possible.

burs...@gmail.com

unread,
May 25, 2018, 12:38:23 PM5/25/18
to
Despite all the testing here, Tau Prolog seems
pretty cool. This test case is a hard nut to
crack, and one of the main reasons why the

syntax of Prolog is as it is and why the
conformity test of Ulrich Neumerkel makes
a lot of sense:

The number syntax of Prolog is tight,
so that we can easily write intervals,
for example in CLP(FD) (Finite Domain Solver)

I made a little example, and it seems Tau Prolog
can do it. Here are the results, the input
program and query is as follows:

Program:

:-op(400,xfx,..).

Query:

?- X = 1..2.

Result:

X = '..'(1, 2) ;

This is only a first test, but possibly implementing
a CLP(FD) in Tau Prolog, with the usual syntax
known from other Prolog systems is feasible.

Cool!

P.S.: Just add interval arithmetic, here done
with -- instead of .. , maybe because their Prolog
syste couldn't manage it:

PROLOG SETS-AS-INTERVAL PREDICATES
Jocelyn Ireson-Paine
Shelved on the 21st of December 1987
http://www.j-paine.org/prolog/intervals/intervals.descr

burs...@gmail.com

unread,
May 25, 2018, 12:41:05 PM5/25/18
to
Please don't make short sentences without
supporting your arguments in any way. Nothing
in your sentences supports your argument.

A supporting sentence normally goes as follows:

This and that is like this and that, because ...

You are missing the because ... .

Michael Ben Yosef

unread,
May 25, 2018, 1:06:47 PM5/25/18
to
On Friday, 25 May 2018 17:19:16 UTC+2, Ulrich Neumerkel wrote:
> >For C, see here:
>
> Mnmn. No. No longer (since ~ 5 years).

I don't understand. C11 is the current C standard.

> >> Or take the test suite by Peter Szeredi. [...]
> >Where is the code?
>
> http://www.complang.tuwien.ac.at/ulrich/iso-prolog/#hu2006
>
> That entry is there since 2011.

Thanks, I remember that page now.

What about this one:

> > Same is true for Koen DeBosschere's Prolog parser which is close to perfection
> > http://www.complang.tuwien.ac.at/ulrich/prolog.parser/PROLOG-PARSER-HEADER.html
> > [...]
>
> Where is the code?


> > I think a _Summary of ISO Prolog_ that is complete and correct up to Cor. 3
> > would be a valuable document to produce and make freely available on the
> > web.
>
> Here it is:
>
> http://www.complang.tuwien.ac.at/ulrich/iso-prolog/prologue#status_quo
>
> Anything more detailed would not be read anyway. Yes, it would help
> a lot if systems would adopt the same numbering such that it is
> easier to compare.

I know this page, of course. It does not cover any of the first 7 chapters of the standard. I do not need to list for you all the concepts specified in those chapters, concepts every Prolog programmer should understand, of course. You don't give or link to (even informal) definitions of any of the pre-Cor.1 predicates; programmers have to look up how to use them elsewhere.

It would be wonderful if you could expand this page to become an informal guide to the standard, but let's not pretend that it already is.

Ulrich Neumerkel

unread,
May 25, 2018, 1:35:31 PM5/25/18
to
Michael Ben Yosef <mby...@gmail.com> writes:
>Thanks, I remember that page now.

...

>What about this one:
>> > Same is true for Koen DeBosschere's Prolog parser which is close to perfection

Google.

>> http://www.complang.tuwien.ac.at/ulrich/iso-prolog/prologue#status_quo
>>
>> Anything more detailed would not be read anyway. Yes, it would help
>> a lot if systems would adopt the same numbering such that it is
>> easier to compare.
>
>I know this page, of course. It does not cover any of the first 7 chapters
>of the standard.

1, 2, 3 are just as they are.

4 is practically nothing

5 is compilance, similar to 1, 2, 3

6 is (not fully, but for the cases of differences) covered by
http://www.complang.tuwien.ac.at/ulrich/iso-prolog/conformity_testing

7 A lot of items are in
http://www.complang.tuwien.ac.at/ulrich/iso-prolog/prologue#status_quo

8 Hopefully is covered

In any case, for detailed questions, there is

https://stackoverflow.com/tags/iso-prolog/

Not sure, what you want. It soons boils down to getting the actual codex.


burs...@gmail.com

unread,
May 25, 2018, 2:03:35 PM5/25/18
to
I see a lot of missed opportunities on
prologue#status_quo. The following items
have never undergone some scrunity.

a)
5 double_quotes. In SWI-Prolog it is:

Welcome to SWI-Prolog (threaded, 64 bits, version 7.7.1)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.

?- current_prolog_flag(double_quotes, X).
X = string.

Is this allowed? What do you, Ulrich, mean by
canonical syntax would no longer be possible?
Your comment doesn't make any sense.

Do you mean by canonical syntax the output
of canonical syntax? Or inputing such a
output? Of course flags

will probably influence such built-ins. This
needs all to be defined, whereby the simplest
definition is as follows:

- If this and that flag has these an these
values in some normed range the behaviour
is such and such normed.
- For values outside of the normed range
the behaviour is implementation specififc.

So in the case of "string" in SWI7 you are
anyway not bothered, since its outside of
the normed range. You only need to

check then, if you set back the flags into
the normed range, whether the behaviour is
normed. Easy? Probably yes, for a normal

person, but not for the ISO commitee...

b)
current_predicate/1.

I already posted 3 differening systems, SWI,
Ciao and YAP in this thread.

burs...@gmail.com

unread,
May 25, 2018, 2:09:28 PM5/25/18
to
So let me reiterate your SWI7 vs ISO rant
was total baseless. The Prolog flag did
neither have the value chars, codes nor atom,

in SWI7 the default value is string. So
nothing is to be judged, this is anyway
outside of the ISO range.

If you want to perform some testing, you
need to set the flag into some range from
the norm, only then you can test,

or you need to explicitly enhance the codex
or have clauses in the codex, that
cover other values for this flag,

or maybe allowing additional flags in
a Prolog system, and subsequently additional
parameters that have to be watched, to

see whether the Prolog system is even operating
in some ISO compatible mode, or whether its
doing its implementation specific thing...

burs...@gmail.com

unread,
May 25, 2018, 2:18:39 PM5/25/18
to
Implementation specific means outside of
the scope of ISO. The ISO core standard has
not much to do for implementation specific

features, it cannot test them. If SWI7
comes up with the implementation specific
value "string" for double_quotes, then

there is nothing to test or rant about
SWI7. Thats their problem, if an implementation
specific features isn't perfect.

But what is not defined in ISO cannot be
judged from ISO viewpoint. Ok, different
features need to integrate well. But

write_canonical is even not defined for
implementation specific data types. What
if you have a data type that is not readable

and only writeable. For example I have
some reference types which are written as
0r<hex>, but they exist only at runtime,

and do not necessarely provide serialization
and deserialization, so you cannot read them.
So what? Its an implementation specific

feature, so nobody must care, as long as
the ISO core standard doesn't define it.

burs...@gmail.com

unread,
May 25, 2018, 2:28:07 PM5/25/18
to
Ok, lets put one more item on the list
of missed opportunities:

c)
8.14.2 write_canonical/[1,2]

The ISO core standard defines it via
write_term, which in turn refers to
7.10.5, some rules for writing.

But there it is only:
a) If Term is a variable
b) If Term is an integer
c) If Term is a float
d) If Term is an atom
e) If Term has the form ’ $VAR’ (N)
f) Else if Term has a principal functor
which is not a current Operator,
g) Else if Term has the form ' . '
h) If Term has a principal functor
which is an Operato

A string matches neither of the above clauses
a), b), c), d), e), f), g) or h). You
can check yourself, a string is not an atom,
but its atomic and it has its own tester.

Welcome to SWI-Prolog (threaded, 64 bits, version 7.7.1)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.

?- X = "abc", atom(X).
false.

?- X = "abc", atomic(X).
X = "abc".

?- X = "abc", string(X).
X = "abc".

So again there are some missed opportunities,
and also your rant SWI7 vs ISO was baseless,
you ranted agains an extension,

but ISO says nothing about strings.

Julio Di Egidio

unread,
May 25, 2018, 3:25:26 PM5/25/18
to
I have lost my (cheap) copy of the standard 10+ years ago, together with all my
notes and a full implementation of the WAM in C#/.NET: and I just won't buy the
standard again, not until I find a customer who pays me to use Prolog. So, I
cannot be precise anymore, nor I will dig the Usenet archives for my old posts
on these matters: you should do it instead of pretending, for years, that you
don't know what I am talking about. (I may misremember but already consistently
and conformingly parsing the dot character is impossible. And there was more,
and not just at the level of the grammar, two or three things that just will not
sum up. BTW, it's not an inconsistency proper, but there is also the big issue
with the "denotational semantics" as opposed to the "operational" one, and the
fact that the former had rather not been part of the Prolog standard at all...)

OTOH, you might try and provide any one Prolog grammar/syntax specification
(BNF, YACC, ANTLR, even Prolog/DGC or what have you) that is (publicly available
and somehow proven to be) *fully* conformant. Can you? I certainly couldn't,
not up to a couple of years ago, the last time I have tried.

Julio

burs...@gmail.com

unread,
May 25, 2018, 3:47:13 PM5/25/18
to
How did you loose your copy, did your cat eat it?

*Plonk*

j4n bur53

unread,
May 25, 2018, 3:50:03 PM5/25/18
to
How does the inconsistency in the grammar
manifest itself. Do existing Prolog systems
suddently evaporate? Like when this happens:

OH CRAP... Who divided by zero?
https://new2.fjcdn.com/pictures/Don_14c7e1_411770.jpg

*Plonk*

*Plonk*

burs...@gmail.com schrieb:

burs...@gmail.com

unread,
May 25, 2018, 4:26:06 PM5/25/18
to
All you need to know about the period is
that this one:

a. b.

And this one:

a.b.

Are two different inputs on the token level.
And subsequently have different parses.

You can check yourself:

Welcome to SWI-Prolog (threaded, 64 bits, version 7.7.14)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.

?- read(X), write(X), nl, read(Y), write(Y), nl.
|: a. b.
a
b
X = a,
Y = b.

?- read(X), write(X), nl, read(Y), write(Y), nl.
|: a.b.
a.b
|: /* <<< here is a famous Ulrich Neumerkel wait */

I dont know how complex the SWI-Prolog parser
is, whether it can be also judged recursive
decent. But you can do it also with a recursive
decent parser:

Jekejeke Prolog 2, Runtime Library 1.2.6
(c) 1985-2018, XLOG Technologies GmbH, Switzerland

?- op(400,xfx,'.').
Yes

?- read(X), write(X), nl, read(Y), write(Y), nl.
a. b.
a
b
X = a,
Y = b

?- read(X), write(X), nl, read(Y), write(Y), nl.
a.b.
[a|b]
/* <<< here is a famous Ulrich Neumerkel wait */

Only difference in SWI7 now, it has changed the
functor for lists, so the result is not shown
as [a|b], but as a.b, but the syntax is essentially

the same, especially the token scanner, that preceeds
the parser, when you implement the parser two layers,
like here:

+------------------+
| Tree Parser |
+------------------+
|
+------------------+
| Token Scanner |
+------------------+
|
+------------------+
| Input Stream |
+------------------+

What allows the period as an operator, is
this little production in my grammar.
Namely the op2 production (for simplicity
I removed the array index feature):

operator --> atom
| "|" | "," | ".".

http://www.jekejeke.ch/idatab/doclet/prod/en/docs/05_run/10_docu/02_reference/06_syntax/02_term/04_expressions.html

The above is a syntax on top of tokens,
so the EBNF says what happens with tokens,
und not what happens with characters.
For the ISO core standard, I don't know

what the final word will be. They are still
fiddling around with the vertical bar. So I
refrain from pointing to the ISO grammar.
But roughly you find it in the following ISO

grammar productions, which tell you that
on the token level, the distinction between
period and terminating period is made:

end char (* 6.4.8 *) = " . " ;
An end char shall be followed by a layout Character or a %

j4n bur53

unread,
May 25, 2018, 5:21:53 PM5/25/18
to
BTW this is also a nice test case, which I got
wrong in release 1.2.6, which should work in the
upcoming release 1.2.7.

Works with GNU Prolog 1.4.4 (64 bits):
--------------------------------------

?- op(400,xfx,'.').
yes

?- read(X), write(X), nl, read(Y), write(Y), nl.
a.b.% this is a line comment
[a|b]
c.
c

Works with SWI-Prolog (threaded, 64 bits, version 7.7.14):
----------------------------------------------------------

?- read(X), write(X), nl, read(Y), write(Y), nl.
|: a.b.% this is a line comment
a.b
|: c.
c

Here is a preview of a fix:
---------------------------

?- op(400,xfx,'.').
Yes

?- read(X), write(X), nl, read(Y), write(Y), nl.
a.b.% this is a line comment
[a|b]
c.
c

What I got wrong was basically the Ulrich Neumerkel
<wait>, I was consuming the newline of the line
comment, before I could output [a|b],

causing a wait and no output of [a|b].

burs...@gmail.com schrieb:

Ulrich Neumerkel

unread,
May 25, 2018, 5:25:03 PM5/25/18
to
There are still some differences between SWI and GNU, see

http://www.complang.tuwien.ac.at/ulrich/iso-prolog/conformity_testing#270

burs...@gmail.com

unread,
May 25, 2018, 5:46:29 PM5/25/18
to
Yes, I get:

Welcome to SWI-Prolog (threaded, 64 bits, version 7.7.14)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.

?- get_char(C). %a
|: b

C = b.

And then in GNU-Prolog:

GNU Prolog 1.4.4 (64 bits)
Compiled Apr 23 2013, 16:05:07 with cl

?- get_char(C). %a
C = '%'

I have adopted the extra reading from SWI-Prolog.
since I get the same result:

Jekejeke Prolog 2, Runtime Library 1.2.6
(c) 1985-2018, XLOG Technologies GmbH, Switzerland

?- get_char(C). %a
b
C = b

But since this is top-level behaviour, I guess its
anyway unspecified.

burs...@gmail.com

unread,
May 25, 2018, 6:00:27 PM5/25/18
to
There is a reason for this skipping in the top-level,
and the GNU Behaviour can cause a lot of problems.
The skipping is there so that you get towards

the solution next/cut interaction, the semicolon
and other stuff. Here is what happens in SWI-Prolog:

Welcome to SWI-Prolog (threaded, 64 bits, version 7.7.14)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.

?- (X=0;X=1). % this is a comment
X = 0 ;
X = 1.

Now try the same in GNU Prolog:

GNU Prolog 1.4.4 (64 bits)
Compiled Apr 23 2013, 16:05:07 with cl

?- (X=0;X=1). % this is a comment
uncaught exception: error(syntax_error('user_input:2
(char:1) . or operator expected after expression'),read_term/3)

So the SWI-Prolog behaviour has some reasons,
some top-level specific reasons, that you cannot
measure with the ISO core standard.

Works also on my side (preview release 1.2.7,
includes a very very small fix exactly in the
skipping routine, an hour ago):

Jekejeke Prolog 2, Runtime Library 1.2.7
(c) 1985-2018, XLOG Technologies GmbH, Switzerland

?- (X=0;X=1). % this is a comment
X = 0 ;
X = 1

I already posted my PrologReader and PrologWriter is
open source since a few days. This includes also the
code for this extra skipping, which makes the

top-level more user friendly. See see this
extra skipping here:

/**
* <p>Will consume or skip spaces.</p>
* <p>Will consume or skip line comments.</p>
*/
public void nextTerminalSuffix();

https://github.com/jburse/jekejeke-devel/blob/master/utils/headless/matula/util/regex/ScannerToken.java#L728

I don't know which part of SWI-Prolog is responsible
for this extra skipping. I also don't know whether
in SWI-Prolog it is intended or not,

but it is there and its useful.

burs...@gmail.com

unread,
May 25, 2018, 6:10:31 PM5/25/18
to
Corr.: Oops, there was still something in the
input buffer from get_char/1.

The GNU Prolog behaviour is like this, with a
fresh top-level:

GNU Prolog 1.4.4 (64 bits)
Compiled Apr 23 2013, 16:05:07 with cl

?- (X=0;X=1). % this is a comment
X = 0 ?
Action (; for next solution, a for all solutions, RET to stop) ?;
X = 1
yes

You see it runs through the next/cut solution
display cycle on the basis of characters in
the comment, leave no room for end-user interaction.

I call this a perfect entrance for viri. Just
have a web server with a top-level, and send
it some line comments, and you

can execute whather code you want? Not sure
whether the scenario is that bad, but you see
the problem. For the end-user, GNU-Prologs

non-skipping can be quite confusing... Apropos
Viri, there is a new head-ache for Web Masters:

Who and What Is Coinhive?
https://krebsonsecurity.com/2018/03/who-and-what-is-coinhive/

burs...@gmail.com

unread,
May 25, 2018, 6:39:06 PM5/25/18
to
But your test results #270 are outdated or wrong. I get
the following results, using the devel SWI-Prolog:

Welcome to SWI-Prolog (threaded, 64 bits, version 7.7.14)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.

?- get_char(C). %a
|: f

C = f.

?- get_char(C).%a
|: f

C = f.

Because of the skipping, there is obviously
this behaviour:

- There is no difference in . %a and .%a
- The result depends on what is input on the next line

Did you not notice that there is a Ulrich Neumerkel
<wait> after the get_char/1 ?

burs...@gmail.com

unread,
May 25, 2018, 7:05:36 PM5/25/18
to
Tau Prologs top-level is not really
stream based. Some stuff works:

Tau prolog 2018:

(X=0;X=1). % this is a comment

?- (X=0;X=1). % this is a comment
false.
X = 1 ;
X = 0 ;

Others stuff varies:

Tau prolog 2018:

(X=0;X=1). ;

?- (X=0;X=1). ;
error parsing query: error(syntax_error(line(1),
column(13), token_not_found, cause('. or expression expected')))

Compare this to SWI-Prolog:

Welcome to SWI-Prolog (threaded, 64 bits, version 7.7.14)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.

?- (X=0;X=1). ;

X = 0 ;
X = 1.

SWI-Prolog takes the semicolon from the original
imput line. I did not input it.

You see, the top-level has infinite variations,
no need to check it. Better work towards a
with_input_from/2, and test syntax with it.

burs...@gmail.com

unread,
May 25, 2018, 7:42:09 PM5/25/18
to
Concerning this skipping, I still consider
it not perfect. Maybe some better ideas and
code are possible.

For example, whats happening next here,
any guesses? The below is really really
nasty:

Welcome to SWI-Prolog (threaded, 64 bits, version 7.7.1)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.

?- X=1. /* begin

X = 1.

Julio Di Egidio

unread,
May 26, 2018, 5:39:56 AM5/26/18
to
No comment?? As usual: I am looking forward to the next time you'll again
pretend you don't what I am talking about.

The fact that it's *impossible* to parse Prolog consistently and conformingly
is the reason why I have not implemented Prolog as a first class (dynamic, via
the DLR) .NET language: plus the fact that most of present day self-proclaimed
Prolog experts are actually and systematically sabotaging it. (But, to be fair
this has been happening with everything software for decades now, anyway.)

I'll just insult you next time...

*Plonk*

Julio

burs...@gmail.com

unread,
May 26, 2018, 5:57:54 AM5/26/18
to
You confuse mental overload with sabotage. You
have to high expectation, about those that would
threaten the Prolog.

To sabotage something, you need to understand
it very deeply and find a way to harm it. You really
need to be an expert.

But what currently happens, is rather a very slow
life cycle. Because the life cycle is slow, the
standard has seen many past and present waves,

and basically done nothing:

- Past Wave: This is already 10-30 years ago,
all the functional programming languages adopted
some operator handling, also theorem provers.
Any lessons learnt? Probably no...

- Present Wave: New interest in artificial intelligence,
also from far east. New generation of young programmers,
not necessarely from the functional programming camp,
things like Python and JavaScript.

You see especially the present wave represented in
this forum by exemplars:
- Tau Prolog --> JavaScript
- Bi --> Python
- Kenichi Sasagawa --> far east

I like JavaScript and Python. They are not pontificially
functional programming, and Prolog is viewed as a kind
of embedded component for some special uses. Python is
intersting with their Notebooks, so there is a relation

to web programming, but maybe JavaScript has here an
advantage over Python. The Bi Python code is interesting
since it light handedly has abstractions such as engine,
etc.. which no nowhere see in a core standard

as objects that explicitly exist as part of some API. In
the core standard the Prolog processor is an implicit
object somewhere. I am following my own strand of research
currently, where I want to add a parent link to another

implicit object on the core standard. Namely in the
core standard there is often talk about the "database".
I call it the "knowledgebase". I don't mind that the
life cycle of the standards comittee is very slow and

that they are not jumping of any waves. There are a few
little missed opportunities, like for example I think the
SWI7 vs ISO rant is baseless and ISO could be more helpful,
preserving a very defensive attitude.

A defensive attitude based on the view that the standard
is a "core" Prolog standard, and not a "general" Prolog
standard. So their life cycle could really only deal with
the "core" which only embraces int, float, atom and compound

and nothing more, no SWI7 vs ISO rant concerning strings.
It would be nice if new waves such as:

- Tau Prolog --> JavaScript
- Bi --> Python
- Kenichi Sasagawa --> far east

Follow the same core, and if the core would get slightly
more elaborated. The parsing and unparsing, lets get our

noses more dirty in this matter!

burs...@gmail.com

unread,
May 26, 2018, 6:34:18 AM5/26/18
to
Prolog, since it doesn't have any types, no type
system, it allows you the luxury to concentrate
on the problem, and solve the problem

and not being bother by inventing in addition
some complex types for your problem, which is
notorously difficult for meta programming.

Types can be really harmful, see the domain
error expectation in length([a,b,c],-1). Does
this make any sense in a Herbrand domain, what

would a logician say? Anyway, the lack of a
type system causes also a lot of problems, tied
to developing production code.

I guess Python has also recognized this, and
added more types to its language already in 2014.

PEP 484 -- Type Hints
https://www.python.org/dev/peps/pep-0484/

I don't know what is the newest trend in types,
in connecrion with logic programming, whether
Mercury leads the camp. There is also a new
project out there:

Paul Bone - Plasma Programming Language
http://plasmalang.org/

But like Picat, it doesn't put an emphasis on
logic programming, they write "The Plasma programming
language strikes a balance between functional
and imperative programming".

In Picat the situation is maybe different.
I like a little revival of logic programming,
after functional and imperative programming
was force-feeded into our throat,

as if somebody wants to make Foie gras of us.

burs...@gmail.com

unread,
May 26, 2018, 5:33:39 PM5/26/18
to
Hi Ken,

length/2 is not part of the ISO core standard.
length/2 is something totally different. length/2
belongs to a hypothetical library called "a
Prologue to Prolog". But its not currently an
ISO standard of any kind.

See here:
https://www.complang.tuwien.ac.at/ulrich/iso-prolog/prologue

There are different ways to support something
like a Prologue to Prolog, either as built-ins
or as predefined, or packaged as modules. In
Jekejeke Prolog you find length/2 in a module
library(basic/lists).

See also here:
https://github.com/jburse/jekejeke-devel/blob/master/jekrun/headless/jekpro/frequent/basic/lists.p

Warning: This library contains a length/2
that doesn't throw a domain error for negative
numbers! Highly toxic, very dangerous.

Am Samstag, 19. Mai 2018 11:14:54 UTC+2 schrieb ken...@gmail.com:
> Hello
>
> Please tell me.
> Is there a DCG, CLP code written within the ISO-Prolog standard?
>
> Kenichi Sasagawa

ken...@gmail.com

unread,
May 26, 2018, 5:45:55 PM5/26/18
to
Thank you.

burs...@gmail.com

unread,
May 26, 2018, 5:52:04 PM5/26/18
to
CiaoProlog lists lists as a "classic" library.
What they expect as classic is this here:

Definite Clause Grammars
Formatted output
List processing
Sorting lists
compiler (library)
Enumeration of integers inside a range
Operating system utilities
Prolog system internal predicates
DEC-10 Prolog file IO
Quintus-like internal database
ttyout (library)
Enabling operators at run-time

https://ciao-lang.org/docs/ciao/ClassicProlog.html

Bot Oh! They had another idea of an ('|')/2 operator.
Namely they said:

New operators defined, see in ISO package:
|/2 [1100,xfy].

https://ciao-lang.org/docs/ciao/IsoProlog.html

But now its:

Welcome to SWI-Prolog (threaded, 64 bits, version 7.7.14)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.

?- current_op(X,Y,'|').
X = 1105,
Y = xfy.

Ulrich Neumerkel

unread,
May 26, 2018, 5:59:14 PM5/26/18
to
For a comparison of current implementations of length/2, see:

http://www.complang.tuwien.ac.at/ulrich/iso-prolog/length

burs...@gmail.com

unread,
May 26, 2018, 6:15:22 PM5/26/18
to
Better have a standardized module system, so that
in some way such libraries can be simply copied
and used. The module system

was once planned, but what has been released as
a standard is a little rudimentary. Interestingly
the ISO core standard, part 1 was written

in 1993-1994 it seems. According to this source:

Prolog Standardization: A Progress Report
Roger Scowen - 17th June 1994
Appeared in Volume 7/3, August 1994
https://dtai.cs.kuleuven.be/projects/ALP/newsletter/archive_93_96/comment/standard.html

Their idea of further standards didn't contain
such toy predicates as length/2. The article
closes with the following outlook:

"Further standardization?

The Prolog community should now consider
whether further features of Prolog should
be standardized. And if so, whether by ISO or
some other group. Candidates include some
features which were left out of Part 1 because
their inclusion would have delayed its
completion (e.g. grammar rules). Other features
would fill a semantic gap (e.g. a 'read_token'
built-in predicate), or extend the logical and
computational framework (e.g. constraints,
breadth-first searching, a foreign language
interface)."

If you standardize length/2 you do not standardize
some computational framework, as does the
core for example. You are just wasting your time.
length/2 could be maintained by a more

user oriented group. Note the "ISO or some
other group". I remember there was some attempt
for common libraries in the past, for example
accross SWI and YAp. But a module, you can just
copy it. Well SWI has length/2 as a built-in,

but lets say modules could also contain foreign
functions. We will probably not arrive at interop
as in Java, but lets say there are only 1 or 2
predicates which are built-ins. But again, you
have a good Prolog system and you need built-ins?

This only shows that your Prolog system is slow.
I have the same problem. Making length/2 built-in
would also give me a faster length/2. But this should
not be the reason to make something a standard.
If you have a copyable module, you

can always read the source, and understand what
the predicate does. Thats the good thing in most
of the Java stuff, also from the runtime, its mostly
written in Java itself. Java has some standard for
libraries, but its very much tied also to standardizing
the following:

- Standardize some package path like java.lang.*
where the standardized stuff will sit.
- In Prolog could look after absolute_file_name/2,
and the first thing would be to require
- larger module names, with a package component,
otherwise we dont have namespace to work with.

Etc..

burs...@gmail.com

unread,
May 26, 2018, 6:19:53 PM5/26/18
to
To sum up, standardizising length/2 only because
most systems have it as a native built-in is
stupid, since it doesn't make up a logical and

computational framework. Basically you should
be able to write your own length/2 in any Prolog
system. So basically length/2 should not be

realy a user:built-in or a user:predefined, it
should really sit in a module, so that its a
conscious act when using it. And its also a

conscious act which length from where you are
using. And you should have choices...

burs...@gmail.com

unread,
May 26, 2018, 6:45:17 PM5/26/18
to
I did some experimentation to arrive at a mechanism
for longer module names. First I tried something
very simple, namely I allowed so called structured
names in the module directive. For example:

First Take:

:- module(basic/lists, [append/3, ...]).

But this was a little bit off, compared to what
Java does, and also I asked myself, are all the
files in basic automatically Prolog text friends
with a special visibility? So I introduced the

Java package construct into Prolog:

Second Take:

:- package(basic).
:- module(lists, [append/3, ...]).

The package directive has an additional function,
not only enlarging the module name, it also provides
some automatic prefixing of other module names
appearing in the rest of the Prolog text,

as one is used to from Java.

So on the surface it looks very simple. But there
is also something going on under the surface.
I don't know whether Logtalk has this feature already.
I also cannot point an exact position in JLS (Java

lamguage specific) that would detail the semantics.
It was more a result from some practice and experimenting
side by side with Java and Prolog. Unlike PrologWriter
and PrologReader its not yet Open Sourced.

I don't know whether Picat has already a better namespace
or whether they also sit on a long linear list of modules.
If I read their spec I only find:

module M.
import M1,M2,…,Mn.
The declared module name and the file name must be the same
http://web.mit.edu/picat_v2.2/picat_tutorial.pdf

This reminds me of the following annectdote from
Niklaus Wirth. When he made his Lilith machine, the
file system was not hierarchical. So it could happen
for a list command, that the screen was scrolling

with file names for a couple of minutes. But I guess
they later introduced a hierarchical file system
as well, or not. Did Modula-2 have a package directive
in their language?

https://de.wikipedia.org/wiki/Lilith_%28Computersystem%29

Anyway, its never to late, to do something for
your namespace. I don't know the exact situation in
SWI-Prolog at the moment. It seems they are very liberal
what concerns their module names:

?- module('foo bar').
Warning: foo bar is not a current module (created)
true.

foo bar: ?-

And they have already structured library paths, like
a whole family of modules in a http "package":

3.2 library(http/http_dispatch): Dispatch requests in the HTTP server
3.3 library(http/http_dirindex): HTTP directory listings
3.4 library(http/http_files): Serve plain files from a hierarchy
Etc...

I have never looked how they define the module itself.
If the library(..) is only a absolute_file_name/2 thing
but the module names are not longer, then there can be
still clashes.

You see, this is not correct:

- module(http_dispatch, ...
http://www.swi-prolog.org/pldoc/doc/_SWI_/library/http/http_dispatch.pl?show=src

From the outside, via library it has a structured module
name, but from the inside it doesn't have. This would
not work for different list modules in different packages,
when the module would have the same name.

I don't recommend to have many modules with same names,
but namespace is namespace, and a linear namespace is
not really a namespace. You can get more bang out of it
when its really structured, and when you can talk
sub namespaces.

In SWI you can not really talk about http packages,
if I write my own alternative module http_dispatch,
I run into a module name clash.

Am Sonntag, 27. Mai 2018 00:15:22 UTC+2 schrieb burs...@gmail.com:

burs...@gmail.com

unread,
May 26, 2018, 6:50:41 PM5/26/18
to
Packages in the Java JLS:

7.3. Compilation Units
A compilation unit consists of three parts, each of
which is optional: A package declaration (§7.4), giving
the fully qualified name (§6.7) of the package to which the
compilation unit belongs.

A compilation unit that has no package declaration
is part of an unnamed package (§7.4.2).

import declarations (§7.5) that allow types from other
packages and static members of types to be referred
to using their simple names.

Top level type declarations (§7.6) of class and interface types.
https://docs.oracle.com/javase/specs/jls/se8/html/jls-7.html

For Prolog, I have a new import besides use_module/1.
Its called use_package/1, which makes a namespace available.
use_module/1 still comes after the module/1 directive.

But use_package/1 comes before the module/1 directive. So
its very similar to the Java import statement. One can also
make visible a whole set of module names, its like import .*

burs...@gmail.com

unread,
May 26, 2018, 7:10:49 PM5/26/18
to
Yes, for Modula-2 the earth was still flat.
No package directive:

compilation module =
program module | definition module | implementation module ;
program module =
"MODULE", module identifier, [interrupt protection], semicolon,
https://www.modula2.org/tutor/syntax.php

or this one is also cute:

Having namespaces seems like no-brainer for most languages.
Why doesn't ANSI C have namespaces?
https://stackoverflow.com/questions/4396140/why-doesnt-ansi-c-have-namespaces

The earth became only later round, with
other languages, including the Java
programming language.

I guess the earth is still flat for some
Prolog systems or the ISO module standard.
If I look at ISO/IEC 13211-2 First edition

2000-06-01, I find no packages/namespaces:

6 Language concepts and semantics
6.1 Related terms
6.1.1 Qualified and unqualified terms
6.2 Module text
6.2.1 Module user
6.2.2 Procedure Visibility
6.2.3 Module interface
6.2.4 Module directives
6.2.5 Module body
6.2.6 Clauses

Given that namespaces are not really a no-brainer,
having both the new package/1 directive and a use_package/1
directive, is not really a no-brainer,

The problem is not easy to fix.

burs...@gmail.com

unread,
May 26, 2018, 7:20:41 PM5/26/18
to
The ANSI C SO thread is quite interesting:

Quote 1:
Because people who want to add this capability to C
have not gotten together and organized to put some
pressure on compiler author teams and on ISO bodies.

I think we will see namespace in C is only if these
people would organise themselves and create an
extension(s) with namespace support. Then the ISO
bodies will have no choice but bring publish them
as standard(with more or less changes). That's how
javascript(which has some similarities with C in
this respect) did it.

@themihai: "create an extension" = get the gcc
and clang people to compile namespaces.

But I must correct myself concerning module-2,
they had local modules:

declaration =
"CONST", { constant declaration, semicolon } |
"TYPE", { type declaration, semicolon } |
"VAR", { variable declaration, semicolon } |
procedure declaration, semicolon |
local module declaration, semicolon ;
https://www.modula2.org/tutor/syntax.php

This is also seen in this quote:

Quite 2:
ANSI C was invented before namespaces were.

It was? The first ANSI C spec was 1989. I'm pretty sure
that namespaces (in some form or another) were in
programming languages before then. Ada, for example,
was standardized in 1983 and had packages as namespaces.
Those in turn were essentially based on Modula-2 modules.

burs...@gmail.com

unread,
May 26, 2018, 7:29:04 PM5/26/18
to
So what is it with local modules (do exist in Jekejeke
Prolog since recently). Well local modules are not
exactly the same as namespaces.

In local modules there is only a namespace inside a
compilation unit. But the compilation units itself
don't form a namespace.

This should have already worked for Niklaus Wirth with
Lilith and its flat file system. The names could have
grown inside the local modules of a compilation unit.

Today we can have both. For example in Java, there is
both. You have packages and local classes. A
full class name can be:

java.util.LinkedList$ListItr
http://www.docjar.com/docs/api/java/util/LinkedList$ListItr.html

There are two namespaces, which need to be viewed
as combined to form the final name:

java.util.LinkedList compilation unit namespace = packages

LinkedList$ListItr local class namespace

burs...@gmail.com

unread,
May 28, 2018, 1:17:34 PM5/28/18
to
It seems there are now two versiona of the ISO
core standard. Dunno, maybe one with nonsense

and the other without nonsense like
botched negative numbers:

PDF 60$:
INCITS/ISO/IEC 13211-1 1995 Edition, June 1, 1995
Includes all amendments and changes through Reaffirmation Notice , 2017

PDF 30$:
INCITS/ISO/IEC 13211-1 1995 Edition, June 1, 1995

So its 30$ as it always was?

Source: https://global.ihs.com/ , for a picture see here:
https://gist.github.com/jburse/baa1a055a1e2fb28f4defa539b787d1c#gistcomment-2602934

burs...@gmail.com

unread,
May 28, 2018, 1:26:10 PM5/28/18
to
Anyway, nobody will implement such absurd nonsense,
see for example Tau Prolog. So you can use the
standard as firewood for your oven.

burs...@gmail.com

unread,
May 28, 2018, 1:30:21 PM5/28/18
to
Simply quickly retract the 2017 reaffirmation, in
case there were really changes to the main document,
and make a better version for Tokyo 2020 olympia,

there is still some time left. Ha Ha. Disclaimer
if I have time and money, will make a diff of the
two and lets see what happened, not really

sure what the two prices mean..

burs...@gmail.com

unread,
May 28, 2018, 1:33:36 PM5/28/18
to
Anyway, good job, first ranting about SWI7,
so that it gets fed-up with ISO, one of the
systems that implements the simple negative

numbers, and then when this system, which
has also some weight, is out, promote your
own nonsense. Very clever. And very stupid

at the same time...

burs...@gmail.com

unread,
May 28, 2018, 1:43:00 PM5/28/18
to
You can make the calculation yourself, if you
would have different test cases for negative numbers,
how SWI7 would climb in the ranking:

Your results are:
Pass Name Status
287 ECLiPSe Alive
286 GNU Dead
262 SICStus Alive
248 IV Dead
223 IF Dead
215 Ciao Dead
207 B Dead
206 YAP Dead
200 SWI Alive
200 Minerva Dead
179 XSB Alive

A great deal of red in your conformance test,
for SWI7, is only because of your nonsense
negative numbers. Check for yourself:

http://www.complang.tuwien.ac.at/ulrich/iso-prolog/conformity_testing

Whats with the following, I dont understand:

65 compound(+1).
66 compound(+ 1).

Well again some number stuff, see it for the first time:

Welcome to SWI-Prolog (threaded, 64 bits, version 7.7.1)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.

?- (+ 1) =.. L.
L = [+, 1].

?- (+1) =.. L.
L = [1].

There could be some deeper reasons. Dunno, maybe
positive and negative infinity or positive and
negative NaNs, positive and negative zeros.

So that one wants a single token for numbers,
that also includes a plus sign. Although this looks
a little artificial to me.

Whats behind this in SWI7?

burs...@gmail.com

unread,
May 28, 2018, 2:06:43 PM5/28/18
to
You can check the standard, table 7, originally
there was no prefix operator (+)/1. So I really
need to read the new version of the standard, the

new table 7. Funny how Tau Prolog stumbles here.
There must be something wrong in their token
scanner and/or parser, I get a case where the

system doesn't react to a query anymore with
the usual error handling:

Tau Prolog, 28.05.2018 20:02

?- (+1) =.. L.
<void>

?- (+ 1) =.. L.
<void>

?- (+ a) =.. L.
error parsing query: error(syntax_error(line(1),
column(4), found(a), cause(', or ) expected')))

I opened an issue for them:

Missing Operator (+)/1 and Mute Top-Level #10
https://github.com/jariazavalverde/tau-prolog/issues/10

Just currious, what does my system do:

Jekejeke Prolog 2, Runtime Library 1.2.6
(c) 1985-2018, XLOG Technologies GmbH, Switzerland

?- (+ 1) =.. L.
L = [+,1]

?- (+1) =.. L.
L = [+,1]

Seems I implemented the numerical no-op over the
years, while consulting the corrigenda...

Ulrich Neumerkel

unread,
May 29, 2018, 2:54:16 AM5/29/18
to
burs...@gmail.com writes:
>It seems there are now two versiona of the ISO
>core standard. Dunno, maybe one with nonsense
>
>and the other without nonsense like
>botched negative numbers:
>
>PDF 60$:
>INCITS/ISO/IEC 13211-1 1995 Edition, June 1, 1995
>Includes all amendments and changes through Reaffirmation Notice , 2017
>
>PDF 30$:
>INCITS/ISO/IEC 13211-1 1995 Edition, June 1, 1995
>
>So its 30$ as it always was?

That's an excellet find! The $30 version is marked with a
yellow H for historical. So currently, that is the
cheapest way!

The "reaffirmation notice" must be some INCITS-ISO issue.

burs...@gmail.com

unread,
Jun 8, 2018, 2:07:17 PM6/8/18
to
Hi Ken,

Did you already decided whether you will ever implement
modules? They are useful for attributed variables. Maybe
you have them already?

For modules there is this standard:
ISO/IEC 13211-2 First edition 2000-06-01

This standard has already a reexport/1 directive. Here
is a little secret about the reexport/1 directive.
It can be used as a IS-A link in a class hierarchy.

Lets make an example:

:- module(human, []).

:- module(man, []).
:- reexport(library(human)).

:- module(woman, []).
:- reexport(library(human)).

Only what the ISO module standard doesn't specify, is
the following predicate subclasses_of/2. But borrowing
from Java, I would rather reverse the arguments,

and call it assignable_from/2, see also here:

java: Class.isInstance vs Class.isAssignableFrom
https://stackoverflow.com/q/3949260/502187

Can you model and solve assignable_from equations
with ROZDD? If yes, how quickly? Here are some
example queries (preview):

Jekejeke Prolog 2, Runtime Library 1.2.7
(c) 1985-2018, XLOG Technologies GmbH, Switzerland

?- use_module(library(basic/proxy)).
% 1 consults and 0 unloads in 0 ms.
Yes

?- sys_assignable_from(human, woman).
Yes

?- sys_assignable_from(man, woman).
No

j4n bur53

unread,
Jun 8, 2018, 2:10:10 PM6/8/18
to
To compute the sys_assignable_from/2 predicate I use an
inline cache. Similar to your ROZDD cache. I did not yet

do a lot of benchmarking. But its natively implememted
in Java for speed, but still there might be application scenarios

where the algorithm is not optimal. The code starts here:

case SPECIAL_SYS_ASSIGNABLE_FROM:
https://github.com/jburse/jekejeke-devel/blob/master/jekrun/headless/jekpro/frequent/basic/SpecialProxy.java#L128

From sys_assignable_from/2, and another predicate,
a predicate sys_instance_of/2 can be bootstrapped:

sys_instance_of(O, N) :-
sys_get_module(O, M),
sys_assignable_from(N, M).

This is done here:
https://github.com/jburse/jekejeke-devel/blob/master/jekrun/headless/jekpro/frequent/basic/proxy.p#L115

This was a lesson about the ISO reexport/1 from the
ISO module standard.

Next will be, Best kept secret of Prolog, Lesson 2: How
to use the ISO (:)/2 module invokation operator to implement

an object oriented message sending operator (::)/2.
Thats also not that hard...

burs...@gmail.com schrieb:
It is loading more messages.
0 new messages