+
+let get_first_args var =
+let rec aux l = function
+| `Lam(_,t) -> aux (l+1) t
+| `Match(u,orig,liftno,bs,args) -> Util.concat_map (aux l) args
+| `I((n,_), args) -> if n = var + l then [Listx.last args] else []
+| `N _
+| `Var _ -> []
+in aux 0
+;;
+
+let compute_arities m =
+ let rec aux n tms =
+ if n = 0
+ then []
+ else
+ let tms = Util.filter_map (function `Lam(_,t) -> Some t | _ -> None ) tms in
+ let arity = max 0 (max_arity_tms (m-n) tms) in (* FIXME: 0 or -1 ??? *)
+ arity :: (aux (n-1) tms)
+ in fun tms -> List.rev (aux m tms)
+;;
+
+let compute_arities var special_k all_tms =
+ let tms = List.fold_left (fun acc t -> acc @ (get_first_args var t)) [] all_tms in
+ compute_arities special_k tms
+;;