author | paulson |
Mon, 02 Aug 1999 11:24:30 +0200 | |
changeset 7143 | 9c02848c5404 |
parent 7089 | 9bfb8e218b99 |
child 7338 | b275ae194e5a |
permissions | -rw-r--r-- |
1465 | 1 |
(* Title: HOL/Fun |
923 | 2 |
ID: $Id$ |
1465 | 3 |
Author: Tobias Nipkow, Cambridge University Computer Laboratory |
923 | 4 |
Copyright 1993 University of Cambridge |
5 |
||
6 |
Lemmas about functions. |
|
7 |
*) |
|
8 |
||
4656 | 9 |
|
7089 | 10 |
Goal "(f = g) = (! x. f(x)=g(x))"; |
923 | 11 |
by (rtac iffI 1); |
1264 | 12 |
by (Asm_simp_tac 1); |
13 |
by (rtac ext 1 THEN Asm_simp_tac 1); |
|
923 | 14 |
qed "expand_fun_eq"; |
15 |
||
5316 | 16 |
val prems = Goal |
923 | 17 |
"[| f(x)=u; !!x. P(x) ==> g(f(x)) = x; P(x) |] ==> x=g(u)"; |
18 |
by (rtac (arg_cong RS box_equals) 1); |
|
19 |
by (REPEAT (resolve_tac (prems@[refl]) 1)); |
|
20 |
qed "apply_inverse"; |
|
21 |
||
22 |
||
4656 | 23 |
(** "Axiom" of Choice, proved using the description operator **) |
24 |
||
5316 | 25 |
Goal "!!Q. ALL x. EX y. Q x y ==> EX f. ALL x. Q x (f x)"; |
4656 | 26 |
by (fast_tac (claset() addEs [selectI]) 1); |
27 |
qed "choice"; |
|
28 |
||
5316 | 29 |
Goal "!!S. ALL x:S. EX y. Q x y ==> EX f. ALL x:S. Q x (f x)"; |
4656 | 30 |
by (fast_tac (claset() addEs [selectI]) 1); |
31 |
qed "bchoice"; |
|
32 |
||
33 |
||
5608 | 34 |
section "id"; |
5441 | 35 |
|
7089 | 36 |
Goalw [id_def] "id x = x"; |
37 |
by (rtac refl 1); |
|
38 |
qed "id_apply"; |
|
5608 | 39 |
Addsimps [id_apply]; |
5441 | 40 |
|
41 |
||
5306 | 42 |
section "o"; |
43 |
||
7089 | 44 |
Goalw [o_def] "(f o g) x = f (g x)"; |
45 |
by (rtac refl 1); |
|
46 |
qed "o_apply"; |
|
5306 | 47 |
Addsimps [o_apply]; |
48 |
||
7089 | 49 |
Goalw [o_def] "f o (g o h) = f o g o h"; |
50 |
by (rtac ext 1); |
|
51 |
by (rtac refl 1); |
|
52 |
qed "o_assoc"; |
|
5306 | 53 |
|
7089 | 54 |
Goalw [id_def] "id o g = g"; |
55 |
by (rtac ext 1); |
|
56 |
by (Simp_tac 1); |
|
57 |
qed "id_o"; |
|
5608 | 58 |
Addsimps [id_o]; |
5306 | 59 |
|
7089 | 60 |
Goalw [id_def] "f o id = f"; |
61 |
by (rtac ext 1); |
|
62 |
by (Simp_tac 1); |
|
63 |
qed "o_id"; |
|
5608 | 64 |
Addsimps [o_id]; |
5306 | 65 |
|
66 |
Goalw [o_def] "(f o g)``r = f``(g``r)"; |
|
67 |
by (Blast_tac 1); |
|
68 |
qed "image_compose"; |
|
69 |
||
5852 | 70 |
Goalw [o_def] "UNION A (g o f) = UNION (f``A) g"; |
71 |
by (Blast_tac 1); |
|
6829
50459a995aa3
renamed UNION_o to UN_o (to fit the convention) and added image_UN, image_INT
paulson
parents:
6301
diff
changeset
|
72 |
qed "UN_o"; |
5852 | 73 |
|
7014
11ee650edcd2
Added some definitions and theorems needed for the
berghofe
parents:
6829
diff
changeset
|
74 |
(** lemma for proving injectivity of representation functions for **) |
11ee650edcd2
Added some definitions and theorems needed for the
berghofe
parents:
6829
diff
changeset
|
75 |
(** datatypes involving function types **) |
11ee650edcd2
Added some definitions and theorems needed for the
berghofe
parents:
6829
diff
changeset
|
76 |
|
11ee650edcd2
Added some definitions and theorems needed for the
berghofe
parents:
6829
diff
changeset
|
77 |
Goalw [o_def] |
7089 | 78 |
"[| ! x y. g (f x) = g y --> f x = y; g o f = g o fa |] ==> f = fa"; |
79 |
by (rtac ext 1); |
|
80 |
by (etac allE 1); |
|
81 |
by (etac allE 1); |
|
82 |
by (etac mp 1); |
|
83 |
by (etac fun_cong 1); |
|
7014
11ee650edcd2
Added some definitions and theorems needed for the
berghofe
parents:
6829
diff
changeset
|
84 |
qed "inj_fun_lemma"; |
11ee650edcd2
Added some definitions and theorems needed for the
berghofe
parents:
6829
diff
changeset
|
85 |
|
5306 | 86 |
|
87 |
section "inj"; |
|
6171 | 88 |
(**NB: inj now just translates to inj_on**) |
5306 | 89 |
|
923 | 90 |
(*** inj(f): f is a one-to-one function ***) |
91 |
||
6171 | 92 |
(*for Tools/datatype_rep_proofs*) |
93 |
val [prem] = Goalw [inj_on_def] |
|
94 |
"(!! x. ALL y. f(x) = f(y) --> x=y) ==> inj(f)"; |
|
95 |
by (blast_tac (claset() addIs [prem RS spec RS mp]) 1); |
|
96 |
qed "datatype_injI"; |
|
923 | 97 |
|
6171 | 98 |
Goalw [inj_on_def] "[| inj(f); f(x) = f(y) |] ==> x=y"; |
5316 | 99 |
by (Blast_tac 1); |
923 | 100 |
qed "injD"; |
101 |
||
102 |
(*Useful with the simplifier*) |
|
5316 | 103 |
Goal "inj(f) ==> (f(x) = f(y)) = (x=y)"; |
923 | 104 |
by (rtac iffI 1); |
5316 | 105 |
by (etac arg_cong 2); |
106 |
by (etac injD 1); |
|
5318 | 107 |
by (assume_tac 1); |
923 | 108 |
qed "inj_eq"; |
109 |
||
5316 | 110 |
Goal "inj(f) ==> (@x. f(x)=f(y)) = y"; |
111 |
by (etac injD 1); |
|
923 | 112 |
by (rtac selectI 1); |
113 |
by (rtac refl 1); |
|
114 |
qed "inj_select"; |
|
115 |
||
116 |
(*A one-to-one function has an inverse (given using select).*) |
|
5316 | 117 |
Goalw [inv_def] "inj(f) ==> inv f (f x) = x"; |
118 |
by (etac inj_select 1); |
|
2912 | 119 |
qed "inv_f_f"; |
923 | 120 |
|
6235 | 121 |
Addsimps [inv_f_f]; |
122 |
||
923 | 123 |
(* Useful??? *) |
5316 | 124 |
val [oneone,minor] = Goal |
2912 | 125 |
"[| inj(f); !!y. y: range(f) ==> P(inv f y) |] ==> P(x)"; |
126 |
by (res_inst_tac [("t", "x")] (oneone RS (inv_f_f RS subst)) 1); |
|
923 | 127 |
by (rtac (rangeI RS minor) 1); |
128 |
qed "inj_transfer"; |
|
129 |
||
7014
11ee650edcd2
Added some definitions and theorems needed for the
berghofe
parents:
6829
diff
changeset
|
130 |
Goalw [o_def] "[| inj f; f o g = f o h |] ==> g = h"; |
11ee650edcd2
Added some definitions and theorems needed for the
berghofe
parents:
6829
diff
changeset
|
131 |
by (rtac ext 1); |
11ee650edcd2
Added some definitions and theorems needed for the
berghofe
parents:
6829
diff
changeset
|
132 |
by (etac injD 1); |
11ee650edcd2
Added some definitions and theorems needed for the
berghofe
parents:
6829
diff
changeset
|
133 |
by (etac fun_cong 1); |
11ee650edcd2
Added some definitions and theorems needed for the
berghofe
parents:
6829
diff
changeset
|
134 |
qed "inj_o"; |
923 | 135 |
|
4830 | 136 |
(*** inj_on f A: f is one-to-one over A ***) |
923 | 137 |
|
5316 | 138 |
val prems = Goalw [inj_on_def] |
4830 | 139 |
"(!! x y. [| f(x) = f(y); x:A; y:A |] ==> x=y) ==> inj_on f A"; |
4089 | 140 |
by (blast_tac (claset() addIs prems) 1); |
4830 | 141 |
qed "inj_onI"; |
6171 | 142 |
val injI = inj_onI; (*for compatibility*) |
923 | 143 |
|
5316 | 144 |
val [major] = Goal |
4830 | 145 |
"(!!x. x:A ==> g(f(x)) = x) ==> inj_on f A"; |
146 |
by (rtac inj_onI 1); |
|
923 | 147 |
by (etac (apply_inverse RS trans) 1); |
148 |
by (REPEAT (eresolve_tac [asm_rl,major] 1)); |
|
4830 | 149 |
qed "inj_on_inverseI"; |
6171 | 150 |
val inj_inverseI = inj_on_inverseI; (*for compatibility*) |
923 | 151 |
|
5316 | 152 |
Goalw [inj_on_def] "[| inj_on f A; f(x)=f(y); x:A; y:A |] ==> x=y"; |
153 |
by (Blast_tac 1); |
|
4830 | 154 |
qed "inj_onD"; |
923 | 155 |
|
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5069
diff
changeset
|
156 |
Goal "[| inj_on f A; x:A; y:A |] ==> (f(x)=f(y)) = (x=y)"; |
4830 | 157 |
by (blast_tac (claset() addSDs [inj_onD]) 1); |
158 |
qed "inj_on_iff"; |
|
923 | 159 |
|
5316 | 160 |
Goalw [inj_on_def] "[| inj_on f A; ~x=y; x:A; y:A |] ==> ~ f(x)=f(y)"; |
161 |
by (Blast_tac 1); |
|
4830 | 162 |
qed "inj_on_contraD"; |
923 | 163 |
|
5316 | 164 |
Goalw [inj_on_def] "[| A<=B; inj_on f B |] ==> inj_on f A"; |
3341 | 165 |
by (Blast_tac 1); |
4830 | 166 |
qed "subset_inj_on"; |
3341 | 167 |
|
923 | 168 |
|
6235 | 169 |
(** surj **) |
170 |
||
6267 | 171 |
val [prem] = Goalw [surj_def] "(!! x. g(f x) = x) ==> surj g"; |
172 |
by (blast_tac (claset() addIs [prem RS sym]) 1); |
|
6235 | 173 |
qed "surjI"; |
174 |
||
175 |
Goalw [surj_def] "surj f ==> range f = UNIV"; |
|
176 |
by Auto_tac; |
|
177 |
qed "surj_range"; |
|
178 |
||
6267 | 179 |
Goalw [surj_def] "surj f ==> EX x. y = f x"; |
180 |
by (Blast_tac 1); |
|
181 |
qed "surjD"; |
|
182 |
||
6235 | 183 |
|
6171 | 184 |
(*** Lemmas about injective functions and inv ***) |
923 | 185 |
|
7051 | 186 |
Goalw [o_def] "[| inj_on f A; inj_on g (f``A) |] ==> inj_on (g o f) A"; |
6171 | 187 |
by (fast_tac (claset() addIs [inj_onI] addEs [inj_onD]) 1); |
188 |
qed "comp_inj_on"; |
|
923 | 189 |
|
5316 | 190 |
Goalw [inv_def] "y : range(f) ==> f(inv f y) = y"; |
191 |
by (fast_tac (claset() addIs [selectI]) 1); |
|
2912 | 192 |
qed "f_inv_f"; |
923 | 193 |
|
6235 | 194 |
Goal "surj f ==> f(inv f y) = y"; |
195 |
by (asm_simp_tac (simpset() addsimps [f_inv_f, surj_range]) 1); |
|
196 |
qed "surj_f_inv_f"; |
|
197 |
||
6171 | 198 |
Goal "[| inv f x = inv f y; x: range(f); y: range(f) |] ==> x=y"; |
2912 | 199 |
by (rtac (arg_cong RS box_equals) 1); |
5316 | 200 |
by (REPEAT (ares_tac [f_inv_f] 1)); |
2912 | 201 |
qed "inv_injective"; |
202 |
||
6235 | 203 |
Goal "A <= range(f) ==> inj_on (inv f) A"; |
4830 | 204 |
by (fast_tac (claset() addIs [inj_onI] |
6235 | 205 |
addEs [inv_injective, injD]) 1); |
4830 | 206 |
qed "inj_on_inv"; |
923 | 207 |
|
6235 | 208 |
Goal "surj f ==> inj (inv f)"; |
209 |
by (asm_simp_tac (simpset() addsimps [inj_on_inv, surj_range]) 1); |
|
210 |
qed "surj_imp_inj_inv"; |
|
211 |
||
6290 | 212 |
Goal "f``(A Int B) <= f``A Int f``B"; |
213 |
by (Blast_tac 1); |
|
214 |
qed "image_Int_subset"; |
|
215 |
||
216 |
Goal "f``A - f``B <= f``(A - B)"; |
|
217 |
by (Blast_tac 1); |
|
218 |
qed "image_diff_subset"; |
|
219 |
||
5069 | 220 |
Goalw [inj_on_def] |
5148
74919e8f221c
More tidying and removal of "\!\!... from Goal commands
paulson
parents:
5143
diff
changeset
|
221 |
"[| inj_on f C; A<=C; B<=C |] ==> f``(A Int B) = f``A Int f``B"; |
4059 | 222 |
by (Blast_tac 1); |
4830 | 223 |
qed "inj_on_image_Int"; |
4059 | 224 |
|
5069 | 225 |
Goalw [inj_on_def] |
5148
74919e8f221c
More tidying and removal of "\!\!... from Goal commands
paulson
parents:
5143
diff
changeset
|
226 |
"[| inj_on f C; A<=C; B<=C |] ==> f``(A-B) = f``A - f``B"; |
4059 | 227 |
by (Blast_tac 1); |
4830 | 228 |
qed "inj_on_image_set_diff"; |
4059 | 229 |
|
6171 | 230 |
Goalw [inj_on_def] "inj f ==> f``(A Int B) = f``A Int f``B"; |
4059 | 231 |
by (Blast_tac 1); |
232 |
qed "image_Int"; |
|
233 |
||
6171 | 234 |
Goalw [inj_on_def] "inj f ==> f``(A-B) = f``A - f``B"; |
4059 | 235 |
by (Blast_tac 1); |
236 |
qed "image_set_diff"; |
|
237 |
||
6235 | 238 |
Goalw [image_def] "inj(f) ==> inv(f)``(f``X) = X"; |
239 |
by Auto_tac; |
|
240 |
qed "inv_image_comp"; |
|
5847 | 241 |
|
6301 | 242 |
Goal "inj f ==> (f a : f``A) = (a : A)"; |
243 |
by (blast_tac (claset() addDs [injD]) 1); |
|
244 |
qed "inj_image_mem_iff"; |
|
245 |
||
246 |
Goal "inj f ==> (f``A = f``B) = (A = B)"; |
|
247 |
by (blast_tac (claset() addSEs [equalityE] addDs [injD]) 1); |
|
248 |
qed "inj_image_eq_iff"; |
|
249 |
||
6829
50459a995aa3
renamed UNION_o to UN_o (to fit the convention) and added image_UN, image_INT
paulson
parents:
6301
diff
changeset
|
250 |
Goal "(f `` (UNION A B)) = (UN x:A.(f `` (B x)))"; |
50459a995aa3
renamed UNION_o to UN_o (to fit the convention) and added image_UN, image_INT
paulson
parents:
6301
diff
changeset
|
251 |
by (Blast_tac 1); |
50459a995aa3
renamed UNION_o to UN_o (to fit the convention) and added image_UN, image_INT
paulson
parents:
6301
diff
changeset
|
252 |
qed "image_UN"; |
50459a995aa3
renamed UNION_o to UN_o (to fit the convention) and added image_UN, image_INT
paulson
parents:
6301
diff
changeset
|
253 |
|
50459a995aa3
renamed UNION_o to UN_o (to fit the convention) and added image_UN, image_INT
paulson
parents:
6301
diff
changeset
|
254 |
(*injectivity's required. Left-to-right inclusion holds even if A is empty*) |
50459a995aa3
renamed UNION_o to UN_o (to fit the convention) and added image_UN, image_INT
paulson
parents:
6301
diff
changeset
|
255 |
Goalw [inj_on_def] |
50459a995aa3
renamed UNION_o to UN_o (to fit the convention) and added image_UN, image_INT
paulson
parents:
6301
diff
changeset
|
256 |
"[| inj_on f C; ALL x:A. B x <= C; j:A |] \ |
50459a995aa3
renamed UNION_o to UN_o (to fit the convention) and added image_UN, image_INT
paulson
parents:
6301
diff
changeset
|
257 |
\ ==> f `` (INTER A B) = (INT x:A. f `` B x)"; |
50459a995aa3
renamed UNION_o to UN_o (to fit the convention) and added image_UN, image_INT
paulson
parents:
6301
diff
changeset
|
258 |
by (Blast_tac 1); |
50459a995aa3
renamed UNION_o to UN_o (to fit the convention) and added image_UN, image_INT
paulson
parents:
6301
diff
changeset
|
259 |
qed "image_INT"; |
50459a995aa3
renamed UNION_o to UN_o (to fit the convention) and added image_UN, image_INT
paulson
parents:
6301
diff
changeset
|
260 |
|
4089 | 261 |
val set_cs = claset() delrules [equalityI]; |
5305 | 262 |
|
263 |
||
264 |
section "fun_upd"; |
|
265 |
||
266 |
Goalw [fun_upd_def] "(f(x:=y) = f) = (f x = y)"; |
|
267 |
by Safe_tac; |
|
268 |
by (etac subst 1); |
|
269 |
by (rtac ext 2); |
|
270 |
by Auto_tac; |
|
271 |
qed "fun_upd_idem_iff"; |
|
272 |
||
273 |
(* f x = y ==> f(x:=y) = f *) |
|
274 |
bind_thm("fun_upd_idem", fun_upd_idem_iff RS iffD2); |
|
275 |
||
276 |
(* f(x := f x) = f *) |
|
277 |
AddIffs [refl RS fun_upd_idem]; |
|
278 |
||
279 |
Goal "(f(x:=y))z = (if z=x then y else f z)"; |
|
280 |
by (simp_tac (simpset() addsimps [fun_upd_def]) 1); |
|
281 |
qed "fun_upd_apply"; |
|
282 |
Addsimps [fun_upd_apply]; |
|
283 |
||
7089 | 284 |
Goal "(f(x:=y)) x = y"; |
285 |
by (Simp_tac 1); |
|
286 |
qed "fun_upd_same"; |
|
287 |
||
288 |
Goal "z~=x ==> (f(x:=y)) z = f z"; |
|
289 |
by (Asm_simp_tac 1); |
|
290 |
qed "fun_upd_other"; |
|
291 |
||
292 |
(*Currently unused? |
|
293 |
We could try Addsimps [fun_upd_same, fun_upd_other];*) |
|
5305 | 294 |
|
295 |
Goal "a ~= c ==> m(a:=b)(c:=d) = m(c:=d)(a:=b)"; |
|
296 |
by (rtac ext 1); |
|
7089 | 297 |
by Auto_tac; |
5305 | 298 |
qed "fun_upd_twist"; |
5852 | 299 |
|
300 |
||
301 |
(*** -> and Pi, by Florian Kammueller and LCP ***) |
|
302 |
||
303 |
val prems = Goalw [Pi_def] |
|
304 |
"[| !!x. x: A ==> f x: B x; !!x. x ~: A ==> f(x) = (@ y. True)|] \ |
|
305 |
\ ==> f: Pi A B"; |
|
306 |
by (auto_tac (claset(), simpset() addsimps prems)); |
|
307 |
qed "Pi_I"; |
|
308 |
||
309 |
val prems = Goal |
|
310 |
"[| !!x. x: A ==> f x: B; !!x. x ~: A ==> f(x) = (@ y. True)|] ==> f: A funcset B"; |
|
311 |
by (blast_tac (claset() addIs Pi_I::prems) 1); |
|
312 |
qed "funcsetI"; |
|
313 |
||
314 |
Goalw [Pi_def] "[|f: Pi A B; x: A|] ==> f x: B x"; |
|
315 |
by Auto_tac; |
|
316 |
qed "Pi_mem"; |
|
317 |
||
318 |
Goalw [Pi_def] "[|f: A funcset B; x: A|] ==> f x: B"; |
|
319 |
by Auto_tac; |
|
320 |
qed "funcset_mem"; |
|
321 |
||
322 |
Goalw [Pi_def] "[|f: Pi A B; x~: A|] ==> f x = (@ y. True)"; |
|
323 |
by Auto_tac; |
|
324 |
qed "apply_arb"; |
|
325 |
||
326 |
Goalw [Pi_def] "[| f: Pi A B; g: Pi A B; ! x: A. f x = g x |] ==> f = g"; |
|
327 |
by (rtac ext 1); |
|
328 |
by Auto_tac; |
|
329 |
val Pi_extensionality = ballI RSN (3, result()); |
|
330 |
||
331 |
(*** compose ***) |
|
332 |
||
333 |
Goalw [Pi_def, compose_def, restrict_def] |
|
334 |
"[| f: A funcset B; g: B funcset C |]==> compose A g f: A funcset C"; |
|
335 |
by Auto_tac; |
|
336 |
qed "funcset_compose"; |
|
337 |
||
338 |
Goal "[| f: A funcset B; g: B funcset C; h: C funcset D |]\ |
|
339 |
\ ==> compose A h (compose A g f) = compose A (compose B h g) f"; |
|
340 |
by (res_inst_tac [("A","A")] Pi_extensionality 1); |
|
341 |
by (blast_tac (claset() addIs [funcset_compose]) 1); |
|
342 |
by (blast_tac (claset() addIs [funcset_compose]) 1); |
|
343 |
by (rewrite_goals_tac [Pi_def, compose_def, restrict_def]); |
|
344 |
by Auto_tac; |
|
345 |
qed "compose_assoc"; |
|
346 |
||
347 |
Goal "[| f: A funcset B; g: B funcset C; x: A |]==> compose A g f x = g(f(x))"; |
|
348 |
by (asm_full_simp_tac (simpset() addsimps [compose_def, restrict_def]) 1); |
|
349 |
qed "compose_eq"; |
|
350 |
||
351 |
Goal "[| f : A funcset B; f `` A = B; g: B funcset C; g `` B = C |]\ |
|
352 |
\ ==> compose A g f `` A = C"; |
|
353 |
by (auto_tac (claset(), |
|
354 |
simpset() addsimps [image_def, compose_eq])); |
|
355 |
qed "surj_compose"; |
|
356 |
||
357 |
||
358 |
Goal "[| f : A funcset B; g: B funcset C; f `` A = B; inj_on f A; inj_on g B |]\ |
|
359 |
\ ==> inj_on (compose A g f) A"; |
|
360 |
by (auto_tac (claset(), |
|
361 |
simpset() addsimps [inj_on_def, compose_eq])); |
|
362 |
qed "inj_on_compose"; |
|
363 |
||
364 |
||
365 |
(*** restrict / lam ***) |
|
366 |
Goal "[| f `` A <= B |] ==> (lam x: A. f x) : A funcset B"; |
|
367 |
by (auto_tac (claset(), |
|
368 |
simpset() addsimps [restrict_def, Pi_def])); |
|
369 |
qed "restrict_in_funcset"; |
|
370 |
||
371 |
val prems = Goalw [restrict_def, Pi_def] |
|
372 |
"(!!x. x: A ==> f x: B x) ==> (lam x: A. f x) : Pi A B"; |
|
373 |
by (asm_simp_tac (simpset() addsimps prems) 1); |
|
374 |
qed "restrictI"; |
|
375 |
||
376 |
||
377 |
Goal "x: A ==> (lam y: A. f y) x = f x"; |
|
378 |
by (asm_simp_tac (simpset() addsimps [restrict_def]) 1); |
|
379 |
qed "restrict_apply1"; |
|
380 |
||
381 |
Goal "[| x: A; f : A funcset B |] ==> (lam y: A. f y) x : B"; |
|
382 |
by (asm_full_simp_tac (simpset() addsimps [restrict_apply1,Pi_def]) 1); |
|
383 |
qed "restrict_apply1_mem"; |
|
384 |
||
385 |
Goal "x ~: A ==> (lam y: A. f y) x = (@ y. True)"; |
|
386 |
by (asm_simp_tac (simpset() addsimps [restrict_def]) 1); |
|
387 |
qed "restrict_apply2"; |
|
388 |
||
389 |
||
390 |
val prems = Goal |
|
391 |
"(!!x. x: A ==> f x = g x) ==> (lam x: A. f x) = (lam x: A. g x)"; |
|
392 |
by (rtac ext 1); |
|
393 |
by (auto_tac (claset(), |
|
394 |
simpset() addsimps prems@[restrict_def, Pi_def])); |
|
395 |
qed "restrict_ext"; |
|
396 |
||
397 |
||
398 |
(*** Inverse ***) |
|
399 |
||
400 |
Goal "[|f `` A = B; x: B |] ==> ? y: A. f y = x"; |
|
401 |
by (Blast_tac 1); |
|
402 |
qed "surj_image"; |
|
403 |
||
404 |
Goalw [Inv_def] "[| f `` A = B; f : A funcset B |] \ |
|
405 |
\ ==> (lam x: B. (Inv A f) x) : B funcset A"; |
|
406 |
by (fast_tac (claset() addIs [restrict_in_funcset, selectI2]) 1); |
|
407 |
qed "Inv_funcset"; |
|
408 |
||
409 |
||
410 |
Goal "[| f: A funcset B; inj_on f A; f `` A = B; x: A |] \ |
|
411 |
\ ==> (lam y: B. (Inv A f) y) (f x) = x"; |
|
412 |
by (asm_simp_tac (simpset() addsimps [restrict_apply1, funcset_mem]) 1); |
|
413 |
by (asm_full_simp_tac (simpset() addsimps [Inv_def, inj_on_def]) 1); |
|
414 |
by (rtac selectI2 1); |
|
415 |
by Auto_tac; |
|
416 |
qed "Inv_f_f"; |
|
417 |
||
418 |
Goal "[| f: A funcset B; f `` A = B; x: B |] \ |
|
419 |
\ ==> f ((lam y: B. (Inv A f y)) x) = x"; |
|
420 |
by (asm_simp_tac (simpset() addsimps [Inv_def, restrict_apply1]) 1); |
|
421 |
by (fast_tac (claset() addIs [selectI2]) 1); |
|
422 |
qed "f_Inv_f"; |
|
423 |
||
424 |
Goal "[| f: A funcset B; inj_on f A; f `` A = B |]\ |
|
425 |
\ ==> compose A (lam y:B. (Inv A f) y) f = (lam x: A. x)"; |
|
426 |
by (rtac Pi_extensionality 1); |
|
427 |
by (blast_tac (claset() addIs [funcset_compose, Inv_funcset]) 1); |
|
428 |
by (blast_tac (claset() addIs [restrict_in_funcset]) 1); |
|
429 |
by (asm_simp_tac |
|
430 |
(simpset() addsimps [restrict_apply1, compose_def, Inv_f_f]) 1); |
|
431 |
qed "compose_Inv_id"; |
|
432 |
||
433 |
||
434 |
(*** Pi and Applyall ***) |
|
435 |
||
436 |
Goalw [Pi_def] "[| B(x) = {}; x: A |] ==> (PI x: A. B x) = {}"; |
|
437 |
by Auto_tac; |
|
438 |
qed "Pi_eq_empty"; |
|
439 |
||
440 |
Goal "[| (PI x: A. B x) ~= {}; x: A |] ==> B(x) ~= {}"; |
|
441 |
by (blast_tac (HOL_cs addIs [Pi_eq_empty]) 1); |
|
442 |
qed "Pi_total1"; |
|
443 |
||
444 |
Goal "[| a : A; Pi A B ~= {} |] ==> Applyall (Pi A B) a = B a"; |
|
445 |
by (auto_tac (claset(), simpset() addsimps [Applyall_def, Pi_def])); |
|
446 |
by (rename_tac "g z" 1); |
|
447 |
by (res_inst_tac [("x","%y. if (y = a) then z else g y")] exI 1); |
|
448 |
by (auto_tac (claset(), simpset() addsimps [split_if_mem1, split_if_eq1])); |
|
449 |
qed "Applyall_beta"; |
|
450 |
||
5865
2303f5a3036d
moved some facts about Pi from ex/PiSets to Fun.ML
paulson
parents:
5852
diff
changeset
|
451 |
Goal "Pi {} B = { (%x. @ y. True) }"; |
2303f5a3036d
moved some facts about Pi from ex/PiSets to Fun.ML
paulson
parents:
5852
diff
changeset
|
452 |
by (auto_tac (claset() addIs [ext], simpset() addsimps [Pi_def])); |
2303f5a3036d
moved some facts about Pi from ex/PiSets to Fun.ML
paulson
parents:
5852
diff
changeset
|
453 |
qed "Pi_empty"; |
5852 | 454 |
|
5865
2303f5a3036d
moved some facts about Pi from ex/PiSets to Fun.ML
paulson
parents:
5852
diff
changeset
|
455 |
val [major] = Goalw [Pi_def] "(!!x. x: A ==> B x <= C x) ==> Pi A B <= Pi A C"; |
2303f5a3036d
moved some facts about Pi from ex/PiSets to Fun.ML
paulson
parents:
5852
diff
changeset
|
456 |
by (auto_tac (claset(), |
2303f5a3036d
moved some facts about Pi from ex/PiSets to Fun.ML
paulson
parents:
5852
diff
changeset
|
457 |
simpset() addsimps [impOfSubs major])); |
2303f5a3036d
moved some facts about Pi from ex/PiSets to Fun.ML
paulson
parents:
5852
diff
changeset
|
458 |
qed "Pi_mono"; |