1 (* Copyright (C) 2002, 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/.
29 let debug_print s = if debug then prerr_endline (Lazy.force s)
31 (* let debug_print = fun _ -> () *)
33 let bool params name default =
35 let s = List.assoc name params in
36 if s = "" || s = "1" || s = "true" || s = "yes" || s = "on" then true
37 else if s = "0" || s = "false" || s = "no" || s= "off" then false
39 let msg = "Unrecognized value for parameter "^name^"\n" in
40 let msg = msg^"Accepted values are 1,true,yes,on and 0,false,no,off" in
41 raise (ProofEngineTypes.Fail (lazy msg))
42 with Not_found -> default
45 let string params name default =
46 try List.assoc name params with
47 | Not_found -> default
50 let int params name default =
51 try int_of_string (List.assoc name params) with
52 | Not_found -> default
54 raise (ProofEngineTypes.Fail (lazy (name ^ " must be an integer")))
57 let auto_tac ~params ~(dbd:HMysql.dbd) (proof, goal) =
58 (* argument parsing *)
60 and string = string params
61 and bool = bool params in
62 let depth = int "depth" ((AutoTypes.default_flags()).AutoTypes.maxdepth) in
63 let width = int "width" ((AutoTypes.default_flags()).AutoTypes.maxwidth) in
64 let timeout = int "timeout" 0 in
65 let use_paramod = bool "use_paramod" true in
66 let use_only_paramod = bool "paramodulation" false in
67 (* hacks to debug paramod *)
68 let superposition = bool "superposition" false in
69 let target = string "target" "" in
70 let table = string "table" "" in
71 let subterms_only = bool "subterms_only" false in
72 let demod_table = string "demod_table" "" in
73 match superposition with
75 (* this is the ugly hack to debug paramod *)
76 Saturation.superposition_tac
77 ~target ~table ~subterms_only ~demod_table (proof,goal)
79 (* this is the real auto *)
80 let _, metasenv, _, _ = proof in
81 let _, context, goalty = CicUtil.lookup_meta goal metasenv in
84 AutoCache.cache_add_context context metasenv AutoCache.cache_empty
86 if use_only_paramod then (* only paramod *)
89 AutoCache.cache_add_library dbd proof [goal] cache
91 let oldmetasenv = metasenv in
94 if use_only_paramod then 2 else depth;
95 AutoTypes.maxwidth = width;
97 if timeout = 0 then float_of_int timeout
98 else Unix.gettimeofday() +. (float_of_int timeout);
99 AutoTypes.use_paramod = use_paramod;
100 AutoTypes.use_only_paramod = use_only_paramod;
101 AutoTypes.dont_cache_failures = false
104 match Auto.auto dbd cache context metasenv [goal] flags with
106 raise (ProofEngineTypes.Fail (lazy "Auto gave up"))
107 | Some (subst,metasenv),cache ->
109 ProofEngineHelpers.subst_meta_and_metasenv_in_proof
110 proof goal (CicMetaSubst.apply_subst subst) metasenv
113 ProofEngineHelpers.compare_metasenvs ~oldmetasenv
114 ~newmetasenv:metasenv
119 let auto_tac ~params ~dbd =
120 ProofEngineTypes.mk_tactic (auto_tac ~params ~dbd)
123 let pp_proofterm = Equality.pp_proofterm;;