src/HOL/Tools/Sledgehammer/sledgehammer_commands.ML
changeset 61223 dfccf6c06201
parent 60740 c0f6d90d0ae4
child 61311 150aa3015c47
equal deleted inserted replaced
61222:05d28dc76e5c 61223:dfccf6c06201
   297 
   297 
   298 (* Sledgehammer the given subgoal *)
   298 (* Sledgehammer the given subgoal *)
   299 
   299 
   300 val default_learn_prover_timeout = 2.0
   300 val default_learn_prover_timeout = 2.0
   301 
   301 
   302 fun hammer_away override_params output_result subcommand opt_i fact_override state0 =
   302 fun hammer_away override_params writeln_result subcommand opt_i fact_override state0 =
   303   let
   303   let
   304     (* We generally want chained facts to be picked up by the relevance filter, because it can then
   304     (* We generally want chained facts to be picked up by the relevance filter, because it can then
   305        give it a proper name, which is useful for a variety of reasons (minimization, Isar proofs,
   305        give it a proper name, which is useful for a variety of reasons (minimization, Isar proofs,
   306        verbose output, machine learning). However, if the fact is available by no other means (not
   306        verbose output, machine learning). However, if the fact is available by no other means (not
   307        even backticks), as "f" would be in "using f unfolding f'" after unfolding, we have no choice
   307        even backticks), as "f" would be in "using f unfolding f'" after unfolding, we have no choice
   326     val _ = Isabelle_System.mkdir (Path.explode (getenv "ISABELLE_TMP"))
   326     val _ = Isabelle_System.mkdir (Path.explode (getenv "ISABELLE_TMP"))
   327   in
   327   in
   328     if subcommand = runN then
   328     if subcommand = runN then
   329       let val i = the_default 1 opt_i in
   329       let val i = the_default 1 opt_i in
   330         ignore (run_sledgehammer
   330         ignore (run_sledgehammer
   331           (get_params Normal thy override_params) Normal output_result i fact_override state)
   331           (get_params Normal thy override_params) Normal writeln_result i fact_override state)
   332       end
   332       end
   333     else if subcommand = messagesN then
   333     else if subcommand = messagesN then
   334       messages opt_i
   334       messages opt_i
   335     else if subcommand = supported_proversN then
   335     else if subcommand = supported_proversN then
   336       supported_provers ctxt
   336       supported_provers ctxt
   406   end
   406   end
   407 
   407 
   408 val _ = Try.tool_setup (sledgehammerN, (40, @{system_option auto_sledgehammer}, try_sledgehammer))
   408 val _ = Try.tool_setup (sledgehammerN, (40, @{system_option auto_sledgehammer}, try_sledgehammer))
   409 
   409 
   410 val _ =
   410 val _ =
   411   Query_Operation.register {name = sledgehammerN, pri = 0} (fn {state = st, args, output_result} =>
   411   Query_Operation.register {name = sledgehammerN, pri = 0}
   412     (case try Toplevel.proof_of st of
   412     (fn {state = st, args, writeln_result, ...} =>
   413       SOME state =>
   413       (case try Toplevel.proof_of st of
   414         let
   414         SOME state =>
   415           val [provers_arg, isar_proofs_arg, try0_arg] = args
   415           let
   416           val override_params =
   416             val [provers_arg, isar_proofs_arg, try0_arg] = args
   417             ((if provers_arg = "" then [] else [("provers", space_explode " " provers_arg)]) @
   417             val override_params =
   418               [("isar_proofs", [if isar_proofs_arg = "true" then "true" else "smart"]),
   418               ((if provers_arg = "" then [] else [("provers", space_explode " " provers_arg)]) @
   419                ("try0", [try0_arg]),
   419                 [("isar_proofs", [if isar_proofs_arg = "true" then "true" else "smart"]),
   420                ("blocking", ["true"]),
   420                  ("try0", [try0_arg]),
   421                ("debug", ["false"]),
   421                  ("blocking", ["true"]),
   422                ("verbose", ["false"]),
   422                  ("debug", ["false"]),
   423                ("overlord", ["false"])]);
   423                  ("verbose", ["false"]),
   424         in hammer_away override_params (SOME output_result) runN NONE no_fact_override state end
   424                  ("overlord", ["false"])]);
   425     | NONE => error "Unknown proof context"))
   425           in hammer_away override_params (SOME writeln_result) runN NONE no_fact_override state end
       
   426       | NONE => error "Unknown proof context"))
   426 
   427 
   427 end;
   428 end;