src/ZF/sum.ML
author clasohm
Thu Sep 16 12:20:38 1993 +0200 (1993-09-16)
changeset 0 a5a9c433f639
child 6 8ce8c4d13d4d
permissions -rw-r--r--
Initial revision
clasohm@0
     1
(*  Title: 	ZF/sum
clasohm@0
     2
    ID:         $Id$
clasohm@0
     3
    Author: 	Lawrence C Paulson, Cambridge University Computer Laboratory
clasohm@0
     4
    Copyright   1992  University of Cambridge
clasohm@0
     5
clasohm@0
     6
Disjoint sums in Zermelo-Fraenkel Set Theory 
clasohm@0
     7
*)
clasohm@0
     8
clasohm@0
     9
open Sum;
clasohm@0
    10
clasohm@0
    11
val sum_defs = [sum_def,Inl_def,Inr_def,case_def];
clasohm@0
    12
clasohm@0
    13
(** Introduction rules for the injections **)
clasohm@0
    14
clasohm@0
    15
goalw Sum.thy sum_defs "!!a A B. a : A ==> Inl(a) : A+B";
clasohm@0
    16
by (REPEAT (ares_tac [UnI1,SigmaI,singletonI] 1));
clasohm@0
    17
val InlI = result();
clasohm@0
    18
clasohm@0
    19
goalw Sum.thy sum_defs "!!b A B. b : B ==> Inr(b) : A+B";
clasohm@0
    20
by (REPEAT (ares_tac [UnI2,SigmaI,singletonI] 1));
clasohm@0
    21
val InrI = result();
clasohm@0
    22
clasohm@0
    23
(** Elimination rules **)
clasohm@0
    24
clasohm@0
    25
val major::prems = goalw Sum.thy sum_defs
clasohm@0
    26
    "[| u: A+B;  \
clasohm@0
    27
\       !!x. [| x:A;  u=Inl(x) |] ==> P; \
clasohm@0
    28
\       !!y. [| y:B;  u=Inr(y) |] ==> P \
clasohm@0
    29
\    |] ==> P";
clasohm@0
    30
by (rtac (major RS UnE) 1);
clasohm@0
    31
by (REPEAT (rtac refl 1
clasohm@0
    32
     ORELSE eresolve_tac (prems@[SigmaE,singletonE,ssubst]) 1));
clasohm@0
    33
val sumE = result();
clasohm@0
    34
clasohm@0
    35
(** Injection and freeness rules **)
clasohm@0
    36
clasohm@0
    37
val [major] = goalw Sum.thy sum_defs "Inl(a)=Inl(b) ==> a=b";
clasohm@0
    38
by (EVERY1 [rtac (major RS Pair_inject), assume_tac]);
clasohm@0
    39
val Inl_inject = result();
clasohm@0
    40
clasohm@0
    41
val [major] = goalw Sum.thy sum_defs "Inr(a)=Inr(b) ==> a=b";
clasohm@0
    42
by (EVERY1 [rtac (major RS Pair_inject), assume_tac]);
clasohm@0
    43
val Inr_inject = result();
clasohm@0
    44
clasohm@0
    45
val [major] = goalw Sum.thy sum_defs "Inl(a)=Inr(b) ==> P";
clasohm@0
    46
by (rtac (major RS Pair_inject) 1);
clasohm@0
    47
by (etac (sym RS one_neq_0) 1);
clasohm@0
    48
val Inl_neq_Inr = result();
clasohm@0
    49
clasohm@0
    50
val Inr_neq_Inl = sym RS Inl_neq_Inr;
clasohm@0
    51
clasohm@0
    52
(** Injection and freeness equivalences, for rewriting **)
clasohm@0
    53
clasohm@0
    54
goal Sum.thy "Inl(a)=Inl(b) <-> a=b";
clasohm@0
    55
by (rtac iffI 1);
clasohm@0
    56
by (REPEAT (eresolve_tac [Inl_inject,subst_context] 1));
clasohm@0
    57
