5 (* profiling statistics... *)
6 let infer_time = ref 0.;;
7 let forward_simpl_time = ref 0.;;
8 let backward_simpl_time = ref 0.;;
10 (* limited-resource-strategy related globals *)
11 let processed_clauses = ref 0;; (* number of equalities selected so far... *)
12 let time_limit = ref 0.;; (* in seconds, settable by the user... *)
13 let start_time = ref 0.;; (* time at which the execution started *)
14 let elapsed_time = ref 0.;;
15 let maximal_retained_equality = ref None;;
17 (* equality-selection related globals *)
18 let use_fullred = ref false;;
19 let weight_age_ratio = ref 0;; (* settable by the user from the command line *)
20 let weight_age_counter = ref !weight_age_ratio;;
21 let symbols_ratio = ref 0;;
22 let symbols_counter = ref 0;;
24 (* index of the greatest Cic.Meta created - TODO: find a better way! *)
30 | Success of Cic.term option * environment
35 let symbols_of_equality (_, (_, left, right), _, _) =
36 TermSet.union (symbols_of_term left) (symbols_of_term right)
40 let symbols_of_equality ((_, (_, left, right, _), _, _) as equality) =
41 let m1 = symbols_of_term left in
46 let c = TermMap.find k res in
47 TermMap.add k (c+v) res
50 (symbols_of_term right) m1
52 (* Printf.printf "symbols_of_equality %s:\n" *)
53 (* (string_of_equality equality); *)
54 (* TermMap.iter (fun k v -> Printf.printf "%s: %d\n" (CicPp.ppterm k) v) m; *)
55 (* print_newline (); *)
60 module OrderedEquality = struct
61 type t = Inference.equality
64 match meta_convertibility_eq eq1 eq2 with
67 let _, (ty, left, right, _), _, _ = eq1
68 and _, (ty', left', right', _), _, _ = eq2 in
69 let weight_of t = fst (weight_of_term ~consider_metas:false t) in
70 let w1 = (weight_of ty) + (weight_of left) + (weight_of right)
71 and w2 = (weight_of ty') + (weight_of left') + (weight_of right') in
72 match Pervasives.compare w1 w2 with
73 | 0 -> Pervasives.compare eq1 eq2
77 module EqualitySet = Set.Make(OrderedEquality);;
80 let select env passive (active, _) =
81 processed_clauses := !processed_clauses + 1;
83 let (neg_list, neg_set), (pos_list, pos_set), passive_table = passive in
85 List.filter (fun e -> e <> eq) l
87 if !weight_age_ratio > 0 then
88 weight_age_counter := !weight_age_counter - 1;
89 match !weight_age_counter with
91 weight_age_counter := !weight_age_ratio;
92 match neg_list, pos_list with
94 (* Negatives aren't indexed, no need to remove them... *)
96 ((tl, EqualitySet.remove hd neg_set), (pos, pos_set), passive_table)
99 Indexing.remove_index passive_table hd
100 (* if !use_fullred then Indexing.remove_index passive_table hd *)
101 (* else passive_table *)
104 (([], neg_set), (tl, EqualitySet.remove hd pos_set), passive_table)
105 | _, _ -> assert false
107 | _ when (!symbols_counter > 0) && (EqualitySet.is_empty neg_set) -> (
108 symbols_counter := !symbols_counter - 1;
109 let cardinality map =
110 TermMap.fold (fun k v res -> res + v) map 0
113 | (Negative, e)::_ ->
114 let symbols = symbols_of_equality e in
115 let card = cardinality symbols in
116 let foldfun k v (r1, r2) =
117 if TermMap.mem k symbols then
118 let c = TermMap.find k symbols in
119 let c1 = abs (c - v) in
125 let f equality (i, e) =
127 TermMap.fold foldfun (symbols_of_equality equality) (0, 0)
129 let c = others + (abs (common - card)) in
130 if c < i then (c, equality)
133 let e1 = EqualitySet.min_elt pos_set in
136 TermMap.fold foldfun (symbols_of_equality e1) (0, 0)
138 (others + (abs (common - card))), e1
140 let _, current = EqualitySet.fold f pos_set initial in
141 (* Printf.printf "\nsymbols-based selection: %s\n\n" *)
142 (* (string_of_equality ~env current); *)
144 Indexing.remove_index passive_table current
145 (* if !use_fullred then Indexing.remove_index passive_table current *)
146 (* else passive_table *)
150 (remove current pos_list, EqualitySet.remove current pos_set),
153 let current = EqualitySet.min_elt pos_set in
155 Indexing.remove_index passive_table current
156 (* if !use_fullred then Indexing.remove_index passive_table current *)
157 (* else passive_table *)
161 (remove current pos_list, EqualitySet.remove current pos_set),
164 (Positive, current), passive
167 symbols_counter := !symbols_ratio;
168 let set_selection set = EqualitySet.min_elt set in
169 if EqualitySet.is_empty neg_set then
170 let current = set_selection pos_set in
173 (remove current pos_list, EqualitySet.remove current pos_set),
174 Indexing.remove_index passive_table current
175 (* if !use_fullred then Indexing.remove_index passive_table current *)
176 (* else passive_table *)
178 (Positive, current), passive
180 let current = set_selection neg_set in
182 (remove current neg_list, EqualitySet.remove current neg_set),
186 (Negative, current), passive
190 let make_passive neg pos =
191 let set_of equalities =
192 List.fold_left (fun s e -> EqualitySet.add e s) EqualitySet.empty equalities
195 List.fold_left (fun tbl e -> Indexing.index tbl e)
196 (Indexing.empty_table ()) pos
197 (* if !use_fullred then *)
198 (* List.fold_left (fun tbl e -> Indexing.index tbl e) *)
199 (* (Indexing.empty_table ()) pos *)
201 (* Indexing.empty_table () *)
210 [], Indexing.empty_table ()
214 let add_to_passive passive (new_neg, new_pos) =
215 let (neg_list, neg_set), (pos_list, pos_set), table = passive in
216 let ok set equality = not (EqualitySet.mem equality set) in
217 let neg = List.filter (ok neg_set) new_neg
218 and pos = List.filter (ok pos_set) new_pos in
220 List.fold_left (fun tbl e -> Indexing.index tbl e) table pos
221 (* if !use_fullred then *)
222 (* List.fold_left (fun tbl e -> Indexing.index tbl e) table pos *)
226 let add set equalities =
227 List.fold_left (fun s e -> EqualitySet.add e s) set equalities
229 (neg @ neg_list, add neg_set neg),
230 (pos_list @ pos, add pos_set pos),
235 let passive_is_empty = function
236 | ([], _), ([], _), _ -> true
241 let size_of_passive ((_, ns), (_, ps), _) =
242 (EqualitySet.cardinal ns) + (EqualitySet.cardinal ps)
246 let prune_passive howmany (active, _) passive =
247 let (nl, ns), (pl, ps), tbl = passive in
248 let howmany = float_of_int howmany
249 and ratio = float_of_int !weight_age_ratio in
250 let in_weight = int_of_float (howmany *. ratio /. (ratio +. 1.))
251 and in_age = int_of_float (howmany /. (ratio +. 1.)) in
252 Printf.printf "in_weight: %d, in_age: %d\n" in_weight in_age;
255 | (Negative, e)::_ ->
256 let symbols = symbols_of_equality e in
257 let card = TermMap.fold (fun k v res -> res + v) symbols 0 in
261 let counter = ref !symbols_ratio in
262 let rec pickw w ns ps =
264 if not (EqualitySet.is_empty ns) then
265 let e = EqualitySet.min_elt ns in
266 let ns', ps = pickw (w-1) (EqualitySet.remove e ns) ps in
267 EqualitySet.add e ns', ps
268 else if !counter > 0 then
270 counter := !counter - 1;
271 if !counter = 0 then counter := !symbols_ratio
275 let e = EqualitySet.min_elt ps in
276 let ns, ps' = pickw (w-1) ns (EqualitySet.remove e ps) in
277 ns, EqualitySet.add e ps'
279 let foldfun k v (r1, r2) =
280 if TermMap.mem k symbols then
281 let c = TermMap.find k symbols in
282 let c1 = abs (c - v) in
288 let f equality (i, e) =
290 TermMap.fold foldfun (symbols_of_equality equality) (0, 0)
292 let c = others + (abs (common - card)) in
293 if c < i then (c, equality)
296 let e1 = EqualitySet.min_elt ps in
299 TermMap.fold foldfun (symbols_of_equality e1) (0, 0)
301 (others + (abs (common - card))), e1
303 let _, e = EqualitySet.fold f ps initial in
304 let ns, ps' = pickw (w-1) ns (EqualitySet.remove e ps) in
305 ns, EqualitySet.add e ps'
307 let e = EqualitySet.min_elt ps in
308 let ns, ps' = pickw (w-1) ns (EqualitySet.remove e ps) in
309 ns, EqualitySet.add e ps'
311 EqualitySet.empty, EqualitySet.empty
313 (* let in_weight, ns = pickw in_weight ns in *)
314 (* let _, ps = pickw in_weight ps in *)
315 let ns, ps = pickw in_weight ns ps in
316 let rec picka w s l =
320 | hd::tl when not (EqualitySet.mem hd s) ->
321 let w, s, l = picka (w-1) s tl in
322 w, EqualitySet.add hd s, hd::l
324 let w, s, l = picka w s tl in
329 let in_age, ns, nl = picka in_age ns nl in
330 let _, ps, pl = picka in_age ps pl in
331 if not (EqualitySet.is_empty ps) then
332 maximal_retained_equality := Some (EqualitySet.max_elt ps);
335 (fun e tbl -> Indexing.index tbl e) ps (Indexing.empty_table ())
336 (* if !use_fullred then *)
337 (* EqualitySet.fold *)
338 (* (fun e tbl -> Indexing.index tbl e) ps (Indexing.empty_table ()) *)
342 (nl, ns), (pl, ps), tbl
346 let infer env sign current (active_list, active_table) =
347 let new_neg, new_pos =
350 Indexing.superposition_left env active_table current, []
353 Indexing.superposition_right !maxmeta env active_table current in
355 let rec infer_positive table = function
357 | (Negative, equality)::tl ->
358 let res = Indexing.superposition_left env table equality in
359 let neg, pos = infer_positive table tl in
361 | (Positive, equality)::tl ->
363 Indexing.superposition_right !maxmeta env table equality in
365 let neg, pos = infer_positive table tl in
368 let curr_table = Indexing.index (Indexing.empty_table ()) current in
369 let neg, pos = infer_positive curr_table active_list in
372 match !maximal_retained_equality with
373 | None -> new_neg, new_pos
376 List.filter (fun e -> OrderedEquality.compare e eq <= 0) new_pos in
381 let contains_empty env (negative, positive) =
382 let metasenv, context, ugraph = env in
384 let (proof, _, _, _) =
386 (fun (proof, (ty, left, right, ordering), m, a) ->
387 fst (CicReduction.are_convertible context left right ugraph))
396 let forward_simplify env (sign, current) ?passive (active_list, active_table) =
397 let pl, passive_table =
400 | Some ((pn, _), (pp, _), pt) ->
401 let pn = List.map (fun e -> (Negative, e)) pn
402 and pp = List.map (fun e -> (Positive, e)) pp in
405 let all = if pl = [] then active_list else active_list @ pl in
407 (* let rec find_duplicate sign current = function *)
409 (* | (s, eq)::tl when s = sign -> *)
410 (* if meta_convertibility_eq current eq then true *)
411 (* else find_duplicate sign current tl *)
412 (* | _::tl -> find_duplicate sign current tl *)
414 let demodulate table current =
415 let newmeta, newcurrent =
416 Indexing.demodulation !maxmeta env table current in
418 if is_identity env newcurrent then
419 if sign = Negative then Some (sign, newcurrent) else None
421 Some (sign, newcurrent)
424 let res = demodulate active_table current in
427 | Some (sign, newcurrent) ->
428 match passive_table with
430 | Some passive_table -> demodulate passive_table newcurrent
434 | Some (Negative, c) ->
437 (fun (s, eq) -> s = Negative && meta_convertibility_eq eq c)
440 if ok then res else None
441 | Some (Positive, c) ->
442 if Indexing.in_index active_table c then
445 match passive_table with
447 | Some passive_table ->
448 if Indexing.in_index passive_table c then None else res
450 (* | Some (s, c) -> if find_duplicate s c all then None else res *)
452 (* if s = Utils.Negative then *)
455 (* if Indexing.subsumption env active_table c then *)
458 (* match passive_table with *)
460 (* | Some passive_table -> *)
461 (* if Indexing.subsumption env passive_table c then *)
467 (* let pred (sign, eq) = *)
468 (* if sign <> s then false *)
469 (* else subsumption env c eq *)
471 (* if List.exists pred all then None *)
475 type fs_time_info_t = {
476 mutable build_all: float;
477 mutable demodulate: float;
478 mutable subsumption: float;
481 let fs_time_info = { build_all = 0.; demodulate = 0.; subsumption = 0. };;
484 let forward_simplify_new env (new_neg, new_pos) ?passive active =
485 let t1 = Unix.gettimeofday () in
487 let active_list, active_table = active in
488 let pl, passive_table =
491 | Some ((pn, _), (pp, _), pt) ->
492 let pn = List.map (fun e -> (Negative, e)) pn
493 and pp = List.map (fun e -> (Positive, e)) pp in
496 let all = active_list @ pl in
498 let t2 = Unix.gettimeofday () in
499 fs_time_info.build_all <- fs_time_info.build_all +. (t2 -. t1);
501 let demodulate table target =
502 let newmeta, newtarget = Indexing.demodulation !maxmeta env table target in
506 (* let f sign' target (sign, eq) = *)
507 (* if sign <> sign' then false *)
508 (* else subsumption env target eq *)
511 let t1 = Unix.gettimeofday () in
513 let new_neg, new_pos =
514 let new_neg = List.map (demodulate active_table) new_neg
515 and new_pos = List.map (demodulate active_table) new_pos in
516 match passive_table with
517 | None -> new_neg, new_pos
518 | Some passive_table ->
519 List.map (demodulate passive_table) new_neg,
520 List.map (demodulate passive_table) new_pos
523 let t2 = Unix.gettimeofday () in
524 fs_time_info.demodulate <- fs_time_info.demodulate +. (t2 -. t1);
529 if not (Inference.is_identity env e) then EqualitySet.add e s else s)
530 EqualitySet.empty new_pos
532 let new_pos = EqualitySet.elements new_pos_set in
535 (* match passive_table with *)
537 (* (fun e -> not (Indexing.subsumption env active_table e)) *)
538 (* | Some passive_table -> *)
539 (* (fun e -> not ((Indexing.subsumption env active_table e) || *)
540 (* (Indexing.subsumption env passive_table e))) *)
543 let t1 = Unix.gettimeofday () in
545 (* let new_neg, new_pos = *)
546 (* List.filter subs new_neg, *)
547 (* List.filter subs new_pos *)
550 (* let new_neg, new_pos = *)
551 (* (List.filter (fun e -> not (List.exists (f Negative e) all)) new_neg, *)
552 (* List.filter (fun e -> not (List.exists (f Positive e) all)) new_pos) *)
555 let t2 = Unix.gettimeofday () in
556 fs_time_info.subsumption <- fs_time_info.subsumption +. (t2 -. t1);
559 match passive_table with
560 | None -> (fun e -> not (Indexing.in_index active_table e))
561 | Some passive_table ->
562 (fun e -> not ((Indexing.in_index active_table e) ||
563 (Indexing.in_index passive_table e)))
565 new_neg, List.filter is_duplicate new_pos
567 (* new_neg, new_pos *)
570 (* (List.filter (fun e -> not (List.exists (f Negative e) all)) new_neg, *)
571 (* List.filter (fun e -> not (List.exists (f Positive e) all)) new_pos) *)
577 let backward_simplify_active env (new_neg, new_pos) active =
578 let active_list, active_table = active in
579 let new_pos, new_table =
581 (fun (l, t) e -> (Positive, e)::l, Indexing.index t e)
582 ([], Indexing.empty_table ()) new_pos
584 let active_list, newa =
586 (fun (s, equality) (res, newn) ->
587 match forward_simplify env (s, equality) (new_pos, new_table) with
597 List.exists (fun (s, e) -> meta_convertibility_eq eq1 e) where
601 (fun (s, eq) (res, tbl) ->
602 if (is_identity env eq) || (find eq res) then
605 (s, eq)::res, if s = Negative then tbl else Indexing.index tbl eq)
606 active_list ([], Indexing.empty_table ()),
608 (fun (s, eq) (n, p) ->
609 if (s <> Negative) && (is_identity env eq) then
612 if s = Negative then eq::n, p
617 | [], [] -> active, None
618 | _ -> active, Some newa
622 let backward_simplify_passive env (new_neg, new_pos) passive =
623 let new_pos, new_table =
625 (fun (l, t) e -> (Positive, e)::l, Indexing.index t e)
626 ([], Indexing.empty_table ()) new_pos
628 let (nl, ns), (pl, ps), passive_table = passive in
629 let f sign equality (resl, ress, newn) =
630 match forward_simplify env (sign, equality) (new_pos, new_table) with
631 | None -> resl, EqualitySet.remove equality ress, newn
634 equality::resl, ress, newn
636 let ress = EqualitySet.remove equality ress in
639 let nl, ns, newn = List.fold_right (f Negative) nl ([], ns, [])
640 and pl, ps, newp = List.fold_right (f Positive) pl ([], ps, []) in
643 (fun tbl e -> Indexing.index tbl e) (Indexing.empty_table ()) pl
645 match newn, newp with
646 | [], [] -> ((nl, ns), (pl, ps), passive_table), None
647 | _, _ -> ((nl, ns), (pl, ps), passive_table), Some (newn, newp)
651 let backward_simplify env new' ?passive active =
652 let active, newa = backward_simplify_active env new' active in
655 active, (make_passive [] []), newa, None
658 backward_simplify_passive env new' passive in
659 active, passive, newa, newp
663 let get_selection_estimate () =
664 elapsed_time := (Unix.gettimeofday ()) -. !start_time;
666 ceil ((float_of_int !processed_clauses) *.
667 (!time_limit /. !elapsed_time -. 1.)))
671 let rec given_clause env passive active =
672 let selection_estimate = get_selection_estimate () in
673 let kept = size_of_passive passive in
675 if !time_limit = 0. || !processed_clauses = 0 then
677 else if !elapsed_time > !time_limit then (
678 Printf.printf "Time limit (%.2f) reached: %.2f\n"
679 !time_limit !elapsed_time;
681 ) else if kept > selection_estimate then (
682 Printf.printf ("Too many passive equalities: pruning... (kept: %d, " ^^
683 "selection_estimate: %d)\n") kept selection_estimate;
684 prune_passive selection_estimate active passive
689 match passive_is_empty passive with
692 let (sign, current), passive = select env passive active in
693 match forward_simplify env (sign, current) ~passive active with
695 given_clause env passive active
696 | Some (sign, current) ->
697 if (sign = Negative) && (is_identity env current) then (
698 Printf.printf "OK!!! %s %s" (string_of_sign sign)
699 (string_of_equality ~env current);
701 let proof, _, _, _ = current in
702 Success (Some proof, env)
704 print_endline "\n================================================";
705 Printf.printf "selected: %s %s"
706 (string_of_sign sign) (string_of_equality ~env current);
709 let t1 = Unix.gettimeofday () in
710 let new' = infer env sign current active in
711 let t2 = Unix.gettimeofday () in
712 infer_time := !infer_time +. (t2 -. t1);
714 let res, proof = contains_empty env new' in
718 let t1 = Unix.gettimeofday () in
719 let new' = forward_simplify_new env new' (* ~passive *) active in
720 let t2 = Unix.gettimeofday () in
722 forward_simpl_time := !forward_simpl_time +. (t2 -. t1)
728 let t1 = Unix.gettimeofday () in
729 let active, _, newa, _ =
730 backward_simplify env ([], [current]) active
732 let t2 = Unix.gettimeofday () in
733 backward_simpl_time := !backward_simpl_time +. (t2 -. t1);
737 let al, tbl = active in
738 let nn = List.map (fun e -> Negative, e) n in
743 Indexing.index tbl e)
749 Printf.printf "active:\n%s\n"
752 (fun (s, e) -> (string_of_sign s) ^ " " ^
753 (string_of_equality ~env e)) (fst active))));
759 Printf.printf "new':\n%s\n"
762 (fun e -> "Negative " ^
763 (string_of_equality ~env e)) neg) @
765 (fun e -> "Positive " ^
766 (string_of_equality ~env e)) pos)));
769 match contains_empty env new' with
772 let al, tbl = active in
774 | Negative -> (sign, current)::al, tbl
776 al @ [(sign, current)], Indexing.index tbl current
778 let passive = add_to_passive passive new' in
779 let (_, ns), (_, ps), _ = passive in
780 Printf.printf "passive:\n%s\n"
782 ((List.map (fun e -> "Negative " ^
783 (string_of_equality ~env e))
784 (EqualitySet.elements ns)) @
785 (List.map (fun e -> "Positive " ^
786 (string_of_equality ~env e))
787 (EqualitySet.elements ps))));
789 given_clause env passive active
796 let rec given_clause_fullred env passive active =
797 let selection_estimate = get_selection_estimate () in
798 let kept = size_of_passive passive in
800 if !time_limit = 0. || !processed_clauses = 0 then
802 else if !elapsed_time > !time_limit then (
803 Printf.printf "Time limit (%.2f) reached: %.2f\n"
804 !time_limit !elapsed_time;
806 ) else if kept > selection_estimate then (
807 Printf.printf ("Too many passive equalities: pruning... (kept: %d, " ^^
808 "selection_estimate: %d)\n") kept selection_estimate;
809 prune_passive selection_estimate active passive
814 match passive_is_empty passive with
817 let (sign, current), passive = select env passive active in
818 match forward_simplify env (sign, current) ~passive active with
820 given_clause_fullred env passive active
821 | Some (sign, current) ->
822 if (sign = Negative) && (is_identity env current) then (
823 Printf.printf "OK!!! %s %s" (string_of_sign sign)
824 (string_of_equality ~env current);
826 let proof, _, _, _ = current in
827 Success (Some proof, env)
829 print_endline "\n================================================";
830 Printf.printf "selected: %s %s"
831 (string_of_sign sign) (string_of_equality ~env current);
834 let t1 = Unix.gettimeofday () in
835 let new' = infer env sign current active in
836 let t2 = Unix.gettimeofday () in
837 infer_time := !infer_time +. (t2 -. t1);
840 if is_identity env current then active
842 let al, tbl = active in
844 | Negative -> (sign, current)::al, tbl
845 | Positive -> al @ [(sign, current)], Indexing.index tbl current
847 let rec simplify new' active passive =
848 let t1 = Unix.gettimeofday () in
849 let new' = forward_simplify_new env new' ~passive active in
850 let t2 = Unix.gettimeofday () in
851 forward_simpl_time := !forward_simpl_time +. (t2 -. t1);
852 let t1 = Unix.gettimeofday () in
853 let active, passive, newa, retained =
854 backward_simplify env new' ~passive active in
855 let t2 = Unix.gettimeofday () in
856 backward_simpl_time := !backward_simpl_time +. (t2 -. t1);
857 match newa, retained with
858 | None, None -> active, passive, new'
860 | None, Some (n, p) ->
862 simplify (nn @ n, np @ p) active passive
863 | Some (n, p), Some (rn, rp) ->
865 simplify (nn @ n @ rn, np @ p @ rp) active passive
867 let active, passive, new' = simplify new' active passive in
869 let k = size_of_passive passive in
870 if k < (kept - 1) then
871 processed_clauses := !processed_clauses + (kept - 1 - k);
874 Printf.printf "active:\n%s\n"
877 (fun (s, e) -> (string_of_sign s) ^ " " ^
878 (string_of_equality ~env e)) (fst active))));
884 Printf.printf "new':\n%s\n"
887 (fun e -> "Negative " ^
888 (string_of_equality ~env e)) neg) @
890 (fun e -> "Positive " ^
891 (string_of_equality ~env e)) pos)));
894 match contains_empty env new' with
896 let passive = add_to_passive passive new' in
897 given_clause_fullred env passive active
904 let get_from_user () =
905 let dbd = Mysql.quick_connect
906 ~host:"localhost" ~user:"helm" ~database:"mowgli" () in
908 match read_line () with
912 let term_string = String.concat "\n" (get ()) in
913 let env, metasenv, term, ugraph =
914 List.nth (Disambiguate.Trivial.disambiguate_string dbd term_string) 0
916 term, metasenv, ugraph
920 let given_clause_ref = ref given_clause;;
924 let module C = Cic in
925 let module T = CicTypeChecker in
926 let module PET = ProofEngineTypes in
927 let module PP = CicPp in
928 let term, metasenv, ugraph = get_from_user () in
929 let proof = None, (1, [], term)::metasenv, C.Meta (1, []), term in
931 PET.apply_tactic (PrimitiveTactics.intros_tac ()) (proof, 1) in
932 let goal = List.nth goals 0 in
933 let _, metasenv, meta_proof, _ = proof in
934 let _, context, goal = CicUtil.lookup_meta goal metasenv in
935 let equalities, maxm = find_equalities context proof in
936 maxmeta := maxm; (* TODO ugly!! *)
937 let env = (metasenv, context, ugraph) in
939 let term_equality = equality_of_term meta_proof goal in
940 let meta_proof, (eq_ty, left, right, ordering), _, _ = term_equality in
941 let active = make_active () in
942 let passive = make_passive [term_equality] equalities in
943 Printf.printf "\ncurrent goal: %s\n"
944 (string_of_equality ~env term_equality);
945 Printf.printf "\ncontext:\n%s\n" (PP.ppcontext context);
946 Printf.printf "\nmetasenv:\n%s\n" (print_metasenv metasenv);
947 Printf.printf "\nequalities:\n%s\n"
950 (string_of_equality ~env)
952 print_endline "--------------------------------------------------";
953 let start = Unix.gettimeofday () in
955 start_time := Unix.gettimeofday ();
957 (if !use_fullred then given_clause_fullred else given_clause)
960 let finish = Unix.gettimeofday () in
963 Printf.printf "NO proof found! :-(\n\n"
964 | Success (Some proof, env) ->
965 Printf.printf "OK, found a proof!:\n%s\n%.9f\n"
966 (PP.pp proof (names_of_context context))
968 Printf.printf ("infer_time: %.9f\nforward_simpl_time: %.9f\n" ^^
969 "backward_simpl_time: %.9f\n")
970 !infer_time !forward_simpl_time !backward_simpl_time;
971 (* Printf.printf ("forward_simpl_details:\n build_all: %.9f\n" ^^ *)
972 (* " demodulate: %.9f\n subsumption: %.9f\n") *)
973 (* fs_time_info.build_all fs_time_info.demodulate *)
974 (* fs_time_info.subsumption; *)
975 | Success (None, env) ->
976 Printf.printf "Success, but no proof?!?\n\n"
978 print_endline ("EXCEPTION: " ^ (Printexc.to_string exc));
983 let configuration_file = ref "../../gTopLevel/gTopLevel.conf.xml";;
986 let set_ratio v = weight_age_ratio := (v+1); weight_age_counter := (v+1)
987 and set_sel v = symbols_ratio := v; symbols_counter := v;
988 and set_conf f = configuration_file := f
989 and set_lpo () = Utils.compare_terms := lpo
990 and set_kbo () = Utils.compare_terms := nonrec_kbo
991 and set_fullred () = use_fullred := true
992 and set_time_limit v = time_limit := float_of_int v
995 "-f", Arg.Unit set_fullred, "Use full-reduction strategy";
997 "-r", Arg.Int set_ratio, "Weight-Age equality selection ratio (default: 0)";
999 "-s", Arg.Int set_sel,
1000 "symbols-based selection ratio (relative to the weight ratio)";
1002 "-c", Arg.String set_conf, "Configuration file (for the db connection)";
1004 "-lpo", Arg.Unit set_lpo, "Use lpo term ordering";
1006 "-kbo", Arg.Unit set_kbo, "Use (non-recursive) kbo term ordering (default)";
1008 "-l", Arg.Int set_time_limit, "Time limit (in seconds)";
1009 ] (fun a -> ()) "Usage:"
1011 Helm_registry.load_from !configuration_file;