src/ZF/upair.thy
author wenzelm
Thu Mar 15 22:08:53 2012 +0100 (2012-03-15)
changeset 46950 d0181abdbdac
parent 46821 ff6b0c1087f2
child 46955 7bd0780c0bd3
permissions -rw-r--r--
declare command keywords via theory header, including strict checking outside Pure;
paulson@2469
     1
(*  Title:      ZF/upair.thy
paulson@2469
     2
    Author:     Lawrence C Paulson and Martin D Coen, CU Computer Laboratory
paulson@2469
     3
    Copyright   1993  University of Cambridge
paulson@13259
     4
paulson@13259
     5
Observe the order of dependence:
paulson@13259
     6
    Upair is defined in terms of Replace
paulson@46820
     7
    \<union> is defined in terms of Upair and \<Union>(similarly for Int)
paulson@13259
     8
    cons is defined in terms of Upair and Un
paulson@13259
     9
    Ordered pairs and descriptions are defined using cons ("set notation")
paulson@2469
    10
*)
paulson@2469
    11
paulson@13357
    12
header{*Unordered Pairs*}
paulson@13357
    13
wenzelm@46950
    14
theory upair
wenzelm@46950
    15
imports ZF
wenzelm@46950
    16
keywords "print_tcset" :: diag
wenzelm@46950
    17
uses "Tools/typechk.ML"
wenzelm@46950
    18
begin
paulson@6153
    19
wenzelm@9907
    20
setup TypeCheck.setup
paulson@6153
    21
paulson@13780
    22
lemma atomize_ball [symmetric, rulify]:
paulson@46820
    23
     "(!!x. x:A ==> P(x)) == Trueprop (\<forall>x\<in>A. P(x))"
paulson@13780
    24
by (simp add: Ball_def atomize_all atomize_imp)
paulson@13259
    25
paulson@13259
    26
paulson@13357
    27
subsection{*Unordered Pairs: constant @{term Upair}*}
paulson@13259
    28
paulson@46821
    29
lemma Upair_iff [simp]: "c \<in> Upair(a,b) \<longleftrightarrow> (c=a | c=b)"
paulson@13259
    30
by (unfold Upair_def, blast)
paulson@13259
    31
paulson@46820
    32
lemma UpairI1: "a \<in> Upair(a,b)"
paulson@13259
    33
by simp
paulson@13259
    34
paulson@46820
    35
lemma UpairI2: "b \<in> Upair(a,b)"
paulson@13259
    36
by simp
paulson@13259
    37
paulson@46820
    38
lemma UpairE: "[| a \<in> Upair(b,c);  a=b ==> P;  a=c ==> P |] ==> P"
paulson@13780
    39
by (simp, blast)
paulson@13259
    40
paulson@13357
    41
subsection{*Rules for Binary Union, Defined via @{term Upair}*}
paulson@13259
    42
paulson@46821
    43
lemma Un_iff [simp]: "c \<in> A \<union> B \<longleftrightarrow> (c:A | c:B)"
paulson@13259
    44
apply (simp add: Un_def)
paulson@13259
    45
apply (blast intro: UpairI1 UpairI2 elim: UpairE)
paulson@13259
    46
done
paulson@13259
    47
paulson@46820
    48
lemma UnI1: "c \<in> A ==> c \<in> A \<union> B"
paulson@13259
    49
by simp
paulson@13259
    50
paulson@46820
    51
lemma UnI2: "c \<in> B ==> c \<in> A \<union> B"
paulson@13259
    52
by simp
paulson@13259
    53
paulson@13356
    54
declare UnI1 [elim?]  UnI2 [elim?]
paulson@13356
    55
paulson@46820
    56
lemma UnE [elim!]: "[| c \<in> A \<union> B;  c:A ==> P;  c:B ==> P |] ==> P"
paulson@13780
    57
by (simp, blast)
paulson@13259
    58
paulson@13259
    59
(*Stronger version of the rule above*)
paulson@46820
    60
lemma UnE': "[| c \<in> A \<union> B;  c:A ==> P;  [| c:B;  c\<notin>A |] ==> P |] ==> P"
paulson@13780
    61
by (simp, blast)
paulson@13259
    62
paulson@13259
    63
(*Classical introduction rule: no commitment to A vs B*)
paulson@46820
    64
lemma UnCI [intro!]: "(c \<notin> B ==> c \<in> A) ==> c \<in> A \<union> B"
paulson@13780
    65
by (simp, blast)
paulson@13259
    66
paulson@13357
    67
subsection{*Rules for Binary Intersection, Defined via @{term Upair}*}
paulson@13259
    68
paulson@46821
    69
lemma Int_iff [simp]: "c \<in> A \<inter> B \<longleftrightarrow> (c:A & c:B)"
paulson@13259
    70
apply (unfold Int_def)
paulson@13259
    71
apply (blast intro: UpairI1 UpairI2 elim: UpairE)
paulson@13259
    72
