]> matita.cs.unibo.it Git - helm.git/blob - helm/ocaml/paramodulation/saturate_main.ml
ocaml 3.09 transition
[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 retrieve_only = ref false;;
46
47 let _ =
48   let module S = Saturation in
49   let set_ratio v = S.weight_age_ratio := v; S.weight_age_counter := v
50   and set_sel v = S.symbols_ratio := v; S.symbols_counter := v;
51   and set_conf f = configuration_file := f
52   and set_ordering o =
53     match o with
54     | "lpo" -> Utils.compare_terms := Utils.lpo
55     | "kbo" -> Utils.compare_terms := Utils.kbo
56     | "nr-kbo" -> Utils.compare_terms := Utils.nonrec_kbo
57     | o -> raise (Arg.Bad ("Unknown term ordering: " ^ o))
58   and set_fullred b = S.use_fullred := b
59   and set_time_limit v = S.time_limit := float_of_int v
60   and set_width w = S.maxwidth := w
61   and set_depth d = S.maxdepth := d
62   and set_full () = full := true
63   and set_retrieve () = retrieve_only := true
64   in
65   Arg.parse [
66     "-full", Arg.Unit set_full, "Enable full mode";
67     "-f", Arg.Bool set_fullred,
68     "Enable/disable full-reduction strategy (default: enabled)";
69     
70     "-r", Arg.Int set_ratio, "Weight-Age equality selection ratio (default: 4)";
71
72     "-s", Arg.Int set_sel,
73     "symbols-based selection ratio (relative to the weight ratio, default: 0)";
74
75     "-c", Arg.String set_conf, "Configuration file (for the db connection)";
76
77     "-o", Arg.String set_ordering,
78     "Term ordering. Possible values are:\n" ^
79       "\tkbo: Knuth-Bendix ordering\n" ^
80       "\tnr-kbo: Non-recursive variant of kbo (default)\n" ^
81       "\tlpo: Lexicographic path ordering";
82
83     "-l", Arg.Int set_time_limit, "Time limit in seconds (default: no limit)";
84     
85     "-w", Arg.Int set_width,
86     Printf.sprintf "Maximal width (default: %d)" !Saturation.maxwidth;
87     
88     "-d", Arg.Int set_depth,
89     Printf.sprintf "Maximal depth (default: %d)" !Saturation.maxdepth;
90
91     "-retrieve", Arg.Unit set_retrieve, "retrieve only";
92   ] (fun a -> ()) "Usage:"
93 in
94 Helm_registry.load_from !configuration_file;
95 CicNotation.load_notation core_notation_script;
96 CicNotation.load_notation "../../matita/coq.ma";
97 let dbd = HMysql.quick_connect
98   ~host:(Helm_registry.get "db.host")
99   ~user:(Helm_registry.get "db.user")
100   ~database:(Helm_registry.get "db.database")
101   ()
102 in
103 let term, metasenv, ugraph = get_from_user ~dbd in
104 if !retrieve_only then
105   Saturation.retrieve_and_print dbd term metasenv ugraph
106 else
107   Saturation.main dbd !full term metasenv ugraph
108 ;;