src/ZF/upair.thy
author paulson
Sat Jun 29 21:33:06 2002 +0200 (2002-06-29)
changeset 13259 01fa0c8dbc92
parent 11770 b6bb7a853dd2
child 13356 c9cfe1638bf2
permissions -rw-r--r--
conversion of many files to Isar format
paulson@2469
     1
(*  Title:      ZF/upair.thy
paulson@2469
     2
    ID:         $Id$
paulson@2469
     3
    Author:     Lawrence C Paulson and Martin D Coen, CU Computer Laboratory
paulson@2469
     4
    Copyright   1993  University of Cambridge
paulson@13259
     5
paulson@13259
     6
UNORDERED pairs in Zermelo-Fraenkel Set Theory 
paulson@13259
     7
paulson@13259
     8
Observe the order of dependence:
paulson@13259
     9
    Upair is defined in terms of Replace
paulson@13259
    10
    Un is defined in terms of Upair and Union (similarly for Int)
paulson@13259
    11
    cons is defined in terms of Upair and Un
paulson@13259
    12
    Ordered pairs and descriptions are defined using cons ("set notation")
paulson@2469
    13
*)
paulson@2469
    14
paulson@9570
    15
theory upair = ZF
paulson@9570
    16
files "Tools/typechk":
paulson@6153
    17
wenzelm@9907
    18
setup TypeCheck.setup
wenzelm@11770
    19
declare atomize_ball [symmetric, rulify]
paulson@6153
    20
paulson@13259
    21
(*** Lemmas about power sets  ***)
paulson@13259
    22
paulson@13259
    23
lemmas Pow_bottom = empty_subsetI [THEN PowI] (* 0 : Pow(B) *)
paulson@13259
    24
lemmas Pow_top = subset_refl [THEN PowI] (* A : Pow(A) *)
paulson@13259
    25
paulson@13259
    26
paulson@13259
    27
(*** Unordered pairs - Upair ***)
paulson@13259
    28
paulson@13259
    29
lemma Upair_iff [simp]: "c : Upair(a,b) <-> (c=a | c=b)"
paulson@13259
    30
by (unfold Upair_def, blast)
paulson@13259
    31
paulson@13259
    32
lemma UpairI1: "a : Upair(a,b)"
paulson@13259
    33
by simp
paulson@13259
    34
paulson@13259
    35
lemma UpairI2: "b : Upair(a,b)"
paulson@13259
    36
by simp
paulson@13259
    37
paulson@13259
    38
lemma UpairE:
paulson@13259
    39
    "[| a : Upair(b,c);  a=b ==> P;  a=c ==> P |] ==> P"
paulson@13259
    40
apply simp
paulson@13259
    41
apply blast 
paulson@13259
    42
done
paulson@13259
    43
paulson@13259
    44
(*** Rules for binary union -- Un -- defined via Upair ***)
paulson@13259
    45
paulson@13259
    46
lemma Un_iff [simp]: "c : A Un B <-> (c:A | c:B)"
paulson@13259
    47
apply (simp add: Un_def)
paulson@13259
    48
apply (blast intro: UpairI1 UpairI2 elim: UpairE)
paulson@13259
    49
done
paulson@13259
    50
paulson@13259
    51
lemma UnI1: "c : A ==> c : A Un B"
paulson@13259
    52
by simp
paulson@13259
    53
paulson@13259
    54
lemma UnI2: "c : B ==> c : A Un B"
paulson@13259
    55
by simp
paulson@13259
    56
paulson@13259
    57
lemma UnE [elim!]: "[| c : A Un B;  c:A ==> P;  c:B ==> P |] ==> P"
paulson@13259
    58
apply simp 
paulson@13259
    59
apply blast 
paulson@13259
    60
done
paulson@13259
    61
paulson@13259
    62
(*Stronger version of the rule above*)
paulson@13259
    63
lemma UnE': "[| c : A Un B;  c:A ==> P;  [| c:B;  c~:A |] ==> P |] ==> P"
paulson@13259
    64
