misc tuning and recovery of Isabelle coding style;
authorwenzelm
Thu, 15 Oct 2009 12:23:24 +0200
changeset 32942b6711ec9de26
parent 32941 72d48e333b77
child 32943 2cb928848e77
misc tuning and recovery of Isabelle coding style;
src/HOL/Tools/ATP_Manager/atp_minimal.ML
src/HOL/Tools/ATP_Manager/atp_wrapper.ML
     1.1 --- a/src/HOL/Tools/ATP_Manager/atp_minimal.ML	Thu Oct 15 11:49:27 2009 +0200
     1.2 +++ b/src/HOL/Tools/ATP_Manager/atp_minimal.ML	Thu Oct 15 12:23:24 2009 +0200
     1.3 @@ -99,8 +99,8 @@
     1.4  
     1.5  fun produce_answer (result: ATP_Wrapper.prover_result) =
     1.6    let
     1.7 -    val {success, message, proof = result_string,
     1.8 -      internal_thm_names = thm_name_vec, filtered_clauses = filtered, ...} = result
     1.9 +    val {success, proof = result_string, internal_thm_names = thm_name_vec,
    1.10 +      filtered_clauses = filtered, ...} = result
    1.11    in
    1.12    if success then
    1.13      (Success (Vector.foldr op:: [] thm_name_vec, filtered), result_string)
     2.1 --- a/src/HOL/Tools/ATP_Manager/atp_wrapper.ML	Thu Oct 15 11:49:27 2009 +0200
     2.2 +++ b/src/HOL/Tools/ATP_Manager/atp_wrapper.ML	Thu Oct 15 12:23:24 2009 +0200
     2.3 @@ -107,80 +107,80 @@
     2.4    |> Exn.release
     2.5    |> tap (after path);
     2.6  
     2.7 -fun external_prover relevance_filter preparer writer cmd args find_failure produce_answer
     2.8 +fun external_prover relevance_filter prepare write cmd args find_failure produce_answer
     2.9    axiom_clauses filtered_clauses name subgoalno goal =
    2.10    let
    2.11      (* get clauses and prepare them for writing *)
    2.12 -    val (ctxt, (chain_ths, th)) = goal
    2.13 -    val thy = ProofContext.theory_of ctxt
    2.14 -    val chain_ths = map (Thm.put_name_hint ResReconstruct.chained_hint) chain_ths
    2.15 -    val goal_cls = #1 (ResAxioms.neg_conjecture_clauses ctxt th subgoalno)
    2.16 -    val _ = app (fn th => Output.debug (fn _ => Display.string_of_thm ctxt th)) goal_cls
    2.17 +    val (ctxt, (chain_ths, th)) = goal;
    2.18 +    val thy = ProofContext.theory_of ctxt;
    2.19 +    val chain_ths = map (Thm.put_name_hint ResReconstruct.chained_hint) chain_ths;
    2.20 +    val goal_cls = #1 (ResAxioms.neg_conjecture_clauses ctxt th subgoalno);
    2.21      val the_filtered_clauses =
    2.22 -      case filtered_clauses of
    2.23 -          NONE => relevance_filter goal goal_cls
    2.24 -        | SOME fcls => fcls
    2.25 +      (case filtered_clauses of
    2.26 +        NONE => relevance_filter goal goal_cls
    2.27 +      | SOME fcls => fcls);
    2.28      val the_axiom_clauses =
    2.29 -      case axiom_clauses of
    2.30 -          NONE => the_filtered_clauses
    2.31 -        | SOME axcls => axcls
    2.32 +      (case axiom_clauses of
    2.33 +        NONE => the_filtered_clauses
    2.34 +      | SOME axcls => axcls);
    2.35      val (thm_names, clauses) =
    2.36 -      preparer goal_cls chain_ths the_axiom_clauses the_filtered_clauses thy
    2.37 +      prepare goal_cls chain_ths the_axiom_clauses the_filtered_clauses thy;
    2.38  
    2.39      (* path to unique problem file *)
    2.40 -    val destdir' = Config.get ctxt destdir
    2.41 -    val problem_prefix' = Config.get ctxt problem_prefix
    2.42 +    val destdir' = Config.get ctxt destdir;
    2.43 +    val problem_prefix' = Config.get ctxt problem_prefix;
    2.44      fun prob_pathname nr =
    2.45 -      let val probfile = Path.basic (problem_prefix' ^ serial_string () ^ "_" ^ string_of_int nr)
    2.46 -      in if destdir' = "" then File.tmp_path probfile
    2.47 +      let val probfile =
    2.48 +        Path.basic (problem_prefix' ^ serial_string () ^ "_" ^ string_of_int nr)
    2.49 +      in
    2.50 +        if destdir' = "" then File.tmp_path probfile
    2.51          else if File.exists (Path.explode (destdir'))
    2.52          then Path.append  (Path.explode (destdir')) probfile
    2.53          else error ("No such directory: " ^ destdir')
    2.54 -      end
    2.55 +      end;
    2.56  
    2.57      (* write out problem file and call prover *)
    2.58      fun cmd_line probfile = "TIMEFORMAT='%3U'; { time " ^ space_implode " "
    2.59        [File.shell_path cmd, args, File.platform_path probfile] ^ " ; } 2>&1"
    2.60      fun split_time s =
    2.61        let
    2.62 -        val split = String.tokens (fn c => str c = "\n")
    2.63 -        val (proof, t) = s |> split |> split_last |> apfst cat_lines
    2.64 -        fun as_num f = f >> (fst o read_int)
    2.65 -        val num = as_num (Scan.many1 Symbol.is_ascii_digit)
    2.66 -        val digit = Scan.one Symbol.is_ascii_digit
    2.67 -        val num3 = as_num (digit ::: digit ::: (digit >> single))
    2.68 -        val time = num --| Scan.$$ "." -- num3 >> (fn (a, b) => a * 1000 + b)
    2.69 -        val as_time = the_default 0 o Scan.read Symbol.stopper time o explode
    2.70 -      in (proof, as_time t) end
    2.71 +        val split = String.tokens (fn c => str c = "\n");
    2.72 +        val (proof, t) = s |> split |> split_last |> apfst cat_lines;
    2.73 +        fun as_num f = f >> (fst o read_int);
    2.74 +        val num = as_num (Scan.many1 Symbol.is_ascii_digit);
    2.75 +        val digit = Scan.one Symbol.is_ascii_digit;
    2.76 +        val num3 = as_num (digit ::: digit ::: (digit >> single));
    2.77 +        val time = num --| Scan.$$ "." -- num3 >> (fn (a, b) => a * 1000 + b);
    2.78 +        val as_time = the_default 0 o Scan.read Symbol.stopper time o explode;
    2.79 +      in (proof, as_time t) end;
    2.80      fun run_on probfile =
    2.81 -      if File.exists cmd
    2.82 -      then
    2.83 -        writer probfile clauses
    2.84 +      if File.exists cmd then
    2.85 +        write probfile clauses
    2.86          |> pair (apfst split_time (system_out (cmd_line probfile)))
    2.87 -      else error ("Bad executable: " ^ Path.implode cmd)
    2.88 +      else error ("Bad executable: " ^ Path.implode cmd);
    2.89  
    2.90      (* if problemfile has not been exported, delete problemfile; otherwise export proof, too *)
    2.91 -    fun cleanup probfile = if destdir' = "" then try File.rm probfile else NONE
    2.92 -    fun export probfile (((proof, _), _), _) = if destdir' = "" then ()
    2.93 -      else File.write (Path.explode (Path.implode probfile ^ "_proof")) proof
    2.94 +    fun cleanup probfile = if destdir' = "" then try File.rm probfile else NONE;
    2.95 +    fun export probfile (((proof, _), _), _) =
    2.96 +      if destdir' = "" then ()
    2.97 +      else File.write (Path.explode (Path.implode probfile ^ "_proof")) proof;
    2.98  
    2.99 -    val (((proof, time), rc), conj_pos) = with_path cleanup export run_on
   2.100 -      (prob_pathname subgoalno)
   2.101 +    val (((proof, time), rc), conj_pos) =
   2.102 +      with_path cleanup export run_on (prob_pathname subgoalno);
   2.103  
   2.104      (* check for success and print out some information on failure *)
   2.105 -    val failure = find_failure proof
   2.106 -    val success = rc = 0 andalso is_none failure
   2.107 +    val failure = find_failure proof;
   2.108 +    val success = rc = 0 andalso is_none failure;
   2.109      val (message, real_thm_names) =
   2.110        if is_some failure then ("External prover failed.", [])
   2.111        else if rc <> 0 then ("External prover failed: " ^ proof, [])
   2.112        else apfst (fn s => "Try this command: " ^ s)
   2.113 -        (produce_answer name (proof, thm_names, conj_pos, ctxt, th, subgoalno))
   2.114 -    val _ = Output.debug (fn () => "Sledgehammer response (rc = " ^ string_of_int rc ^ "):\n" ^ proof)
   2.115 +        (produce_answer name (proof, thm_names, conj_pos, ctxt, th, subgoalno));
   2.116    in
   2.117      {success = success, message = message,
   2.118        theorem_names = real_thm_names, runtime = time, proof = proof,
   2.119        internal_thm_names = thm_names, filtered_clauses = the_filtered_clauses}
   2.120 -  end
   2.121 +  end;
   2.122  
   2.123  
   2.124  (* generic TPTP-based provers *)
   2.125 @@ -188,8 +188,8 @@
   2.126  fun gen_tptp_prover (name, prover_config) problem timeout =
   2.127    let
   2.128      val {max_new_clauses, insert_theory_const, emit_structured_proof, command, arguments} =
   2.129 -      prover_config
   2.130 -    val {with_full_types, subgoal, goal, axiom_clauses, filtered_clauses} = problem
   2.131 +      prover_config;
   2.132 +    val {with_full_types, subgoal, goal, axiom_clauses, filtered_clauses} = problem;
   2.133    in
   2.134      external_prover
   2.135        (ResAtp.get_relevant max_new_clauses insert_theory_const)
   2.136 @@ -205,9 +205,9 @@
   2.137        name
   2.138        subgoal
   2.139        goal
   2.140 -  end
   2.141 +  end;
   2.142  
   2.143 -fun tptp_prover (name, config) = (name, gen_tptp_prover (name, config))
   2.144 +fun tptp_prover (name, config) = (name, gen_tptp_prover (name, config));
   2.145  
   2.146  
   2.147  
   2.148 @@ -217,8 +217,8 @@
   2.149  
   2.150  (*NB: Vampire does not work without explicit timelimit*)
   2.151  
   2.152 -val vampire_max_new_clauses = 60
   2.153 -val vampire_insert_theory_const = false
   2.154 +val vampire_max_new_clauses = 60;
   2.155 +val vampire_insert_theory_const = false;
   2.156  
   2.157  fun vampire_prover_config full : prover_config =
   2.158   {command = Path.explode "$VAMPIRE_HOME/vampire",
   2.159 @@ -226,16 +226,16 @@
   2.160      " -t " ^ string_of_int timeout),
   2.161    max_new_clauses = vampire_max_new_clauses,
   2.162    insert_theory_const = vampire_insert_theory_const,
   2.163 -  emit_structured_proof = full}
   2.164 +  emit_structured_proof = full};
   2.165  
   2.166 -val vampire = tptp_prover ("vampire", vampire_prover_config false)
   2.167 -val vampire_full = tptp_prover ("vampire_full", vampire_prover_config true)
   2.168 +val vampire = tptp_prover ("vampire", vampire_prover_config false);
   2.169 +val vampire_full = tptp_prover ("vampire_full", vampire_prover_config true);
   2.170  
   2.171  
   2.172  (* E prover *)
   2.173  
   2.174 -val eprover_max_new_clauses = 100
   2.175 -val eprover_insert_theory_const = false
   2.176 +val eprover_max_new_clauses = 100;
   2.177 +val eprover_insert_theory_const = false;
   2.178  
   2.179  fun eprover_config full : prover_config =
   2.180   {command = Path.explode "$E_HOME/eproof",
   2.181 @@ -243,16 +243,16 @@
   2.182      " --silent --cpu-limit=" ^ string_of_int timeout),
   2.183    max_new_clauses = eprover_max_new_clauses,
   2.184    insert_theory_const = eprover_insert_theory_const,
   2.185 -  emit_structured_proof = full}
   2.186 +  emit_structured_proof = full};
   2.187  
   2.188 -val eprover = tptp_prover ("e", eprover_config false)
   2.189 -val eprover_full = tptp_prover ("e_full", eprover_config true)
   2.190 +val eprover = tptp_prover ("e", eprover_config false);
   2.191 +val eprover_full = tptp_prover ("e_full", eprover_config true);
   2.192  
   2.193  
   2.194  (* SPASS *)
   2.195  
   2.196 -val spass_max_new_clauses = 40
   2.197 -val spass_insert_theory_const = true
   2.198 +val spass_max_new_clauses = 40;
   2.199 +val spass_insert_theory_const = true;
   2.200  
   2.201  fun spass_config insert_theory_const: prover_config =
   2.202   {command = Path.explode "$SPASS_HOME/SPASS",
   2.203 @@ -260,12 +260,11 @@
   2.204      " -FullRed=0 -DocProof -TimeLimit=" ^ string_of_int timeout),
   2.205    max_new_clauses = spass_max_new_clauses,
   2.206    insert_theory_const = insert_theory_const,
   2.207 -  emit_structured_proof = false}
   2.208 +  emit_structured_proof = false};
   2.209  
   2.210 -fun gen_dfg_prover (name, prover_config) problem timeout =
   2.211 +fun gen_dfg_prover (name, prover_config: prover_config) problem timeout =
   2.212    let
   2.213 -    val {max_new_clauses, insert_theory_const, emit_structured_proof, command, arguments} =
   2.214 -      prover_config
   2.215 +    val {max_new_clauses, insert_theory_const, command, arguments, ...} = prover_config
   2.216      val {with_full_types, subgoal, goal, axiom_clauses, filtered_clauses} = problem
   2.217    in
   2.218      external_prover
   2.219 @@ -281,18 +280,17 @@
   2.220        name
   2.221        subgoal
   2.222        goal
   2.223 -  end
   2.224 +  end;
   2.225  
   2.226 -fun dfg_prover (name, config) = (name, gen_dfg_prover (name, config))
   2.227 +fun dfg_prover (name, config) = (name, gen_dfg_prover (name, config));
   2.228  
   2.229 -val spass = dfg_prover ("spass", spass_config spass_insert_theory_const)
   2.230 -val spass_no_tc = dfg_prover ("spass_no_tc", spass_config false)
   2.231 +val spass = dfg_prover ("spass", spass_config spass_insert_theory_const);
   2.232 +val spass_no_tc = dfg_prover ("spass_no_tc", spass_config false);
   2.233  
   2.234  
   2.235  (* remote prover invocation via SystemOnTPTP *)
   2.236  
   2.237 -val systems =
   2.238 -  Synchronized.var "atp_wrapper_systems" ([]: string list);
   2.239 +val systems = Synchronized.var "atp_wrapper_systems" ([]: string list);
   2.240  
   2.241  fun get_systems () =
   2.242    let
   2.243 @@ -302,33 +300,32 @@
   2.244      else split_lines answer
   2.245    end;
   2.246  
   2.247 -fun refresh_systems () = Synchronized.change systems (fn _ =>
   2.248 -  get_systems ());
   2.249 +fun refresh_systems () = Synchronized.change systems (fn _ => get_systems ());
   2.250  
   2.251  fun get_system prefix = Synchronized.change_result systems (fn systems =>
   2.252    (if null systems then get_systems () else systems)
   2.253 -  |> ` (find_first (String.isPrefix prefix)));
   2.254 +  |> `(find_first (String.isPrefix prefix)));
   2.255  
   2.256  fun get_the_system prefix =
   2.257    (case get_system prefix of
   2.258      NONE => error ("No system like " ^ quote prefix ^ " at SystemOnTPTP")
   2.259 -  | SOME sys => sys)
   2.260 +  | SOME sys => sys);
   2.261  
   2.262  fun remote_prover_config prover_prefix args max_new insert_tc: prover_config =
   2.263   {command = Path.explode "$ISABELLE_ATP_MANAGER/SystemOnTPTP",
   2.264 -  arguments = (fn timeout => args ^ " -t " ^ string_of_int timeout ^ " -s " ^
   2.265 -    get_the_system prover_prefix),
   2.266 +  arguments =
   2.267 +    (fn timeout => args ^ " -t " ^ string_of_int timeout ^ " -s " ^ get_the_system prover_prefix),
   2.268    max_new_clauses = max_new,
   2.269    insert_theory_const = insert_tc,
   2.270 -  emit_structured_proof = false}
   2.271 +  emit_structured_proof = false};
   2.272  
   2.273  val remote_vampire = tptp_prover ("remote_vampire", remote_prover_config
   2.274 -  "Vampire---9" "" vampire_max_new_clauses vampire_insert_theory_const)
   2.275 +  "Vampire---9" "" vampire_max_new_clauses vampire_insert_theory_const);
   2.276  
   2.277  val remote_eprover = tptp_prover ("remote_e", remote_prover_config
   2.278 -  "EP---" "" eprover_max_new_clauses eprover_insert_theory_const)
   2.279 +  "EP---" "" eprover_max_new_clauses eprover_insert_theory_const);
   2.280  
   2.281  val remote_spass = tptp_prover ("remote_spass", remote_prover_config
   2.282 -  "SPASS---" "-x" spass_max_new_clauses spass_insert_theory_const)
   2.283 +  "SPASS---" "-x" spass_max_new_clauses spass_insert_theory_const);
   2.284  
   2.285  end;