1 (* Copyright (C) 2005, HELM Team.
3 * This file is part of HELM, an Hypertextual, Electronic
4 * Library of Mathematics, developed at the Computer Science
5 * Department, University of Bologna, Italy.
7 * HELM is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * HELM is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with HELM; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 * For details, see the HELM World-Wide-Web page,
23 * http://cs.unibo.it/helm/.
26 (* let _profiler = <:profiler<_profiler>>;; *)
30 (* set to false to disable paramodulation inside auto_tac *)
32 let connect_to_auto = true;;
35 (* profiling statistics... *)
36 let infer_time = ref 0.;;
37 let forward_simpl_time = ref 0.;;
38 let forward_simpl_new_time = ref 0.;;
39 let backward_simpl_time = ref 0.;;
40 let passive_maintainance_time = ref 0.;;
42 (* limited-resource-strategy related globals *)
43 let processed_clauses = ref 0;; (* number of equalities selected so far... *)
44 let time_limit = ref 0.;; (* in seconds, settable by the user... *)
45 let start_time = ref 0.;; (* time at which the execution started *)
46 let elapsed_time = ref 0.;;
47 (* let maximal_weight = ref None;; *)
48 let maximal_retained_equality = ref None;;
50 (* equality-selection related globals *)
51 let use_fullred = ref true;;
52 let weight_age_ratio = ref 6 (* 5 *);; (* settable by the user *)
53 let weight_age_counter = ref !weight_age_ratio ;;
54 let symbols_ratio = ref 0 (* 3 *);;
55 let symbols_counter = ref 0;;
57 (* non-recursive Knuth-Bendix term ordering by default *)
58 (* Utils.compare_terms := Utils.rpo;; *)
59 (* Utils.compare_terms := Utils.nonrec_kbo;; *)
60 (* Utils.compare_terms := Utils.ao;; *)
63 let derived_clauses = ref 0;;
64 let kept_clauses = ref 0;;
66 (* index of the greatest Cic.Meta created - TODO: find a better way! *)
69 (* varbiables controlling the search-space *)
70 let maxdepth = ref 3;;
71 let maxwidth = ref 3;;
73 type theorem = Cic.term * Cic.term * Cic.metasenv;;
75 let symbols_of_equality equality =
76 let (_, _, (_, left, right, _), _,_) = Equality.open_equality equality in
77 let m1 = Utils.symbols_of_term left in
82 let c = Utils.TermMap.find k res in
83 Utils.TermMap.add k (c+v) res
85 Utils.TermMap.add k v res)
86 (Utils.symbols_of_term right) m1
92 module OrderedEquality = struct
93 type t = Equality.equality
96 match Equality.meta_convertibility_eq eq1 eq2 with
99 let w1, _, (ty,left, right, _), m1,_ = Equality.open_equality eq1 in
100 let w2, _, (ty',left', right', _), m2,_ = Equality.open_equality eq2 in
101 match Pervasives.compare w1 w2 with
103 let res = (List.length m1) - (List.length m2) in
104 if res <> 0 then res else
105 Equality.compare eq1 eq2
109 module EqualitySet = Set.Make(OrderedEquality);;
111 type passive_table = Equality.equality list * EqualitySet.t
112 type active_table = Equality.equality list * Indexing.Index.t
114 Equality.goal_proof * Equality.proof * int * Subst.substitution * Cic.metasenv
116 | ParamodulationFailure of string * active_table * passive_table
117 | ParamodulationSuccess of new_proof * active_table * passive_table
120 let list_of_passive (l,s) = l
123 let make_passive eq_list =
125 List.fold_left (fun s e -> EqualitySet.add e s) EqualitySet.empty eq_list
127 (*EqualitySet.elements set*) eq_list, set (* see applys.ma *)
129 let make_empty_active () = [], Indexing.empty ;;
130 let make_active eq_list =
131 eq_list, List.fold_left Indexing.index Indexing.empty eq_list
134 let size_of_passive (passive_list, _) = List.length passive_list;;
135 let size_of_active (active_list, _) = List.length active_list;;
136 let passive_is_empty = function
137 | [], s when EqualitySet.is_empty s -> true
138 | [], s -> assert false (* the set and the list should be in sync *)
142 type goals = Equality.goal list * Equality.goal list
144 let no_more_passive_goals g = match g with | _,[] -> true | _ -> false;;
147 let age_factor = 0.01;;
150 selects one equality from passive. The selection strategy is a combination
151 of weight, age and goal-similarity
154 let rec select env g passive =
155 processed_clauses := !processed_clauses + 1;
158 match (List.rev goals) with goal::_ -> goal | _ -> assert false
161 let pos_list, pos_set = passive in
162 let remove eq l = List.filter (fun e -> Equality.compare e eq <> 0) l in
163 if !weight_age_ratio > 0 then
164 weight_age_counter := !weight_age_counter - 1;
165 match !weight_age_counter with
167 weight_age_counter := !weight_age_ratio;
168 let skip_giant pos_list pos_set =
170 | (hd:EqualitySet.elt)::tl ->
171 let w,_,_,_,_ = Equality.open_equality hd in
173 hd, (tl, EqualitySet.remove hd pos_set)
177 ("+++ skipping giant of size "^string_of_int w^" +++");
179 select env g (tl@[hd],pos_set)
182 skip_giant pos_list pos_set)
185 let rec skip_giant pos_list pos_set =
187 | (hd:EqualitySet.elt)::tl ->
188 let w,_,_,_,_ = Equality.open_equality hd in
189 let pos_set = EqualitySet.remove hd pos_set in
194 ("+++ skipping giant of size "^string_of_int w^" +++");
195 skip_giant tl pos_set)
198 skip_giant pos_list pos_set)
202 | _ when (!symbols_counter > 0) ->
203 (symbols_counter := !symbols_counter - 1;
204 let cardinality map =
205 Utils.TermMap.fold (fun k v res -> res + v) map 0
208 let _, _, term = goal in
209 Utils.symbols_of_term term
211 let card = cardinality symbols in
212 let foldfun k v (r1, r2) =
213 if Utils.TermMap.mem k symbols then
214 let c = Utils.TermMap.find k symbols in
215 let c1 = abs (c - v) in
221 let f equality (i, e) =
223 Utils.TermMap.fold foldfun (symbols_of_equality equality) (0, 0)
225 let c = others + (abs (common - card)) in
226 if c < i then (c, equality)
229 let e1 = EqualitySet.min_elt pos_set in
232 Utils.TermMap.fold foldfun (symbols_of_equality e1) (0, 0)
234 (others + (abs (common - card))), e1
236 let _, current = EqualitySet.fold f pos_set initial in
238 (remove current pos_list, EqualitySet.remove current pos_set))
241 symbols_counter := !symbols_ratio;
243 let w1,_,_,_,_ = Equality.open_equality e1 in
244 let w2,_,_,_,_ = Equality.open_equality e2 in
245 if w1 < w2 then e1 else e2
247 let rec my_min_elt min = function
249 | hd::tl -> my_min_elt (my_min hd min) tl
251 (* let current = EqualitySet.min_elt pos_set in *)
252 let current = my_min_elt (List.hd pos_list) (List.tl pos_list) in
253 current,(remove current pos_list, EqualitySet.remove current pos_set)
257 let filter_dependent bag passive id =
258 let pos_list, pos_set = passive in
259 let passive,no_pruned =
261 (fun eq ((list,set),no) ->
262 if Equality.depend bag eq id then
263 (list, EqualitySet.remove eq set), no + 1
266 pos_list (([],pos_set),0)
269 if no_pruned > 0 then
270 prerr_endline ("+++ pruning "^ string_of_int no_pruned ^" passives +++");
276 (* adds to passive a list of equalities new_pos *)
277 let add_to_passive passive new_pos preferred =
278 let pos_list, pos_set = passive in
279 let ok set equality = not (EqualitySet.mem equality set) in
280 let pos = List.filter (ok pos_set) new_pos in
281 let add set equalities =
282 List.fold_left (fun s e -> EqualitySet.add e s) set equalities
284 let pos_head, pos_tail =
286 (fun e -> List.exists (fun x -> Equality.compare x e = 0) preferred)
289 pos_head @ pos_list @ pos_tail, add pos_set pos
293 (* removes from passive equalities that are estimated impossible to activate
294 within the current time limit *)
295 let prune_passive howmany (active, _) passive =
296 let (pl, ps), tbl = passive in
297 let howmany = float_of_int howmany
298 and ratio = float_of_int !weight_age_ratio in
301 int_of_float (if t -. v < 0.5 then t else v)
303 let in_weight = round (howmany *. ratio /. (ratio +. 1.))
304 and in_age = round (howmany /. (ratio +. 1.)) in
306 (lazy (Printf.sprintf "in_weight: %d, in_age: %d\n" in_weight in_age));
307 let counter = ref !symbols_ratio in
312 counter := !counter - 1;
313 if !counter = 0 then counter := !symbols_ratio in
314 let e = EqualitySet.min_elt ps in
315 let ps' = pickw (w-1) (EqualitySet.remove e ps) in
316 EqualitySet.add e ps'
318 let e = EqualitySet.min_elt ps in
319 let ps' = pickw (w-1) (EqualitySet.remove e ps) in
320 EqualitySet.add e ps'
324 let ps = pickw in_weight ps in
325 let rec picka w s l =
329 | hd::tl when not (EqualitySet.mem hd s) ->
330 let w, s, l = picka (w-1) s tl in
331 w, EqualitySet.add hd s, hd::l
333 let w, s, l = picka w s tl in
338 let _, ps, pl = picka in_age ps pl in
339 if not (EqualitySet.is_empty ps) then
340 maximal_retained_equality := Some (EqualitySet.max_elt ps);
343 (fun e tbl -> Indexing.index tbl e) ps Indexing.empty
349 (** inference of new equalities between current and some in active *)
350 let infer bag eq_uri env current (active_list, active_table) =
352 if Utils.debug_metas then
353 (ignore(Indexing.check_target bag c current "infer1");
354 ignore(List.map (function current -> Indexing.check_target bag c current "infer2") active_list));
356 let maxm, copy_of_current = Equality.fix_metas bag !maxmeta current in
358 let active_table = Indexing.index active_table copy_of_current in
359 (* let _ = <:start<current contro active>> in *)
361 Indexing.superposition_right bag eq_uri !maxmeta env active_table current
363 (* let _ = <:stop<current contro active>> in *)
364 if Utils.debug_metas then
367 Indexing.check_target bag c current "sup0") res);
369 let rec infer_positive table = function
373 Indexing.superposition_right bag
374 ~subterms_only:true eq_uri !maxmeta env table equality
377 if Utils.debug_metas then
381 Indexing.check_target bag c current "sup2") res);
382 let pos = infer_positive table tl in
386 let maxm, copy_of_current = Equality.fix_metas !maxmeta current in
389 let curr_table = Indexing.index Indexing.empty current in
390 (* let _ = <:start<active contro current>> in *)
391 let pos = infer_positive curr_table ((*copy_of_current::*)active_list) in
392 (* let _ = <:stop<active contro current>> in *)
393 if Utils.debug_metas then
396 Indexing.check_target bag c current "sup3") pos);
399 derived_clauses := !derived_clauses + (List.length new_pos);
400 match !maximal_retained_equality with
403 ignore(assert false);
404 (* if we have a maximal_retained_equality, we can discard all equalities
405 "greater" than it, as they will never be reached... An equality is
406 greater than maximal_retained_equality if it is bigger
407 wrt. OrderedEquality.compare and it is less similar than
408 maximal_retained_equality to the current goal *)
409 List.filter (fun e -> OrderedEquality.compare e eq <= 0) new_pos
412 let check_for_deep_subsumption env active_table eq =
413 let _,_,(eq_ty, left, right, order),metas,id = Equality.open_equality eq in
414 let check_subsumed deep l r =
416 Equality.mk_tmp_equality(0,(eq_ty,l,r,Utils.Incomparable),metas)in
417 match Indexing.subsumption env active_table eqtmp with
421 let rec aux b (ok_so_far, subsumption_used) t1 t2 =
423 | t1, t2 when not ok_so_far -> ok_so_far, subsumption_used
424 | t1, t2 when subsumption_used -> t1 = t2, subsumption_used
425 | Cic.Appl (h1::l),Cic.Appl (h2::l') ->
426 let rc = check_subsumed b t1 t2 in
432 (fun (ok_so_far, subsumption_used) t t' ->
433 aux true (ok_so_far, subsumption_used) t t')
434 (ok_so_far, subsumption_used) l l'
435 with Invalid_argument _ -> false,subsumption_used)
437 false, subsumption_used
438 | _ -> false, subsumption_used
440 fst (aux false (true,false) left right)
443 (** simplifies current using active and passive *)
444 let forward_simplify bag eq_uri env current (active_list, active_table) =
445 let _, context, _ = env in
446 let demodulate table current =
447 let newmeta, newcurrent =
448 Indexing.demodulation_equality bag eq_uri !maxmeta env table current
451 if Equality.is_identity env newcurrent then None else Some newcurrent
454 if Utils.debug_metas then
455 ignore (Indexing.check_target bag context current "demod0");
456 let res = demodulate active_table current in
457 if Utils.debug_metas then
458 ignore ((function None -> () | Some x ->
459 ignore (Indexing.check_target bag context x "demod1");()) res);
462 let res = demod current in
466 if Indexing.in_index active_table c ||
467 check_for_deep_subsumption env active_table c
474 (** simplifies new using active and passive *)
475 let forward_simplify_new bag eq_uri env new_pos active =
476 if Utils.debug_metas then
480 (fun current -> Indexing.check_target bag c current "forward new pos")
483 let active_list, active_table = active in
484 let demodulate table target =
485 let newmeta, newtarget =
486 Indexing.demodulation_equality bag eq_uri !maxmeta env table target
491 (* we could also demodulate using passive. Currently we don't *)
492 let new_pos = List.map (demodulate active_table) new_pos in
496 if not (Equality.is_identity env e) then
499 EqualitySet.empty new_pos
501 let new_pos = EqualitySet.elements new_pos_set in
503 let subs e = Indexing.subsumption env active_table e = None in
504 let is_duplicate e = not (Indexing.in_index active_table e) in
505 List.filter subs (List.filter is_duplicate new_pos)
509 (** simplifies a goal with equalities in active and passive *)
510 let rec simplify_goal bag env goal (active_list, active_table) =
511 let demodulate table goal = Indexing.demodulation_goal bag env table goal in
512 let changed, goal = demodulate active_table goal in
517 snd (simplify_goal bag env goal (active_list, active_table))
521 let simplify_goals bag env goals active =
522 let a_goals, p_goals = goals in
523 let p_goals = List.map (fun g -> snd (simplify_goal bag env g active)) p_goals in
524 let a_goals = List.map (fun g -> snd (simplify_goal bag env g active)) a_goals in
529 (** simplifies active usign new *)
530 let backward_simplify_active
531 bag eq_uri env new_pos new_table min_weight active
533 let active_list, active_table = active in
534 let active_list, newa, pruned =
536 (fun equality (res, newn,pruned) ->
537 let ew, _, _, _,id = Equality.open_equality equality in
538 if ew < min_weight then
539 equality::res, newn,pruned
542 forward_simplify bag eq_uri env equality (new_pos, new_table)
544 | None -> res, newn, id::pruned
546 if Equality.compare equality e = 0 then
549 res, e::newn, pruned)
550 active_list ([], [],[])
553 List.exists (Equality.meta_convertibility_eq eq1) where
556 let _, _, _, _,id = Equality.open_equality eq in id
558 let ((active1,pruned),tbl), newa =
560 (fun eq ((res,pruned), tbl) ->
561 if List.mem eq res then
562 (res, (id_of_eq eq)::pruned),tbl
563 else if (Equality.is_identity env eq) || (find eq res) then (
564 (res, (id_of_eq eq)::pruned),tbl
567 (eq::res,pruned), Indexing.index tbl eq)
568 active_list (([],pruned), Indexing.empty),
571 if (Equality.is_identity env eq) then p
576 | [] -> (active1,tbl), None, pruned
577 | _ -> (active1,tbl), Some newa, pruned
581 (** simplifies passive using new *)
582 let backward_simplify_passive
583 bag eq_uri env new_pos new_table min_weight passive
585 let (pl, ps), passive_table = passive in
586 let f equality (resl, ress, newn) =
587 let ew, _, _, _ , _ = Equality.open_equality equality in
588 if ew < min_weight then
589 equality::resl, ress, newn
592 forward_simplify bag eq_uri env equality (new_pos, new_table)
594 | None -> resl, EqualitySet.remove equality ress, newn
597 equality::resl, ress, newn
599 let ress = EqualitySet.remove equality ress in
602 let pl, ps, newp = List.fold_right f pl ([], ps, []) in
605 (fun tbl e -> Indexing.index tbl e) Indexing.empty pl
608 | [] -> ((pl, ps), passive_table), None
609 | _ -> ((pl, ps), passive_table), Some (newp)
612 let build_table equations =
615 let ew, _, _, _ , _ = Equality.open_equality e in
616 e::l, Indexing.index t e, min ew w)
617 ([], Indexing.empty, 1000000) equations
621 let backward_simplify bag eq_uri env new' active =
622 let new_pos, new_table, min_weight = build_table new' in
623 let active, newa, pruned =
624 backward_simplify_active bag eq_uri env new_pos new_table min_weight active
629 let close bag eq_uri env new' given =
630 let new_pos, new_table, min_weight =
633 let ew, _, _, _ , _ = Equality.open_equality e in
634 e::l, Indexing.index t e, min ew w)
635 ([], Indexing.empty, 1000000) (snd new')
639 let pos = infer bag eq_uri env c (new_pos,new_table) in
644 let is_commutative_law eq =
645 let w, proof, (eq_ty, left, right, order), metas , _ =
646 Equality.open_equality eq
648 match left,right with
649 Cic.Appl[f1;Cic.Meta _ as a1;Cic.Meta _ as b1],
650 Cic.Appl[f2;Cic.Meta _ as a2;Cic.Meta _ as b2] ->
651 f1 = f2 && a1 = b2 && a2 = b1
655 let prova bag eq_uri env new' active =
656 let given = List.filter is_commutative_law (fst active) in
660 (Printf.sprintf "symmetric:\n%s\n"
663 (fun e -> Equality.string_of_equality ~env e)
665 close bag eq_uri env new' given
668 (* returns an estimation of how many equalities in passive can be activated
669 within the current time limit *)
670 let get_selection_estimate () =
671 elapsed_time := (Unix.gettimeofday ()) -. !start_time;
672 (* !processed_clauses * (int_of_float (!time_limit /. !elapsed_time)) *)
674 ceil ((float_of_int !processed_clauses) *.
675 ((!time_limit (* *. 2. *)) /. !elapsed_time -. 1.)))
679 (** initializes the set of goals *)
680 let make_goals goal =
682 and passive = [0, [goal]] in
686 let make_goal_set goal =
690 (** initializes the set of theorems *)
691 let make_theorems theorems =
696 let activate_goal (active, passive) =
699 | goal_conj::tl -> true, (goal_conj::active, tl)
700 | [] -> false, (active, passive)
702 true, (active,passive)
706 let activate_theorem (active, passive) =
708 | theorem::tl -> true, (theorem::active, tl)
709 | [] -> false, (active, passive)
714 let simplify_theorems bag env theorems ?passive (active_list, active_table) =
715 let pl, passive_table =
718 | Some ((pn, _), (pp, _), pt) -> pn @ pp, Some pt
720 let a_theorems, p_theorems = theorems in
721 let demodulate table theorem =
722 let newmeta, newthm =
723 Indexing.demodulation_theorem bag !maxmeta env table theorem in
725 theorem != newthm, newthm
727 let foldfun table (a, p) theorem =
728 let changed, theorem = demodulate table theorem in
729 if changed then (a, theorem::p) else (theorem::a, p)
731 let mapfun table theorem = snd (demodulate table theorem) in
732 match passive_table with
734 let p_theorems = List.map (mapfun active_table) p_theorems in
735 List.fold_left (foldfun active_table) ([], p_theorems) a_theorems
736 | Some passive_table ->
737 let p_theorems = List.map (mapfun active_table) p_theorems in
738 let p_theorems, a_theorems =
739 List.fold_left (foldfun active_table) ([], p_theorems) a_theorems in
740 let p_theorems = List.map (mapfun passive_table) p_theorems in
741 List.fold_left (foldfun passive_table) ([], p_theorems) a_theorems
745 let rec simpl bag eq_uri env e others others_simpl =
746 let active = others @ others_simpl in
750 if Equality.is_identity env e then t else Indexing.index t e)
751 Indexing.empty active
754 forward_simplify bag eq_uri env e (active, tbl)
759 | None -> simpl bag eq_uri env hd tl others_simpl
760 | Some e -> simpl bag eq_uri env hd tl (e::others_simpl)
764 | None -> others_simpl
765 | Some e -> e::others_simpl
769 let simplify_equalities bag eq_uri env equalities =
772 (Printf.sprintf "equalities:\n%s\n"
774 (List.map Equality.string_of_equality equalities))));
775 Utils.debug_print (lazy "SIMPLYFYING EQUALITIES...");
776 match equalities with
780 List.rev (simpl bag eq_uri env hd tl [])
784 (Printf.sprintf "equalities AFTER:\n%s\n"
786 (List.map Equality.string_of_equality res))));
790 let print_goals goals =
797 (* (string_of_proof p) ^ ", " ^ *) (CicPp.ppterm t)) gl
799 Printf.sprintf "%d: %s" d (String.concat "; " gl')) goals))
802 let pp_goal_set msg goals names =
803 let active_goals, passive_goals = goals in
804 prerr_endline ("////" ^ msg);
805 prerr_endline ("ACTIVE G: " ^
806 (String.concat "\n " (List.map (fun (_,_,g) -> CicPp.pp g names)
808 prerr_endline ("PASSIVE G: " ^
809 (String.concat "\n " (List.map (fun (_,_,g) -> CicPp.pp g names)
813 let check_if_goal_is_subsumed bag ((_,ctx,_) as env) table (goalproof,menv,ty) =
814 (* let names = Utils.names_of_context ctx in *)
816 | Cic.Appl[Cic.MutInd(uri,_,_);eq_ty;left;right]
817 when LibraryObjects.is_eq_URI uri ->
819 Equality.mk_equality bag
820 (0,Equality.Exact (Cic.Implicit None),(eq_ty,left,right,Utils.Eq),menv)
822 (* match Indexing.subsumption env table goal_equation with*)
823 match Indexing.unification env table goal_equation with
824 | Some (subst, equality, swapped ) ->
827 ("GOAL SUBSUMED IS: "^Equality.string_of_equality goal_equation ~env);
829 ("GOAL IS SUBSUMED BY: "^Equality.string_of_equality equality ~env);
830 prerr_endline ("SUBST:"^Subst.ppsubst ~names subst);
832 let (_,p,(ty,l,r,_),m,id) = Equality.open_equality equality in
833 let cicmenv = Subst.apply_subst_metasenv subst (m @ menv) in
836 Equality.symmetric bag eq_ty l id uri m
840 Some (goalproof, p, id, subst, cicmenv)
845 let find_all_subsumed bag env table (goalproof,menv,ty) =
847 | Cic.Appl[Cic.MutInd(uri,_,_);eq_ty;left;right]
848 when LibraryObjects.is_eq_URI uri ->
850 Equality.mk_equality bag
851 (0,Equality.Exact (Cic.Implicit None),(eq_ty,left,right,Utils.Eq),menv)
854 (fun (subst, equality, swapped ) ->
855 let (_,p,(ty,l,r,_),m,id) = Equality.open_equality equality in
856 let cicmenv = Subst.apply_subst_metasenv subst (m @ menv) in
859 Equality.symmetric bag eq_ty l id uri m
862 in (goalproof, p, id, subst, cicmenv))
863 (Indexing.unification_all env table goal_equation)
868 let check_if_goal_is_identity env = function
869 | (goalproof,m,Cic.Appl[Cic.MutInd(uri,_,ens);eq_ty;left;right])
870 when left = right && LibraryObjects.is_eq_URI uri ->
871 let reflproof = Equality.Exact (Equality.refl_proof uri eq_ty left) in
872 Some (goalproof, reflproof, 0, Subst.empty_subst,m)
873 | (goalproof,m,Cic.Appl[Cic.MutInd(uri,_,ens);eq_ty;left;right])
874 when LibraryObjects.is_eq_URI uri ->
875 (let _,context,_ = env in
878 Founif.unification m m context left right CicUniv.empty_ugraph
880 let reflproof = Equality.Exact (Equality.refl_proof uri eq_ty left) in
881 let m = Subst.apply_subst_metasenv s m in
882 Some (goalproof, reflproof, 0, s,m)
887 let rec check goal = function
891 | None -> check goal tl
892 | (Some p) as ok -> ok
895 let simplify_goal_set bag env goals active =
896 let active_goals, passive_goals = goals in
897 let find (_,_,g) where =
898 List.exists (fun (_,_,g1) -> Equality.meta_convertibility g g1) where
900 (* prova:tengo le passive semplificate
902 List.map (fun g -> snd (simplify_goal env g active)) passive_goals
905 (fun (acc_a,acc_p) goal ->
906 match simplify_goal bag env goal active with
909 if find g acc_p then acc_a,acc_p else acc_a,g::acc_p
911 if find g acc_a then acc_a,acc_p else g::acc_a,acc_p)
912 ([],passive_goals) active_goals
915 let check_if_goals_set_is_solved bag env active goals =
916 let active_goals, passive_goals = goals in
923 check_if_goal_is_identity env;
924 check_if_goal_is_subsumed bag env (snd active)])
925 (* provare active and passive?*)
929 let infer_goal_set bag env active goals =
930 let active_goals, passive_goals = goals in
931 let rec aux = function
932 | [] -> active_goals, []
934 let changed,selected = simplify_goal bag env hd active in
937 prerr_endline ("--------------- goal semplificato");
939 let (_,_,t1) = selected in
941 List.exists (fun (_,_,t) -> Equality.meta_convertibility t t1)
947 let passive_goals = tl in
948 let new_passive_goals =
949 if Utils.metas_of_term t1 = [] then passive_goals
951 let newmaxmeta,new' =
952 Indexing.superposition_left bag env (snd active) selected
955 maxmeta := newmaxmeta;
958 selected::active_goals, new_passive_goals
963 let infer_goal_set_with_current bag env current goals active =
964 let active_goals, passive_goals = simplify_goal_set bag env goals active in
965 let l,table,_ = build_table [current] in
969 let newmaxmeta, new' = Indexing.superposition_left bag env table g !maxmeta in
970 maxmeta := newmaxmeta;
972 passive_goals active_goals
977 let ids = List.map (fun _,_,i,_,_ -> i) p in
981 let ids_of_goal_set (ga,gp) =
982 List.flatten (List.map ids_of_goal ga) @
983 List.flatten (List.map ids_of_goal gp)
986 let size_of_goal_set_a (l,_) = List.length l;;
987 let size_of_goal_set_p (_,l) = List.length l;;
989 let pp_goals label goals context =
990 let names = Utils.names_of_context context in
994 (Printf.sprintf "Current goal: %s = %s\n" label (CicPp.pp g names)))
999 (Printf.sprintf "PASSIVE goal: %s = %s\n" label (CicPp.pp g names)))
1003 let print_status iterno goals active passive =
1005 (Printf.sprintf "\n%d #ACTIVES: %d #PASSIVES: %d #GOALSET: %d(%d)"
1006 iterno (size_of_active active) (size_of_passive passive)
1007 (size_of_goal_set_a goals) (size_of_goal_set_p goals))
1010 (** given-clause algorithm with full reduction strategy: NEW implementation *)
1011 (* here goals is a set of goals in OR *)
1013 bag eq_uri ((_,context,_) as env) goals passive active
1014 goal_steps saturation_steps max_time
1016 let initial_time = Unix.gettimeofday () in
1017 let iterations_left iterno =
1018 let now = Unix.gettimeofday () in
1019 let time_left = max_time -. now in
1020 let time_spent_until_now = now -. initial_time in
1021 let iteration_medium_cost =
1022 time_spent_until_now /. (float_of_int iterno)
1024 let iterations_left = time_left /. iteration_medium_cost in
1025 int_of_float iterations_left
1027 let rec step goals passive active g_iterno s_iterno =
1028 if g_iterno > goal_steps && s_iterno > saturation_steps then
1029 (ParamodulationFailure ("No more iterations to spend",active,passive))
1030 else if Unix.gettimeofday () > max_time then
1031 (ParamodulationFailure ("No more time to spend",active,passive))
1034 print_status (max g_iterno s_iterno) goals active passive
1035 (* Printf.eprintf ".%!"; *)
1037 (* PRUNING OF PASSIVE THAT WILL NEVER BE PROCESSED *)
1039 let selection_estimate = iterations_left (max g_iterno s_iterno) in
1040 let kept = size_of_passive passive in
1041 if kept > selection_estimate then
1043 (*Printf.eprintf "Too many passive equalities: pruning...";
1044 prune_passive selection_estimate active*) passive
1049 kept_clauses := (size_of_passive passive) + (size_of_active active);
1051 if g_iterno < goal_steps then
1052 infer_goal_set bag env active goals
1056 match check_if_goals_set_is_solved bag env active goals with
1059 (Printf.sprintf "\nFound a proof in: %f\n"
1060 (Unix.gettimeofday() -. initial_time));
1061 ParamodulationSuccess (p,active,passive)
1064 if passive_is_empty passive then
1065 if no_more_passive_goals goals then
1066 ParamodulationFailure
1067 ("No more passive equations/goals",active,passive)
1068 (*maybe this is a success! *)
1070 step goals passive active (g_iterno+1) (s_iterno+1)
1073 (* COLLECTION OF GARBAGED EQUALITIES *)
1074 if max g_iterno s_iterno mod 40 = 0 then
1076 print_status (max g_iterno s_iterno) goals active passive;
1077 let active = List.map Equality.id_of (fst active) in
1078 let passive = List.map Equality.id_of (fst passive) in
1079 let goal = ids_of_goal_set goals in
1080 Equality.collect bag active passive goal
1083 if s_iterno < saturation_steps then
1084 let current, passive = select env goals passive in
1085 (* SIMPLIFICATION OF CURRENT *)
1088 Equality.string_of_equality ~env current);
1089 forward_simplify bag eq_uri env current active, passive
1094 | None -> step goals passive active (g_iterno+1) (s_iterno+1)
1096 (* GENERATION OF NEW EQUATIONS *)
1097 (* prerr_endline "infer"; *)
1098 let new' = infer bag eq_uri env current active in
1099 (* prerr_endline "infer goal"; *)
1101 match check_if_goals_set_is_solved env active goals with
1104 (Printf.sprintf "Found a proof in: %f\n"
1105 (Unix.gettimeofday() -. initial_time));
1106 ParamodulationSuccess p
1111 let al, tbl = active in
1112 al @ [current], Indexing.index tbl current
1115 infer_goal_set_with_current bag env current goals active
1118 (* FORWARD AND BACKWARD SIMPLIFICATION *)
1119 (* prerr_endline "fwd/back simpl"; *)
1120 let rec simplify new' active passive =
1122 forward_simplify_new bag eq_uri env new' active
1124 let active, newa, pruned =
1125 backward_simplify bag eq_uri env new' active
1128 List.fold_left (filter_dependent bag) passive pruned
1131 | None -> active, passive, new'
1132 | Some p -> simplify (new' @ p) active passive
1134 let active, passive, new' =
1135 simplify new' active passive
1138 (* prerr_endline "simpl goal with new"; *)
1140 let a,b,_ = build_table new' in
1141 (* let _ = <:start<simplify_goal_set new>> in *)
1142 let rc = simplify_goal_set bag env goals (a,b) in
1143 (* let _ = <:stop<simplify_goal_set new>> in *)
1146 let passive = add_to_passive passive new' [] in
1147 step goals passive active (g_iterno+1) (s_iterno+1)
1150 step goals passive active 1 1
1153 let rec saturate_equations bag eq_uri env goal accept_fun passive active =
1154 elapsed_time := Unix.gettimeofday () -. !start_time;
1155 if !elapsed_time > !time_limit then
1158 let current, passive = select env ([goal],[]) passive in
1159 let res = forward_simplify bag eq_uri env current active in
1162 saturate_equations bag eq_uri env goal accept_fun passive active
1164 Utils.debug_print (lazy (Printf.sprintf "selected: %s"
1165 (Equality.string_of_equality ~env current)));
1166 let new' = infer bag eq_uri env current active in
1168 if Equality.is_identity env current then active
1170 let al, tbl = active in
1171 al @ [current], Indexing.index tbl current
1173 (* alla fine new' contiene anche le attive semplificate!
1174 * quindi le aggiungo alle passive insieme alle new *)
1175 let rec simplify new' active passive =
1176 let new' = forward_simplify_new bag eq_uri env new' active in
1177 let active, newa, pruned =
1178 backward_simplify bag eq_uri env new' active in
1180 List.fold_left (filter_dependent bag) passive pruned in
1182 | None -> active, passive, new'
1183 | Some p -> simplify (new' @ p) active passive
1185 let active, passive, new' = simplify new' active passive in
1189 (Printf.sprintf "active:\n%s\n"
1192 (fun e -> Equality.string_of_equality ~env e)
1198 (Printf.sprintf "new':\n%s\n"
1201 (fun e -> "Negative " ^
1202 (Equality.string_of_equality ~env e)) new'))))
1204 let new' = List.filter accept_fun new' in
1205 let passive = add_to_passive passive new' [] in
1206 saturate_equations bag eq_uri env goal accept_fun passive active
1209 let default_depth = !maxdepth
1210 and default_width = !maxwidth;;
1214 symbols_counter := 0;
1215 weight_age_counter := !weight_age_ratio;
1216 processed_clauses := 0;
1219 maximal_retained_equality := None;
1221 forward_simpl_time := 0.;
1222 forward_simpl_new_time := 0.;
1223 backward_simpl_time := 0.;
1224 passive_maintainance_time := 0.;
1225 derived_clauses := 0;
1229 let eq_of_goal = function
1230 | Cic.Appl [Cic.MutInd(uri,0,_);_;_;_] when LibraryObjects.is_eq_URI uri ->
1232 | _ -> raise (ProofEngineTypes.Fail (lazy ("The goal is not an equality ")))
1235 let eq_and_ty_of_goal = function
1236 | Cic.Appl [Cic.MutInd(uri,0,_);t;_;_] when LibraryObjects.is_eq_URI uri ->
1238 | _ -> raise (ProofEngineTypes.Fail (lazy ("The goal is not an equality ")))
1241 (* fix proof takes in input a term and try to build a metasenv for it *)
1243 let fix_proof metasenv context all_implicits p =
1244 let rec aux metasenv n p =
1247 if all_implicits then
1248 metasenv,Cic.Implicit None
1251 CicMkImplicit.identity_relocation_list_for_metavariable context
1253 let meta = CicSubstitution.lift n (Cic.Meta (i,irl)) in
1256 let _ = CicUtil.lookup_meta i metasenv in metasenv
1257 with CicUtil.Meta_not_found _ ->
1258 prerr_endline ("not found: "^(string_of_int i));
1259 let metasenv,j = CicMkImplicit.mk_implicit_type metasenv [] context in
1260 (i,context,Cic.Meta(j,irl))::metasenv
1266 (fun a (metasenv,l) ->
1267 let metasenv,a' = aux metasenv n a in
1270 in metasenv,Cic.Appl l
1271 | Cic.Lambda(name,s,t) ->
1272 let metasenv,s = aux metasenv n s in
1273 let metasenv,t = aux metasenv (n+1) t in
1274 metasenv,Cic.Lambda(name,s,t)
1275 | Cic.Prod(name,s,t) ->
1276 let metasenv,s = aux metasenv n s in
1277 let metasenv,t = aux metasenv (n+1) t in
1278 metasenv,Cic.Prod(name,s,t)
1279 | Cic.LetIn(name,s,t) ->
1280 let metasenv,s = aux metasenv n s in
1281 let metasenv,t = aux metasenv (n+1) t in
1282 metasenv,Cic.LetIn(name,s,t)
1283 | Cic.Const(uri,ens) ->
1286 (fun (v,a) (metasenv,ens) ->
1287 let metasenv,a' = aux metasenv n a in
1288 metasenv,(v,a')::ens)
1291 metasenv,Cic.Const(uri,ens)
1297 let fix_metasenv metasenv =
1300 let m,t = fix_proof m c false t in
1301 let m = List.filter (fun (j,_,_) -> j<>i) m in
1306 (* status: input proof status
1307 * goalproof: forward steps on goal
1308 * newproof: backward steps
1309 * subsumption_id: the equation used if goal is closed by subsumption
1310 * (0 if not closed by subsumption) (DEBUGGING: can be safely removed)
1311 * subsumption_subst: subst to make newproof and goalproof match
1312 * proof_menv: final metasenv
1317 goalproof newproof subsumption_id subsumption_subst proof_menv
1319 if proof_menv = [] then prerr_endline "+++++++++++++++VUOTA"
1320 else prerr_endline (CicMetaSubst.ppmetasenv [] proof_menv);
1321 let proof, goalno = status in
1322 let uri, metasenv, meta_proof, term_to_prove, attrs = proof in
1323 let _, context, type_of_goal = CicUtil.lookup_meta goalno metasenv in
1324 let eq_uri = eq_of_goal type_of_goal in
1325 let names = Utils.names_of_context context in
1326 prerr_endline "Proof:";
1328 (Equality.pp_proof bag names goalproof newproof subsumption_subst
1329 subsumption_id type_of_goal);
1331 prerr_endline ("max weight: " ^
1332 (string_of_int (Equality.max_weight goalproof newproof)));
1334 (* generation of the CIC proof *)
1335 (* let metasenv' = List.filter (fun i,_,_ -> i<>goalno) metasenv in *)
1337 List.filter (fun i -> i <> goalno)
1338 (ProofEngineHelpers.compare_metasenvs
1339 ~newmetasenv:metasenv ~oldmetasenv:proof_menv) in
1340 let goal_proof, side_effects_t =
1341 let initial = (* Equality.add_subst subsumption_subst*) newproof in
1342 Equality.build_goal_proof bag
1343 eq_uri goalproof initial type_of_goal side_effects
1346 (* Equality.draw_proof bag names goalproof newproof subsumption_id; *)
1347 let goal_proof = Subst.apply_subst subsumption_subst goal_proof in
1348 let real_menv = fix_metasenv (proof_menv@metasenv) in
1349 let real_menv,goal_proof =
1350 fix_proof real_menv context false goal_proof in
1352 let real_menv,fixed_proof = fix_proof proof_menv context false goal_proof in
1353 (* prerr_endline ("PROOF: " ^ CicPp.pp goal_proof names); *)
1355 let pp_error goal_proof names error exn =
1356 prerr_endline "THE PROOF DOES NOT TYPECHECK! <begin>";
1357 prerr_endline (CicPp.pp goal_proof names);
1358 prerr_endline "THE PROOF DOES NOT TYPECHECK!";
1359 prerr_endline error;
1360 prerr_endline "THE PROOF DOES NOT TYPECHECK! <end>";
1363 let goal_proof,goal_ty,real_menv,_ =
1364 (* prerr_endline ("parte la refine per: " ^ (CicPp.pp goal_proof names)); *)
1366 prerr_endline (CicPp.ppterm goal_proof);
1367 CicRefine.type_of_aux' real_menv context goal_proof CicUniv.empty_ugraph
1369 | CicRefine.RefineFailure s
1370 | CicRefine.Uncertain s
1371 | CicRefine.AssertFailure s as exn ->
1372 pp_error goal_proof names (Lazy.force s) exn
1373 | CicUtil.Meta_not_found i as exn ->
1374 pp_error goal_proof names ("META NOT FOUND: "^string_of_int i) exn
1375 | Invalid_argument "list_fold_left2" as exn ->
1376 pp_error goal_proof names "Invalid_argument: list_fold_left2" exn
1378 let subst_side_effects,real_menv,_ =
1380 CicUnification.fo_unif_subst [] context real_menv
1381 goal_ty type_of_goal CicUniv.empty_ugraph
1383 | CicUnification.UnificationFailure s
1384 | CicUnification.Uncertain s
1385 | CicUnification.AssertFailure s -> assert false
1386 (* fail "Maybe the local context of metas in the goal was not an IRL" s *)
1388 prerr_endline "+++++++++++++ FINE UNIF";
1390 (goalno,(context,goal_proof,type_of_goal))::subst_side_effects
1393 let metas_of_proof = Utils.metas_of_term goal_proof in
1395 let proof, real_metasenv =
1396 ProofEngineHelpers.subst_meta_and_metasenv_in_proof
1397 proof goalno (CicMetaSubst.apply_subst final_subst)
1398 (List.filter (fun i,_,_ -> i<>goalno ) real_menv)
1401 (ProofEngineHelpers.compare_metasenvs
1402 ~oldmetasenv:metasenv ~newmetasenv:real_metasenv) in
1405 List.map (fun i,_,_ -> i) real_metasenv in
1407 final_subst, proof, open_goals
1412 let metas_still_open_in_proof = Utils.metas_of_term goal_proof in
1413 (* prerr_endline (CicPp.pp goal_proof names); *)
1414 let goal_proof = (* Subst.apply_subst subsumption_subst *) goal_proof in
1415 let side_effects_t =
1416 List.map (Subst.apply_subst subsumption_subst) side_effects_t
1418 (* replacing fake mets with real ones *)
1419 (* prerr_endline "replacing metas..."; *)
1420 let irl=CicMkImplicit.identity_relocation_list_for_metavariable context in
1421 if proof_menv = [] then prerr_endline "VUOTA";
1422 CicMetaSubst.ppmetasenv [] proof_menv;
1423 let what, with_what =
1425 (fun (acc1,acc2) i ->
1426 (Cic.Meta(i,[]))::acc1, (Cic.Implicit None)::acc2)
1428 metas_still_open_in_proof
1432 List.mem i metas_still_open_in_proof
1433 (*&& not(List.mem i metas_still_open_in_goal)*))
1437 let goal_proof_menv =
1439 (fun (i,_,_) -> List.mem i metas_still_open_in_proof)
1443 (* we need this fake equality since the metas of the hypothesis may be
1444 * with a real local context *)
1445 ProofEngineReduction.replace_lifting
1446 ~equality:(fun x y ->
1447 match x,y with Cic.Meta(i,_),Cic.Meta(j,_) -> i=j | _-> false)
1448 ~what ~with_what ~where
1450 let goal_proof = replace goal_proof in
1451 (* ok per le meta libere... ma per quelle che c'erano e sono rimaste?
1452 * what mi pare buono, sostituisce solo le meta farlocche *)
1453 let side_effects_t = List.map replace side_effects_t in
1455 List.filter (fun i -> i <> goalno)
1456 (ProofEngineHelpers.compare_metasenvs
1457 ~oldmetasenv:metasenv ~newmetasenv:goal_proof_menv)
1461 * String.concat "," (List.map string_of_int free_metas) ); *)
1462 (* check/refine/... build the new proof *)
1464 ProofEngineReduction.replace
1465 ~what:side_effects ~with_what:side_effects_t
1466 ~equality:(fun i t -> match t with Cic.Meta(j,_)->j=i|_->false)
1469 let goal_proof,goal_ty,real_menv,_ =
1470 prerr_endline "parte la refine";
1472 CicRefine.type_of_aux' metasenv context goal_proof
1473 CicUniv.empty_ugraph
1475 | CicUtil.Meta_not_found _
1476 | CicRefine.RefineFailure _
1477 | CicRefine.Uncertain _
1478 | CicRefine.AssertFailure _
1479 | Invalid_argument "list_fold_left2" as exn ->
1480 prerr_endline "THE PROOF DOES NOT TYPECHECK!";
1481 prerr_endline (CicPp.pp goal_proof names);
1482 prerr_endline "THE PROOF DOES NOT TYPECHECK!";
1485 prerr_endline "+++++++++++++ METASENV";
1487 (CicMetaSubst.ppmetasenv [] real_menv);
1488 let subst_side_effects,real_menv,_ =
1490 prerr_endline ("XX type_of_goal " ^ CicPp.ppterm type_of_goal);
1491 prerr_endline ("XX replaced_goal " ^ CicPp.ppterm replaced_goal);
1492 prerr_endline ("XX metasenv " ^
1493 CicMetaSubst.ppmetasenv [] (metasenv @ free_metas_menv));
1496 CicUnification.fo_unif_subst [] context real_menv
1497 goal_ty type_of_goal CicUniv.empty_ugraph
1499 | CicUnification.UnificationFailure s
1500 | CicUnification.Uncertain s
1501 | CicUnification.AssertFailure s -> assert false
1502 (* fail "Maybe the local context of metas in the goal was not an IRL" s *)
1505 (goalno,(context,goal_proof,type_of_goal))::subst_side_effects
1508 let metas_of_proof = Utils.metas_of_term goal_proof in
1510 let proof, real_metasenv =
1511 ProofEngineHelpers.subst_meta_and_metasenv_in_proof
1512 proof goalno (CicMetaSubst.apply_subst final_subst)
1513 (List.filter (fun i,_,_ -> i<>goalno ) real_menv)
1516 List.map (fun i,_,_ -> i) real_metasenv in
1519 HExtlib.list_uniq (List.sort Pervasives.compare metas_of_proof)
1522 match free_meta with Some(Cic.Meta(m,_)) when m<>goalno ->[m] | _ ->[]
1527 "GOALS APERTI: %s\nMETASENV PRIMA:\n%s\nMETASENV DOPO:\n%s\n"
1528 (String.concat ", " (List.map string_of_int open_goals))
1529 (CicMetaSubst.ppmetasenv [] metasenv)
1530 (CicMetaSubst.ppmetasenv [] real_metasenv);
1532 final_subst, proof, open_goals
1536 (* **************** HERE ENDS THE PARAMODULATION STUFF ******************** *)
1538 (* exported functions *)
1540 let pump_actives context bag maxm active passive saturation_steps max_time =
1546 (fun acc e -> let _,_,_,menv,_ = Equality.open_equality e in
1547 List.fold_left (fun acc (i,_,_) -> max i acc) acc menv)
1550 (* let active_l = fst active in *)
1551 (* let passive_l = fst passive in *)
1552 (* let ma = max_l active_l in *)
1553 (* let mp = max_l passive_l in *)
1554 match LibraryObjects.eq_URI () with
1555 | None -> active, passive, !maxmeta
1557 let env = [],context,CicUniv.empty_ugraph in
1559 given_clause bag eq_uri env ([],[])
1560 passive active 0 saturation_steps max_time
1562 | ParamodulationFailure (_,a,p) ->
1564 | ParamodulationSuccess _ ->
1568 let all_subsumed bag maxm status active passive =
1570 let proof, goalno = status in
1571 let uri, metasenv, meta_proof, term_to_prove, attrs = proof in
1572 let _, context, type_of_goal = CicUtil.lookup_meta goalno metasenv in
1573 let env = metasenv,context,CicUniv.empty_ugraph in
1574 let cleaned_goal = Utils.remove_local_context type_of_goal in
1575 let goal = [], List.filter (fun (i,_,_)->i<>goalno) metasenv, cleaned_goal in
1576 prerr_endline (string_of_int (List.length (fst active)));
1577 (* we simplify using both actives passives *)
1580 (fun (l,tbl) eq -> eq::l,(Indexing.index tbl eq))
1581 active (list_of_passive passive) in
1582 let _,goal = simplify_goal bag env goal table in
1583 let (_,_,ty) = goal in
1584 prerr_endline (CicPp.ppterm ty);
1585 let subsumed = find_all_subsumed bag env (snd table) goal in
1586 let subsumed_or_id =
1587 match (check_if_goal_is_identity env goal) with
1589 | Some id -> id::subsumed in
1593 (goalproof,newproof,subsumption_id,subsumption_subst, proof_menv) ->
1595 status goalproof newproof subsumption_id subsumption_subst proof_menv)
1601 bag maxm status active passive goal_steps saturation_steps max_time
1605 let active_l = fst active in
1609 (fun acc e -> let _,_,_,menv,_ = Equality.open_equality e in
1610 List.fold_left (fun acc (i,_,_) -> max i acc) acc menv)
1613 let passive_l = fst passive in
1614 let ma = max_l active_l in
1615 let mp = max_l passive_l in
1617 let proof, goalno = status in
1618 let uri, metasenv, meta_proof, term_to_prove, attrs = proof in
1619 let _, context, type_of_goal = CicUtil.lookup_meta goalno metasenv in
1620 let eq_uri = eq_of_goal type_of_goal in
1621 let cleaned_goal = Utils.remove_local_context type_of_goal in
1622 Utils.set_goal_symbols cleaned_goal; (* DISACTIVATED *)
1623 let metasenv' = List.filter (fun (i,_,_)->i<>goalno) metasenv in
1624 let goal = [], metasenv', cleaned_goal in
1625 let env = metasenv,context,CicUniv.empty_ugraph in
1626 prerr_endline ">>>>>> ACTIVES >>>>>>>>";
1627 List.iter (fun e -> prerr_endline (Equality.string_of_equality ~env e))
1629 prerr_endline ">>>>>>>>>>>>>>";
1630 let goals = make_goal_set goal in
1632 (* given_caluse non prende in input maxm ????? *)
1633 given_clause bag eq_uri env goals passive active
1634 goal_steps saturation_steps max_time
1636 | ParamodulationFailure (_,a,p) ->
1637 None, a, p, !maxmeta
1638 | ParamodulationSuccess
1639 ((goalproof,newproof,subsumption_id,subsumption_subst, proof_menv),a,p) ->
1640 let subst, proof, gl =
1642 status goalproof newproof subsumption_id subsumption_subst proof_menv
1644 Some (subst, proof,gl),a,p, !maxmeta
1647 let add_to_passive eql passives =
1648 add_to_passive passives eql eql