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