src/FOL/IFOL.thy
author wenzelm
Sat Mar 15 22:07:25 2008 +0100 (2008-03-15)
changeset 26286 3ff5d257f175
parent 24830 a7b3ab44d993
child 26580 c3e597a476fd
permissions -rw-r--r--
added lemmas from simpdata.ML;
clasohm@1268
     1
(*  Title:      FOL/IFOL.thy
lcp@35
     2
    ID:         $Id$
wenzelm@11677
     3
    Author:     Lawrence C Paulson and Markus Wenzel
wenzelm@11677
     4
*)
lcp@35
     5
wenzelm@11677
     6
header {* Intuitionistic first-order logic *}
lcp@35
     7
paulson@15481
     8
theory IFOL
paulson@15481
     9
imports Pure
wenzelm@23155
    10
uses
wenzelm@23155
    11
  "~~/src/Provers/splitter.ML"
wenzelm@23155
    12
  "~~/src/Provers/hypsubst.ML"
wenzelm@23171
    13
  "~~/src/Tools/IsaPlanner/zipper.ML"
wenzelm@23171
    14
  "~~/src/Tools/IsaPlanner/isand.ML"
wenzelm@23171
    15
  "~~/src/Tools/IsaPlanner/rw_tools.ML"
wenzelm@23171
    16
  "~~/src/Tools/IsaPlanner/rw_inst.ML"
wenzelm@23155
    17
  "~~/src/Provers/eqsubst.ML"
wenzelm@23155
    18
  "~~/src/Provers/quantifier1.ML"
wenzelm@23155
    19
  "~~/src/Provers/project_rule.ML"
wenzelm@23155
    20
  ("fologic.ML")
wenzelm@23155
    21
  ("hypsubstdata.ML")
wenzelm@23155
    22
  ("intprover.ML")
paulson@15481
    23
begin
wenzelm@7355
    24
clasohm@0
    25
wenzelm@11677
    26
subsection {* Syntax and axiomatic basis *}
wenzelm@11677
    27
wenzelm@3906
    28
global
wenzelm@3906
    29
wenzelm@14854
    30
classes "term"
wenzelm@7355
    31
defaultsort "term"
clasohm@0
    32
wenzelm@7355
    33
typedecl o
wenzelm@79
    34
wenzelm@11747
    35
judgment
wenzelm@11747
    36
  Trueprop      :: "o => prop"                  ("(_)" 5)
clasohm@0
    37
wenzelm@11747
    38
consts
wenzelm@7355
    39
  True          :: o
wenzelm@7355
    40
  False         :: o
wenzelm@79
    41
wenzelm@79
    42
  (* Connectives *)
wenzelm@79
    43
wenzelm@17276
    44
  "op ="        :: "['a, 'a] => o"              (infixl "=" 50)
lcp@35
    45
wenzelm@7355
    46
  Not           :: "o => o"                     ("~ _" [40] 40)
wenzelm@17276
    47
  "op &"        :: "[o, o] => o"                (infixr "&" 35)
wenzelm@17276
    48
  "op |"        :: "[o, o] => o"                (infixr "|" 30)
wenzelm@17276
    49
  "op -->"      :: "[o, o] => o"                (infixr "-->" 25)
wenzelm@17276
    50
  "op <->"      :: "[o, o] => o"                (infixr "<->" 25)
wenzelm@79
    51
wenzelm@79
    52
  (* Quantifiers *)
wenzelm@79
    53
wenzelm@7355
    54
  All           :: "('a => o) => o"             (binder "ALL " 10)
wenzelm@7355
    55
  Ex            :: "('a => o) => o"             (binder "EX " 10)
wenzelm@7355
    56
  Ex1           :: "('a => o) => o"             (binder "EX! " 10)
wenzelm@79
    57
clasohm@0
    58
wenzelm@19363
    59
abbreviation
wenzelm@21404
    60
  not_equal :: "['a, 'a] => o"  (infixl "~=" 50) where
wenzelm@19120
    61
  "x ~= y == ~ (x = y)"
wenzelm@79
    62
wenzelm@21210
    63
notation (xsymbols)
wenzelm@19656
    64
  not_equal  (infixl "\<noteq>" 50)
wenzelm@19363
    65
wenzelm@21210
    66
notation (HTML output)
wenzelm@19656
    67
  not_equal  (infixl "\<noteq>" 50)
wenzelm@19363
    68
wenzelm@21524
    69
notation (xsymbols)
wenzelm@21539
    70
  Not       ("\<not> _" [40] 40) and
wenzelm@21539
    71
  "op &"    (infixr "\<and>" 35) and
wenzelm@21539
    72
  "op |"    (infixr "\<or>" 30) and
wenzelm@21539
    73
  All       (binder "\<forall>" 10) and
wenzelm@21539
    74
  Ex        (binder "\<exists>" 10) and
wenzelm@21539
    75
  Ex1       (binder "\<exists>!" 10) and
wenzelm@21524
    76
  "op -->"  (infixr "\<longrightarrow>" 25) and
wenzelm@21524
    77
  "op <->"  (infixr "\<longleftrightarrow>" 25)
lcp@35
    78
wenzelm@21524
    79
notation (HTML output)
wenzelm@21539
    80
  Not       ("\<not> _" [40] 40) and
wenzelm@21539
    81
  "op &"    (infixr "\<and>" 35) and
wenzelm@21539
    82
  "op |"    (infixr "\<or>" 30) and
wenzelm@21539
    83
  All       (binder "\<forall>" 10) and
wenzelm@21539
    84
  Ex        (binder "\<exists>" 10) and
wenzelm@21539
    85
  Ex1       (binder "\<exists>!" 10)
wenzelm@6340
    86
wenzelm@3932
    87
local
wenzelm@3906
    88
paulson@14236
    89
finalconsts
paulson@14236
    90
  False All Ex
paulson@14236
    91
  "op ="
paulson@14236
    92
  "op &"
paulson@14236
    93
  "op |"
paulson@14236
    94
  "op -->"
paulson@14236
    95
wenzelm@7355
    96
axioms
clasohm@0
    97
wenzelm@79
    98
  (* Equality *)
clasohm@0
    99
wenzelm@7355
   100
  refl:         "a=a"
clasohm@0
   101
wenzelm@79
   102
  (* Propositional logic *)
clasohm@0
   103
wenzelm@7355
   104
  conjI:        "[| P;  Q |] ==> P&Q"
wenzelm@7355
   105
  conjunct1:    "P&Q ==> P"
wenzelm@7355
   106
  conjunct2:    "P&Q ==> Q"
clasohm@0
   107
wenzelm@7355
   108
  disjI1:       "P ==> P|Q"
wenzelm@7355
   109
  disjI2:       "Q ==> P|Q"
wenzelm@7355
   110
  disjE:        "[| P|Q;  P ==> R;  Q ==> R |] ==> R"
clasohm@0
   111
wenzelm@7355
   112
  impI:         "(P ==> Q) ==> P-->Q"
wenzelm@7355
   113
  mp:           "[| P-->Q;  P |] ==> Q"
clasohm@0
   114
wenzelm@7355
   115
  FalseE:       "False ==> P"
wenzelm@7355
   116
wenzelm@79
   117
  (* Quantifiers *)
clasohm@0
   118
wenzelm@7355
   119
  allI:         "(!!x. P(x)) ==> (ALL x. P(x))"
