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