[sledge] Change to normal argument order for Set.mem

Reviewed By: jvillard

Differential Revision: D24532360

fbshipit-source-id: d711d6725
master
Josh Berdine 4 years ago committed by Facebook GitHub Bot
parent 54f6b9e974
commit 1da536ebe5

@ -40,7 +40,7 @@ end) : S with type elt = Elt.t = struct
let union_list ss = List.fold ~f:union ss empty
let is_empty = S.is_empty
let cardinal = S.cardinal
let mem s x = S.mem x s
let mem = S.mem
let subset s ~of_:t = S.subset s t
let disjoint = S.disjoint
let max_elt = S.max_elt_opt

@ -36,7 +36,7 @@ module type S = sig
val is_empty : t -> bool
val cardinal : t -> int
val mem : t -> elt -> bool
val mem : elt -> t -> bool
val subset : t -> of_:t -> bool
val disjoint : t -> t -> bool
val max_elt : t -> elt option

@ -300,7 +300,8 @@ struct
(* solve *)
let exists_fv_in vs poly = Iter.exists ~f:(Var.Set.mem vs) (vars poly)
let exists_fv_in vs poly =
Iter.exists ~f:(fun v -> Var.Set.mem v vs) (vars poly)
(** [solve_for_mono r c m p] solves [0 = r + (c×m) + p] as [m = q]
([Some (m, q)]) such that [r + (c×m) + p = m - q] *)

@ -542,7 +542,7 @@ let set_derived_metadata functions =
else
let ancestors = Block_label.Set.add src ancestors in
let jump jmp =
if Block_label.Set.mem ancestors jmp.dst then
if Block_label.Set.mem jmp.dst ancestors then
jmp.retreating <- true
else visit ancestors func jmp.dst
in
@ -557,7 +557,7 @@ let set_derived_metadata functions =
Func.find (Reg.name reg) functions
with
| Some func ->
if Block_label.Set.mem ancestors func.entry then
if Block_label.Set.mem func.entry ancestors then
call.recursive <- true
else visit ancestors func func.entry
| None ->

@ -139,7 +139,7 @@ end = struct
[ys xs]. *)
let is_valid_eq xs e f =
let is_var_in xs e =
Option.exists ~f:(Var.Set.mem xs) (Var.of_term e)
Option.exists ~f:(fun x -> Var.Set.mem x xs) (Var.of_term e)
in
( is_var_in xs e
|| is_var_in xs f
@ -280,14 +280,14 @@ and solve_ ?f d e s =
| Some m -> solve_ ?f n m s )
>>= solve_ ?f a b
| Some ((Var _ as v), (Ap3 (Extract, _, _, l) as e)) ->
if not (Var.Set.mem (Term.fv e) (Var.of_ v)) then
if not (Var.Set.mem (Var.of_ v) (Term.fv e)) then
(* v = α[o,l) ==> v ↦ α[o,l) when v ∉ fv(α[o,l)) *)
compose1 ?f ~var:v ~rep:e s
else
(* v = α[o,l) ==> α[o,l) ↦ ⟨l,v⟩ when v ∈ fv(α[o,l)) *)
compose1 ?f ~var:e ~rep:(Term.sized ~siz:l ~seq:v) s
| Some ((Var _ as v), (ApN (Concat, a0V) as c)) ->
if not (Var.Set.mem (Term.fv c) (Var.of_ v)) then
if not (Var.Set.mem (Var.of_ v) (Term.fv c)) then
(* v = α₀^…^αᵥ ==> v ↦ α₀^…^αᵥ when v ∉ fv(α₀^…^αᵥ) *)
compose1 ?f ~var:v ~rep:c s
else

@ -1170,7 +1170,8 @@ let rec height = function
(** Solve *)
let exists_fv_in vs qset =
Qset.exists qset ~f:(fun e _ -> exists_vars e ~f:(Var.Set.mem vs))
Qset.exists qset ~f:(fun e _ ->
exists_vars e ~f:(fun v -> Var.Set.mem v vs) )
(* solve [0 = rejected_sum + (coeff × mono) + sum] *)
let solve_for_mono rejected_sum coeff mono sum =

@ -69,7 +69,7 @@ module Make (T : REPR) = struct
Map.fold s (Set.empty, Set.empty)
~f:(fun ~key ~data (domain, range) ->
(* substs are injective *)
assert (not (Set.mem range data)) ;
assert (not (Set.mem data range)) ;
(Set.add key domain, Set.add data range) )
in
assert (Set.disjoint domain range)
@ -105,13 +105,13 @@ module Make (T : REPR) = struct
let restrict sub vs =
Map.fold sub {sub; dom= Set.empty; rng= Set.empty}
~f:(fun ~key ~data z ->
if Set.mem vs key then
if Set.mem key vs then
{z with dom= Set.add key z.dom; rng= Set.add data z.rng}
else (
assert (
(* all substs are injective, so the current mapping is the
only one that can cause [data] to be in [rng] *)
(not (Set.mem (range (Map.remove key sub)) data))
(not (Set.mem data (range (Map.remove key sub))))
|| violates invariant sub ) ;
{z with sub= Map.remove key z.sub} ) )
|> check (fun {sub; dom; rng} ->

@ -97,7 +97,7 @@ let rec var_strength_ xs m q =
let xs = Var.Set.union xs q.xs in
let m_stem =
fold_vars_stem ~ignore_ctx:() q m ~f:(fun var m ->
if not (Var.Set.mem xs var) then
if not (Var.Set.mem var xs) then
Var.Map.add ~key:var ~data:`Universal m
else add var m )
in

Loading…
Cancel
Save