wenzelm@7355
   120
  spec:         "(ALL x. P(x)) ==> P(x)"
clasohm@0
   121
wenzelm@7355
   122
  exI:          "P(x) ==> (EX x. P(x))"
wenzelm@7355
   123
  exE:          "[| EX x. P(x);  !!x. P(x) ==> R |] ==> R"
clasohm@0
   124
clasohm@0
   125
  (* Reflection *)
clasohm@0
   126
wenzelm@7355
   127
  eq_reflection:  "(x=y)   ==> (x==y)"
wenzelm@7355
   128
  iff_reflection: "(P<->Q) ==> (P==Q)"
clasohm@0
   129
wenzelm@4092
   130
wenzelm@19756
   131
lemmas strip = impI allI
wenzelm@19756
   132
wenzelm@19756
   133
paulson@15377
   134
text{*Thanks to Stephan Merz*}
paulson@15377
   135
theorem subst:
paulson@15377
   136
  assumes eq: "a = b" and p: "P(a)"
paulson@15377
   137
  shows "P(b)"
paulson@15377
   138
proof -
paulson@15377
   139
  from eq have meta: "a \<equiv> b"
paulson@15377
   140
    by (rule eq_reflection)
paulson@15377
   141
  from p show ?thesis
paulson@15377
   142
    by (unfold meta)
paulson@15377
   143
qed
paulson@15377
   144
paulson@15377
   145
paulson@14236
   146
defs
paulson@14236
   147
  (* Definitions *)
paulson@14236
   148
paulson@14236
   149
  True_def:     "True  == False-->False"
paulson@14236
   150
  not_def:      "~P    == P-->False"
paulson@14236
   151
  iff_def:      "P<->Q == (P-->Q) & (Q-->P)"
paulson@14236
   152
paulson@14236
   153
  (* Unique existence *)
paulson@14236
   154
paulson@14236
   155
  ex1_def:      "Ex1(P) == EX x. P(x) & (ALL y. P(y) --> y=x)"
paulson@14236
   156
paulson@13779
   157
wenzelm@11677
   158
subsection {* Lemmas and proof tools *}
wenzelm@11677
   159
wenzelm@21539
   160
lemma TrueI: True
wenzelm@21539
   161
  unfolding True_def by (rule impI)
wenzelm@21539
   162
wenzelm@21539
   163
wenzelm@21539
   164
(*** Sequent-style elimination rules for & --> and ALL ***)
wenzelm@21539
   165
wenzelm@21539
   166
lemma conjE:
wenzelm@21539
   167
  assumes major: "P & Q"
wenzelm@21539
   168
    and r: "[| P; Q |] ==> R"
wenzelm@21539
   169
  shows R
wenzelm@21539
   170
  apply (rule r)
wenzelm@21539
   171
   apply (rule major [THEN conjunct1])
wenzelm@21539
   172
  apply (rule major [THEN conjunct2])
wenzelm@21539
   173
  done
wenzelm@21539
   174
wenzelm@21539
   175
lemma impE:
wenzelm@21539
   176
  assumes major: "P --> Q"
wenzelm@21539
   177
    and P
wenzelm@21539
   178
  and r: "Q ==> R"
wenzelm@21539
   179
  shows R
wenzelm@21539
   180
  apply (rule r)
wenzelm@21539
   181
  apply (rule major [THEN mp])
wenzelm@21539
   182
  apply (rule `P`)
wenzelm@21539
   183
  done
wenzelm@21539
   184
wenzelm@21539
   185
lemma allE:
wenzelm@21539
   186
  assumes major: "ALL x. P(x)"
wenzelm@21539
   187
    and r: "P(x) ==> R"
wenzelm@21539
   188
  shows R
wenzelm@21539
   189
  apply (rule r)
wenzelm@21539
   190
  apply (rule major [THEN spec])
wenzelm@21539
   191
  done
wenzelm@21539
   192
wenzelm@21539
   193
(*Duplicates the quantifier; for use with eresolve_tac*)
wenzelm@21539
   194
lemma all_dupE:
wenzelm@21539
   195
  assumes major: "ALL x. P(x)"
wenzelm@21539
   196
    and r: "[| P(x); ALL x. P(x) |] ==> R"
wenzelm@21539
   197
  shows R
wenzelm@21539
   198
  apply (rule r)
wenzelm@21539
   199
   apply (rule major [THEN spec])
wenzelm@21539
   200
  apply (rule major)
wenzelm@21539
   201
  done
wenzelm@21539
   202
wenzelm@21539
   203
wenzelm@21539
   204
(*** Negation rules, which translate between ~P and P-->False ***)
wenzelm@21539
   205
wenzelm@21539
   206
lemma notI: "(P ==> False) ==> ~P"
wenzelm@21539
   207
  unfolding not_def by (erule impI)
wenzelm@21539
   208
wenzelm@21539
   209
lemma notE: "[| ~P;  P |] ==> R"
wenzelm@21539
   210
  unfolding not_def by (erule mp [THEN FalseE])
wenzelm@21539
   211
wenzelm@21539
   212
lemma rev_notE: "[| P; ~P |] ==> R"
wenzelm@21539
   213
  by (erule notE)
wenzelm@21539
   214
wenzelm@21539
   215
(*This is useful with the special implication rules for each kind of P. *)
wenzelm@21539
   216
lemma not_to_imp:
wenzelm@21539
   217
  assumes "~P"
wenzelm@21539
   218
    and r: "P --> False ==> Q"
wenzelm@21539
   219
  shows Q
wenzelm@21539
   220
  apply (rule r)
wenzelm@21539
   221
  apply (rule impI)
wenzelm@21539
   222
  apply (erule notE [OF `~P`])
wenzelm@21539
   223
  done
wenzelm@21539
   224
wenzelm@21539
   225
(* For substitution into an assumption P, reduce Q to P-->Q, substitute into
wenzelm@21539
   226
   this implication, then apply impI to move P back into the assumptions.
wenzelm@21539
   227
   To specify P use something like
wenzelm@21539
   228
      eres_inst_tac [ ("P","ALL y. ?S(x,y)") ] rev_mp 1   *)
wenzelm@21539
   229
lemma rev_mp: "[| P;  P --> Q |] ==> Q"
wenzelm@21539
   230
  by (erule mp)
wenzelm@21539
   231
wenzelm@21539
   232
(*Contrapositive of an inference rule*)
wenzelm@21539
   233
lemma contrapos:
wenzelm@21539
   234
  assumes major: "~Q"
wenzelm@21539
   235
    and minor: "P ==> Q"
wenzelm@21539
   236
  shows "~P"
wenzelm@21539
   237
  apply (rule major [THEN notE, THEN notI])
wenzelm@21539
   238
  apply (erule minor)
wenzelm@21539
   239
  done
wenzelm@21539
   240
wenzelm@21539
   241
wenzelm@21539
   242
(*** Modus Ponens Tactics ***)
wenzelm@21539
   243
wenzelm@21539
   244
(*Finds P-->Q and P in the assumptions, replaces implication by Q *)
wenzelm@21539
   245
ML {*
wenzelm@22139
   246
  fun mp_tac i = eresolve_tac [@{thm notE}, @{thm impE}] i  THEN  assume_tac i
wenzelm@22139
   247
  fun eq_mp_tac i = eresolve_tac [@{thm notE}, @{thm impE}] i  THEN  eq_assume_tac i
wenzelm@21539
   248
*}
wenzelm@21539
   249
