(* Copyright (C) 2002, HELM Team. * * This file is part of HELM, an Hypertextual, Electronic * Library of Mathematics, developed at the Computer Science * Department, University of Bologna, Italy. * * HELM is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * HELM is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HELM; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. * * For details, see the HELM World-Wide-Web page, * http://cs.unibo.it/helm/. *) (* $Id$ *) let debug = false let debug_print s = if debug then prerr_endline (Lazy.force s) (* let debug_print = fun _ -> () *) let bool params name default = try let s = List.assoc name params in if s = "" || s = "1" || s = "true" || s = "yes" || s = "on" then true else if s = "0" || s = "false" || s = "no" || s= "off" then false else let msg = "Unrecognized value for parameter "^name^"\n" in let msg = msg^"Accepted values are 1,true,yes,on and 0,false,no,off" in raise (ProofEngineTypes.Fail (lazy msg)) with Not_found -> default ;; let string params name default = try List.assoc name params with | Not_found -> default ;; let int params name default = try int_of_string (List.assoc name params) with | Not_found -> default | Failure _ -> raise (ProofEngineTypes.Fail (lazy (name ^ " must be an integer"))) ;; let auto_tac ~params ~(dbd:HMysql.dbd) (proof, goal) = (* argument parsing *) let int = int params and string = string params and bool = bool params in let depth = int "depth" ((AutoTypes.default_flags()).AutoTypes.maxdepth) in let width = int "width" ((AutoTypes.default_flags()).AutoTypes.maxwidth) in let timeout = int "timeout" 0 in let use_paramod = bool "use_paramod" true in let use_only_paramod = bool "paramodulation" false in (* hacks to debug paramod *) let superposition = bool "superposition" false in let target = string "target" "" in let table = string "table" "" in let subterms_only = bool "subterms_only" false in let demod_table = string "demod_table" "" in match superposition with | true -> (* this is the ugly hack to debug paramod *) Saturation.superposition_tac ~target ~table ~subterms_only ~demod_table (proof,goal) | false -> (* this is the real auto *) let _, metasenv, _, _ = proof in let _, context, goalty = CicUtil.lookup_meta goal metasenv in let cache = let cache = AutoCache.cache_add_context context metasenv AutoCache.cache_empty in if use_only_paramod then (* only paramod *) cache else AutoCache.cache_add_library dbd proof [goal] cache in let oldmetasenv = metasenv in let flags = { AutoTypes.maxdepth = if use_only_paramod then 2 else depth; AutoTypes.maxwidth = width; AutoTypes.timeout = if timeout = 0 then float_of_int timeout else Unix.gettimeofday() +. (float_of_int timeout); AutoTypes.use_paramod = use_paramod; AutoTypes.use_only_paramod = use_only_paramod; AutoTypes.dont_cache_failures = false } in match Auto.auto dbd cache context metasenv [goal] flags with | None,cache -> raise (ProofEngineTypes.Fail (lazy "Auto gave up")) | Some (subst,metasenv),cache -> let proof,metasenv = ProofEngineHelpers.subst_meta_and_metasenv_in_proof proof goal (CicMetaSubst.apply_subst subst) metasenv in let opened = ProofEngineHelpers.compare_metasenvs ~oldmetasenv ~newmetasenv:metasenv in proof,opened ;; let auto_tac ~params ~dbd = ProofEngineTypes.mk_tactic (auto_tac ~params ~dbd) ;; let pp_proofterm = Equality.pp_proofterm;;