src/ZF/Perm.thy
changeset 13356 c9cfe1638bf2
parent 13269 3ba9be497c33
child 13357 6f54e992777e
equal deleted inserted replaced
13355:d19cdbd8b559 13356:c9cfe1638bf2
     7   -- Composition of relations, the identity relation
     7   -- Composition of relations, the identity relation
     8   -- Injections, surjections, bijections
     8   -- Injections, surjections, bijections
     9   -- Lemmas for the Schroeder-Bernstein Theorem
     9   -- Lemmas for the Schroeder-Bernstein Theorem
    10 *)
    10 *)
    11 
    11 
       
    12 header{*Injections, Surjections, Bijections, Composition*}
       
    13 
    12 theory Perm = mono + func:
    14 theory Perm = mono + func:
    13 
    15 
    14 constdefs
    16 constdefs
    15 
    17 
    16   (*composition of relations and functions; NOT Suppes's relative product*)
    18   (*composition of relations and functions; NOT Suppes's relative product*)
    32 
    34 
    33   (*one-to-one and onto functions*)
    35   (*one-to-one and onto functions*)
    34   bij   :: "[i,i]=>i"
    36   bij   :: "[i,i]=>i"
    35     "bij(A,B) == inj(A,B) Int surj(A,B)"
    37     "bij(A,B) == inj(A,B) Int surj(A,B)"
    36 
    38 
       
    39 
       
    40 subsection{*Surjections*}
    37 
    41 
    38 (** Surjective function space **)
    42 (** Surjective function space **)
    39 
    43 
    40 lemma surj_is_fun: "f: surj(A,B) ==> f: A->B"
    44 lemma surj_is_fun: "f: surj(A,B) ==> f: A->B"
    41 apply (unfold surj_def)
    45 apply (unfold surj_def)
    75 apply (cut_tac cantor)
    79 apply (cut_tac cantor)
    76 apply (best del: subsetI) 
    80 apply (best del: subsetI) 
    77 done
    81 done
    78 
    82 
    79 
    83 
       
    84 subsection{*Injections*}
       
    85 
    80 (** Injective function space **)
    86 (** Injective function space **)
    81 
    87 
    82 lemma inj_is_fun: "f: inj(A,B) ==> f: A->B"
    88 lemma inj_is_fun: "f: inj(A,B) ==> f: A->B"
    83 apply (unfold inj_def)
    89 apply (unfold inj_def)
    84 apply (erule CollectD1)
    90 apply (erule CollectD1)
   107      ==> (lam x:A. c(x)) : inj(A,B)"
   113      ==> (lam x:A. c(x)) : inj(A,B)"
   108 apply (rule_tac d = "d" in f_imp_injective)
   114 apply (rule_tac d = "d" in f_imp_injective)
   109 apply (simp_all add: lam_type)
   115 apply (simp_all add: lam_type)
   110 done
   116 done
   111 
   117 
   112 (** Bijections **)
   118 subsection{*Bijections*}
   113 
   119 
   114 lemma bij_is_inj: "f: bij(A,B) ==> f: inj(A,B)"
   120 lemma bij_is_inj: "f: bij(A,B) ==> f: inj(A,B)"
   115 apply (unfold bij_def)
   121 apply (unfold bij_def)
   116 apply (erule IntD1)
   122 apply (erule IntD1)
   117 done
   123 done
   139 apply (rule_tac d = "f" in lam_bijective)
   145 apply (rule_tac d = "f" in lam_bijective)
   140 apply (auto simp add: the_equality2)
   146 apply (auto simp add: the_equality2)
   141 done
   147 done
   142 
   148 
   143 
   149 
   144 (** Identity function **)
   150 subsection{*Identity Function*}
   145 
   151 
   146 lemma idI [intro!]: "a:A ==> <a,a> : id(A)"
   152 lemma idI [intro!]: "a:A ==> <a,a> : id(A)"
   147 apply (unfold id_def)
   153 apply (unfold id_def)
   148 apply (erule lamI)
   154 apply (erule lamI)
   149 done
   155 done
   223 by (blast intro: right_inverse_lemma inj_converse_fun inj_is_fun)
   229 by (blast intro: right_inverse_lemma inj_converse_fun inj_is_fun)
   224 
   230 
   225 lemma right_inverse_bij: "[| f: bij(A,B);  b: B |] ==> f`(converse(f)`b) = b"
   231 lemma right_inverse_bij: "[| f: bij(A,B);  b: B |] ==> f`(converse(f)`b) = b"
   226 by (force simp add: bij_def surj_range)
   232 by (force simp add: bij_def surj_range)
   227 
   233 
   228 (** Converses of injections, surjections, bijections **)
   234 subsection{*Converses of Injections, Surjections, Bijections*}
   229 
   235 
   230 lemma inj_converse_inj: "f: inj(A,B) ==> converse(f): inj(range(f), A)"
   236 lemma inj_converse_inj: "f: inj(A,B) ==> converse(f): inj(range(f), A)"
   231 apply (rule f_imp_injective)
   237 apply (rule f_imp_injective)
   232 apply (erule inj_converse_fun, clarify) 
   238 apply (erule inj_converse_fun, clarify) 
   233 apply (rule right_inverse)
   239 apply (rule right_inverse)
   245 apply (fast elim: surj_range [THEN subst] inj_converse_inj inj_converse_surj)
   251 apply (fast elim: surj_range [THEN subst] inj_converse_inj inj_converse_surj)
   246 done
   252 done
   247 
   253 
   248 
   254 
   249 
   255 
   250 (** Composition of two relations **)
   256 subsection{*Composition of Two Relations*}
   251 
   257 
   252 (*The inductive definition package could derive these theorems for (r O s)*)
   258 (*The inductive definition package could derive these theorems for (r O s)*)
   253 
   259 
   254 lemma compI [intro]: "[| <a,b>:s; <b,c>:r |] ==> <a,c> : r O s"
   260 lemma compI [intro]: "[| <a,b>:s; <b,c>:r |] ==> <a,c> : r O s"
   255 by (unfold comp_def, blast)
   261 by (unfold comp_def, blast)
   268 
   274 
   269 lemma converse_comp: "converse(R O S) = converse(S) O converse(R)"
   275 lemma converse_comp: "converse(R O S) = converse(S) O converse(R)"
   270 by blast
   276 by blast
   271 
   277 
   272 
   278 
   273 (** Domain and Range -- see Suppes, section 3.1 **)
   279 subsection{*Domain and Range -- see Suppes, Section 3.1*}
   274 
   280 
   275 (*Boyer et al., Set Theory in First-Order Logic, JAR 2 (1986), 287-327*)
   281 (*Boyer et al., Set Theory in First-Order Logic, JAR 2 (1986), 287-327*)
   276 lemma range_comp: "range(r O s) <= range(r)"
   282 lemma range_comp: "range(r O s) <= range(r)"
   277 by blast
   283 by blast
   278 
   284 
   287 
   293 
   288 lemma image_comp: "(r O s)``A = r``(s``A)"
   294 lemma image_comp: "(r O s)``A = r``(s``A)"
   289 by blast
   295 by blast
   290 
   296 
   291 
   297 
   292 (** Other results **)
   298 subsection{*Other Results*}
   293 
   299 
   294 lemma comp_mono: "[| r'<=r; s'<=s |] ==> (r' O s') <= (r O s)"
   300 lemma comp_mono: "[| r'<=r; s'<=s |] ==> (r' O s') <= (r O s)"
   295 by blast
   301 by blast
   296 
   302 
   297 (*composition preserves relations*)
   303 (*composition preserves relations*)
   313   and   [| r<=A*B; A<=C |] ==> r <= r O id(C) *)
   319   and   [| r<=A*B; A<=C |] ==> r <= r O id(C) *)
   314 lemma right_comp_id: "r<=A*B ==> r O id(A) = r"
   320 lemma right_comp_id: "r<=A*B ==> r O id(A) = r"
   315 by blast
   321 by blast
   316 
   322 
   317 
   323 
   318 (** Composition preserves functions, injections, and surjections **)
   324 subsection{*Composition Preserves Functions, Injections, and Surjections*}
   319 
   325 
   320 lemma comp_function: "[| function(g);  function(f) |] ==> function(f O g)"
   326 lemma comp_function: "[| function(g);  function(f) |] ==> function(f O g)"
   321 by (unfold function_def, blast)
   327 by (unfold function_def, blast)
   322 
   328 
   323 (*Don't think the premises can be weakened much*)
   329 (*Don't think the premises can be weakened much*)
   365 apply (unfold bij_def)
   371 apply (unfold bij_def)
   366 apply (blast intro: comp_inj comp_surj)
   372 apply (blast intro: comp_inj comp_surj)
   367 done
   373 done
   368 
   374 
   369 
   375 
   370 (** Dual properties of inj and surj -- useful for proofs from
   376 subsection{*Dual Properties of @{term inj} and @{term surj}*}
       
   377 
       
   378 text{*Useful for proofs from
   371     D Pastre.  Automatic theorem proving in set theory. 
   379     D Pastre.  Automatic theorem proving in set theory. 
   372     Artificial Intelligence, 10:1--27, 1978. **)
   380     Artificial Intelligence, 10:1--27, 1978.*}
   373 
   381 
   374 lemma comp_mem_injD1: 
   382 lemma comp_mem_injD1: 
   375     "[| (f O g): inj(A,C);  g: A->B;  f: B->C |] ==> g: inj(A,B)"
   383     "[| (f O g): inj(A,C);  g: A->B;  f: B->C |] ==> g: inj(A,B)"
   376 apply (unfold inj_def, force) 
   384 by (unfold inj_def, force) 
   377 done
       
   378 
   385 
   379 lemma comp_mem_injD2: 
   386 lemma comp_mem_injD2: 
   380     "[| (f O g): inj(A,C);  g: surj(A,B);  f: B->C |] ==> f: inj(B,C)"
   387     "[| (f O g): inj(A,C);  g: surj(A,B);  f: B->C |] ==> f: inj(B,C)"
   381 apply (unfold inj_def surj_def, safe)
   388 apply (unfold inj_def surj_def, safe)
   382 apply (rule_tac x1 = "x" in bspec [THEN bexE])
   389 apply (rule_tac x1 = "x" in bspec [THEN bexE])
   398 apply (unfold inj_def surj_def, safe)
   405 apply (unfold inj_def surj_def, safe)
   399 apply (drule_tac x = "f`y" in bspec, auto)  
   406 apply (drule_tac x = "f`y" in bspec, auto)  
   400 apply (blast intro: apply_funtype)
   407 apply (blast intro: apply_funtype)
   401 done
   408 done
   402 
   409 
   403 (** inverses of composition **)
   410 subsubsection{*Inverses of Composition*}
   404 
   411 
   405 (*left inverse of composition; one inclusion is
   412 (*left inverse of composition; one inclusion is
   406         f: A->B ==> id(A) <= converse(f) O f *)
   413         f: A->B ==> id(A) <= converse(f) O f *)
   407 lemma left_comp_inverse: "f: inj(A,B) ==> converse(f) O f = id(A)"
   414 lemma left_comp_inverse: "f: inj(A,B) ==> converse(f) O f = id(A)"
   408 apply (unfold inj_def, clarify) 
   415 apply (unfold inj_def, clarify) 
   419 apply (best elim: domain_type range_type dest: apply_equality2)
   426 apply (best elim: domain_type range_type dest: apply_equality2)
   420 apply (blast intro: apply_Pair)
   427 apply (blast intro: apply_Pair)
   421 done
   428 done
   422 
   429 
   423 
   430 
   424 (** Proving that a function is a bijection **)
   431 subsubsection{*Proving that a Function is a Bijection*}
   425 
   432 
   426 lemma comp_eq_id_iff: 
   433 lemma comp_eq_id_iff: 
   427     "[| f: A->B;  g: B->A |] ==> f O g = id(B) <-> (ALL y:B. f`(g`y)=y)"
   434     "[| f: A->B;  g: B->A |] ==> f O g = id(B) <-> (ALL y:B. f`(g`y)=y)"
   428 apply (unfold id_def, safe)
   435 apply (unfold id_def, safe)
   429  apply (drule_tac t = "%h. h`y " in subst_context)
   436  apply (drule_tac t = "%h. h`y " in subst_context)
   446 lemma invertible_imp_bijective:
   453 lemma invertible_imp_bijective:
   447      "[| converse(f): B->A;  f: A->B |] ==> f : bij(A,B)"
   454      "[| converse(f): B->A;  f: A->B |] ==> f : bij(A,B)"
   448 by (simp add: fg_imp_bijective comp_eq_id_iff 
   455 by (simp add: fg_imp_bijective comp_eq_id_iff 
   449               left_inverse_lemma right_inverse_lemma)
   456               left_inverse_lemma right_inverse_lemma)
   450 
   457 
   451 (** Unions of functions -- cf similar theorems on func.ML **)
   458 subsubsection{*Unions of Functions*}
       
   459 
       
   460 text{*See similar theorems in func.thy*}
   452 
   461 
   453 (*Theorem by KG, proof by LCP*)
   462 (*Theorem by KG, proof by LCP*)
   454 lemma inj_disjoint_Un:
   463 lemma inj_disjoint_Un:
   455      "[| f: inj(A,B);  g: inj(C,D);  B Int D = 0 |]  
   464      "[| f: inj(A,B);  g: inj(C,D);  B Int D = 0 |]  
   456       ==> (lam a: A Un C. if a:A then f`a else g`a) : inj(A Un C, B Un D)"
   465       ==> (lam a: A Un C. if a:A then f`a else g`a) : inj(A Un C, B Un D)"
   477 apply (subst converse_Un)
   486 apply (subst converse_Un)
   478 apply (auto intro: fun_disjoint_Un bij_is_fun bij_converse_bij)
   487 apply (auto intro: fun_disjoint_Un bij_is_fun bij_converse_bij)
   479 done
   488 done
   480 
   489 
   481 
   490 
   482 (** Restrictions as surjections and bijections *)
   491 subsubsection{*Restrictions as Surjections and Bijections*}
   483 
   492 
   484 lemma surj_image:
   493 lemma surj_image:
   485     "f: Pi(A,B) ==> f: surj(A, f``A)"
   494     "f: Pi(A,B) ==> f: surj(A, f``A)"
   486 apply (simp add: surj_def) 
   495 apply (simp add: surj_def) 
   487 apply (blast intro: apply_equality apply_Pair Pi_type) 
   496 apply (blast intro: apply_equality apply_Pair Pi_type) 
   506 apply (simp add: inj_def bij_def)
   515 apply (simp add: inj_def bij_def)
   507 apply (blast intro: restrict_surj surj_is_fun)
   516 apply (blast intro: restrict_surj surj_is_fun)
   508 done
   517 done
   509 
   518 
   510 
   519 
   511 (*** Lemmas for Ramsey's Theorem ***)
   520 subsubsection{*Lemmas for Ramsey's Theorem*}
   512 
   521 
   513 lemma inj_weaken_type: "[| f: inj(A,B);  B<=D |] ==> f: inj(A,D)"
   522 lemma inj_weaken_type: "[| f: inj(A,B);  B<=D |] ==> f: inj(A,D)"
   514 apply (unfold inj_def)
   523 apply (unfold inj_def)
   515 apply (blast intro: fun_weaken_type)
   524 apply (blast intro: fun_weaken_type)
   516 done
   525 done