src/HOL/Tools/ATP/atp_proof_reconstruct.ML
changeset 46340 cac402c486b0
parent 46320 0b8b73b49848
child 46342 c59b8560eb48
equal deleted inserted replaced
46339:6268c5b3efdc 46340:cac402c486b0
     9 signature ATP_PROOF_RECONSTRUCT =
     9 signature ATP_PROOF_RECONSTRUCT =
    10 sig
    10 sig
    11   type ('a, 'b) ho_term = ('a, 'b) ATP_Problem.ho_term
    11   type ('a, 'b) ho_term = ('a, 'b) ATP_Problem.ho_term
    12   type ('a, 'b, 'c) formula = ('a, 'b, 'c) ATP_Problem.formula
    12   type ('a, 'b, 'c) formula = ('a, 'b, 'c) ATP_Problem.formula
    13   type 'a proof = 'a ATP_Proof.proof
    13   type 'a proof = 'a ATP_Proof.proof
    14   type locality = ATP_Problem_Generate.locality
    14   type stature = ATP_Problem_Generate.stature
    15 
    15 
    16   datatype reconstructor =
    16   datatype reconstructor =
    17     Metis of string * string |
    17     Metis of string * string |
    18     SMT
    18     SMT
    19 
    19 
    22     Trust_Playable of reconstructor * Time.time option |
    22     Trust_Playable of reconstructor * Time.time option |
    23     Failed_to_Play of reconstructor
    23     Failed_to_Play of reconstructor
    24 
    24 
    25   type minimize_command = string list -> string
    25   type minimize_command = string list -> string
    26   type one_line_params =
    26   type one_line_params =
    27     play * string * (string * locality) list * minimize_command * int * int
    27     play * string * (string * stature) list * minimize_command * int * int
    28   type isar_params =
    28   type isar_params =
    29     bool * int * string Symtab.table * (string * locality) list vector
    29     bool * int * string Symtab.table * (string * stature) list vector
    30     * int Symtab.table * string proof * thm
    30     * int Symtab.table * string proof * thm
    31 
    31 
    32   val metisN : string
    32   val metisN : string
    33   val smtN : string
    33   val smtN : string
    34   val full_typesN : string
    34   val full_typesN : string
    42   val partial_type_encs : string list
    42   val partial_type_encs : string list
    43   val metis_default_lam_trans : string
    43   val metis_default_lam_trans : string
    44   val metis_call : string -> string -> string
    44   val metis_call : string -> string -> string
    45   val string_for_reconstructor : reconstructor -> string
    45   val string_for_reconstructor : reconstructor -> string
    46   val used_facts_in_atp_proof :
    46   val used_facts_in_atp_proof :
    47     Proof.context -> (string * locality) list vector -> string proof
    47     Proof.context -> (string * stature) list vector -> string proof
    48     -> (string * locality) list
    48     -> (string * stature) list
    49   val lam_trans_from_atp_proof : string proof -> string -> string
    49   val lam_trans_from_atp_proof : string proof -> string -> string
    50   val is_typed_helper_used_in_atp_proof : string proof -> bool
    50   val is_typed_helper_used_in_atp_proof : string proof -> bool
    51   val used_facts_in_unsound_atp_proof :
    51   val used_facts_in_unsound_atp_proof :
    52     Proof.context -> (string * locality) list vector -> 'a proof
    52     Proof.context -> (string * stature) list vector -> 'a proof
    53     -> string list option
    53     -> string list option
    54   val unalias_type_enc : string -> string list
    54   val unalias_type_enc : string -> string list
    55   val one_line_proof_text : one_line_params -> string
    55   val one_line_proof_text : one_line_params -> string
    56   val make_tvar : string -> typ
    56   val make_tvar : string -> typ
    57   val make_tfree : Proof.context -> string -> typ
    57   val make_tfree : Proof.context -> string -> typ
    91   Trust_Playable of reconstructor * Time.time option |
    91   Trust_Playable of reconstructor * Time.time option |
    92   Failed_to_Play of reconstructor
    92   Failed_to_Play of reconstructor
    93 
    93 
    94 type minimize_command = string list -> string
    94 type minimize_command = string list -> string
    95 type one_line_params =
    95 type one_line_params =
    96   play * string * (string * locality) list * minimize_command * int * int
    96   play * string * (string * stature) list * minimize_command * int * int
    97 type isar_params =
    97 type isar_params =
    98   bool * int * string Symtab.table * (string * locality) list vector
    98   bool * int * string Symtab.table * (string * stature) list vector
    99   * int Symtab.table * string proof * thm
    99   * int Symtab.table * string proof * thm
   100 
   100 
   101 val metisN = "metis"
   101 val metisN = "metis"
   102 val smtN = "smt"
   102 val smtN = "smt"
   103 
   103 
   196     isa_ext
   196     isa_ext
   197 
   197 
   198 fun add_fact _ fact_names (Inference ((_, ss), _, _, [])) =
   198 fun add_fact _ fact_names (Inference ((_, ss), _, _, [])) =
   199     union (op =) (resolve_fact fact_names ss)
   199     union (op =) (resolve_fact fact_names ss)
   200   | add_fact ctxt _ (Inference (_, _, rule, _)) =
   200   | add_fact ctxt _ (Inference (_, _, rule, _)) =
   201     if rule = leo2_ext then insert (op =) (ext_name ctxt, General) else I
   201     if rule = leo2_ext then insert (op =) (ext_name ctxt, (Global, General))
       
   202     else I
   202   | add_fact _ _ _ = I
   203   | add_fact _ _ _ = I
   203 
   204 
   204 fun used_facts_in_atp_proof ctxt fact_names atp_proof =
   205 fun used_facts_in_atp_proof ctxt fact_names atp_proof =
   205   if null atp_proof then Vector.foldl (uncurry (union (op =))) [] fact_names
   206   if null atp_proof then Vector.foldl (uncurry (union (op =))) [] fact_names
   206   else fold (add_fact ctxt fact_names) atp_proof []
   207   else fold (add_fact ctxt fact_names) atp_proof []
   207 
       
   208 (* (quasi-)underapproximation of the truth *)
       
   209 fun is_locality_global Local = false
       
   210   | is_locality_global Assum = false
       
   211   | is_locality_global Chained = false
       
   212   | is_locality_global _ = true
       
   213 
   208 
   214 fun used_facts_in_unsound_atp_proof _ _ [] = NONE
   209 fun used_facts_in_unsound_atp_proof _ _ [] = NONE
   215   | used_facts_in_unsound_atp_proof ctxt fact_names atp_proof =
   210   | used_facts_in_unsound_atp_proof ctxt fact_names atp_proof =
   216     let
   211     let
   217       val used_facts = used_facts_in_atp_proof ctxt fact_names atp_proof
   212       val used_facts = used_facts_in_atp_proof ctxt fact_names atp_proof
   218     in
   213     in
   219       if forall (is_locality_global o snd) used_facts andalso
   214       if forall (fn (_, (sc, _)) => sc = Global) used_facts andalso
   220          not (is_axiom_used_in_proof (is_conjecture o single) atp_proof) then
   215          not (is_axiom_used_in_proof (is_conjecture o single) atp_proof) then
   221         SOME (map fst used_facts)
   216         SOME (map fst used_facts)
   222       else
   217       else
   223         NONE
   218         NONE
   224     end
   219     end
   248   command_call (string_for_reconstructor reconstr) ss
   243   command_call (string_for_reconstructor reconstr) ss
   249 fun minimize_line _ [] = ""
   244 fun minimize_line _ [] = ""
   250   | minimize_line minimize_command ss =
   245   | minimize_line minimize_command ss =
   251     case minimize_command ss of
   246     case minimize_command ss of
   252       "" => ""
   247       "" => ""
   253     | command => "\nTo minimize: " ^ Markup.markup Isabelle_Markup.sendback command ^ "."
   248     | command =>
       
   249       "\nTo minimize: " ^ Markup.markup Isabelle_Markup.sendback command ^ "."
   254 
   250 
   255 val split_used_facts =
   251 val split_used_facts =
   256   List.partition (curry (op =) Chained o snd)
   252   List.partition (fn (_, (sc, _)) => sc = Chained)
   257   #> pairself (sort_distinct (string_ord o pairself fst))
   253   #> pairself (sort_distinct (string_ord o pairself fst))
   258 
   254 
   259 fun one_line_proof_text (preplay, banner, used_facts, minimize_command,
   255 fun one_line_proof_text (preplay, banner, used_facts, minimize_command,
   260                          subgoal, subgoal_count) =
   256                          subgoal, subgoal_count) =
   261   let
   257   let