val Inl_iff = result();
clasohm@0
    58
clasohm@0
    59
goal Sum.thy "Inr(a)=Inr(b) <-> a=b";
clasohm@0
    60
by (rtac iffI 1);
clasohm@0
    61
by (REPEAT (eresolve_tac [Inr_inject,subst_context] 1));
clasohm@0
    62
val Inr_iff = result();
clasohm@0
    63
clasohm@0
    64
goal Sum.thy "Inl(a)=Inr(b) <-> False";
clasohm@0
    65
by (rtac iffI 1);
clasohm@0
    66
by (REPEAT (eresolve_tac [Inl_neq_Inr,FalseE] 1));
clasohm@0
    67
val Inl_Inr_iff = result();
clasohm@0
    68
clasohm@0
    69
goal Sum.thy "Inr(b)=Inl(a) <-> False";
clasohm@0
    70
by (rtac iffI 1);
clasohm@0
    71
by (REPEAT (eresolve_tac [Inr_neq_Inl,FalseE] 1));
clasohm@0
    72
val Inr_Inl_iff = result();
clasohm@0
    73
clasohm@0
    74
val sum_cs = ZF_cs addIs [InlI,InrI] addSEs [sumE,Inl_neq_Inr,Inr_neq_Inl]
clasohm@0
    75
                   addSDs [Inl_inject,Inr_inject];
clasohm@0
    76
clasohm@0
    77
goal Sum.thy "u: A+B <-> (EX x. x:A & u=Inl(x)) | (EX y. y:B & u=Inr(y))";
clasohm@0
    78
by (fast_tac sum_cs 1);
clasohm@0
    79
val sum_iff = result();
clasohm@0
    80
clasohm@0
    81
goal Sum.thy "A+B <= C+D <-> A<=C & B<=D";
clasohm@0
    82
by (fast_tac sum_cs 1);
clasohm@0
    83
val sum_subset_iff = result();
clasohm@0
    84
clasohm@0
    85
goal Sum.thy "A+B = C+D <-> A=C & B=D";
clasohm@0
    86
by (SIMP_TAC (ZF_ss addrews [extension,sum_subset_iff]) 1);
clasohm@0
    87
by (fast_tac ZF_cs 1);
clasohm@0
    88
val sum_equal_iff = result();
clasohm@0
    89
clasohm@0
    90
(*** Eliminator -- case ***)
clasohm@0
    91
clasohm@0
    92
goalw Sum.thy sum_defs "case(c, d, Inl(a)) = c(a)";
clasohm@0
    93
by (rtac (split RS trans) 1);
clasohm@0
    94
by (rtac cond_0 1);
clasohm@0
    95
val case_Inl = result();
clasohm@0
    96
clasohm@0
    97
goalw Sum.thy sum_defs "case(c, d, Inr(b)) = d(b)";
clasohm@0
    98
by (rtac (split RS trans) 1);
clasohm@0
    99
by (rtac cond_1 1);
clasohm@0
   100
val case_Inr = result();
clasohm@0
   101
clasohm@0
   102
val prems = goalw Sum.thy [case_def]
clasohm@0
   103
    "[| u=u'; !!x. c(x)=c'(x);  !!y. d(y)=d'(y) |] ==>    \
clasohm@0
   104
\    case(c,d,u)=case(c',d',u')";
clasohm@0
   105
by (REPEAT (resolve_tac ([refl,split_cong,cond_cong] @ prems) 1));
clasohm@0
   106
val case_cong = result();
clasohm@0
   107
clasohm@0
   108
val major::prems = goal Sum.thy
clasohm@0
   109
    "[| u: A+B; \
clasohm@0
   110
\       !!x. x: A ==> c(x): C(Inl(x));   \
clasohm@0
   111
\       !!y. y: B ==> d(y): C(Inr(y)) \
clasohm@0
   112
\    |] ==> case(c,d,u) : C(u)";
clasohm@0
   113
by (rtac (major RS sumE) 1);
clasohm@0
   114
