src/HOL/Tools/Sledgehammer/sledgehammer_fact.ML
changeset 61054 add998b3c597
parent 60948 b710a5087116
child 61322 44f4ffe2b210
equal deleted inserted replaced
61053:62f3b4988277 61054:add998b3c597
   458   end
   458   end
   459 
   459 
   460 fun all_facts ctxt generous ho_atp keywords add_ths chained css =
   460 fun all_facts ctxt generous ho_atp keywords add_ths chained css =
   461   let
   461   let
   462     val thy = Proof_Context.theory_of ctxt
   462     val thy = Proof_Context.theory_of ctxt
       
   463     val transfer = Global_Theory.transfer_theories thy;
   463     val global_facts = Global_Theory.facts_of thy
   464     val global_facts = Global_Theory.facts_of thy
   464     val is_too_complex =
   465     val is_too_complex =
   465       if generous orelse fact_count global_facts >= max_facts_for_complex_check then K false
   466       if generous orelse fact_count global_facts >= max_facts_for_complex_check then K false
   466       else is_too_complex
   467       else is_too_complex
   467     val local_facts = Proof_Context.facts_of ctxt
   468     val local_facts = Proof_Context.facts_of ctxt
   491             fun check_thms a =
   492             fun check_thms a =
   492               (case try (Proof_Context.get_thms ctxt) a of
   493               (case try (Proof_Context.get_thms ctxt) a of
   493                 NONE => false
   494                 NONE => false
   494               | SOME ths' => eq_list Thm.eq_thm_prop (ths, ths'))
   495               | SOME ths' => eq_list Thm.eq_thm_prop (ths, ths'))
   495           in
   496           in
   496             snd (fold_rev (fn th => fn (j, accum) =>
   497             snd (fold_rev (fn th0 => fn (j, accum) =>
   497               (j - 1,
   498               let val th = transfer th0 in
   498                if not (member Thm.eq_thm_prop add_ths th) andalso
   499                 (j - 1,
   499                   (is_likely_tautology_too_meta_or_too_technical th orelse
   500                  if not (member Thm.eq_thm_prop add_ths th) andalso
   500                    is_too_complex (Thm.prop_of th)) then
   501                     (is_likely_tautology_too_meta_or_too_technical th orelse
   501                  accum
   502                      is_too_complex (Thm.prop_of th)) then
   502                else
   503                    accum
   503                  let
   504                  else
   504                    fun get_name () =
   505                    let
   505                      if name0 = "" orelse name0 = local_thisN then
   506                      fun get_name () =
   506                        backquote_thm ctxt th
   507                        if name0 = "" orelse name0 = local_thisN then
   507                      else
   508                          backquote_thm ctxt th
   508                        let val short_name = Facts.extern ctxt facts name0 in
   509                        else
   509                          if check_thms short_name then
   510                          let val short_name = Facts.extern ctxt facts name0 in
   510                            short_name
   511                            if check_thms short_name then
   511                          else
   512                              short_name
   512                            let val long_name = Name_Space.extern ctxt full_space name0 in
   513                            else
   513                              if check_thms long_name then
   514                              let val long_name = Name_Space.extern ctxt full_space name0 in
   514                                long_name
   515                                if check_thms long_name then
   515                              else
   516                                  long_name
   516                                name0
   517                                else
   517                            end
   518                                  name0
   518                        end
   519                              end
   519                        |> make_name keywords multi j
   520                          end
   520                    val stature = stature_of_thm global assms chained css name0 th
   521                          |> make_name keywords multi j
   521                    val new = ((get_name, stature), th)
   522                      val stature = stature_of_thm global assms chained css name0 th
   522                  in
   523                      val new = ((get_name, stature), th)
   523                    (if multi then apsnd else apfst) (cons new) accum
   524                    in
   524                  end)) ths (n, accum))
   525                      (if multi then apsnd else apfst) (cons new) accum
       
   526                    end)
       
   527               end) ths (n, accum))
   525           end)
   528           end)
   526   in
   529   in
   527     (* The single-theorem names go before the multiple-theorem ones (e.g., "xxx" vs. "xxx(3)"), so
   530     (* The single-theorem names go before the multiple-theorem ones (e.g., "xxx" vs. "xxx(3)"), so
   528        that single names are preferred when both are available. *)
   531        that single names are preferred when both are available. *)
   529     `I []
   532     `I []