apply simp 
paulson@13259
    65
apply blast 
paulson@13259
    66
done
paulson@13259
    67
paulson@13259
    68
(*Classical introduction rule: no commitment to A vs B*)
paulson@13259
    69
lemma UnCI [intro!]: "(c ~: B ==> c : A) ==> c : A Un B"
paulson@13259
    70
apply simp
paulson@13259
    71
apply blast
paulson@13259
    72
done
paulson@13259
    73
paulson@13259
    74
paulson@13259
    75
(*** Rules for small intersection -- Int -- defined via Upair ***)
paulson@13259
    76
paulson@13259
    77
lemma Int_iff [simp]: "c : A Int B <-> (c:A & c:B)"
paulson@13259
    78
apply (unfold Int_def)
paulson@13259
    79
apply (blast intro: UpairI1 UpairI2 elim: UpairE)
paulson@13259
    80
done
paulson@13259
    81
paulson@13259
    82
lemma IntI [intro!]: "[| c : A;  c : B |] ==> c : A Int B"
paulson@13259
    83
by simp
paulson@13259
    84
paulson@13259
    85
lemma IntD1: "c : A Int B ==> c : A"
paulson@13259
    86
by simp
paulson@13259
    87
paulson@13259
    88
lemma IntD2: "c : A Int B ==> c : B"
paulson@13259
    89
by simp
paulson@13259
    90
paulson@13259
    91
lemma IntE [elim!]: "[| c : A Int B;  [| c:A; c:B |] ==> P |] ==> P"
paulson@13259
    92
by simp
paulson@13259
    93
paulson@13259
    94
paulson@13259
    95
(*** Rules for set difference -- defined via Upair ***)
paulson@13259
    96
paulson@13259
    97
lemma Diff_iff [simp]: "c : A-B <-> (c:A & c~:B)"
paulson@13259
    98
by (unfold Diff_def, blast)
paulson@13259
    99
paulson@13259
   100
lemma DiffI [intro!]: "[| c : A;  c ~: B |] ==> c : A - B"
paulson@13259
   101
by simp
paulson@13259
   102
paulson@13259
   103
lemma DiffD1: "c : A - B ==> c : A"
paulson@13259
   104
by simp
paulson@13259
   105
paulson@13259
   106
lemma DiffD2: "c : A - B ==> c ~: B"
paulson@13259
   107
by simp
paulson@13259
   108
paulson@13259
   109
lemma DiffE [elim!]: "[| c : A - B;  [| c:A; c~:B |] ==> P |] ==> P"
paulson@13259
   110
by simp
paulson@13259
   111
paulson@13259
   112
paulson@13259
   113
(*** Rules for cons -- defined via Un and Upair ***)
paulson@13259
   114
paulson@13259
   115
lemma cons_iff [simp]: "a : cons(b,A) <-> (a=b | a:A)"
paulson@13259
   116
apply (unfold cons_def)
paulson@13259
   117
apply (blast intro: UpairI1 UpairI2 elim: UpairE)
paulson@13259
   118
done
paulson@13259
   119
paulson@13259
   120
(*risky as a typechecking rule, but solves otherwise unconstrained goals of
paulson@13259
   121
the form x : ?A*)
paulson@13259
   122
lemma consI1 [simp,TC]: "a : cons(a,B)"
paulson@13259
   123
by simp
paulson@13259
   124
paulson@13259
   125
paulson@13259
   126
lemma consI2: "a : B ==> a : cons(b,B)"
paulson@13259
   127
by simp
paulson@13259
   128
paulson@13259
   129
lemma consE [elim!]:
paulson@13259
   130
    "[| a : cons(b,A);  a=b ==> P;  a:A ==> P |] ==> P"
paulson@13259
   131
apply simp 
paulson@13259
   132
apply blast 
paulson@13259
   133
done
paulson@13259
   134
paulson@13259
   135
(*Stronger version of the rule above*)
paulson@13259
   136
