- NCicUtils.Subst_not_found _ -> None
- in
- (match meta_chain with
- Some (_,_,bo,_) ->
- aux k ms (NCicSubstitution.subst_meta l bo)
- | None ->
- (* we ignore the subst since restrict will take care of already
- * instantiated/restricted metavariabels *)
- let (metasenv,subst as ms), restrictions_for_n, l' =
- let l = NCicUtils.expand_local_context lc in
-
- 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)
- in
- if restrictions_for_n = [] then
- ms, if l = l' then orig else NCic.Meta (n, l')
- else
- let metasenv, subst, newmeta =
- restrict metasenv subst n restrictions_for_n
- in
- (metasenv, subst), NCic.Meta (newmeta, l'))
+ NCicUtils.Subst_not_found _ ->
+ (* we ignore the subst since restrict will take care of already
+ * instantiated/restricted metavariabels *)
+ let l = NCicUtils.expand_local_context lc in
+ let sl = List.map (NCicSubstitution.lift shift) l in
+ let (metasenv,subst as ms), _, restrictions_for_n, l' =
+ List.fold_right
+ (fun t (ms, i, restrictions_for_n, l) ->
+ try
+ (*pp (lazy ("L'ORLO DELLA FOSSA: k= " ^ string_of_int k ^ " shift=" ^
+ string_of_int shift ^ " t=" ^ NCicPp.ppterm ~metasenv ~subst ~context:[] t));*)
+ let ms, t = aux k ms t in
+ (*pp (lazy ("LA FOSSA: " ^ NCicPp.ppterm ~metasenv ~subst ~context:[] t));*)
+ ms, i-1, restrictions_for_n, t::l
+ with Occur ->
+ ms, i-1, i::restrictions_for_n, l)
+ sl (ms, List.length l, [], [])
+ in
+ if restrictions_for_n = [] then
+ ms, if sl = l' then orig else (
+ (*pp (lazy ("FINITO: " ^ NCicPp.ppterm ~metasenv:[] ~subst:[]
+ ~context:[] (NCic.Meta (n,pack_lc (0, NCic.Ctx l')))));*)
+ NCic.Meta (n, pack_lc (0, NCic.Ctx l'))
+ )
+ else
+ let l' = pack_lc (0, NCic.Ctx l') in
+ let _ = pp (lazy ("restrictions for n are:" ^ String.concat "," (List.map string_of_int restrictions_for_n))) in
+ let metasenv, subst, newmeta, more_restricted =
+ restrict metasenv subst n restrictions_for_n in
+ let _ = pp (lazy ("more restricted: " ^String.concat "," (List.map string_of_int more_restricted))) in
+ let l' = purge_restricted restrictions more_restricted l' in
+ (metasenv, subst), NCic.Meta (newmeta, l'))