scryer-prolog
scryer-prolog copied to clipboard
time/1 negative inference
v0.9.3-126-g1e0fa567-modified
$ scryer-prolog -f
?- use_module(library(time)).
true.
?- time(X = 1).
% CPU time: 0.000s, -22 inference (exception?) % Meaning?
X = 1.
?- time(X = 1).
% CPU time: 0.000s, 1 inference
X = 1.
?-
What is most irritating here is that the result is stateful
Another irritation:
$ scryer-prolog -f
?- use_module(library(lists)).
true.
?- use_module(library(time)).
true.
?- time((length(L,1), append(L,[_|Y],LT),Y="")).
% CPU time: 0.000s, -13 inference (exception?) % This time -13
L = [_A], Y = [], LT = [_A,_B].
?- halt.
$ scryer-prolog -f
?- use_module(library(time)).
true.
?- use_module(library(lists)).
true.
?- time((length(L,100), append(L,[_|Y],LY),Y="")). % "Excess work" and it is gone
% CPU time: 0.000s, 86 inferences
L = [_A,_B,_C,_D,_E,_F,_G,_H,_I,_J,_K,_L,_M,_N,_O,_P,_Q,_R,_S,_T|...], Y = [], LY = [_A,_B,_C,_D,_E,_F,_G,_H,_I,_J,_K,_L,_M,_N,_O,_P,_Q,_R,_S,_T|...].
And another one:
$ scryer-prolog -f
?- use_module(library(lists)).
true.
?- use_module(library(time)).
true.
?- time((length(L,15), append(L,[_|Y],LY),Y="")). % Goes positive but
% CPU time: 0.000s, 1 inference % unexpected
:
?- time((length(L,15), append(L,[_|Y],LY),Y="")).
% CPU time: 0.000s, 24 inferences % I guess this result is expected
:
?- time((length(L,15), append(L,[_|Y],LY),Y="")).
% CPU time: 0.000s, 24 inferences
:
?-
Finding: The result of calling time/1 a first time is rendered unusable.
Related: #2180.