src/HOL/Tools/res_atp.ML
changeset 31410 c231efe693ce
parent 31409 d8537ba165b5
child 31723 f5cafe803b55
equal deleted inserted replaced
31409:d8537ba165b5 31410:c231efe693ce
     6   val tvar_classes_of_terms : term list -> string list
     6   val tvar_classes_of_terms : term list -> string list
     7   val tfree_classes_of_terms : term list -> string list
     7   val tfree_classes_of_terms : term list -> string list
     8   val type_consts_of_terms : theory -> term list -> string list
     8   val type_consts_of_terms : theory -> term list -> string list
     9   val get_relevant : int -> bool -> Proof.context * (thm list * 'a) -> thm list ->
     9   val get_relevant : int -> bool -> Proof.context * (thm list * 'a) -> thm list ->
    10     (thm * (string * int)) list
    10     (thm * (string * int)) list
    11   val prepare_clauses : bool -> thm list ->
    11   val prepare_clauses : bool -> thm list -> thm list ->
    12     (thm * (ResHolClause.axiom_name * ResHolClause.clause_id)) list -> theory ->
    12     (thm * (ResHolClause.axiom_name * ResHolClause.clause_id)) list -> theory ->
    13     ResHolClause.axiom_name vector * (ResHolClause.clause list * ResHolClause.clause list *
    13     ResHolClause.axiom_name vector * (ResHolClause.clause list * ResHolClause.clause list *
    14     ResHolClause.clause list * ResClause.classrelClause list * ResClause.arityClause list)
    14     ResHolClause.clause list * ResClause.classrelClause list * ResClause.arityClause list)
    15 end;
    15 end;
    16 
    16 
   401   | check_named (_,th) = true;
   401   | check_named (_,th) = true;
   402 
   402 
   403 fun display_thm (name,th) = Output.debug (fn () => name ^ ": " ^ Display.string_of_thm th);
   403 fun display_thm (name,th) = Output.debug (fn () => name ^ ": " ^ Display.string_of_thm th);
   404 
   404 
   405 (* get lemmas from claset, simpset, atpset and extra supplied rules *)
   405 (* get lemmas from claset, simpset, atpset and extra supplied rules *)
   406 fun get_clasimp_atp_lemmas ctxt user_thms =
   406 fun get_clasimp_atp_lemmas ctxt =
   407   let val included_thms =
   407   let val included_thms =
   408         if include_all
   408     if include_all
   409         then (tap (fn ths => Output.debug
   409     then (tap (fn ths => Output.debug
   410                      (fn () => ("Including all " ^ Int.toString (length ths) ^ " theorems")))
   410                  (fn () => ("Including all " ^ Int.toString (length ths) ^ " theorems")))
   411                   (name_thm_pairs ctxt))
   411               (name_thm_pairs ctxt))
   412         else
   412     else
   413         let val atpset_thms =
   413     let val atpset_thms =
   414                 if include_atpset then ResAxioms.atpset_rules_of ctxt
   414             if include_atpset then ResAxioms.atpset_rules_of ctxt
   415                 else []
   415             else []
   416             val _ = (Output.debug (fn () => "ATP theorems: ");  app display_thm atpset_thms)
   416         val _ = (Output.debug (fn () => "ATP theorems: ");  app display_thm atpset_thms)
   417         in  atpset_thms  end
   417     in  atpset_thms  end
   418       val user_rules = filter check_named
   418   in
   419                          (map ResAxioms.pairname
   419     filter check_named included_thms
   420                            (if null user_thms then whitelist else user_thms))
       
   421   in
       
   422       (filter check_named included_thms, user_rules)
       
   423   end;
   420   end;
   424 
   421 
   425 (***************************************************************)
   422 (***************************************************************)
   426 (* Type Classes Present in the Axiom or Conjecture Clauses     *)
   423 (* Type Classes Present in the Axiom or Conjecture Clauses     *)
   427 (***************************************************************)
   424 (***************************************************************)
   519     | Hol => false
   516     | Hol => false
   520 
   517 
   521 fun get_relevant max_new theory_const (ctxt, (chain_ths, th)) goal_cls =
   518 fun get_relevant max_new theory_const (ctxt, (chain_ths, th)) goal_cls =
   522   let
   519   let
   523     val thy = ProofContext.theory_of ctxt
   520     val thy = ProofContext.theory_of ctxt
   524     val (included_thms,white_thms) = get_clasimp_atp_lemmas ctxt chain_ths
   521     val included_thms = get_clasimp_atp_lemmas ctxt
   525     val included_cls = included_thms |> ResAxioms.cnf_rules_pairs thy |> make_unique
   522     val included_cls = included_thms |> ResAxioms.cnf_rules_pairs thy |> make_unique
   526                                      |> restrict_to_logic thy (isFO thy goal_cls)
   523                                      |> restrict_to_logic thy (isFO thy goal_cls)
   527                                      |> remove_unwanted_clauses
   524                                      |> remove_unwanted_clauses
       
   525   in
       
   526     relevance_filter max_new theory_const thy included_cls (map prop_of goal_cls)
       
   527   end;
       
   528 
       
   529 (* prepare and count clauses before writing *)
       
   530 fun prepare_clauses dfg goal_cls chain_ths axcls thy =
       
   531   let
       
   532     val white_thms = filter check_named (map ResAxioms.pairname (if null chain_ths then whitelist else chain_ths))
   528     val white_cls = ResAxioms.cnf_rules_pairs thy white_thms
   533     val white_cls = ResAxioms.cnf_rules_pairs thy white_thms
   529     (*clauses relevant to goal gl*)
   534     val axcls = white_cls @ axcls
   530   in
       
   531     white_cls @ relevance_filter max_new theory_const thy included_cls (map prop_of goal_cls)
       
   532   end;
       
   533 
       
   534 (* prepare and count clauses before writing *)
       
   535 fun prepare_clauses dfg goal_cls axcls thy =
       
   536   let
       
   537     val ccls = subtract_cls goal_cls axcls
   535     val ccls = subtract_cls goal_cls axcls
   538     val _ = app (fn th => Output.debug (fn _ => Display.string_of_thm th)) ccls
   536     val _ = app (fn th => Output.debug (fn _ => Display.string_of_thm th)) ccls
   539     val ccltms = map prop_of ccls
   537     val ccltms = map prop_of ccls
   540     and axtms = map (prop_of o #1) axcls
   538     and axtms = map (prop_of o #1) axcls
   541     val subs = tfree_classes_of_terms ccltms
   539     val subs = tfree_classes_of_terms ccltms