done
paulson@13259
    73
paulson@46820
    74
lemma IntI [intro!]: "[| c \<in> A;  c \<in> B |] ==> c \<in> A \<inter> B"
paulson@13259
    75
by simp
paulson@13259
    76
paulson@46820
    77
lemma IntD1: "c \<in> A \<inter> B ==> c \<in> A"
paulson@13259
    78
by simp
paulson@13259
    79
paulson@46820
    80
lemma IntD2: "c \<in> A \<inter> B ==> c \<in> B"
paulson@13259
    81
by simp
paulson@13259
    82
paulson@46820
    83
lemma IntE [elim!]: "[| c \<in> A \<inter> B;  [| c:A; c:B |] ==> P |] ==> P"
paulson@13259
    84
by simp
paulson@13259
    85
paulson@13259
    86
paulson@13357
    87
subsection{*Rules for Set Difference, Defined via @{term Upair}*}
paulson@13259
    88
paulson@46821
    89
lemma Diff_iff [simp]: "c \<in> A-B \<longleftrightarrow> (c:A & c\<notin>B)"
paulson@13259
    90
by (unfold Diff_def, blast)
paulson@13259
    91
paulson@46820
    92
lemma DiffI [intro!]: "[| c \<in> A;  c \<notin> B |] ==> c \<in> A - B"
paulson@13259
    93
by simp
paulson@13259
    94
paulson@46820
    95
lemma DiffD1: "c \<in> A - B ==> c \<in> A"
paulson@13259
    96
by simp
paulson@13259
    97
paulson@46820
    98
lemma DiffD2: "c \<in> A - B ==> c \<notin> B"
paulson@13259
    99
by simp
paulson@13259
   100
paulson@46820
   101
lemma DiffE [elim!]: "[| c \<in> A - B;  [| c:A; c\<notin>B |] ==> P |] ==> P"
paulson@13259
   102
by simp
paulson@13259
   103
paulson@13259
   104
paulson@13357
   105
subsection{*Rules for @{term cons}*}
paulson@13259
   106
paulson@46821
   107
lemma cons_iff [simp]: "a \<in> cons(b,A) \<longleftrightarrow> (a=b | a:A)"
paulson@13259
   108
apply (unfold cons_def)
paulson@13259
   109
apply (blast intro: UpairI1 UpairI2 elim: UpairE)
paulson@13259
   110
done
paulson@13259
   111
paulson@13259
   112
(*risky as a typechecking rule, but solves otherwise unconstrained goals of
paulson@46820
   113
the form x \<in> ?A*)
paulson@46820
   114
lemma consI1 [simp,TC]: "a \<in> cons(a,B)"
paulson@13259
   115
by simp
paulson@13259
   116
paulson@13259
   117
paulson@46820
   118
lemma consI2: "a \<in> B ==> a \<in> cons(b,B)"
paulson@13259
   119
by simp
paulson@13259
   120
paulson@46820
   121
lemma consE [elim!]: "[| a \<in> cons(b,A);  a=b ==> P;  a:A ==> P |] ==> P"
paulson@13780
   122
by (simp, blast)
paulson@13259
   123
paulson@13259
   124
(*Stronger version of the rule above*)
paulson@13259
   125
lemma consE':
paulson@46820
   126
    "[| a \<in> cons(b,A);  a=b ==> P;  [| a:A;  a\<noteq>b |] ==> P |] ==> P"
paulson@13780
   127
by (simp, blast)
paulson@13259
   128
paulson@13259
   129
(*Classical introduction rule*)
paulson@46820
   130
lemma consCI [intro!]: "(a\<notin>B ==> a=b) ==> a: cons(b,B)"
paulson@13780
   131
by (simp, blast)
paulson@13259
   132
paulson@46820
   133
lemma cons_not_0 [simp]: "cons(a,B) \<noteq> 0"
paulson@13259
   134
by (blast elim: equalityE)
paulson@13259
   135
wenzelm@45602
   136
lemmas cons_neq_0 = cons_not_0 [THEN notE]
paulson@13259
   137
paulson@13259
   138
declare cons_not_0 [THEN not_sym, simp]
paulson@13259
   139
paulson@13259
   140
paulson@13357
   141
subsection{*Singletons*}
paulson@13259
   142
paulson@46821
   143
lemma singleton_iff: "a \<in> {b} \<longleftrightarrow> a=b"
paulson@13259
   144
by simp
paulson@13259
   145
paulson@46820
   146
lemma singletonI [intro!]: "a \<in> {a}"
paulson@13259
   147
by (rule consI1)
paulson@13259
   148
wenzelm@45602
   149
lemmas singletonE = singleton_iff [THEN iffD1, elim_format, elim!]
paulson@13259
   150
paulson@13259
   151
paulson@14883
   152
subsection{*Descriptions*}
paulson@13259
   153
paulson@13259
   154
