- let more_to_be_restricted = ref [] in
- let l' =
- let i = ref 0 in
- HExtlib.map_option
- (fun t ->
- incr i ;
- try
- let (*subst, metasenv,*) t = aux k t in Some t
- with Occur ->
- more_to_be_restricted := !i :: !more_to_be_restricted; None)
- l
+ let (metasenv,subst as ms), restrictions_for_n, l' =
+ match l with
+ | shift, NCic.Irl len ->
+ let restrictions =
+ List.filter
+ (fun i -> i > shift && i <= shift + len) restrictions in
+ ms, restrictions, mk_restricted_irl shift len restrictions
+ | shift, NCic.Ctx l ->
+ let ms, _, restrictions_for_n, l =
+ List.fold_right
+ (fun t (ms, i, restrictions_for_n, l) ->
+ try
+ let ms, t = aux (k-shift) ms t in
+ ms, i-1, restrictions_for_n, t::l
+ with Occur ->
+ ms, i-1, i::restrictions_for_n, l)
+ l (ms, List.length l, [], [])
+ in
+ ms, restrictions_for_n, pack_lc (shift, NCic.Ctx l)