src/HOL/Tools/Mirabelle/mirabelle_sledgehammer.ML
changeset 73797 f7ea394490f5
parent 73697 0e7a5c7a14c8
child 73847 58f6b41efe88
equal deleted inserted replaced
73796:56f31baaa837 73797:f7ea394490f5
    34 val proverK = "prover" (*=STRING: name of the external prover to call*)
    34 val proverK = "prover" (*=STRING: name of the external prover to call*)
    35 val prover_timeoutK = "prover_timeout" (*=TIME: timeout for invoked ATP (seconds of process time)*)
    35 val prover_timeoutK = "prover_timeout" (*=TIME: timeout for invoked ATP (seconds of process time)*)
    36 val sliceK = "slice" (*=BOOL: allow sledgehammer-level strategy-scheduling*)
    36 val sliceK = "slice" (*=BOOL: allow sledgehammer-level strategy-scheduling*)
    37 val smt_proofsK = "smt_proofs" (*=BOOL: enable SMT proof generation*)
    37 val smt_proofsK = "smt_proofs" (*=BOOL: enable SMT proof generation*)
    38 val strictK = "strict" (*=BOOL: run in strict mode*)
    38 val strictK = "strict" (*=BOOL: run in strict mode*)
    39 val strideK = "stride" (*=NUM: run every nth goal*)
       
    40 val term_orderK = "term_order" (*=STRING: term order (in E)*)
    39 val term_orderK = "term_order" (*=STRING: term order (in E)*)
    41 val type_encK = "type_enc" (*=STRING: type encoding scheme*)
    40 val type_encK = "type_enc" (*=STRING: type encoding scheme*)
    42 val uncurried_aliasesK = "uncurried_aliases" (*=SMART_BOOL: use fresh function names to alias curried applications*)
    41 val uncurried_aliasesK = "uncurried_aliases" (*=SMART_BOOL: use fresh function names to alias curried applications*)
    43 
    42 
    44 val separator = "-----"
    43 val separator = "-----"
    49 val lam_trans_default = "smart"
    48 val lam_trans_default = "smart"
    50 val uncurried_aliases_default = "smart"
    49 val uncurried_aliases_default = "smart"
    51 val fact_filter_default = "smart"
    50 val fact_filter_default = "smart"
    52 val type_enc_default = "smart"
    51 val type_enc_default = "smart"
    53 val strict_default = "false"
    52 val strict_default = "false"
    54 val stride_default = 1
       
    55 val max_facts_default = "smart"
    53 val max_facts_default = "smart"
    56 val slice_default = "true"
    54 val slice_default = "true"
    57 val max_calls_default = 10000000
    55 val max_calls_default = 10000000
    58 val check_trivial_default = false
    56 val check_trivial_default = false
    59 
    57 
   613     if Exn.is_interrupt exn then Exn.reraise exn
   611     if Exn.is_interrupt exn then Exn.reraise exn
   614     else Mirabelle.print_exn exn
   612     else Mirabelle.print_exn exn
   615 
   613 
   616 (* crude hack *)
   614 (* crude hack *)
   617 val num_sledgehammer_calls = Unsynchronized.ref 0
   615 val num_sledgehammer_calls = Unsynchronized.ref 0
   618 val remaining_stride = Unsynchronized.ref stride_default
       
   619 
   616 
   620 val _ =
   617 val _ =
   621   Theory.setup (Mirabelle.theory_action \<^binding>\<open>sledgehammer\<close>
   618   Theory.setup (Mirabelle.theory_action \<^binding>\<open>sledgehammer\<close>
   622     (fn context => fn commands =>
   619     (fn context => fn commands =>
   623       let
   620       let
   625         fun proof_method_tag meth = "#" ^ string_of_int index ^ " " ^ meth ^ " (sledgehammer): "
   622         fun proof_method_tag meth = "#" ^ string_of_int index ^ " " ^ meth ^ " (sledgehammer): "
   626 
   623 
   627         val data = Unsynchronized.ref empty_data
   624         val data = Unsynchronized.ref empty_data
   628         val change_data = Unsynchronized.change data
   625         val change_data = Unsynchronized.change data
   629 
   626 
   630         val stride = Mirabelle.get_int_argument args (strideK, stride_default)
       
   631         val max_calls = Mirabelle.get_int_argument args (max_callsK, max_calls_default)
   627         val max_calls = Mirabelle.get_int_argument args (max_callsK, max_calls_default)
   632         val check_trivial = Mirabelle.get_bool_argument args (check_trivialK, check_trivial_default)
   628         val check_trivial = Mirabelle.get_bool_argument args (check_trivialK, check_trivial_default)
   633 
   629 
   634         val results =
   630         val results =
   635           commands |> maps (fn command =>
   631           commands |> maps (fn command =>
   636             let
   632             let
   637               val {name, pos, pre = st, ...} = command
   633               val {name, pos, pre = st, ...} = command
   638               val goal = Thm.major_prem_of (#goal (Proof.goal st))
   634               val goal = Thm.major_prem_of (#goal (Proof.goal st))
   639               val log =
   635               val log =
   640                 if can Logic.dest_conjunction goal orelse can Logic.dest_equals goal then []
   636                 if can Logic.dest_conjunction goal orelse can Logic.dest_equals goal then []
   641                 else if !remaining_stride > 1 then
       
   642                   (* We still have some steps to do *)
       
   643                   (Unsynchronized.dec remaining_stride; ["Skipping because of stride"])
       
   644                 else
   637                 else
   645                   (* This was the last step, now run the action *)
       
   646                   let
   638                   let
   647                     val _ = remaining_stride := stride
       
   648                     val _ = Unsynchronized.inc num_sledgehammer_calls
   639                     val _ = Unsynchronized.inc num_sledgehammer_calls
   649                   in
   640                   in
   650                     if !num_sledgehammer_calls > max_calls then
   641                     if !num_sledgehammer_calls > max_calls then
   651                       ["Skipping because max number of calls reached"]
   642                       ["Skipping because max number of calls reached"]
   652                     else
   643                     else