lemma the_equality [intro]:
paulson@13259
   155
    "[| P(a);  !!x. P(x) ==> x=a |] ==> (THE x. P(x)) = a"
paulson@46820
   156
apply (unfold the_def)
paulson@13259
   157
apply (fast dest: subst)
paulson@13259
   158
done
paulson@13259
   159
paulson@13259
   160
(* Only use this if you already know EX!x. P(x) *)
paulson@13259
   161
lemma the_equality2: "[| EX! x. P(x);  P(a) |] ==> (THE x. P(x)) = a"
paulson@13259
   162
by blast
paulson@13259
   163
paulson@13259
   164
lemma theI: "EX! x. P(x) ==> P(THE x. P(x))"
paulson@13259
   165
apply (erule ex1E)
paulson@13259
   166
apply (subst the_equality)
paulson@13259
   167
apply (blast+)
paulson@13259
   168
done
paulson@13259
   169
paulson@46821
   170
(*No congruence rule is necessary: if @{term"\<forall>y.P(y)\<longleftrightarrow>Q(y)"} then
paulson@46820
   171
  @{term "THE x.P(x)"}  rewrites to @{term "THE x.Q(x)"} *)
paulson@13259
   172
paulson@13259
   173
(*If it's "undefined", it's zero!*)
paulson@13259
   174
lemma the_0: "~ (EX! x. P(x)) ==> (THE x. P(x))=0"
paulson@13259
   175
apply (unfold the_def)
paulson@13259
   176
apply (blast elim!: ReplaceE)
paulson@13259
   177
done
paulson@13259
   178
paulson@13259
   179
(*Easier to apply than theI: conclusion has only one occurrence of P*)
paulson@13259
   180
lemma theI2:
paulson@13259
   181
    assumes p1: "~ Q(0) ==> EX! x. P(x)"
paulson@13259
   182
        and p2: "!!x. P(x) ==> Q(x)"
paulson@13259
   183
    shows "Q(THE x. P(x))"
paulson@13259
   184
apply (rule classical)
paulson@13259
   185
apply (rule p2)
paulson@13259
   186
apply (rule theI)
paulson@13259
   187
apply (rule classical)
paulson@13259
   188
apply (rule p1)
paulson@13259
   189
apply (erule the_0 [THEN subst], assumption)
paulson@13259
   190
done
paulson@13259
   191
paulson@13357
   192
lemma the_eq_trivial [simp]: "(THE x. x = a) = a"
paulson@13357
   193
by blast
paulson@13357
   194
paulson@13544
   195
lemma the_eq_trivial2 [simp]: "(THE x. a = x) = a"
paulson@13544
   196
by blast
paulson@13544
   197
paulson@13780
   198
paulson@13357
   199
subsection{*Conditional Terms: @{text "if-then-else"}*}
paulson@13259
   200
paulson@13259
   201
lemma if_true [simp]: "(if True then a else b) = a"
paulson@13259
   202
by (unfold if_def, blast)
paulson@13259
   203
paulson@13259
   204
lemma if_false [simp]: "(if False then a else b) = b"
paulson@13259
   205
by (unfold if_def, blast)
paulson@13259
   206
paulson@13259
   207
(*Never use with case splitting, or if P is known to be true or false*)
paulson@13259
   208
lemma if_cong:
paulson@46821
   209
    "[| P\<longleftrightarrow>Q;  Q ==> a=c;  ~Q ==> b=d |]
paulson@13259
   210
     ==> (if P then a else b) = (if Q then c else d)"
paulson@13259
   211
by (simp add: if_def cong add: conj_cong)
paulson@13259
   212
paulson@13259
   213
(*Prevents simplification of x and y: faster and allows the execution
paulson@13259
   214
  of functional programs. NOW THE DEFAULT.*)
paulson@46821
   215
lemma if_weak_cong: "P\<longleftrightarrow>Q ==> (if P then x else y) = (if Q then x else y)"
paulson@13259
   216
by simp
paulson@13259
   217
paulson@13259
   218
(*Not needed for rewriting, since P would rewrite to True anyway*)
paulson@13259
   219
lemma if_P: "P ==> (if P then a else b) = a"
paulson@13259
   220
by (unfold if_def, blast)
paulson@13259
   221
paulson@13259
   222
(*Not needed for rewriting, since P would rewrite to False anyway*)
paulson@13259
   223
lemma if_not_P: "~P ==> (if P then a else b) = b"
paulson@13259
   224
by (unfold if_def, blast)
paulson@13259
   225
paulson@13780
   226
lemma split_if [split]:
paulson@46821
   227
     "P(if Q then x else y) \<longleftrightarrow> ((Q \<longrightarrow> P(x)) & (~Q \<longrightarrow> P(y)))"
paulson@14153
   228
by (case_tac Q, simp_all)
paulson@13259
   229
wenzelm@45620
   230
(** Rewrite rules for boolean case-splitting: faster than split_if [split]
paulson@13259
   231
**)
paulson@13259
   232
