rely on newly available operator notation for (#)/1

This commit is contained in:
Markus Triska
2023-01-10 22:59:11 +01:00
parent 73a1ee59fa
commit 542b9e1976

View File

@@ -922,8 +922,8 @@ expressions with the functor `(?)/1` or `(#)/1`. For example:
?- assertz(clpz:monotonic).
true.
?- #(X) #= #(Y) + #(Z).
#(Y)+ #(Z)#= #(X).
?- #X #= #Y + #Z.
clpz:(#Y+ #Z#= #X).
?- X #= 2, X = 1+1.
ERROR: Arguments are not sufficiently instantiated
@@ -2556,7 +2556,7 @@ parse_clpz(E, R,
g(constrain_to_integer(E)), g(E = R)],
g(integer(E)) => [g(R = E)],
?(E) => [g(must_be_fd_integer(E)), g(R = E)],
#(E) => [g(must_be_fd_integer(E)), g(R = E)],
#E => [g(must_be_fd_integer(E)), g(R = E)],
m(A+B) => [p(pplus(A, B, R))],
% power_var_num/3 must occur before */2 to be useful
g(power_var_num(E, V, N)) => [p(pexp(V, N, R))],
@@ -2614,7 +2614,7 @@ parse_matcher(E, R, Matcher, Clause) :-
parse_condition(g(Goal), E, E) --> [Goal, !].
parse_condition(?(E), _, ?(E)) --> [!].
parse_condition(#(E), _, #(E)) --> [!].
parse_condition(#E, _, #E) --> [!].
parse_condition(m(Match), _, Match0) -->
[!],
{ copy_term(Match, Match0),
@@ -2874,7 +2874,7 @@ matcher(m_c(Matcher,Cond), Gs) -->
).
match(any(A), T) --> [A = T].
match(var(V), T) --> [( nonvar(T), ( T = ?(Var) ; T = #(Var) ) ->
match(var(V), T) --> [( nonvar(T), ( T = ?(Var) ; T = #Var ) ->
must_be_fd_integer(Var), V = Var
; v_or_i(T), V = T
)].
@@ -2937,7 +2937,7 @@ expr_conds(E, E) --> [integer(E)],
{ var(E), !, \+ monotonic }.
expr_conds(E, E) --> { integer(E) }.
expr_conds(?(E), E) --> [integer(E)].
expr_conds(#(E), E) --> [integer(E)].
expr_conds(#E, E) --> [integer(E)].
expr_conds(-E0, -E) --> expr_conds(E0, E).
expr_conds(abs(E0), abs(E)) --> expr_conds(E0, E).
expr_conds(A0+B0, A+B) --> expr_conds(A0, A), expr_conds(B0, B).
@@ -3118,7 +3118,7 @@ user:goal_expansion(Goal0, Goal) :-
linsum(X, S, S) --> { var(X), !, non_monotonic(X) }, [vn(X,1)].
linsum(I, S0, S) --> { integer(I), S is S0 + I }.
linsum(?(X), S, S) --> { must_be_fd_integer(X) }, [vn(X,1)].
linsum(#(X), S, S) --> { must_be_fd_integer(X) }, [vn(X,1)].
linsum(#X, S, S) --> { must_be_fd_integer(X) }, [vn(X,1)].
linsum(-A, S0, S) --> mulsum(A, -1, S0, S).
linsum(N*A, S0, S) --> { integer(N) }, !, mulsum(A, N, S0, S).
linsum(A*N, S0, S) --> { integer(N) }, !, mulsum(A, N, S0, S).
@@ -3523,7 +3523,7 @@ parse_reified(E, R, D,
g(constrain_to_integer(E)), g(R = E), g(D=1)],
g(integer(E)) => [g(R=E), g(D=1)],
?(E) => [g(must_be_fd_integer(E)), g(R=E), g(D=1)],
#(E) => [g(must_be_fd_integer(E)), g(R=E), g(D=1)],
#E => [g(must_be_fd_integer(E)), g(R=E), g(D=1)],
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)],
@@ -3576,7 +3576,7 @@ parse_reified(E, R, D, Matcher, Clause) :-
reified_condition(g(Goal), E, E, []) --> [{Goal}, !].
reified_condition(?(E), _, ?(E), []) --> [!].
reified_condition(#(E), _, #(E), []) --> [!].
reified_condition(#E, _, #E, []) --> [!].
reified_condition(m(Match), _, Match0, Ds) -->
[!],
{ copy_term(Match, Match0),
@@ -3640,7 +3640,7 @@ reify(Expr, B, Ps) :-
reifiable(E) :- var(E), non_monotonic(E).
reifiable(E) :- integer(E), E in 0..1.
reifiable(?(E)) :- must_be_fd_integer(E).
reifiable(#(E)) :- must_be_fd_integer(E).
reifiable(#E) :- must_be_fd_integer(E).
reifiable(V in _) :- fd_variable(V).
reifiable(Expr) :-
Expr =.. [Op,Left,Right],
@@ -3661,7 +3661,7 @@ reify(E, B) --> { B in 0..1 }, reify_(E, B).
reify_(E, B) --> { var(E), !, E = B }.
reify_(E, B) --> { integer(E), E = B }.
reify_(?(B), B) --> [].
reify_(#(B), B) --> [].
reify_(#B, B) --> [].
reify_(V in Drep, B) -->
{ drep_to_domain(Drep, Dom) },
propagator_init_trigger(reified_in(V,Dom,B)),
@@ -7706,7 +7706,7 @@ unwrap_with(Goal, Term0, Term) :-
maplist(unwrap_with(Goal), Args0, Args),
Term =.. [F|Args].
bare_integer(V0, V) :- ( integer(V0) -> V = V0 ; V = #(V0) ).
bare_integer(V0, V) :- ( integer(V0) -> V = V0 ; V = #V0 ).
attribute_goal_(presidual(Goal)) --> [Goal].
attribute_goal_(pgeq(A,B)) --> [#A #>= #B].