src/ZF/func.thy
changeset 60770 240563fbf41d
parent 58871 c399ae4b836f
child 63901 4ce989e962e0
equal deleted inserted replaced
60769:cf7f3465eaf1 60770:240563fbf41d
     1 (*  Title:      ZF/func.thy
     1 (*  Title:      ZF/func.thy
     2     Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
     2     Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
     3     Copyright   1991  University of Cambridge
     3     Copyright   1991  University of Cambridge
     4 *)
     4 *)
     5 
     5 
     6 section{*Functions, Function Spaces, Lambda-Abstraction*}
     6 section\<open>Functions, Function Spaces, Lambda-Abstraction\<close>
     7 
     7 
     8 theory func imports equalities Sum begin
     8 theory func imports equalities Sum begin
     9 
     9 
    10 subsection{*The Pi Operator: Dependent Function Space*}
    10 subsection\<open>The Pi Operator: Dependent Function Space\<close>
    11 
    11 
    12 lemma subset_Sigma_imp_relation: "r \<subseteq> Sigma(A,B) ==> relation(r)"
    12 lemma subset_Sigma_imp_relation: "r \<subseteq> Sigma(A,B) ==> relation(r)"
    13 by (simp add: relation_def, blast)
    13 by (simp add: relation_def, blast)
    14 
    14 
    15 lemma relation_converse_converse [simp]:
    15 lemma relation_converse_converse [simp]:
    53 
    53 
    54 (*Weakening one function type to another; see also Pi_type*)
    54 (*Weakening one function type to another; see also Pi_type*)
    55 lemma fun_weaken_type: "[| f \<in> A->B;  B<=D |] ==> f \<in> A->D"
    55 lemma fun_weaken_type: "[| f \<in> A->B;  B<=D |] ==> f \<in> A->D"
    56 by (unfold Pi_def, best)
    56 by (unfold Pi_def, best)
    57 
    57 
    58 subsection{*Function Application*}
    58 subsection\<open>Function Application\<close>
    59 
    59 
    60 lemma apply_equality2: "[| <a,b>: f;  <a,c>: f;  f \<in> Pi(A,B) |] ==> b=c"
    60 lemma apply_equality2: "[| <a,b>: f;  <a,c>: f;  f \<in> Pi(A,B) |] ==> b=c"
    61 by (unfold Pi_def function_def, blast)
    61 by (unfold Pi_def function_def, blast)
    62 
    62 
    63 lemma function_apply_equality: "[| <a,b>: f;  function(f) |] ==> f`a = b"
    63 lemma function_apply_equality: "[| <a,b>: f;  function(f) |] ==> f`a = b"
   127 by (blast dest: fun_is_rel)
   127 by (blast dest: fun_is_rel)
   128 
   128 
   129 lemma Pair_mem_PiD: "[| <a,b>: f;  f \<in> Pi(A,B) |] ==> a \<in> A & b \<in> B(a) & f`a = b"
   129 lemma Pair_mem_PiD: "[| <a,b>: f;  f \<in> Pi(A,B) |] ==> a \<in> A & b \<in> B(a) & f`a = b"
   130 by (blast intro: domain_type range_type apply_equality)
   130 by (blast intro: domain_type range_type apply_equality)
   131 
   131 
   132 subsection{*Lambda Abstraction*}
   132 subsection\<open>Lambda Abstraction\<close>
   133 
   133 
   134 lemma lamI: "a \<in> A ==> <a,b(a)> \<in> (\<lambda>x\<in>A. b(x))"
   134 lemma lamI: "a \<in> A ==> <a,b(a)> \<in> (\<lambda>x\<in>A. b(x))"
   135 apply (unfold lam_def)
   135 apply (unfold lam_def)
   136 apply (erule RepFunI)
   136 apply (erule RepFunI)
   137 done
   137 done
   200 apply auto
   200 apply auto
   201 apply (fast intro!: equals0I intro: lam_type)
   201 apply (fast intro!: equals0I intro: lam_type)
   202 done
   202 done
   203 
   203 
   204 
   204 
   205 subsection{*Extensionality*}
   205 subsection\<open>Extensionality\<close>
   206 
   206 
   207 (*Semi-extensionality!*)
   207 (*Semi-extensionality!*)
   208 
   208 
   209 lemma fun_subset:
   209 lemma fun_subset:
   210     "[| f \<in> Pi(A,B);  g \<in> Pi(C,D);  A<=C;
   210     "[| f \<in> Pi(A,B);  g \<in> Pi(C,D);  A<=C;
   240 apply (rule_tac [2] eta [symmetric])
   240 apply (rule_tac [2] eta [symmetric])
   241 apply (blast intro: major apply_type)+
   241 apply (blast intro: major apply_type)+
   242 done
   242 done
   243 
   243 
   244 
   244 
   245 subsection{*Images of Functions*}
   245 subsection\<open>Images of Functions\<close>
   246 
   246 
   247 lemma image_lam: "C \<subseteq> A ==> (\<lambda>x\<in>A. b(x)) `` C = {b(x). x \<in> C}"
   247 lemma image_lam: "C \<subseteq> A ==> (\<lambda>x\<in>A. b(x)) `` C = {b(x). x \<in> C}"
   248 by (unfold lam_def, blast)
   248 by (unfold lam_def, blast)
   249 
   249 
   250 lemma Repfun_function_if:
   250 lemma Repfun_function_if:
   276 lemma Pi_image_cons:
   276 lemma Pi_image_cons:
   277      "[| f \<in> Pi(A,B);  x \<in> A |] ==> f `` cons(x,y) = cons(f`x, f``y)"
   277      "[| f \<in> Pi(A,B);  x \<in> A |] ==> f `` cons(x,y) = cons(f`x, f``y)"
   278 by (blast dest: apply_equality apply_Pair)
   278 by (blast dest: apply_equality apply_Pair)
   279 
   279 
   280 
   280 
   281 subsection{*Properties of @{term "restrict(f,A)"}*}
   281 subsection\<open>Properties of @{term "restrict(f,A)"}\<close>
   282 
   282 
   283 lemma restrict_subset: "restrict(f,A) \<subseteq> f"
   283 lemma restrict_subset: "restrict(f,A) \<subseteq> f"
   284 by (unfold restrict_def, blast)
   284 by (unfold restrict_def, blast)
   285 
   285 
   286 lemma function_restrictI:
   286 lemma function_restrictI:
   336  prefer 2 apply (blast intro: apply_Pair restrict_subset [THEN subsetD])
   336  prefer 2 apply (blast intro: apply_Pair restrict_subset [THEN subsetD])
   337 apply (auto dest!: Pi_memberD simp add: restrict_def lam_def)
   337 apply (auto dest!: Pi_memberD simp add: restrict_def lam_def)
   338 done
   338 done
   339 
   339 
   340 
   340 
   341 subsection{*Unions of Functions*}
   341 subsection\<open>Unions of Functions\<close>
   342 
   342 
   343 (** The Union of a set of COMPATIBLE functions is a function **)
   343 (** The Union of a set of COMPATIBLE functions is a function **)
   344 
   344 
   345 lemma function_Union:
   345 lemma function_Union:
   346     "[| \<forall>x\<in>S. function(x);
   346     "[| \<forall>x\<in>S. function(x);
   379 by (simp add: apply_def, blast)
   379 by (simp add: apply_def, blast)
   380 
   380 
   381 lemma fun_disjoint_apply2: "c \<notin> domain(f) ==> (f \<union> g)`c = g`c"
   381 lemma fun_disjoint_apply2: "c \<notin> domain(f) ==> (f \<union> g)`c = g`c"
   382 by (simp add: apply_def, blast)
   382 by (simp add: apply_def, blast)
   383 
   383 
   384 subsection{*Domain and Range of a Function or Relation*}
   384 subsection\<open>Domain and Range of a Function or Relation\<close>
   385 
   385 
   386 lemma domain_of_fun: "f \<in> Pi(A,B) ==> domain(f)=A"
   386 lemma domain_of_fun: "f \<in> Pi(A,B) ==> domain(f)=A"
   387 by (unfold Pi_def, blast)
   387 by (unfold Pi_def, blast)
   388 
   388 
   389 lemma apply_rangeI: "[| f \<in> Pi(A,B);  a \<in> A |] ==> f`a \<in> range(f)"
   389 lemma apply_rangeI: "[| f \<in> Pi(A,B);  a \<in> A |] ==> f`a \<in> range(f)"
   390 by (erule apply_Pair [THEN rangeI], assumption)
   390 by (erule apply_Pair [THEN rangeI], assumption)
   391 
   391 
   392 lemma range_of_fun: "f \<in> Pi(A,B) ==> f \<in> A->range(f)"
   392 lemma range_of_fun: "f \<in> Pi(A,B) ==> f \<in> A->range(f)"
   393 by (blast intro: Pi_type apply_rangeI)
   393 by (blast intro: Pi_type apply_rangeI)
   394 
   394 
   395 subsection{*Extensions of Functions*}
   395 subsection\<open>Extensions of Functions\<close>
   396 
   396 
   397 lemma fun_extend:
   397 lemma fun_extend:
   398      "[| f \<in> A->B;  c\<notin>A |] ==> cons(<c,b>,f) \<in> cons(c,A) -> cons(b,B)"
   398      "[| f \<in> A->B;  c\<notin>A |] ==> cons(<c,b>,f) \<in> cons(c,A) -> cons(b,B)"
   399 apply (frule singleton_fun [THEN fun_disjoint_Un], blast)
   399 apply (frule singleton_fun [THEN fun_disjoint_Un], blast)
   400 apply (simp add: cons_eq)
   400 apply (simp add: cons_eq)
   437 
   437 
   438 lemma succ_fun_eq: "succ(n) -> B = (\<Union>f \<in> n->B. \<Union>b\<in>B. {cons(<n,b>, f)})"
   438 lemma succ_fun_eq: "succ(n) -> B = (\<Union>f \<in> n->B. \<Union>b\<in>B. {cons(<n,b>, f)})"
   439 by (simp add: succ_def mem_not_refl cons_fun_eq)
   439 by (simp add: succ_def mem_not_refl cons_fun_eq)
   440 
   440 
   441 
   441 
   442 subsection{*Function Updates*}
   442 subsection\<open>Function Updates\<close>
   443 
   443 
   444 definition
   444 definition
   445   update  :: "[i,i,i] => i"  where
   445   update  :: "[i,i,i] => i"  where
   446    "update(f,a,b) == \<lambda>x\<in>cons(a, domain(f)). if(x=a, b, f`x)"
   446    "update(f,a,b) == \<lambda>x\<in>cons(a, domain(f)). if(x=a, b, f`x)"
   447 
   447 
   485 apply (unfold update_def)
   485 apply (unfold update_def)
   486 apply (simp add: domain_of_fun cons_absorb apply_funtype lam_type)
   486 apply (simp add: domain_of_fun cons_absorb apply_funtype lam_type)
   487 done
   487 done
   488 
   488 
   489 
   489 
   490 subsection{*Monotonicity Theorems*}
   490 subsection\<open>Monotonicity Theorems\<close>
   491 
   491 
   492 subsubsection{*Replacement in its Various Forms*}
   492 subsubsection\<open>Replacement in its Various Forms\<close>
   493 
   493 
   494 (*Not easy to express monotonicity in P, since any "bigger" predicate
   494 (*Not easy to express monotonicity in P, since any "bigger" predicate
   495   would have to be single-valued*)
   495   would have to be single-valued*)
   496 lemma Replace_mono: "A<=B ==> Replace(A,P) \<subseteq> Replace(B,P)"
   496 lemma Replace_mono: "A<=B ==> Replace(A,P) \<subseteq> Replace(B,P)"
   497 by (blast elim!: ReplaceE)
   497 by (blast elim!: ReplaceE)
   523 by blast
   523 by blast
   524 
   524 
   525 lemma Diff_mono: "[| A<=C;  D<=B |] ==> A-B \<subseteq> C-D"
   525 lemma Diff_mono: "[| A<=C;  D<=B |] ==> A-B \<subseteq> C-D"
   526 by blast
   526 by blast
   527 
   527 
   528 subsubsection{*Standard Products, Sums and Function Spaces *}
   528 subsubsection\<open>Standard Products, Sums and Function Spaces\<close>
   529 
   529 
   530 lemma Sigma_mono [rule_format]:
   530 lemma Sigma_mono [rule_format]:
   531      "[| A<=C;  !!x. x \<in> A \<longrightarrow> B(x) \<subseteq> D(x) |] ==> Sigma(A,B) \<subseteq> Sigma(C,D)"
   531      "[| A<=C;  !!x. x \<in> A \<longrightarrow> B(x) \<subseteq> D(x) |] ==> Sigma(A,B) \<subseteq> Sigma(C,D)"
   532 by blast
   532 by blast
   533 
   533 
   541 lemma lam_mono: "A<=B ==> Lambda(A,c) \<subseteq> Lambda(B,c)"
   541 lemma lam_mono: "A<=B ==> Lambda(A,c) \<subseteq> Lambda(B,c)"
   542 apply (unfold lam_def)
   542 apply (unfold lam_def)
   543 apply (erule RepFun_mono)
   543 apply (erule RepFun_mono)
   544 done
   544 done
   545 
   545 
   546 subsubsection{*Converse, Domain, Range, Field*}
   546 subsubsection\<open>Converse, Domain, Range, Field\<close>
   547 
   547 
   548 lemma converse_mono: "r<=s ==> converse(r) \<subseteq> converse(s)"
   548 lemma converse_mono: "r<=s ==> converse(r) \<subseteq> converse(s)"
   549 by blast
   549 by blast
   550 
   550 
   551 lemma domain_mono: "r<=s ==> domain(r)<=domain(s)"
   551 lemma domain_mono: "r<=s ==> domain(r)<=domain(s)"
   563 
   563 
   564 lemma field_rel_subset: "r \<subseteq> A*A ==> field(r) \<subseteq> A"
   564 lemma field_rel_subset: "r \<subseteq> A*A ==> field(r) \<subseteq> A"
   565 by (erule field_mono [THEN subset_trans], blast)
   565 by (erule field_mono [THEN subset_trans], blast)
   566 
   566 
   567 
   567 
   568 subsubsection{*Images*}
   568 subsubsection\<open>Images\<close>
   569 
   569 
   570 lemma image_pair_mono:
   570 lemma image_pair_mono:
   571     "[| !! x y. <x,y>:r ==> <x,y>:s;  A<=B |] ==> r``A \<subseteq> s``B"
   571     "[| !! x y. <x,y>:r ==> <x,y>:s;  A<=B |] ==> r``A \<subseteq> s``B"
   572 by blast
   572 by blast
   573 
   573