]> Repositorios git - scryer-prolog.git/commitdiff
Remove `min/2` and `max/2` when possible
authornotoria <[email protected]>
Sun, 7 Jan 2024 19:15:28 +0000 (20:15 +0100)
committernotoria <[email protected]>
Sun, 7 Jan 2024 19:15:28 +0000 (20:15 +0100)
?- A #= min(A,B).
   clpz:(B#>=A), clpz:(A#=min(A,B)). % unexpected.
?- A #= min(A,0).
   clpz:(A in inf..0), clpz:(A#=min(A,0)). % unexpected.

src/lib/clpz.pl

index c0c306817e7e1938dd4157c34877b86c35043041..d699cad18f992458cadb914fe97166bdcc3f5220 100644 (file)
@@ -5384,6 +5384,7 @@ run_propagator(pmax(X,Y,Z), MState) -->
                 ;   Z > X -> queue_goal(Z = Y)
                 ;   { false } % Z < X
                 )
+            ;   Y == Z -> kill(MState), queue_goal(Y #>= X)
             ;   { fd_get(Y, _, YInf, YSup, _) },
                 (   { YInf cis_gt n(X) } -> queue_goal(Z = Y)
                 ;   { YSup cis_lt n(X) } -> queue_goal(Z = X)
@@ -5419,6 +5420,7 @@ run_propagator(pmin(X,Y,Z), MState) -->
                 ;   Z < X -> Z = Y
                 ;   { false } % Z > X
                 )
+            ;   Y == Z -> kill(MState), queue_goal(Y #=< X)
             ;   { fd_get(Y, _, YInf, YSup, _) },
                 (   { YSup cis_lt n(X) } -> Z = Y
                 ;   { YInf cis_gt n(X) } -> Z = X