things to do c: - profile=fast (unordered :p)
triskacountall/2number_chars/2 is good test because it tests the
parserread(G_0), G_0. or …call_with_inference_limitcall_with_time_limit/3
time_out/3 https://sicstus.sics.se/sicstus/docs/3.12.7/html/sicstus/Timeout.htmldif/2 (scryer:dif.pl)CLP(B)clpz.pl
file
?- Goal. at the top, is treated as functor
?- with argument Goal.Answer, unexpected. means the answer s unexpected, not
needed, but write it to document a mistake in the engineAnswer1 | Answer2 meaning either are acceptableuwn
https://www.complang.tuwien.ac.at/ulrich/flowlog-prolog/ ulrich@p0:/opt/gupu/flowlog$ make
cc -O2 -Wall -Wextra -pthread flowlog.c -lm -o flowlog
flowlog.c:41:23: fatal error: stdatomic.h: No such file or directory
#include
^
compilation terminated.
make: *** [flowlog] Error 1
ulrich@p0:/opt/gupu/flowlog$ cc --version
cc (Ubuntu 4.8.4-2ubuntu1~14.04.4) 4.8.4
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
ulrich@gupu:/opt/gupu/flowlog$ ./flowlog
Flowlog (pthreads)
Type 'help.' for help, 'halt.' to exit.
?- number_chars(1,[_,[]]).
error(instantiation_error,/(number_chars,2)), unexpected.
type_error(character,[]). % expected, but not found
?- number_chars(N,['3',.]).
N = 3.0, unexpected.
syntax_error(...). % expected, but not found
?- number_chars(N,[-,' ','1']).
flowlog: fatal error (240): flowlog: unexpected token while parsing term
writeq ignores operators Before improving read-ing,
consider writeq-ing. Such that you always write valid
syntax. So the first to address would be:
integer overflow incorrect
?- 62 = E, X is 2^E-1+2^E.
X = 9223372036854775807 % good
?- 62 = E, X is 2^E-1+2^E+1.
X = -9223372036854775808, unexpected.
?- X is 2^63.
error(evaluation_error(undefined),/(is,2)), unexpected.
evaluation_error(int_overflow) % expected exceptional value (3.66, 7.9.2 e, 7.12.2 g, 9.1.2)
| X = 9223372036854775808. % current_prolog_flag(bounded,false)
current_prolog_flag(bounded,false) in SICStus, Scryer, Trealla, YAP, B, IF, IV, SWI, ECLiPSe, Ciao. Internally, these implementations have two versions of integers, the small immediate ones and the large one which reside on the heap. In this manner the immediate integers may use less than 60..63 bits, which frees tagging space for other uses.
Only GNU, 1ban with current_prolog_flag(bounded,true) and correct overflows.
GNU:
| ?- 59 = E, X is 2^E-1+2^E.
X = 1152921504606846975
yes
| ?- 59 = E, X is 2^E-1+2^E+1.
uncaught exception: error(evaluation_error(int_overflow),(is)/2)
1ban:
?- 62 = E, X is 2^E-1+2^E.
X = 9223372036854775807.
?- 62 = E, X is 2^E-1+2^E+1.
2026/01/02 11:43:26 error(evaluation_error(int_overflow),is/2)
XSB, Cx, Minerva are also bounded, but miss some overflows.
In general, it is much easier to be conforming with unbounded integers, because this overflow evaluation_error never occurs which limits arithmetical optimizations. And one has to test for overflows anyway.
?- select(X, Xs, Ys).
false, unexpected.
?- select(X, Xs, Xs).
false, unexpected. % see p.p.5.4
?- select(X,Xs,[1,2,3]).
false, unexpected.
% this is the expected answer:
Xs = [X,1,2,3]
; Xs = [1,X,2,3]
; Xs = [1,2,X,3]
; Xs = [1,2,3,X].
?- select(X, [Y|nonlist], Xs).
error(type_error(list,[_G0|nonlist]),/(select1,3)), unexpected.
This type error would make sense, if the template and modes subclause would indicate ?list for the second argument, but it reads in p.p.5.2
select(?term, ?term, ?term)
?- Xs = [a|Xs], ( true ; catch(select(X, Xs, Ys), Err, true ) ).
Xs = [a,a,a,a,a|...]
; Xs = [a,a,a,a,a|...], error(representation_error(term),/(select1,3)), unexpected.
% expected behaviour:
sto,
false % occurs-check
| sto,
Xs = [a|Xs] % rational trees
; Xs = [a|Xs], X = a, Ys = [a|Ys]
; Xs = [a|Xs], X = a, Ys = [a|Ys]
; ..., ad_infinitum
| sto,
representation_error(term).
ulrich@p0:/tmp$ git clone https://git.liminal.cafe/byakuren/flowlog.git
Cloning into 'flowlog'...
fatal: unable to access 'https://git.liminal.cafe/byakuren/flowlog.git/': gnutls_handshake() failed: Handshake failed
ulrich@p0:/tmp$ cat /etc/issue
Ubuntu 14.04.6 LTS \n \l
This does not happen with github. There I follow various systems like Scryer, Trealla.
A representation error can only be issued at a point in time when a goal attempts to create some term that cannot be represented. So this error prevents the creation of something. Thus the goal Xs = [a|Xs] may issue a representation error, if unification is defined in such a manner (e.g., set_prolog_flag(occurs_check, error) in Scryer or Trealla). But from above answer it is clear that this goal succeeds, and thus the infinite tree is created. (Do not call it an infinite term since terms are defined such that there are no cyclic structures in them).
?- append([a], Ys, Zs).
Segmentation fault (core dumped), unexpected.
Zs = [a|Ys]. % expected, but not found
v4.6.5
inf :-
inf.
?- inf.
Segmentation fault (core dumped), unexpected.
loops % expected
| resource_error(...). % if you insist ...