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