wenzelm@45602
   233
lemmas split_if_eq1 = split_if [of "%x. x = b"] for b
wenzelm@45602
   234
lemmas split_if_eq2 = split_if [of "%x. a = x"] for x
paulson@13259
   235
paulson@46820
   236
lemmas split_if_mem1 = split_if [of "%x. x \<in> b"] for b
paulson@46820
   237
lemmas split_if_mem2 = split_if [of "%x. a \<in> x"] for x
paulson@13259
   238
paulson@13259
   239
lemmas split_ifs = split_if_eq1 split_if_eq2 split_if_mem1 split_if_mem2
paulson@13259
   240
paulson@13259
   241
(*Logically equivalent to split_if_mem2*)
paulson@46821
   242
lemma if_iff: "a: (if P then x else y) \<longleftrightarrow> P & a:x | ~P & a:y"
paulson@13780
   243
by simp
paulson@13259
   244
paulson@13259
   245
lemma if_type [TC]:
paulson@13259
   246
    "[| P ==> a: A;  ~P ==> b: A |] ==> (if P then a else b): A"
paulson@13780
   247
by simp
paulson@13780
   248
paulson@13780
   249
(** Splitting IFs in the assumptions **)
paulson@13780
   250
paulson@46821
   251
lemma split_if_asm: "P(if Q then x else y) \<longleftrightarrow> (~((Q & ~P(x)) | (~Q & ~P(y))))"
paulson@13780
   252
by simp
paulson@13780
   253
paulson@13780
   254
lemmas if_splits = split_if split_if_asm
paulson@13259
   255
paulson@13259
   256
paulson@13357
   257
subsection{*Consequences of Foundation*}
paulson@13259
   258
paulson@13259
   259
(*was called mem_anti_sym*)
paulson@13259
   260
lemma mem_asym: "[| a:b;  ~P ==> b:a |] ==> P"
paulson@13259
   261
apply (rule classical)
paulson@13259
   262
apply (rule_tac A1 = "{a,b}" in foundation [THEN disjE])
paulson@13259
   263
apply (blast elim!: equalityE)+
paulson@13259
   264
done
paulson@13259
   265
paulson@13259
   266
(*was called mem_anti_refl*)
paulson@13259
   267
lemma mem_irrefl: "a:a ==> P"
paulson@13259
   268
by (blast intro: mem_asym)
paulson@13259
   269
paulson@13259
   270
(*mem_irrefl should NOT be added to default databases:
paulson@13259
   271
      it would be tried on most goals, making proofs slower!*)
paulson@13259
   272
paulson@46820
   273
lemma mem_not_refl: "a \<notin> a"
paulson@13259
   274
apply (rule notI)
paulson@13259
   275
apply (erule mem_irrefl)
paulson@13259
   276
done
paulson@13259
   277
paulson@13259
   278
(*Good for proving inequalities by rewriting*)
paulson@46820
   279
lemma mem_imp_not_eq: "a:A ==> a \<noteq> A"
paulson@13259
   280
by (blast elim!: mem_irrefl)
paulson@13259
   281
paulson@46820
   282
lemma eq_imp_not_mem: "a=A ==> a \<notin> A"
paulson@13357
   283
by (blast intro: elim: mem_irrefl)
paulson@13357
   284
paulson@13357
   285
subsection{*Rules for Successor*}
paulson@13259
   286
paulson@46821
   287
lemma succ_iff: "i \<in> succ(j) \<longleftrightarrow> i=j | i:j"
paulson@13259
   288
by (unfold succ_def, blast)
paulson@13259
   289
paulson@46820
   290
lemma succI1 [simp]: "i \<in> succ(i)"
paulson@13259
   291
by (simp add: succ_iff)
paulson@13259
   292
paulson@46820
   293
lemma succI2: "i \<in> j ==> i \<in> succ(j)"
paulson@13259
   294
by (simp add: succ_iff)
paulson@13259
   295
paulson@46820
   296
lemma succE [elim!]:
paulson@46820
   297
    "[| i \<in> succ(j);  i=j ==> P;  i:j ==> P |] ==> P"
paulson@46820
   298
apply (simp add: succ_iff, blast)
paulson@13259
   299
done
paulson@13259
   300
paulson@13259
   301
(*Classical introduction rule*)
paulson@46820
   302
lemma succCI [intro!]: "(i\<notin>j ==> i=j) ==> i: succ(j)"
paulson@13259
   303
by (simp add: succ_iff, blast)
paulson@13259
   304
paulson@46820
   305
lemma succ_not_0 [simp]: "succ(n) \<noteq> 0"
paulson@13259
   306
by (blast elim!: equalityE)
paulson@13259
   307
wenzelm@45602
   308
lemmas succ_neq_0 = succ_not_0 [THEN notE, elim!]
paulson@13259
   309
paulson@13259
   310
declare succ_not_0 [THEN not_sym, simp]
paulson@13259
   311
