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