correct mishandled Addr::CharCode case in eq_test (#505)

This commit is contained in:
Mark Thom
2020-05-15 22:51:18 -06:00
parent b60561c3bb
commit 510530973c
2 changed files with 60 additions and 58 deletions

View File

@@ -4676,64 +4676,64 @@ run_propagator(scalar_product_eq(Cs0,Vs0,P0), MState) -->
% X + Y = Z % X + Y = Z
run_propagator(pplus(X,Y,Z), MState) --> run_propagator(pplus(X,Y,Z), MState) -->
( nonvar(X) -> ( nonvar(X) ->
( X =:= 0 -> kill(MState), Y = Z ( X =:= 0 -> kill(MState), Y = Z
; Y == Z -> kill(MState), X =:= 0 ; Y == Z -> kill(MState), X =:= 0
; nonvar(Y) -> kill(MState), Z is X + Y ; nonvar(Y) -> kill(MState), Z is X + Y
; nonvar(Z) -> kill(MState), Y is Z - X ; nonvar(Z) -> kill(MState), Y is Z - X
; { fd_get(Z, ZD, ZPs), ; { fd_get(Z, ZD, ZPs),
fd_get(Y, YD, _), fd_get(Y, YD, _),
domain_shift(YD, X, Shifted_YD), domain_shift(YD, X, Shifted_YD),
domains_intersection(ZD, Shifted_YD, ZD1) }, domains_intersection(ZD, Shifted_YD, ZD1) },
fd_put(Z, ZD1, ZPs), fd_put(Z, ZD1, ZPs),
( { fd_get(Y, YD1, YPs) } -> ( { fd_get(Y, YD1, YPs) } ->
O is -X, O is -X,
{ domain_shift(ZD1, O, YD2), { domain_shift(ZD1, O, YD2),
domains_intersection(YD1, YD2, YD3) }, domains_intersection(YD1, YD2, YD3) },
fd_put(Y, YD3, YPs) fd_put(Y, YD3, YPs)
; [] ; []
) )
) )
; nonvar(Y) -> run_propagator(pplus(Y,X,Z), MState) ; nonvar(Y) -> run_propagator(pplus(Y,X,Z), MState)
; nonvar(Z) -> ; nonvar(Z) ->
( X == Y -> kill(MState), { even(Z), X is Z // 2 } ( X == Y -> kill(MState), { even(Z), X is Z // 2 }
; { fd_get(X, XD, _), ; { fd_get(X, XD, _),
fd_get(Y, YD, YPs), fd_get(Y, YD, YPs),
domain_negate(XD, XDN), domain_negate(XD, XDN),
domain_shift(XDN, Z, YD1), domain_shift(XDN, Z, YD1),
domains_intersection(YD, YD1, YD2) }, domains_intersection(YD, YD1, YD2) },
fd_put(Y, YD2, YPs), fd_put(Y, YD2, YPs),
( { fd_get(X, XD1, XPs) } -> ( { fd_get(X, XD1, XPs) } ->
{ domain_negate(YD2, YD2N), { domain_negate(YD2, YD2N),
domain_shift(YD2N, Z, XD2), domain_shift(YD2N, Z, XD2),
domains_intersection(XD1, XD2, XD3) }, domains_intersection(XD1, XD2, XD3) },
fd_put(X, XD3, XPs) fd_put(X, XD3, XPs)
; [] ; []
) )
) )
; ( X == Y -> { kill(MState), 2*X #= Z } ; ( X == Y -> { kill(MState), 2*X #= Z }
; X == Z -> kill(MState), Y = 0 ; X == Z -> kill(MState), Y = 0
; Y == Z -> kill(MState), X = 0 ; Y == Z -> kill(MState), X = 0
; { fd_get(X, XD, XL, XU, XPs), ; { fd_get(X, XD, XL, XU, XPs),
fd_get(Y, _, YL, YU, _), fd_get(Y, _, YL, YU, _),
fd_get(Z, _, ZL, ZU, _), fd_get(Z, _, ZL, ZU, _),
NXL cis max(XL, ZL-YU), NXL cis max(XL, ZL-YU),
NXU cis min(XU, ZU-YL) }, NXU cis min(XU, ZU-YL) },
update_bounds(X, XD, XPs, XL, XU, NXL, NXU), update_bounds(X, XD, XPs, XL, XU, NXL, NXU),
( { fd_get(Y, YD2, YL2, YU2, YPs2) } -> ( { fd_get(Y, YD2, YL2, YU2, YPs2) } ->
{ NYL cis max(YL2, ZL-NXU), { NYL cis max(YL2, ZL-NXU),
NYU cis min(YU2, ZU-NXL) }, NYU cis min(YU2, ZU-NXL) },
update_bounds(Y, YD2, YPs2, YL2, YU2, NYL, NYU) update_bounds(Y, YD2, YPs2, YL2, YU2, NYL, NYU)
; NYL = n(Y), NYU = n(Y) ; NYL = n(Y), NYU = n(Y)
), ),
( { fd_get(Z, ZD2, ZL2, ZU2, ZPs2) } -> ( { fd_get(Z, ZD2, ZL2, ZU2, ZPs2) } ->
{ NZL cis max(ZL2,NXL+NYL), { NZL cis max(ZL2,NXL+NYL),
NZU cis min(ZU2,NXU+NYU) }, NZU cis min(ZU2,NXU+NYU) },
update_bounds(Z, ZD2, ZPs2, ZL2, ZU2, NZL, NZU) update_bounds(Z, ZD2, ZPs2, ZL2, ZU2, NZL, NZU)
; [] ; []
) )
) )
). ).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View File

@@ -1959,11 +1959,13 @@ impl MachineState {
(Addr::CharCode(n1), v2) | (v2, Addr::CharCode(n1)) => { (Addr::CharCode(n1), v2) | (v2, Addr::CharCode(n1)) => {
if let Ok(n2) = Number::try_from((v2, &self.heap)) { if let Ok(n2) = Number::try_from((v2, &self.heap)) {
if let Some(n2) = n2.to_u32() { if let Some(n2) = n2.to_u32() {
if n1 != n2 { if n1 == n2 {
return true; continue;
} }
} }
} }
return true;
} }
(a1, a2) => { (a1, a2) => {
if let Ok(n1) = Number::try_from((a1, &self.heap)) { if let Ok(n1) = Number::try_from((a1, &self.heap)) {