diff --git a/library/clpz.pl b/library/clpz.pl index 0b789774c..ff7cfe4f0 100644 --- a/library/clpz.pl +++ b/library/clpz.pl @@ -2566,7 +2566,7 @@ g(power_var_num(E, V, N)) => [p(pexp(V, N, R))], m(A*B) => [p(ptimes(A, B, R))], m(A-B) => [p(pplus(R,B,A))], - m(-A) => [p(ptimes(-1,A,R))], + m(-A) => [p(pplus(A,R,0))], m(max(A,B)) => [g(A #=< #R), g(B #=< R), p(pmax(A, B, R))], m(min(A,B)) => [g(A #>= #R), g(B #>= R), p(pmin(A, B, R))], m(A mod B) => [g(B #\= 0), p(pmod(A, B, R))], @@ -2647,6 +2647,7 @@ morphing(pplus). morphing(ptimes). +morphing(pexp). morphing_propagator(P0, P, Target) :- P0 =.. [F|Args0], @@ -2823,7 +2824,7 @@ m(var(X) #= var(Y)+var(Z)) => [p(pplus(Y,Z,X))], m(var(X) #= var(Y)-var(Z)) => [p(pplus(X,Z,Y))], m(var(X) #= var(Y)*var(Z)) => [p(ptimes(Y,Z,X))], - m(var(X) #= -var(Z)) => [p(ptimes(-1, Z, X))], + m(var(X) #= -var(Y)) => [p(pplus(X,Y,0))], m_c(any(X) #= any(Y), left_right_linsum_const(X, Y, Cs, Vs, S)) => [g(scalar_product_(#=, Cs, Vs, S))], m_c(var(X) #= abs(var(Y)) + any(V0), X == Y) => [d(V0,V),p(x_eq_abs_plus_v(X,V))], @@ -3559,7 +3560,7 @@ m(A+B) => [d(D), p(pplus(A,B,R)), a(A,B,R)], m(A*B) => [d(D), p(ptimes(A,B,R)), a(A,B,R)], m(A-B) => [d(D), p(pplus(R,B,A)), a(A,B,R)], - m(-A) => [d(D), p(ptimes(-1,A,R)), a(R)], + m(-A) => [d(D), p(pplus(A,R,0)), a(R)], m(max(A,B)) => [d(D), p(pgeq(R, A)), p(pgeq(R, B)), p(pmax(A,B,R)), a(A,B,R)], m(min(A,B)) => [d(D), p(pgeq(A, R)), p(pgeq(B, R)), p(pmin(A,B,R)), a(A,B,R)], m(abs(A)) => [d(D), g(#R#>=0), p(pabs(A, R)), a(A,R)], @@ -4909,7 +4910,7 @@ ) ; ( X == Y -> kill(MState), - { make_propagator(pexp(X,2,Z), Morph) }, + { make_propagator(pexp(X,2,Z,_), Morph) }, init_propagator_([X,Z], Morph) ; { fd_get(X, XD, XL, XU, XPs), fd_get(Y, _, YL, YU, _), @@ -5436,9 +5437,13 @@ %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% % Z = X ^ Y -run_propagator(pexp(X,Y,Z), MState) --> +run_propagator(pexp(X,Y,Z,Morph), MState) --> ( X == 1 -> kill(MState), Z = 1 - ; X == 0 -> kill(MState), queue_goal((Z in 0..1, Y #>= 0, Z #<==> Y #= 0)) + ; X == 0 -> + kill(MState), + queue_goal((Z in 0..1, Y #>= 0)), + { make_propagator(reified_eq(1,Y,1,0,[],Z), Morph) }, + init_propagator_([Y,Z], Morph) ; Y == 0 -> kill(MState), Z = 1 ; Y == 1 -> kill(MState), Z = X ; nonvar(X) -> @@ -5498,7 +5503,9 @@ ) ; nonvar(Y), Y > 0 -> ( { even(Y) } -> - { geq(Z, 0) } + { fd_get(Z, ZD0, ZPs0), + domain_remove_smaller_than(ZD0, 0, ZDG0) }, + fd_put(Z, ZDG0, ZPs0) ; true ), ( { fd_get(X, XD, XL, XU, _), fd_get(Z, ZD, ZL, ZU, ZPs) } -> @@ -7803,7 +7810,7 @@ attribute_goal_(x_neq_y_plus_z(X,Y,Z)) --> [#X #\= #Y + #Z]. attribute_goal_(x_leq_y_plus_c(X,Y,C)) --> [#X #=< #Y + C]. attribute_goal_(ptzdiv(X,Y,Z)) --> [#X // #Y #= #Z]. -attribute_goal_(pexp(X,Y,Z)) --> [#X ^ #Y #= #Z]. +attribute_goal_(pexp(X,Y,Z,_)) --> [#X ^ #Y #= #Z]. attribute_goal_(psign(X,Y)) --> [#Y #= sign(#X)]. attribute_goal_(pabs(X,Y)) --> [#Y #= abs(#X)]. attribute_goal_(pmod(X,M,K)) --> [#X mod #M #= #K]. diff --git a/src/query.c b/src/query.c index 1cad073d9..fcdf7df87 100644 --- a/src/query.c +++ b/src/query.c @@ -874,7 +874,7 @@ static bool are_slots_ok(const query *q, const frame *f) if (is_empty(c)) return false; - else if (is_indirect(c) /*&& !is_evaluable(c->val_ptr)*/) + else if (is_indirect(c)) return false; else if (is_cstring(c) && (c->flags & FLAG_CSTR_QUANTUM_ERASER)) return false;