author | paulson |
Wed, 09 Feb 2005 18:32:28 +0100 | |
changeset 15510 | 9de204d7b699 |
parent 15439 | 71c0f98e31f1 |
child 15531 | 08c8dad8e399 |
permissions | -rw-r--r-- |
1475 | 1 |
(* Title: HOL/Fun.thy |
923 | 2 |
ID: $Id$ |
1475 | 3 |
Author: Tobias Nipkow, Cambridge University Computer Laboratory |
923 | 4 |
Copyright 1994 University of Cambridge |
5 |
||
2912 | 6 |
Notions about functions. |
923 | 7 |
*) |
8 |
||
15510 | 9 |
theory Fun |
15140 | 10 |
imports Typedef |
15131 | 11 |
begin |
2912 | 12 |
|
12338
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
12258
diff
changeset
|
13 |
instance set :: (type) order |
13585 | 14 |
by (intro_classes, |
15 |
(assumption | rule subset_refl subset_trans subset_antisym psubset_eq)+) |
|
16 |
||
17 |
constdefs |
|
18 |
fun_upd :: "('a => 'b) => 'a => 'b => ('a => 'b)" |
|
19 |
"fun_upd f a b == % x. if x=a then b else f x" |
|
6171 | 20 |
|
9141 | 21 |
nonterminals |
22 |
updbinds updbind |
|
5305 | 23 |
syntax |
13585 | 24 |
"_updbind" :: "['a, 'a] => updbind" ("(2_ :=/ _)") |
25 |
"" :: "updbind => updbinds" ("_") |
|
26 |
"_updbinds":: "[updbind, updbinds] => updbinds" ("_,/ _") |
|
27 |
"_Update" :: "['a, updbinds] => 'a" ("_/'((_)')" [1000,0] 900) |
|
5305 | 28 |
|
29 |
translations |
|
30 |
"_Update f (_updbinds b bs)" == "_Update (_Update f b) bs" |
|
31 |
"f(x:=y)" == "fun_upd f x y" |
|
2912 | 32 |
|
9340 | 33 |
(* Hint: to define the sum of two functions (or maps), use sum_case. |
34 |
A nice infix syntax could be defined (in Datatype.thy or below) by |
|
35 |
consts |
|
36 |
fun_sum :: "('a => 'c) => ('b => 'c) => (('a+'b) => 'c)" (infixr "'(+')"80) |
|
37 |
translations |
|
13585 | 38 |
"fun_sum" == sum_case |
9340 | 39 |
*) |
12258 | 40 |
|
6171 | 41 |
constdefs |
13910 | 42 |
overwrite :: "('a => 'b) => ('a => 'b) => 'a set => ('a => 'b)" |
43 |
("_/'(_|/_')" [900,0,0]900) |
|
44 |
"f(g|A) == %a. if a : A then g a else f a" |
|
6171 | 45 |
|
13910 | 46 |
id :: "'a => 'a" |
47 |
"id == %x. x" |
|
48 |
||
49 |
comp :: "['b => 'c, 'a => 'b, 'a] => 'c" (infixl "o" 55) |
|
50 |
"f o g == %x. f(g(x))" |
|
11123 | 51 |
|
13585 | 52 |
text{*compatibility*} |
53 |
lemmas o_def = comp_def |
|
2912 | 54 |
|
12114
a8e860c86252
eliminated old "symbols" syntax, use "xsymbols" instead;
wenzelm
parents:
11609
diff
changeset
|
55 |
syntax (xsymbols) |
13585 | 56 |
comp :: "['b => 'c, 'a => 'b, 'a] => 'c" (infixl "\<circ>" 55) |
14565 | 57 |
syntax (HTML output) |
58 |
comp :: "['b => 'c, 'a => 'b, 'a] => 'c" (infixl "\<circ>" 55) |
|
13585 | 59 |
|
9352 | 60 |
|
13585 | 61 |
constdefs |
62 |
inj_on :: "['a => 'b, 'a set] => bool" (*injective*) |
|
63 |
"inj_on f A == ! x:A. ! y:A. f(x)=f(y) --> x=y" |
|
6171 | 64 |
|
13585 | 65 |
text{*A common special case: functions injective over the entire domain type.*} |
66 |
syntax inj :: "('a => 'b) => bool" |
|
6171 | 67 |
translations |
68 |
"inj f" == "inj_on f UNIV" |
|
5852 | 69 |
|
7374 | 70 |
constdefs |
13585 | 71 |
surj :: "('a => 'b) => bool" (*surjective*) |
7374 | 72 |
"surj f == ! y. ? x. y=f(x)" |
12258 | 73 |
|
13585 | 74 |
bij :: "('a => 'b) => bool" (*bijective*) |
7374 | 75 |
"bij f == inj f & surj f" |
12258 | 76 |
|
7374 | 77 |
|
13585 | 78 |
|
79 |
text{*As a simplification rule, it replaces all function equalities by |
|
80 |
first-order equalities.*} |
|
81 |
lemma expand_fun_eq: "(f = g) = (! x. f(x)=g(x))" |
|
82 |
apply (rule iffI) |
|
83 |
apply (simp (no_asm_simp)) |
|
84 |
apply (rule ext, simp (no_asm_simp)) |
|
85 |
done |
|
86 |
||
87 |
lemma apply_inverse: |
|
88 |
"[| f(x)=u; !!x. P(x) ==> g(f(x)) = x; P(x) |] ==> x=g(u)" |
|
89 |
by auto |
|
90 |
||
91 |
||
92 |
text{*The Identity Function: @{term id}*} |
|
93 |
lemma id_apply [simp]: "id x = x" |
|
94 |
by (simp add: id_def) |
|
95 |
||
15510 | 96 |
lemma inj_on_id: "inj_on id A" |
97 |
by (simp add: inj_on_def) |
|
98 |
||
99 |
lemma surj_id: "surj id" |
|
100 |
by (simp add: surj_def) |
|
101 |
||
102 |
lemma bij_id: "bij id" |
|
103 |
by (simp add: bij_def inj_on_id surj_id) |
|
104 |
||
105 |
||
13585 | 106 |
|
107 |
subsection{*The Composition Operator: @{term "f \<circ> g"}*} |
|
108 |
||
109 |
lemma o_apply [simp]: "(f o g) x = f (g x)" |
|
110 |
by (simp add: comp_def) |
|
111 |
||
112 |
lemma o_assoc: "f o (g o h) = f o g o h" |
|
113 |
by (simp add: comp_def) |
|
114 |
||
115 |
lemma id_o [simp]: "id o g = g" |
|
116 |
by (simp add: comp_def) |
|
117 |
||
118 |
lemma o_id [simp]: "f o id = f" |
|
119 |
by (simp add: comp_def) |
|
120 |
||
121 |
lemma image_compose: "(f o g) ` r = f`(g`r)" |
|
122 |
by (simp add: comp_def, blast) |
|
123 |
||
124 |
lemma image_eq_UN: "f`A = (UN x:A. {f x})" |
|
125 |
by blast |
|
126 |
||
127 |
lemma UN_o: "UNION A (g o f) = UNION (f`A) g" |
|
128 |
by (unfold comp_def, blast) |
|
129 |
||
130 |
||
131 |
subsection{*The Injectivity Predicate, @{term inj}*} |
|
132 |
||
133 |
text{*NB: @{term inj} now just translates to @{term inj_on}*} |
|
134 |
||
135 |
||
136 |
text{*For Proofs in @{text "Tools/datatype_rep_proofs"}*} |
|
137 |
lemma datatype_injI: |
|
138 |
"(!! x. ALL y. f(x) = f(y) --> x=y) ==> inj(f)" |
|
139 |
by (simp add: inj_on_def) |
|
140 |
||
13637 | 141 |
theorem range_ex1_eq: "inj f \<Longrightarrow> b : range f = (EX! x. b = f x)" |
142 |
by (unfold inj_on_def, blast) |
|
143 |
||
13585 | 144 |
lemma injD: "[| inj(f); f(x) = f(y) |] ==> x=y" |
145 |
by (simp add: inj_on_def) |
|
146 |
||
147 |
(*Useful with the simplifier*) |
|
148 |
lemma inj_eq: "inj(f) ==> (f(x) = f(y)) = (x=y)" |
|
149 |
by (force simp add: inj_on_def) |
|
150 |
||
151 |
||
152 |
subsection{*The Predicate @{term inj_on}: Injectivity On A Restricted Domain*} |
|
153 |
||
154 |
lemma inj_onI: |
|
155 |
"(!! x y. [| x:A; y:A; f(x) = f(y) |] ==> x=y) ==> inj_on f A" |
|
156 |
by (simp add: inj_on_def) |
|
157 |
||
158 |
lemma inj_on_inverseI: "(!!x. x:A ==> g(f(x)) = x) ==> inj_on f A" |
|
159 |
by (auto dest: arg_cong [of concl: g] simp add: inj_on_def) |
|
160 |
||
161 |
lemma inj_onD: "[| inj_on f A; f(x)=f(y); x:A; y:A |] ==> x=y" |
|
162 |
by (unfold inj_on_def, blast) |
|
163 |
||
164 |
lemma inj_on_iff: "[| inj_on f A; x:A; y:A |] ==> (f(x)=f(y)) = (x=y)" |
|
165 |
by (blast dest!: inj_onD) |
|
166 |
||
167 |
lemma comp_inj_on: |
|
168 |
"[| inj_on f A; inj_on g (f`A) |] ==> inj_on (g o f) A" |
|
169 |
by (simp add: comp_def inj_on_def) |
|
170 |
||
15303 | 171 |
lemma inj_on_imageI: "inj_on (g o f) A \<Longrightarrow> inj_on g (f ` A)" |
172 |
apply(simp add:inj_on_def image_def) |
|
173 |
apply blast |
|
174 |
done |
|
175 |
||
15439 | 176 |
lemma inj_on_image_iff: "\<lbrakk> ALL x:A. ALL y:A. (g(f x) = g(f y)) = (g x = g y); |
177 |
inj_on f A \<rbrakk> \<Longrightarrow> inj_on g (f ` A) = inj_on g A" |
|
178 |
apply(unfold inj_on_def) |
|
179 |
apply blast |
|
180 |
done |
|
181 |
||
13585 | 182 |
lemma inj_on_contraD: "[| inj_on f A; ~x=y; x:A; y:A |] ==> ~ f(x)=f(y)" |
183 |
by (unfold inj_on_def, blast) |
|
12258 | 184 |
|
13585 | 185 |
lemma inj_singleton: "inj (%s. {s})" |
186 |
by (simp add: inj_on_def) |
|
187 |
||
15111 | 188 |
lemma inj_on_empty[iff]: "inj_on f {}" |
189 |
by(simp add: inj_on_def) |
|
190 |
||
15303 | 191 |
lemma subset_inj_on: "[| inj_on f B; A <= B |] ==> inj_on f A" |
13585 | 192 |
by (unfold inj_on_def, blast) |
193 |
||
15111 | 194 |
lemma inj_on_Un: |
195 |
"inj_on f (A Un B) = |
|
196 |
(inj_on f A & inj_on f B & f`(A-B) Int f`(B-A) = {})" |
|
197 |
apply(unfold inj_on_def) |
|
198 |
apply (blast intro:sym) |
|
199 |
done |
|
200 |
||
201 |
lemma inj_on_insert[iff]: |
|
202 |
"inj_on f (insert a A) = (inj_on f A & f a ~: f`(A-{a}))" |
|
203 |
apply(unfold inj_on_def) |
|
204 |
apply (blast intro:sym) |
|
205 |
done |
|
206 |
||
207 |
lemma inj_on_diff: "inj_on f A ==> inj_on f (A-B)" |
|
208 |
apply(unfold inj_on_def) |
|
209 |
apply (blast) |
|
210 |
done |
|
211 |
||
13585 | 212 |
|
213 |
subsection{*The Predicate @{term surj}: Surjectivity*} |
|
214 |
||
215 |
lemma surjI: "(!! x. g(f x) = x) ==> surj g" |
|
216 |
apply (simp add: surj_def) |
|
217 |
apply (blast intro: sym) |
|
218 |
done |
|
219 |
||
220 |
lemma surj_range: "surj f ==> range f = UNIV" |
|
221 |
by (auto simp add: surj_def) |
|
222 |
||
223 |
lemma surjD: "surj f ==> EX x. y = f x" |
|
224 |
by (simp add: surj_def) |
|
225 |
||
226 |
lemma surjE: "surj f ==> (!!x. y = f x ==> C) ==> C" |
|
227 |
by (simp add: surj_def, blast) |
|
228 |
||
229 |
lemma comp_surj: "[| surj f; surj g |] ==> surj (g o f)" |
|
230 |
apply (simp add: comp_def surj_def, clarify) |
|
231 |
apply (drule_tac x = y in spec, clarify) |
|
232 |
apply (drule_tac x = x in spec, blast) |
|
233 |
done |
|
234 |
||
235 |
||
236 |
||
237 |
subsection{*The Predicate @{term bij}: Bijectivity*} |
|
238 |
||
239 |
lemma bijI: "[| inj f; surj f |] ==> bij f" |
|
240 |
by (simp add: bij_def) |
|
241 |
||
242 |
lemma bij_is_inj: "bij f ==> inj f" |
|
243 |
by (simp add: bij_def) |
|
244 |
||
245 |
lemma bij_is_surj: "bij f ==> surj f" |
|
246 |
by (simp add: bij_def) |
|
247 |
||
248 |
||
249 |
subsection{*Facts About the Identity Function*} |
|
5852 | 250 |
|
13585 | 251 |
text{*We seem to need both the @{term id} forms and the @{term "\<lambda>x. x"} |
252 |
forms. The latter can arise by rewriting, while @{term id} may be used |
|
253 |
explicitly.*} |
|
254 |
||
255 |
lemma image_ident [simp]: "(%x. x) ` Y = Y" |
|
256 |
by blast |
|
257 |
||
258 |
lemma image_id [simp]: "id ` Y = Y" |
|
259 |
by (simp add: id_def) |
|
260 |
||
261 |
lemma vimage_ident [simp]: "(%x. x) -` Y = Y" |
|
262 |
by blast |
|
263 |
||
264 |
lemma vimage_id [simp]: "id -` A = A" |
|
265 |
by (simp add: id_def) |
|
266 |
||
267 |
lemma vimage_image_eq: "f -` (f ` A) = {y. EX x:A. f x = f y}" |
|
268 |
by (blast intro: sym) |
|
269 |
||
270 |
lemma image_vimage_subset: "f ` (f -` A) <= A" |
|
271 |
by blast |
|
272 |
||
273 |
lemma image_vimage_eq [simp]: "f ` (f -` A) = A Int range f" |
|
274 |
by blast |
|
275 |
||
276 |
lemma surj_image_vimage_eq: "surj f ==> f ` (f -` A) = A" |
|
277 |
by (simp add: surj_range) |
|
278 |
||
279 |
lemma inj_vimage_image_eq: "inj f ==> f -` (f ` A) = A" |
|
280 |
by (simp add: inj_on_def, blast) |
|
281 |
||
282 |
lemma vimage_subsetD: "surj f ==> f -` B <= A ==> B <= f ` A" |
|
283 |
apply (unfold surj_def) |
|
284 |
apply (blast intro: sym) |
|
285 |
done |
|
286 |
||
287 |
lemma vimage_subsetI: "inj f ==> B <= f ` A ==> f -` B <= A" |
|
288 |
by (unfold inj_on_def, blast) |
|
289 |
||
290 |
lemma vimage_subset_eq: "bij f ==> (f -` B <= A) = (B <= f ` A)" |
|
291 |
apply (unfold bij_def) |
|
292 |
apply (blast del: subsetI intro: vimage_subsetI vimage_subsetD) |
|
293 |
done |
|
294 |
||
295 |
lemma image_Int_subset: "f`(A Int B) <= f`A Int f`B" |
|
296 |
by blast |
|
297 |
||
298 |
lemma image_diff_subset: "f`A - f`B <= f`(A - B)" |
|
299 |
by blast |
|
5852 | 300 |
|
13585 | 301 |
lemma inj_on_image_Int: |
302 |
"[| inj_on f C; A<=C; B<=C |] ==> f`(A Int B) = f`A Int f`B" |
|
303 |
apply (simp add: inj_on_def, blast) |
|
304 |
done |
|
305 |
||
306 |
lemma inj_on_image_set_diff: |
|
307 |
"[| inj_on f C; A<=C; B<=C |] ==> f`(A-B) = f`A - f`B" |
|
308 |
apply (simp add: inj_on_def, blast) |
|
309 |
done |
|
310 |
||
311 |
lemma image_Int: "inj f ==> f`(A Int B) = f`A Int f`B" |
|
312 |
by (simp add: inj_on_def, blast) |
|
313 |
||
314 |
lemma image_set_diff: "inj f ==> f`(A-B) = f`A - f`B" |
|
315 |
by (simp add: inj_on_def, blast) |
|
316 |
||
317 |
lemma inj_image_mem_iff: "inj f ==> (f a : f`A) = (a : A)" |
|
318 |
by (blast dest: injD) |
|
319 |
||
320 |
lemma inj_image_subset_iff: "inj f ==> (f`A <= f`B) = (A<=B)" |
|
321 |
by (simp add: inj_on_def, blast) |
|
322 |
||
323 |
lemma inj_image_eq_iff: "inj f ==> (f`A = f`B) = (A = B)" |
|
324 |
by (blast dest: injD) |
|
325 |
||
326 |
lemma image_UN: "(f ` (UNION A B)) = (UN x:A.(f ` (B x)))" |
|
327 |
by blast |
|
328 |
||
329 |
(*injectivity's required. Left-to-right inclusion holds even if A is empty*) |
|
330 |
lemma image_INT: |
|
331 |
"[| inj_on f C; ALL x:A. B x <= C; j:A |] |
|
332 |
==> f ` (INTER A B) = (INT x:A. f ` B x)" |
|
333 |
apply (simp add: inj_on_def, blast) |
|
334 |
done |
|
335 |
||
336 |
(*Compare with image_INT: no use of inj_on, and if f is surjective then |
|
337 |
it doesn't matter whether A is empty*) |
|
338 |
lemma bij_image_INT: "bij f ==> f ` (INTER A B) = (INT x:A. f ` B x)" |
|
339 |
apply (simp add: bij_def) |
|
340 |
apply (simp add: inj_on_def surj_def, blast) |
|
341 |
done |
|
342 |
||
343 |
lemma surj_Compl_image_subset: "surj f ==> -(f`A) <= f`(-A)" |
|
344 |
by (auto simp add: surj_def) |
|
345 |
||
346 |
lemma inj_image_Compl_subset: "inj f ==> f`(-A) <= -(f`A)" |
|
347 |
by (auto simp add: inj_on_def) |
|
5852 | 348 |
|
13585 | 349 |
lemma bij_image_Compl_eq: "bij f ==> f`(-A) = -(f`A)" |
350 |
apply (simp add: bij_def) |
|
351 |
apply (rule equalityI) |
|
352 |
apply (simp_all (no_asm_simp) add: inj_image_Compl_subset surj_Compl_image_subset) |
|
353 |
done |
|
354 |
||
355 |
||
356 |
subsection{*Function Updating*} |
|
357 |
||
358 |
lemma fun_upd_idem_iff: "(f(x:=y) = f) = (f x = y)" |
|
359 |
apply (simp add: fun_upd_def, safe) |
|
360 |
apply (erule subst) |
|
361 |
apply (rule_tac [2] ext, auto) |
|
362 |
done |
|
363 |
||
364 |
(* f x = y ==> f(x:=y) = f *) |
|
365 |
lemmas fun_upd_idem = fun_upd_idem_iff [THEN iffD2, standard] |
|
366 |
||
367 |
(* f(x := f x) = f *) |
|
368 |
declare refl [THEN fun_upd_idem, iff] |
|
369 |
||
370 |
lemma fun_upd_apply [simp]: "(f(x:=y))z = (if z=x then y else f z)" |
|
371 |
apply (simp (no_asm) add: fun_upd_def) |
|
372 |
done |
|
373 |
||
374 |
(* fun_upd_apply supersedes these two, but they are useful |
|
375 |
if fun_upd_apply is intentionally removed from the simpset *) |
|
376 |
lemma fun_upd_same: "(f(x:=y)) x = y" |
|
377 |
by simp |
|
378 |
||
379 |
lemma fun_upd_other: "z~=x ==> (f(x:=y)) z = f z" |
|
380 |
by simp |
|
381 |
||
382 |
lemma fun_upd_upd [simp]: "f(x:=y,x:=z) = f(x:=z)" |
|
383 |
by (simp add: expand_fun_eq) |
|
384 |
||
385 |
lemma fun_upd_twist: "a ~= c ==> (m(a:=b))(c:=d) = (m(c:=d))(a:=b)" |
|
386 |
by (rule ext, auto) |
|
387 |
||
15303 | 388 |
lemma inj_on_fun_updI: "\<lbrakk> inj_on f A; y \<notin> f`A \<rbrakk> \<Longrightarrow> inj_on (f(x:=y)) A" |
389 |
by(fastsimp simp:inj_on_def image_def) |
|
390 |
||
15510 | 391 |
lemma fun_upd_image: |
392 |
"f(x:=y) ` A = (if x \<in> A then insert y (f ` (A-{x})) else f ` A)" |
|
393 |
by auto |
|
394 |
||
13910 | 395 |
subsection{* overwrite *} |
396 |
||
397 |
lemma overwrite_emptyset[simp]: "f(g|{}) = f" |
|
398 |
by(simp add:overwrite_def) |
|
399 |
||
400 |
lemma overwrite_apply_notin[simp]: "a ~: A ==> (f(g|A)) a = f a" |
|
401 |
by(simp add:overwrite_def) |
|
402 |
||
403 |
lemma overwrite_apply_in[simp]: "a : A ==> (f(g|A)) a = g a" |
|
404 |
by(simp add:overwrite_def) |
|
405 |
||
15510 | 406 |
subsection{* swap *} |
407 |
||
408 |
constdefs |
|
409 |
swap :: "['a, 'a, 'a => 'b] => ('a => 'b)" |
|
410 |
"swap a b f == f(a := f b, b:= f a)" |
|
411 |
||
412 |
lemma swap_self: "swap a a f = f" |
|
413 |
by (simp add: swap_def) |
|
414 |
||
415 |
lemma swap_commute: "swap a b f = swap b a f" |
|
416 |
by (rule ext, simp add: fun_upd_def swap_def) |
|
417 |
||
418 |
lemma swap_nilpotent [simp]: "swap a b (swap a b f) = f" |
|
419 |
by (rule ext, simp add: fun_upd_def swap_def) |
|
420 |
||
421 |
lemma inj_on_imp_inj_on_swap: |
|
422 |
"[|inj_on f A; a \<in> A; b \<in> A|] ==> inj_on (swap a b f) A" |
|
423 |
by (simp add: inj_on_def swap_def, blast) |
|
424 |
||
425 |
lemma inj_on_swap_iff [simp]: |
|
426 |
assumes A: "a \<in> A" "b \<in> A" shows "inj_on (swap a b f) A = inj_on f A" |
|
427 |
proof |
|
428 |
assume "inj_on (swap a b f) A" |
|
429 |
with A have "inj_on (swap a b (swap a b f)) A" |
|
430 |
by (rules intro: inj_on_imp_inj_on_swap) |
|
431 |
thus "inj_on f A" by simp |
|
432 |
next |
|
433 |
assume "inj_on f A" |
|
434 |
with A show "inj_on (swap a b f) A" by (rules intro: inj_on_imp_inj_on_swap) |
|
435 |
qed |
|
436 |
||
437 |
lemma surj_imp_surj_swap: "surj f ==> surj (swap a b f)" |
|
438 |
apply (simp add: surj_def swap_def, clarify) |
|
439 |
apply (rule_tac P = "y = f b" in case_split_thm, blast) |
|
440 |
apply (rule_tac P = "y = f a" in case_split_thm, auto) |
|
441 |
--{*We don't yet have @{text case_tac}*} |
|
442 |
done |
|
443 |
||
444 |
lemma surj_swap_iff [simp]: "surj (swap a b f) = surj f" |
|
445 |
proof |
|
446 |
assume "surj (swap a b f)" |
|
447 |
hence "surj (swap a b (swap a b f))" by (rule surj_imp_surj_swap) |
|
448 |
thus "surj f" by simp |
|
449 |
next |
|
450 |
assume "surj f" |
|
451 |
thus "surj (swap a b f)" by (rule surj_imp_surj_swap) |
|
452 |
qed |
|
453 |
||
454 |
lemma bij_swap_iff: "bij (swap a b f) = bij f" |
|
455 |
by (simp add: bij_def) |
|
456 |
||
457 |
||
13585 | 458 |
text{*The ML section includes some compatibility bindings and a simproc |
459 |
for function updates, in addition to the usual ML-bindings of theorems.*} |
|
460 |
ML |
|
461 |
{* |
|
462 |
val id_def = thm "id_def"; |
|
463 |
val inj_on_def = thm "inj_on_def"; |
|
464 |
val surj_def = thm "surj_def"; |
|
465 |
val bij_def = thm "bij_def"; |
|
466 |
val fun_upd_def = thm "fun_upd_def"; |
|
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
11123
diff
changeset
|
467 |
|
13585 | 468 |
val o_def = thm "comp_def"; |
469 |
val injI = thm "inj_onI"; |
|
470 |
val inj_inverseI = thm "inj_on_inverseI"; |
|
471 |
val set_cs = claset() delrules [equalityI]; |
|
472 |
||
473 |
val print_translation = [("Pi", dependent_tr' ("@Pi", "op funcset"))]; |
|
474 |
||
475 |
(* simplifies terms of the form f(...,x:=y,...,x:=z,...) to f(...,x:=z,...) *) |
|
476 |
local |
|
477 |
fun gen_fun_upd None T _ _ = None |
|
478 |
| gen_fun_upd (Some f) T x y = Some (Const ("Fun.fun_upd",T) $ f $ x $ y) |
|
479 |
fun dest_fun_T1 (Type (_, T :: Ts)) = T |
|
480 |
fun find_double (t as Const ("Fun.fun_upd",T) $ f $ x $ y) = |
|
481 |
let |
|
482 |
fun find (Const ("Fun.fun_upd",T) $ g $ v $ w) = |
|
483 |
if v aconv x then Some g else gen_fun_upd (find g) T v w |
|
484 |
| find t = None |
|
485 |
in (dest_fun_T1 T, gen_fun_upd (find f) T x y) end |
|
486 |
||
487 |
val ss = simpset () |
|
488 |
val fun_upd_prover = K (rtac eq_reflection 1 THEN rtac ext 1 THEN simp_tac ss 1) |
|
489 |
in |
|
490 |
val fun_upd2_simproc = |
|
491 |
Simplifier.simproc (Theory.sign_of (the_context ())) |
|
492 |
"fun_upd2" ["f(v := w, x := y)"] |
|
493 |
(fn sg => fn _ => fn t => |
|
494 |
case find_double t of (T, None) => None |
|
495 |
| (T, Some rhs) => Some (Tactic.prove sg [] [] (Term.equals T $ t $ rhs) fun_upd_prover)) |
|
496 |
end; |
|
497 |
Addsimprocs[fun_upd2_simproc]; |
|
5852 | 498 |
|
13585 | 499 |
val expand_fun_eq = thm "expand_fun_eq"; |
500 |
val apply_inverse = thm "apply_inverse"; |
|
501 |
val id_apply = thm "id_apply"; |
|
502 |
val o_apply = thm "o_apply"; |
|
503 |
val o_assoc = thm "o_assoc"; |
|
504 |
val id_o = thm "id_o"; |
|
505 |
val o_id = thm "o_id"; |
|
506 |
val image_compose = thm "image_compose"; |
|
507 |
val image_eq_UN = thm "image_eq_UN"; |
|
508 |
val UN_o = thm "UN_o"; |
|
509 |
val datatype_injI = thm "datatype_injI"; |
|
510 |
val injD = thm "injD"; |
|
511 |
val inj_eq = thm "inj_eq"; |
|
512 |
val inj_onI = thm "inj_onI"; |
|
513 |
val inj_on_inverseI = thm "inj_on_inverseI"; |
|
514 |
val inj_onD = thm "inj_onD"; |
|
515 |
val inj_on_iff = thm "inj_on_iff"; |
|
516 |
val comp_inj_on = thm "comp_inj_on"; |
|
517 |
val inj_on_contraD = thm "inj_on_contraD"; |
|
518 |
val inj_singleton = thm "inj_singleton"; |
|
519 |
val subset_inj_on = thm "subset_inj_on"; |
|
520 |
val surjI = thm "surjI"; |
|
521 |
val surj_range = thm "surj_range"; |
|
522 |
val surjD = thm "surjD"; |
|
523 |
val surjE = thm "surjE"; |
|
524 |
val comp_surj = thm "comp_surj"; |
|
525 |
val bijI = thm "bijI"; |
|
526 |
val bij_is_inj = thm "bij_is_inj"; |
|
527 |
val bij_is_surj = thm "bij_is_surj"; |
|
528 |
val image_ident = thm "image_ident"; |
|
529 |
val image_id = thm "image_id"; |
|
530 |
val vimage_ident = thm "vimage_ident"; |
|
531 |
val vimage_id = thm "vimage_id"; |
|
532 |
val vimage_image_eq = thm "vimage_image_eq"; |
|
533 |
val image_vimage_subset = thm "image_vimage_subset"; |
|
534 |
val image_vimage_eq = thm "image_vimage_eq"; |
|
535 |
val surj_image_vimage_eq = thm "surj_image_vimage_eq"; |
|
536 |
val inj_vimage_image_eq = thm "inj_vimage_image_eq"; |
|
537 |
val vimage_subsetD = thm "vimage_subsetD"; |
|
538 |
val vimage_subsetI = thm "vimage_subsetI"; |
|
539 |
val vimage_subset_eq = thm "vimage_subset_eq"; |
|
540 |
val image_Int_subset = thm "image_Int_subset"; |
|
541 |
val image_diff_subset = thm "image_diff_subset"; |
|
542 |
val inj_on_image_Int = thm "inj_on_image_Int"; |
|
543 |
val inj_on_image_set_diff = thm "inj_on_image_set_diff"; |
|
544 |
val image_Int = thm "image_Int"; |
|
545 |
val image_set_diff = thm "image_set_diff"; |
|
546 |
val inj_image_mem_iff = thm "inj_image_mem_iff"; |
|
547 |
val inj_image_subset_iff = thm "inj_image_subset_iff"; |
|
548 |
val inj_image_eq_iff = thm "inj_image_eq_iff"; |
|
549 |
val image_UN = thm "image_UN"; |
|
550 |
val image_INT = thm "image_INT"; |
|
551 |
val bij_image_INT = thm "bij_image_INT"; |
|
552 |
val surj_Compl_image_subset = thm "surj_Compl_image_subset"; |
|
553 |
val inj_image_Compl_subset = thm "inj_image_Compl_subset"; |
|
554 |
val bij_image_Compl_eq = thm "bij_image_Compl_eq"; |
|
555 |
val fun_upd_idem_iff = thm "fun_upd_idem_iff"; |
|
556 |
val fun_upd_idem = thm "fun_upd_idem"; |
|
557 |
val fun_upd_apply = thm "fun_upd_apply"; |
|
558 |
val fun_upd_same = thm "fun_upd_same"; |
|
559 |
val fun_upd_other = thm "fun_upd_other"; |
|
560 |
val fun_upd_upd = thm "fun_upd_upd"; |
|
561 |
val fun_upd_twist = thm "fun_upd_twist"; |
|
13637 | 562 |
val range_ex1_eq = thm "range_ex1_eq"; |
13585 | 563 |
*} |
5852 | 564 |
|
2912 | 565 |
end |