src/HOL/TPTP/atp_problem_import.ML
changeset 69597 ff784d5a5bfb
parent 64561 a7664ca9ffc5
child 72001 3e08311ada8e
equal deleted inserted replaced
69596:c8a2755bf220 69597:ff784d5a5bfb
    61   end
    61   end
    62 
    62 
    63 
    63 
    64 (** Nitpick **)
    64 (** Nitpick **)
    65 
    65 
    66 fun aptrueprop f ((t0 as @{const Trueprop}) $ t1) = t0 $ f t1
    66 fun aptrueprop f ((t0 as \<^const>\<open>Trueprop\<close>) $ t1) = t0 $ f t1
    67   | aptrueprop f t = f t
    67   | aptrueprop f t = f t
    68 
    68 
    69 fun is_legitimate_tptp_def (@{const Trueprop} $ t) = is_legitimate_tptp_def t
    69 fun is_legitimate_tptp_def (\<^const>\<open>Trueprop\<close> $ t) = is_legitimate_tptp_def t
    70   | is_legitimate_tptp_def (Const (@{const_name HOL.eq}, _) $ t $ u) =
    70   | is_legitimate_tptp_def (Const (\<^const_name>\<open>HOL.eq\<close>, _) $ t $ u) =
    71     (is_Const t orelse is_Free t) andalso not (exists_subterm (curry (op =) t) u)
    71     (is_Const t orelse is_Free t) andalso not (exists_subterm (curry (op =) t) u)
    72   | is_legitimate_tptp_def _ = false
    72   | is_legitimate_tptp_def _ = false
    73 
    73 
    74 fun nitpick_tptp_file thy timeout file_name =
    74 fun nitpick_tptp_file thy timeout file_name =
    75   let
    75   let
   100     val n = 1
   100     val n = 1
   101     val step = 0
   101     val step = 0
   102     val subst = []
   102     val subst = []
   103   in
   103   in
   104     Nitpick.pick_nits_in_term state params Nitpick.TPTP i n step subst defs nondefs
   104     Nitpick.pick_nits_in_term state params Nitpick.TPTP i n step subst defs nondefs
   105       (case conjs of conj :: _ => conj | [] => @{prop True});
   105       (case conjs of conj :: _ => conj | [] => \<^prop>\<open>True\<close>);
   106     ()
   106     ()
   107   end
   107   end
   108 
   108 
   109 
   109 
   110 (** Refute **)
   110 (** Refute **)
   122     val params =
   122     val params =
   123       [("maxtime", string_of_int timeout),
   123       [("maxtime", string_of_int timeout),
   124        ("maxvars", "100000")]
   124        ("maxvars", "100000")]
   125   in
   125   in
   126     Refute.refute_term ctxt params (defs @ nondefs)
   126     Refute.refute_term ctxt params (defs @ nondefs)
   127       (case conjs of conj :: _ => conj | [] => @{prop True})
   127       (case conjs of conj :: _ => conj | [] => \<^prop>\<open>True\<close>)
   128     |> print_szs_of_outcome (not (null conjs))
   128     |> print_szs_of_outcome (not (null conjs))
   129   end
   129   end
   130 
   130 
   131 
   131 
   132 (** Sledgehammer and Isabelle (combination of provers) **)
   132 (** Sledgehammer and Isabelle (combination of provers) **)
   146     | SOME st' => (writeln ("SUCCESS: " ^ name); Seq.single st'))
   146     | SOME st' => (writeln ("SUCCESS: " ^ name); Seq.single st'))
   147   end
   147   end
   148 
   148 
   149 fun nitpick_finite_oracle_tac ctxt timeout i th =
   149 fun nitpick_finite_oracle_tac ctxt timeout i th =
   150   let
   150   let
   151     fun is_safe (Type (@{type_name fun}, Ts)) = forall is_safe Ts
   151     fun is_safe (Type (\<^type_name>\<open>fun\<close>, Ts)) = forall is_safe Ts
   152       | is_safe @{typ prop} = true
   152       | is_safe \<^typ>\<open>prop\<close> = true
   153       | is_safe @{typ bool} = true
   153       | is_safe \<^typ>\<open>bool\<close> = true
   154       | is_safe _ = false
   154       | is_safe _ = false
   155 
   155 
   156     val conj = Thm.term_of (Thm.cprem_of th i)
   156     val conj = Thm.term_of (Thm.cprem_of th i)
   157   in
   157   in
   158     if exists_type (not o is_safe) conj then
   158     if exists_type (not o is_safe) conj then
   185   let
   185   let
   186     val thy = Proof_Context.theory_of ctxt
   186     val thy = Proof_Context.theory_of ctxt
   187     val assm_ths0 = map (Skip_Proof.make_thm thy) assms
   187     val assm_ths0 = map (Skip_Proof.make_thm thy) assms
   188     val ((assm_name, _), ctxt) = ctxt
   188     val ((assm_name, _), ctxt) = ctxt
   189       |> Config.put Sledgehammer_Prover_ATP.atp_completish (if completeness > 0 then 3 else 0)
   189       |> Config.put Sledgehammer_Prover_ATP.atp_completish (if completeness > 0 then 3 else 0)
   190       |> Local_Theory.note ((@{binding thms}, []), assm_ths0)
   190       |> Local_Theory.note ((\<^binding>\<open>thms\<close>, []), assm_ths0)
   191 
   191 
   192     fun ref_of th = (Facts.named (Thm.derivation_name th), [])
   192     fun ref_of th = (Facts.named (Thm.derivation_name th), [])
   193     val ref_of_assms = (Facts.named assm_name, [])
   193     val ref_of_assms = (Facts.named assm_name, [])
   194   in
   194   in
   195     Sledgehammer_Tactics.sledgehammer_as_oracle_tac ctxt
   195     Sledgehammer_Tactics.sledgehammer_as_oracle_tac ctxt
   258       (fn t as Const (s, T) => if is_problem_const s then Free (Long_Name.base_name s, T) else t
   258       (fn t as Const (s, T) => if is_problem_const s then Free (Long_Name.base_name s, T) else t
   259         | t => t)
   259         | t => t)
   260   end
   260   end
   261 
   261 
   262 fun make_conj (defs, nondefs) conjs =
   262 fun make_conj (defs, nondefs) conjs =
   263   Logic.list_implies (rev defs @ rev nondefs, case conjs of conj :: _ => conj | [] => @{prop False})
   263   Logic.list_implies (rev defs @ rev nondefs, case conjs of conj :: _ => conj | [] => \<^prop>\<open>False\<close>)
   264 
   264 
   265 fun print_szs_of_success conjs success =
   265 fun print_szs_of_success conjs success =
   266   writeln ("% SZS status " ^
   266   writeln ("% SZS status " ^
   267     (if success then
   267     (if success then
   268        if null conjs then "Unsatisfiable" else "Theorem"
   268        if null conjs then "Unsatisfiable" else "Theorem"