]> matita.cs.unibo.it Git - helm.git/blob - helm/ocaml/paramodulation/saturate_main.ml
added some comments; general code cleanup
[helm.git] / helm / ocaml / paramodulation / saturate_main.ml
1 (* Copyright (C) 2005, HELM Team.
2  * 
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.
6  * 
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.
11  * 
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.
16  *
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,
20  * MA  02111-1307, USA.
21  * 
22  * For details, see the HELM World-Wide-Web page,
23  * http://cs.unibo.it/helm/.
24  *)
25
26 let configuration_file = ref "../../matita/matita.conf.xml";;
27
28 let core_notation_script = "../../matita/core_notation.moo";;
29
30 let get_from_user ~(dbd:HMysql.dbd) =
31   let rec get () =
32     match read_line () with
33     | "" -> []
34     | t -> t::(get ())
35   in
36   let term_string = String.concat "\n" (get ()) in
37   let env, metasenv, term, ugraph =
38     List.nth (Disambiguate.Trivial.disambiguate_string dbd term_string) 0
39   in
40   term, metasenv, ugraph
41 ;;
42
43 let full = ref false;;
44
45 let _ =
46   let module S = Saturation in
47   let set_ratio v = S.weight_age_ratio := v; S.weight_age_counter := v
48   and set_sel v = S.symbols_ratio := v; S.symbols_counter := v;
49   and set_conf f = configuration_file := f
50   and set_ordering o =
51     match o with
52     | "lpo" -> Utils.compare_terms := Utils.lpo
53     | "kbo" -> Utils.compare_terms := Utils.kbo
54     | "nr-kbo" -> Utils.compare_terms := Utils.nonrec_kbo
55     | o -> raise (Arg.Bad ("Unknown term ordering: " ^ o))
56   and set_fullred b = S.use_fullred := b
57   and set_time_limit v = S.time_limit := float_of_int v
58   and set_width w = S.maxwidth := w
59   and set_depth d = S.maxdepth := d
60   and set_full () = full := true
61   in
62   Arg.parse [
63     "-full", Arg.Unit set_full, "Enable full mode";
64     "-f", Arg.Bool set_fullred,
65     "Enable/disable full-reduction strategy (default: enabled)";
66     
67     "-r", Arg.Int set_ratio, "Weight-Age equality selection ratio (default: 4)";
68
69     "-s", Arg.Int set_sel,
70     "symbols-based selection ratio (relative to the weight ratio, default: 0)";
71
72     "-c", Arg.String set_conf, "Configuration file (for the db connection)";
73
74     "-o", Arg.String set_ordering,
75     "Term ordering. Possible values are:\n" ^
76       "\tkbo: Knuth-Bendix ordering\n" ^
77       "\tnr-kbo: Non-recursive variant of kbo (default)\n" ^
78       "\tlpo: Lexicographic path ordering";
79
80     "-l", Arg.Int set_time_limit, "Time limit in seconds (default: no limit)";
81     
82     "-w", Arg.Int set_width,
83     Printf.sprintf "Maximal width (default: %d)" !Saturation.maxwidth;
84     
85     "-d", Arg.Int set_depth,
86     Printf.sprintf "Maximal depth (default: %d)" !Saturation.maxdepth;
87   ] (fun a -> ()) "Usage:"
88 in
89 Helm_registry.load_from !configuration_file;
90 CicNotation.load_notation core_notation_script;
91 CicNotation.load_notation "../../matita/coq.ma";
92 let dbd = HMysql.quick_connect
93   ~host:(Helm_registry.get "db.host")
94   ~user:(Helm_registry.get "db.user")
95   ~database:(Helm_registry.get "db.database")
96   ()
97 in
98 let term, metasenv, ugraph = get_from_user ~dbd in
99 Saturation.main dbd !full term metasenv ugraph;;