wenzelm@21539
   250
wenzelm@21539
   251
(*** If-and-only-if ***)
wenzelm@21539
   252
wenzelm@21539
   253
lemma iffI: "[| P ==> Q; Q ==> P |] ==> P<->Q"
wenzelm@21539
   254
  apply (unfold iff_def)
wenzelm@21539
   255
  apply (rule conjI)
wenzelm@21539
   256
   apply (erule impI)
wenzelm@21539
   257
  apply (erule impI)
wenzelm@21539
   258
  done
wenzelm@21539
   259
wenzelm@21539
   260
wenzelm@21539
   261
(*Observe use of rewrite_rule to unfold "<->" in meta-assumptions (prems) *)
wenzelm@21539
   262
lemma iffE:
wenzelm@21539
   263
  assumes major: "P <-> Q"
wenzelm@21539
   264
    and r: "P-->Q ==> Q-->P ==> R"
wenzelm@21539
   265
  shows R
wenzelm@21539
   266
  apply (insert major, unfold iff_def)
wenzelm@21539
   267
  apply (erule conjE)
wenzelm@21539
   268
  apply (erule r)
wenzelm@21539
   269
  apply assumption
wenzelm@21539
   270
  done
wenzelm@21539
   271
wenzelm@21539
   272
(* Destruct rules for <-> similar to Modus Ponens *)
wenzelm@21539
   273
wenzelm@21539
   274
lemma iffD1: "[| P <-> Q;  P |] ==> Q"
wenzelm@21539
   275
  apply (unfold iff_def)
wenzelm@21539
   276
  apply (erule conjunct1 [THEN mp])
wenzelm@21539
   277
  apply assumption
wenzelm@21539
   278
  done
wenzelm@21539
   279
wenzelm@21539
   280
lemma iffD2: "[| P <-> Q;  Q |] ==> P"
wenzelm@21539
   281
  apply (unfold iff_def)
wenzelm@21539
   282
  apply (erule conjunct2 [THEN mp])
wenzelm@21539
   283
  apply assumption
wenzelm@21539
   284
  done
wenzelm@21539
   285
wenzelm@21539
   286
lemma rev_iffD1: "[| P; P <-> Q |] ==> Q"
wenzelm@21539
   287
  apply (erule iffD1)
wenzelm@21539
   288
  apply assumption
wenzelm@21539
   289
  done
wenzelm@21539
   290
wenzelm@21539
   291
lemma rev_iffD2: "[| Q; P <-> Q |] ==> P"
wenzelm@21539
   292
  apply (erule iffD2)
wenzelm@21539
   293
  apply assumption
wenzelm@21539
   294
  done
wenzelm@21539
   295
wenzelm@21539
   296
lemma iff_refl: "P <-> P"
wenzelm@21539
   297
  by (rule iffI)
wenzelm@21539
   298
wenzelm@21539
   299
lemma iff_sym: "Q <-> P ==> P <-> Q"
wenzelm@21539
   300
  apply (erule iffE)
wenzelm@21539
   301
  apply (rule iffI)
wenzelm@21539
   302
  apply (assumption | erule mp)+
wenzelm@21539
   303
  done
wenzelm@21539
   304
wenzelm@21539
   305
lemma iff_trans: "[| P <-> Q;  Q<-> R |] ==> P <-> R"
wenzelm@21539
   306
  apply (rule iffI)
wenzelm@21539
   307
  apply (assumption | erule iffE | erule (1) notE impE)+
wenzelm@21539
   308
  done
wenzelm@21539
   309
wenzelm@21539
   310
wenzelm@21539
   311
(*** Unique existence.  NOTE THAT the following 2 quantifications
wenzelm@21539
   312
   EX!x such that [EX!y such that P(x,y)]     (sequential)
wenzelm@21539
   313
   EX!x,y such that P(x,y)                    (simultaneous)
wenzelm@21539
   314
 do NOT mean the same thing.  The parser treats EX!x y.P(x,y) as sequential.
wenzelm@21539
   315
***)
wenzelm@21539
   316
wenzelm@21539
   317
lemma ex1I:
wenzelm@23393
   318
  "P(a) \<Longrightarrow> (!!x. P(x) ==> x=a) \<Longrightarrow> EX! x. P(x)"
wenzelm@21539
   319
  apply (unfold ex1_def)
wenzelm@23393
   320
  apply (assumption | rule exI conjI allI impI)+
wenzelm@21539
   321
  done
wenzelm@21539
   322
wenzelm@21539
   323
(*Sometimes easier to use: the premises have no shared variables.  Safe!*)
wenzelm@21539
   324
lemma ex_ex1I:
wenzelm@23393
   325
  "EX x. P(x) \<Longrightarrow> (!!x y. [| P(x); P(y) |] ==> x=y) \<Longrightarrow> EX! x. P(x)"
wenzelm@23393
   326
  apply (erule exE)
wenzelm@23393
   327
  apply (rule ex1I)
wenzelm@23393
   328
   apply assumption
wenzelm@23393
   329
  apply assumption
wenzelm@21539
   330
  done
wenzelm@21539
   331
wenzelm@21539
   332
lemma ex1E:
wenzelm@23393
   333
  "EX! x. P(x) \<Longrightarrow> (!!x. [| P(x);  ALL y. P(y) --> y=x |] ==> R) \<Longrightarrow> R"
wenzelm@23393
   334
  apply (unfold ex1_def)
wenzelm@21539
   335
  apply (assumption | erule exE conjE)+
wenzelm@21539
   336
  done
wenzelm@21539
   337
wenzelm@21539
   338
wenzelm@21539
   339
(*** <-> congruence rules for simplification ***)
wenzelm@21539
   340
wenzelm@21539
   341
(*Use iffE on a premise.  For conj_cong, imp_cong, all_cong, ex_cong*)
wenzelm@21539
   342
ML {*
wenzelm@22139
   343
  fun iff_tac prems i =
wenzelm@22139
   344
    resolve_tac (prems RL @{thms iffE}) i THEN
wenzelm@22139
   345
    REPEAT1 (eresolve_tac [@{thm asm_rl}, @{thm mp}] i)
wenzelm@21539
   346
*}
wenzelm@21539
   347
wenzelm@21539
   348
lemma conj_cong:
wenzelm@21539
   349
  assumes "P <-> P'"
wenzelm@21539
   350
    and "P' ==> Q <-> Q'"
wenzelm@21539
   351
  shows "(P&Q) <-> (P'&Q')"
wenzelm@21539
   352
  apply (insert assms)
wenzelm@21539
   353
  apply (assumption | rule iffI conjI | erule iffE conjE mp |
wenzelm@21539
   354
    tactic {* iff_tac (thms "assms") 1 *})+
wenzelm@21539
   355
  done
wenzelm@21539
   356
wenzelm@21539
   357
(*Reversed congruence rule!   Used in ZF/Order*)
wenzelm@21539
   358
lemma conj_cong2:
wenzelm@21539
   359
  assumes "P <-> P'"
wenzelm@21539
   360
    and "P' ==> Q <-> Q'"
wenzelm@21539
   361
  shows "(Q&P) <-> (Q'&P')"
