Fix integer detection

Clingo treats operations that were assumed to be “invalid” not as
processing errors but as operations returning an empty set.

This changes how formulas have to be evaluated. This commit implements
an explicit function for retrieving the return type of an expression,
that is, both the domain of the result as well as whether it’s an empty,
unit, or general set with multiple values.
This commit is contained in:
2018-04-22 17:04:15 +02:00
parent 92cd114cf8
commit ea885f5fdb
8 changed files with 227 additions and 309 deletions

View File

@@ -1,5 +1,5 @@
#show p/2.
#external integer(n(0)).
%#external integer(n(0)).
{p(1..n, 1..n)}.

View File

@@ -1,5 +1,5 @@
#show prime/1.
#external integer(n(0)).
%#external integer(n(0)).
composite(I * J) :- I = 2..n, J = 2..n.
prime(N) :- N = 2..n, not composite(N).

View File

@@ -1,6 +1,6 @@
#show in/2.
#external integer(n(0)).
#external integer(r(0)).
%#external integer(n(0)).
%#external integer(r(0)).
{in(1..n, 1..r)}.
covered(I) :- in(I, S).