;;
let print ?(l=[]) = string_of_term l;;
-let string_of_nf t = string_of_term [] (t:>nf);;
(************ Hereditary substitutions ************************************)
;;
let eta_subterm (#nf as x) (#nf as y) = eta_subterm x y;;
+
+let compute_special_k tms =
+ let rec aux k (t: nf) = Pervasives.max k (match t with
+ | `Lam(b,t) -> aux (k + if b then 1 else 0) t
+ | `I(n, tms) -> Listx.max (Listx.map (aux 0) tms)
+ | `Match(t, liftno, bs, args) ->
+ List.fold_left max 0 (List.map (aux 0) ((t :> nf)::args@List.map snd !bs))
+ | `N _ -> 0
+ | `Var _ -> 0
+ ) in Listx.max (Listx.map (aux 0) tms)
+;;