src/HOL/HOL.thy
author wenzelm
Sat, 25 Apr 2009 21:28:04 +0200
changeset 30981 fe0855471964
parent 30970 3fe2e418a071
child 31024 0fdf666e08bf
permissions -rw-r--r--
misc cleanup of auto_solve and quickcheck:
tools are in src/Tools and loaded uniformly in HOL;
preferences are configured in their proper place -- despite old misleading comments in the source;
use predefined preferences categories;
setmp preferences in-place;
clasohm@923
     1
(*  Title:      HOL/HOL.thy
wenzelm@11750
     2
    Author:     Tobias Nipkow, Markus Wenzel, and Larry Paulson
wenzelm@11750
     3
*)
clasohm@923
     4
wenzelm@11750
     5
header {* The basis of Higher-Order Logic *}
clasohm@923
     6
nipkow@15131
     7
theory HOL
haftmann@30929
     8
imports Pure "~~/src/Tools/Code_Generator"
wenzelm@23163
     9
uses
haftmann@28952
    10
  ("Tools/hologic.ML")
wenzelm@30981
    11
  "~~/src/Tools/auto_solve.ML"
wenzelm@23171
    12
  "~~/src/Tools/IsaPlanner/zipper.ML"
wenzelm@23171
    13
  "~~/src/Tools/IsaPlanner/isand.ML"
wenzelm@23171
    14
  "~~/src/Tools/IsaPlanner/rw_tools.ML"
wenzelm@23171
    15
  "~~/src/Tools/IsaPlanner/rw_inst.ML"
wenzelm@30165
    16
  "~~/src/Tools/intuitionistic.ML"
wenzelm@30160
    17
  "~~/src/Tools/project_rule.ML"
haftmann@23263
    18
  "~~/src/Provers/hypsubst.ML"
haftmann@23263
    19
  "~~/src/Provers/splitter.ML"
wenzelm@23163
    20
  "~~/src/Provers/classical.ML"
wenzelm@23163
    21
  "~~/src/Provers/blast.ML"
wenzelm@23163
    22
  "~~/src/Provers/clasimp.ML"
wenzelm@30160
    23
  "~~/src/Tools/coherent.ML"
wenzelm@30160
    24
  "~~/src/Tools/eqsubst.ML"
wenzelm@23163
    25
  "~~/src/Provers/quantifier1.ML"
haftmann@28952
    26
  ("Tools/simpdata.ML")
wenzelm@25741
    27
  "~~/src/Tools/random_word.ML"
krauss@26580
    28
  "~~/src/Tools/atomize_elim.ML"
haftmann@24901
    29
  "~~/src/Tools/induct.ML"
wenzelm@27326
    30
  ("~~/src/Tools/induct_tacs.ML")
haftmann@29505
    31
  ("Tools/recfun_codegen.ML")
nipkow@15131
    32
begin
wenzelm@2260
    33
wenzelm@30165
    34
setup {* Intuitionistic.method_setup "iprover" *}
wenzelm@30165
    35
wenzelm@30165
    36
wenzelm@11750
    37
subsection {* Primitive logic *}
wenzelm@11750
    38
wenzelm@11750
    39
subsubsection {* Core syntax *}
wenzelm@2260
    40
wenzelm@14854
    41
classes type
wenzelm@12338
    42
defaultsort type
wenzelm@25494
    43
setup {* ObjectLogic.add_base_sort @{sort type} *}
haftmann@25460
    44
haftmann@25460
    45
arities
haftmann@25460
    46
  "fun" :: (type, type) type
haftmann@25460
    47
  itself :: (type) type
haftmann@25460
    48
wenzelm@3947
    49
global
wenzelm@3947
    50
wenzelm@7357
    51
typedecl bool
clasohm@923
    52
wenzelm@11750
    53
judgment
wenzelm@11750
    54
  Trueprop      :: "bool => prop"                   ("(_)" 5)
wenzelm@11750
    55
clasohm@923
    56
consts
wenzelm@7357
    57
  Not           :: "bool => bool"                   ("~ _" [40] 40)
wenzelm@7357
    58
  True          :: bool
wenzelm@7357
    59
  False         :: bool
clasohm@923
    60
wenzelm@11432
    61
  The           :: "('a => bool) => 'a"
wenzelm@7357
    62
  All           :: "('a => bool) => bool"           (binder "ALL " 10)
wenzelm@7357
    63
  Ex            :: "('a => bool) => bool"           (binder "EX " 10)
wenzelm@7357
    64
  Ex1           :: "('a => bool) => bool"           (binder "EX! " 10)
wenzelm@7357
    65
  Let           :: "['a, 'a => 'b] => 'b"
clasohm@923
    66
haftmann@22839
    67
  "op ="        :: "['a, 'a] => bool"               (infixl "=" 50)
haftmann@22839
    68
  "op &"        :: "[bool, bool] => bool"           (infixr "&" 35)
haftmann@22839
    69
  "op |"        :: "[bool, bool] => bool"           (infixr "|" 30)
haftmann@22839
    70
  "op -->"      :: "[bool, bool] => bool"           (infixr "-->" 25)
clasohm@923
    71
wenzelm@10432
    72
local
wenzelm@10432
    73
paulson@16587
    74
consts
paulson@16587
    75
  If            :: "[bool, 'a, 'a] => 'a"           ("(if (_)/ then (_)/ else (_))" 10)
clasohm@923
    76
wenzelm@19656
    77
wenzelm@11750
    78
subsubsection {* Additional concrete syntax *}
wenzelm@2260
    79
wenzelm@21210
    80
notation (output)
wenzelm@19656
    81
  "op ="  (infix "=" 50)
wenzelm@19656
    82
wenzelm@19656
    83
abbreviation
wenzelm@21404
    84
  not_equal :: "['a, 'a] => bool"  (infixl "~=" 50) where
wenzelm@19656
    85
  "x ~= y == ~ (x = y)"
wenzelm@19656
    86
wenzelm@21210
    87
notation (output)
wenzelm@19656
    88
  not_equal  (infix "~=" 50)
wenzelm@19656
    89
wenzelm@21210
    90
notation (xsymbols)
wenzelm@21404
    91
  Not  ("\<not> _" [40] 40) and
wenzelm@21404
    92
  "op &"  (infixr "\<and>" 35) and
wenzelm@21404
    93
  "op |"  (infixr "\<or>" 30) and
wenzelm@21404
    94
  "op -->"  (infixr "\<longrightarrow>" 25) and
wenzelm@19656
    95
  not_equal  (infix "\<noteq>" 50)
wenzelm@19656
    96
wenzelm@21210
    97
notation (HTML output)
wenzelm@21404
    98
  Not  ("\<not> _" [40] 40) and
wenzelm@21404
    99
  "op &"  (infixr "\<and>" 35) and
wenzelm@21404
   100
  "op |"  (infixr "\<or>" 30) and
wenzelm@19656
   101
  not_equal  (infix "\<noteq>" 50)
wenzelm@19656
   102
wenzelm@19656
   103
abbreviation (iff)
wenzelm@21404
   104
  iff :: "[bool, bool] => bool"  (infixr "<->" 25) where
wenzelm@19656
   105
  "A <-> B == A = B"
wenzelm@19656
   106
wenzelm@21210
   107
notation (xsymbols)
wenzelm@19656
   108
  iff  (infixr "\<longleftrightarrow>" 25)
wenzelm@19656
   109
wenzelm@19656
   110
wenzelm@4868
   111
nonterminals
clasohm@923
   112
  letbinds  letbind
clasohm@923
   113
  case_syn  cases_syn
clasohm@923
   114
clasohm@923
   115
syntax
wenzelm@11432
   116
  "_The"        :: "[pttrn, bool] => 'a"                 ("(3THE _./ _)" [0, 10] 10)
clasohm@923
   117
wenzelm@7357
   118
  "_bind"       :: "[pttrn, 'a] => letbind"              ("(2_ =/ _)" 10)
wenzelm@7357
   119
  ""            :: "letbind => letbinds"                 ("_")
wenzelm@7357
   120
  "_binds"      :: "[letbind, letbinds] => letbinds"     ("_;/ _")
wenzelm@7357
   121
  "_Let"        :: "[letbinds, 'a] => 'a"                ("(let (_)/ in (_))" 10)
clasohm@923
   122
wenzelm@9060
   123
  "_case_syntax":: "['a, cases_syn] => 'b"               ("(case _ of/ _)" 10)
wenzelm@9060
   124
  "_case1"      :: "['a, 'b] => case_syn"                ("(2_ =>/ _)" 10)
wenzelm@7357
   125
  ""            :: "case_syn => cases_syn"               ("_")
wenzelm@9060
   126
  "_case2"      :: "[case_syn, cases_syn] => cases_syn"  ("_/ | _")
clasohm@923
   127
clasohm@923
   128
translations
nipkow@13764
   129
  "THE x. P"              == "The (%x. P)"
clasohm@923
   130
  "_Let (_binds b bs) e"  == "_Let b (_Let bs e)"
nipkow@1114
   131
  "let x = a in e"        == "Let a (%x. e)"
clasohm@923
   132
nipkow@13763
   133
print_translation {*
nipkow@13763
   134
(* To avoid eta-contraction of body: *)
nipkow@13763
   135
[("The", fn [Abs abs] =>
nipkow@13763
   136
     let val (x,t) = atomic_abs_tr' abs
nipkow@13763
   137
     in Syntax.const "_The" $ x $ t end)]
nipkow@13763
   138
*}
nipkow@13763
   139
wenzelm@12114
   140
syntax (xsymbols)
wenzelm@11687
   141
  "_case1"      :: "['a, 'b] => case_syn"                ("(2_ \<Rightarrow>/ _)" 10)
wenzelm@2372
   142
wenzelm@21524
   143
notation (xsymbols)
wenzelm@21524
   144
  All  (binder "\<forall>" 10) and
wenzelm@21524
   145
  Ex  (binder "\<exists>" 10) and
wenzelm@21524
   146
  Ex1  (binder "\<exists>!" 10)
wenzelm@6340
   147
wenzelm@21524
   148
notation (HTML output)
wenzelm@21524
   149
  All  (binder "\<forall>" 10) and
wenzelm@21524
   150
  Ex  (binder "\<exists>" 10) and
wenzelm@21524
   151
  Ex1  (binder "\<exists>!" 10)
wenzelm@21524
   152
wenzelm@21524
   153
notation (HOL)
wenzelm@21524
   154
  All  (binder "! " 10) and
wenzelm@21524
   155
  Ex  (binder "? " 10) and
wenzelm@21524
   156
  Ex1  (binder "?! " 10)
wenzelm@7238
   157
wenzelm@7238
   158
wenzelm@11750
   159
subsubsection {* Axioms and basic definitions *}
wenzelm@2260
   160
wenzelm@7357
   161
axioms
paulson@15380
   162
  refl:           "t = (t::'a)"
haftmann@28513
   163
  subst:          "s = t \<Longrightarrow> P s \<Longrightarrow> P t"
paulson@15380
   164
  ext:            "(!!x::'a. (f x ::'b) = g x) ==> (%x. f x) = (%x. g x)"
paulson@15380
   165
    -- {*Extensionality is built into the meta-logic, and this rule expresses
paulson@15380
   166
         a related property.  It is an eta-expanded version of the traditional
paulson@15380
   167
         rule, and similar to the ABS rule of HOL*}
paulson@6289
   168
wenzelm@11432
   169
  the_eq_trivial: "(THE x. x = a) = (a::'a)"
clasohm@923
   170
paulson@15380
   171
  impI:           "(P ==> Q) ==> P-->Q"
paulson@15380
   172
  mp:             "[| P-->Q;  P |] ==> Q"
paulson@15380
   173
paulson@15380
   174
clasohm@923
   175
defs
wenzelm@7357
   176
  True_def:     "True      == ((%x::bool. x) = (%x. x))"
wenzelm@7357
   177
  All_def:      "All(P)    == (P = (%x. True))"
paulson@11451
   178
  Ex_def:       "Ex(P)     == !Q. (!x. P x --> Q) --> Q"
wenzelm@7357
   179
  False_def:    "False     == (!P. P)"
wenzelm@7357
   180
  not_def:      "~ P       == P-->False"
wenzelm@7357
   181
  and_def:      "P & Q     == !R. (P-->Q-->R) --> R"
wenzelm@7357
   182
  or_def:       "P | Q     == !R. (P-->R) --> (Q-->R) --> R"
wenzelm@7357
   183
  Ex1_def:      "Ex1(P)    == ? x. P(x) & (! y. P(y) --> y=x)"
clasohm@923
   184
wenzelm@7357
   185
axioms
wenzelm@7357
   186
  iff:          "(P-->Q) --> (Q-->P) --> (P=Q)"
wenzelm@7357
   187
  True_or_False:  "(P=True) | (P=False)"
clasohm@923
   188
clasohm@923
   189
defs
haftmann@24219
   190
  Let_def:      "Let s f == f(s)"
paulson@11451
   191
  if_def:       "If P x y == THE z::'a. (P=True --> z=x) & (P=False --> z=y)"
wenzelm@5069
   192
skalberg@14223
   193
finalconsts
skalberg@14223
   194
  "op ="
skalberg@14223
   195
  "op -->"
skalberg@14223
   196
  The
nipkow@3320
   197
haftmann@22481
   198
axiomatization
haftmann@22481
   199
  undefined :: 'a
wenzelm@19656
   200
haftmann@28682
   201
abbreviation (input)
haftmann@28682
   202
  "arbitrary \<equiv> undefined"
haftmann@22481
   203
haftmann@22481
   204
haftmann@22481
   205
subsubsection {* Generic classes and algebraic operations *}
haftmann@22481
   206
haftmann@29608
   207
class default =
haftmann@24901
   208
  fixes default :: 'a
wenzelm@4793
   209
haftmann@29608
   210
class zero = 
haftmann@25062
   211
  fixes zero :: 'a  ("0")
haftmann@20713
   212
haftmann@29608
   213
class one =
haftmann@25062
   214
  fixes one  :: 'a  ("1")
haftmann@20713
   215
haftmann@20713
   216
hide (open) const zero one
wenzelm@11750
   217
haftmann@29608
   218
class plus =
haftmann@25062
   219
  fixes plus :: "'a \<Rightarrow> 'a \<Rightarrow> 'a"  (infixl "+" 65)
haftmann@20590
   220
haftmann@29608
   221
class minus =
haftmann@25762
   222
  fixes minus :: "'a \<Rightarrow> 'a \<Rightarrow> 'a"  (infixl "-" 65)
haftmann@25762
   223
haftmann@29608
   224
class uminus =
haftmann@25062
   225
  fixes uminus :: "'a \<Rightarrow> 'a"  ("- _" [81] 80)
haftmann@20590
   226
haftmann@29608
   227
class times =
haftmann@25062
   228
  fixes times :: "'a \<Rightarrow> 'a \<Rightarrow> 'a"  (infixl "*" 70)
haftmann@20590
   229
haftmann@29608
   230
class inverse =
haftmann@20590
   231
  fixes inverse :: "'a \<Rightarrow> 'a"
haftmann@25062
   232
    and divide :: "'a \<Rightarrow> 'a \<Rightarrow> 'a"  (infixl "'/" 70)
wenzelm@21524
   233
haftmann@29608
   234
class abs =
haftmann@23878
   235
  fixes abs :: "'a \<Rightarrow> 'a"
wenzelm@25388
   236
begin
haftmann@23878
   237
wenzelm@21524
   238
notation (xsymbols)
wenzelm@21524
   239
  abs  ("\<bar>_\<bar>")
wenzelm@25388
   240
wenzelm@21524
   241
notation (HTML output)
wenzelm@21524
   242
  abs  ("\<bar>_\<bar>")
wenzelm@11750
   243
wenzelm@25388
   244
end
wenzelm@25388
   245
haftmann@29608
   246
class sgn =
haftmann@25062
   247
  fixes sgn :: "'a \<Rightarrow> 'a"
haftmann@25062
   248
haftmann@29608
   249
class ord =
haftmann@24748
   250
  fixes less_eq :: "'a \<Rightarrow> 'a \<Rightarrow> bool"
