+let sum_arities p =
+ let rec aux = function
+ | `N _ -> 0
+ | `Var(_,ar) -> if ar = min_int then 0 else (assert (ar >= 0); ar)
+ | `Lam(_,t) -> aux t
+ | `I(v,args) -> aux (`Var v) + aux_many (Listx.to_list args)
+ | `Match(u,v,_,_,args) -> (*aux (u :> nf) +*) aux (`Var v) + aux_many args
+ and aux_many tms = List.fold_right ((+) ++ aux) tms 0 in
+ aux_many (all_terms p :> nf list)
+ ;;
+
+let count_fakevars p =
+ let rec aux = function
+ | `N _ -> 0
+ | `Var(_,ar) -> if ar = min_int then 1 else 0
+ | `Lam(_,t) -> aux t
+ | `I(v,args) -> aux (`Var v) + aux_many (Listx.to_list args)
+ | `Match(u,v,_,_,args) -> (*aux (u :> nf) +*) aux (`Var v) + aux_many args
+ and aux_many tms = List.fold_right ((+) ++ aux) tms 0 in
+ aux_many (all_terms p :> nf list)
+;;
+
+(* let problem_measure p = count_fakevars p, sum_arities p;;
+let string_of_measure (a,b) = "(fakevars="^string_of_int a^",sum_arities="^string_of_int b^")" *)
+
+let problem_measure p = sum_arities p;;
+let string_of_measure = string_of_int;;