src/HOL/Tools/Sledgehammer/sledgehammer_prover_atp.ML
changeset 57255 488046fdda59
parent 57245 f6bf6d5341ee
child 57258 67d85a8aa6cc
equal deleted inserted replaced
57254:d3d91422f408 57255:488046fdda59
   300                     if debug then (warning (string_of_atp_failure failure); NONE) else SOME failure
   300                     if debug then (warning (string_of_atp_failure failure); NONE) else SOME failure
   301                   end
   301                   end
   302                 | NONE => NONE)
   302                 | NONE => NONE)
   303               | _ => outcome)
   303               | _ => outcome)
   304           in
   304           in
   305             ((SOME key, value), (output, run_time, facts, atp_proof, outcome))
   305             ((SOME key, value), (output, run_time, facts, atp_proof, outcome),
       
   306               SOME (format, type_enc))
   306           end
   307           end
   307 
   308 
   308         val timer = Timer.startRealTimer ()
   309         val timer = Timer.startRealTimer ()
   309 
   310 
   310         fun maybe_run_slice slice (result as (cache, (_, run_time0, _, _, SOME _))) =
   311         fun maybe_run_slice slice (result as (cache, (_, run_time0, _, _, SOME _), _)) =
   311             let val time_left = Time.- (timeout, Timer.checkRealTimer timer) in
   312             let val time_left = Time.- (timeout, Timer.checkRealTimer timer) in
   312               if Time.<= (time_left, Time.zeroTime) then
   313               if Time.<= (time_left, Time.zeroTime) then
   313                 result
   314                 result
   314               else
   315               else
   315                 run_slice time_left cache slice
   316                 run_slice time_left cache slice
   316                 |> (fn (cache, (output, run_time, used_from, atp_proof, outcome)) =>
   317                 |> (fn (cache, (output, run_time, used_from, atp_proof, outcome),
   317                   (cache, (output, Time.+ (run_time0, run_time), used_from, atp_proof, outcome)))
   318                         format_type_enc) =>
       
   319                   (cache, (output, Time.+ (run_time0, run_time), used_from, atp_proof, outcome),
       
   320                    format_type_enc))
   318             end
   321             end
   319           | maybe_run_slice _ result = result
   322           | maybe_run_slice _ result = result
   320       in
   323       in
   321         ((NONE, ([], Symtab.empty, Vector.fromList [], [], Symtab.empty)),
   324         ((NONE, ([], Symtab.empty, Vector.fromList [], [], Symtab.empty)),
   322          ("", Time.zeroTime, [], [], SOME InternalError))
   325          ("", Time.zeroTime, [], [], SOME InternalError), NONE)
   323         |> fold maybe_run_slice actual_slices
   326         |> fold maybe_run_slice actual_slices
   324       end
   327       end
   325 
   328 
   326     (* If the problem file has not been exported, remove it; otherwise, export
   329     (* If the problem file has not been exported, remove it; otherwise, export
   327        the proof file too. *)
   330        the proof file too. *)
   328     fun clean_up () = if dest_dir = "" then (try File.rm prob_path; ()) else ()
   331     fun clean_up () = if dest_dir = "" then (try File.rm prob_path; ()) else ()
   329     fun export (_, (output, _, _, _, _)) =
   332     fun export (_, (output, _, _, _, _), _) =
   330       if dest_dir = "" then ()
   333       if dest_dir = "" then ()
   331       else File.write (Path.explode (Path.implode prob_path ^ "_proof")) output
   334       else File.write (Path.explode (Path.implode prob_path ^ "_proof")) output
   332 
   335 
   333     val ((_, (_, pool, fact_names, lifted, sym_tab)),
   336     val ((_, (_, pool, fact_names, lifted, sym_tab)),
   334          (output, run_time, used_from, atp_proof, outcome)) =
   337          (output, run_time, used_from, atp_proof, outcome), SOME (format, type_enc)) =
   335       with_cleanup clean_up run () |> tap export
   338       with_cleanup clean_up run () |> tap export
   336 
   339 
   337     val important_message =
   340     val important_message =
   338       if mode = Normal andalso random_range 0 (atp_important_message_keep_quotient - 1) = 0 then
   341       if mode = Normal andalso random_range 0 (atp_important_message_keep_quotient - 1) = 0 then
   339         extract_important_message output
   342         extract_important_message output
   365                       if is_typed_helper_used_in_atp_proof atp_proof then SOME full_typesN else NONE
   368                       if is_typed_helper_used_in_atp_proof atp_proof then SOME full_typesN else NONE
   366                     val metis_lam_trans =
   369                     val metis_lam_trans =
   367                       if atp_proof_prefers_lifting atp_proof then SOME liftingN else NONE
   370                       if atp_proof_prefers_lifting atp_proof then SOME liftingN else NONE
   368                     val atp_proof =
   371                     val atp_proof =
   369                       atp_proof
   372                       atp_proof
   370                       |> termify_atp_proof ctxt pool lifted sym_tab
   373                       |> termify_atp_proof ctxt name format type_enc pool lifted sym_tab
   371                       |> introduce_spass_skolem
   374                       |> introduce_spass_skolem
   372                       |> factify_atp_proof fact_names hyp_ts concl_t
   375                       |> factify_atp_proof fact_names hyp_ts concl_t
   373                   in
   376                   in
   374                     (verbose, (metis_type_enc, metis_lam_trans), preplay_timeout, compress, try0,
   377                     (verbose, (metis_type_enc, metis_lam_trans), preplay_timeout, compress, try0,
   375                      minimize <> SOME false, atp_proof, goal)
   378                      minimize <> SOME false, atp_proof, goal)