haftmann@24748
   251
    and less :: "'a \<Rightarrow> 'a \<Rightarrow> bool"
haftmann@23878
   252
begin
haftmann@23878
   253
haftmann@23878
   254
notation
haftmann@23878
   255
  less_eq  ("op <=") and
haftmann@23878
   256
  less_eq  ("(_/ <= _)" [51, 51] 50) and
haftmann@23878
   257
  less  ("op <") and
haftmann@23878
   258
  less  ("(_/ < _)"  [51, 51] 50)
haftmann@23878
   259
  
haftmann@23878
   260
notation (xsymbols)
haftmann@23878
   261
  less_eq  ("op \<le>") and
haftmann@23878
   262
  less_eq  ("(_/ \<le> _)"  [51, 51] 50)
haftmann@23878
   263
haftmann@23878
   264
notation (HTML output)
haftmann@23878
   265
  less_eq  ("op \<le>") and
haftmann@23878
   266
  less_eq  ("(_/ \<le> _)"  [51, 51] 50)
haftmann@23878
   267
wenzelm@25388
   268
abbreviation (input)
wenzelm@25388
   269
  greater_eq  (infix ">=" 50) where
wenzelm@25388
   270
  "x >= y \<equiv> y <= x"
wenzelm@25388
   271
haftmann@24842
   272
notation (input)
haftmann@23878
   273
  greater_eq  (infix "\<ge>" 50)
haftmann@23878
   274
wenzelm@25388
   275
abbreviation (input)
wenzelm@25388
   276
  greater  (infix ">" 50) where
wenzelm@25388
   277
  "x > y \<equiv> y < x"
wenzelm@25388
   278
wenzelm@25388
   279
end
wenzelm@25388
   280
wenzelm@13456
   281
syntax
wenzelm@13456
   282
  "_index1"  :: index    ("\<^sub>1")
wenzelm@13456
   283
translations
wenzelm@14690
   284
  (index) "\<^sub>1" => (index) "\<^bsub>\<struct>\<^esub>"
wenzelm@13456
   285
wenzelm@11750
   286
typed_print_translation {*
haftmann@20713
   287
let
haftmann@20713
   288
  fun tr' c = (c, fn show_sorts => fn T => fn ts =>
haftmann@29905
   289
    if (not o null) ts orelse T = dummyT orelse not (! show_types) andalso can Term.dest_Type T then raise Match
haftmann@20713
   290
    else Syntax.const Syntax.constrainC $ Syntax.const c $ Syntax.term_of_typ show_sorts T);
haftmann@22993
   291
in map tr' [@{const_syntax HOL.one}, @{const_syntax HOL.zero}] end;
wenzelm@11750
   292
*} -- {* show types that are presumably too general *}
wenzelm@11750
   293
wenzelm@11750
   294
haftmann@20944
   295
subsection {* Fundamental rules *}
haftmann@20944
   296
haftmann@20973
   297
subsubsection {* Equality *}
haftmann@20944
   298
wenzelm@18457
   299
lemma sym: "s = t ==> t = s"
wenzelm@18457
   300
  by (erule subst) (rule refl)
paulson@15411
   301
wenzelm@18457
   302
lemma ssubst: "t = s ==> P s ==> P t"
wenzelm@18457
   303
  by (drule sym) (erule subst)
paulson@15411
   304
paulson@15411
   305
lemma trans: "[| r=s; s=t |] ==> r=t"
wenzelm@18457
   306
  by (erule subst)
paulson@15411
   307
haftmann@20944
   308
lemma meta_eq_to_obj_eq: 
haftmann@20944
   309
  assumes meq: "A == B"
haftmann@20944
   310
  shows "A = B"
haftmann@20944
   311
  by (unfold meq) (rule refl)
paulson@15411
   312
wenzelm@21502
   313
text {* Useful with @{text erule} for proving equalities from known equalities. *}
haftmann@20944
   314
     (* a = b
paulson@15411
   315
        |   |
paulson@15411
   316
        c = d   *)
paulson@15411
   317
lemma box_equals: "[| a=b;  a=c;  b=d |] ==> c=d"
paulson@15411
   318
apply (rule trans)
paulson@15411
   319
apply (rule trans)
paulson@15411
   320
apply (rule sym)
paulson@15411
   321
apply assumption+
paulson@15411
   322
done
paulson@15411
   323
nipkow@15524
   324
text {* For calculational reasoning: *}
nipkow@15524
   325
nipkow@15524
   326
lemma forw_subst: "a = b ==> P b ==> P a"
nipkow@15524
   327
  by (rule ssubst)
nipkow@15524
   328
nipkow@15524
   329
lemma back_subst: "P a ==> a = b ==> P b"
nipkow@15524
   330
  by (rule subst)
nipkow@15524
   331
paulson@15411
   332
haftmann@20944
   333
subsubsection {*Congruence rules for application*}
paulson@15411
   334
paulson@15411
   335