wenzelm@21539
   362
  apply (insert assms)
wenzelm@21539
   363
  apply (assumption | rule iffI conjI | erule iffE conjE mp |
wenzelm@21539
   364
    tactic {* iff_tac (thms "assms") 1 *})+
wenzelm@21539
   365
  done
wenzelm@21539
   366
wenzelm@21539
   367
lemma disj_cong:
wenzelm@21539
   368
  assumes "P <-> P'" and "Q <-> Q'"
wenzelm@21539
   369
  shows "(P|Q) <-> (P'|Q')"
wenzelm@21539
   370
  apply (insert assms)
wenzelm@21539
   371
  apply (erule iffE disjE disjI1 disjI2 | assumption | rule iffI | erule (1) notE impE)+
wenzelm@21539
   372
  done
wenzelm@21539
   373
wenzelm@21539
   374
lemma imp_cong:
wenzelm@21539
   375
  assumes "P <-> P'"
wenzelm@21539
   376
    and "P' ==> Q <-> Q'"
wenzelm@21539
   377
  shows "(P-->Q) <-> (P'-->Q')"
wenzelm@21539
   378
  apply (insert assms)
wenzelm@21539
   379
  apply (assumption | rule iffI impI | erule iffE | erule (1) notE impE |
wenzelm@21539
   380
    tactic {* iff_tac (thms "assms") 1 *})+
wenzelm@21539
   381
  done
wenzelm@21539
   382
wenzelm@21539
   383
lemma iff_cong: "[| P <-> P'; Q <-> Q' |] ==> (P<->Q) <-> (P'<->Q')"
wenzelm@21539
   384
  apply (erule iffE | assumption | rule iffI | erule (1) notE impE)+
wenzelm@21539
   385
  done
wenzelm@21539
   386
wenzelm@21539
   387
lemma not_cong: "P <-> P' ==> ~P <-> ~P'"
wenzelm@21539
   388
  apply (assumption | rule iffI notI | erule (1) notE impE | erule iffE notE)+
wenzelm@21539
   389
  done
wenzelm@21539
   390
wenzelm@21539
   391
lemma all_cong:
wenzelm@21539
   392
  assumes "!!x. P(x) <-> Q(x)"
wenzelm@21539
   393
  shows "(ALL x. P(x)) <-> (ALL x. Q(x))"
wenzelm@21539
   394
  apply (assumption | rule iffI allI | erule (1) notE impE | erule allE |
wenzelm@21539
   395
    tactic {* iff_tac (thms "assms") 1 *})+
wenzelm@21539
   396
  done
wenzelm@21539
   397
wenzelm@21539
   398
lemma ex_cong:
wenzelm@21539
   399
  assumes "!!x. P(x) <-> Q(x)"
wenzelm@21539
   400
  shows "(EX x. P(x)) <-> (EX x. Q(x))"
wenzelm@21539
   401
  apply (erule exE | assumption | rule iffI exI | erule (1) notE impE |
wenzelm@21539
   402
    tactic {* iff_tac (thms "assms") 1 *})+
wenzelm@21539
   403
  done
wenzelm@21539
   404
wenzelm@21539
   405
lemma ex1_cong:
wenzelm@21539
   406
  assumes "!!x. P(x) <-> Q(x)"
wenzelm@21539
   407
  shows "(EX! x. P(x)) <-> (EX! x. Q(x))"
wenzelm@21539
   408
  apply (erule ex1E spec [THEN mp] | assumption | rule iffI ex1I | erule (1) notE impE |
wenzelm@21539
   409
    tactic {* iff_tac (thms "assms") 1 *})+
wenzelm@21539
   410
  done
wenzelm@21539
   411
wenzelm@21539
   412
(*** Equality rules ***)
wenzelm@21539
   413
wenzelm@21539
   414
lemma sym: "a=b ==> b=a"
wenzelm@21539
   415
  apply (erule subst)
wenzelm@21539
   416
  apply (rule refl)
wenzelm@21539
   417
  done
wenzelm@21539
   418
wenzelm@21539
   419
lemma trans: "[| a=b;  b=c |] ==> a=c"
wenzelm@21539
   420
  apply (erule subst, assumption)
wenzelm@21539
   421
  done
wenzelm@21539
   422
wenzelm@21539
   423
(**  **)
wenzelm@21539
   424
lemma not_sym: "b ~= a ==> a ~= b"
wenzelm@21539
   425
  apply (erule contrapos)
wenzelm@21539
   426
  apply (erule sym)
wenzelm@21539
   427
  done
wenzelm@21539
   428
  
wenzelm@21539
   429
(* Two theorms for rewriting only one instance of a definition:
wenzelm@21539
   430
   the first for definitions of formulae and the second for terms *)
wenzelm@21539
   431
wenzelm@21539
   432
lemma def_imp_iff: "(A == B) ==> A <-> B"
wenzelm@21539
   433
  apply unfold
wenzelm@21539
   434
  apply (rule iff_refl)
wenzelm@21539
   435
  done
wenzelm@21539
   436
wenzelm@21539
   437
lemma meta_eq_to_obj_eq: "(A == B) ==> A = B"
wenzelm@21539
   438
  apply unfold
wenzelm@21539
   439
  apply (rule refl)
wenzelm@21539
   440
  done
wenzelm@21539
   441
wenzelm@21539
   442
lemma meta_eq_to_iff: "x==y ==> x<->y"
wenzelm@21539
   443
  by unfold (rule iff_refl)
wenzelm@21539
   444
wenzelm@21539
   445
(*substitution*)
wenzelm@21539
   446
lemma ssubst: "[| b = a; P(a) |] ==> P(b)"
wenzelm@21539
   447
  apply (drule sym)
wenzelm@21539
   448
  apply (erule (1) subst)
wenzelm@21539
   449
  done
wenzelm@21539
   450
wenzelm@21539
   451
(*A special case of ex1E that would otherwise need quantifier expansion*)
wenzelm@21539
   452
lemma ex1_equalsE:
wenzelm@21539
   453
    "[| EX! x. P(x);  P(a);  P(b) |] ==> a=b"
wenzelm@21539
   454
  apply (erule ex1E)
wenzelm@21539
   455
  apply (rule trans)
wenzelm@21539
   456
   apply (rule_tac [2] sym)
wenzelm@21539
   457
   apply (assumption | erule spec [THEN mp])+
wenzelm@21539
   458
  done
wenzelm@21539
   459
wenzelm@21539
   460
(** Polymorphic congruence rules **)
wenzelm@21539
   461
wenzelm@21539
   462
lemma subst_context: "[| a=b |]  ==>  t(a)=t(b)"
wenzelm@21539
   463
  apply (erule ssubst)
wenzelm@21539
   464
  apply (rule refl)
wenzelm@21539
   465
  done
wenzelm@21539
   466
wenzelm@21539
   467
lemma subst_context2: "[| a=b;  c=d |]  ==>  t(a,c)=t(b,d)"
wenzelm@21539
   468
  apply (erule ssubst)+
wenzelm@21539
   469
  apply (rule refl)
wenzelm@21539
   470
  done
wenzelm@21539
   471
wenzelm@21539
   472
lemma subst_context3: "[| a=b;  c=d;  e=f |]  ==>  t(a,c,e)=t(b,d,f)"
wenzelm@21539
   473
  apply (erule ssubst)+