by (ALLGOALS (etac ssubst));
clasohm@0
   115
by (ALLGOALS (ASM_SIMP_TAC (ZF_ss addrews
clasohm@0
   116
			    (prems@[case_Inl,case_Inr]))));
clasohm@0
   117
val case_type = result();
clasohm@0
   118
clasohm@0
   119
(** Rules for the Part primitive **)
clasohm@0
   120
clasohm@0
   121
goalw Sum.thy [Part_def]
clasohm@0
   122
    "!!a b A h. [| a : A;  a=h(b) |] ==> a : Part(A,h)";
clasohm@0
   123
by (REPEAT (ares_tac [exI,CollectI] 1));
clasohm@0
   124
val Part_eqI = result();
clasohm@0
   125
clasohm@0
   126
val PartI = refl RSN (2,Part_eqI);
clasohm@0
   127
clasohm@0
   128
val major::prems = goalw Sum.thy [Part_def]
clasohm@0
   129
    "[| a : Part(A,h);  !!z. [| a : A;  a=h(z) |] ==> P  \
clasohm@0
   130
\    |] ==> P";
clasohm@0
   131
by (rtac (major RS CollectE) 1);
clasohm@0
   132
by (etac exE 1);
clasohm@0
   133
by (REPEAT (ares_tac prems 1));
clasohm@0
   134
val PartE = result();
clasohm@0
   135
clasohm@0
   136
goalw Sum.thy [Part_def] "Part(A,h) <= A";
clasohm@0
   137
by (rtac Collect_subset 1);
clasohm@0
   138
val Part_subset = result();
clasohm@0
   139
clasohm@0
   140
goal Sum.thy "!!A B h. A<=B ==> Part(A,h)<=Part(B,h)";
clasohm@0
   141
by (fast_tac (ZF_cs addIs [PartI] addSEs [PartE]) 1);
clasohm@0
   142
val Part_mono = result();
clasohm@0
   143
clasohm@0
   144
goal Sum.thy "Part(A+B,Inl) = {Inl(x). x: A}";
clasohm@0
   145
by (fast_tac (sum_cs addIs [PartI,equalityI] addSEs [PartE]) 1);
clasohm@0
   146
val Part_Inl = result();
clasohm@0
   147
clasohm@0
   148
goal Sum.thy "Part(A+B,Inr) = {Inr(y). y: B}";
clasohm@0
   149
by (fast_tac (sum_cs addIs [PartI,equalityI] addSEs [PartE]) 1);
clasohm@0
   150
val Part_Inr = result();
clasohm@0
   151
clasohm@0
   152
goalw Sum.thy [Part_def] "!!a. a : Part(A,h) ==> a : A";
clasohm@0
   153
by (etac CollectD1 1);
clasohm@0
   154
val PartD1 = result();
clasohm@0
   155
clasohm@0
   156
goal Sum.thy "Part(A,%x.x) = A";
clasohm@0
   157
by (fast_tac (ZF_cs addIs [PartI,equalityI] addSEs [PartE]) 1);
clasohm@0
   158
val Part_id = result();
clasohm@0
   159
clasohm@0
   160
goal Sum.thy "Part(A+B, %x.Inr(h(x))) = {Inr(y). y: Part(B,h)}";
clasohm@0
   161
by (fast_tac (sum_cs addIs [PartI,equalityI] addSEs [PartE]) 1);
clasohm@0
   162
val Part_Inr2 = result();
clasohm@0
   163
clasohm@0
   164
goal Sum.thy "!!A B C. C <= A+B ==> Part(C,Inl) Un Part(C,Inr) = C";
clasohm@0
   165
by (rtac equalityI 1);
clasohm@0
   166
by (rtac Un_least 1);
clasohm@0
   167
by (rtac Part_subset 1);
clasohm@0
   168
by (rtac Part_subset 1);
clasohm@0
   169
by (fast_tac (ZF_cs addIs [PartI] addSEs [sumE]) 1);
clasohm@0
   170
val Part_sum_equality = result();