-let counter = ref 0
-
-(** given-clause algorithm with full reduction strategy *)
-let rec given_clause_fullred dbd env goals theorems ~passive active =
- let goals = simplify_goals env goals ~passive active in
- let _,context,_ = env in
- let ok, (goals:
- (Equality.goal_proof * Cic.metasenv * Cic.term) list *
- (Equality.goal_proof * Cic.metasenv * Cic.term) list) = activate_goal
-
- (goals:
- (Equality.goal_proof * Cic.metasenv * Cic.term) list *
- (Equality.goal_proof * Cic.metasenv * Cic.term) list)
- in
-(* let theorems = simplify_theorems env theorems ~passive active in *)
- if ok then
- let names = List.map (HExtlib.map_option (fun (name,_) -> name)) context in
- let _, _, t = List.hd (fst goals) in
- let _ = prerr_endline ("goal activated = " ^ (CicPp.pp t names)) in
-(* let _ = *)
-(* debug_print *)
-(* (lazy *)
-(* (Printf.sprintf "\ngoals = \nactive\n%s\npassive\n%s\n" *)
-(* (print_goals (fst goals)) (print_goals (snd goals)))); *)
-(* let current = List.hd (fst goals) in *)
-(* let p, _, t = List.hd (snd current) in *)
-(* debug_print *)
-(* (lazy *)
-(* (Printf.sprintf "goal activated:\n%s\n%s\n" *)
-(* (CicPp.ppterm t) (string_of_proof p))); *)
-(* in *)
- let ok, proof =
- (* apply_goal_to_theorems dbd env theorems ~passive active goals in *)
- let iseq uri = UriManager.eq uri (LibraryObjects.eq_URI ()) in
- match fst goals with
- | (goalproof,m,Cic.Appl[Cic.MutInd(uri,_,ens);eq_ty;left;right])::_
- when left = right && iseq uri ->
- let reflproof = Equality.Exact (Equality.refl_proof eq_ty left) in
- true, Some (goalproof, reflproof, 0, Subst.empty_subst,m)
- | goal::_ ->
- (match check_if_goal_is_subsumed env (snd active) goal with
- | None -> false,None
- | Some p ->
- prerr_endline "Proof found by subsumption!";
- true, Some p)
- | _ -> false, None
- in
- if ok then
- ( prerr_endline "esco qui";
- (*
- let s = Printf.sprintf "actives:\n%s\n"
- (String.concat "\n"
- ((List.map
- (fun (s, e) -> (string_of_sign s) ^ " " ^
- (string_of_equality ~env e))
- (fst active)))) in
- let sp = Printf.sprintf "passives:\n%s\n"
- (String.concat "\n"
- (List.map
- (string_of_equality ~env)
- (let x,y,_ = passive in (fst x)@(fst y)))) in
- prerr_endline s;
- prerr_endline sp; *)
- match proof with
- | None -> assert false
- | Some p -> ParamodulationSuccess p)
- else
- given_clause_fullred_aux dbd env goals theorems passive active
- else
-(* let ok', theorems = activate_theorem theorems in *)
-(* if ok' then *)
-(* let ok, goals = apply_theorem_to_goals env theorems active goals in *)
-(* if ok then *)
-(* let proof = *)
-(* match (fst goals) with *)
-(* | (_, [proof, _, _])::_ -> Some proof *)
-(* | _ -> assert false *)
-(* in *)
-(* ParamodulationSuccess (proof, env) *)
-(* else *)
-(* given_clause_fullred_aux env goals theorems passive active *)
-(* else *)
- if (passive_is_empty passive) then ParamodulationFailure ""
- else given_clause_fullred_aux dbd env goals theorems passive active
-
-and given_clause_fullred_aux dbd env goals theorems passive active =
- prerr_endline (string_of_int !counter ^
- " MAXMETA: " ^ string_of_int !maxmeta ^
- " #ACTIVES: " ^ string_of_int (size_of_active active) ^
- " #PASSIVES: " ^ string_of_int (size_of_passive passive));
- incr counter;
-(*
- if !counter mod 10 = 0 then
- begin
- let size = HExtlib.estimate_size (passive,active) in
- let sizep = HExtlib.estimate_size (passive) in
- let sizea = HExtlib.estimate_size (active) in
- let (l1,s1),(l2,s2), t = passive in
- let sizetbl = HExtlib.estimate_size t in
- let sizel = HExtlib.estimate_size (l1,l2) in
- let sizes = HExtlib.estimate_size (s1,s2) in
-
- prerr_endline ("SIZE: " ^ string_of_int size);
- prerr_endline ("SIZE P: " ^ string_of_int sizep);
- prerr_endline ("SIZE A: " ^ string_of_int sizea);
- prerr_endline ("SIZE TBL: " ^ string_of_int sizetbl ^
- " SIZE L: " ^ string_of_int sizel ^
- " SIZE S:" ^ string_of_int sizes);
- end;*)
-(*
- if (size_of_active active) mod 50 = 0 then
- (let s = Printf.sprintf "actives:\n%s\n"
- (String.concat "\n"
- ((List.map
- (fun (s, e) -> (string_of_sign s) ^ " " ^
- (string_of_equality ~env e))
- (fst active)))) in
- let sp = Printf.sprintf "passives:\n%s\n"
- (String.concat "\n"
- (List.map
- (string_of_equality ~env)
- (let x,y,_ = passive in (fst x)@(fst y)))) in
- prerr_endline s;
- prerr_endline sp); *)
- let time1 = Unix.gettimeofday () in
- let (_,context,_) = env in
- let selection_estimate = get_selection_estimate () in
- let kept = size_of_passive passive in
- let passive =
- if !time_limit = 0. || !processed_clauses = 0 then
- passive
- else if !elapsed_time > !time_limit then (
- debug_print (lazy (Printf.sprintf "Time limit (%.2f) reached: %.2f\n"
- !time_limit !elapsed_time));
- make_passive []
- ) else if kept > selection_estimate then (
- debug_print
- (lazy (Printf.sprintf ("Too many passive equalities: pruning..." ^^
- "(kept: %d, selection_estimate: %d)\n")
- kept selection_estimate));
- prune_passive selection_estimate active passive
- ) else
- passive
- in
-
- let time2 = Unix.gettimeofday () in
- passive_maintainance_time := !passive_maintainance_time +. (time2 -. time1);
-
- kept_clauses := (size_of_passive passive) + (size_of_active active);
- match passive_is_empty passive with
- | true -> ParamodulationFailure ""
- (* given_clause_fullred dbd env goals theorems passive active *)
- | false ->
- let current, passive = select env goals passive in
- prerr_endline
- ("Selected = " ^ Equality.string_of_equality ~env current);
-(* ^
- (let w,p,(t,l,r,o),m = current in
- " size w: " ^ string_of_int (HExtlib.estimate_size w)^
- " size p: " ^ string_of_int (HExtlib.estimate_size p)^
- " size t: " ^ string_of_int (HExtlib.estimate_size t)^
- " size l: " ^ string_of_int (HExtlib.estimate_size l)^
- " size r: " ^ string_of_int (HExtlib.estimate_size r)^
- " size o: " ^ string_of_int (HExtlib.estimate_size o)^
- " size m: " ^ string_of_int (HExtlib.estimate_size m)^
- " size m-c: " ^ string_of_int
- (HExtlib.estimate_size (List.map (fun (x,_,_) -> x) m)))) *)
- let time1 = Unix.gettimeofday () in
- let res = forward_simplify env (Positive, current) ~passive active in
- let time2 = Unix.gettimeofday () in
- forward_simpl_time := !forward_simpl_time +. (time2 -. time1);
- match res with
- | None ->
- (* weight_age_counter := !weight_age_counter + 1; *)
- given_clause_fullred dbd env goals theorems passive active
- | Some current ->
-(* prerr_endline (Printf.sprintf "selected simpl: %s"
- (Equality.string_of_equality ~env current));*)
- let t1 = Unix.gettimeofday () in
- let new' = infer env current active in
- let _ =
- debug_print
- (lazy
- (Printf.sprintf "new' (senza semplificare):\n%s\n"
- (String.concat "\n"
- (List.map
- (fun e -> "Positive " ^
- (Equality.string_of_equality ~env e)) new'))))
- in
- let t2 = Unix.gettimeofday () in
- infer_time := !infer_time +. (t2 -. t1);
- let active =
- if Equality.is_identity env current then active
- else
- let al, tbl = active in
- al @ [current], Indexing.index tbl current
- in
- let rec simplify new' active passive =
- let t1 = Unix.gettimeofday () in
- let new' = forward_simplify_new env new'~passive active in
- let t2 = Unix.gettimeofday () in
- forward_simpl_new_time :=
- !forward_simpl_new_time +. (t2 -. t1);
- let t1 = Unix.gettimeofday () in
- let active, passive, newa, retained, pruned =
- backward_simplify env new' ~passive active in
- let passive =
- List.fold_left filter_dependent passive pruned in
- let t2 = Unix.gettimeofday () in
- backward_simpl_time := !backward_simpl_time +. (t2 -. t1);
- match newa, retained with
- | None, None -> active, passive, new'
- | Some p, None
- | None, Some p ->
- if Utils.debug_metas then
- begin
- List.iter
- (fun x->Indexing.check_target context x "simplify1")
- p;
- end;
- simplify (new' @ p) active passive
- | Some p, Some rp ->
- simplify (new' @ p @ rp) active passive
- in
- let active, passive, new' = simplify new' active passive in
- let goals =
- let a,b,_ = build_table new' in
- simplify_goals env goals ~passive (a,b)
- in
-
-(* pessima prova
- let new1 = prova env new' active in
- let new' = (fst new') @ (fst new1), (snd new') @ (snd new1) in
- let _ =
- match new1 with
- | neg, pos ->
- debug_print
- (lazy
- (Printf.sprintf "new1:\n%s\n"
- (String.concat "\n"
- ((List.map
- (fun e -> "Negative " ^
- (string_of_equality ~env e)) neg) @
- (List.map
- (fun e -> "Positive " ^
- (string_of_equality ~env e)) pos)))))
- in
-end prova *)
- let k = size_of_passive passive in
- if k < (kept - 1) then
- processed_clauses := !processed_clauses + (kept - 1 - k);
-
- let _ =
- debug_print
- (lazy
- (Printf.sprintf "active:\n%s\n"
- (String.concat "\n"
- ((List.map
- (fun e -> (Equality.string_of_equality ~env e))
- (fst active))))))
- in
- let _ =
- debug_print
- (lazy
- (Printf.sprintf "new':\n%s\n"
- (String.concat "\n"
- ((List.map
- (fun e -> "Negative " ^
- (Equality.string_of_equality ~env e)) new')))))
- in
- let passive = add_to_passive passive new' in
- given_clause_fullred dbd env goals theorems passive active
-;;
-
-(*
-let profiler0 = HExtlib.profile "P/Saturation.given_clause_fullred"
-
-let given_clause_fullred dbd env goals theorems passive active =
- profiler0.HExtlib.profile
- (given_clause_fullred dbd env goals theorems passive) active
-*)
-
-let iseq uri = UriManager.eq uri (LibraryObjects.eq_URI ());;
-