[sledge] Improve simplification of negated booleans

Reviewed By: mbouaziz

Differential Revision: D12854516

fbshipit-source-id: e6d454a21
master
Josh Berdine 6 years ago committed by Facebook Github Bot
parent 48e947883d
commit 69c9dbad9c

@ -839,6 +839,8 @@ let rec simp_not (typ : Typ.t) exp =
| ( App {op= App {op= App {op= Conditional; arg= cnd}; arg= thn}; arg= els} | ( App {op= App {op= App {op= Conditional; arg= cnd}; arg= thn}; arg= els}
, Integer {bits= 1} ) -> , Integer {bits= 1} ) ->
simp_cond cnd (simp_not typ thn) (simp_not typ els) simp_cond cnd (simp_not typ thn) (simp_not typ els)
(* ¬false ==> true ¬true ==> false *)
| Integer {data}, Integer {bits= 1} -> bool (Z.is_false data)
(* ¬b ==> false = b *) (* ¬b ==> false = b *)
| b, Integer {bits= 1} -> App {op= App {op= Eq; arg= bool false}; arg= b} | b, Integer {bits= 1} -> App {op= App {op= Eq; arg= bool false}; arg= b}
(* ¬e ==> true xor e *) (* ¬e ==> true xor e *)

@ -178,7 +178,7 @@ let%test_module _ =
let%expect_test _ = let%expect_test _ =
pf (z != z) ; pf (z != z) ;
[%expect {| (0 = -1) |}] [%expect {| 0 |}]
let%expect_test _ = let%expect_test _ =
pf (!1 = !0) ; pf (!1 = !0) ;

Loading…
Cancel
Save