wenzelm@21539
   474
  apply (rule refl)
wenzelm@21539
   475
  done
wenzelm@21539
   476
wenzelm@21539
   477
(*Useful with eresolve_tac for proving equalties from known equalities.
wenzelm@21539
   478
        a = b
wenzelm@21539
   479
        |   |
wenzelm@21539
   480
        c = d   *)
wenzelm@21539
   481
lemma box_equals: "[| a=b;  a=c;  b=d |] ==> c=d"
wenzelm@21539
   482
  apply (rule trans)
wenzelm@21539
   483
   apply (rule trans)
wenzelm@21539
   484
    apply (rule sym)
wenzelm@21539
   485
    apply assumption+
wenzelm@21539
   486
  done
wenzelm@21539
   487
wenzelm@21539
   488
(*Dual of box_equals: for proving equalities backwards*)
wenzelm@21539
   489
lemma simp_equals: "[| a=c;  b=d;  c=d |] ==> a=b"
wenzelm@21539
   490
  apply (rule trans)
wenzelm@21539
   491
   apply (rule trans)
wenzelm@21539
   492
    apply assumption+
wenzelm@21539
   493
  apply (erule sym)
wenzelm@21539
   494
  done
wenzelm@21539
   495
wenzelm@21539
   496
(** Congruence rules for predicate letters **)
wenzelm@21539
   497
wenzelm@21539
   498
lemma pred1_cong: "a=a' ==> P(a) <-> P(a')"
wenzelm@21539
   499
  apply (rule iffI)
wenzelm@21539
   500
   apply (erule (1) subst)
wenzelm@21539
   501
  apply (erule (1) ssubst)
wenzelm@21539
   502
  done
wenzelm@21539
   503
wenzelm@21539
   504
lemma pred2_cong: "[| a=a';  b=b' |] ==> P(a,b) <-> P(a',b')"
wenzelm@21539
   505
  apply (rule iffI)
wenzelm@21539
   506
   apply (erule subst)+
wenzelm@21539
   507
   apply assumption
wenzelm@21539
   508
  apply (erule ssubst)+
wenzelm@21539
   509
  apply assumption
wenzelm@21539
   510
  done
wenzelm@21539
   511
wenzelm@21539
   512
lemma pred3_cong: "[| a=a';  b=b';  c=c' |] ==> P(a,b,c) <-> P(a',b',c')"
wenzelm@21539
   513
  apply (rule iffI)
wenzelm@21539
   514
   apply (erule subst)+
wenzelm@21539
   515
   apply assumption
wenzelm@21539
   516
  apply (erule ssubst)+
wenzelm@21539
   517
  apply assumption
wenzelm@21539
   518
  done
wenzelm@21539
   519
wenzelm@21539
   520
(*special cases for free variables P, Q, R, S -- up to 3 arguments*)
wenzelm@21539
   521
wenzelm@21539
   522
ML {*
wenzelm@21539
   523
bind_thms ("pred_congs",
wenzelm@21539
   524
  List.concat (map (fn c => 
wenzelm@21539
   525
               map (fn th => read_instantiate [("P",c)] th)
wenzelm@22139
   526
                   [@{thm pred1_cong}, @{thm pred2_cong}, @{thm pred3_cong}])
wenzelm@21539
   527
               (explode"PQRS")))
wenzelm@21539
   528
*}
wenzelm@21539
   529
wenzelm@21539
   530
(*special case for the equality predicate!*)
wenzelm@21539
   531
lemma eq_cong: "[| a = a'; b = b' |] ==> a = b <-> a' = b'"
wenzelm@21539
   532
  apply (erule (1) pred2_cong)
wenzelm@21539
   533
  done
wenzelm@21539
   534
wenzelm@21539
   535
wenzelm@21539
   536
(*** Simplifications of assumed implications.
wenzelm@21539
   537
     Roy Dyckhoff has proved that conj_impE, disj_impE, and imp_impE
wenzelm@21539
   538
     used with mp_tac (restricted to atomic formulae) is COMPLETE for 
wenzelm@21539
   539
     intuitionistic propositional logic.  See
wenzelm@21539
   540
   R. Dyckhoff, Contraction-free sequent calculi for intuitionistic logic
wenzelm@21539
   541
    (preprint, University of St Andrews, 1991)  ***)
wenzelm@21539
   542
wenzelm@21539
   543
lemma conj_impE:
wenzelm@21539
   544
  assumes major: "(P&Q)-->S"
wenzelm@21539
   545
    and r: "P-->(Q-->S) ==> R"
wenzelm@21539
   546
  shows R
wenzelm@21539
   547
  by (assumption | rule conjI impI major [THEN mp] r)+
wenzelm@21539
   548
wenzelm@21539
   549
lemma disj_impE:
wenzelm@21539
   550
  assumes major: "(P|Q)-->S"
wenzelm@21539
   551
    and r: "[| P-->S; Q-->S |] ==> R"
wenzelm@21539
   552
  shows R
wenzelm@21539
   553
  by (assumption | rule disjI1 disjI2 impI major [THEN mp] r)+
wenzelm@21539
   554
wenzelm@21539
   555
(*Simplifies the implication.  Classical version is stronger. 
wenzelm@21539
   556
  Still UNSAFE since Q must be provable -- backtracking needed.  *)
wenzelm@21539
   557
lemma imp_impE:
wenzelm@21539
   558
  assumes major: "(P-->Q)-->S"
wenzelm@21539
   559
    and r1: "[| P; Q-->S |] ==> Q"
wenzelm@21539
   560
    and r2: "S ==> R"
wenzelm@21539
   561
  shows R
wenzelm@21539
   562
  by (assumption | rule impI major [THEN mp] r1 r2)+
wenzelm@21539
   563
wenzelm@21539
   564
(*Simplifies the implication.  Classical version is stronger. 
wenzelm@21539
   565
  Still UNSAFE since ~P must be provable -- backtracking needed.  *)
wenzelm@21539
   566
lemma not_impE:
wenzelm@23393
   567
  "~P --> S \<Longrightarrow> (P ==> False) \<Longrightarrow> (S ==> R) \<Longrightarrow> R"
wenzelm@23393
   568
  apply (drule mp)
wenzelm@23393
   569
   apply (rule notI)
wenzelm@23393
   570
   apply assumption
wenzelm@23393
   571
  apply assumption
wenzelm@21539
   572
  done
wenzelm@21539
   573
wenzelm@21539
   574
(*Simplifies the implication.   UNSAFE.  *)
wenzelm@21539
   575
lemma iff_impE:
wenzelm@21539
   576
  assumes major: "(P<->Q)-->S"
wenzelm@21539
   577
    and r1: "[| P; Q-->S |] ==> Q"
wenzelm@21539
   578
    and r2: "[| Q; P-->S |] ==> P"
wenzelm@21539
   579
    and r3: "S ==> R"
wenzelm@21539
   580
  shows R
wenzelm@21539
   581
  apply (assumption | rule iffI impI major [THEN mp] r1 r2 r3)+
wenzelm@21539
   582
  done
wenzelm@21539
   583
wenzelm@21539
   584
(*What if (ALL x.~~P(x)) --> ~~(ALL x.P(x)) is an assumption? UNSAFE*)
wenzelm@21539
   585
