author | paulson |
Mon, 27 Apr 1998 13:47:46 +0200 | |
changeset 4829 | aa5ea943f8e3 |
parent 4512 | 572440df6aa7 |
child 5067 | 62b6288e6005 |
permissions | -rw-r--r-- |
1461 | 1 |
(* Title: ZF/func |
0 | 2 |
ID: $Id$ |
1461 | 3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
0 | 4 |
Copyright 1991 University of Cambridge |
5 |
||
6 |
Functions in Zermelo-Fraenkel Set Theory |
|
7 |
*) |
|
8 |
||
9 |
(*** The Pi operator -- dependent function space ***) |
|
10 |
||
2877 | 11 |
goalw ZF.thy [Pi_def] |
691
b9fc536792bb
ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents:
538
diff
changeset
|
12 |
"f: Pi(A,B) <-> function(f) & f<=Sigma(A,B) & A<=domain(f)"; |
2877 | 13 |
by (Blast_tac 1); |
760 | 14 |
qed "Pi_iff"; |
691
b9fc536792bb
ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents:
538
diff
changeset
|
15 |
|
b9fc536792bb
ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents:
538
diff
changeset
|
16 |
(*For upward compatibility with the former definition*) |
2877 | 17 |
goalw ZF.thy [Pi_def, function_def] |
691
b9fc536792bb
ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents:
538
diff
changeset
|
18 |
"f: Pi(A,B) <-> f<=Sigma(A,B) & (ALL x:A. EX! y. <x,y>: f)"; |
2877 | 19 |
by (Blast_tac 1); |
760 | 20 |
qed "Pi_iff_old"; |
691
b9fc536792bb
ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents:
538
diff
changeset
|
21 |
|
2877 | 22 |
goal ZF.thy "!!f. f: Pi(A,B) ==> function(f)"; |
691
b9fc536792bb
ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents:
538
diff
changeset
|
23 |
by (asm_full_simp_tac (FOL_ss addsimps [Pi_iff]) 1); |
760 | 24 |
qed "fun_is_function"; |
0 | 25 |
|
26 |
(**Two "destruct" rules for Pi **) |
|
27 |
||
2877 | 28 |
val [major] = goalw ZF.thy [Pi_def] "f: Pi(A,B) ==> f <= Sigma(A,B)"; |
691
b9fc536792bb
ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents:
538
diff
changeset
|
29 |
by (rtac (major RS CollectD1 RS PowD) 1); |
760 | 30 |
qed "fun_is_rel"; |
0 | 31 |
|
2877 | 32 |
goal ZF.thy "!!f. [| f: Pi(A,B); a:A |] ==> EX! y. <a,y>: f"; |
4091 | 33 |
by (blast_tac (claset() addSDs [Pi_iff_old RS iffD1]) 1); |
760 | 34 |
qed "fun_unique_Pair"; |
0 | 35 |
|
2877 | 36 |
val prems = goalw ZF.thy [Pi_def] |
0 | 37 |
"[| A=A'; !!x. x:A' ==> B(x)=B'(x) |] ==> Pi(A,B) = Pi(A',B')"; |
6
8ce8c4d13d4d
Installation of new simplifier for ZF. Deleted all congruence rules not
lcp
parents:
0
diff
changeset
|
38 |
by (simp_tac (FOL_ss addsimps prems addcongs [Sigma_cong]) 1); |
760 | 39 |
qed "Pi_cong"; |
0 | 40 |
|
2469 | 41 |
(*Sigma_cong, Pi_cong NOT given to Addcongs: they cause |
42 |
flex-flex pairs and the "Check your prover" error. Most |
|
43 |
Sigmas and Pis are abbreviated as * or -> *) |
|
44 |
||
485 | 45 |
(*Weakening one function type to another; see also Pi_type*) |
2877 | 46 |
goalw ZF.thy [Pi_def] "!!f. [| f: A->B; B<=D |] ==> f: A->D"; |
2469 | 47 |
by (Best_tac 1); |
760 | 48 |
qed "fun_weaken_type"; |
0 | 49 |
|
50 |
(*Empty function spaces*) |
|
2877 | 51 |
goalw ZF.thy [Pi_def, function_def] "Pi(0,A) = {0}"; |
52 |
by (Blast_tac 1); |
|
760 | 53 |
qed "Pi_empty1"; |
0 | 54 |
|
2877 | 55 |
goalw ZF.thy [Pi_def] "!!A a. a:A ==> A->0 = 0"; |
56 |
by (Blast_tac 1); |
|
760 | 57 |
qed "Pi_empty2"; |
0 | 58 |
|
519 | 59 |
(*The empty function*) |
2877 | 60 |
goalw ZF.thy [Pi_def, function_def] "0: Pi(0,B)"; |
61 |
by (Blast_tac 1); |
|
760 | 62 |
qed "empty_fun"; |
519 | 63 |
|
64 |
(*The singleton function*) |
|
2877 | 65 |
goalw ZF.thy [Pi_def, function_def] "{<a,b>} : {a} -> {b}"; |
66 |
by (Blast_tac 1); |
|
857 | 67 |
qed "singleton_fun"; |
519 | 68 |
|
2469 | 69 |
Addsimps [empty_fun, singleton_fun]; |
70 |
||
0 | 71 |
(*** Function Application ***) |
72 |
||
2877 | 73 |
goalw ZF.thy [Pi_def, function_def] |
691
b9fc536792bb
ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents:
538
diff
changeset
|
74 |
"!!a b f. [| <a,b>: f; <a,c>: f; f: Pi(A,B) |] ==> b=c"; |
2877 | 75 |
by (Blast_tac 1); |
760 | 76 |
qed "apply_equality2"; |
0 | 77 |
|
4829
aa5ea943f8e3
New proof of apply_equality and new thm Pi_image_cons
paulson
parents:
4512
diff
changeset
|
78 |
goalw ZF.thy [apply_def, function_def] |
aa5ea943f8e3
New proof of apply_equality and new thm Pi_image_cons
paulson
parents:
4512
diff
changeset
|
79 |
"!!a b f. [| <a,b>: f; function(f) |] ==> f`a = b"; |
aa5ea943f8e3
New proof of apply_equality and new thm Pi_image_cons
paulson
parents:
4512
diff
changeset
|
80 |
by (blast_tac (claset() addIs [the_equality]) 1); |
aa5ea943f8e3
New proof of apply_equality and new thm Pi_image_cons
paulson
parents:
4512
diff
changeset
|
81 |
qed "function_apply_equality"; |
aa5ea943f8e3
New proof of apply_equality and new thm Pi_image_cons
paulson
parents:
4512
diff
changeset
|
82 |
|
aa5ea943f8e3
New proof of apply_equality and new thm Pi_image_cons
paulson
parents:
4512
diff
changeset
|
83 |
goalw ZF.thy [Pi_def] "!!a b f. [| <a,b>: f; f: Pi(A,B) |] ==> f`a = b"; |
aa5ea943f8e3
New proof of apply_equality and new thm Pi_image_cons
paulson
parents:
4512
diff
changeset
|
84 |
by (blast_tac (claset() addIs [function_apply_equality]) 1); |
760 | 85 |
qed "apply_equality"; |
0 | 86 |
|
517 | 87 |
(*Applying a function outside its domain yields 0*) |
2877 | 88 |
goalw ZF.thy [apply_def] |
517 | 89 |
"!!a b f. [| a ~: domain(f); f: Pi(A,B) |] ==> f`a = 0"; |
90 |
by (rtac the_0 1); |
|
2877 | 91 |
by (Blast_tac 1); |
760 | 92 |
qed "apply_0"; |
517 | 93 |
|
2877 | 94 |
goal ZF.thy "!!f. [| f: Pi(A,B); c: f |] ==> EX x:A. c = <x,f`x>"; |
691
b9fc536792bb
ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents:
538
diff
changeset
|
95 |
by (forward_tac [fun_is_rel] 1); |
4091 | 96 |
by (blast_tac (claset() addDs [apply_equality]) 1); |
760 | 97 |
qed "Pi_memberD"; |
691
b9fc536792bb
ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents:
538
diff
changeset
|
98 |
|
2877 | 99 |
goal ZF.thy "!!f. [| f: Pi(A,B); a:A |] ==> <a,f`a>: f"; |
691
b9fc536792bb
ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents:
538
diff
changeset
|
100 |
by (rtac (fun_unique_Pair RS ex1E) 1); |
b9fc536792bb
ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents:
538
diff
changeset
|
101 |
by (resolve_tac [apply_equality RS ssubst] 3); |
b9fc536792bb
ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents:
538
diff
changeset
|
102 |
by (REPEAT (assume_tac 1)); |
760 | 103 |
qed "apply_Pair"; |
0 | 104 |
|
6
8ce8c4d13d4d
Installation of new simplifier for ZF. Deleted all congruence rules not
lcp
parents:
0
diff
changeset
|
105 |
(*Conclusion is flexible -- use res_inst_tac or else apply_funtype below!*) |
2877 | 106 |
goal ZF.thy "!!f. [| f: Pi(A,B); a:A |] ==> f`a : B(a)"; |
0 | 107 |
by (rtac (fun_is_rel RS subsetD RS SigmaE2) 1); |
691
b9fc536792bb
ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents:
538
diff
changeset
|
108 |
by (REPEAT (ares_tac [apply_Pair] 1)); |
760 | 109 |
qed "apply_type"; |
0 | 110 |
|
6
8ce8c4d13d4d
Installation of new simplifier for ZF. Deleted all congruence rules not
lcp
parents:
0
diff
changeset
|
111 |
(*This version is acceptable to the simplifier*) |
2877 | 112 |
goal ZF.thy "!!f. [| f: A->B; a:A |] ==> f`a : B"; |
6
8ce8c4d13d4d
Installation of new simplifier for ZF. Deleted all congruence rules not
lcp
parents:
0
diff
changeset
|
113 |
by (REPEAT (ares_tac [apply_type] 1)); |
760 | 114 |
qed "apply_funtype"; |
6
8ce8c4d13d4d
Installation of new simplifier for ZF. Deleted all congruence rules not
lcp
parents:
0
diff
changeset
|
115 |
|
2877 | 116 |
val [major] = goal ZF.thy |
0 | 117 |
"f: Pi(A,B) ==> <a,b>: f <-> a:A & f`a = b"; |
691
b9fc536792bb
ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents:
538
diff
changeset
|
118 |
by (cut_facts_tac [major RS fun_is_rel] 1); |
4091 | 119 |
by (blast_tac (claset() addSIs [major RS apply_Pair, |
2835 | 120 |
major RSN (2,apply_equality)]) 1); |
760 | 121 |
qed "apply_iff"; |
0 | 122 |
|
123 |
(*Refining one Pi type to another*) |
|
2877 | 124 |
val pi_prem::prems = goal ZF.thy |
0 | 125 |
"[| f: Pi(A,C); !!x. x:A ==> f`x : B(x) |] ==> f : Pi(A,B)"; |
691
b9fc536792bb
ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents:
538
diff
changeset
|
126 |
by (cut_facts_tac [pi_prem] 1); |
b9fc536792bb
ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents:
538
diff
changeset
|
127 |
by (asm_full_simp_tac (FOL_ss addsimps [Pi_iff]) 1); |
4091 | 128 |
by (blast_tac (claset() addIs prems addSDs [pi_prem RS Pi_memberD]) 1); |
760 | 129 |
qed "Pi_type"; |
0 | 130 |
|
131 |
||
132 |
(** Elimination of membership in a function **) |
|
133 |
||
2877 | 134 |
goal ZF.thy "!!a A. [| <a,b> : f; f: Pi(A,B) |] ==> a : A"; |
0 | 135 |
by (REPEAT (ares_tac [fun_is_rel RS subsetD RS SigmaD1] 1)); |
760 | 136 |
qed "domain_type"; |
0 | 137 |
|
2877 | 138 |
goal ZF.thy "!!b B a. [| <a,b> : f; f: Pi(A,B) |] ==> b : B(a)"; |
0 | 139 |
by (etac (fun_is_rel RS subsetD RS SigmaD2) 1); |
140 |
by (assume_tac 1); |
|
760 | 141 |
qed "range_type"; |
0 | 142 |
|
2877 | 143 |
val prems = goal ZF.thy |
0 | 144 |
"[| <a,b>: f; f: Pi(A,B); \ |
145 |
\ [| a:A; b:B(a); f`a = b |] ==> P \ |
|
146 |
\ |] ==> P"; |
|
147 |
by (cut_facts_tac prems 1); |
|
148 |
by (resolve_tac prems 1); |
|
149 |
by (REPEAT (eresolve_tac [asm_rl,domain_type,range_type,apply_equality] 1)); |
|
760 | 150 |
qed "Pair_mem_PiE"; |
0 | 151 |
|
152 |
(*** Lambda Abstraction ***) |
|
153 |
||
2877 | 154 |
goalw ZF.thy [lam_def] "!!A b. a:A ==> <a,b(a)> : (lam x:A. b(x))"; |
0 | 155 |
by (etac RepFunI 1); |
760 | 156 |
qed "lamI"; |
0 | 157 |
|
2877 | 158 |
val major::prems = goalw ZF.thy [lam_def] |
0 | 159 |
"[| p: (lam x:A. b(x)); !!x.[| x:A; p=<x,b(x)> |] ==> P \ |
160 |
\ |] ==> P"; |
|
161 |
by (rtac (major RS RepFunE) 1); |
|
162 |
by (REPEAT (ares_tac prems 1)); |
|
760 | 163 |
qed "lamE"; |
0 | 164 |
|
2877 | 165 |
goal ZF.thy "!!a b c. [| <a,c>: (lam x:A. b(x)) |] ==> c = b(a)"; |
0 | 166 |
by (REPEAT (eresolve_tac [asm_rl,lamE,Pair_inject,ssubst] 1)); |
760 | 167 |
qed "lamD"; |
0 | 168 |
|
2877 | 169 |
val prems = goalw ZF.thy [lam_def, Pi_def, function_def] |
3840 | 170 |
"[| !!x. x:A ==> b(x): B(x) |] ==> (lam x:A. b(x)) : Pi(A,B)"; |
4091 | 171 |
by (blast_tac (claset() addIs prems) 1); |
760 | 172 |
qed "lam_type"; |
0 | 173 |
|
3840 | 174 |
goal ZF.thy "(lam x:A. b(x)) : A -> {b(x). x:A}"; |
0 | 175 |
by (REPEAT (ares_tac [refl,lam_type,RepFunI] 1)); |
760 | 176 |
qed "lam_funtype"; |
0 | 177 |
|
3840 | 178 |
goal ZF.thy "!!a A. a : A ==> (lam x:A. b(x)) ` a = b(a)"; |
0 | 179 |
by (REPEAT (ares_tac [apply_equality,lam_funtype,lamI] 1)); |
760 | 180 |
qed "beta"; |
0 | 181 |
|
2877 | 182 |
goalw ZF.thy [lam_def] "(lam x:0. b(x)) = 0"; |
2469 | 183 |
by (Simp_tac 1); |
184 |
qed "lam_empty"; |
|
185 |
||
186 |
Addsimps [beta, lam_empty]; |
|
187 |
||
0 | 188 |
(*congruence rule for lambda abstraction*) |
2877 | 189 |
val prems = goalw ZF.thy [lam_def] |
6
8ce8c4d13d4d
Installation of new simplifier for ZF. Deleted all congruence rules not
lcp
parents:
0
diff
changeset
|
190 |
"[| A=A'; !!x. x:A' ==> b(x)=b'(x) |] ==> Lambda(A,b) = Lambda(A',b')"; |
8ce8c4d13d4d
Installation of new simplifier for ZF. Deleted all congruence rules not
lcp
parents:
0
diff
changeset
|
191 |
by (simp_tac (FOL_ss addsimps prems addcongs [RepFun_cong]) 1); |
760 | 192 |
qed "lam_cong"; |
0 | 193 |
|
2469 | 194 |
Addcongs [lam_cong]; |
195 |
||
2877 | 196 |
val [major] = goal ZF.thy |
0 | 197 |
"(!!x. x:A ==> EX! y. Q(x,y)) ==> EX f. ALL x:A. Q(x, f`x)"; |
198 |
by (res_inst_tac [("x", "lam x: A. THE y. Q(x,y)")] exI 1); |
|
199 |
by (rtac ballI 1); |
|
2033 | 200 |
by (stac beta 1); |
0 | 201 |
by (assume_tac 1); |
202 |
by (etac (major RS theI) 1); |
|
760 | 203 |
qed "lam_theI"; |
0 | 204 |
|
205 |
||
206 |
(** Extensionality **) |
|
207 |
||
208 |
(*Semi-extensionality!*) |
|
2877 | 209 |
val prems = goal ZF.thy |
0 | 210 |
"[| f : Pi(A,B); g: Pi(C,D); A<=C; \ |
211 |
\ !!x. x:A ==> f`x = g`x |] ==> f<=g"; |
|
212 |
by (rtac subsetI 1); |
|
691
b9fc536792bb
ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents:
538
diff
changeset
|
213 |
by (eresolve_tac (prems RL [Pi_memberD RS bexE]) 1); |
0 | 214 |
by (etac ssubst 1); |
215 |
by (resolve_tac (prems RL [ssubst]) 1); |
|
216 |
by (REPEAT (ares_tac (prems@[apply_Pair,subsetD]) 1)); |
|
760 | 217 |
qed "fun_subset"; |
0 | 218 |
|
2877 | 219 |
val prems = goal ZF.thy |
0 | 220 |
"[| f : Pi(A,B); g: Pi(A,D); \ |
221 |
\ !!x. x:A ==> f`x = g`x |] ==> f=g"; |
|
222 |
by (REPEAT (ares_tac (prems @ (prems RL [sym]) @ |
|
1461 | 223 |
[subset_refl,equalityI,fun_subset]) 1)); |
760 | 224 |
qed "fun_extension"; |
0 | 225 |
|
2877 | 226 |
goal ZF.thy "!!f A B. f : Pi(A,B) ==> (lam x:A. f`x) = f"; |
0 | 227 |
by (rtac fun_extension 1); |
228 |
by (REPEAT (ares_tac [lam_type,apply_type,beta] 1)); |
|
760 | 229 |
qed "eta"; |
0 | 230 |
|
2469 | 231 |
Addsimps [eta]; |
232 |
||
0 | 233 |
(*Every element of Pi(A,B) may be expressed as a lambda abstraction!*) |
2877 | 234 |
val prems = goal ZF.thy |
0 | 235 |
"[| f: Pi(A,B); \ |
3840 | 236 |
\ !!b. [| ALL x:A. b(x):B(x); f = (lam x:A. b(x)) |] ==> P \ |
0 | 237 |
\ |] ==> P"; |
238 |
by (resolve_tac prems 1); |
|
239 |
by (rtac (eta RS sym) 2); |
|
240 |
by (REPEAT (ares_tac (prems@[ballI,apply_type]) 1)); |
|
760 | 241 |
qed "Pi_lamE"; |
0 | 242 |
|
243 |
||
435 | 244 |
(** Images of functions **) |
245 |
||
3840 | 246 |
goalw ZF.thy [lam_def] "!!C A. C <= A ==> (lam x:A. b(x)) `` C = {b(x). x:C}"; |
2877 | 247 |
by (Blast_tac 1); |
760 | 248 |
qed "image_lam"; |
435 | 249 |
|
2877 | 250 |
goal ZF.thy "!!C A. [| f : Pi(A,B); C <= A |] ==> f``C = {f`x. x:C}"; |
437 | 251 |
by (etac (eta RS subst) 1); |
435 | 252 |
by (asm_full_simp_tac (FOL_ss addsimps [beta, image_lam, subset_iff] |
253 |
addcongs [RepFun_cong]) 1); |
|
760 | 254 |
qed "image_fun"; |
435 | 255 |
|
4829
aa5ea943f8e3
New proof of apply_equality and new thm Pi_image_cons
paulson
parents:
4512
diff
changeset
|
256 |
goal thy "!!f. [| f: Pi(A,B); x: A |] ==> f `` cons(x,y) = cons(f`x, f``y)"; |
aa5ea943f8e3
New proof of apply_equality and new thm Pi_image_cons
paulson
parents:
4512
diff
changeset
|
257 |
by (blast_tac (claset() addDs [apply_equality, apply_Pair]) 1); |
aa5ea943f8e3
New proof of apply_equality and new thm Pi_image_cons
paulson
parents:
4512
diff
changeset
|
258 |
qed "Pi_image_cons"; |
aa5ea943f8e3
New proof of apply_equality and new thm Pi_image_cons
paulson
parents:
4512
diff
changeset
|
259 |
|
435 | 260 |
|
0 | 261 |
(*** properties of "restrict" ***) |
262 |
||
2877 | 263 |
goalw ZF.thy [restrict_def,lam_def] |
0 | 264 |
"!!f A. [| f: Pi(C,B); A<=C |] ==> restrict(f,A) <= f"; |
4091 | 265 |
by (blast_tac (claset() addIs [apply_Pair]) 1); |
760 | 266 |
qed "restrict_subset"; |
0 | 267 |
|
2877 | 268 |
val prems = goalw ZF.thy [restrict_def] |
0 | 269 |
"[| !!x. x:A ==> f`x: B(x) |] ==> restrict(f,A) : Pi(A,B)"; |
270 |
by (rtac lam_type 1); |
|
271 |
by (eresolve_tac prems 1); |
|
760 | 272 |
qed "restrict_type"; |
0 | 273 |
|
2877 | 274 |
val [pi,subs] = goal ZF.thy |
0 | 275 |
"[| f: Pi(C,B); A<=C |] ==> restrict(f,A) : Pi(A,B)"; |
276 |
by (rtac (pi RS apply_type RS restrict_type) 1); |
|
277 |
by (etac (subs RS subsetD) 1); |
|
760 | 278 |
qed "restrict_type2"; |
0 | 279 |
|
2877 | 280 |
goalw ZF.thy [restrict_def] "!!a A. a : A ==> restrict(f,A) ` a = f`a"; |
0 | 281 |
by (etac beta 1); |
760 | 282 |
qed "restrict"; |
0 | 283 |
|
2877 | 284 |
goalw ZF.thy [restrict_def] "restrict(f,0) = 0"; |
2469 | 285 |
by (Simp_tac 1); |
286 |
qed "restrict_empty"; |
|
287 |
||
288 |
Addsimps [restrict, restrict_empty]; |
|
289 |
||
0 | 290 |
(*NOT SAFE as a congruence rule for the simplifier! Can cause it to fail!*) |
2877 | 291 |
val prems = goalw ZF.thy [restrict_def] |
0 | 292 |
"[| A=B; !!x. x:B ==> f`x=g`x |] ==> restrict(f,A) = restrict(g,B)"; |
293 |
by (REPEAT (ares_tac (prems@[lam_cong]) 1)); |
|
760 | 294 |
qed "restrict_eqI"; |
0 | 295 |
|
2877 | 296 |
goalw ZF.thy [restrict_def, lam_def] "domain(restrict(f,C)) = C"; |
297 |
by (Blast_tac 1); |
|
760 | 298 |
qed "domain_restrict"; |
0 | 299 |
|
2877 | 300 |
val [prem] = goalw ZF.thy [restrict_def] |
0 | 301 |
"A<=C ==> restrict(lam x:C. b(x), A) = (lam x:A. b(x))"; |
302 |
by (rtac (refl RS lam_cong) 1); |
|
1461 | 303 |
by (etac (prem RS subsetD RS beta) 1); (*easier than calling simp_tac*) |
760 | 304 |
qed "restrict_lam_eq"; |
0 | 305 |
|
306 |
||
307 |
||
308 |
(*** Unions of functions ***) |
|
309 |
||
310 |
(** The Union of a set of COMPATIBLE functions is a function **) |
|
691
b9fc536792bb
ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents:
538
diff
changeset
|
311 |
|
2877 | 312 |
goalw ZF.thy [function_def] |
691
b9fc536792bb
ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents:
538
diff
changeset
|
313 |
"!!S. [| ALL x:S. function(x); \ |
b9fc536792bb
ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents:
538
diff
changeset
|
314 |
\ ALL x:S. ALL y:S. x<=y | y<=x |] ==> \ |
b9fc536792bb
ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents:
538
diff
changeset
|
315 |
\ function(Union(S))"; |
2925 | 316 |
by (fast_tac (ZF_cs addSDs [bspec RS bspec]) 1); |
317 |
(*by (Blast_tac 1); takes too long...*) |
|
760 | 318 |
qed "function_Union"; |
691
b9fc536792bb
ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents:
538
diff
changeset
|
319 |
|
2877 | 320 |
goalw ZF.thy [Pi_def] |
691
b9fc536792bb
ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents:
538
diff
changeset
|
321 |
"!!S. [| ALL f:S. EX C D. f:C->D; \ |
b9fc536792bb
ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents:
538
diff
changeset
|
322 |
\ ALL f:S. ALL y:S. f<=y | y<=f |] ==> \ |
b9fc536792bb
ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents:
538
diff
changeset
|
323 |
\ Union(S) : domain(Union(S)) -> range(Union(S))"; |
2877 | 324 |
by (blast_tac (subset_cs addSIs [rel_Union, function_Union]) 1); |
760 | 325 |
qed "fun_Union"; |
0 | 326 |
|
327 |
||
328 |
(** The Union of 2 disjoint functions is a function **) |
|
329 |
||
691
b9fc536792bb
ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents:
538
diff
changeset
|
330 |
val Un_rls = [Un_subset_iff, domain_Un_eq, SUM_Un_distrib1, prod_Un_distrib2, |
1461 | 331 |
Un_upper1 RSN (2, subset_trans), |
332 |
Un_upper2 RSN (2, subset_trans)]; |
|
691
b9fc536792bb
ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents:
538
diff
changeset
|
333 |
|
2925 | 334 |
goal ZF.thy "!!f. [| f: A->B; g: C->D; A Int C = 0 |] \ |
335 |
\ ==> (f Un g) : (A Un C) -> (B Un D)"; |
|
2877 | 336 |
(*Prove the product and domain subgoals using distributive laws*) |
4091 | 337 |
by (asm_full_simp_tac (simpset() addsimps [Pi_iff,extension]@Un_rls) 1); |
1461 | 338 |
by (rewtac function_def); |
4512
572440df6aa7
Changed required by new blast_tac (the one that squashes flex-flex pairs)
paulson
parents:
4091
diff
changeset
|
339 |
by (Blast_tac 1); |
760 | 340 |
qed "fun_disjoint_Un"; |
0 | 341 |
|
2877 | 342 |
goal ZF.thy |
0 | 343 |
"!!f g a. [| a:A; f: A->B; g: C->D; A Int C = 0 |] ==> \ |
344 |
\ (f Un g)`a = f`a"; |
|
691
b9fc536792bb
ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents:
538
diff
changeset
|
345 |
by (rtac (apply_Pair RS UnI1 RS apply_equality) 1); |
b9fc536792bb
ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents:
538
diff
changeset
|
346 |
by (REPEAT (ares_tac [fun_disjoint_Un] 1)); |
760 | 347 |
qed "fun_disjoint_apply1"; |
0 | 348 |
|
2877 | 349 |
goal ZF.thy |
0 | 350 |
"!!f g c. [| c:C; f: A->B; g: C->D; A Int C = 0 |] ==> \ |
351 |
\ (f Un g)`c = g`c"; |
|
691
b9fc536792bb
ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents:
538
diff
changeset
|
352 |
by (rtac (apply_Pair RS UnI2 RS apply_equality) 1); |
b9fc536792bb
ZF/func: tidied many proofs, using new definition of Pi(A,B)
lcp
parents:
538
diff
changeset
|
353 |
by (REPEAT (ares_tac [fun_disjoint_Un] 1)); |
760 | 354 |
qed "fun_disjoint_apply2"; |
0 | 355 |
|
356 |
(** Domain and range of a function/relation **) |
|
357 |
||
2877 | 358 |
goalw ZF.thy [Pi_def] "!!f. f : Pi(A,B) ==> domain(f)=A"; |
359 |
by (Blast_tac 1); |
|
760 | 360 |
qed "domain_of_fun"; |
0 | 361 |
|
2877 | 362 |
goal ZF.thy "!!f. [| f : Pi(A,B); a: A |] ==> f`a : range(f)"; |
517 | 363 |
by (etac (apply_Pair RS rangeI) 1); |
364 |
by (assume_tac 1); |
|
760 | 365 |
qed "apply_rangeI"; |
517 | 366 |
|
2877 | 367 |
val [major] = goal ZF.thy "f : Pi(A,B) ==> f : A->range(f)"; |
0 | 368 |
by (rtac (major RS Pi_type) 1); |
517 | 369 |
by (etac (major RS apply_rangeI) 1); |
760 | 370 |
qed "range_of_fun"; |
0 | 371 |
|
372 |
(*** Extensions of functions ***) |
|
373 |
||
2877 | 374 |
goal ZF.thy |
37 | 375 |
"!!f A B. [| f: A->B; c~:A |] ==> cons(<c,b>,f) : cons(c,A) -> cons(b,B)"; |
857 | 376 |
by (forward_tac [singleton_fun RS fun_disjoint_Un] 1); |
519 | 377 |
by (asm_full_simp_tac (FOL_ss addsimps [cons_eq]) 2); |
2877 | 378 |
by (Blast_tac 1); |
760 | 379 |
qed "fun_extend"; |
0 | 380 |
|
2877 | 381 |
goal ZF.thy |
538 | 382 |
"!!f A B. [| f: A->B; c~:A; b: B |] ==> cons(<c,b>,f) : cons(c,A) -> B"; |
4091 | 383 |
by (blast_tac (claset() addIs [fun_extend RS fun_weaken_type]) 1); |
760 | 384 |
qed "fun_extend3"; |
538 | 385 |
|
2877 | 386 |
goal ZF.thy "!!f A B. [| f: A->B; a:A; c~:A |] ==> cons(<c,b>,f)`a = f`a"; |
0 | 387 |
by (rtac (apply_Pair RS consI2 RS apply_equality) 1); |
388 |
by (rtac fun_extend 3); |
|
389 |
by (REPEAT (assume_tac 1)); |
|
760 | 390 |
qed "fun_extend_apply1"; |
0 | 391 |
|
2877 | 392 |
goal ZF.thy "!!f A B. [| f: A->B; c~:A |] ==> cons(<c,b>,f)`c = b"; |
0 | 393 |
by (rtac (consI1 RS apply_equality) 1); |
394 |
by (rtac fun_extend 1); |
|
395 |
by (REPEAT (assume_tac 1)); |
|
760 | 396 |
qed "fun_extend_apply2"; |
0 | 397 |
|
2469 | 398 |
bind_thm ("singleton_apply", [singletonI, singleton_fun] MRS apply_equality); |
399 |
Addsimps [singleton_apply]; |
|
400 |
||
538 | 401 |
(*For Finite.ML. Inclusion of right into left is easy*) |
2877 | 402 |
goal ZF.thy |
485 | 403 |
"!!c. c ~: A ==> cons(c,A) -> B = (UN f: A->B. UN b:B. {cons(<c,b>, f)})"; |
737
436019ca97d7
cons_fun_eq: modified strange uses of classical reasoner
lcp
parents:
691
diff
changeset
|
404 |
by (rtac equalityI 1); |
4091 | 405 |
by (safe_tac (claset() addSEs [fun_extend3])); |
485 | 406 |
(*Inclusion of left into right*) |
407 |
by (subgoal_tac "restrict(x, A) : A -> B" 1); |
|
4091 | 408 |
by (blast_tac (claset() addIs [restrict_type2]) 2); |
485 | 409 |
by (rtac UN_I 1 THEN assume_tac 1); |
737
436019ca97d7
cons_fun_eq: modified strange uses of classical reasoner
lcp
parents:
691
diff
changeset
|
410 |
by (rtac (apply_funtype RS UN_I) 1 THEN REPEAT (ares_tac [consI1] 1)); |
2469 | 411 |
by (Simp_tac 1); |
1461 | 412 |
by (rtac fun_extension 1 THEN REPEAT (ares_tac [fun_extend] 1)); |
485 | 413 |
by (etac consE 1); |
414 |
by (ALLGOALS |
|
4091 | 415 |
(asm_simp_tac (simpset() addsimps [restrict, fun_extend_apply1, |
2493 | 416 |
fun_extend_apply2]))); |
760 | 417 |
qed "cons_fun_eq"; |
485 | 418 |