From 8fa2f86b7e9994f31ef5214ab5254135826b45cd Mon Sep 17 00:00:00 2001 From: Josh Berdine Date: Thu, 28 Feb 2019 06:45:34 -0800 Subject: [PATCH] [sledge] Fix order of Exp.fold args Reviewed By: ngorogiannis Differential Revision: D14251654 fbshipit-source-id: 8d1e22da7 --- sledge/src/llair/exp.ml | 12 ++++-------- sledge/src/llair/exp.mli | 2 +- sledge/src/symbheap/congruence.ml | 2 +- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/sledge/src/llair/exp.ml b/sledge/src/llair/exp.ml index 83ec1cf4e..f13d518e7 100644 --- a/sledge/src/llair/exp.ml +++ b/sledge/src/llair/exp.ml @@ -1039,17 +1039,13 @@ let iter e ~f = let fold e ~init:s ~f = match e with - | App {op; arg} -> - let s = f s op in - let s = f s arg in - s + | App {op; arg} -> f op (f arg s) | Add {args} | Mul {args} -> - let s = Qset.fold ~f:(fun e _ s -> f s e) args ~init:s in - s + Qset.fold ~f:(fun e _ s -> f e s) args ~init:s | _ -> s -let for_all e ~f = fold ~f:(fun so_far a -> so_far && f a) ~init:true e -let exists e ~f = fold ~f:(fun found a -> found || f a) ~init:false e +let for_all e ~f = fold ~f:(fun a so_far -> so_far && f a) ~init:true e +let exists e ~f = fold ~f:(fun a found -> found || f a) ~init:false e let app1 ?(partial = false) op arg = ( match (op, arg) with diff --git a/sledge/src/llair/exp.mli b/sledge/src/llair/exp.mli index 216b5274a..d55e8fee4 100644 --- a/sledge/src/llair/exp.mli +++ b/sledge/src/llair/exp.mli @@ -204,7 +204,7 @@ val offset : t -> (Q.t * Typ.t) option val iter : t -> f:(t -> unit) -> unit val fold_vars : t -> init:'a -> f:('a -> Var.t -> 'a) -> 'a val fold_exps : t -> init:'a -> f:('a -> t -> 'a) -> 'a -val fold : t -> init:'a -> f:('a -> t -> 'a) -> 'a +val fold : t -> init:'a -> f:(t -> 'a -> 'a) -> 'a val for_all : t -> f:(t -> bool) -> bool val exists : t -> f:(t -> bool) -> bool diff --git a/sledge/src/symbheap/congruence.ml b/sledge/src/symbheap/congruence.ml index 6095740e4..7292d463b 100644 --- a/sledge/src/symbheap/congruence.ml +++ b/sledge/src/symbheap/congruence.ml @@ -551,7 +551,7 @@ let rec norm_extend r ek = ~default:e ~if_added:(fun lkp -> let use = - Exp.fold e_' ~init:r.use ~f:(fun use b'j -> + Exp.fold e_' ~init:r.use ~f:(fun b'j use -> let b' = Exp.base b'j in Map.update use b' ~f:(function | Some b_use -> Use.add b_use e