lemma all_impE:
wenzelm@21539
   586
  assumes major: "(ALL x. P(x))-->S"
wenzelm@21539
   587
    and r1: "!!x. P(x)"
wenzelm@21539
   588
    and r2: "S ==> R"
wenzelm@21539
   589
  shows R
wenzelm@23393
   590
  apply (rule allI impI major [THEN mp] r1 r2)+
wenzelm@21539
   591
  done
wenzelm@21539
   592
wenzelm@21539
   593
(*Unsafe: (EX x.P(x))-->S  is equivalent to  ALL x.P(x)-->S.  *)
wenzelm@21539
   594
lemma ex_impE:
wenzelm@21539
   595
  assumes major: "(EX x. P(x))-->S"
wenzelm@21539
   596
    and r: "P(x)-->S ==> R"
wenzelm@21539
   597
  shows R
wenzelm@21539
   598
  apply (assumption | rule exI impI major [THEN mp] r)+
wenzelm@21539
   599
  done
wenzelm@21539
   600
wenzelm@21539
   601
(*** Courtesy of Krzysztof Grabczewski ***)
wenzelm@21539
   602
wenzelm@21539
   603
lemma disj_imp_disj:
wenzelm@23393
   604
  "P|Q \<Longrightarrow> (P==>R) \<Longrightarrow> (Q==>S) \<Longrightarrow> R|S"
wenzelm@23393
   605
  apply (erule disjE)
wenzelm@21539
   606
  apply (rule disjI1) apply assumption
wenzelm@21539
   607
  apply (rule disjI2) apply assumption
wenzelm@21539
   608
  done
wenzelm@11734
   609
wenzelm@18481
   610
ML {*
wenzelm@18481
   611
structure ProjectRule = ProjectRuleFun
wenzelm@18481
   612
(struct
wenzelm@22139
   613
  val conjunct1 = @{thm conjunct1}
wenzelm@22139
   614
  val conjunct2 = @{thm conjunct2}
wenzelm@22139
   615
  val mp = @{thm mp}
wenzelm@18481
   616
end)
wenzelm@18481
   617
*}
wenzelm@18481
   618
wenzelm@7355
   619
use "fologic.ML"
wenzelm@21539
   620
wenzelm@21539
   621
lemma thin_refl: "!!X. [|x=x; PROP W|] ==> PROP W" .
wenzelm@21539
   622
wenzelm@9886
   623
use "hypsubstdata.ML"
wenzelm@9886
   624
setup hypsubst_setup
wenzelm@7355
   625
use "intprover.ML"
wenzelm@7355
   626
wenzelm@4092
   627
wenzelm@12875
   628
subsection {* Intuitionistic Reasoning *}
wenzelm@12368
   629
wenzelm@12349
   630
lemma impE':
wenzelm@12937
   631
  assumes 1: "P --> Q"
wenzelm@12937
   632
    and 2: "Q ==> R"
wenzelm@12937
   633
    and 3: "P --> Q ==> P"
wenzelm@12937
   634
  shows R
wenzelm@12349
   635
proof -
wenzelm@12349
   636
  from 3 and 1 have P .
wenzelm@12368
   637
  with 1 have Q by (rule impE)
wenzelm@12349
   638
  with 2 show R .
wenzelm@12349
   639
qed
wenzelm@12349
   640
wenzelm@12349
   641
lemma allE':
wenzelm@12937
   642
  assumes 1: "ALL x. P(x)"
wenzelm@12937
   643
    and 2: "P(x) ==> ALL x. P(x) ==> Q"
wenzelm@12937
   644
  shows Q
wenzelm@12349
   645
proof -
wenzelm@12349
   646
  from 1 have "P(x)" by (rule spec)
wenzelm@12349
   647
  from this and 1 show Q by (rule 2)
wenzelm@12349
   648
qed
wenzelm@12349
   649
wenzelm@12937
   650
lemma notE':
wenzelm@12937
   651
  assumes 1: "~ P"
wenzelm@12937
   652
    and 2: "~ P ==> P"
wenzelm@12937
   653
  shows R
wenzelm@12349
   654
proof -
wenzelm@12349
   655
  from 2 and 1 have P .
wenzelm@12349
   656
  with 1 show R by (rule notE)
wenzelm@12349
   657
qed
wenzelm@12349
   658
wenzelm@12349
   659
lemmas [Pure.elim!] = disjE iffE FalseE conjE exE
wenzelm@12349
   660
  and [Pure.intro!] = iffI conjI impI TrueI notI allI refl
wenzelm@12349
   661
  and [Pure.elim 2] = allE notE' impE'
wenzelm@12349
   662
  and [Pure.intro] = exI disjI2 disjI1
wenzelm@12349
   663
wenzelm@18708
   664