lemma consE':
paulson@13259
   137
    "[| a : cons(b,A);  a=b ==> P;  [| a:A;  a~=b |] ==> P |] ==> P"
paulson@13259
   138
apply simp 
paulson@13259
   139
apply blast 
paulson@13259
   140
done
paulson@13259
   141
paulson@13259
   142
(*Classical introduction rule*)
paulson@13259
   143
lemma consCI [intro!]: "(a~:B ==> a=b) ==> a: cons(b,B)"
paulson@13259
   144
apply simp
paulson@13259
   145
apply blast
paulson@13259
   146
done
paulson@13259
   147
paulson@13259
   148
lemma cons_not_0 [simp]: "cons(a,B) ~= 0"
paulson@13259
   149
by (blast elim: equalityE)
paulson@13259
   150
paulson@13259
   151
lemmas cons_neq_0 = cons_not_0 [THEN notE, standard]
paulson@13259
   152
paulson@13259
   153
declare cons_not_0 [THEN not_sym, simp]
paulson@13259
   154
paulson@13259
   155
paulson@13259
   156
(*** Singletons - using cons ***)
paulson@13259
   157
paulson@13259
   158
lemma singleton_iff: "a : {b} <-> a=b"
paulson@13259
   159
by simp
paulson@13259
   160
paulson@13259
   161
lemma singletonI [intro!]: "a : {a}"
paulson@13259
   162
by (rule consI1)
paulson@13259
   163
paulson@13259
   164
lemmas singletonE = singleton_iff [THEN iffD1, elim_format, standard, elim!]
paulson@13259
   165
paulson@13259
   166
paulson@13259
   167
(*** Rules for Descriptions ***)
paulson@13259
   168
paulson@13259
   169
lemma the_equality [intro]:
paulson@13259
   170
    "[| P(a);  !!x. P(x) ==> x=a |] ==> (THE x. P(x)) = a"
paulson@13259
   171
apply (unfold the_def) 
paulson@13259
   172
apply (fast dest: subst)
paulson@13259
   173
done
paulson@13259
   174
paulson@13259
   175
(* Only use this if you already know EX!x. P(x) *)
paulson@13259
   176
lemma the_equality2: "[| EX! x. P(x);  P(a) |] ==> (THE x. P(x)) = a"
paulson@13259
   177
by blast
paulson@13259
   178
paulson@13259
   179
lemma theI: "EX! x. P(x) ==> P(THE x. P(x))"
paulson@13259
   180
apply (erule ex1E)
paulson@13259
   181
apply (subst the_equality)
paulson@13259
   182
apply (blast+)
paulson@13259
   183
done
paulson@13259
   184
paulson@13259
   185
(*the_cong is no longer necessary: if (ALL y.P(y)<->Q(y)) then 
paulson@13259
   186
  (THE x.P(x))  rewrites to  (THE x. Q(x))  *)
paulson@13259
   187
paulson@13259
   188
(*If it's "undefined", it's zero!*)
paulson@13259
   189
lemma the_0: "~ (EX! x. P(x)) ==> (THE x. P(x))=0"
paulson@13259
   190
apply (unfold the_def)
paulson@13259
   191
apply (blast elim!: ReplaceE)
paulson@13259
   192
done
paulson@13259
   193
paulson@13259
   194
(*Easier to apply than theI: conclusion has only one occurrence of P*)
paulson@13259
   195
lemma theI2:
paulson@13259
   196
    assumes p1: "~ Q(0) ==> EX! x. P(x)"
paulson@13259
   197
        and p2: "!!x. P(x) ==> Q(x)"
paulson@13259
   198
    shows "Q(THE x. P(x))"
paulson@13259
   199
apply (rule classical)
paulson@13259
   200
apply (rule p2)
paulson@13259
   201
apply (rule theI)
paulson@13259
   202
apply (rule classical)
paulson@13259
   203
apply (rule p1)
paulson@13259
   204
apply (erule the_0 [THEN subst], assumption)
paulson@13259
   205
