src/HOL/Tools/Sledgehammer/sledgehammer_prover.ML
changeset 75025 f741d55a81e5
parent 75023 fdda7e754f45
child 75026 b61949cba32a
equal deleted inserted replaced
75024:114eb0af123d 75025:f741d55a81e5
    12   type stature = ATP_Problem_Generate.stature
    12   type stature = ATP_Problem_Generate.stature
    13   type type_enc = ATP_Problem_Generate.type_enc
    13   type type_enc = ATP_Problem_Generate.type_enc
    14   type fact = Sledgehammer_Fact.fact
    14   type fact = Sledgehammer_Fact.fact
    15   type proof_method = Sledgehammer_Proof_Methods.proof_method
    15   type proof_method = Sledgehammer_Proof_Methods.proof_method
    16   type play_outcome = Sledgehammer_Proof_Methods.play_outcome
    16   type play_outcome = Sledgehammer_Proof_Methods.play_outcome
       
    17   type atp_slice = Sledgehammer_ATP_Systems.atp_slice
    17 
    18 
    18   datatype mode = Auto_Try | Try | Normal | Minimize | MaSh
    19   datatype mode = Auto_Try | Try | Normal | Minimize | MaSh
    19 
    20 
    20   datatype induction_rules = Include | Exclude | Instantiate
    21   datatype induction_rules = Include | Exclude | Instantiate
    21   val induction_rules_of_string : string -> induction_rules option
    22   val induction_rules_of_string : string -> induction_rules option
    56     {comment : string,
    57     {comment : string,
    57      state : Proof.state,
    58      state : Proof.state,
    58      goal : thm,
    59      goal : thm,
    59      subgoal : int,
    60      subgoal : int,
    60      subgoal_count : int,
    61      subgoal_count : int,
    61      facts : string * fact list,
    62      factss : (string * fact list) list,
    62      found_proof : string -> unit}
    63      found_proof : string -> unit}
       
    64 
       
    65   datatype prover_slice =
       
    66     ATP_Slice of atp_slice
       
    67   | SMT_Slice of int * string
    63 
    68 
    64   type prover_result =
    69   type prover_result =
    65     {outcome : atp_failure option,
    70     {outcome : atp_failure option,
    66      used_facts : (string * stature) list,
    71      used_facts : (string * stature) list,
    67      used_from : fact list,
    72      used_from : fact list,
    68      preferred_methss : proof_method * proof_method list list,
    73      preferred_methss : proof_method * proof_method list list,
    69      run_time : Time.time,
    74      run_time : Time.time,
    70      message : (unit -> (string * stature) list * (proof_method * play_outcome)) -> string}
    75      message : (unit -> (string * stature) list * (proof_method * play_outcome)) -> string}
    71 
    76 
    72   type prover = params -> prover_problem -> prover_result
    77   type prover = params -> prover_problem -> prover_slice -> prover_result
    73 
    78 
    74   val SledgehammerN : string
    79   val SledgehammerN : string
    75   val str_of_mode : mode -> string
    80   val str_of_mode : mode -> string
    76   val overlord_file_location_of_prover : string -> string * string
    81   val overlord_file_location_of_prover : string -> string * string
    77   val proof_banner : mode -> string -> string
    82   val proof_banner : mode -> string -> string
    78   val is_atp : theory -> string -> bool
    83   val is_atp : theory -> string -> bool
    79   val bunches_of_proof_methods : Proof.context -> bool -> bool -> bool -> string ->
    84   val bunches_of_proof_methods : Proof.context -> bool -> bool -> bool -> string ->
    80     proof_method list list
    85     proof_method list list
       
    86   val get_facts_of_filter : string -> (string * fact list) list -> fact list
    81   val is_fact_chained : (('a * stature) * 'b) -> bool
    87   val is_fact_chained : (('a * stature) * 'b) -> bool
    82   val filter_used_facts : bool -> (''a * stature) list -> ((''a * stature) * 'b) list ->
    88   val filter_used_facts : bool -> (''a * stature) list -> ((''a * stature) * 'b) list ->
    83     ((''a * stature) * 'b) list
    89     ((''a * stature) * 'b) list
    84   val repair_monomorph_context : int option -> int -> int option -> int -> Proof.context ->
    90   val repair_monomorph_context : int option -> int -> int option -> int -> Proof.context ->
    85     Proof.context
    91     Proof.context
   188   {comment : string,
   194   {comment : string,
   189    state : Proof.state,
   195    state : Proof.state,
   190    goal : thm,
   196    goal : thm,
   191    subgoal : int,
   197    subgoal : int,
   192    subgoal_count : int,
   198    subgoal_count : int,
   193    facts : string * fact list,
   199    factss : (string * fact list) list,
   194    found_proof : string -> unit}
   200    found_proof : string -> unit}
       
   201 
       
   202 datatype prover_slice =
       
   203   ATP_Slice of atp_slice
       
   204 | SMT_Slice of int * string
   195 
   205 
   196 type prover_result =
   206 type prover_result =
   197   {outcome : atp_failure option,
   207   {outcome : atp_failure option,
   198    used_facts : (string * stature) list,
   208    used_facts : (string * stature) list,
   199    used_from : fact list,
   209    used_from : fact list,
   200    preferred_methss : proof_method * proof_method list list,
   210    preferred_methss : proof_method * proof_method list list,
   201    run_time : Time.time,
   211    run_time : Time.time,
   202    message : (unit -> (string * stature) list * (proof_method * play_outcome)) -> string}
   212    message : (unit -> (string * stature) list * (proof_method * play_outcome)) -> string}
   203 
   213 
   204 type prover = params -> prover_problem -> prover_result
   214 type prover = params -> prover_problem -> prover_slice -> prover_result
   205 
   215 
   206 fun overlord_file_location_of_prover prover = (getenv "ISABELLE_HOME_USER", "prob_" ^ prover)
   216 fun overlord_file_location_of_prover prover = (getenv "ISABELLE_HOME_USER", "prob_" ^ prover)
   207 
   217 
   208 fun proof_banner mode prover_name =
   218 fun proof_banner mode prover_name =
   209   (case mode of
   219   (case mode of
   238         []
   248         []
   239   in
   249   in
   240     try0_methodss @ [metis_methods] @ smt_methodss
   250     try0_methodss @ [metis_methods] @ smt_methodss
   241   end
   251   end
   242 
   252 
       
   253 fun get_facts_of_filter fact_filter factss =
       
   254   (case AList.lookup (op =) factss fact_filter of
       
   255     SOME facts => facts
       
   256   | NONE => snd (hd factss))
       
   257 
   243 fun is_fact_chained ((_, (sc, _)), _) = sc = Chained
   258 fun is_fact_chained ((_, (sc, _)), _) = sc = Chained
   244 
   259 
   245 fun filter_used_facts keep_chained used =
   260 fun filter_used_facts keep_chained used =
   246   filter ((member (eq_fst (op =)) used o fst) orf
   261   filter ((member (eq_fst (op =)) used o fst) orf
   247     (if keep_chained then is_fact_chained else K false))
   262     (if keep_chained then is_fact_chained else K false))