[sledge] Refactor: Replace Formula.is_false with equal ff, similarly for tt

Summary:
`Formula.is_true` and `is_false` are now trivial one-line wrappers,
remove them for clarity.

Reviewed By: jvillard

Differential Revision: D22571143

fbshipit-source-id: 3f058eab4
master
Josh Berdine 4 years ago committed by Facebook GitHub Bot
parent f20cabf7a4
commit c440ce81fe

@ -979,8 +979,6 @@ module Formula = struct
(** Query *) (** Query *)
let fv e = fold_vars_f e ~f:Var.Set.add ~init:Var.Set.empty let fv e = fold_vars_f e ~f:Var.Set.add ~init:Var.Set.empty
let is_true = function Tt -> true | _ -> false
let is_false = function Ff -> true | _ -> false
(** Traverse *) (** Traverse *)
@ -1327,7 +1325,7 @@ module Context = struct
let fml = let fml =
let normalizef x e = f_ses_map (Ses.Equality.normalize x) e in let normalizef x e = f_ses_map (Ses.Equality.normalize x) e in
let fml' = normalizef ctx fml in let fml' = normalizef ctx fml in
if Formula.is_true fml' then [] else [fml'] if Formula.(equal tt fml') then [] else [fml']
in in
List.pp List.pp
~pre:(if first then "@[ " else "@ @[@<2>∧ ") ~pre:(if first then "@[ " else "@ @[@<2>∧ ")

@ -167,8 +167,6 @@ and Formula : sig
(** Query *) (** Query *)
val fv : t -> Var.Set.t val fv : t -> Var.Set.t
val is_true : t -> bool
val is_false : t -> bool
(** Traverse *) (** Traverse *)

@ -59,7 +59,7 @@ let map_seg ~f h =
let map ~f_sjn ~f_ctx ~f_trm ~f_fml ({us; xs= _; ctx; pure; heap; djns} as q) let map ~f_sjn ~f_ctx ~f_trm ~f_fml ({us; xs= _; ctx; pure; heap; djns} as q)
= =
let pure = f_fml pure in let pure = f_fml pure in
if Formula.is_false pure then false_ us if Formula.(equal ff pure) then false_ us
else else
let ctx = f_ctx ctx in let ctx = f_ctx ctx in
let heap = List.map_endo heap ~f:(map_seg ~f:f_trm) in let heap = List.map_endo heap ~f:(map_seg ~f:f_trm) in
@ -274,7 +274,7 @@ let fv ?ignore_ctx q =
in in
fv_union Var.Set.empty q fv_union Var.Set.empty q
let invariant_pure p = assert (not (Formula.is_false p)) let invariant_pure p = assert (not Formula.(equal ff p))
let invariant_seg _ = () let invariant_seg _ = ()
let rec invariant q = let rec invariant q =
@ -293,7 +293,7 @@ let rec invariant q =
( match djns with ( match djns with
| [[]] -> | [[]] ->
assert (Context.is_empty ctx) ; assert (Context.is_empty ctx) ;
assert (Formula.is_true pure) ; assert (Formula.(equal tt pure)) ;
assert (List.is_empty heap) assert (List.is_empty heap)
| _ -> assert (not (Context.is_unsat ctx)) ) ; | _ -> assert (not (Context.is_unsat ctx)) ) ;
invariant_pure pure ; invariant_pure pure ;
@ -451,11 +451,11 @@ let star q1 q2 =
| {djns= [[]]; _}, _ | _, {djns= [[]]; _} -> | {djns= [[]]; _}, _ | _, {djns= [[]]; _} ->
false_ (Var.Set.union q1.us q2.us) false_ (Var.Set.union q1.us q2.us)
| {us= _; xs= _; ctx; pure; heap= []; djns= []}, _ | {us= _; xs= _; ctx; pure; heap= []; djns= []}, _
when Context.is_empty ctx && Formula.is_true pure -> when Context.is_empty ctx && Formula.(equal tt pure) ->
let us = Var.Set.union q1.us q2.us in let us = Var.Set.union q1.us q2.us in
if us == q2.us then q2 else {q2 with us} if us == q2.us then q2 else {q2 with us}
| _, {us= _; xs= _; ctx; pure; heap= []; djns= []} | _, {us= _; xs= _; ctx; pure; heap= []; djns= []}
when Context.is_empty ctx && Formula.is_true pure -> when Context.is_empty ctx && Formula.(equal tt pure) ->
let us = Var.Set.union q1.us q2.us in let us = Var.Set.union q1.us q2.us in
if us == q1.us then q1 else {q1 with us} if us == q1.us then q1 else {q1 with us}
| _ -> | _ ->
@ -496,11 +496,11 @@ let or_ q1 q2 =
| _, {djns= [[]]; _} -> extend_us q2.us q1 | _, {djns= [[]]; _} -> extend_us q2.us q1
| ( ({djns= []; _} as q) | ( ({djns= []; _} as q)
, ({us= _; xs; ctx= _; pure; heap= []; djns= [djn]} as d) ) , ({us= _; xs; ctx= _; pure; heap= []; djns= [djn]} as d) )
when Var.Set.is_empty xs && Formula.is_true pure -> when Var.Set.is_empty xs && Formula.(equal tt pure) ->
{d with us= Var.Set.union q.us d.us; djns= [q :: djn]} {d with us= Var.Set.union q.us d.us; djns= [q :: djn]}
| ( ({us= _; xs; ctx= _; pure; heap= []; djns= [djn]} as d) | ( ({us= _; xs; ctx= _; pure; heap= []; djns= [djn]} as d)
, ({djns= []; _} as q) ) , ({djns= []; _} as q) )
when Var.Set.is_empty xs && Formula.is_true pure -> when Var.Set.is_empty xs && Formula.(equal tt pure) ->
{d with us= Var.Set.union q.us d.us; djns= [q :: djn]} {d with us= Var.Set.union q.us d.us; djns= [q :: djn]}
| _ -> | _ ->
{ us= Var.Set.union q1.us q2.us { us= Var.Set.union q1.us q2.us

Loading…
Cancel
Save