-(*
- let rec deeply_subsumed ~unify bag maxvar (id, lit, vl, _) table =
- match lit with
- | Terms.Predicate _ -> assert false
- | Terms.Equation (l,r,ty,_) ->
- (match is_subsumed ~unify bag maxvar (id, lit, vl, _) table with
- | Some((bag,maxvar),c) -> Some((bag,maxvar),c)
- | None ->
- match l,r with ->
- Var i, _ ->
+ let rec deep_eq ~unify l r ty pos contextl contextr table acc =
+ match acc with
+ | None -> None
+ | Some(bag,maxvar,(id,lit,vl,p),subst) ->
+ (* prerr_endline ("input subst = "^Pp.pp_substitution subst); *)
+ let l = Subst.apply_subst subst l in
+ let r = Subst.apply_subst subst r in
+ try
+ let subst1 = Unif.unification (* vl *) [] l r in
+ let lit =
+ match lit with Terms.Predicate _ -> assert false
+ | Terms.Equation (l,r,ty,o) ->
+ Terms.Equation (FoSubst.apply_subst subst1 l,
+ FoSubst.apply_subst subst1 r, ty, o)
+ in
+ Some(bag,maxvar,(id,lit,vl,p),Subst.concat subst1 subst)
+ with FoUnif.UnificationFailure _ ->
+ match rewrite_eq ~unify l r ty vl table with
+ | Some (id2, dir, subst1) ->
+ (* prerr_endline ("subst1 = "^Pp.pp_substitution subst1);
+ prerr_endline ("old subst = "^Pp.pp_substitution subst);*)
+ let newsubst = Subst.concat subst1 subst in
+ let id_t =
+ FoSubst.apply_subst newsubst
+ (Terms.Node[Terms.Leaf B.eqP;ty;contextl r;contextr r])
+ in
+ (match
+ build_new_clause_reloc bag maxvar (fun _ -> true)
+ Terms.Superposition id_t
+ subst1 id id2 (pos@[2]) dir
+ with
+ | Some ((bag, maxvar), c), r ->
+ (* prerr_endline ("r = "^Pp.pp_substitution r); *)
+ let newsubst = Subst.flat
+ (Subst.concat r subst) in
+ Some(bag,maxvar,c,newsubst)
+ | None, _ -> assert false)
+ | None ->
+ match l,r with
+ | Terms.Node (a::la), Terms.Node (b::lb) when
+ a = b && List.length la = List.length lb ->
+ let acc,_,_,_ =
+ List.fold_left2
+ (fun (acc,pre,postl,postr) a b ->
+ let newcl =
+ fun x -> contextl(Terms.Node (pre@(x::postl))) in
+ let newcr =
+ fun x -> contextr(Terms.Node (pre@(x::postr))) in
+ let newpos = List.length pre::pos in
+ let footail l =
+ if l = [] then [] else List.tl l in
+ (deep_eq ~unify a b ty
+ newpos newcl newcr table acc,pre@[b],
+ footail postl, footail postr))
+ (acc,[a],List.tl la,List.tl lb) la lb
+ in acc
+ | _,_ -> None