setup {* ContextRules.addSWrapper (fn tac => hyp_subst_tac ORELSE' tac) *}
wenzelm@12349
   665
wenzelm@12349
   666
wenzelm@12368
   667
lemma iff_not_sym: "~ (Q <-> P) ==> ~ (P <-> Q)"
nipkow@17591
   668
  by iprover
wenzelm@12368
   669
wenzelm@12368
   670
lemmas [sym] = sym iff_sym not_sym iff_not_sym
wenzelm@12368
   671
  and [Pure.elim?] = iffD1 iffD2 impE
wenzelm@12368
   672
wenzelm@12368
   673
paulson@13435
   674
lemma eq_commute: "a=b <-> b=a"
paulson@13435
   675
apply (rule iffI) 
paulson@13435
   676
apply (erule sym)+
paulson@13435
   677
done
paulson@13435
   678
paulson@13435
   679
wenzelm@11677
   680
subsection {* Atomizing meta-level rules *}
wenzelm@11677
   681
wenzelm@11747
   682
lemma atomize_all [atomize]: "(!!x. P(x)) == Trueprop (ALL x. P(x))"
wenzelm@11976
   683
proof
wenzelm@11677
   684
  assume "!!x. P(x)"
wenzelm@22931
   685
  then show "ALL x. P(x)" ..
wenzelm@11677
   686
next
wenzelm@11677
   687
  assume "ALL x. P(x)"
wenzelm@22931
   688
  then show "!!x. P(x)" ..
wenzelm@11677
   689
qed
wenzelm@11677
   690
wenzelm@11747
   691
lemma atomize_imp [atomize]: "(A ==> B) == Trueprop (A --> B)"
wenzelm@11976
   692
proof
wenzelm@12368
   693
  assume "A ==> B"
wenzelm@22931
   694
  then show "A --> B" ..
wenzelm@11677
   695
next
wenzelm@11677
   696
  assume "A --> B" and A
wenzelm@22931
   697
  then show B by (rule mp)
wenzelm@11677
   698
qed
wenzelm@11677
   699
wenzelm@11747
   700
lemma atomize_eq [atomize]: "(x == y) == Trueprop (x = y)"
wenzelm@11976
   701
proof
wenzelm@11677
   702
  assume "x == y"
wenzelm@22931
   703
  show "x = y" unfolding `x == y` by (rule refl)
wenzelm@11677
   704
next
wenzelm@11677
   705
  assume "x = y"
wenzelm@22931
   706
  then show "x == y" by (rule eq_reflection)
wenzelm@11677
   707
qed
wenzelm@11677
   708
wenzelm@18813
   709
lemma atomize_iff [atomize]: "(A == B) == Trueprop (A <-> B)"
wenzelm@18813
   710
proof
wenzelm@18813
   711
  assume "A == B"
wenzelm@22931
   712
  show "A <-> B" unfolding `A == B` by (rule iff_refl)
wenzelm@18813
   713
next
wenzelm@18813
   714
  assume "A <-> B"
wenzelm@22931
   715
  then show "A == B" by (rule iff_reflection)
wenzelm@18813
   716
qed
wenzelm@18813
   717
wenzelm@12875
   718
lemma atomize_conj [atomize]:
wenzelm@19120
   719
  includes meta_conjunction_syntax
wenzelm@19120
   720
  shows "(A && B) == Trueprop (A & B)"
wenzelm@11976
   721
proof
wenzelm@19120
   722
  assume conj: "A && B"
wenzelm@19120
   723
  show "A & B"
wenzelm@19120
   724
  proof (rule conjI)
wenzelm@19120
   725
    from conj show A by (rule conjunctionD1)
wenzelm@19120
   726
    from conj show B by (rule conjunctionD2)
wenzelm@19120
   727
  qed
wenzelm@11953
   728
next
wenzelm@19120
   729
  assume conj: "A & B"
wenzelm@19120
   730
  show "A && B"
wenzelm@19120
   731
  proof -
wenzelm@19120
   732
    from conj show A ..
wenzelm@19120
   733
    from conj show B ..
wenzelm@11953
   734
  qed
wenzelm@11953
   735
qed
wenzelm@11953
   736
wenzelm@12368
   737
lemmas [symmetric, rulify] = atomize_all atomize_imp
wenzelm@18861
   738
  and [symmetric, defn] = atomize_all atomize_imp atomize_eq atomize_iff
wenzelm@11771
   739
wenzelm@11848
   740
wenzelm@11848
   741
subsection {* Calculational rules *}
wenzelm@11848
   742
wenzelm@11848
   743
lemma forw_subst: "a = b ==> P(b) ==> P(a)"
wenzelm@11848
   744
  by (rule ssubst)
wenzelm@11848
   745
wenzelm@11848
   746
lemma back_subst: "P(a) ==> a = b ==> P(b)"
wenzelm@11848
   747
  by (rule subst)
wenzelm@11848
   748
wenzelm@11848
   749
text {*
wenzelm@11848
   750
  Note that this list of rules is in reverse order of priorities.
wenzelm@11848
   751
*}
wenzelm@11848
   752
wenzelm@12019
   753
lemmas basic_trans_rules [trans] =
wenzelm@11848
   754
  forw_subst
wenzelm@11848
   755
  back_subst
wenzelm@11848
   756
  rev_mp
wenzelm@11848
   757
  mp
wenzelm@11848
   758
  trans
wenzelm@11848
   759
paulson@13779
   760
subsection {* ``Let'' declarations *}
paulson@13779
   761
paulson@13779
   762
nonterminals letbinds letbind
paulson@13779
   763
paulson@13779
   764
constdefs
wenzelm@14854
   765
  Let :: "['a::{}, 'a => 'b] => ('b::{})"
paulson@13779
   766
    "Let(s, f) == f(s)"
paulson@13779
   767
paulson@13779
   768
syntax
paulson@13779
   769
  "_bind"       :: "[pttrn, 'a] => letbind"           ("(2_ =/ _)" 10)
paulson@13779
   770
  ""            :: "letbind => letbinds"              ("_")
paulson@13779
   771
  "_binds"      :: "[letbind, letbinds] => letbinds"  ("_;/ _")
paulson@13779
   772
  "_Let"        :: "[letbinds, 'a] => 'a"             ("(let (_)/ in (_))" 10)
paulson@13779
   773
paulson@13779
   774
translations
paulson@13779
   775
  "_Let(_binds(b, bs), e)"  == "_Let(b, _Let(bs, e))"
paulson@13779
   776
  "let x = a in e"          == "Let(a, %x. e)"
paulson@13779
   777
paulson@13779
   778
paulson@13779
   779
lemma LetI: 
wenzelm@21539
   780
  assumes "!!x. x=t ==> P(u(x))"
wenzelm@21539
   781
  shows "P(let x=t in u(x))"
wenzelm@21539
   782
  apply (unfold Let_def)
wenzelm@21539
   783
  apply (rule refl [THEN assms])
wenzelm@21539
   784
  done
wenzelm@21539
   785
wenzelm@21539
   786
wenzelm@26286
   787
subsection {* Intuitionistic simplification rules *}
wenzelm@26286
   788
wenzelm@26286
   789
lemma conj_simps:
wenzelm@26286
   790
  "P & True <-> P"
wenzelm@26286
   791
  "True & P <-> P"
wenzelm@26286
   792
  "P & False <-> False"
wenzelm@26286
   793
  "False & P <-> False"
wenzelm@26286
   794
  "P & P <-> P"
wenzelm@26286
   795
  "P & P & Q <-> P & Q"
wenzelm@26286
   796
  "P & ~P <-> False"
wenzelm@26286
   797
  "~P & P <-> False"
wenzelm@26286
   798
  "(P & Q) & R <-> P & (Q & R)"
wenzelm@26286
   799
  by iprover+
wenzelm@26286
   800
wenzelm@26286
   801
lemma disj_simps:
wenzelm@26286
   802
  "P | True <-> True"
wenzelm@26286
   803
  "True | P <-> True"
wenzelm@26286
   804
  "P | False <-> P"
wenzelm@26286
   805
  "False | P <-> P"
wenzelm@26286
   806
  "P | P <-> P"
wenzelm@26286
   807
  "P | P | Q <-> P | Q"
wenzelm@26286
   808
  "(P | Q) | R <-> P | (Q | R)"
wenzelm@26286
   809
  by iprover+
wenzelm@26286
   810
wenzelm@26286
   811
lemma not_simps:
wenzelm@26286
   812
  "~(P|Q)  <-> ~P & ~Q"
wenzelm@26286
   813
  "~ False <-> True"
wenzelm@26286
   814
  "~ True <-> False"
wenzelm@26286
   815
  by iprover+
wenzelm@26286
   816
wenzelm@26286
   817
lemma imp_simps:
wenzelm@26286
   818
  "(P --> False) <-> ~P"
wenzelm@26286
   819
  "(P --> True) <-> True"
wenzelm@26286
   820
  "(False --> P) <-> True"
wenzelm@26286
   821
  "(True --> P) <-> P"
wenzelm@26286
   822
  "(P --> P) <-> True"
wenzelm@26286
   823
  "(P --> ~P) <-> ~P"
wenzelm@26286
   824
  by iprover+
wenzelm@26286
   825
wenzelm@26286
   826
lemma iff_simps:
wenzelm@26286
   827
  "(True <-> P) <-> P"
wenzelm@26286
   828
  "(P <-> True) <-> P"
wenzelm@26286
   829
  "(P <-> P) <-> True"
wenzelm@26286
   830
  "(False <-> P) <-> ~P"
wenzelm@26286
   831
  "(P <-> False) <-> ~P"
wenzelm@26286
   832
  by iprover+
wenzelm@26286
   833
wenzelm@26286
   834
(*The x=t versions are needed for the simplification procedures*)
wenzelm@26286
   835
lemma quant_simps:
wenzelm@26286
   836
  "!!P. (ALL x. P) <-> P"
wenzelm@26286
   837
  "(ALL x. x=t --> P(x)) <-> P(t)"
wenzelm@26286
   838
  "(ALL x. t=x --> P(x)) <-> P(t)"
wenzelm@26286
   839
  "!!P. (EX x. P) <-> P"
wenzelm@26286
   840
  "EX x. x=t"
wenzelm@26286
   841
  "EX x. t=x"
wenzelm@26286
   842
  "(EX x. x=t & P(x)) <-> P(t)"
wenzelm@26286
   843
  "(EX x. t=x & P(x)) <-> P(t)"
wenzelm@26286
   844
  by iprover+
wenzelm@26286
   845
wenzelm@26286
   846
(*These are NOT supplied by default!*)
wenzelm@26286
   847
lemma distrib_simps:
wenzelm@26286
   848
  "P & (Q | R) <-> P&Q | P&R"
wenzelm@26286
   849
  "(Q | R) & P <-> Q&P | R&P"
wenzelm@26286
   850
  "(P | Q --> R) <-> (P --> R) & (Q --> R)"
wenzelm@26286
   851
  by iprover+
wenzelm@26286
   852
wenzelm@26286
   853
wenzelm@26286
   854
text {* Conversion into rewrite rules *}
wenzelm@26286
   855
wenzelm@26286
   856
lemma P_iff_F: "~P ==> (P <-> False)" by iprover
wenzelm@26286
   857
lemma iff_reflection_F: "~P ==> (P == False)" by (rule P_iff_F [THEN iff_reflection])
wenzelm@26286
   858
wenzelm@26286
   859
lemma P_iff_T: "P ==> (P <-> True)" by iprover
wenzelm@26286
   860
lemma iff_reflection_T: "P ==> (P == True)" by (rule P_iff_T [THEN iff_reflection])
wenzelm@26286
   861
wenzelm@26286
   862
wenzelm@26286
   863
text {* More rewrite rules *}
wenzelm@26286
   864
wenzelm@26286
   865
lemma conj_commute: "P&Q <-> Q&P" by iprover
wenzelm@26286
   866
lemma conj_left_commute: "P&(Q&R) <-> Q&(P&R)" by iprover
wenzelm@26286
   867
lemmas conj_comms = conj_commute conj_left_commute
wenzelm@26286
   868
wenzelm@26286
   869
lemma disj_commute: "P|Q <-> Q|P" by iprover
wenzelm@26286
   870
lemma disj_left_commute: "P|(Q|R) <-> Q|(P|R)" by iprover
wenzelm@26286
   871
lemmas disj_comms = disj_commute disj_left_commute
wenzelm@26286
   872
wenzelm@26286
   873
lemma conj_disj_distribL: "P&(Q|R) <-> (P&Q | P&R)" by iprover
wenzelm@26286
   874
lemma conj_disj_distribR: "(P|Q)&R <-> (P&R | Q&R)" by iprover
wenzelm@26286
   875
wenzelm@26286
   876
lemma disj_conj_distribL: "P|(Q&R) <-> (P|Q) & (P|R)" by iprover
wenzelm@26286
   877
lemma disj_conj_distribR: "(P&Q)|R <-> (P|R) & (Q|R)" by iprover
wenzelm@26286
   878
wenzelm@26286
   879
lemma imp_conj_distrib: "(P --> (Q&R)) <-> (P-->Q) & (P-->R)" by iprover
wenzelm@26286
   880
lemma imp_conj: "((P&Q)-->R)   <-> (P --> (Q --> R))" by iprover
wenzelm@26286
   881
lemma imp_disj: "(P|Q --> R)   <-> (P-->R) & (Q-->R)" by iprover
wenzelm@26286
   882
wenzelm@26286
   883
lemma de_Morgan_disj: "(~(P | Q)) <-> (~P & ~Q)" by iprover
wenzelm@26286
   884
wenzelm@26286
   885
lemma not_ex: "(~ (EX x. P(x))) <-> (ALL x.~P(x))" by iprover
wenzelm@26286
   886
lemma imp_ex: "((EX x. P(x)) --> Q) <-> (ALL x. P(x) --> Q)" by iprover
wenzelm@26286
   887
wenzelm@26286
   888
lemma ex_disj_distrib:
wenzelm@26286
   889
  "(EX x. P(x) | Q(x)) <-> ((EX x. P(x)) | (EX x. Q(x)))" by iprover
wenzelm@26286
   890
wenzelm@26286
   891
lemma all_conj_distrib:
wenzelm@26286
   892
  "(ALL x. P(x) & Q(x)) <-> ((ALL x. P(x)) & (ALL x. Q(x)))" by iprover
wenzelm@26286
   893
wenzelm@26286
   894
wenzelm@26286
   895
subsection {* Legacy ML bindings *}
paulson@13779
   896
wenzelm@21539
   897
ML {*
wenzelm@22139
   898
val refl = @{thm refl}
wenzelm@22139
   899
val trans = @{thm trans}
wenzelm@22139
   900
val sym = @{thm sym}
wenzelm@22139
   901
val subst = @{thm subst}
wenzelm@22139
   902
val ssubst = @{thm ssubst}
wenzelm@22139
   903
val conjI = @{thm conjI}
wenzelm@22139
   904
val conjE = @{thm conjE}
wenzelm@22139
   905
val conjunct1 = @{thm conjunct1}
wenzelm@22139
   906
val conjunct2 = @{thm conjunct2}
wenzelm@22139
   907
val disjI1 = @{thm disjI1}
wenzelm@22139
   908
val disjI2 = @{thm disjI2}
wenzelm@22139
   909
val disjE = @{thm disjE}
wenzelm@22139
   910
val impI = @{thm impI}
wenzelm@22139
   911
val impE = @{thm impE}
wenzelm@22139
   912
val mp = @{thm mp}
wenzelm@22139
   913
val rev_mp = @{thm rev_mp}
wenzelm@22139
   914
val TrueI = @{thm TrueI}
wenzelm@22139
   915
val FalseE = @{thm FalseE}
wenzelm@22139
   916
val iff_refl = @{thm iff_refl}
wenzelm@22139
   917
val iff_trans = @{thm iff_trans}
wenzelm@22139
   918
val iffI = @{thm iffI}
wenzelm@22139
   919
val iffE = @{thm iffE}
wenzelm@22139
   920
val iffD1 = @{thm iffD1}
wenzelm@22139
   921
val iffD2 = @{thm iffD2}
wenzelm@22139
   922
val notI = @{thm notI}
wenzelm@22139
   923
val notE = @{thm notE}
wenzelm@22139
   924
val allI = @{thm allI}
wenzelm@22139
   925
val allE = @{thm allE}
wenzelm@22139
   926
val spec = @{thm spec}
wenzelm@22139
   927
val exI = @{thm exI}
wenzelm@22139
   928
val exE = @{thm exE}
wenzelm@22139
   929
val eq_reflection = @{thm eq_reflection}
wenzelm@22139
   930
val iff_reflection = @{thm iff_reflection}
wenzelm@22139
   931
val meta_eq_to_obj_eq = @{thm meta_eq_to_obj_eq}
wenzelm@22139
   932
val meta_eq_to_iff = @{thm meta_eq_to_iff}
paulson@13779
   933
*}
paulson@13779
   934
wenzelm@4854
   935
end