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