diff --git a/infer/src/pulse/PulseFormula.ml b/infer/src/pulse/PulseFormula.ml index ea17244b1..1276dbfbf 100644 --- a/infer/src/pulse/PulseFormula.ml +++ b/infer/src/pulse/PulseFormula.ml @@ -1069,11 +1069,11 @@ end = struct let normalize_term phi t = Term.map_variables t ~f:(fun v -> let v_canon = (VarUF.find phi.var_eqs v :> Var.t) in - let q_opt = - let open Option.Monad_infix in - Var.Map.find_opt v_canon phi.linear_eqs >>= LinArith.get_as_const - in - match q_opt with None -> VarSubst v_canon | Some q -> QSubst q ) + match Var.Map.find_opt v_canon phi.linear_eqs with + | None -> + VarSubst v_canon + | Some l -> ( + match LinArith.get_as_const l with None -> LinSubst l | Some q -> QSubst q ) ) in let atom' = Atom.map_terms atom ~f:(fun t -> normalize_term phi t) in Atom.eval atom' |> sat_of_eval_result diff --git a/infer/src/pulse/unit/PulseFormulaTest.ml b/infer/src/pulse/unit/PulseFormulaTest.ml index e7abadb75..8fc56464d 100644 --- a/infer/src/pulse/unit/PulseFormulaTest.ml +++ b/infer/src/pulse/unit/PulseFormulaTest.ml @@ -168,7 +168,7 @@ let%test_module "normalization" = let%expect_test _ = normalize (x + y < x + y) ; - [%expect {|true (no var=var) && v6 = x + y ∧ v7 = x + y && {[v6 + -v7] < 0}|}] + [%expect {|unsat|}] let%expect_test "nonlinear arithmetic" = normalize (z * (x + (v * y) + i 1) / w = i 0) ; @@ -178,7 +178,7 @@ let%test_module "normalization" = && v7 = x + v6 ∧ v8 = x + v6 +1 ∧ v10 = 0 && - {0 = [v9]÷[w]}∧{[v6] = [v]×[y]}∧{[v9] = [z]×[v8]} |}] + {0 = [v9]÷[w]}∧{[v6] = [v]×[y]}∧{[v9] = [z]×[x + v6 +1]} |}] (* check that this becomes all linear equalities *) let%expect_test _ =