done
paulson@13259
   206
paulson@13259
   207
(*** if -- a conditional expression for formulae ***)
paulson@13259
   208
paulson@13259
   209
lemma if_true [simp]: "(if True then a else b) = a"
paulson@13259
   210
by (unfold if_def, blast)
paulson@13259
   211
paulson@13259
   212
lemma if_false [simp]: "(if False then a else b) = b"
paulson@13259
   213
by (unfold if_def, blast)
paulson@13259
   214
paulson@13259
   215
(*Never use with case splitting, or if P is known to be true or false*)
paulson@13259
   216
lemma if_cong:
paulson@13259
   217
    "[| P<->Q;  Q ==> a=c;  ~Q ==> b=d |]  
paulson@13259
   218
     ==> (if P then a else b) = (if Q then c else d)"
paulson@13259
   219
by (simp add: if_def cong add: conj_cong)
paulson@13259
   220
paulson@13259
   221
(*Prevents simplification of x and y: faster and allows the execution
paulson@13259
   222
  of functional programs. NOW THE DEFAULT.*)
paulson@13259
   223
lemma if_weak_cong: "P<->Q ==> (if P then x else y) = (if Q then x else y)"
paulson@13259
   224
by simp
paulson@13259
   225
paulson@13259
   226
(*Not needed for rewriting, since P would rewrite to True anyway*)
paulson@13259
   227
lemma if_P: "P ==> (if P then a else b) = a"
paulson@13259
   228
by (unfold if_def, blast)
paulson@13259
   229
paulson@13259
   230
(*Not needed for rewriting, since P would rewrite to False anyway*)
paulson@13259
   231
lemma if_not_P: "~P ==> (if P then a else b) = b"
paulson@13259
   232
by (unfold if_def, blast)
paulson@13259
   233
paulson@13259
   234
lemma split_if: "P(if Q then x else y) <-> ((Q --> P(x)) & (~Q --> P(y)))"
paulson@13259
   235
(*no case_tac yet!*)
paulson@13259
   236
apply (rule_tac P=Q in case_split_thm, simp_all)
paulson@13259
   237
done
paulson@13259
   238
paulson@13259
   239
(** Rewrite rules for boolean case-splitting: faster than 
paulson@13259
   240
	addsplits[split_if]
paulson@13259
   241
**)
paulson@13259
   242
paulson@13259
   243
lemmas split_if_eq1 = split_if [of "%x. x = b", standard]
paulson@13259
   244
lemmas split_if_eq2 = split_if [of "%x. a = x", standard]
paulson@13259
   245
paulson@13259
   246
lemmas split_if_mem1 = split_if [of "%x. x : b", standard]
paulson@13259
   247
lemmas split_if_mem2 = split_if [of "%x. a : x", standard]
paulson@13259
   248
paulson@13259
   249
lemmas split_ifs = split_if_eq1 split_if_eq2 split_if_mem1 split_if_mem2
paulson@13259
   250
paulson@13259
   251
(*Logically equivalent to split_if_mem2*)
paulson@13259
   252
lemma if_iff: "a: (if P then x else y) <-> P & a:x | ~P & a:y"
paulson@13259
   253
by (simp split add: split_if)
paulson@13259
   254
paulson@13259
   255
lemma if_type [TC]:
paulson@13259
   256
    "[| P ==> a: A;  ~P ==> b: A |] ==> (if P then a else b): A"
paulson@13259
   257
by (simp split add: split_if)
paulson@13259
   258
paulson@13259
   259
paulson@13259
   260
(*** Foundation lemmas ***)
paulson@13259
   261
paulson@13259
   262
(*was called mem_anti_sym*)
paulson@13259
   263
lemma mem_asym: "[| a:b;  ~P ==> b:a |] ==> P"
paulson@13259
   264
apply (rule classical)
paulson@13259
   265
apply (rule_tac A1 = "{a,b}" in foundation [THEN disjE])
paulson@13259
   266
