src/HOL/Tools/ATP/atp_proof_reconstruct.ML
changeset 77602 7c25451ae2c1
parent 77576 80bcebe6cf33
child 78693 1c0576840bf4
equal deleted inserted replaced
77601:d39027e1c8c5 77602:7c25451ae2c1
    62   val termify_atp_abduce_candidate : Proof.context -> string -> ATP_Problem.atp_format ->
    62   val termify_atp_abduce_candidate : Proof.context -> string -> ATP_Problem.atp_format ->
    63     ATP_Problem_Generate.type_enc -> string Symtab.table -> (string * term) list ->
    63     ATP_Problem_Generate.type_enc -> string Symtab.table -> (string * term) list ->
    64     int Symtab.table -> (string, string, (string, string atp_type) atp_term, string) atp_formula ->
    64     int Symtab.table -> (string, string, (string, string atp_type) atp_term, string) atp_formula ->
    65     term
    65     term
    66   val top_abduce_candidates : int -> term list -> term list
    66   val top_abduce_candidates : int -> term list -> term list
       
    67   val sort_propositions_by_provability : Proof.context -> term list -> term list
    67 end;
    68 end;
    68 
    69 
    69 structure ATP_Proof_Reconstruct : ATP_PROOF_RECONSTRUCT =
    70 structure ATP_Proof_Reconstruct : ATP_PROOF_RECONSTRUCT =
    70 struct
    71 struct
    71 
    72 
   857         else NONE)
   858         else NONE)
   858   in
   859   in
   859     sort_top max_candidates (map_filter maybe_score candidates)
   860     sort_top max_candidates (map_filter maybe_score candidates)
   860   end
   861   end
   861 
   862 
       
   863 fun provability_status ctxt t =
       
   864   let
       
   865     val res = Timeout.apply (seconds 0.1)
       
   866       (Thm.term_of o Thm.rhs_of o Simplifier.full_rewrite ctxt) (Thm.cterm_of ctxt t)
       
   867   in
       
   868     if res aconv @{prop True} then SOME true
       
   869     else if res aconv @{prop False} then SOME false
       
   870     else NONE
       
   871   end
       
   872   handle Timeout.TIMEOUT _ => NONE
       
   873 
       
   874 (* Put propositions that simplify to "True" first, and filter out propositions
       
   875    that simplify to "False". *)
       
   876 fun sort_propositions_by_provability ctxt ts =
       
   877   let
       
   878     val statuses_ts = map (`(provability_status ctxt)) ts
       
   879   in
       
   880     maps (fn (SOME true, t) => [t] | _ => []) statuses_ts @
       
   881     maps (fn (NONE, t) => [t] | _ => []) statuses_ts
       
   882   end
       
   883 
   862 end;
   884 end;