(*similar to AP_THM in Gordon's HOL*)
paulson@15411
   336
lemma fun_cong: "(f::'a=>'b) = g ==> f(x)=g(x)"
paulson@15411
   337
apply (erule subst)
paulson@15411
   338
apply (rule refl)
paulson@15411
   339
done
paulson@15411
   340
paulson@15411
   341
(*similar to AP_TERM in Gordon's HOL and FOL's subst_context*)
paulson@15411
   342
lemma arg_cong: "x=y ==> f(x)=f(y)"
paulson@15411
   343
apply (erule subst)
paulson@15411
   344
apply (rule refl)
paulson@15411
   345
done
paulson@15411
   346
paulson@15655
   347
lemma arg_cong2: "\<lbrakk> a = b; c = d \<rbrakk> \<Longrightarrow> f a c = f b d"
paulson@15655
   348
apply (erule ssubst)+
paulson@15655
   349
apply (rule refl)
paulson@15655
   350
done
paulson@15655
   351
paulson@15411
   352
lemma cong: "[| f = g; (x::'a) = y |] ==> f(x) = g(y)"
paulson@15411
   353
apply (erule subst)+
paulson@15411
   354
apply (rule refl)
paulson@15411
   355
done
paulson@15411
   356
paulson@15411
   357
haftmann@20944
   358
subsubsection {*Equality of booleans -- iff*}
paulson@15411
   359
wenzelm@21504
   360
lemma iffI: assumes "P ==> Q" and "Q ==> P" shows "P=Q"
wenzelm@21504
   361
  by (iprover intro: iff [THEN mp, THEN mp] impI assms)
paulson@15411
   362
paulson@15411
   363
lemma iffD2: "[| P=Q; Q |] ==> P"
wenzelm@18457
   364
  by (erule ssubst)
paulson@15411
   365
paulson@15411
   366
lemma rev_iffD2: "[| Q; P=Q |] ==> P"
wenzelm@18457
   367
  by (erule iffD2)
paulson@15411
   368
wenzelm@21504
   369
lemma iffD1: "Q = P \<Longrightarrow> Q \<Longrightarrow> P"
wenzelm@21504
   370
  by (drule sym) (rule iffD2)
wenzelm@21504
   371
wenzelm@21504
   372
lemma rev_iffD1: "Q \<Longrightarrow> Q = P \<Longrightarrow> P"
wenzelm@21504
   373
  by (drule sym) (rule rev_iffD2)
paulson@15411
   374
paulson@15411
   375
lemma iffE:
paulson@15411
   376
  assumes major: "P=Q"
wenzelm@21504
   377
    and minor: "[| P --> Q; Q --> P |] ==> R"
wenzelm@18457
   378
  shows R
wenzelm@18457
   379
  by (iprover intro: minor impI major [THEN iffD2] major [THEN iffD1])
paulson@15411
   380
paulson@15411
   381
haftmann@20944
   382
subsubsection {*True*}
paulson@15411
   383
paulson@15411
   384
lemma TrueI: "True"
wenzelm@21504
   385
  unfolding True_def by (rule refl)
paulson@15411
   386
wenzelm@21504
   387
lemma eqTrueI: "P ==> P = True"
wenzelm@18457
   388
  by (iprover intro: iffI TrueI)
paulson@15411
   389
wenzelm@21504
   390
lemma eqTrueE: "P = True ==> P"
wenzelm@21504
   391
  by (erule iffD2) (rule TrueI)
paulson@15411
   392
paulson@15411
   393
haftmann@20944
   394
subsubsection {*Universal quantifier*}
paulson@15411
   395
wenzelm@21504
   396
lemma allI: assumes "!!x::'a. P(x)" shows "ALL x. P(x)"
wenzelm@21504
   397
  unfolding All_def by (iprover intro: ext eqTrueI assms)
paulson@15411
   398
paulson@15411
   399
lemma spec: "ALL x::'a. P(x) ==> P(x)"
paulson@15411
   400
apply (unfold All_def)
paulson@15411
   401
apply (rule eqTrueE)
paulson@15411
   402
apply (erule fun_cong)
paulson@15411
   403
done
paulson@15411
   404
paulson@15411
   405
lemma allE:
paulson@15411
   406
  assumes major: "ALL x. P(x)"
wenzelm@21504
   407
    and minor: "P(x) ==> R"
wenzelm@21504
   408
  shows R
wenzelm@21504
   409
  by (iprover intro: minor major [THEN spec])
paulson@15411
   410
paulson@15411
   411
lemma all_dupE:
paulson@15411
   412
  assumes major: "ALL x. P(x)"
wenzelm@21504
   413
    and minor: "[| P(x); ALL x. P(x) |] ==> R"
wenzelm@21504
   414
  shows R
wenzelm@21504
   415
  by (iprover intro: minor major major [THEN spec])
paulson@15411
   416
paulson@15411
   417
wenzelm@21504
   418
subsubsection {* False *}
wenzelm@21504
   419
wenzelm@21504
   420
text {*
wenzelm@21504
   421
  Depends upon @{text spec}; it is impossible to do propositional
wenzelm@21504
   422
  logic before quantifiers!
wenzelm@21504
   423
*}
paulson@15411
   424
paulson@15411
   425
lemma FalseE: "False ==> P"
wenzelm@21504
   426
  apply (unfold False_def)
wenzelm@21504
   427
  apply (erule spec)
wenzelm@21504
   428
  done
paulson@15411
   429
wenzelm@21504
   430
lemma False_neq_True: "False = True ==> P"
wenzelm@21504
   431
  by (erule eqTrueE [THEN FalseE])
paulson@15411
   432
paulson@15411
   433
wenzelm@21504
   434
subsubsection {* Negation *}
paulson@15411
   435
paulson@15411
   436
lemma notI:
wenzelm@21504
   437
  assumes "P ==> False"
paulson@15411
   438
  shows "~P"
wenzelm@21504
   439
  apply (unfold not_def)
wenzelm@21504
   440
  apply (iprover intro: impI assms)
wenzelm@21504
   441
  done
paulson@15411
   442
paulson@15411
   443
lemma False_not_True: "False ~= True"
wenzelm@21504
   444
  apply (rule notI)
wenzelm@21504
   445
  apply (erule False_neq_True)
wenzelm@21504
   446
  done
paulson@15411
   447
paulson@15411
   448
lemma True_not_False: "True ~= False"
wenzelm@21504
   449
  apply (rule notI)
wenzelm@21504
   450
  apply (drule sym)
wenzelm@21504
   451
  apply (erule False_neq_True)
wenzelm@21504
   452
  done
paulson@15411
   453
paulson@15411
   454
lemma notE: "[| ~P;  P |] ==> R"
wenzelm@21504
   455
  apply (unfold not_def)
wenzelm@21504
   456
  apply (erule mp [THEN FalseE])
wenzelm@21504
   457
  apply assumption
wenzelm@21504
   458
  done
paulson@15411
   459
wenzelm@21504
   460
lemma notI2: "(P \<Longrightarrow> \<not> Pa) \<Longrightarrow> (P \<Longrightarrow> Pa) \<Longrightarrow> \<not> P"
wenzelm@21504
   461
  by (erule notE [THEN notI]) (erule meta_mp)
paulson@15411
   462
paulson@15411
   463
haftmann@20944
   464
subsubsection {*Implication*}
paulson@15411
   465
paulson@15411
   466
lemma impE:
paulson@15411
   467
  assumes "P-->Q" "P" "Q ==> R"
paulson@15411
   468
  shows "R"
wenzelm@23553
   469
by (iprover intro: assms mp)
paulson@15411
   470
paulson@15411
   471
(* Reduces Q to P-->Q, allowing substitution in P. *)
paulson@15411
   472
lemma rev_mp: "[| P;  P --> Q |] ==> Q"
nipkow@17589
   473
by (iprover intro: mp)
paulson@15411
   474
paulson@15411
   475
lemma contrapos_nn:
paulson@15411
   476
  assumes major: "~Q"
paulson@15411
   477
      and minor: "P==>Q"
paulson@15411
   478
  shows "~P"
nipkow@17589
   479
by (iprover intro: notI minor major [THEN notE])
paulson@15411
   480
paulson@15411
   481
(*not used at all, but we already have the other 3 combinations *)
paulson@15411
   482
lemma contrapos_pn:
paulson@15411
   483
  assumes major: "Q"
paulson@15411
   484
      and minor: "P ==> ~Q"
paulson@15411
   485
  shows "~P"
nipkow@17589
   486
by (iprover intro: notI minor major notE)
paulson@15411
   487
paulson@15411
   488
lemma not_sym: "t ~= s ==> s ~= t"
haftmann@21250
   489
  by (erule contrapos_nn) (erule sym)
haftmann@21250
   490
haftmann@21250
   491
lemma eq_neq_eq_imp_neq: "[| x = a ; a ~= b; b = y |] ==> x ~= y"
haftmann@21250
   492
  by (erule subst, erule ssubst, assumption)
paulson@15411
   493
paulson@15411
   494
(*still used in HOLCF*)
paulson@15411
   495
lemma rev_contrapos:
paulson@15411
   496
  assumes pq: "P ==> Q"
paulson@15411
   497
      and nq: "~Q"
paulson@15411
   498
  shows "~P"
paulson@15411
   499
apply (rule nq [THEN contrapos_nn])
paulson@15411
   500
apply (erule pq)
paulson@15411
   501
done
paulson@15411
   502
haftmann@20944
   503
subsubsection {*Existential quantifier*}
paulson@15411
   504
paulson@15411
   505
lemma exI: "P x ==> EX x::'a. P x"
paulson@15411
   506
apply (unfold Ex_def)
nipkow@17589
   507
apply (iprover intro: allI allE impI mp)
paulson@15411
   508
done
paulson@15411
   509
paulson@15411
   510
lemma exE:
paulson@15411
   511
  assumes major: "EX x::'a. P(x)"
paulson@15411
   512
      and minor: "!!x. P(x) ==> Q"
paulson@15411
   513
  shows "Q"
paulson@15411
   514
apply (rule major [unfolded Ex_def, THEN spec, THEN mp])
nipkow@17589
   515
apply (iprover intro: impI [THEN allI] minor)
paulson@15411
   516
done
paulson@15411
   517
paulson@15411
   518
haftmann@20944
   519
subsubsection {*Conjunction*}
paulson@15411
   520
paulson@15411
   521
lemma conjI: "[| P; Q |] ==> P&Q"
paulson@15411
   522
apply (unfold and_def)
nipkow@17589
   523
apply (iprover intro: impI [THEN allI] mp)
paulson@15411
   524
done
paulson@15411
   525
paulson@15411
   526
lemma conjunct1: "[| P & Q |] ==> P"
paulson@15411
   527
apply (unfold and_def)
nipkow@17589
   528
apply (iprover intro: impI dest: spec mp)
paulson@15411
   529
done
paulson@15411
   530
paulson@15411
   531
lemma conjunct2: "[| P & Q |] ==> Q"
paulson@15411
   532
apply (unfold and_def)
nipkow@17589
   533
apply (iprover intro: impI dest: spec mp)
paulson@15411
   534
done
paulson@15411
   535
paulson@15411
   536
lemma conjE:
paulson@15411
   537
  assumes major: "P&Q"
paulson@15411
   538
      and minor: "[| P; Q |] ==> R"
paulson@15411
   539
  shows "R"
paulson@15411
   540
apply (rule minor)
paulson@15411
   541
apply (rule major [THEN conjunct1])
paulson@15411
   542
apply (rule major [THEN conjunct2])
paulson@15411
   543
done
paulson@15411
   544
paulson@15411
   545
lemma context_conjI:
wenzelm@23553
   546
  assumes "P" "P ==> Q" shows "P & Q"
wenzelm@23553
   547
by (iprover intro: conjI assms)
paulson@15411
   548
paulson@15411
   549
haftmann@20944
   550
subsubsection {*Disjunction*}
paulson@15411
   551
paulson@15411
   552
lemma disjI1: "P ==> P|Q"
paulson@15411
   553
apply (unfold or_def)
nipkow@17589
   554
apply (iprover intro: allI impI mp)
paulson@15411
   555
done
paulson@15411
   556
paulson@15411
   557
lemma disjI2: "Q ==> P|Q"
paulson@15411
   558
apply (unfold or_def)
nipkow@17589
   559
apply (iprover intro: allI impI mp)
paulson@15411
   560
done
paulson@15411
   561
paulson@15411
   562
lemma disjE:
paulson@15411
   563
  assumes major: "P|Q"
paulson@15411
   564
      and minorP: "P ==> R"
paulson@15411
   565
      and minorQ: "Q ==> R"
paulson@15411
   566
  shows "R"
nipkow@17589
   567
by (iprover intro: minorP minorQ impI
paulson@15411
   568
                 major [unfolded or_def, THEN spec, THEN mp, THEN mp])
paulson@15411
   569
paulson@15411
   570
haftmann@20944
   571
subsubsection {*Classical logic*}
paulson@15411
   572
paulson@15411
   573
lemma classical:
paulson@15411
   574
  assumes prem: "~P ==> P"
paulson@15411
   575
  shows "P"
paulson@15411
   576
apply (rule True_or_False [THEN disjE, THEN eqTrueE])
paulson@15411
   577
apply assumption
paulson@15411
   578
apply (rule notI [THEN prem, THEN eqTrueI])
paulson@15411
   579
apply (erule subst)
paulson@15411
   580
apply assumption
paulson@15411
   581
done
paulson@15411
   582
paulson@15411
   583
lemmas ccontr = FalseE [THEN classical, standard]
paulson@15411
   584
paulson@15411
   585
(*notE with premises exchanged; it discharges ~R so that it can be used to
paulson@15411
   586
  make elimination rules*)
paulson@15411
   587
lemma rev_notE:
paulson@15411
   588
  assumes premp: "P"
paulson@15411
   589
      and premnot: "~R ==> ~P"
paulson@15411
   590
  shows "R"
paulson@15411
   591
apply (rule ccontr)
paulson@15411
   592
apply (erule notE [OF premnot premp])
paulson@15411
   593
done
paulson@15411
   594
paulson@15411
   595
(*Double negation law*)
paulson@15411
   596
lemma notnotD: "~~P ==> P"
paulson@15411
   597
apply (rule classical)
paulson@15411
   598
apply (erule notE)
paulson@15411
   599
apply assumption
paulson@15411
   600
done
paulson@15411
   601
paulson@15411
   602
lemma contrapos_pp:
paulson@15411
   603
  assumes p1: "Q"
paulson@15411
   604
      and p2: "~P ==> ~Q"
paulson@15411
   605
  shows "P"
nipkow@17589
   606
by (iprover intro: classical p1 p2 notE)
paulson@15411
   607
paulson@15411
   608
haftmann@20944
   609
subsubsection {*Unique existence*}
paulson@15411
   610
paulson@15411
   611
lemma ex1I:
wenzelm@23553
   612
  assumes "P a" "!!x. P(x) ==> x=a"
paulson@15411
   613
  shows "EX! x. P(x)"
wenzelm@23553
   614
by (unfold Ex1_def, iprover intro: assms exI conjI allI impI)
paulson@15411
   615
paulson@15411
   616
text{*Sometimes easier to use: the premises have no shared variables.  Safe!*}
paulson@15411
   617
lemma ex_ex1I:
paulson@15411
   618
  assumes ex_prem: "EX x. P(x)"
paulson@15411
   619
      and eq: "!!x y. [| P(x); P(y) |] ==> x=y"
paulson@15411
   620
  shows "EX! x. P(x)"
nipkow@17589
   621
by (iprover intro: ex_prem [THEN exE] ex1I eq)
paulson@15411
   622
paulson@15411
   623
lemma ex1E:
paulson@15411
   624
  assumes major: "EX! x. P(x)"
paulson@15411
   625
      and minor: "!!x. [| P(x);  ALL y. P(y) --> y=x |] ==> R"
paulson@15411
   626
  shows "R"
paulson@15411
   627
apply (rule major [unfolded Ex1_def, THEN exE])
paulson@15411
   628
apply (erule conjE)
nipkow@17589
   629
apply (iprover intro: minor)
paulson@15411
   630
done
paulson@15411
   631
paulson@15411
   632
lemma ex1_implies_ex: "EX! x. P x ==> EX x. P x"
paulson@15411
   633
apply (erule ex1E)
paulson@15411
   634
apply (rule exI)
paulson@15411
   635
apply assumption
paulson@15411
   636
done
paulson@15411
   637
paulson@15411
   638
haftmann@20944
   639
subsubsection {*THE: definite description operator*}
paulson@15411
   640
paulson@15411
   641
lemma the_equality:
paulson@15411
   642
  assumes prema: "P a"
paulson@15411
   643
      and premx: "!!x. P x ==> x=a"
paulson@15411
   644
  shows "(THE x. P x) = a"
paulson@15411
   645
apply (rule trans [OF _ the_eq_trivial])
paulson@15411
   646
apply (rule_tac f = "The" in arg_cong)
paulson@15411
   647
apply (rule ext)
paulson@15411
   648
apply (rule iffI)
paulson@15411
   649
 apply (erule premx)
paulson@15411
   650
apply (erule ssubst, rule prema)
paulson@15411
   651
done
paulson@15411
   652
paulson@15411
   653
lemma theI:
paulson@15411
   654
  assumes "P a" and "!!x. P x ==> x=a"
paulson@15411
   655
  shows "P (THE x. P x)"
wenzelm@23553
   656
by (iprover intro: assms the_equality [THEN ssubst])
paulson@15411
   657
paulson@15411
   658
lemma theI': "EX! x. P x ==> P (THE x. P x)"
paulson@15411
   659
apply (erule ex1E)
paulson@15411
   660
apply (erule theI)
paulson@15411
   661
apply (erule allE)
paulson@15411
   662
apply (erule mp)
paulson@15411
   663
apply assumption
paulson@15411
   664
done
paulson@15411
   665
paulson@15411
   666
(*Easier to apply than theI: only one occurrence of P*)
paulson@15411
   667
lemma theI2:
paulson@15411
   668
  assumes "P a" "!!x. P x ==> x=a" "!!x. P x ==> Q x"
paulson@15411
   669
  shows "Q (THE x. P x)"
wenzelm@23553
   670
by (iprover intro: assms theI)
paulson@15411
   671
nipkow@24553
   672
lemma the1I2: assumes "EX! x. P x" "\<And>x. P x \<Longrightarrow> Q x" shows "Q (THE x. P x)"
nipkow@24553
   673
by(iprover intro:assms(2) theI2[where P=P and Q=Q] ex1E[OF assms(1)]
nipkow@24553
   674
           elim:allE impE)
nipkow@24553
   675
wenzelm@18697
   676
lemma the1_equality [elim?]: "[| EX!x. P x; P a |] ==> (THE x. P x) = a"
paulson@15411
   677
apply (rule the_equality)
paulson@15411
   678
apply  assumption
paulson@15411
   679
apply (erule ex1E)
paulson@15411
   680
apply (erule all_dupE)
paulson@15411
   681
apply (drule mp)
paulson@15411
   682
apply  assumption
paulson@15411
   683
apply (erule ssubst)
paulson@15411
   684
apply (erule allE)
paulson@15411
   685
apply (erule mp)
paulson@15411
   686
apply assumption
paulson@15411
   687
done
paulson@15411
   688
paulson@15411
   689
lemma the_sym_eq_trivial: "(THE y. x=y) = x"
paulson@15411
   690
apply (rule the_equality)
paulson@15411
   691
apply (rule refl)
paulson@15411
   692
apply (erule sym)
paulson@15411
   693
done
paulson@15411
   694
paulson@15411
   695
haftmann@20944
   696
subsubsection {*Classical intro rules for disjunction and existential quantifiers*}
paulson@15411
   697
paulson@15411
   698
lemma disjCI:
paulson@15411
   699
  assumes "~Q ==> P" shows "P|Q"
paulson@15411
   700
apply (rule classical)
wenzelm@23553
   701
apply (iprover intro: assms disjI1 disjI2 notI elim: notE)
paulson@15411
   702
done
paulson@15411
   703
paulson@15411
   704
lemma excluded_middle: "~P | P"
nipkow@17589
   705
by (iprover intro: disjCI)
paulson@15411
   706
haftmann@20944
   707
text {*
haftmann@20944
   708
  case distinction as a natural deduction rule.
haftmann@20944
   709
  Note that @{term "~P"} is the second case, not the first
haftmann@20944
   710
*}
wenzelm@27126
   711
lemma case_split [case_names True False]:
paulson@15411
   712
  assumes prem1: "P ==> Q"
paulson@15411
   713
      and prem2: "~P ==> Q"
paulson@15411
   714
  shows "Q"
paulson@15411
   715
apply (rule excluded_middle [THEN disjE])
paulson@15411
   716
apply (erule prem2)
paulson@15411
   717
apply (erule prem1)
paulson@15411
   718
done
wenzelm@27126
   719
paulson@15411
   720
(*Classical implies (-->) elimination. *)
paulson@15411
   721
lemma impCE:
paulson@15411
   722
  assumes major: "P-->Q"
paulson@15411
   723
      and minor: "~P ==> R" "Q ==> R"
paulson@15411
   724
  shows "R"
paulson@15411
   725
apply (rule excluded_middle [of P, THEN disjE])
nipkow@17589
   726
apply (iprover intro: minor major [THEN mp])+
paulson@15411
   727
done
paulson@15411
   728
paulson@15411
   729
(*This version of --> elimination works on Q before P.  It works best for
paulson@15411
   730
  those cases in which P holds "almost everywhere".  Can't install as
paulson@15411
   731
  default: would break old proofs.*)
paulson@15411
   732
lemma impCE':
paulson@15411
   733
  assumes major: "P-->Q"
paulson@15411
   734
      and minor: "Q ==> R" "~P ==> R"
paulson@15411
   735
  shows "R"
paulson@15411
   736
apply (rule excluded_middle [of P, THEN disjE])
nipkow@17589
   737
apply (iprover intro: minor major [THEN mp])+
paulson@15411
   738
done
paulson@15411
   739
paulson@15411
   740
(*Classical <-> elimination. *)
paulson@15411
   741
lemma iffCE:
paulson@15411
   742
  assumes major: "P=Q"
paulson@15411
   743
      and minor: "[| P; Q |] ==> R"  "[| ~P; ~Q |] ==> R"
paulson@15411
   744
  shows "R"
paulson@15411
   745
apply (rule major [THEN iffE])
nipkow@17589
   746
apply (iprover intro: minor elim: impCE notE)
paulson@15411
   747
done
paulson@15411
   748
paulson@15411
   749
lemma exCI:
paulson@15411
   750
  assumes "ALL x. ~P(x) ==> P(a)"
paulson@15411
   751
  shows "EX x. P(x)"
paulson@15411
   752
apply (rule ccontr)
wenzelm@23553
   753
apply (iprover intro: assms exI allI notI notE [of "\<exists>x. P x"])
paulson@15411
   754
done
paulson@15411
   755
paulson@15411
   756
wenzelm@12386
   757
subsubsection {* Intuitionistic Reasoning *}
wenzelm@12386
   758
wenzelm@12386
   759
lemma impE':
wenzelm@12937
   760
  assumes 1: "P --> Q"
wenzelm@12937
   761
    and 2: "Q ==> R"
wenzelm@12937
   762
    and 3: "P --> Q ==> P"
wenzelm@12937
   763
  shows R
wenzelm@12386
   764
proof -
wenzelm@12386
   765
  from 3 and 1 have P .
wenzelm@12386
   766
  with 1 have Q by (rule impE)
wenzelm@12386
   767
  with 2 show R .
wenzelm@12386
   768
qed
wenzelm@12386
   769
wenzelm@12386
   770
lemma allE':
wenzelm@12937
   771
  assumes 1: "ALL x. P x"
wenzelm@12937
   772
    and 2: "P x ==> ALL x. P x ==> Q"
wenzelm@12937
   773
  shows Q
wenzelm@12386
   774
proof -
wenzelm@12386
   775
  from 1 have "P x" by (rule spec)
wenzelm@12386
   776
  from this and 1 show Q by (rule 2)
wenzelm@12386
   777
qed
wenzelm@12386
   778
wenzelm@12937
   779
lemma notE':
wenzelm@12937
   780
  assumes 1: "~ P"
wenzelm@12937
   781
    and 2: "~ P ==> P"
wenzelm@12937
   782
  shows R
wenzelm@12386
   783
proof -
wenzelm@12386
   784
  from 2 and 1 have P .
wenzelm@12386
   785
  with 1 show R by (rule notE)
wenzelm@12386
   786
qed
wenzelm@12386
   787
dixon@22444
   788
lemma TrueE: "True ==> P ==> P" .
dixon@22444
   789
lemma notFalseE: "~ False ==> P ==> P" .
dixon@22444
   790
dixon@22467
   791
lemmas [Pure.elim!] = disjE iffE FalseE conjE exE TrueE notFalseE
wenzelm@15801
   792
  and [Pure.intro!] = iffI conjI impI TrueI notI allI refl
wenzelm@15801
   793
  and [Pure.elim 2] = allE notE' impE'
wenzelm@15801
   794
  and [Pure.intro] = exI disjI2 disjI1
wenzelm@12386
   795
wenzelm@12386
   796
lemmas [trans] = trans
wenzelm@12386
   797
  and [sym] = sym not_sym
wenzelm@15801
   798
  and [Pure.elim?] = iffD1 iffD2 impE
wenzelm@11438
   799
haftmann@28952
   800
use "Tools/hologic.ML"
wenzelm@23553
   801
wenzelm@11750
   802
wenzelm@11750
   803
subsubsection {* Atomizing meta-level connectives *}
wenzelm@11750
   804
haftmann@28513
   805
axiomatization where
haftmann@28513
   806
  eq_reflection: "x = y \<Longrightarrow> x \<equiv> y" (*admissible axiom*)
haftmann@28513
   807
wenzelm@11750
   808
lemma atomize_all [atomize]: "(!!x. P x) == Trueprop (ALL x. P x)"
wenzelm@12003
   809
proof
wenzelm@9488
   810
  assume "!!x. P x"
wenzelm@23389
   811
  then show "ALL x. P x" ..
wenzelm@9488
   812
next
wenzelm@9488
   813
  assume "ALL x. P x"
wenzelm@23553
   814
  then show "!!x. P x" by (rule allE)
wenzelm@9488
   815
qed
wenzelm@9488
   816
wenzelm@11750
   817
lemma atomize_imp [atomize]: "(A ==> B) == Trueprop (A --> B)"
wenzelm@12003
   818
proof
wenzelm@9488
   819
  assume r: "A ==> B"
wenzelm@10383
   820
  show "A --> B" by (rule impI) (rule r)
wenzelm@9488
   821
next
wenzelm@9488
   822
  assume "A --> B" and A
wenzelm@23553
   823
  then show B by (rule mp)
wenzelm@9488
   824
qed
wenzelm@9488
   825
paulson@14749
   826
lemma atomize_not: "(A ==> False) == Trueprop (~A)"
paulson@14749
   827
proof
paulson@14749
   828
  assume r: "A ==> False"
paulson@14749
   829
  show "~A" by (rule notI) (rule r)
paulson@14749
   830
next
paulson@14749
   831
  assume "~A" and A
wenzelm@23553
   832
  then show False by (rule notE)
paulson@14749
   833
qed
paulson@14749
   834
wenzelm@11750
   835
lemma atomize_eq [atomize]: "(x == y) == Trueprop (x = y)"
wenzelm@12003
   836
proof
wenzelm@10432
   837
  assume "x == y"
wenzelm@23553
   838
  show "x = y" by (unfold `x == y`) (rule refl)
wenzelm@10432
   839
next
wenzelm@10432
   840
  assume "x = y"
wenzelm@23553
   841
  then show "x == y" by (rule eq_reflection)
wenzelm@10432
   842
qed
wenzelm@10432
   843
wenzelm@28856
   844
lemma atomize_conj [atomize]: "(A &&& B) == Trueprop (A & B)"
wenzelm@12003
   845
proof
wenzelm@28856
   846
  assume conj: "A &&& B"
wenzelm@19121
   847
  show "A & B"
wenzelm@19121
   848
  proof (rule conjI)
wenzelm@19121
   849
    from conj show A by (rule conjunctionD1)
wenzelm@19121
   850
    from conj show B by (rule conjunctionD2)
wenzelm@19121
   851
  qed
wenzelm@11953
   852
next
wenzelm@19121
   853
  assume conj: "A & B"
wenzelm@28856
   854
  show "A &&& B"
wenzelm@19121
   855
  proof -
wenzelm@19121
   856
    from conj show A ..
wenzelm@19121
   857
    from conj show B ..
wenzelm@11953
   858
  qed
wenzelm@11953
   859
qed
wenzelm@11953
   860
wenzelm@12386
   861
lemmas [symmetric, rulify] = atomize_all atomize_imp
wenzelm@18832
   862
  and [symmetric, defn] = atomize_all atomize_imp atomize_eq
wenzelm@12386
   863
wenzelm@11750
   864
krauss@26580
   865
subsubsection {* Atomizing elimination rules *}
krauss@26580
   866
krauss@26580
   867
setup AtomizeElim.setup
krauss@26580
   868
krauss@26580
   869
lemma atomize_exL[atomize_elim]: "(!!x. P x ==> Q) == ((EX x. P x) ==> Q)"
krauss@26580
   870
  by rule iprover+
krauss@26580
   871
krauss@26580
   872
lemma atomize_conjL[atomize_elim]: "(A ==> B ==> C) == (A & B ==> C)"
krauss@26580
   873
  by rule iprover+
krauss@26580
   874
krauss@26580
   875
lemma atomize_disjL[atomize_elim]: "((A ==> C) ==> (B ==> C) ==> C) == ((A | B ==> C) ==> C)"
krauss@26580
   876
  by rule iprover+
krauss@26580
   877
krauss@26580
   878
lemma atomize_elimL[atomize_elim]: "(!!B. (A ==> B) ==> B) == Trueprop A" ..
krauss@26580
   879
krauss@26580
   880
haftmann@20944
   881
subsection {* Package setup *}
haftmann@20944
   882
wenzelm@11750
   883
subsubsection {* Classical Reasoner setup *}
wenzelm@9529
   884
wenzelm@26411
   885
lemma imp_elim: "P --> Q ==> (~ R ==> P) ==> (Q ==> R) ==> R"
wenzelm@26411
   886
  by (rule classical) iprover
wenzelm@26411
   887
wenzelm@26411
   888
lemma swap: "~ P ==> (~ R ==> P) ==> R"
wenzelm@26411
   889
  by (rule classical) iprover
wenzelm@26411
   890
haftmann@20944
   891
lemma thin_refl:
haftmann@20944
   892
  "\<And>X. \<lbrakk> x=x; PROP W \<rbrakk> \<Longrightarrow> PROP W" .
haftmann@20944
   893
haftmann@21151
   894
ML {*
haftmann@21151
   895
structure Hypsubst = HypsubstFun(
haftmann@21151
   896
struct
haftmann@21151
   897
  structure Simplifier = Simplifier
wenzelm@21218
   898
  val dest_eq = HOLogic.dest_eq
haftmann@21151
   899
  val dest_Trueprop = HOLogic.dest_Trueprop
haftmann@21151
   900
  val dest_imp = HOLogic.dest_imp
wenzelm@26411
   901
  val eq_reflection = @{thm eq_reflection}
wenzelm@26411
   902
  val rev_eq_reflection = @{thm meta_eq_to_obj_eq}
wenzelm@26411
   903
  val imp_intr = @{thm impI}
wenzelm@26411
   904
  val rev_mp = @{thm rev_mp}
wenzelm@26411
   905
  val subst = @{thm subst}
wenzelm@26411
   906
  val sym = @{thm sym}
wenzelm@22129
   907
  val thin_refl = @{thm thin_refl};
krauss@27572
   908
  val prop_subst = @{lemma "PROP P t ==> PROP prop (x = t ==> PROP P x)"
krauss@27572
   909
                     by (unfold prop_def) (drule eq_reflection, unfold)}
haftmann@21151
   910
end);
wenzelm@21671
   911
open Hypsubst;
haftmann@21151
   912
haftmann@21151
   913
structure Classical = ClassicalFun(
haftmann@21151
   914
struct
wenzelm@26411
   915
  val imp_elim = @{thm imp_elim}
wenzelm@26411
   916
  val not_elim = @{thm notE}
wenzelm@26411
   917
  val swap = @{thm swap}
wenzelm@26411
   918
  val classical = @{thm classical}
haftmann@21151
   919
  val sizef = Drule.size_of_thm
haftmann@21151
   920
  val hyp_subst_tacs = [Hypsubst.hyp_subst_tac]
haftmann@21151
   921
end);
haftmann@21151
   922
haftmann@21151
   923
structure BasicClassical: BASIC_CLASSICAL = Classical; 
wenzelm@21671
   924
open BasicClassical;
wenzelm@22129
   925
wenzelm@27338
   926
ML_Antiquote.value "claset"
wenzelm@27338
   927
  (Scan.succeed "Classical.local_claset_of (ML_Context.the_local_context ())");
wenzelm@24035
   928
wenzelm@24035
   929
structure ResAtpset = NamedThmsFun(val name = "atp" val description = "ATP rules");
paulson@24286
   930
blanchet@29806
   931
structure ResBlacklist = NamedThmsFun(val name = "noatp" val description = "theorems blacklisted for ATP");
haftmann@21151
   932
*}
haftmann@21151
   933
wenzelm@25388
   934
text {*ResBlacklist holds theorems blacklisted to sledgehammer. 
paulson@24286
   935
  These theorems typically produce clauses that are prolific (match too many equality or
wenzelm@25388
   936
  membership literals) and relate to seldom-used facts. Some duplicate other rules.*}
paulson@24286
   937
haftmann@21009
   938
setup {*
haftmann@21009
   939
let
haftmann@21009
   940
  (*prevent substitution on bool*)
haftmann@21009
   941
  fun hyp_subst_tac' i thm = if i <= Thm.nprems_of thm andalso
haftmann@21009
   942
    Term.exists_Const (fn ("op =", Type (_, [T, _])) => T <> Type ("bool", []) | _ => false)
haftmann@21009
   943
      (nth (Thm.prems_of thm) (i - 1)) then Hypsubst.hyp_subst_tac i thm else no_tac thm;
haftmann@21009
   944
in
haftmann@21151
   945
  Hypsubst.hypsubst_setup
haftmann@21151
   946
  #> ContextRules.addSWrapper (fn tac => hyp_subst_tac' ORELSE' tac)
haftmann@21151
   947
  #> Classical.setup
haftmann@21151
   948
  #> ResAtpset.setup
paulson@24286
   949
  #> ResBlacklist.setup
haftmann@21009
   950
end
haftmann@21009
   951
*}
haftmann@21009
   952
haftmann@21009
   953
declare iffI [intro!]
haftmann@21009
   954
  and notI [intro!]
haftmann@21009
   955
  and impI [intro!]
haftmann@21009
   956
  and disjCI [intro!]
haftmann@21009
   957
  and conjI [intro!]
haftmann@21009
   958
  and TrueI [intro!]
haftmann@21009
   959
  and refl [intro!]
haftmann@21009
   960
haftmann@21009
   961
declare iffCE [elim!]
haftmann@21009
   962
  and FalseE [elim!]
haftmann@21009
   963
  and impCE [elim!]
haftmann@21009
   964
  and disjE [elim!]
haftmann@21009
   965
  and conjE [elim!]
haftmann@21009
   966
  and conjE [elim!]
haftmann@21009
   967
haftmann@21009
   968
declare ex_ex1I [intro!]
haftmann@21009
   969
  and allI [intro!]
haftmann@21009
   970
  and the_equality [intro]
haftmann@21009
   971
  and exI [intro]
haftmann@21009
   972
haftmann@21009
   973
declare exE [elim!]
haftmann@21009
   974
  allE [elim]
haftmann@21009
   975
wenzelm@22377
   976
ML {* val HOL_cs = @{claset} *}
wenzelm@11977
   977
wenzelm@20223
   978
lemma contrapos_np: "~ Q ==> (~ P ==> Q) ==> P"
wenzelm@20223
   979
  apply (erule swap)
wenzelm@20223
   980
  apply (erule (1) meta_mp)
wenzelm@20223
   981
  done
wenzelm@10383
   982
wenzelm@18689
   983
declare ex_ex1I [rule del, intro! 2]
wenzelm@18689
   984
  and ex1I [intro]
wenzelm@18689
   985
wenzelm@12386
   986
lemmas [intro?] = ext
wenzelm@12386
   987
  and [elim?] = ex1_implies_ex
wenzelm@11977
   988
haftmann@20944
   989
(*Better then ex1E for classical reasoner: needs no quantifier duplication!*)
haftmann@20973
   990
lemma alt_ex1E [elim!]:
haftmann@20944
   991
  assumes major: "\<exists>!x. P x"
haftmann@20944
   992
      and prem: "\<And>x. \<lbrakk> P x; \<forall>y y'. P y \<and> P y' \<longrightarrow> y = y' \<rbrakk> \<Longrightarrow> R"
haftmann@20944
   993
  shows R
haftmann@20944
   994
apply (rule ex1E [OF major])
haftmann@20944
   995
apply (rule prem)
wenzelm@22129
   996
apply (tactic {* ares_tac @{thms allI} 1 *})+
wenzelm@22129
   997
apply (tactic {* etac (Classical.dup_elim @{thm allE}) 1 *})
wenzelm@22129
   998
apply iprover
wenzelm@22129
   999
done
haftmann@20944
  1000
haftmann@21151
  1001
ML {*
wenzelm@25388
  1002
structure Blast = BlastFun
wenzelm@25388
  1003
(
haftmann@21151
  1004
  type claset = Classical.claset
haftmann@22744
  1005
  val equality_name = @{const_name "op ="}
haftmann@22993
  1006
  val not_name = @{const_name Not}
wenzelm@26411
  1007
  val notE = @{thm notE}
wenzelm@26411
  1008
  val ccontr = @{thm ccontr}
haftmann@21151
  1009
  val contr_tac = Classical.contr_tac
haftmann@21151
  1010
  val dup_intr = Classical.dup_intr
haftmann@21151
  1011
  val hyp_subst_tac = Hypsubst.blast_hyp_subst_tac
haftmann@21151
  1012
  val rep_cs = Classical.rep_cs
haftmann@21151
  1013
  val cla_modifiers = Classical.cla_modifiers
haftmann@21151
  1014
  val cla_meth' = Classical.cla_meth'
wenzelm@25388
  1015
);
wenzelm@21671
  1016
val blast_tac = Blast.blast_tac;
haftmann@20944
  1017
*}
haftmann@20944
  1018
haftmann@21151
  1019
setup Blast.setup
haftmann@21151
  1020
haftmann@20944
  1021
haftmann@20944
  1022
subsubsection {* Simplifier *}
wenzelm@12281
  1023
wenzelm@12281
  1024
lemma eta_contract_eq: "(%s. f s) = f" ..
wenzelm@12281
  1025
wenzelm@12281
  1026
lemma simp_thms:
wenzelm@12937
  1027
  shows not_not: "(~ ~ P) = P"
nipkow@15354
  1028
  and Not_eq_iff: "((~P) = (~Q)) = (P = Q)"
wenzelm@12937
  1029
  and
berghofe@12436
  1030
    "(P ~= Q) = (P = (~Q))"
berghofe@12436
  1031
    "(P | ~P) = True"    "(~P | P) = True"
wenzelm@12281
  1032
    "(x = x) = True"
haftmann@20944
  1033
  and not_True_eq_False: "(\<not> True) = False"
haftmann@20944
  1034
  and not_False_eq_True: "(\<not> False) = True"
haftmann@20944
  1035
  and
berghofe@12436
  1036
    "(~P) ~= P"  "P ~= (~P)"
haftmann@20944
  1037
    "(True=P) = P"
haftmann@20944
  1038
  and eq_True: "(P = True) = P"
haftmann@20944
  1039
  and "(False=P) = (~P)"
haftmann@20944
  1040
  and eq_False: "(P = False) = (\<not> P)"
haftmann@20944
  1041
  and
wenzelm@12281
  1042
    "(True --> P) = P"  "(False --> P) = True"
wenzelm@12281
  1043
    "(P --> True) = True"  "(P --> P) = True"
wenzelm@12281
  1044
    "(P --> False) = (~P)"  "(P --> ~P) = (~P)"
wenzelm@12281
  1045
    "(P & True) = P"  "(True & P) = P"
wenzelm@12281
  1046
    "(P & False) = False"  "(False & P) = False"
wenzelm@12281
  1047
    "(P & P) = P"  "(P & (P & Q)) = (P & Q)"
wenzelm@12281
  1048
    "(P & ~P) = False"    "(~P & P) = False"
wenzelm@12281
  1049
    "(P | True) = True"  "(True | P) = True"
wenzelm@12281
  1050
    "(P | False) = P"  "(False | P) = P"
berghofe@12436
  1051
    "(P | P) = P"  "(P | (P | Q)) = (P | Q)" and
wenzelm@12281
  1052
    "(ALL x. P) = P"  "(EX x. P) = P"  "EX x. x=t"  "EX x. t=x"
wenzelm@12281
  1053
    -- {* needed for the one-point-rule quantifier simplification procs *}
wenzelm@12281
  1054
    -- {* essential for termination!! *} and
wenzelm@12281
  1055
    "!!P. (EX x. x=t & P(x)) = P(t)"
wenzelm@12281
  1056
    "!!P. (EX x. t=x & P(x)) = P(t)"
wenzelm@12281
  1057
    "!!P. (ALL x. x=t --> P(x)) = P(t)"
wenzelm@12937
  1058
    "!!P. (ALL x. t=x --> P(x)) = P(t)"
nipkow@17589
  1059
  by (blast, blast, blast, blast, blast, iprover+)
wenzelm@13421
  1060
paulson@14201
  1061
lemma disj_absorb: "(A | A) = A"
paulson@14201
  1062
  by blast
paulson@14201
  1063
paulson@14201
  1064
lemma disj_left_absorb: "(A | (A | B)) = (A | B)"
paulson@14201
  1065
  by blast
paulson@14201
  1066
paulson@14201
  1067
lemma conj_absorb: "(A & A) = A"
paulson@14201
  1068
  by blast
paulson@14201
  1069
paulson@14201
  1070
lemma conj_left_absorb: "(A & (A & B)) = (A & B)"
paulson@14201
  1071
  by blast
paulson@14201
  1072
wenzelm@12281
  1073
lemma eq_ac:
wenzelm@12937
  1074
  shows eq_commute: "(a=b) = (b=a)"
wenzelm@12937
  1075
    and eq_left_commute: "(P=(Q=R)) = (Q=(P=R))"
nipkow@17589
  1076
    and eq_assoc: "((P=Q)=R) = (P=(Q=R))" by (iprover, blast+)
nipkow@17589
  1077
lemma neq_commute: "(a~=b) = (b~=a)" by iprover
wenzelm@12281
  1078
wenzelm@12281
  1079
lemma conj_comms:
wenzelm@12937
  1080
  shows conj_commute: "(P&Q) = (Q&P)"
nipkow@17589
  1081
    and conj_left_commute: "(P&(Q&R)) = (Q&(P&R))" by iprover+
nipkow@17589
  1082
lemma conj_assoc: "((P&Q)&R) = (P&(Q&R))" by iprover
wenzelm@12281
  1083
paulson@19174
  1084
lemmas conj_ac = conj_commute conj_left_commute conj_assoc
paulson@19174
  1085
wenzelm@12281
  1086
lemma disj_comms:
wenzelm@12937
  1087
  shows disj_commute: "(P|Q) = (Q|P)"
nipkow@17589
  1088
    and disj_left_commute: "(P|(Q|R)) = (Q|(P|R))" by iprover+
nipkow@17589
  1089
lemma disj_assoc: "((P|Q)|R) = (P|(Q|R))" by iprover
wenzelm@12281
  1090
paulson@19174
  1091
lemmas disj_ac = disj_commute disj_left_commute disj_assoc
paulson@19174
  1092
nipkow@17589
  1093
lemma conj_disj_distribL: "(P&(Q|R)) = (P&Q | P&R)" by iprover
nipkow@17589
  1094
lemma conj_disj_distribR: "((P|Q)&R) = (P&R | Q&R)" by iprover
wenzelm@12281
  1095
nipkow@17589
  1096
lemma disj_conj_distribL: "(P|(Q&R)) = ((P|Q) & (P|R))" by iprover
nipkow@17589
  1097
lemma disj_conj_distribR: "((P&Q)|R) = ((P|R) & (Q|R))" by iprover
wenzelm@12281
  1098
nipkow@17589
  1099
lemma imp_conjR: "(P --> (Q&R)) = ((P-->Q) & (P-->R))" by iprover
nipkow@17589
  1100
lemma imp_conjL: "((P&Q) -->R)  = (P --> (Q --> R))" by iprover
nipkow@17589
  1101
lemma imp_disjL: "((P|Q) --> R) = ((P-->R)&(Q-->R))" by iprover
wenzelm@12281
  1102
wenzelm@12281
  1103
text {* These two are specialized, but @{text imp_disj_not1} is useful in @{text "Auth/Yahalom"}. *}
wenzelm@12281
  1104
lemma imp_disj_not1: "(P --> Q | R) = (~Q --> P --> R)" by blast
wenzelm@12281
  1105
lemma imp_disj_not2: "(P --> Q | R) = (~R --> P --> Q)" by blast
wenzelm@12281
  1106
wenzelm@12281
  1107
lemma imp_disj1: "((P-->Q)|R) = (P--> Q|R)" by blast
wenzelm@12281
  1108
lemma imp_disj2: "(Q|(P-->R)) = (P--> Q|R)" by blast
wenzelm@12281
  1109
haftmann@21151
  1110
lemma imp_cong: "(P = P') ==> (P' ==> (Q = Q')) ==> ((P --> Q) = (P' --> Q'))"
haftmann@21151
  1111
  by iprover
haftmann@21151
  1112
nipkow@17589
  1113
lemma de_Morgan_disj: "(~(P | Q)) = (~P & ~Q)" by iprover
wenzelm@12281
  1114
lemma de_Morgan_conj: "(~(P & Q)) = (~P | ~Q)" by blast
wenzelm@12281
  1115
lemma not_imp: "(~(P --> Q)) = (P & ~Q)" by blast
wenzelm@12281
  1116
lemma not_iff: "(P~=Q) = (P = (~Q))" by blast
wenzelm@12281
  1117
lemma disj_not1: "(~P | Q) = (P --> Q)" by blast
wenzelm@12281
  1118
lemma disj_not2: "(P | ~Q) = (Q --> P)"  -- {* changes orientation :-( *}
wenzelm@12281
  1119
  by blast
wenzelm@12281
  1120
lemma imp_conv_disj: "(P --> Q) = ((~P) | Q)" by blast
wenzelm@12281
  1121
nipkow@17589
  1122
lemma iff_conv_conj_imp: "(P = Q) = ((P --> Q) & (Q --> P))" by iprover
wenzelm@12281
  1123
wenzelm@12281
  1124
wenzelm@12281
  1125
lemma cases_simp: "((P --> Q) & (~P --> Q)) = Q"
wenzelm@12281
  1126
  -- {* Avoids duplication of subgoals after @{text split_if}, when the true and false *}
wenzelm@12281
  1127
  -- {* cases boil down to the same thing. *}
wenzelm@12281
  1128
  by blast
wenzelm@12281
  1129
wenzelm@12281
  1130
lemma not_all: "(~ (! x. P(x))) = (? x.~P(x))" by blast
wenzelm@12281
  1131
lemma imp_all: "((! x. P x) --> Q) = (? x. P x --> Q)" by blast
nipkow@17589
  1132
lemma not_ex: "(~ (? x. P(x))) = (! x.~P(x))" by iprover
nipkow@17589
  1133
lemma imp_ex: "((? x. P x) --> Q) = (! x. P x --> Q)" by iprover
chaieb@23403
  1134
lemma all_not_ex: "(ALL x. P x) = (~ (EX x. ~ P x ))" by blast
wenzelm@12281
  1135
paulson@24286
  1136
declare All_def [noatp]
paulson@24286
  1137
nipkow@17589
  1138
lemma ex_disj_distrib: "(? x. P(x) | Q(x)) = ((? x. P(x)) | (? x. Q(x)))" by iprover
nipkow@17589
  1139
lemma all_conj_distrib: "(!x. P(x) & Q(x)) = ((! x. P(x)) & (! x. Q(x)))" by iprover
wenzelm@12281
  1140
wenzelm@12281
  1141
text {*
wenzelm@12281
  1142
  \medskip The @{text "&"} congruence rule: not included by default!
wenzelm@12281
  1143
  May slow rewrite proofs down by as much as 50\% *}
wenzelm@12281
  1144
wenzelm@12281
  1145
lemma conj_cong:
wenzelm@12281
  1146
    "(P = P') ==> (P' ==> (Q = Q')) ==> ((P & Q) = (P' & Q'))"
nipkow@17589
  1147
  by iprover
wenzelm@12281
  1148
wenzelm@12281
  1149
lemma rev_conj_cong:
wenzelm@12281
  1150
    "(Q = Q') ==> (Q' ==> (P = P')) ==> ((P & Q) = (P' & Q'))"
nipkow@17589
  1151
  by iprover
wenzelm@12281
  1152
wenzelm@12281
  1153
text {* The @{text "|"} congruence rule: not included by default! *}
wenzelm@12281
  1154
wenzelm@12281
  1155
lemma disj_cong:
wenzelm@12281
  1156
    "(P = P') ==> (~P' ==> (Q = Q')) ==> ((P | Q) = (P' | Q'))"
wenzelm@12281
  1157
  by blast
wenzelm@12281
  1158
wenzelm@12281
  1159
wenzelm@12281
  1160
text {* \medskip if-then-else rules *}
wenzelm@12281
  1161
wenzelm@12281
  1162
lemma if_True: "(if True then x else y) = x"
wenzelm@12281
  1163
  by (unfold if_def) blast
wenzelm@12281
  1164
wenzelm@12281
  1165
lemma if_False: "(if False then x else y) = y"
wenzelm@12281
  1166
  by (unfold if_def) blast
wenzelm@12281
  1167
wenzelm@12281
  1168
lemma if_P: "P ==> (if P then x else y) = x"
wenzelm@12281
  1169
  by (unfold if_def) blast
wenzelm@12281
  1170
wenzelm@12281
  1171
lemma if_not_P: "~P ==> (if P then x else y) = y"
wenzelm@12281
  1172
  by (unfold if_def) blast
wenzelm@12281
  1173
wenzelm@12281
  1174
lemma split_if: "P (if Q then x else y) = ((Q --> P(x)) & (~Q --> P(y)))"
wenzelm@12281
  1175
  apply (rule case_split [of Q])
paulson@15481
  1176
   apply (simplesubst if_P)
paulson@15481
  1177
    prefer 3 apply (simplesubst if_not_P, blast+)
wenzelm@12281
  1178
  done
wenzelm@12281
  1179
wenzelm@12281
  1180
lemma split_if_asm: "P (if Q then x else y) = (~((Q & ~P x) | (~Q & ~P y)))"
paulson@15481
  1181
by (simplesubst split_if, blast)
wenzelm@12281
  1182
paulson@24286
  1183
lemmas if_splits [noatp] = split_if split_if_asm
wenzelm@12281
  1184
wenzelm@12281
  1185
lemma if_cancel: "(if c then x else x) = x"
paulson@15481
  1186
by (simplesubst split_if, blast)
wenzelm@12281
  1187
wenzelm@12281
  1188
lemma if_eq_cancel: "(if x = y then y else x) = x"
paulson@15481
  1189
by (simplesubst split_if, blast)
wenzelm@12281
  1190
wenzelm@12281
  1191
lemma if_bool_eq_conj: "(if P then Q else R) = ((P-->Q) & (~P-->R))"
wenzelm@19796
  1192
  -- {* This form is useful for expanding @{text "if"}s on the RIGHT of the @{text "==>"} symbol. *}
wenzelm@12281
  1193
  by (rule split_if)
wenzelm@12281
  1194
wenzelm@12281
  1195
lemma if_bool_eq_disj: "(if P then Q else R) = ((P&Q) | (~P&R))"
wenzelm@19796
  1196
  -- {* And this form is useful for expanding @{text "if"}s on the LEFT. *}
paulson@15481
  1197
  apply (simplesubst split_if, blast)
wenzelm@12281
  1198
  done
wenzelm@12281
  1199
nipkow@17589
  1200
lemma Eq_TrueI: "P ==> P == True" by (unfold atomize_eq) iprover
nipkow@17589
  1201
lemma Eq_FalseI: "~P ==> P == False" by (unfold atomize_eq) iprover
wenzelm@12281
  1202
schirmer@15423
  1203
text {* \medskip let rules for simproc *}
schirmer@15423
  1204
schirmer@15423
  1205
lemma Let_folded: "f x \<equiv> g x \<Longrightarrow>  Let x f \<equiv> Let x g"
schirmer@15423
  1206
  by (unfold Let_def)
schirmer@15423
  1207
schirmer@15423
  1208
lemma Let_unfold: "f x \<equiv> g \<Longrightarrow>  Let x f \<equiv> g"
schirmer@15423
  1209
  by (unfold Let_def)
schirmer@15423
  1210
berghofe@16633
  1211
text {*
ballarin@16999
  1212
  The following copy of the implication operator is useful for
ballarin@16999
  1213
  fine-tuning congruence rules.  It instructs the simplifier to simplify
ballarin@16999
  1214
  its premise.
berghofe@16633
  1215
*}
berghofe@16633
  1216
wenzelm@17197
  1217
constdefs
wenzelm@17197
  1218
  simp_implies :: "[prop, prop] => prop"  (infixr "=simp=>" 1)
haftmann@28562
  1219
  [code del]: "simp_implies \<equiv> op ==>"
berghofe@16633
  1220
wenzelm@18457
  1221
lemma simp_impliesI:
berghofe@16633
  1222
  assumes PQ: "(PROP P \<Longrightarrow> PROP Q)"
berghofe@16633
  1223
  shows "PROP P =simp=> PROP Q"
berghofe@16633
  1224
  apply (unfold simp_implies_def)
berghofe@16633
  1225
  apply (rule PQ)
berghofe@16633
  1226
  apply assumption
berghofe@16633
  1227
  done
berghofe@16633
  1228
berghofe@16633
  1229
lemma simp_impliesE:
wenzelm@25388
  1230
  assumes PQ: "PROP P =simp=> PROP Q"
berghofe@16633
  1231
  and P: "PROP P"
berghofe@16633
  1232
  and QR: "PROP Q \<Longrightarrow> PROP R"
berghofe@16633
  1233
  shows "PROP R"
berghofe@16633
  1234
  apply (rule QR)
berghofe@16633
  1235
  apply (rule PQ [unfolded simp_implies_def])
berghofe@16633
  1236
  apply (rule P)
berghofe@16633
  1237
  done
berghofe@16633
  1238
berghofe@16633
  1239
lemma simp_implies_cong:
berghofe@16633
  1240
  assumes PP' :"PROP P == PROP P'"
berghofe@16633
  1241
  and P'QQ': "PROP P' ==> (PROP Q == PROP Q')"
berghofe@16633
  1242
  shows "(PROP P =simp=> PROP Q) == (PROP P' =simp=> PROP Q')"
berghofe@16633
  1243
proof (unfold simp_implies_def, rule equal_intr_rule)
berghofe@16633
  1244
  assume PQ: "PROP P \<Longrightarrow> PROP Q"
berghofe@16633
  1245
  and P': "PROP P'"
berghofe@16633
  1246
  from PP' [symmetric] and P' have "PROP P"
berghofe@16633
  1247
    by (rule equal_elim_rule1)
wenzelm@23553
  1248
  then have "PROP Q" by (rule PQ)
berghofe@16633
  1249
  with P'QQ' [OF P'] show "PROP Q'" by (rule equal_elim_rule1)
berghofe@16633
  1250
next
berghofe@16633
  1251
  assume P'Q': "PROP P' \<Longrightarrow> PROP Q'"
berghofe@16633
  1252
  and P: "PROP P"
berghofe@16633
  1253
  from PP' and P have P': "PROP P'" by (rule equal_elim_rule1)
wenzelm@23553
  1254
  then have "PROP Q'" by (rule P'Q')
berghofe@16633
  1255
  with P'QQ' [OF P', symmetric] show "PROP Q"
berghofe@16633
  1256
    by (rule equal_elim_rule1)
berghofe@16633
  1257
qed
berghofe@16633
  1258
haftmann@20944
  1259
lemma uncurry:
haftmann@20944
  1260
  assumes "P \<longrightarrow> Q \<longrightarrow> R"
haftmann@20944
  1261
  shows "P \<and> Q \<longrightarrow> R"
wenzelm@23553
  1262
  using assms by blast
haftmann@20944
  1263
haftmann@20944
  1264
lemma iff_allI:
haftmann@20944
  1265
  assumes "\<And>x. P x = Q x"
haftmann@20944
  1266
  shows "(\<forall>x. P x) = (\<forall>x. Q x)"
wenzelm@23553
  1267
  using assms by blast
haftmann@20944
  1268
haftmann@20944
  1269
lemma iff_exI:
haftmann@20944
  1270
  assumes "\<And>x. P x = Q x"
haftmann@20944
  1271
  shows "(\<exists>x. P x) = (\<exists>x. Q x)"
wenzelm@23553
  1272
  using assms by blast
haftmann@20944
  1273
haftmann@20944
  1274
lemma all_comm:
haftmann@20944
  1275
  "(\<forall>x y. P x y) = (\<forall>y x. P x y)"
haftmann@20944
  1276
  by blast
haftmann@20944
  1277
haftmann@20944
  1278
lemma ex_comm:
haftmann@20944
  1279
  "(\<exists>x y. P x y) = (\<exists>y x. P x y)"
haftmann@20944
  1280
  by blast
haftmann@20944
  1281
haftmann@28952
  1282
use "Tools/simpdata.ML"
wenzelm@21671
  1283
ML {* open Simpdata *}
wenzelm@21671
  1284
haftmann@21151
  1285
setup {*
haftmann@21151
  1286
  Simplifier.method_setup Splitter.split_modifiers
wenzelm@26496
  1287
  #> Simplifier.map_simpset (K Simpdata.simpset_simprocs)
haftmann@21151
  1288
  #> Splitter.setup
wenzelm@26496
  1289
  #> clasimp_setup
haftmann@21151
  1290
  #> EqSubst.setup
haftmann@21151
  1291
*}
haftmann@21151
  1292
wenzelm@24035
  1293
text {* Simproc for proving @{text "(y = x) == False"} from premise @{text "~(x = y)"}: *}
wenzelm@24035
  1294
wenzelm@24035
  1295
simproc_setup neq ("x = y") = {* fn _ =>
wenzelm@24035
  1296
let
wenzelm@24035
  1297
  val neq_to_EQ_False = @{thm not_sym} RS @{thm Eq_FalseI};
wenzelm@24035
  1298
  fun is_neq eq lhs rhs thm =
wenzelm@24035
  1299
    (case Thm.prop_of thm of
wenzelm@24035
  1300
      _ $ (Not $ (eq' $ l' $ r')) =>
wenzelm@24035
  1301
        Not = HOLogic.Not andalso eq' = eq andalso
wenzelm@24035
  1302
        r' aconv lhs andalso l' aconv rhs
wenzelm@24035
  1303
    | _ => false);
wenzelm@24035
  1304
  fun proc ss ct =
wenzelm@24035
  1305
    (case Thm.term_of ct of
wenzelm@24035
  1306
      eq $ lhs $ rhs =>
wenzelm@24035
  1307
        (case find_first (is_neq eq lhs rhs) (Simplifier.prems_of_ss ss) of
wenzelm@24035
  1308
          SOME thm => SOME (thm RS neq_to_EQ_False)
wenzelm@24035
  1309
        | NONE => NONE)
wenzelm@24035
  1310
     | _ => NONE);
wenzelm@24035
  1311
in proc end;
wenzelm@24035
  1312
*}
wenzelm@24035
  1313
wenzelm@24035
  1314
simproc_setup let_simp ("Let x f") = {*
wenzelm@24035
  1315
let
wenzelm@24035
  1316
  val (f_Let_unfold, x_Let_unfold) =
haftmann@28741
  1317
    let val [(_ $ (f $ x) $ _)] = prems_of @{thm Let_unfold}
wenzelm@24035
  1318
    in (cterm_of @{theory} f, cterm_of @{theory} x) end
wenzelm@24035
  1319
  val (f_Let_folded, x_Let_folded) =
haftmann@28741
  1320
    let val [(_ $ (f $ x) $ _)] = prems_of @{thm Let_folded}
wenzelm@24035
  1321
    in (cterm_of @{theory} f, cterm_of @{theory} x) end;
wenzelm@24035
  1322
  val g_Let_folded =
haftmann@28741
  1323
    let val [(_ $ _ $ (g $ _))] = prems_of @{thm Let_folded}
haftmann@28741
  1324
    in cterm_of @{theory} g end;
haftmann@28741
  1325
  fun count_loose (Bound i) k = if i >= k then 1 else 0
haftmann@28741
  1326
    | count_loose (s $ t) k = count_loose s k + count_loose t k
haftmann@28741
  1327
    | count_loose (Abs (_, _, t)) k = count_loose  t (k + 1)
haftmann@28741
  1328
    | count_loose _ _ = 0;
haftmann@28741
  1329
  fun is_trivial_let (Const (@{const_name Let}, _) $ x $ t) =
haftmann@28741
  1330
   case t
haftmann@28741
  1331
    of Abs (_, _, t') => count_loose t' 0 <= 1
haftmann@28741
  1332
     | _ => true;
haftmann@28741
  1333
in fn _ => fn ss => fn ct => if is_trivial_let (Thm.term_of ct)
haftmann@28741
  1334
  then SOME @{thm Let_def} (*no or one ocurrenc of bound variable*)
haftmann@28741
  1335
  else let (*Norbert Schirmer's case*)
haftmann@28741
  1336
    val ctxt = Simplifier.the_context ss;
haftmann@28741
  1337
    val thy = ProofContext.theory_of ctxt;
haftmann@28741
  1338
    val t = Thm.term_of ct;
haftmann@28741
  1339
    val ([t'], ctxt') = Variable.import_terms false [t] ctxt;
haftmann@28741
  1340
  in Option.map (hd o Variable.export ctxt' ctxt o single)
haftmann@28741
  1341
    (case t' of Const (@{const_name Let},_) $ x $ f => (* x and f are already in normal form *)
haftmann@28741
  1342
      if is_Free x orelse is_Bound x orelse is_Const x
haftmann@28741
  1343
      then SOME @{thm Let_def}
haftmann@28741
  1344
      else
haftmann@28741
  1345
        let
haftmann@28741
  1346
          val n = case f of (Abs (x, _, _)) => x | _ => "x";
haftmann@28741
  1347
          val cx = cterm_of thy x;
haftmann@28741
  1348
          val {T = xT, ...} = rep_cterm cx;
haftmann@28741
  1349
          val cf = cterm_of thy f;
haftmann@28741
  1350
          val fx_g = Simplifier.rewrite ss (Thm.capply cf cx);
haftmann@28741
  1351
          val (_ $ _ $ g) = prop_of fx_g;
haftmann@28741
  1352
          val g' = abstract_over (x,g);
haftmann@28741
  1353
        in (if (g aconv g')
haftmann@28741
  1354
             then
haftmann@28741
  1355
                let
haftmann@28741
  1356
                  val rl =
haftmann@28741
  1357
                    cterm_instantiate [(f_Let_unfold, cf), (x_Let_unfold, cx)] @{thm Let_unfold};
haftmann@28741
  1358
                in SOME (rl OF [fx_g]) end
haftmann@28741
  1359
             else if Term.betapply (f, x) aconv g then NONE (*avoid identity conversion*)
haftmann@28741
  1360
             else let
haftmann@28741
  1361
                   val abs_g'= Abs (n,xT,g');
haftmann@28741
  1362
                   val g'x = abs_g'$x;
haftmann@28741
  1363
                   val g_g'x = symmetric (beta_conversion false (cterm_of thy g'x));
haftmann@28741
  1364
                   val rl = cterm_instantiate
haftmann@28741
  1365
                             [(f_Let_folded, cterm_of thy f), (x_Let_folded, cx),
haftmann@28741
  1366
                              (g_Let_folded, cterm_of thy abs_g')]
haftmann@28741
  1367
                             @{thm Let_folded};
haftmann@28741
  1368
                 in SOME (rl OF [transitive fx_g g_g'x])
haftmann@28741
  1369
                 end)
haftmann@28741
  1370
        end
haftmann@28741
  1371
    | _ => NONE)
haftmann@28741
  1372
  end
haftmann@28741
  1373
end *}
wenzelm@24035
  1374
haftmann@21151
  1375
lemma True_implies_equals: "(True \<Longrightarrow> PROP P) \<equiv> PROP P"
haftmann@21151
  1376
proof
wenzelm@23389
  1377
  assume "True \<Longrightarrow> PROP P"
wenzelm@23389
  1378
  from this [OF TrueI] show "PROP P" .
haftmann@21151
  1379
next
haftmann@21151
  1380
  assume "PROP P"
wenzelm@23389
  1381
  then show "PROP P" .
haftmann@21151
  1382
qed
haftmann@21151
  1383
haftmann@21151
  1384
lemma ex_simps:
haftmann@21151
  1385
  "!!P Q. (EX x. P x & Q)   = ((EX x. P x) & Q)"
haftmann@21151
  1386
  "!!P Q. (EX x. P & Q x)   = (P & (EX x. Q x))"
haftmann@21151
  1387
  "!!P Q. (EX x. P x | Q)   = ((EX x. P x) | Q)"
haftmann@21151
  1388
  "!!P Q. (EX x. P | Q x)   = (P | (EX x. Q x))"
haftmann@21151
  1389
  "!!P Q. (EX x. P x --> Q) = ((ALL x. P x) --> Q)"
haftmann@21151
  1390
  "!!P Q. (EX x. P --> Q x) = (P --> (EX x. Q x))"
haftmann@21151
  1391
  -- {* Miniscoping: pushing in existential quantifiers. *}
haftmann@21151
  1392
  by (iprover | blast)+
haftmann@21151
  1393
haftmann@21151
  1394
lemma all_simps:
haftmann@21151
  1395
  "!!P Q. (ALL x. P x & Q)   = ((ALL x. P x) & Q)"
haftmann@21151
  1396
  "!!P Q. (ALL x. P & Q x)   = (P & (ALL x. Q x))"
haftmann@21151
  1397
  "!!P Q. (ALL x. P x | Q)   = ((ALL x. P x) | Q)"
haftmann@21151
  1398
  "!!P Q. (ALL x. P | Q x)   = (P | (ALL x. Q x))"
haftmann@21151
  1399
  "!!P Q. (ALL x. P x --> Q) = ((EX x. P x) --> Q)"
haftmann@21151
  1400
  "!!P Q. (ALL x. P --> Q x) = (P --> (ALL x. Q x))"
haftmann@21151
  1401
  -- {* Miniscoping: pushing in universal quantifiers. *}
haftmann@21151
  1402
  by (iprover | blast)+
paulson@15481
  1403
wenzelm@21671
  1404
lemmas [simp] =
wenzelm@21671
  1405
  triv_forall_equality (*prunes params*)
wenzelm@21671
  1406
  True_implies_equals  (*prune asms `True'*)
wenzelm@21671
  1407
  if_True
wenzelm@21671
  1408
  if_False
wenzelm@21671
  1409
  if_cancel
wenzelm@21671
  1410
  if_eq_cancel
wenzelm@21671
  1411
  imp_disjL
haftmann@20973
  1412
  (*In general it seems wrong to add distributive laws by default: they
haftmann@20973
  1413
    might cause exponential blow-up.  But imp_disjL has been in for a while
haftmann@20973
  1414
    and cannot be removed without affecting existing proofs.  Moreover,
haftmann@20973
  1415
    rewriting by "(P|Q --> R) = ((P-->R)&(Q-->R))" might be justified on the
haftmann@20973
  1416
    grounds that it allows simplification of R in the two cases.*)
wenzelm@21671
  1417
  conj_assoc
wenzelm@21671
  1418
  disj_assoc
wenzelm@21671
  1419
  de_Morgan_conj
wenzelm@21671
  1420
  de_Morgan_disj
wenzelm@21671
  1421
  imp_disj1
wenzelm@21671
  1422
  imp_disj2
wenzelm@21671
  1423
  not_imp
wenzelm@21671
  1424
  disj_not1
wenzelm@21671
  1425
  not_all
wenzelm@21671
  1426
  not_ex
wenzelm@21671
  1427
  cases_simp
wenzelm@21671
  1428
  the_eq_trivial
wenzelm@21671
  1429
  the_sym_eq_trivial
wenzelm@21671
  1430
  ex_simps
wenzelm@21671
  1431
  all_simps
wenzelm@21671
  1432
  simp_thms
wenzelm@21671
  1433
wenzelm@21671
  1434
lemmas [cong] = imp_cong simp_implies_cong
wenzelm@21671
  1435
lemmas [split] = split_if
haftmann@20973
  1436
wenzelm@22377
  1437
ML {* val HOL_ss = @{simpset} *}
haftmann@20973
  1438
haftmann@20944
  1439
text {* Simplifies x assuming c and y assuming ~c *}
haftmann@20944
  1440
lemma if_cong:
haftmann@20944
  1441
  assumes "b = c"
haftmann@20944
  1442
      and "c \<Longrightarrow> x = u"
haftmann@20944
  1443
      and "\<not> c \<Longrightarrow> y = v"
haftmann@20944
  1444
  shows "(if b then x else y) = (if c then u else v)"
wenzelm@23553
  1445
  unfolding if_def using assms by simp
haftmann@20944
  1446
haftmann@20944
  1447
text {* Prevents simplification of x and y:
haftmann@20944
  1448
  faster and allows the execution of functional programs. *}
haftmann@20944
  1449
lemma if_weak_cong [cong]:
haftmann@20944
  1450
  assumes "b = c"
haftmann@20944
  1451
  shows "(if b then x else y) = (if c then x else y)"
wenzelm@23553
  1452
  using assms by (rule arg_cong)
haftmann@20944
  1453
haftmann@20944
  1454
text {* Prevents simplification of t: much faster *}
haftmann@20944
  1455
lemma let_weak_cong:
haftmann@20944
  1456
  assumes "a = b"
haftmann@20944
  1457
  shows "(let x = a in t x) = (let x = b in t x)"
wenzelm@23553
  1458
  using assms by (rule arg_cong)
haftmann@20944
  1459
haftmann@20944
  1460
text {* To tidy up the result of a simproc.  Only the RHS will be simplified. *}
haftmann@20944
  1461
lemma eq_cong2:
haftmann@20944
  1462
  assumes "u = u'"
haftmann@20944
  1463
  shows "(t \<equiv> u) \<equiv> (t \<equiv> u')"
wenzelm@23553
  1464
  using assms by simp
haftmann@20944
  1465
haftmann@20944
  1466
lemma if_distrib:
haftmann@20944
  1467
  "f (if c then x else y) = (if c then f x else f y)"
haftmann@20944
  1468
  by simp
haftmann@20944
  1469
haftmann@20944
  1470
text {* This lemma restricts the effect of the rewrite rule u=v to the left-hand
wenzelm@21502
  1471
  side of an equality.  Used in @{text "{Integ,Real}/simproc.ML"} *}
haftmann@20944
  1472
lemma restrict_to_left:
haftmann@20944
  1473
  assumes "x = y"
haftmann@20944
  1474
  shows "(x = z) = (y = z)"
wenzelm@23553
  1475
  using assms by simp
haftmann@20944
  1476
haftmann@20944
  1477
haftmann@20944
  1478
subsubsection {* Generic cases and induction *}
haftmann@20944
  1479
haftmann@20944
  1480
text {* Rule projections: *}
haftmann@20944
  1481
haftmann@20944
  1482
ML {*
haftmann@20944
  1483
structure ProjectRule = ProjectRuleFun
wenzelm@25388
  1484
(
wenzelm@27126
  1485
  val conjunct1 = @{thm conjunct1}
wenzelm@27126
  1486
  val conjunct2 = @{thm conjunct2}
wenzelm@27126
  1487
  val mp = @{thm mp}
wenzelm@25388
  1488
)
haftmann@20944
  1489
*}
haftmann@20944
  1490
haftmann@20944
  1491
constdefs
haftmann@20944
  1492
  induct_forall where "induct_forall P == \<forall>x. P x"
haftmann@20944
  1493
  induct_implies where "induct_implies A B == A \<longrightarrow> B"
haftmann@20944
  1494
  induct_equal where "induct_equal x y == x = y"
haftmann@20944
  1495
  induct_conj where "induct_conj A B == A \<and> B"
haftmann@20944
  1496
haftmann@20944
  1497
lemma induct_forall_eq: "(!!x. P x) == Trueprop (induct_forall (\<lambda>x. P x))"
haftmann@20944
  1498
  by (unfold atomize_all induct_forall_def)
haftmann@20944
  1499
haftmann@20944
  1500
lemma induct_implies_eq: "(A ==> B) == Trueprop (induct_implies A B)"
haftmann@20944
  1501
  by (unfold atomize_imp induct_implies_def)
haftmann@20944
  1502
haftmann@20944
  1503
lemma induct_equal_eq: "(x == y) == Trueprop (induct_equal x y)"
haftmann@20944
  1504
  by (unfold atomize_eq induct_equal_def)
haftmann@20944
  1505
wenzelm@28856
  1506
lemma induct_conj_eq: "(A &&& B) == Trueprop (induct_conj A B)"
haftmann@20944
  1507
  by (unfold atomize_conj induct_conj_def)
haftmann@20944
  1508
haftmann@20944
  1509
lemmas induct_atomize = induct_forall_eq induct_implies_eq induct_equal_eq induct_conj_eq
haftmann@20944
  1510
lemmas induct_rulify [symmetric, standard] = induct_atomize
haftmann@20944
  1511
lemmas induct_rulify_fallback =
haftmann@20944
  1512
  induct_forall_def induct_implies_def induct_equal_def induct_conj_def
haftmann@20944
  1513
haftmann@20944
  1514
haftmann@20944
  1515
lemma induct_forall_conj: "induct_forall (\<lambda>x. induct_conj (A x) (B x)) =
haftmann@20944
  1516
    induct_conj (induct_forall A) (induct_forall B)"
haftmann@20944
  1517
  by (unfold induct_forall_def induct_conj_def) iprover
haftmann@20944
  1518
haftmann@20944
  1519
lemma induct_implies_conj: "induct_implies C (induct_conj A B) =
haftmann@20944
  1520
    induct_conj (induct_implies C A) (induct_implies C B)"
haftmann@20944
  1521
  by (unfold induct_implies_def induct_conj_def) iprover
haftmann@20944
  1522
haftmann@20944
  1523
lemma induct_conj_curry: "(induct_conj A B ==> PROP C) == (A ==> B ==> PROP C)"
haftmann@20944
  1524
proof
haftmann@20944
  1525
  assume r: "induct_conj A B ==> PROP C" and A B
haftmann@20944
  1526
  show "PROP C" by (rule r) (simp add: induct_conj_def `A` `B`)
haftmann@20944
  1527
next
haftmann@20944
  1528
  assume r: "A ==> B ==> PROP C" and "induct_conj A B"
haftmann@20944
  1529
  show "PROP C" by (rule r) (simp_all add: `induct_conj A B` [unfolded induct_conj_def])
haftmann@20944
  1530
qed
haftmann@20944
  1531
haftmann@20944
  1532
lemmas induct_conj = induct_forall_conj induct_implies_conj induct_conj_curry
haftmann@20944
  1533
haftmann@20944
  1534
hide const induct_forall induct_implies induct_equal induct_conj
haftmann@20944
  1535
haftmann@20944
  1536
text {* Method setup. *}
haftmann@20944
  1537
haftmann@20944
  1538
ML {*
wenzelm@27126
  1539
structure Induct = InductFun
wenzelm@27126
  1540
(
wenzelm@27126
  1541
  val cases_default = @{thm case_split}
wenzelm@27126
  1542
  val atomize = @{thms induct_atomize}
wenzelm@27126
  1543
  val rulify = @{thms induct_rulify}
wenzelm@27126
  1544
  val rulify_fallback = @{thms induct_rulify_fallback}
wenzelm@27126
  1545
)
haftmann@20944
  1546
*}
haftmann@20944
  1547
wenzelm@24830
  1548
setup Induct.setup
wenzelm@17459
  1549
wenzelm@27326
  1550
use "~~/src/Tools/induct_tacs.ML"
wenzelm@27126
  1551
setup InductTacs.setup
wenzelm@27126
  1552
haftmann@20944
  1553
berghofe@28325
  1554
subsubsection {* Coherent logic *}
berghofe@28325
  1555
berghofe@28325
  1556
ML {*
berghofe@28325
  1557
structure Coherent = CoherentFun
berghofe@28325
  1558
(
berghofe@28325
  1559
  val atomize_elimL = @{thm atomize_elimL}
berghofe@28325
  1560
  val atomize_exL = @{thm atomize_exL}
berghofe@28325
  1561
  val atomize_conjL = @{thm atomize_conjL}
berghofe@28325
  1562
  val atomize_disjL = @{thm atomize_disjL}
berghofe@28325
  1563
  val operator_names =
berghofe@28325
  1564
    [@{const_name "op |"}, @{const_name "op &"}, @{const_name "Ex"}]
berghofe@28325
  1565
);
berghofe@28325
  1566
*}
berghofe@28325
  1567
berghofe@28325
  1568
setup Coherent.setup
berghofe@28325
  1569
berghofe@28325
  1570
haftmann@20944
  1571
subsection {* Other simple lemmas and lemma duplicates *}
haftmann@20944
  1572
haftmann@24166
  1573
lemma Let_0 [simp]: "Let 0 f = f 0"
haftmann@24166
  1574
  unfolding Let_def ..
haftmann@24166
  1575
haftmann@24166
  1576
lemma Let_1 [simp]: "Let 1 f = f 1"
haftmann@24166
  1577
  unfolding Let_def ..
haftmann@24166
  1578
haftmann@20944
  1579
lemma ex1_eq [iff]: "EX! x. x = t" "EX! x. t = x"
haftmann@20944
  1580
  by blast+
haftmann@20944
  1581
haftmann@20944
  1582
lemma choice_eq: "(ALL x. EX! y. P x y) = (EX! f. ALL x. P x (f x))"
haftmann@20944
  1583
  apply (rule iffI)
haftmann@20944
  1584
  apply (rule_tac a = "%x. THE y. P x y" in ex1I)
haftmann@20944
  1585
  apply (fast dest!: theI')
haftmann@20944
  1586
  apply (fast intro: ext the1_equality [symmetric])
haftmann@20944
  1587
  apply (erule ex1E)
haftmann@20944
  1588
  apply (rule allI)
haftmann@20944
  1589
  apply (rule ex1I)
haftmann@20944
  1590
  apply (erule spec)
haftmann@20944
  1591
  apply (erule_tac x = "%z. if z = x then y else f z" in allE)
haftmann@20944
  1592
  apply (erule impE)
haftmann@20944
  1593
  apply (rule allI)
wenzelm@27126
  1594
  apply (case_tac "xa = x")
haftmann@20944
  1595
  apply (drule_tac [3] x = x in fun_cong, simp_all)
haftmann@20944
  1596
  done
haftmann@20944
  1597
haftmann@20944
  1598
lemma mk_left_commute:
haftmann@21547
  1599
  fixes f (infix "\<otimes>" 60)
haftmann@21547
  1600
  assumes a: "\<And>x y z. (x \<otimes> y) \<otimes> z = x \<otimes> (y \<otimes> z)" and
haftmann@21547
  1601
          c: "\<And>x y. x \<otimes> y = y \<otimes> x"
haftmann@21547
  1602
  shows "x \<otimes> (y \<otimes> z) = y \<otimes> (x \<otimes> z)"
haftmann@20944
  1603
  by (rule trans [OF trans [OF c a] arg_cong [OF c, of "f y"]])
haftmann@20944
  1604
haftmann@22218
  1605
lemmas eq_sym_conv = eq_commute
haftmann@22218
  1606
chaieb@23037
  1607
lemma nnf_simps:
chaieb@23037
  1608
  "(\<not>(P \<and> Q)) = (\<not> P \<or> \<not> Q)" "(\<not> (P \<or> Q)) = (\<not> P \<and> \<not>Q)" "(P \<longrightarrow> Q) = (\<not>P \<or> Q)" 
chaieb@23037
  1609
  "(P = Q) = ((P \<and> Q) \<or> (\<not>P \<and> \<not> Q))" "(\<not>(P = Q)) = ((P \<and> \<not> Q) \<or> (\<not>P \<and> Q))" 
chaieb@23037
  1610
  "(\<not> \<not>(P)) = P"
chaieb@23037
  1611
by blast+
chaieb@23037
  1612
wenzelm@21671
  1613
wenzelm@21671
  1614
subsection {* Basic ML bindings *}
wenzelm@21671
  1615
wenzelm@21671
  1616
ML {*
wenzelm@22129
  1617
val FalseE = @{thm FalseE}
wenzelm@22129
  1618
val Let_def = @{thm Let_def}
wenzelm@22129
  1619
val TrueI = @{thm TrueI}
wenzelm@22129
  1620
val allE = @{thm allE}
wenzelm@22129
  1621
val allI = @{thm allI}
wenzelm@22129
  1622
val all_dupE = @{thm all_dupE}
wenzelm@22129
  1623
val arg_cong = @{thm arg_cong}
wenzelm@22129
  1624
val box_equals = @{thm box_equals}
wenzelm@22129
  1625
val ccontr = @{thm ccontr}
wenzelm@22129
  1626
val classical = @{thm classical}
wenzelm@22129
  1627
val conjE = @{thm conjE}
wenzelm@22129
  1628
val conjI = @{thm conjI}
wenzelm@22129
  1629
val conjunct1 = @{thm conjunct1}
wenzelm@22129
  1630
val conjunct2 = @{thm conjunct2}
wenzelm@22129
  1631
val disjCI = @{thm disjCI}
wenzelm@22129
  1632
val disjE = @{thm disjE}
wenzelm@22129
  1633
val disjI1 = @{thm disjI1}
wenzelm@22129
  1634
val disjI2 = @{thm disjI2}
wenzelm@22129
  1635
val eq_reflection = @{thm eq_reflection}
wenzelm@22129
  1636
val ex1E = @{thm ex1E}
wenzelm@22129
  1637
val ex1I = @{thm ex1I}
wenzelm@22129
  1638
val ex1_implies_ex = @{thm ex1_implies_ex}
wenzelm@22129
  1639
val exE = @{thm exE}
wenzelm@22129
  1640
val exI = @{thm exI}
wenzelm@22129
  1641
val excluded_middle = @{thm excluded_middle}
wenzelm@22129
  1642
val ext = @{thm ext}
wenzelm@22129
  1643
val fun_cong = @{thm fun_cong}
wenzelm@22129
  1644
val iffD1 = @{thm iffD1}
wenzelm@22129
  1645
val iffD2 = @{thm iffD2}
wenzelm@22129
  1646
val iffI = @{thm iffI}
wenzelm@22129
  1647
val impE = @{thm impE}
wenzelm@22129
  1648
val impI = @{thm impI}
wenzelm@22129
  1649
val meta_eq_to_obj_eq = @{thm meta_eq_to_obj_eq}
wenzelm@22129
  1650
val mp = @{thm mp}
wenzelm@22129
  1651
val notE = @{thm notE}
wenzelm@22129
  1652
val notI = @{thm notI}
wenzelm@22129
  1653
val not_all = @{thm not_all}
wenzelm@22129
  1654
val not_ex = @{thm not_ex}
wenzelm@22129
  1655
val not_iff = @{thm not_iff}
wenzelm@22129
  1656
val not_not = @{thm not_not}
wenzelm@22129
  1657
val not_sym = @{thm not_sym}
wenzelm@22129
  1658
val refl = @{thm refl}
wenzelm@22129
  1659
val rev_mp = @{thm rev_mp}
wenzelm@22129
  1660
val spec = @{thm spec}
wenzelm@22129
  1661
val ssubst = @{thm ssubst}
wenzelm@22129
  1662
val subst = @{thm subst}
wenzelm@22129
  1663
val sym = @{thm sym}
wenzelm@22129
  1664
val trans = @{thm trans}
wenzelm@21671
  1665
*}
wenzelm@21671
  1666
wenzelm@21671
  1667
haftmann@30929
  1668
subsection {* Code generator setup *}
haftmann@28400
  1669
haftmann@30929
  1670
subsubsection {* SML code generator setup *}
haftmann@30929
  1671
haftmann@30929
  1672
use "Tools/recfun_codegen.ML"
haftmann@30929
  1673
haftmann@30929
  1674
setup {*
haftmann@30929
  1675
  Codegen.setup
haftmann@30929
  1676
  #> RecfunCodegen.setup
haftmann@30929
  1677
*}
haftmann@30929
  1678
haftmann@30929
  1679
types_code
haftmann@30929
  1680
  "bool"  ("bool")
haftmann@30929
  1681
attach (term_of) {*
haftmann@30929
  1682
fun term_of_bool b = if b then HOLogic.true_const else HOLogic.false_const;
haftmann@30929
  1683
*}
haftmann@30929
  1684
attach (test) {*
haftmann@30929
  1685
fun gen_bool i =
haftmann@30929
  1686
  let val b = one_of [false, true]
haftmann@30929
  1687
  in (b, fn () => term_of_bool b) end;
haftmann@30929
  1688
*}
haftmann@30929
  1689
  "prop"  ("bool")
haftmann@30929
  1690
attach (term_of) {*
haftmann@30929
  1691
fun term_of_prop b =
haftmann@30929
  1692
  HOLogic.mk_Trueprop (if b then HOLogic.true_const else HOLogic.false_const);
haftmann@30929
  1693
*}
haftmann@30929
  1694
haftmann@30929
  1695
consts_code
haftmann@30929
  1696
  "Trueprop" ("(_)")
haftmann@30929
  1697
  "True"    ("true")
haftmann@30929
  1698
  "False"   ("false")
haftmann@30929
  1699
  "Not"     ("Bool.not")
haftmann@30929
  1700
  "op |"    ("(_ orelse/ _)")
haftmann@30929
  1701
  "op &"    ("(_ andalso/ _)")
haftmann@30929
  1702
  "If"      ("(if _/ then _/ else _)")
haftmann@30929
  1703
haftmann@30929
  1704
setup {*
haftmann@30929
  1705
let
haftmann@30929
  1706
haftmann@30929
  1707
fun eq_codegen thy defs dep thyname b t gr =
haftmann@30929
  1708
    (case strip_comb t of
haftmann@30929
  1709
       (Const ("op =", Type (_, [Type ("fun", _), _])), _) => NONE
haftmann@30929
  1710
     | (Const ("op =", _), [t, u]) =>
haftmann@30929
  1711
          let
haftmann@30929
  1712
            val (pt, gr') = Codegen.invoke_codegen thy defs dep thyname false t gr;
haftmann@30929
  1713
            val (pu, gr'') = Codegen.invoke_codegen thy defs dep thyname false u gr';
haftmann@30929
  1714
            val (_, gr''') = Codegen.invoke_tycodegen thy defs dep thyname false HOLogic.boolT gr'';
haftmann@30929
  1715
          in
haftmann@30929
  1716
            SOME (Codegen.parens
haftmann@30929
  1717
              (Pretty.block [pt, Codegen.str " =", Pretty.brk 1, pu]), gr''')
haftmann@30929
  1718
          end
haftmann@30929
  1719
     | (t as Const ("op =", _), ts) => SOME (Codegen.invoke_codegen
haftmann@30929
  1720
         thy defs dep thyname b (Codegen.eta_expand t ts 2) gr)
haftmann@30929
  1721
     | _ => NONE);
haftmann@30929
  1722
haftmann@30929
  1723
in
haftmann@30929
  1724
  Codegen.add_codegen "eq_codegen" eq_codegen
haftmann@30929
  1725
end
haftmann@30929
  1726
*}
haftmann@30929
  1727
haftmann@30929
  1728
subsubsection {* Equality *}
haftmann@24844
  1729
haftmann@29608
  1730
class eq =
haftmann@26513
  1731
  fixes eq :: "'a \<Rightarrow> 'a \<Rightarrow> bool"
haftmann@28400
  1732
  assumes eq_equals: "eq x y \<longleftrightarrow> x = y"
haftmann@26513
  1733
begin
haftmann@26513
  1734
haftmann@30929
  1735
lemma eq [code unfold, code inline del]: "eq = (op =)"
haftmann@28346
  1736
  by (rule ext eq_equals)+
haftmann@28346
  1737
haftmann@28346
  1738
lemma eq_refl: "eq x x \<longleftrightarrow> True"
haftmann@28346
  1739
  unfolding eq by rule+
haftmann@28346
  1740
haftmann@30966
  1741
lemma equals_eq [code inline]: "(op =) \<equiv> eq"
haftmann@30929
  1742
  by (rule eq_reflection) (rule ext, rule ext, rule sym, rule eq_equals)
haftmann@30929
  1743
haftmann@30929
  1744
declare equals_eq [symmetric, code post]
haftmann@30929
  1745
haftmann@26513
  1746
end
haftmann@26513
  1747
haftmann@30966
  1748
declare equals_eq [code]
haftmann@30966
  1749
haftmann@30966
  1750
haftmann@30929
  1751
subsubsection {* Generic code generator foundation *}
haftmann@28513
  1752
haftmann@30929
  1753
text {* Datatypes *}
haftmann@30929
  1754
haftmann@30929
  1755
code_datatype True False
haftmann@30929
  1756
haftmann@30929
  1757
code_datatype "TYPE('a\<Colon>{})"
haftmann@30929
  1758
haftmann@30929
  1759
code_datatype Trueprop "prop"
haftmann@30929
  1760
haftmann@30929
  1761
text {* Code equations *}
haftmann@30929
  1762
haftmann@30929
  1763
lemma [code]:
haftmann@30929
  1764
  shows "(True \<Longrightarrow> PROP P) \<equiv> PROP P" 
haftmann@30929
  1765
    and "(False \<Longrightarrow> Q) \<equiv> Trueprop True" 
haftmann@30929
  1766
    and "(PROP P \<Longrightarrow> True) \<equiv> Trueprop True" 
haftmann@30929
  1767
    and "(Q \<Longrightarrow> False) \<equiv> Trueprop (\<not> Q)" by (auto intro!: equal_intr_rule)
haftmann@30929
  1768
haftmann@30929
  1769
lemma [code]:
haftmann@30929
  1770
  shows "False \<and> x \<longleftrightarrow> False"
haftmann@30929
  1771
    and "True \<and> x \<longleftrightarrow> x"
haftmann@30929
  1772
    and "x \<and> False \<longleftrightarrow> False"
haftmann@30929
  1773
    and "x \<and> True \<longleftrightarrow> x" by simp_all
haftmann@30929
  1774
haftmann@30929
  1775
lemma [code]:
haftmann@30929
  1776
  shows "False \<or> x \<longleftrightarrow> x"
haftmann@30929
  1777
    and "True \<or> x \<longleftrightarrow> True"
haftmann@30929
  1778
    and "x \<or> False \<longleftrightarrow> x"
haftmann@30929
  1779
    and "x \<or> True \<longleftrightarrow> True" by simp_all
haftmann@30929
  1780
haftmann@30929
  1781
lemma [code]:
haftmann@30929
  1782
  shows "\<not> True \<longleftrightarrow> False"
haftmann@30929
  1783
    and "\<not> False \<longleftrightarrow> True" by (rule HOL.simp_thms)+
haftmann@30929
  1784
haftmann@30929
  1785
lemmas [code] = Let_def if_True if_False
haftmann@30929
  1786
haftmann@30929
  1787
lemmas [code, code unfold, symmetric, code post] = imp_conv_disj
haftmann@30929
  1788
haftmann@30929
  1789
text {* Equality *}
haftmann@30929
  1790
haftmann@30929
  1791
declare simp_thms(6) [code nbe]
haftmann@30929
  1792
haftmann@30929
  1793
hide (open) const eq
haftmann@30929
  1794
hide const eq
haftmann@28513
  1795
haftmann@28513
  1796
setup {*
haftmann@30929
  1797
  Code_Unit.add_const_alias @{thm equals_eq}
haftmann@28513
  1798
*}
haftmann@28513
  1799
haftmann@30929
  1800
text {* Cases *}
haftmann@30929
  1801
haftmann@30929
  1802
lemma Let_case_cert:
haftmann@30929
  1803
  assumes "CASE \<equiv> (\<lambda>x. Let x f)"
haftmann@30929
  1804
  shows "CASE x \<equiv> f x"
haftmann@30929
  1805
  using assms by simp_all
haftmann@30929
  1806
haftmann@30929
  1807
lemma If_case_cert:
haftmann@30929
  1808
  assumes "CASE \<equiv> (\<lambda>b. If b f g)"
haftmann@30929
  1809
  shows "(CASE True \<equiv> f) &&& (CASE False \<equiv> g)"
haftmann@30929
  1810
  using assms by simp_all
haftmann@30929
  1811
haftmann@30929
  1812
setup {*
haftmann@30929
  1813
  Code.add_case @{thm Let_case_cert}
haftmann@30929
  1814
  #> Code.add_case @{thm If_case_cert}
haftmann@30929
  1815
  #> Code.add_undefined @{const_name undefined}
haftmann@30929
  1816
*}
haftmann@30929
  1817
haftmann@30929
  1818
code_abort undefined
haftmann@30929
  1819
haftmann@30929
  1820
subsubsection {* Generic code generator preprocessor *}
haftmann@30929
  1821
haftmann@30929
  1822
setup {*
haftmann@30929
  1823
  Code.map_pre (K HOL_basic_ss)
haftmann@30929
  1824
  #> Code.map_post (K HOL_basic_ss)
haftmann@30929
  1825
*}
haftmann@30929
  1826
haftmann@30929
  1827
subsubsection {* Generic code generator target languages *}
haftmann@30929
  1828
haftmann@30929
  1829
text {* type bool *}
haftmann@30929
  1830
haftmann@30929
  1831
code_type bool
haftmann@30929
  1832
  (SML "bool")
haftmann@30929
  1833
  (OCaml "bool")
haftmann@30929
  1834
  (Haskell "Bool")
haftmann@30929
  1835
haftmann@30929
  1836
code_const True and False and Not and "op &" and "op |" and If
haftmann@30929
  1837
  (SML "true" and "false" and "not"
haftmann@30929
  1838
    and infixl 1 "andalso" and infixl 0 "orelse"
haftmann@30929
  1839
    and "!(if (_)/ then (_)/ else (_))")
haftmann@30929
  1840
  (OCaml "true" and "false" and "not"
haftmann@30929
  1841
    and infixl 4 "&&" and infixl 2 "||"
haftmann@30929
  1842
    and "!(if (_)/ then (_)/ else (_))")
haftmann@30929
  1843
  (Haskell "True" and "False" and "not"
haftmann@30929
  1844
    and infixl 3 "&&" and infixl 2 "||"
haftmann@30929
  1845
    and "!(if (_)/ then (_)/ else (_))")
haftmann@30929
  1846
haftmann@30929
  1847
code_reserved SML
haftmann@30929
  1848
  bool true false not
haftmann@30929
  1849
haftmann@30929
  1850
code_reserved OCaml
haftmann@30929
  1851
  bool not
haftmann@30929
  1852
haftmann@30929
  1853
text {* using built-in Haskell equality *}
haftmann@30929
  1854
haftmann@30929
  1855
code_class eq
haftmann@30929
  1856
  (Haskell "Eq")
haftmann@30929
  1857
haftmann@30929
  1858
code_const "eq_class.eq"
haftmann@30929
  1859
  (Haskell infixl 4 "==")
haftmann@30929
  1860
haftmann@30929
  1861
code_const "op ="
haftmann@30929
  1862
  (Haskell infixl 4 "==")
haftmann@30929
  1863
haftmann@30929
  1864
text {* undefined *}
haftmann@30929
  1865
haftmann@30929
  1866
code_const undefined
haftmann@30929
  1867
  (SML "!(raise/ Fail/ \"undefined\")")
haftmann@30929
  1868
  (OCaml "failwith/ \"undefined\"")
haftmann@30929
  1869
  (Haskell "error/ \"undefined\"")
haftmann@30929
  1870
haftmann@30929
  1871
subsubsection {* Evaluation and normalization by evaluation *}
haftmann@30929
  1872
haftmann@30929
  1873
setup {*
haftmann@30929
  1874
  Value.add_evaluator ("SML", Codegen.eval_term o ProofContext.theory_of)
haftmann@30929
  1875
*}
haftmann@30929
  1876
haftmann@30929
  1877
ML {*
haftmann@30929
  1878
structure Eval_Method =
haftmann@30929
  1879
struct
haftmann@30929
  1880
haftmann@30929
  1881
val eval_ref : (unit -> bool) option ref = ref NONE;
haftmann@30929
  1882
haftmann@30929
  1883
end;
haftmann@30929
  1884
*}
haftmann@30929
  1885
haftmann@30929
  1886
oracle eval_oracle = {* fn ct =>
haftmann@30929
  1887
  let
haftmann@30929
  1888
    val thy = Thm.theory_of_cterm ct;
haftmann@30929
  1889
    val t = Thm.term_of ct;
haftmann@30929
  1890
    val dummy = @{cprop True};
haftmann@30929
  1891
  in case try HOLogic.dest_Trueprop t
haftmann@30947
  1892
   of SOME t' => if Code_ML.eval NONE
haftmann@30970
  1893
         ("Eval_Method.eval_ref", Eval_Method.eval_ref) (K I) thy t' [] 
haftmann@30929
  1894
       then Thm.capply (Thm.capply @{cterm "op \<equiv> \<Colon> prop \<Rightarrow> prop \<Rightarrow> prop"} ct) dummy
haftmann@30929
  1895
       else dummy
haftmann@30929
  1896
    | NONE => dummy
haftmann@30929
  1897
  end
haftmann@30929
  1898
*}
haftmann@30929
  1899
haftmann@30929
  1900
ML {*
haftmann@30929
  1901
fun gen_eval_method conv ctxt = SIMPLE_METHOD'
haftmann@30929
  1902
  (CONVERSION (Conv.params_conv (~1) (K (Conv.concl_conv (~1) conv)) ctxt)
haftmann@30929
  1903
    THEN' rtac TrueI)
haftmann@30929
  1904
*}
haftmann@30929
  1905
haftmann@30929
  1906
method_setup eval = {* Scan.succeed (gen_eval_method eval_oracle) *}
haftmann@30929
  1907
  "solve goal by evaluation"
haftmann@30929
  1908
haftmann@30929
  1909
method_setup evaluation = {* Scan.succeed (gen_eval_method Codegen.evaluation_conv) *}
haftmann@30929
  1910
  "solve goal by evaluation"
haftmann@30929
  1911
haftmann@30929
  1912
method_setup normalization = {*
haftmann@30929
  1913
  Scan.succeed (K (SIMPLE_METHOD' (CONVERSION Nbe.norm_conv THEN' (fn k => TRY (rtac TrueI k)))))
haftmann@30929
  1914
*} "solve goal by normalization"
haftmann@30929
  1915
haftmann@30929
  1916
subsubsection {* Quickcheck *}
haftmann@30929
  1917
haftmann@30929
  1918
setup {*
haftmann@30929
  1919
  Quickcheck.add_generator ("SML", Codegen.test_term)
haftmann@30929
  1920
*}
haftmann@30929
  1921
haftmann@30929
  1922
quickcheck_params [size = 5, iterations = 50]
haftmann@30929
  1923
haftmann@23247
  1924
wenzelm@30981
  1925
subsection {* Nitpick setup *}
blanchet@30309
  1926
blanchet@30309
  1927
text {* This will be relocated once Nitpick is moved to HOL. *}
blanchet@30309
  1928
blanchet@29800
  1929
ML {*
blanchet@30254
  1930
structure Nitpick_Const_Def_Thms = NamedThmsFun
blanchet@30254
  1931
(
blanchet@30254
  1932
  val name = "nitpick_const_def"
blanchet@30254
  1933
  val description = "alternative definitions of constants as needed by Nitpick"
blanchet@30254
  1934
)
blanchet@29803
  1935
structure Nitpick_Const_Simp_Thms = NamedThmsFun
blanchet@29800
  1936
(
blanchet@29803
  1937
  val name = "nitpick_const_simp"
blanchet@29806
  1938
  val description = "equational specification of constants as needed by Nitpick"
blanchet@29800
  1939
)
blanchet@29803
  1940
structure Nitpick_Const_Psimp_Thms = NamedThmsFun
blanchet@29800
  1941
(
blanchet@29803
  1942
  val name = "nitpick_const_psimp"
blanchet@29806
  1943
  val description = "partial equational specification of constants as needed by Nitpick"
blanchet@29800
  1944
)
blanchet@29805
  1945
structure Nitpick_Ind_Intro_Thms = NamedThmsFun
blanchet@29805
  1946
(
blanchet@29805
  1947
  val name = "nitpick_ind_intro"
blanchet@29806
  1948
  val description = "introduction rules for (co)inductive predicates as needed by Nitpick"
blanchet@29805
  1949
)
blanchet@29800
  1950
*}
wenzelm@30981
  1951
wenzelm@30981
  1952
setup {*
wenzelm@30981
  1953
  Nitpick_Const_Def_Thms.setup
wenzelm@30981
  1954
  #> Nitpick_Const_Simp_Thms.setup
wenzelm@30981
  1955
  #> Nitpick_Const_Psimp_Thms.setup
wenzelm@30981
  1956
  #> Nitpick_Ind_Intro_Thms.setup
wenzelm@30981
  1957
*}
wenzelm@30981
  1958
blanchet@29800
  1959
haftmann@22839
  1960
subsection {* Legacy tactics and ML bindings *}
wenzelm@21671
  1961
wenzelm@21671
  1962
ML {*
wenzelm@21671
  1963
fun strip_tac i = REPEAT (resolve_tac [impI, allI] i);
wenzelm@21671
  1964
wenzelm@21671
  1965
(* combination of (spec RS spec RS ...(j times) ... spec RS mp) *)
wenzelm@21671
  1966
local
wenzelm@21671
  1967
  fun wrong_prem (Const ("All", _) $ (Abs (_, _, t))) = wrong_prem t
wenzelm@21671
  1968
    | wrong_prem (Bound _) = true
wenzelm@21671
  1969
    | wrong_prem _ = false;
wenzelm@21671
  1970
  val filter_right = filter (not o wrong_prem o HOLogic.dest_Trueprop o hd o Thm.prems_of);
wenzelm@21671
  1971
in
wenzelm@21671
  1972
  fun smp i = funpow i (fn m => filter_right ([spec] RL m)) ([mp]);
wenzelm@21671
  1973
  fun smp_tac j = EVERY'[dresolve_tac (smp j), atac];
wenzelm@21671
  1974
end;
haftmann@22839
  1975
haftmann@22839
  1976
val all_conj_distrib = thm "all_conj_distrib";
haftmann@22839
  1977
val all_simps = thms "all_simps";
haftmann@22839
  1978
val atomize_not = thm "atomize_not";
wenzelm@24830
  1979
val case_split = thm "case_split";
haftmann@22839
  1980
val cases_simp = thm "cases_simp";
haftmann@22839
  1981
val choice_eq = thm "choice_eq"
haftmann@22839
  1982
val cong = thm "cong"
haftmann@22839
  1983
val conj_comms = thms "conj_comms";
haftmann@22839
  1984
val conj_cong = thm "conj_cong";
haftmann@22839
  1985
val de_Morgan_conj = thm "de_Morgan_conj";
haftmann@22839
  1986
val de_Morgan_disj = thm "de_Morgan_disj";
haftmann@22839
  1987
val disj_assoc = thm "disj_assoc";
haftmann@22839
  1988
val disj_comms = thms "disj_comms";
haftmann@22839
  1989
val disj_cong = thm "disj_cong";
haftmann@22839
  1990
val eq_ac = thms "eq_ac";
haftmann@22839
  1991
val eq_cong2 = thm "eq_cong2"
haftmann@22839
  1992
val Eq_FalseI = thm "Eq_FalseI";
haftmann@22839
  1993
val Eq_TrueI = thm "Eq_TrueI";
haftmann@22839
  1994
val Ex1_def = thm "Ex1_def"
haftmann@22839
  1995
val ex_disj_distrib = thm "ex_disj_distrib";
haftmann@22839
  1996
val ex_simps = thms "ex_simps";
haftmann@22839
  1997
val if_cancel = thm "if_cancel";
haftmann@22839
  1998
val if_eq_cancel = thm "if_eq_cancel";
haftmann@22839
  1999
val if_False = thm "if_False";
haftmann@22839
  2000
val iff_conv_conj_imp = thm "iff_conv_conj_imp";
haftmann@22839
  2001
val iff = thm "iff"
haftmann@22839
  2002
val if_splits = thms "if_splits";
haftmann@22839
  2003
val if_True = thm "if_True";
haftmann@22839
  2004
val if_weak_cong = thm "if_weak_cong"
haftmann@22839
  2005
val imp_all = thm "imp_all";
haftmann@22839
  2006
val imp_cong = thm "imp_cong";
haftmann@22839
  2007
val imp_conjL = thm "imp_conjL";
haftmann@22839
  2008
val imp_conjR = thm "imp_conjR";
haftmann@22839
  2009
val imp_conv_disj = thm "imp_conv_disj";
haftmann@22839
  2010
val simp_implies_def = thm "simp_implies_def";
haftmann@22839
  2011
val simp_thms = thms "simp_thms";
haftmann@22839
  2012
val split_if = thm "split_if";
haftmann@22839
  2013
val the1_equality = thm "the1_equality"
haftmann@22839
  2014
val theI = thm "theI"
haftmann@22839
  2015
val theI' = thm "theI'"
haftmann@22839
  2016
val True_implies_equals = thm "True_implies_equals";
chaieb@23037
  2017
val nnf_conv = Simplifier.rewrite (HOL_basic_ss addsimps simp_thms @ @{thms "nnf_simps"})
chaieb@23037
  2018
wenzelm@21671
  2019
*}
wenzelm@21671
  2020
kleing@14357
  2021
end