]> Repositorios git - scryer-prolog.git/commit
correct overeager CLP(ℤ) goal expansion
authorMarkus Triska <[email protected]>
Fri, 1 May 2020 16:29:00 +0000 (18:29 +0200)
committerMarkus Triska <[email protected]>
Fri, 1 May 2020 16:29:00 +0000 (18:29 +0200)
commitca5a5b4392bfbed8cfdbb3b2e7dbaa42ea193007
treeffc699b873d6df0aa560f6fa0bd8ba7f954081b4
parent1b7c22677909384e1d84d8f72bba4efc1b4e9330
correct overeager CLP(ℤ) goal expansion

For instance, consider:

    t(X) :- X #= 1.

We *cannot* expand this to:

    ?- listing(t/1).
    t(A) :-
       (  integer(A) ->
          A=:=A
       ;  (  var(A) ->
             true
          ;  true,
             clpz:clpz_equal(A,A)
          )
       ).

Also, a new binding *must not* be dragged outside of disjunctions,
since the code may look for example like this:

        i(X) :-
            (   X #= 3
            ;   X #= 4
            ).

This commit fixes such issues, and still rewrites CLP(ℤ) expressions
as far as possible already at compilation time.

For example:

    n(X) :- X #= 1+3.

This is now compiled to (note that 1+3 is evaluated to 4):

    ?- listing(n/1).
    n(A) :-
       (  integer(A) ->
          A=:=4
       ;  (  var(A) ->
             A=4
          ;  B=4,
             clpz:clpz_equal(A,B)
          )
       ).

Ideally, it should be compiled to:

    n(4).
src/prolog/lib/clpz.pl