declare sym [THEN succ_neq_0, elim!]
paulson@13259
   312
paulson@46820
   313
(* @{term"succ(c) \<subseteq> B ==> c \<in> B"} *)
paulson@13259
   314
lemmas succ_subsetD = succI1 [THEN [2] subsetD]
paulson@13259
   315
paulson@46820
   316
(* @{term"succ(b) \<noteq> b"} *)
wenzelm@45602
   317
lemmas succ_neq_self = succI1 [THEN mem_imp_not_eq, THEN not_sym]
paulson@13259
   318
paulson@46821
   319
lemma succ_inject_iff [simp]: "succ(m) = succ(n) \<longleftrightarrow> m=n"
paulson@13259
   320
by (blast elim: mem_asym elim!: equalityE)
paulson@13259
   321
wenzelm@45602
   322
lemmas succ_inject = succ_inject_iff [THEN iffD1, dest!]
paulson@13259
   323
paulson@13780
   324
paulson@13780
   325
subsection{*Miniscoping of the Bounded Universal Quantifier*}
paulson@13780
   326
paulson@13780
   327
lemma ball_simps1:
paulson@46821
   328
     "(\<forall>x\<in>A. P(x) & Q)   \<longleftrightarrow> (\<forall>x\<in>A. P(x)) & (A=0 | Q)"
paulson@46821
   329
     "(\<forall>x\<in>A. P(x) | Q)   \<longleftrightarrow> ((\<forall>x\<in>A. P(x)) | Q)"
paulson@46821
   330
     "(\<forall>x\<in>A. P(x) \<longrightarrow> Q) \<longleftrightarrow> ((\<exists>x\<in>A. P(x)) \<longrightarrow> Q)"
paulson@46821
   331
     "(~(\<forall>x\<in>A. P(x))) \<longleftrightarrow> (\<exists>x\<in>A. ~P(x))"
paulson@46821
   332
     "(\<forall>x\<in>0.P(x)) \<longleftrightarrow> True"
paulson@46821
   333
     "(\<forall>x\<in>succ(i).P(x)) \<longleftrightarrow> P(i) & (\<forall>x\<in>i. P(x))"
paulson@46821
   334
     "(\<forall>x\<in>cons(a,B).P(x)) \<longleftrightarrow> P(a) & (\<forall>x\<in>B. P(x))"
paulson@46821
   335
     "(\<forall>x\<in>RepFun(A,f). P(x)) \<longleftrightarrow> (\<forall>y\<in>A. P(f(y)))"
paulson@46821
   336
     "(\<forall>x\<in>\<Union>(A).P(x)) \<longleftrightarrow> (\<forall>y\<in>A. \<forall>x\<in>y. P(x))"
paulson@13780
   337
by blast+
paulson@13780
   338
paulson@13780
   339
lemma ball_simps2:
paulson@46821
   340
     "(\<forall>x\<in>A. P & Q(x))   \<longleftrightarrow> (A=0 | P) & (\<forall>x\<in>A. Q(x))"
paulson@46821
   341
     "(\<forall>x\<in>A. P | Q(x))   \<longleftrightarrow> (P | (\<forall>x\<in>A. Q(x)))"
paulson@46821
   342
     "(\<forall>x\<in>A. P \<longrightarrow> Q(x)) \<longleftrightarrow> (P \<longrightarrow> (\<forall>x\<in>A. Q(x)))"
paulson@13780
   343
by blast+
paulson@13780
   344
paulson@13780
   345
lemma ball_simps3:
paulson@46821
   346
     "(\<forall>x\<in>Collect(A,Q).P(x)) \<longleftrightarrow> (\<forall>x\<in>A. Q(x) \<longrightarrow> P(x))"
paulson@13780
   347
by blast+
paulson@13780
   348
paulson@13780
   349
lemmas ball_simps [simp] = ball_simps1 ball_simps2 ball_simps3
paulson@13780
   350
paulson@13780
   351
lemma ball_conj_distrib:
paulson@46821
   352
    "(\<forall>x\<in>A. P(x) & Q(x)) \<longleftrightarrow> ((\<forall>x\<in>A. P(x)) & (\<forall>x\<in>A. Q(x)))"
paulson@13780
   353
by blast
paulson@13780
   354
paulson@13780
   355
paulson@13780
   356
subsection{*Miniscoping of the Bounded Existential Quantifier*}
paulson@13780
   357
paulson@13780
   358
lemma bex_simps1:
paulson@46821
   359
     "(\<exists>x\<in>A. P(x) & Q) \<longleftrightarrow> ((\<exists>x\<in>A. P(x)) & Q)"
paulson@46821
   360
     "(\<exists>x\<in>A. P(x) | Q) \<longleftrightarrow> (\<exists>x\<in>A. P(x)) | (A\<noteq>0 & Q)"
