let lookup = Subst.lookup_subst in
let rec occurs_check subst what where =
match where with
- | t when what = t -> true
+ | Cic.Meta(i,_) when i = what -> true
| C.Appl l -> List.exists (occurs_check subst what) l
| C.Meta _ ->
let t = lookup where subst in
in
match s, t with
| s, t when s = t -> subst, menv
+ (* sometimes the same meta has different local contexts; this
+ could create "cyclic" substitutions *)
+ | C.Meta (i, _), C.Meta (j, _) when i=j -> subst, menv
| C.Meta (i, _), C.Meta (j, _)
when (locked locked_menv i) &&(locked locked_menv j) ->
raise
unif subst menv t s
| C.Meta (i, _), C.Meta (j, _) when (i > j) && not (locked locked_menv j) ->
unif subst menv t s
- | C.Meta _, t when occurs_check subst s t ->
+ | C.Meta (i,_), t when occurs_check subst i t ->
raise
(U.UnificationFailure (lazy "Inference.unification.unif"))
| C.Meta (i, l), t when (locked locked_menv i) ->