scryer-prolog icon indicating copy to clipboard operation
scryer-prolog copied to clipboard

seeming nontermination in char_type/2

Open librarianmage opened this issue 1 year ago • 1 comments

Thanks to #2322, char_type/2 now works when the first argument is not ground but the second is. However, I have noticed a couple odd sharp edges with this new feature. char_type(X, whitespace). works perfectly and generating all solutions terminates quickly, and even char_type(X, alnum). will spit out lots of output when enumerating all solutions. However, char_type(X, upper("A")). seems to not terminate after generating X = 'A' and X = a, and nonsensical queries such as char_type(X, upper("a")). likewise seem to not terminate.

I imagine that this intersects with #2328, as it is likely related to the sheer number of possible chars, but I figured it would be useful as a separate issue.

librarianmage avatar Feb 12 '24 05:02 librarianmage

Yes, definitely worth filing!

I think the first thing here is to find out whether it indeed does not terminate, or is "only" very slow. I tried it now for an hour and then interrupted the search:

?- time(char_type(X, upper("A"))).
   % CPU time: 0.000s, 503 inferences
   X = 'A'
;  % CPU time: 0.000s, 225 inferences
   X = a
;  ^C% CPU time: 3526.985s, 7_017_539 inferences
      error('$interrupt_thrown',repl/0).

Scryer's toplevel once more comes in very handy: We can press a to get all answers!

triska avatar Feb 13 '24 20:02 triska