paulson@46821
   361
     "(\<exists>x\<in>A. P(x) \<longrightarrow> Q) \<longleftrightarrow> ((\<forall>x\<in>A. P(x)) \<longrightarrow> (A\<noteq>0 & Q))"
paulson@46821
   362
     "(\<exists>x\<in>0.P(x)) \<longleftrightarrow> False"
paulson@46821
   363
     "(\<exists>x\<in>succ(i).P(x)) \<longleftrightarrow> P(i) | (\<exists>x\<in>i. P(x))"
paulson@46821
   364
     "(\<exists>x\<in>cons(a,B).P(x)) \<longleftrightarrow> P(a) | (\<exists>x\<in>B. P(x))"
paulson@46821
   365
     "(\<exists>x\<in>RepFun(A,f). P(x)) \<longleftrightarrow> (\<exists>y\<in>A. P(f(y)))"
paulson@46821
   366
     "(\<exists>x\<in>\<Union>(A).P(x)) \<longleftrightarrow> (\<exists>y\<in>A. \<exists>x\<in>y.  P(x))"
paulson@46821
   367
     "(~(\<exists>x\<in>A. P(x))) \<longleftrightarrow> (\<forall>x\<in>A. ~P(x))"
paulson@13780
   368
by blast+
paulson@13780
   369
paulson@13780
   370
lemma bex_simps2:
paulson@46821
   371
     "(\<exists>x\<in>A. P & Q(x)) \<longleftrightarrow> (P & (\<exists>x\<in>A. Q(x)))"
paulson@46821
   372
     "(\<exists>x\<in>A. P | Q(x)) \<longleftrightarrow> (A\<noteq>0 & P) | (\<exists>x\<in>A. Q(x))"
paulson@46821
   373
     "(\<exists>x\<in>A. P \<longrightarrow> Q(x)) \<longleftrightarrow> ((A=0 | P) \<longrightarrow> (\<exists>x\<in>A. Q(x)))"
paulson@13780
   374
by blast+
paulson@13780
   375
paulson@13780
   376
lemma bex_simps3:
paulson@46821
   377
     "(\<exists>x\<in>Collect(A,Q).P(x)) \<longleftrightarrow> (\<exists>x\<in>A. Q(x) & P(x))"
paulson@13780
   378
by blast
paulson@13780
   379
paulson@13780
   380
lemmas bex_simps [simp] = bex_simps1 bex_simps2 bex_simps3
paulson@13780
   381
paulson@13780
   382
lemma bex_disj_distrib:
paulson@46821
   383
    "(\<exists>x\<in>A. P(x) | Q(x)) \<longleftrightarrow> ((\<exists>x\<in>A. P(x)) | (\<exists>x\<in>A. Q(x)))"
paulson@13780
   384
by blast
paulson@13780
   385
paulson@13780
   386
paulson@13780
   387
(** One-point rule for bounded quantifiers: see HOL/Set.ML **)
paulson@13780
   388
paulson@46821
   389
lemma bex_triv_one_point1 [simp]: "(\<exists>x\<in>A. x=a) \<longleftrightarrow> (a:A)"
paulson@13780
   390
by blast
paulson@13780
   391
paulson@46821
   392
lemma bex_triv_one_point2 [simp]: "(\<exists>x\<in>A. a=x) \<longleftrightarrow> (a:A)"
paulson@13780
   393
by blast
paulson@13780
   394
paulson@46821
   395
lemma bex_one_point1 [simp]: "(\<exists>x\<in>A. x=a & P(x)) \<longleftrightarrow> (a:A & P(a))"
paulson@13780
   396
by blast
paulson@13780
   397
paulson@46821
   398
lemma bex_one_point2 [simp]: "(\<exists>x\<in>A. a=x & P(x)) \<longleftrightarrow> (a:A & P(a))"
paulson@13780
   399
by blast
paulson@13780
   400
paulson@46821
   401
lemma ball_one_point1 [simp]: "(\<forall>x\<in>A. x=a \<longrightarrow> P(x)) \<longleftrightarrow> (a:A \<longrightarrow> P(a))"
paulson@13780
   402
by blast
paulson@13780
   403
paulson@46821
   404
lemma ball_one_point2 [simp]: "(\<forall>x\<in>A. a=x \<longrightarrow> P(x)) \<longleftrightarrow> (a:A \<longrightarrow> P(a))"
paulson@13780
   405
by blast
paulson@13780
   406
paulson@13780
   407
paulson@13780
   408
subsection{*Miniscoping of the Replacement Operator*}
paulson@13780
   409
paulson@13780
   410
text{*These cover both @{term Replace} and @{term Collect}*}
paulson@13780
   411
lemma Rep_simps [simp]:
paulson@13780
   412
     "{x. y:0, R(x,y)} = 0"
paulson@13780
   413
     "{x:0. P(x)} = 0"
paulson@13780
   414
     "{x:A. Q} = (if Q then A else 0)"
paulson@13780
   415
     "RepFun(0,f) = 0"
