2 let debug_print = Utils.debug_print;;
5 type retrieval_mode = Matching | Unification;;
8 let print_candidates mode term res =
12 Printf.printf "| candidates Matching %s\n" (CicPp.ppterm term)
14 Printf.printf "| candidates Unification %s\n" (CicPp.ppterm term)
20 Printf.sprintf "| (%s, %s)" (Utils.string_of_pos p)
21 (Inference.string_of_equality e))
27 let indexing_retrieval_time = ref 0.;;
30 (* let my_apply_subst subst term = *)
31 (* let module C = Cic in *)
32 (* let lookup lift_amount meta = *)
34 (* | C.Meta (i, _) -> ( *)
36 (* let _, (_, t, _) = List.find (fun (m, _) -> m = i) subst in *)
37 (* (\* CicSubstitution.lift lift_amount *\)t *)
38 (* with Not_found -> meta *)
40 (* | _ -> assert false *)
42 (* let rec apply_aux lift_amount = function *)
43 (* | C.Meta (i, l) as t -> lookup lift_amount t *)
44 (* | C.Appl l -> C.Appl (List.map (apply_aux lift_amount) l) *)
45 (* | C.Prod (nn, s, t) -> *)
46 (* C.Prod (nn, apply_aux lift_amount s, apply_aux (lift_amount+1) t) *)
47 (* | C.Lambda (nn, s, t) -> *)
48 (* C.Lambda (nn, apply_aux lift_amount s, apply_aux (lift_amount+1) t) *)
51 (* apply_aux 0 term *)
55 (* let apply_subst subst term = *)
56 (* Printf.printf "| apply_subst:\n| subst: %s\n| term: %s\n" *)
57 (* (Utils.print_subst ~prefix:" ; " subst) (CicPp.ppterm term); *)
58 (* let res = my_apply_subst subst term in *)
59 (* (\* let res = CicMetaSubst.apply_subst subst term in *\) *)
60 (* Printf.printf "| res: %s\n" (CicPp.ppterm res); *)
61 (* print_endline "|"; *)
65 (* let apply_subst = my_apply_subst *)
66 let apply_subst = CicMetaSubst.apply_subst
70 let profile = CicUtil.profile "apply_subst" in
71 (fun s a -> profile (apply_subst s) a)
77 Path_indexing.PSTrie.empty
80 let index = Path_indexing.index
81 and remove_index = Path_indexing.remove_index
82 and in_index = Path_indexing.in_index;;
84 let get_candidates mode trie term =
85 let t1 = Unix.gettimeofday () in
89 | Matching -> Path_indexing.retrieve_generalizations trie term
90 | Unification -> Path_indexing.retrieve_unifiables trie term
91 (* Path_indexing.retrieve_all trie term *)
93 Path_indexing.PosEqSet.elements s
95 (* print_candidates mode term res; *)
96 let t2 = Unix.gettimeofday () in
97 indexing_retrieval_time := !indexing_retrieval_time +. (t2 -. t1);
104 Discrimination_tree.DiscriminationTree.empty
107 let index = Discrimination_tree.index
108 and remove_index = Discrimination_tree.remove_index
109 and in_index = Discrimination_tree.in_index;;
111 let get_candidates mode tree term =
112 let t1 = Unix.gettimeofday () in
116 | Matching -> Discrimination_tree.retrieve_generalizations tree term
117 | Unification -> Discrimination_tree.retrieve_unifiables tree term
119 Discrimination_tree.PosEqSet.elements s
121 (* print_candidates mode term res; *)
122 (* print_endline (Discrimination_tree.string_of_discrimination_tree tree); *)
123 (* print_newline (); *)
124 let t2 = Unix.gettimeofday () in
125 indexing_retrieval_time := !indexing_retrieval_time +. (t2 -. t1);
130 (* let get_candidates = *)
131 (* let profile = CicUtil.profile "Indexing.get_candidates" in *)
132 (* (fun mode tree term -> profile (get_candidates mode tree) term) *)
136 let match_unif_time_ok = ref 0.;;
137 let match_unif_time_no = ref 0.;;
140 let rec find_matches metasenv context ugraph lift_amount term =
141 let module C = Cic in
142 let module U = Utils in
143 let module S = CicSubstitution in
144 let module M = CicMetaSubst in
145 let module HL = HelmLibraryObjects in
146 let cmp = !Utils.compare_terms in
147 let names = Utils.names_of_context context in
149 CicTypeChecker.type_of_aux' metasenv context term ugraph
154 let pos, (_, proof, (ty, left, right, o), metas, args) = candidate in
155 if not (fst (CicReduction.are_convertible
156 ~metasenv context termty ty ugraph)) then (
158 Printf.sprintf "CANDIDATE HAS WRONG TYPE: %s required, %s found"
159 (CicPp.pp termty names) (CicPp.pp ty names));
160 find_matches metasenv context ugraph lift_amount term tl
162 let do_match c other eq_URI =
163 let subst', metasenv', ugraph' =
164 let t1 = Unix.gettimeofday () in
167 Inference.matching (metasenv @ metas) context
168 term (S.lift lift_amount c) ugraph in
169 let t2 = Unix.gettimeofday () in
170 match_unif_time_ok := !match_unif_time_ok +. (t2 -. t1);
173 let t2 = Unix.gettimeofday () in
174 match_unif_time_no := !match_unif_time_no +. (t2 -. t1);
177 Some (C.Rel (1 + lift_amount), subst', metasenv', ugraph',
180 let c, other, eq_URI =
181 if pos = Utils.Left then left, right, HL.Logic.eq_ind_URI
182 else right, left, HL.Logic.eq_ind_r_URI
184 if o <> U.Incomparable then
186 do_match c other eq_URI
188 find_matches metasenv context ugraph lift_amount term tl
190 let res = try do_match c other eq_URI with e -> None in
192 | Some (_, s, _, _, _) ->
193 let c' = (* M. *)apply_subst s c
194 and other' = (* M. *)apply_subst s other in
195 let order = cmp c' other' in
196 let names = U.names_of_context context in
200 find_matches metasenv context ugraph lift_amount term tl
202 find_matches metasenv context ugraph lift_amount term tl
206 let rec find_all_matches ?(unif_fun=Inference.unification)
207 metasenv context ugraph lift_amount term =
208 let module C = Cic in
209 let module U = Utils in
210 let module S = CicSubstitution in
211 let module M = CicMetaSubst in
212 let module HL = HelmLibraryObjects in
213 let cmp = !Utils.compare_terms in
214 let names = Utils.names_of_context context in
216 CicTypeChecker.type_of_aux' metasenv context term ugraph
221 let pos, (_, _, (ty, left, right, o), metas, args) = candidate in
222 if not (fst (CicReduction.are_convertible
223 ~metasenv context termty ty ugraph)) then (
225 Printf.sprintf "CANDIDATE HAS WRONG TYPE: %s required, %s found"
226 (CicPp.pp termty names) (CicPp.pp ty names));
227 find_all_matches ~unif_fun metasenv context ugraph
230 let do_match c other eq_URI =
231 let subst', metasenv', ugraph' =
232 let t1 = Unix.gettimeofday () in
235 unif_fun (metasenv @ metas) context
236 term (S.lift lift_amount c) ugraph in
237 let t2 = Unix.gettimeofday () in
238 match_unif_time_ok := !match_unif_time_ok +. (t2 -. t1);
241 let t2 = Unix.gettimeofday () in
242 match_unif_time_no := !match_unif_time_no +. (t2 -. t1);
245 (C.Rel (1 + lift_amount), subst', metasenv', ugraph',
248 let c, other, eq_URI =
249 if pos = Utils.Left then left, right, HL.Logic.eq_ind_URI
250 else right, left, HL.Logic.eq_ind_r_URI
252 if o <> U.Incomparable then
254 let res = do_match c other eq_URI in
255 res::(find_all_matches ~unif_fun metasenv context ugraph
258 find_all_matches ~unif_fun metasenv context ugraph
262 let res = do_match c other eq_URI in
265 let c' = (* M. *)apply_subst s c
266 and other' = (* M. *)apply_subst s other in
267 let order = cmp c' other' in
268 let names = U.names_of_context context in
269 if order <> U.Lt && order <> U.Le then
270 res::(find_all_matches ~unif_fun metasenv context ugraph
273 find_all_matches ~unif_fun metasenv context ugraph
276 find_all_matches ~unif_fun metasenv context ugraph
281 let subsumption env table target =
282 let _, (ty, left, right, _), tmetas, _ = target in
283 let metasenv, context, ugraph = env in
284 let metasenv = metasenv @ tmetas in
285 let samesubst subst subst' =
286 let tbl = Hashtbl.create (List.length subst) in
287 List.iter (fun (m, (c, t1, t2)) -> Hashtbl.add tbl m (c, t1, t2)) subst;
289 (fun (m, (c, t1, t2)) ->
291 let c', t1', t2' = Hashtbl.find tbl m in
292 if (c = c') && (t1 = t1') && (t2 = t2') then true
302 let leftc = get_candidates Matching table left in
303 find_all_matches ~unif_fun:Inference.matching
304 metasenv context ugraph 0 left leftc
306 let ok what (_, subst, menv, ug, ((pos, (_, _, (_, l, r, o), _, _)), _)) =
308 let other = if pos = Utils.Left then r else l in
309 let subst', menv', ug' =
310 let t1 = Unix.gettimeofday () in
313 Inference.matching metasenv context what other ugraph in
314 let t2 = Unix.gettimeofday () in
315 match_unif_time_ok := !match_unif_time_ok +. (t2 -. t1);
318 let t2 = Unix.gettimeofday () in
319 match_unif_time_no := !match_unif_time_no +. (t2 -. t1);
322 samesubst subst subst'
326 let r = List.exists (ok right) leftr in
334 let rightc = get_candidates Matching table right in
335 find_all_matches ~unif_fun:Inference.matching
336 metasenv context ugraph 0 right rightc
338 List.exists (ok left) rightr
342 let rec demodulate_term metasenv context ugraph table lift_amount term =
343 let module C = Cic in
344 let module S = CicSubstitution in
345 let module M = CicMetaSubst in
346 let module HL = HelmLibraryObjects in
347 let candidates = get_candidates Matching table term in
352 find_matches metasenv context ugraph lift_amount term candidates
363 (res, tl @ [S.lift 1 t])
366 demodulate_term metasenv context ugraph table
370 | None -> (None, tl @ [S.lift 1 t])
371 | Some (rel, _, _, _, _) -> (r, tl @ [rel]))
376 | Some (_, subst, menv, ug, eq_found) ->
377 Some (C.Appl ll, subst, menv, ug, eq_found)
379 | C.Prod (nn, s, t) ->
381 demodulate_term metasenv context ugraph table lift_amount s in (
385 demodulate_term metasenv
386 ((Some (nn, C.Decl s))::context) ugraph
387 table (lift_amount+1) t
391 | Some (t', subst, menv, ug, eq_found) ->
392 Some (C.Prod (nn, (S.lift 1 s), t'),
393 subst, menv, ug, eq_found)
395 | Some (s', subst, menv, ug, eq_found) ->
396 Some (C.Prod (nn, s', (S.lift 1 t)),
397 subst, menv, ug, eq_found)
404 let build_ens_for_sym_eq ty x y =
405 [(UriManager.uri_of_string
406 "cic:/Coq/Init/Logic/Logic_lemmas/equality/A.var", ty);
407 (UriManager.uri_of_string
408 "cic:/Coq/Init/Logic/Logic_lemmas/equality/x.var", x);
409 (UriManager.uri_of_string
410 "cic:/Coq/Init/Logic/Logic_lemmas/equality/y.var", y)]
414 let build_newtarget_time = ref 0.;;
417 let demod_counter = ref 1;;
419 let rec demodulation newmeta env table sign target =
420 let module C = Cic in
421 let module S = CicSubstitution in
422 let module M = CicMetaSubst in
423 let module HL = HelmLibraryObjects in
424 let metasenv, context, ugraph = env in
425 let _, proof, (eq_ty, left, right, order), metas, args = target in
426 let metasenv' = metasenv @ metas in
428 let maxmeta = ref newmeta in
430 let build_newtarget is_left (t, subst, menv, ug, (eq_found, eq_URI)) =
431 let time1 = Unix.gettimeofday () in
433 let pos, (_, proof', (ty, what, other, _), menv', args') = eq_found in
434 let what, other = if pos = Utils.Left then what, other else other, what in
435 let newterm, newproof =
436 let bo = (* M. *)apply_subst subst (S.subst other t) in
438 let name = C.Name ("x_Demod_" ^ (string_of_int !demod_counter)) in
441 if is_left then t, S.lift 1 right else S.lift 1 left, t in
442 (name, ty, S.lift 1 eq_ty, l, r)
444 if sign = Utils.Positive then
446 Inference.ProofBlock (subst, eq_URI, t', eq_found, proof))
451 CicMkImplicit.identity_relocation_list_for_metavariable context in
452 Printf.printf "\nADDING META: %d\n" !maxmeta;
454 C.Meta (!maxmeta, irl)
460 if pos = Utils.Left then
461 build_ens_for_sym_eq ty what other
463 build_ens_for_sym_eq ty other what
465 Inference.ProofSymBlock (ens, proof')
468 if pos = Utils.Left then what, other else other, what
470 pos, (0, proof', (ty, other, what, Utils.Incomparable),
475 Inference.ProofBlock (subst, eq_URI, t', eq_found,
476 Inference.BasicProof metaproof)
479 | Inference.BasicProof _ ->
480 print_endline "replacing a BasicProof";
482 | Inference.ProofGoalBlock (_, parent_eq) ->
483 print_endline "replacing another ProofGoalBlock";
484 Inference.ProofGoalBlock (pb, parent_eq)
487 (0, target_proof, (eq_ty, left, right, order), metas, args)
490 C.Appl [C.MutConstruct (* reflexivity *)
491 (HelmLibraryObjects.Logic.eq_URI, 0, 1, []);
492 eq_ty; if is_left then right else left]
495 Inference.ProofGoalBlock (Inference.BasicProof refl, target'))
497 let left, right = if is_left then newterm, right else left, newterm in
498 let m = (Inference.metas_of_term left) @ (Inference.metas_of_term right) in
499 let newmetasenv = List.filter (fun (i, _, _) -> List.mem i m) metas
502 (function C.Meta (i, _) -> List.mem i m | _ -> assert false)
505 let ordering = !Utils.compare_terms left right in
507 let time2 = Unix.gettimeofday () in
508 build_newtarget_time := !build_newtarget_time +. (time2 -. time1);
511 let w = Utils.compute_equality_weight eq_ty left right in
512 (w, newproof, (eq_ty, left, right, ordering), newmetasenv, newargs)
514 (* if sign = Utils.Positive then ( *)
515 (* let newm, res = Inference.fix_metas !maxmeta res in *)
516 (* maxmeta := newm; *)
519 !maxmeta(* newmeta *), res
521 let res = demodulate_term metasenv' context ugraph table 0 left in
522 (* let build_identity (w, p, (t, l, r, o), m, a) = *)
524 (* | Utils.Gt -> (w, p, (t, r, r, Utils.Eq), m, a) *)
525 (* | _ -> (w, p, (t, l, l, Utils.Eq), m, a) *)
529 let newmeta, newtarget = build_newtarget true t in
530 if (Inference.is_identity (metasenv', context, ugraph) newtarget) ||
531 (Inference.meta_convertibility_eq target newtarget) then
534 (* if subsumption env table newtarget then *)
535 (* newmeta, build_identity newtarget *)
537 demodulation newmeta env table sign newtarget
539 let res = demodulate_term metasenv' context ugraph table 0 right in
542 let newmeta, newtarget = build_newtarget false t in
543 if (Inference.is_identity (metasenv', context, ugraph) newtarget) ||
544 (Inference.meta_convertibility_eq target newtarget) then
547 (* if subsumption env table newtarget then *)
548 (* newmeta, build_identity newtarget *)
550 demodulation newmeta env table sign newtarget
556 let rec betaexpand_term metasenv context ugraph table lift_amount term =
557 let module C = Cic in
558 let module S = CicSubstitution in
559 let module M = CicMetaSubst in
560 let module HL = HelmLibraryObjects in
561 let candidates = get_candidates Unification table term in
562 let res, lifted_term =
567 (fun arg (res, lifted_tl) ->
570 let arg_res, lifted_arg =
571 betaexpand_term metasenv context ugraph table
575 (fun (t, s, m, ug, eq_found) ->
576 (Some t)::lifted_tl, s, m, ug, eq_found)
581 (fun (l, s, m, ug, eq_found) ->
582 (Some lifted_arg)::l, s, m, ug, eq_found)
584 (Some lifted_arg)::lifted_tl)
587 (fun (r, s, m, ug, eq_found) ->
588 None::r, s, m, ug, eq_found) res,
594 (fun (l, s, m, ug, eq_found) ->
595 (C.Meta (i, l), s, m, ug, eq_found)) l'
597 e, C.Meta (i, lifted_l)
600 [], if m <= lift_amount then C.Rel m else C.Rel (m+1)
602 | C.Prod (nn, s, t) ->
604 betaexpand_term metasenv context ugraph table lift_amount s in
606 betaexpand_term metasenv ((Some (nn, C.Decl s))::context) ugraph
607 table (lift_amount+1) t in
610 (fun (t, s, m, ug, eq_found) ->
611 C.Prod (nn, t, lifted_t), s, m, ug, eq_found) l1
614 (fun (t, s, m, ug, eq_found) ->
615 C.Prod (nn, lifted_s, t), s, m, ug, eq_found) l2 in
616 l1' @ l2', C.Prod (nn, lifted_s, lifted_t)
621 (fun arg (res, lifted_tl) ->
622 let arg_res, lifted_arg =
623 betaexpand_term metasenv context ugraph table lift_amount arg
627 (fun (a, s, m, ug, eq_found) ->
628 a::lifted_tl, s, m, ug, eq_found)
633 (fun (r, s, m, ug, eq_found) ->
634 lifted_arg::r, s, m, ug, eq_found)
636 lifted_arg::lifted_tl)
640 (fun (l, s, m, ug, eq_found) -> (C.Appl l, s, m, ug, eq_found)) l',
643 | t -> [], (S.lift lift_amount t)
646 | C.Meta _ -> res, lifted_term
649 find_all_matches metasenv context ugraph lift_amount term candidates
655 let sup_l_counter = ref 1;;
657 let superposition_left newmeta (metasenv, context, ugraph) table target =
658 let module C = Cic in
659 let module S = CicSubstitution in
660 let module M = CicMetaSubst in
661 let module HL = HelmLibraryObjects in
662 let module CR = CicReduction in
663 let module U = Utils in
664 let weight, proof, (eq_ty, left, right, ordering), _, _ = target in
666 let term = if ordering = U.Gt then left else right in
667 betaexpand_term metasenv context ugraph table 0 term
669 let maxmeta = ref newmeta in
670 let build_new (bo, s, m, ug, (eq_found, eq_URI)) =
672 print_endline "\nSUPERPOSITION LEFT\n";
674 let time1 = Unix.gettimeofday () in
676 let pos, (_, proof', (ty, what, other, _), menv', args') = eq_found in
677 let what, other = if pos = Utils.Left then what, other else other, what in
678 let newgoal, newproof =
679 let bo' = (* M. *)apply_subst s (S.subst other bo) in
681 let name = C.Name ("x_SupL_" ^ (string_of_int !sup_l_counter)) in
684 if ordering = U.Gt then bo, S.lift 1 right else S.lift 1 left, bo in
685 (name, ty, S.lift 1 eq_ty, l, r)
689 (* [C.MutInd (HL.Logic.eq_URI, 0, []); *)
690 (* S.lift 1 eq_ty] @ *)
691 (* if ordering = U.Gt then [S.lift 1 bo'; S.lift 1 right] *)
692 (* else [S.lift 1 left; S.lift 1 bo']) *)
695 (* let name = C.Name ("x_SupL_" ^ (string_of_int !sup_l_counter)) in *)
696 (* incr sup_l_counter; *)
697 (* C.Lambda (name, ty, bo'') *)
702 CicMkImplicit.identity_relocation_list_for_metavariable context in
703 C.Meta (!maxmeta, irl)
709 if pos = Utils.Left then
710 build_ens_for_sym_eq ty what other
712 build_ens_for_sym_eq ty other what
714 Inference.ProofSymBlock (ens, proof')
717 if pos = Utils.Left then what, other else other, what
719 pos, (0, proof', (ty, other, what, Utils.Incomparable), menv', args')
723 Inference.ProofBlock (s, eq_URI, t', eq_found,
724 Inference.BasicProof metaproof)
727 | Inference.BasicProof _ ->
728 print_endline "replacing a BasicProof";
730 | Inference.ProofGoalBlock (_, parent_eq) ->
731 print_endline "replacing another ProofGoalBlock";
732 Inference.ProofGoalBlock (pb, parent_eq)
735 (weight, target_proof, (eq_ty, left, right, ordering), [], [])
738 C.Appl [C.MutConstruct (* reflexivity *)
739 (HelmLibraryObjects.Logic.eq_URI, 0, 1, []);
740 eq_ty; if ordering = U.Gt then right else left]
743 Inference.ProofGoalBlock (Inference.BasicProof refl, target'))
746 if ordering = U.Gt then newgoal, right else left, newgoal in
747 let neworder = !Utils.compare_terms left right in
749 let time2 = Unix.gettimeofday () in
750 build_newtarget_time := !build_newtarget_time +. (time2 -. time1);
753 let w = Utils.compute_equality_weight eq_ty left right in
754 (w, newproof, (eq_ty, left, right, neworder), [], [])
758 !maxmeta, List.map build_new expansions
762 let sup_r_counter = ref 1;;
764 let superposition_right newmeta (metasenv, context, ugraph) table target =
765 let module C = Cic in
766 let module S = CicSubstitution in
767 let module M = CicMetaSubst in
768 let module HL = HelmLibraryObjects in
769 let module CR = CicReduction in
770 let module U = Utils in
771 let _, eqproof, (eq_ty, left, right, ordering), newmetas, args = target in
772 let metasenv' = metasenv @ newmetas in
773 let maxmeta = ref newmeta in
776 | U.Gt -> fst (betaexpand_term metasenv' context ugraph table 0 left), []
777 | U.Lt -> [], fst (betaexpand_term metasenv' context ugraph table 0 right)
781 (fun (_, subst, _, _, _) ->
782 let subst = (* M. *)apply_subst subst in
783 let o = !Utils.compare_terms (subst l) (subst r) in
784 o <> U.Lt && o <> U.Le)
785 (fst (betaexpand_term metasenv' context ugraph table 0 l))
787 (res left right), (res right left)
789 let build_new ordering (bo, s, m, ug, (eq_found, eq_URI)) =
791 let time1 = Unix.gettimeofday () in
793 let pos, (_, proof', (ty, what, other, _), menv', args') = eq_found in
794 let what, other = if pos = Utils.Left then what, other else other, what in
795 let newgoal, newproof =
796 let bo' = (* M. *)apply_subst s (S.subst other bo) in
798 let name = C.Name ("x_SupR_" ^ (string_of_int !sup_r_counter)) in
801 if ordering = U.Gt then bo, S.lift 1 right else S.lift 1 left, bo in
802 (name, ty, S.lift 1 eq_ty, l, r)
806 (* [C.MutInd (HL.Logic.eq_URI, 0, []); S.lift 1 eq_ty] @ *)
807 (* if ordering = U.Gt then [S.lift 1 bo'; S.lift 1 right] *)
808 (* else [S.lift 1 left; S.lift 1 bo']) *)
811 (* let name = C.Name ("x_SupR_" ^ (string_of_int !sup_r_counter)) in *)
812 (* incr sup_r_counter; *)
813 (* C.Lambda (name, ty, bo'') *)
816 Inference.ProofBlock (s, eq_URI, t', eq_found, eqproof(* target *))
817 (* (\* M. *\)apply_subst s *)
818 (* (C.Appl [C.Const (eq_URI, []); ty; what; t'; *)
819 (* eqproof; other; proof']) *)
821 let newmeta, newequality =
823 if ordering = U.Gt then newgoal, (* M. *)apply_subst s right
824 else (* M. *)apply_subst s left, newgoal in
825 let neworder = !Utils.compare_terms left right
826 and newmenv = newmetas @ menv'
827 and newargs = args @ args' in
829 let w = Utils.compute_equality_weight eq_ty left right in
830 (w, newproof, (eq_ty, left, right, neworder), newmenv, newargs)
831 and env = (metasenv, context, ugraph) in
832 let newm, eq' = Inference.fix_metas !maxmeta eq' in
837 let time2 = Unix.gettimeofday () in
838 build_newtarget_time := !build_newtarget_time +. (time2 -. time1);
843 (* let build_new = *)
844 (* let profile = CicUtil.profile "Indexing.superposition_right.build_new" in *)
845 (* (fun o e -> profile (build_new o) e) *)
848 let new1 = List.map (build_new U.Gt) res1
849 and new2 = List.map (build_new U.Lt) res2 in
851 | _, _, (_, left, right, _), _, _ ->
852 not (fst (CR.are_convertible context left right ugraph))
855 (List.filter ok (new1 @ new2)))