apply (blast elim!: equalityE)+
paulson@13259
   267
done
paulson@13259
   268
paulson@13259
   269
(*was called mem_anti_refl*)
paulson@13259
   270
lemma mem_irrefl: "a:a ==> P"
paulson@13259
   271
by (blast intro: mem_asym)
paulson@13259
   272
paulson@13259
   273
(*mem_irrefl should NOT be added to default databases:
paulson@13259
   274
      it would be tried on most goals, making proofs slower!*)
paulson@13259
   275
paulson@13259
   276
lemma mem_not_refl: "a ~: a"
paulson@13259
   277
apply (rule notI)
paulson@13259
   278
apply (erule mem_irrefl)
paulson@13259
   279
done
paulson@13259
   280
paulson@13259
   281
(*Good for proving inequalities by rewriting*)
paulson@13259
   282
lemma mem_imp_not_eq: "a:A ==> a ~= A"
paulson@13259
   283
by (blast elim!: mem_irrefl)
paulson@13259
   284
paulson@13259
   285
(*** Rules for succ ***)
paulson@13259
   286
paulson@13259
   287
lemma succ_iff: "i : succ(j) <-> i=j | i:j"
paulson@13259
   288
by (unfold succ_def, blast)
paulson@13259
   289
paulson@13259
   290
lemma succI1 [simp]: "i : succ(i)"
paulson@13259
   291
by (simp add: succ_iff)
paulson@13259
   292
paulson@13259
   293
lemma succI2: "i : j ==> i : succ(j)"
paulson@13259
   294
by (simp add: succ_iff)
paulson@13259
   295
paulson@13259
   296
lemma succE [elim!]: 
paulson@13259
   297
    "[| i : succ(j);  i=j ==> P;  i:j ==> P |] ==> P"
paulson@13259
   298
apply (simp add: succ_iff, blast) 
paulson@13259
   299
done
paulson@13259
   300
paulson@13259
   301
(*Classical introduction rule*)
paulson@13259
   302
lemma succCI [intro!]: "(i~:j ==> i=j) ==> i: succ(j)"
paulson@13259
   303
by (simp add: succ_iff, blast)
paulson@13259
   304
paulson@13259
   305
lemma succ_not_0 [simp]: "succ(n) ~= 0"
paulson@13259
   306
by (blast elim!: equalityE)
paulson@13259
   307
paulson@13259
   308
