returns true if target is subsumed by some equality in table
*)
let subsumption_aux use_unification env table target =
- (*
- let print_res l =
- prerr_endline (String.concat "\n" (List.map (fun (_, subst, menv, ug,
- ((pos,equation),_)) -> Inference.string_of_equality equation)l))
- in
- *)
+(* let print_res l =*)
+(* prerr_endline (String.concat "\n" (List.map (fun (_, subst, menv, ug,*)
+(* ((pos,equation),_)) -> Equality.string_of_equality equation)l))*)
+(* in*)
let _, _, (ty, left, right, _), tmetas, _ = Equality.open_equality target in
let metasenv, context, ugraph = env in
let metasenv = tmetas in
+ let predicate, unif_fun =
+ if use_unification then
+ Unification, Inference.unification
+ else
+ Matching, Inference.matching
+ in
let leftr =
match left with
- | Cic.Meta _ -> []
+ | Cic.Meta _ when not use_unification -> []
| _ ->
- let leftc = get_candidates Matching table left in
- find_all_matches ~unif_fun:Inference.matching
+ let leftc = get_candidates predicate table left in
+ find_all_matches ~unif_fun
metasenv context ugraph 0 left ty leftc
in
(* print_res leftr;*)
let subst', menv', ug' =
let t1 = Unix.gettimeofday () in
try
- let r =
- if use_unification then
- Inference.unification metasenv m context what other ugraph
- else
- Inference.matching metasenv m context what other ugraph
- in
+ let other = Subst.apply_subst subst other in
+ let r = unif_fun metasenv m context what other ugraph in
let t2 = Unix.gettimeofday () in
match_unif_time_ok := !match_unif_time_ok +. (t2 -. t1);
r
- with Inference.MatchingFailure as e ->
+ with
+ | Inference.MatchingFailure
+ | CicUnification.UnificationFailure _ as e ->
let t2 = Unix.gettimeofday () in
match_unif_time_no := !match_unif_time_no +. (t2 -. t1);
raise e
(match Subst.merge_subst_if_possible subst subst' with
| None -> ok what tl
| Some s -> Some (s, equation))
- with Inference.MatchingFailure ->
- ok what tl
+ with
+ | Inference.MatchingFailure
+ | CicUnification.UnificationFailure _ -> ok what tl
in
match ok right leftr with
| Some _ as res -> res
| None ->
let rightr =
match right with
- | Cic.Meta _ -> []
+ | Cic.Meta _ when not use_unification -> []
| _ ->
- let rightc = get_candidates Matching table right in
- find_all_matches ~unif_fun:Inference.matching
+ let rightc = get_candidates predicate table right in
+ find_all_matches ~unif_fun
metasenv context ugraph 0 right ty rightc
in
(* print_res rightr;*)