+ subst
+;;
+
+ let alpha_eq s t =
+ let rec equiv subst s t =
+ let s = match s with Terms.Var i -> Subst.lookup i subst | _ -> s
+ and t = match t with Terms.Var i -> Subst.lookup i subst | _ -> t
+
+ in
+ match s, t with
+ | s, t when U.eq_foterm s t -> subst
+ | Terms.Var i, Terms.Var j
+ when (not (List.exists (fun (_,k) -> k=t) subst)) ->
+ let subst = Subst.build_subst i t subst in
+ subst
+ | Terms.Node l1, Terms.Node l2 -> (
+ try
+ List.fold_left2
+ (fun subst' s t -> equiv subst' s t)
+ subst l1 l2
+ with Invalid_argument _ ->
+ raise (UnificationFailure (lazy "Inference.unification.unif"))
+ )
+ | _, _ ->
+ raise (UnificationFailure (lazy "Inference.unification.unif"))
+ in
+ equiv Subst.id_subst s t
+;;
+