src/HOL/TPTP/atp_problem_import.ML
changeset 47946 33afcfad3f8d
parent 47845 2a2bc13669bd
child 47957 d2bdd85ee23c
equal deleted inserted replaced
47945:4073e51293cf 47946:33afcfad3f8d
    13   val nitpick_tptp_file : theory -> int -> string -> unit
    13   val nitpick_tptp_file : theory -> int -> string -> unit
    14   val refute_tptp_file : theory -> int -> string -> unit
    14   val refute_tptp_file : theory -> int -> string -> unit
    15   val can_tac : Proof.context -> tactic -> term -> bool
    15   val can_tac : Proof.context -> tactic -> term -> bool
    16   val SOLVE_TIMEOUT :  int -> string -> tactic -> tactic
    16   val SOLVE_TIMEOUT :  int -> string -> tactic -> tactic
    17   val atp_tac :
    17   val atp_tac :
    18     Proof.context -> (string * string) list -> int -> string -> int -> tactic
    18     Proof.context -> int -> (string * string) list -> int -> string -> int
       
    19     -> tactic
    19   val smt_solver_tac : string -> Proof.context -> int -> tactic
    20   val smt_solver_tac : string -> Proof.context -> int -> tactic
    20   val freeze_problem_consts : theory -> term -> term
    21   val freeze_problem_consts : theory -> term -> term
    21   val make_conj : term list * term list -> term list -> term
    22   val make_conj : term list * term list -> term list -> term
    22   val sledgehammer_tptp_file : theory -> int -> string -> unit
    23   val sledgehammer_tptp_file : theory -> int -> string -> unit
    23   val isabelle_demo_tptp_file : theory -> int -> string -> unit
    24   val isabelle_demo_tptp_file : theory -> int -> string -> unit
   175           Nitpick.pick_nits_in_term state params Nitpick.Normal i n step subst
   176           Nitpick.pick_nits_in_term state params Nitpick.Normal i n step subst
   176                                     [] [] conj
   177                                     [] [] conj
   177       in if outcome = "none" then Skip_Proof.cheat_tac thy th else Seq.empty end
   178       in if outcome = "none" then Skip_Proof.cheat_tac thy th else Seq.empty end
   178   end
   179   end
   179 
   180 
   180 fun atp_tac ctxt override_params timeout prover =
   181 fun atp_tac ctxt aggressivity override_params timeout prover =
   181   Sledgehammer_Tactics.sledgehammer_as_oracle_tac ctxt
   182   let
   182       ([("debug", if debug then "true" else "false"),
   183     val ctxt =
   183         ("overlord", if overlord then "true" else "false"),
   184       ctxt |> Config.put Sledgehammer_Provers.aggressive (aggressivity > 0)
   184         ("provers", prover),
   185   in
   185         ("timeout", string_of_int timeout)] @ override_params)
   186     Sledgehammer_Tactics.sledgehammer_as_oracle_tac ctxt
   186       {add = [(Facts.named (Thm.derivation_name ext), [])],
   187         ([("debug", if debug then "true" else "false"),
   187        del = [], only = true}
   188           ("overlord", if overlord then "true" else "false"),
       
   189           ("provers", prover),
       
   190           ("timeout", string_of_int timeout)] @
       
   191          (if aggressivity > 0 then
       
   192             [("type_enc",
       
   193               if aggressivity = 1 then "mono_native" else "poly_guards??"),
       
   194              ("slicing", "false")]
       
   195           else
       
   196             []) @
       
   197          override_params)
       
   198         {add = [(Facts.named (Thm.derivation_name ext), [])],
       
   199          del = [], only = true}
       
   200   end
   188 
   201 
   189 fun sledgehammer_tac demo ctxt timeout i =
   202 fun sledgehammer_tac demo ctxt timeout i =
   190   let
   203   let
   191     val frac = if demo then 6 else 4
   204     val frac = if demo then 16 else 12
   192     fun slice prover =
   205     fun slice mult aggressivity prover =
   193       SOLVE_TIMEOUT (timeout div frac) prover
   206       SOLVE_TIMEOUT (mult * timeout div frac)
   194                     (atp_tac ctxt [] (timeout div frac) prover i)
   207           (prover ^
   195   in
   208            (if aggressivity > 0 then "(" ^ string_of_int aggressivity ^ ")"
   196     (if demo then
   209             else ""))
   197        slice ATP_Systems.satallaxN
   210           (atp_tac ctxt aggressivity [] (timeout div frac) prover i)
   198        ORELSE slice ATP_Systems.leo2N
   211   in
   199      else
   212     slice 2 0 ATP_Systems.spassN
   200        no_tac)
   213     ORELSE slice 2 0 ATP_Systems.vampireN
   201     ORELSE slice ATP_Systems.spassN
   214     ORELSE slice 2 0 ATP_Systems.eN
   202     ORELSE slice ATP_Systems.vampireN
   215     ORELSE slice 2 0 ATP_Systems.z3_tptpN
   203     ORELSE slice ATP_Systems.eN
   216     ORELSE slice 1 1 ATP_Systems.spassN
   204     ORELSE slice ATP_Systems.z3_tptpN
   217     ORELSE slice 1 2 ATP_Systems.eN
       
   218     ORELSE slice 1 1 ATP_Systems.vampireN
       
   219     ORELSE slice 1 2 ATP_Systems.vampireN
       
   220     ORELSE
       
   221       (if demo then
       
   222          slice 2 0 ATP_Systems.satallaxN
       
   223          ORELSE slice 2 0 ATP_Systems.leo2N
       
   224        else
       
   225          no_tac)
   205   end
   226   end
   206 
   227 
   207 fun smt_solver_tac solver ctxt =
   228 fun smt_solver_tac solver ctxt =
   208   let
   229   let
   209     val ctxt = ctxt |> Context.proof_map (SMT_Config.select_solver solver)
   230     val ctxt = ctxt |> Context.proof_map (SMT_Config.select_solver solver)
   210   in SMT_Solver.smt_tac ctxt [] end
   231   in SMT_Solver.smt_tac ctxt [] end
   211 
   232 
   212 fun auto_etc_tac ctxt timeout i =
   233 fun auto_etc_tac ctxt timeout i =
   213   SOLVE_TIMEOUT (timeout div 20) "nitpick"
   234   SOLVE_TIMEOUT (timeout div 20) "nitpick"
   214       (nitpick_finite_oracle_tac ctxt (timeout div 20) i)
   235       (nitpick_finite_oracle_tac ctxt (timeout div 20) i)
   215   ORELSE SOLVE_TIMEOUT (timeout div 20) "simp"
   236   ORELSE SOLVE_TIMEOUT (timeout div 10) "simp"
   216       (asm_full_simp_tac (simpset_of ctxt) i)
   237       (asm_full_simp_tac (simpset_of ctxt) i)
   217   ORELSE SOLVE_TIMEOUT (timeout div 10) "blast" (blast_tac ctxt i)
   238   ORELSE SOLVE_TIMEOUT (timeout div 10) "blast" (blast_tac ctxt i)
   218   ORELSE SOLVE_TIMEOUT (timeout div 5) "auto+spass"
   239   ORELSE SOLVE_TIMEOUT (timeout div 5) "auto+spass"
   219       (auto_tac ctxt
   240       (auto_tac ctxt
   220        THEN ALLGOALS (atp_tac ctxt [] (timeout div 5) ATP_Systems.spassN))
   241        THEN ALLGOALS (atp_tac ctxt 0 [] (timeout div 5) ATP_Systems.spassN))
   221   ORELSE SOLVE_TIMEOUT (timeout div 10) "z3" (smt_solver_tac "z3" ctxt i)
   242   ORELSE SOLVE_TIMEOUT (timeout div 10) "fast" (fast_tac ctxt i)
   222   ORELSE SOLVE_TIMEOUT (timeout div 10) "cvc3" (smt_solver_tac "cvc3" ctxt i)
   243   ORELSE SOLVE_TIMEOUT (timeout div 20) "z3" (smt_solver_tac "z3" ctxt i)
   223   ORELSE SOLVE_TIMEOUT (timeout div 20) "fast" (fast_tac ctxt i)
   244   ORELSE SOLVE_TIMEOUT (timeout div 20) "cvc3" (smt_solver_tac "cvc3" ctxt i)
   224   ORELSE SOLVE_TIMEOUT (timeout div 20) "best" (best_tac ctxt i)
   245   ORELSE SOLVE_TIMEOUT (timeout div 20) "best" (best_tac ctxt i)
   225   ORELSE SOLVE_TIMEOUT (timeout div 10) "force" (force_tac ctxt i)
   246   ORELSE SOLVE_TIMEOUT (timeout div 10) "force" (force_tac ctxt i)
   226   ORELSE SOLVE_TIMEOUT (timeout div 10) "meson" (Meson.meson_tac ctxt [] i)
   247   ORELSE SOLVE_TIMEOUT (timeout div 10) "meson" (Meson.meson_tac ctxt [] i)
   227   ORELSE SOLVE_TIMEOUT (timeout div 10) "fastforce" (fast_force_tac ctxt i)
   248   ORELSE SOLVE_TIMEOUT (timeout div 10) "fastforce" (fast_force_tac ctxt i)
   228 
   249 
   262 fun isabelle_tptp_file demo thy timeout file_name =
   283 fun isabelle_tptp_file demo thy timeout file_name =
   263   let
   284   let
   264     val (conjs, assms, ctxt) =
   285     val (conjs, assms, ctxt) =
   265       read_tptp_file thy (freeze_problem_consts thy) file_name
   286       read_tptp_file thy (freeze_problem_consts thy) file_name
   266     val conj = make_conj assms conjs
   287     val conj = make_conj assms conjs
   267     val last_hope = if demo then ATP_Systems.satallaxN else ATP_Systems.spassN
   288     val last_hope = if demo then ATP_Systems.satallaxN else ATP_Systems.vampireN
   268   in
   289   in
   269     (can_tac ctxt (auto_etc_tac ctxt (timeout div 2) 1) conj orelse
   290     (can_tac ctxt (auto_etc_tac ctxt (timeout div 2) 1) conj orelse
   270      can_tac ctxt (sledgehammer_tac demo ctxt (timeout div 2) 1) conj orelse
   291      can_tac ctxt (sledgehammer_tac demo ctxt (timeout div 2) 1) conj orelse
   271      can_tac ctxt (atp_tac ctxt [] timeout last_hope 1) conj)
   292      can_tac ctxt (atp_tac ctxt 2 [] timeout last_hope 1) conj)
   272     |> print_szs_from_success conjs
   293     |> print_szs_from_success conjs
   273   end
   294   end
   274 
   295 
   275 val isabelle_demo_tptp_file = isabelle_tptp_file true
   296 val isabelle_demo_tptp_file = isabelle_tptp_file true
   276 val isabelle_comp_tptp_file = isabelle_tptp_file false
   297 val isabelle_comp_tptp_file = isabelle_tptp_file false