paulson@13780
   416
     "RepFun(succ(i),f) = cons(f(i), RepFun(i,f))"
paulson@13780
   417
     "RepFun(cons(a,B),f) = cons(f(a), RepFun(B,f))"
paulson@13780
   418
by (simp_all, blast+)
paulson@13780
   419
paulson@13780
   420
paulson@13780
   421
subsection{*Miniscoping of Unions*}
paulson@13780
   422
paulson@13780
   423
lemma UN_simps1:
paulson@46820
   424
     "(\<Union>x\<in>C. cons(a, B(x))) = (if C=0 then 0 else cons(a, \<Union>x\<in>C. B(x)))"
paulson@46820
   425
     "(\<Union>x\<in>C. A(x) \<union> B')   = (if C=0 then 0 else (\<Union>x\<in>C. A(x)) \<union> B')"
paulson@46820
   426
     "(\<Union>x\<in>C. A' \<union> B(x))   = (if C=0 then 0 else A' \<union> (\<Union>x\<in>C. B(x)))"
paulson@46820
   427
     "(\<Union>x\<in>C. A(x) \<inter> B')  = ((\<Union>x\<in>C. A(x)) \<inter> B')"
paulson@46820
   428
     "(\<Union>x\<in>C. A' \<inter> B(x))  = (A' \<inter> (\<Union>x\<in>C. B(x)))"
paulson@46820
   429
     "(\<Union>x\<in>C. A(x) - B')    = ((\<Union>x\<in>C. A(x)) - B')"
paulson@46820
   430
     "(\<Union>x\<in>C. A' - B(x))    = (if C=0 then 0 else A' - (\<Inter>x\<in>C. B(x)))"
paulson@46820
   431
apply (simp_all add: Inter_def)
paulson@13780
   432
apply (blast intro!: equalityI )+
paulson@13780
   433
done
paulson@13780
   434
paulson@13780
   435
lemma UN_simps2:
paulson@46820
   436
      "(\<Union>x\<in>\<Union>(A). B(x)) = (\<Union>y\<in>A. \<Union>x\<in>y. B(x))"
paulson@46820
   437
      "(\<Union>z\<in>(\<Union>x\<in>A. B(x)). C(z)) = (\<Union>x\<in>A. \<Union>z\<in>B(x). C(z))"
paulson@46820
   438
      "(\<Union>x\<in>RepFun(A,f). B(x))     = (\<Union>a\<in>A. B(f(a)))"
paulson@13780
   439
by blast+
paulson@13780
   440
paulson@13780
   441
lemmas UN_simps [simp] = UN_simps1 UN_simps2
paulson@13780
   442
paulson@13780
   443
text{*Opposite of miniscoping: pull the operator out*}
paulson@13780
   444
paulson@13780
   445
lemma UN_extend_simps1:
paulson@46820
   446
     "(\<Union>x\<in>C. A(x)) \<union> B   = (if C=0 then B else (\<Union>x\<in>C. A(x) \<union> B))"
paulson@46820
   447
     "((\<Union>x\<in>C. A(x)) \<inter> B) = (\<Union>x\<in>C. A(x) \<inter> B)"
paulson@46820
   448
     "((\<Union>x\<in>C. A(x)) - B) = (\<Union>x\<in>C. A(x) - B)"
paulson@46820
   449
apply simp_all
paulson@13780
   450
apply blast+
paulson@13780
   451
done
paulson@13780
   452
paulson@13780
   453
lemma UN_extend_simps2:
paulson@46820
   454
     "cons(a, \<Union>x\<in>C. B(x)) = (if C=0 then {a} else (\<Union>x\<in>C. cons(a, B(x))))"
paulson@46820
   455
     "A \<union> (\<Union>x\<in>C. B(x))   = (if C=0 then A else (\<Union>x\<in>C. A \<union> B(x)))"
paulson@46820
   456
     "(A \<inter> (\<Union>x\<in>C. B(x))) = (\<Union>x\<in>C. A \<inter> B(x))"
paulson@46820
   457
     "A - (\<Inter>x\<in>C. B(x))    = (if C=0 then A else (\<Union>x\<in>C. A - B(x)))"
paulson@46820
   458
     "(\<Union>y\<in>A. \<Union>x\<in>y. B(x)) = (\<Union>x\<in>\<Union>(A). B(x))"
paulson@46820
   459
     "(\<Union>a\<in>A. B(f(a))) = (\<Union>x\<in>RepFun(A,f). B(x))"
paulson@46820
   460
apply (simp_all add: Inter_def)
paulson@13780
   461
apply (blast intro!: equalityI)+
paulson@13780
   462
done
paulson@13780
   463
paulson@13780
   464
lemma UN_UN_extend:
paulson@46820
   465
     "(\<Union>x\<in>A. \<Union>z\<in>B(x). C(z)) = (\<Union>z\<in>(\<Union>x\<in>A. B(x)). C(z))"
paulson@13780
   466
