- | C.Meta (i,(s,C.Ctx l)) ->
- let l1 = HExtlib.sharing_map (aux (k-s)) l in
- if l1 == l then t else C.Meta (i,(s,C.Ctx l1))
- | C.Meta _ -> t
+ | C.Meta (i,(s,l)) ->
+ (try
+ let _,_,term,_ = U.lookup_subst i subst in
+ let ts = S.subst_meta (0,l) term in
+ let ts' = aux (k-s) ts in
+ if ts == ts' then t else ts'
+ with U.Subst_not_found _ ->
+ match l with
+ C.Ctx l ->
+ let l1 = HExtlib.sharing_map (aux (k-s)) l in
+ if l1 == l then t else C.Meta (i,(s,C.Ctx l1))
+ | _ -> t)