- (* TODO: do stats analysys there and generate a new
- * C and then B
- * TODO: rebuild clauses, since the ordering has to
- * change after the stats are computed *)
- let symb_list = Stats.parse_symbols passives g_passives in
- prerr_endline "Hypotheses statistics :";
- List.iter (fun (t,occ,ar,g_occ) -> prerr_endline
- (Printf.sprintf "%s %d %d %d %s"
- (B.pp t) ar occ g_occ
- (String.concat ","
- (List.map B.pp (Stats.dependencies t passives))));
- if List.exists
- (fun (u,occ2,ar2,g_occ2) -> not (B.eq t u) && occ = occ2
- && ar = ar2 && g_occ = g_occ2) symb_list
- then prerr_endline ((B.pp t) ^ " clashes")
- ) symb_list;
- let module C = C in
+ let data = Stats.parse_symbols passives g_passives in
+ let data =
+ List.map
+ (fun (name, n_occ, arity, n_gocc, g_pos) ->
+ name, (n_occ, arity, n_gocc, g_pos, Stats.dependencies name passives))
+ data
+ in
+ List.sort Pervasives.compare data
+ ;;
+
+let worker order goal hypotheses =
+ let stats = compute_stats goal hypotheses in
+ let module C =
+ struct
+ let cmp =
+ let raw = List.map snd stats in
+ let rec pos x = function
+ | ((y,_)::tl) when y = x -> 0
+ | _::tl -> 1 + pos x tl
+ | [] -> assert false
+ in
+ if List.length raw =
+ List.length (HExtlib.list_uniq raw)
+ then
+ (prerr_endline "NO CLASH, using fixed ground order";
+ fun a b ->
+ Pervasives.compare
+ (pos a stats)
+ (pos b stats))
+ else
+ (prerr_endline "CLASH, statistics insufficient";
+ fun (a,_) (b,_) -> Pervasives.compare a b)
+ ;;
+ end
+ in