src/HOL/TPTP/CASC_Setup.thy
author blanchet
Wed Jul 13 22:16:19 2011 +0200 (2011-07-13)
changeset 43806 6b158ce2b5e2
parent 43805 0349175384f8
child 43807 bfad30568d40
permissions -rw-r--r--
added some arithmetic functions, for THF with arithmetic
blanchet@43806
     1
(*  Title:      HOL/TPTP/CASC_Setup.thy
blanchet@42071
     2
    Author:     Jasmin Blanchette
blanchet@42071
     3
    Copyright   2011
blanchet@42071
     4
blanchet@42601
     5
Setup for Isabelle, Nitpick, and Refute for participating at CASC in the THF and
blanchet@42601
     6
TNT divisions. This theory file should be loaded by the Isabelle theory files
blanchet@42601
     7
generated by Geoff Sutcliffe's TPTP2X tool from the original THF0 files.
blanchet@42071
     8
*)
blanchet@42071
     9
blanchet@42601
    10
theory CASC_Setup
blanchet@43805
    11
imports Complex_Main
blanchet@43806
    12
uses "../ex/sledgehammer_tactics.ML"
blanchet@43806
    13
begin
blanchet@43806
    14
blanchet@43806
    15
consts
blanchet@43806
    16
  is_int :: "'a \<Rightarrow> bool"
blanchet@43806
    17
  is_rat :: "'a \<Rightarrow> bool"
blanchet@43806
    18
blanchet@43806
    19
overloading rat_is_int \<equiv> "is_int :: rat \<Rightarrow> bool"
blanchet@43806
    20
begin
blanchet@43806
    21
  definition "rat_is_int (q\<Colon>rat) \<longleftrightarrow> (\<exists>n\<Colon>int. q = of_int n)"
blanchet@43806
    22
end
blanchet@43806
    23
blanchet@43806
    24
overloading real_is_int \<equiv> "is_int :: real \<Rightarrow> bool"
blanchet@43806
    25
begin
blanchet@43806
    26
  definition "real_is_int (x\<Colon>real) \<longleftrightarrow> x \<in> \<int>"
blanchet@43806
    27
end
blanchet@43806
    28
blanchet@43806
    29
overloading real_is_rat \<equiv> "is_rat :: real \<Rightarrow> bool"
blanchet@43806
    30
begin
blanchet@43806
    31
  definition "real_is_rat (x\<Colon>real) \<longleftrightarrow> x \<in> \<rat>"
blanchet@43806
    32
end
blanchet@43806
    33
blanchet@43806
    34
consts
blanchet@43806
    35
  to_int :: "'a \<Rightarrow> int"
blanchet@43806
    36
  to_rat :: "'a \<Rightarrow> rat"
blanchet@43806
    37
  to_real :: "'a \<Rightarrow> real"
blanchet@43806
    38
blanchet@43806
    39
overloading rat_to_int \<equiv> "to_int :: rat \<Rightarrow> int"
blanchet@43806
    40
begin
blanchet@43806
    41
  definition "rat_to_int (q\<Colon>rat) = floor q"
blanchet@43806
    42
end
blanchet@43806
    43
blanchet@43806
    44
overloading real_to_int \<equiv> "to_int :: real \<Rightarrow> int"
blanchet@43806
    45
begin
blanchet@43806
    46
  definition "real_to_int (x\<Colon>real) = floor x"
blanchet@43806
    47
end
blanchet@43806
    48
blanchet@43806
    49
overloading int_to_rat \<equiv> "to_rat :: int \<Rightarrow> rat"
blanchet@42063
    50
begin
blanchet@43806
    51
  definition "int_to_rat (n\<Colon>int) = (of_int n\<Colon>rat)"
blanchet@43806
    52
end
blanchet@43806
    53
blanchet@43806
    54
overloading real_to_rat \<equiv> "to_rat :: real \<Rightarrow> rat"
blanchet@43806
    55
begin
blanchet@43806
    56
  definition "real_to_rat (x\<Colon>real) = (inv real x\<Colon>rat)"
blanchet@43806
    57
end
blanchet@43806
    58
blanchet@43806
    59
overloading int_to_real \<equiv> "to_real :: int \<Rightarrow> real"
blanchet@43806
    60
begin
blanchet@43806
    61
  definition "int_to_real (n\<Colon>int) = real n"
blanchet@43806
    62
end
blanchet@43806
    63
blanchet@43806
    64
overloading rat_to_real \<equiv> "to_real :: rat \<Rightarrow> real"
blanchet@43806
    65
begin
blanchet@43806
    66
  definition "rat_to_real (x\<Colon>rat) = (of_rat x\<Colon>real)"
blanchet@43806
    67
end
blanchet@43806
    68
blanchet@43806
    69
declare
blanchet@43806
    70
  rat_is_int_def [simp]
blanchet@43806
    71
  real_is_int_def [simp]
blanchet@43806
    72
  real_is_rat_def [simp]
blanchet@43806
    73
  rat_to_int_def [simp]
blanchet@43806
    74
  real_to_int_def [simp]
blanchet@43806
    75
  int_to_rat_def [simp]
blanchet@43806
    76
  real_to_rat_def [simp]
blanchet@43806
    77
  int_to_real_def [simp]
blanchet@43806
    78
  rat_to_real_def [simp]
blanchet@43806
    79
