-(* type naif_indexing =
- (Cic.term * ((bool * Inference.equality) list)) list
-;; *)
+(** settable by the command line (-i switch) *)
+let use_index = ref true;;
+
type pos = Left | Right ;;
;;
-let rec find_matches unif_fun metasenv context ugraph lift_amount term =
+let rec find_matches metasenv context ugraph lift_amount term =
let module C = Cic in
let module U = Utils in
let module S = CicSubstitution in
let subst', metasenv', ugraph' =
(* Inference.matching (metasenv @ metas) context term *)
(* (S.lift lift_amount c) ugraph *)
- unif_fun (metasenv @ metas) context
+ Inference.matching (metasenv @ metas) context
term (S.lift lift_amount c) ugraph
in
(* let names = U.names_of_context context in *)
res
with e ->
(* Printf.printf "ERRORE!: %s\n" (Printexc.to_string e); *)
- find_matches unif_fun metasenv context ugraph lift_amount term tl
+ find_matches metasenv context ugraph lift_amount term tl
else
let res = try do_match c other eq_URI with e -> None in
match res with
if order = U.Gt then
res
else
- find_matches unif_fun metasenv context ugraph
- lift_amount term tl
+ find_matches metasenv context ugraph lift_amount term tl
| None ->
- find_matches unif_fun metasenv context ugraph lift_amount term tl
+ find_matches metasenv context ugraph lift_amount term tl
+;;
+
+
+let get_candidates table term =
+ if !use_index then
+ try Hashtbl.find table (head_of_term term) with Not_found -> []
+ else
+ Hashtbl.fold (fun k v l -> v @ l) table []
;;
let module S = CicSubstitution in
let module M = CicMetaSubst in
let module HL = HelmLibraryObjects in
- let hd_term = head_of_term term in
- let candidates = try Hashtbl.find table hd_term with Not_found -> [] in
+ let candidates = get_candidates table term in
match term with
| C.Meta _ -> None
| term ->
let res =
- find_matches Inference.matching metasenv context ugraph
- lift_amount term candidates
+ find_matches metasenv context ugraph lift_amount term candidates
in
if res <> None then
res
if (Inference.is_identity (metasenv', context, ugraph) newtarget) ||
(Inference.meta_convertibility_eq target newtarget) then
newmeta, newtarget
- else (
-(* Printf.printf "Going on 1:\ntarget: %s\nnewtarget: %s\n%s\n\n" *)
-(* (Inference.string_of_equality ~env target) *)
-(* (Inference.string_of_equality ~env newtarget) *)
-(* (string_of_bool (target = newtarget)); *)
+ else
demodulation newmeta env table newtarget
- )
| None ->
let res = demodulate_term metasenv' context ugraph table 0 right in
match res with
if (Inference.is_identity (metasenv', context, ugraph) newtarget) ||
(Inference.meta_convertibility_eq target newtarget) then
newmeta, newtarget
- else (
-(* Printf.printf "Going on 2:\ntarget: %s\nnewtarget: %s\n\n" *)
-(* (Inference.string_of_equality ~env target) *)
-(* (Inference.string_of_equality ~env newtarget); *)
+ else
demodulation newmeta env table newtarget
- )
| None ->
newmeta, target
;;
let module S = CicSubstitution in
let module M = CicMetaSubst in
let module HL = HelmLibraryObjects in
- let hd_term = head_of_term term in
- let candidates = try Hashtbl.find table hd_term with Not_found -> [] in
+ let candidates = get_candidates table term in
let res, lifted_term =
match term with
| C.Meta (i, l) ->