src/ZF/equalities.thy
changeset 13168 afcbca3498b0
parent 13165 31d020705aff
child 13169 394a6c649547
equal deleted inserted replaced
13167:7157c6d47aa4 13168:afcbca3498b0
     1 (*  Title:      ZF/equalities
     1 (*  Title:      ZF/equalities
     2     ID:         $Id$
     2     ID:         $Id$
     3     Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
     3     Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
     4     Copyright   1992  University of Cambridge
     4     Copyright   1992  University of Cambridge
     5 
     5 
     6 Set Theory examples: Union, Intersection, Inclusion, etc.
     6 Converse, domain, range of a relation or function.
       
     7 
       
     8 And set theory equalities involving Union, Intersection, Inclusion, etc.
     7     (Thanks also to Philippe de Groote.)
     9     (Thanks also to Philippe de Groote.)
     8 *)
    10 *)
     9 
    11 
    10 theory equalities = domrange:
    12 theory equalities = pair + subset:
       
    13 
       
    14 
       
    15 (*** converse ***)
       
    16 
       
    17 lemma converse_iff [iff]: "<a,b>: converse(r) <-> <b,a>:r"
       
    18 apply (unfold converse_def)
       
    19 apply blast
       
    20 done
       
    21 
       
    22 lemma converseI: "<a,b>:r ==> <b,a>:converse(r)"
       
    23 apply (unfold converse_def)
       
    24 apply blast
       
    25 done
       
    26 
       
    27 lemma converseD: "<a,b> : converse(r) ==> <b,a> : r"
       
    28 apply (unfold converse_def)
       
    29 apply blast
       
    30 done
       
    31 
       
    32 lemma converseE [elim!]:
       
    33     "[| yx : converse(r);   
       
    34         !!x y. [| yx=<y,x>;  <x,y>:r |] ==> P |]
       
    35      ==> P"
       
    36 apply (unfold converse_def)
       
    37 apply (blast intro: elim:); 
       
    38 done
       
    39 
       
    40 lemma converse_converse: "r<=Sigma(A,B) ==> converse(converse(r)) = r"
       
    41 apply blast
       
    42 done
       
    43 
       
    44 lemma converse_type: "r<=A*B ==> converse(r)<=B*A"
       
    45 apply blast
       
    46 done
       
    47 
       
    48 lemma converse_prod [simp]: "converse(A*B) = B*A"
       
    49 apply blast
       
    50 done
       
    51 
       
    52 lemma converse_empty [simp]: "converse(0) = 0"
       
    53 apply blast
       
    54 done
       
    55 
       
    56 lemma converse_subset_iff: "A <= Sigma(X,Y) ==> converse(A) <= converse(B) <-> A <= B"
       
    57 apply blast
       
    58 done
       
    59 
       
    60 
       
    61 (*** domain ***)
       
    62 
       
    63 lemma domain_iff: "a: domain(r) <-> (EX y. <a,y>: r)"
       
    64 apply (unfold domain_def)
       
    65 apply blast
       
    66 done
       
    67 
       
    68 lemma domainI [intro]: "<a,b>: r ==> a: domain(r)"
       
    69 apply (unfold domain_def)
       
    70 apply blast
       
    71 done
       
    72 
       
    73 lemma domainE [elim!]:
       
    74     "[| a : domain(r);  !!y. <a,y>: r ==> P |] ==> P"
       
    75 apply (unfold domain_def)
       
    76 apply blast
       
    77 done
       
    78 
       
    79 lemma domain_subset: "domain(Sigma(A,B)) <= A"
       
    80 apply blast
       
    81 done
       
    82 
       
    83 (*** range ***)
       
    84 
       
    85 lemma rangeI [intro]: "<a,b>: r ==> b : range(r)"
       
    86 apply (unfold range_def)
       
    87 apply (erule converseI [THEN domainI])
       
    88 done
       
    89 
       
    90 lemma rangeE [elim!]: "[| b : range(r);  !!x. <x,b>: r ==> P |] ==> P"
       
    91 apply (unfold range_def)
       
    92 apply (blast intro: elim:); 
       
    93 done
       
    94 
       
    95 lemma range_subset: "range(A*B) <= B"
       
    96 apply (unfold range_def)
       
    97 apply (subst converse_prod)
       
    98 apply (rule domain_subset)
       
    99 done
       
   100 
       
   101 
       
   102 (*** field ***)
       
   103 
       
   104 lemma fieldI1: "<a,b>: r ==> a : field(r)"
       
   105 apply (unfold field_def)
       
   106 apply blast
       
   107 done
       
   108 
       
   109 lemma fieldI2: "<a,b>: r ==> b : field(r)"
       
   110 apply (unfold field_def)
       
   111 apply blast
       
   112 done
       
   113 
       
   114 lemma fieldCI [intro]: 
       
   115     "(~ <c,a>:r ==> <a,b>: r) ==> a : field(r)"
       
   116 apply (unfold field_def)
       
   117 apply blast
       
   118 done
       
   119 
       
   120 lemma fieldE [elim!]: 
       
   121      "[| a : field(r);   
       
   122          !!x. <a,x>: r ==> P;   
       
   123          !!x. <x,a>: r ==> P        |] ==> P"
       
   124 apply (unfold field_def)
       
   125 apply blast
       
   126 done
       
   127 
       
   128 lemma field_subset: "field(A*B) <= A Un B"
       
   129 apply blast
       
   130 done
       
   131 
       
   132 lemma domain_subset_field: "domain(r) <= field(r)"
       
   133 apply (unfold field_def)
       
   134 apply (rule Un_upper1)
       
   135 done
       
   136 
       
   137 lemma range_subset_field: "range(r) <= field(r)"
       
   138 apply (unfold field_def)
       
   139 apply (rule Un_upper2)
       
   140 done
       
   141 
       
   142 lemma domain_times_range: "r <= Sigma(A,B) ==> r <= domain(r)*range(r)"
       
   143 apply blast
       
   144 done
       
   145 
       
   146 lemma field_times_field: "r <= Sigma(A,B) ==> r <= field(r)*field(r)"
       
   147 apply blast
       
   148 done
       
   149 
       
   150 
       
   151 (*** Image of a set under a function/relation ***)
       
   152 
       
   153 lemma image_iff: "b : r``A <-> (EX x:A. <x,b>:r)"
       
   154 apply (unfold image_def)
       
   155 apply blast
       
   156 done
       
   157 
       
   158 lemma image_singleton_iff: "b : r``{a} <-> <a,b>:r"
       
   159 apply (rule image_iff [THEN iff_trans])
       
   160 apply blast
       
   161 done
       
   162 
       
   163 lemma imageI [intro]: "[| <a,b>: r;  a:A |] ==> b : r``A"
       
   164 apply (unfold image_def)
       
   165 apply blast
       
   166 done
       
   167 
       
   168 lemma imageE [elim!]: 
       
   169     "[| b: r``A;  !!x.[| <x,b>: r;  x:A |] ==> P |] ==> P"
       
   170 apply (unfold image_def)
       
   171 apply blast
       
   172 done
       
   173 
       
   174 lemma image_subset: "r <= A*B ==> r``C <= B"
       
   175 apply blast
       
   176 done
       
   177 
       
   178 
       
   179 (*** Inverse image of a set under a function/relation ***)
       
   180 
       
   181 lemma vimage_iff: 
       
   182     "a : r-``B <-> (EX y:B. <a,y>:r)"
       
   183 apply (unfold vimage_def image_def converse_def)
       
   184 apply blast
       
   185 done
       
   186 
       
   187 lemma vimage_singleton_iff: "a : r-``{b} <-> <a,b>:r"
       
   188 apply (rule vimage_iff [THEN iff_trans])
       
   189 apply blast
       
   190 done
       
   191 
       
   192 lemma vimageI [intro]: "[| <a,b>: r;  b:B |] ==> a : r-``B"
       
   193 apply (unfold vimage_def)
       
   194 apply blast
       
   195 done
       
   196 
       
   197 lemma vimageE [elim!]: 
       
   198     "[| a: r-``B;  !!x.[| <a,x>: r;  x:B |] ==> P |] ==> P"
       
   199 apply (unfold vimage_def)
       
   200 apply blast
       
   201 done
       
   202 
       
   203 lemma vimage_subset: "r <= A*B ==> r-``C <= A"
       
   204 apply (unfold vimage_def)
       
   205 apply (erule converse_type [THEN image_subset])
       
   206 done
       
   207 
       
   208 
       
   209 (** The Union of a set of relations is a relation -- Lemma for fun_Union **)
       
   210 lemma rel_Union: "(ALL x:S. EX A B. x <= A*B) ==>   
       
   211                   Union(S) <= domain(Union(S)) * range(Union(S))"
       
   212 by blast
       
   213 
       
   214 (** The Union of 2 relations is a relation (Lemma for fun_Un)  **)
       
   215 lemma rel_Un: "[| r <= A*B;  s <= C*D |] ==> (r Un s) <= (A Un C) * (B Un D)"
       
   216 apply blast
       
   217 done
       
   218 
       
   219 lemma domain_Diff_eq: "[| <a,c> : r; c~=b |] ==> domain(r-{<a,b>}) = domain(r)"
       
   220 apply blast
       
   221 done
       
   222 
       
   223 lemma range_Diff_eq: "[| <c,b> : r; c~=a |] ==> range(r-{<a,b>}) = range(r)"
       
   224 apply blast
       
   225 done
       
   226 
       
   227 
    11 
   228 
    12 (** Finite Sets **)
   229 (** Finite Sets **)
    13 
   230 
    14 (* cons_def refers to Upair; reversing the equality LOOPS in rewriting!*)
   231 (* cons_def refers to Upair; reversing the equality LOOPS in rewriting!*)
    15 lemma cons_eq: "{a} Un B = cons(a,B)"
   232 lemma cons_eq: "{a} Un B = cons(a,B)"
   591      "Collect(A,P) Int Collect(A,Q) = Collect(A, %x. P(x) & Q(x))"
   808      "Collect(A,P) Int Collect(A,Q) = Collect(A, %x. P(x) & Q(x))"
   592 by blast
   809 by blast
   593 
   810 
   594 ML
   811 ML
   595 {*
   812 {*
       
   813 val ZF_cs = claset() delrules [equalityI];
       
   814 
       
   815 val converse_iff = thm "converse_iff";
       
   816 val converseI = thm "converseI";
       
   817 val converseD = thm "converseD";
       
   818 val converseE = thm "converseE";
       
   819 val converse_converse = thm "converse_converse";
       
   820 val converse_type = thm "converse_type";
       
   821 val converse_prod = thm "converse_prod";
       
   822 val converse_empty = thm "converse_empty";
       
   823 val converse_subset_iff = thm "converse_subset_iff";
       
   824 val domain_iff = thm "domain_iff";
       
   825 val domainI = thm "domainI";
       
   826 val domainE = thm "domainE";
       
   827 val domain_subset = thm "domain_subset";
       
   828 val rangeI = thm "rangeI";
       
   829 val rangeE = thm "rangeE";
       
   830 val range_subset = thm "range_subset";
       
   831 val fieldI1 = thm "fieldI1";
       
   832 val fieldI2 = thm "fieldI2";
       
   833 val fieldCI = thm "fieldCI";
       
   834 val fieldE = thm "fieldE";
       
   835 val field_subset = thm "field_subset";
       
   836 val domain_subset_field = thm "domain_subset_field";
       
   837 val range_subset_field = thm "range_subset_field";
       
   838 val domain_times_range = thm "domain_times_range";
       
   839 val field_times_field = thm "field_times_field";
       
   840 val image_iff = thm "image_iff";
       
   841 val image_singleton_iff = thm "image_singleton_iff";
       
   842 val imageI = thm "imageI";
       
   843 val imageE = thm "imageE";
       
   844 val image_subset = thm "image_subset";
       
   845 val vimage_iff = thm "vimage_iff";
       
   846 val vimage_singleton_iff = thm "vimage_singleton_iff";
       
   847 val vimageI = thm "vimageI";
       
   848 val vimageE = thm "vimageE";
       
   849 val vimage_subset = thm "vimage_subset";
       
   850 val rel_Union = thm "rel_Union";
       
   851 val rel_Un = thm "rel_Un";
       
   852 val domain_Diff_eq = thm "domain_Diff_eq";
       
   853 val range_Diff_eq = thm "range_Diff_eq";
   596 val cons_eq = thm "cons_eq";
   854 val cons_eq = thm "cons_eq";
   597 val cons_commute = thm "cons_commute";
   855 val cons_commute = thm "cons_commute";
   598 val cons_absorb = thm "cons_absorb";
   856 val cons_absorb = thm "cons_absorb";
   599 val cons_Diff = thm "cons_Diff";
   857 val cons_Diff = thm "cons_Diff";
   600 val equal_singleton = thm "equal_singleton";
   858 val equal_singleton = thm "equal_singleton";