blanchet@43806
    80
lemma to_rat_is_int [intro, simp]: "is_int (to_rat (n\<Colon>int))"
blanchet@43806
    81
by (metis int_to_rat_def rat_is_int_def)
blanchet@43806
    82
blanchet@43806
    83
lemma to_real_is_int [intro, simp]: "is_int (to_real (n\<Colon>int))"
blanchet@43806
    84
by (metis Ints_real_of_int int_to_real_def real_is_int_def)
blanchet@43806
    85
blanchet@43806
    86
lemma to_real_is_rat [intro, simp]: "is_rat (to_real (q\<Colon>rat))"
blanchet@43806
    87
by (metis Rats_of_rat rat_to_real_def real_is_rat_def)
blanchet@43806
    88
blanchet@43806
    89
lemma inj_of_rat [intro, simp]: "inj (of_rat\<Colon>rat\<Rightarrow>real)"
blanchet@43806
    90
by (metis injI of_rat_eq_iff rat_to_real_def)
blanchet@42063
    91
blanchet@42063
    92
declare mem_def [simp add]
blanchet@42063
    93
blanchet@42063
    94
declare [[smt_oracle]]
blanchet@42063
    95
blanchet@42106
    96
refute_params [maxtime = 10000, no_assms, expect = genuine]
blanchet@42106
    97
nitpick_params [timeout = none, card = 1-50, verbose, dont_box, no_assms,
blanchet@42211
    98
                batch_size = 1, expect = genuine]
blanchet@42106
    99
wenzelm@42078
   100
ML {* Proofterm.proofs := 0 *}
blanchet@42063
   101
blanchet@42063
   102
ML {*
blanchet@42063
   103
fun SOLVE_TIMEOUT seconds name tac st =
blanchet@42063
   104
  let
blanchet@42063
   105
    val result =
blanchet@42063
   106
      TimeLimit.timeLimit (Time.fromSeconds seconds)
blanchet@42063
   107
        (fn () => SINGLE (SOLVE tac) st) ()
blanchet@42063
   108
      handle TimeLimit.TimeOut => NONE
blanchet@42063
   109
        | ERROR _ => NONE
blanchet@42063
   110
  in
blanchet@42063
   111
    (case result of
blanchet@42213
   112
      NONE => (warning ("FAILURE: " ^ name); Seq.empty)
blanchet@42213
   113
    | SOME st' => (warning ("SUCCESS: " ^ name); Seq.single st'))
blanchet@42063
   114
  end
blanchet@42063
   115
*}
blanchet@42063
   116
blanchet@42063
   117
ML {*
wenzelm@42800
   118
fun isabellep_tac ctxt max_secs =
blanchet@42213
   119
   SOLVE_TIMEOUT (max_secs div 10) "smt" (ALLGOALS (SMT_Solver.smt_tac ctxt []))
blanchet@42063
   120
   ORELSE
blanchet@42213
   121
   SOLVE_TIMEOUT (max_secs div 5) "sledgehammer"
blanchet@42213
   122
       (ALLGOALS (Sledgehammer_Tactics.sledgehammer_as_oracle_tac ctxt))
blanchet@42063
   123
   ORELSE
wenzelm@42800
   124
   SOLVE_TIMEOUT (max_secs div 10) "simp" (ALLGOALS (asm_full_simp_tac (simpset_of ctxt)))
blanchet@42213
   125
   ORELSE
wenzelm@42800
   126
   SOLVE_TIMEOUT (max_secs div 20) "blast" (ALLGOALS (blast_tac ctxt))
blanchet@42063
   127
   ORELSE
wenzelm@42800
   128
   SOLVE_TIMEOUT (max_secs div 10) "auto" (auto_tac ctxt
blanchet@42213
   129
       THEN ALLGOALS (Sledgehammer_Tactics.sledgehammer_as_oracle_tac ctxt))
blanchet@42063
   130
   ORELSE
blanchet@43205
   131
   SOLVE_TIMEOUT (max_secs div 10) "metis"
blanchet@43212
   132
       (ALLGOALS (Metis_Tactics.metis_tac [] ctxt []))
blanchet@42063
   133
   ORELSE
wenzelm@42800
   134
   SOLVE_TIMEOUT (max_secs div 10) "fast" (ALLGOALS (fast_tac ctxt))
blanchet@42063
   135
   ORELSE
wenzelm@42800
   136
   SOLVE_TIMEOUT (max_secs div 10) "best" (ALLGOALS (best_tac ctxt))
blanchet@42063
   137
   ORELSE
wenzelm@42800
   138
   SOLVE_TIMEOUT (max_secs div 10) "force" (ALLGOALS (force_tac ctxt))
blanchet@42063
   139
   ORELSE
wenzelm@42800
   140
   SOLVE_TIMEOUT max_secs "fastsimp" (ALLGOALS (fast_simp_tac ctxt))
blanchet@42063
   141
*}
blanchet@42063
   142
blanchet@42827
   143
method_setup isabellep = {*
blanchet@43161
   144
  Scan.lift (Scan.optional Parse.nat 1) >>
blanchet@42827
   145
    (fn m => fn ctxt => SIMPLE_METHOD (isabellep_tac ctxt m))
blanchet@43161
   146
*} "combination of Isabelle provers and oracles for CASC"
blanchet@42827
   147
blanchet@42063
   148
end