lemmas succ_neq_0 = succ_not_0 [THEN notE, standard, 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@13259
   313
(* succ(c) <= B ==> c : B *)
paulson@13259
   314
lemmas succ_subsetD = succI1 [THEN [2] subsetD]
paulson@13259
   315
paulson@13259
   316
(* succ(b) ~= b *)
paulson@13259
   317
lemmas succ_neq_self = succI1 [THEN mem_imp_not_eq, THEN not_sym, standard]
paulson@13259
   318
paulson@13259
   319
lemma succ_inject_iff [simp]: "succ(m) = succ(n) <-> m=n"
paulson@13259
   320
by (blast elim: mem_asym elim!: equalityE)
paulson@13259
   321
paulson@13259
   322
lemmas succ_inject = succ_inject_iff [THEN iffD1, standard, dest!]
paulson@13259
   323
paulson@13259
   324
ML
paulson@13259
   325
{*
paulson@13259
   326
val Pow_bottom = thm "Pow_bottom";
paulson@13259
   327
val Pow_top = thm "Pow_top";
paulson@13259
   328
val Upair_iff = thm "Upair_iff";
paulson@13259
   329
val UpairI1 = thm "UpairI1";
paulson@13259
   330
val UpairI2 = thm "UpairI2";
paulson@13259
   331
val UpairE = thm "UpairE";
paulson@13259
   332
val Un_iff = thm "Un_iff";
paulson@13259
   333
val UnI1 = thm "UnI1";
paulson@13259
   334
val UnI2 = thm "UnI2";
paulson@13259
   335
val UnE = thm "UnE";
paulson@13259
   336
val UnE' = thm "UnE'";
paulson@13259
   337
val UnCI = thm "UnCI";
paulson@13259
   338
val Int_iff = thm "Int_iff";
paulson@13259
   339
val IntI = thm "IntI";
paulson@13259
   340
val IntD1 = thm "IntD1";
paulson@13259
   341
val IntD2 = thm "IntD2";
paulson@13259
   342
val IntE = thm "IntE";
paulson@13259
   343
val Diff_iff = thm "Diff_iff";
paulson@13259
   344
val DiffI = thm "DiffI";
paulson@13259
   345
val DiffD1 = thm "DiffD1";
paulson@13259
   346
val DiffD2 = thm "DiffD2";
paulson@13259
   347
val DiffE = thm "DiffE";
paulson@13259
   348
val cons_iff = thm "cons_iff";
paulson@13259
   349
val consI1 = thm "consI1";
paulson@13259
   350
val consI2 = thm "consI2";
paulson@13259
   351
val consE = thm "consE";
paulson@13259
   352
val consE' = thm "consE'";
paulson@13259
   353
val consCI = thm "consCI";
paulson@13259
   354
val cons_not_0 = thm "cons_not_0";
paulson@13259
   355
val cons_neq_0 = thm "cons_neq_0";
paulson@13259
   356
val singleton_iff = thm "singleton_iff";
paulson@13259
   357
val singletonI = thm "singletonI";
paulson@13259
   358
val singletonE = thm "singletonE";
paulson@13259
   359
val the_equality = thm "the_equality";
paulson@13259
   360
val the_equality2 = thm "the_equality2";
paulson@13259
   361
val theI = thm "theI";
paulson@13259
   362
val the_0 = thm "the_0";
paulson@13259
   363
val theI2 = thm "theI2";
paulson@13259
   364
val if_true = thm "if_true";
paulson@13259
   365
val if_false = thm "if_false";
paulson@13259
   366
val if_cong = thm "if_cong";
paulson@13259
   367
val if_weak_cong = thm "if_weak_cong";
paulson@13259
   368
val if_P = thm "if_P";
paulson@13259
   369
val if_not_P = thm "if_not_P";
paulson@13259
   370
val split_if = thm "split_if";
paulson@13259
   371
val split_if_eq1 = thm "split_if_eq1";
paulson@13259
   372
val split_if_eq2 = thm "split_if_eq2";
paulson@13259
   373
val split_if_mem1 = thm "split_if_mem1";
paulson@13259
   374
val split_if_mem2 = thm "split_if_mem2";
paulson@13259
   375
val if_iff = thm "if_iff";
paulson@13259
   376
val if_type = thm "if_type";
paulson@13259
   377
val mem_asym = thm "mem_asym";
paulson@13259
   378
val mem_irrefl = thm "mem_irrefl";
paulson@13259
   379
val mem_not_refl = thm "mem_not_refl";
paulson@13259
   380
val mem_imp_not_eq = thm "mem_imp_not_eq";
paulson@13259
   381
val succ_iff = thm "succ_iff";
paulson@13259
   382
val succI1 = thm "succI1";
paulson@13259
   383
val succI2 = thm "succI2";
paulson@13259
   384
val succE = thm "succE";
paulson@13259
   385
val succCI = thm "succCI";
paulson@13259
   386
val succ_not_0 = thm "succ_not_0";
paulson@13259
   387
val succ_neq_0 = thm "succ_neq_0";
paulson@13259
   388
val succ_subsetD = thm "succ_subsetD";
paulson@13259
   389
val succ_neq_self = thm "succ_neq_self";
paulson@13259
   390
val succ_inject_iff = thm "succ_inject_iff";
paulson@13259
   391
val succ_inject = thm "succ_inject";
paulson@13259
   392
paulson@13259
   393
val split_ifs = thms "split_ifs";
paulson@13259
   394
*}
paulson@13259
   395
paulson@6153
   396
end