otherwise the occur check does not make sense in case of unification
of ?n with ?n *)
let delift ~unify metasenv subst context n l t =
+ let is_in_scope_meta subst = function
+ | NCic.Meta (i,_) ->
+ (try
+ let tag, _, _, _ = NCicUtils.lookup_subst i subst in
+ tag = Some in_scope_tag
+ with NCicUtils.Subst_not_found _ -> false)
+ | _ -> false
+ in
let unify_list in_scope =
match l with
| _, NCic.Irl _ -> fun _ _ _ _ _ -> None
| shift, NCic.Ctx l -> fun metasenv subst context k t ->
- if flexible_arg subst t then None else
+ if flexible_arg subst t || is_in_scope_meta subst t then None else
let lb = List.map (fun t -> t, flexible_arg subst t) l in
HExtlib.list_findopt
(fun (li,flexible) i ->
(NCicPp.ppterm ~context ~metasenv ~subst t))))
| NCic.Meta (i,l1) as orig ->
(try
- let tag,_,t,_ = NCicUtils.lookup_subst i subst in
- let in_scope =
+ let tag,c,t,ty = NCicUtils.lookup_subst i subst in
+ let in_scope, clear =
match tag with
- | Some tag when tag = in_scope_tag -> 0
- | Some tag when is_out_scope_tag tag -> int_of_out_scope_tag tag
- | _ -> in_scope
+ | Some tag when tag = in_scope_tag -> 0, true
+ | Some tag when is_out_scope_tag tag->int_of_out_scope_tag tag,true
+ | _ -> in_scope, false
+ in
+ let ms =
+ if not clear then ms
+ else
+ metasenv,
+ (i,(None,c,t,ty)) :: List.filter (fun j,_ -> i <> j) subst
in
aux (context,k,in_scope) ms (NCicSubstitution.subst_meta l1 t)
with NCicUtils.Subst_not_found _ ->