by blast
paulson@13780
   467
paulson@13780
   468
lemmas UN_extend_simps = UN_extend_simps1 UN_extend_simps2 UN_UN_extend
paulson@13780
   469
paulson@13780
   470
paulson@13780
   471
subsection{*Miniscoping of Intersections*}
paulson@13780
   472
paulson@13780
   473
lemma INT_simps1:
paulson@46820
   474
     "(\<Inter>x\<in>C. A(x) \<inter> B) = (\<Inter>x\<in>C. A(x)) \<inter> B"
paulson@46820
   475
     "(\<Inter>x\<in>C. A(x) - B)   = (\<Inter>x\<in>C. A(x)) - B"
paulson@46820
   476
     "(\<Inter>x\<in>C. A(x) \<union> B)  = (if C=0 then 0 else (\<Inter>x\<in>C. A(x)) \<union> B)"
paulson@13780
   477
by (simp_all add: Inter_def, blast+)
paulson@13780
   478
paulson@13780
   479
lemma INT_simps2:
paulson@46820
   480
     "(\<Inter>x\<in>C. A \<inter> B(x)) = A \<inter> (\<Inter>x\<in>C. B(x))"
paulson@46820
   481
     "(\<Inter>x\<in>C. A - B(x))   = (if C=0 then 0 else A - (\<Union>x\<in>C. B(x)))"
paulson@46820
   482
     "(\<Inter>x\<in>C. cons(a, B(x))) = (if C=0 then 0 else cons(a, \<Inter>x\<in>C. B(x)))"
paulson@46820
   483
     "(\<Inter>x\<in>C. A \<union> B(x))  = (if C=0 then 0 else A \<union> (\<Inter>x\<in>C. B(x)))"
paulson@46820
   484
apply (simp_all add: Inter_def)
paulson@13780
   485
apply (blast intro!: equalityI)+
paulson@13780
   486
done
paulson@13780
   487
paulson@13780
   488
lemmas INT_simps [simp] = INT_simps1 INT_simps2
paulson@13780
   489
paulson@13780
   490
text{*Opposite of miniscoping: pull the operator out*}
paulson@13780
   491
paulson@13780
   492
paulson@13780
   493
lemma INT_extend_simps1:
paulson@46820
   494
     "(\<Inter>x\<in>C. A(x)) \<inter> B = (\<Inter>x\<in>C. A(x) \<inter> B)"
paulson@46820
   495
     "(\<Inter>x\<in>C. A(x)) - B = (\<Inter>x\<in>C. A(x) - B)"
paulson@46820
   496
     "(\<Inter>x\<in>C. A(x)) \<union> B  = (if C=0 then B else (\<Inter>x\<in>C. A(x) \<union> B))"
paulson@13780
   497
apply (simp_all add: Inter_def, blast+)
paulson@13780
   498
done
paulson@13780
   499
paulson@13780
   500
lemma INT_extend_simps2:
paulson@46820
   501
     "A \<inter> (\<Inter>x\<in>C. B(x)) = (\<Inter>x\<in>C. A \<inter> B(x))"
paulson@46820
   502
     "A - (\<Union>x\<in>C. B(x))   = (if C=0 then A else (\<Inter>x\<in>C. A - B(x)))"
paulson@46820
   503
     "cons(a, \<Inter>x\<in>C. B(x)) = (if C=0 then {a} else (\<Inter>x\<in>C. cons(a, B(x))))"
paulson@46820
   504
     "A \<union> (\<Inter>x\<in>C. B(x))  = (if C=0 then A else (\<Inter>x\<in>C. A \<union> B(x)))"
paulson@46820
   505
apply (simp_all add: Inter_def)
paulson@13780
   506
apply (blast intro!: equalityI)+
paulson@13780
   507
done
paulson@13780
   508
paulson@13780
   509
lemmas INT_extend_simps = INT_extend_simps1 INT_extend_simps2
paulson@13780
   510
paulson@13780
   511
paulson@13780
   512
subsection{*Other simprules*}
paulson@13780
   513
paulson@13780
   514
paulson@13780
   515
(*** Miniscoping: pushing in big Unions, Intersections, quantifiers, etc. ***)
paulson@13780
   516
paulson@13780
   517
lemma misc_simps [simp]:
paulson@46820
   518
     "0 \<union> A = A"
paulson@46820
   519
     "A \<union> 0 = A"
paulson@46820
   520
     "0 \<inter> A = 0"
paulson@46820
   521
     "A \<inter> 0 = 0"
paulson@13780
   522
     "0 - A = 0"
paulson@13780
   523
     "A - 0 = A"
paulson@46820
   524
     "\<Union>(0) = 0"
paulson@46820
   525
     "\<Union>(cons(b,A)) = b \<union> \<Union>(A)"
paulson@46820
   526
     "\<Inter>({b}) = b"
paulson@13780
   527
by blast+
paulson@13780
   528
paulson@6153
   529
end