3 Author: Tobias Nipkow, Cambridge University Computer Laboratory
4 Copyright 1993 University of Cambridge
6 Lemmas about functions.
10 goal thy "(f = g) = (!x. f(x)=g(x))";
13 by (rtac ext 1 THEN Asm_simp_tac 1);
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));
23 (** "Axiom" of Choice, proved using the description operator **)
25 goal HOL.thy "!!Q. ALL x. EX y. Q x y ==> EX f. ALL x. Q x (f x)";
26 by (fast_tac (claset() addEs [selectI]) 1);
29 goal Set.thy "!!S. ALL x:S. EX y. Q x y ==> EX f. ALL x:S. Q x (f x)";
30 by (fast_tac (claset() addEs [selectI]) 1);
34 (*** inj(f): f is a one-to-one function ***)
36 val prems = goalw thy [inj_def]
37 "[| !! x y. f(x) = f(y) ==> x=y |] ==> inj(f)";
38 by (blast_tac (claset() addIs prems) 1);
41 val [major] = goal thy "(!!x. g(f(x)) = x) ==> inj(f)";
43 by (etac (arg_cong RS box_equals) 1);
48 val [major,minor] = goalw thy [inj_def]
49 "[| inj(f); f(x) = f(y) |] ==> x=y";
50 by (rtac (major RS spec RS spec RS mp) 1);
54 (*Useful with the simplifier*)
55 val [major] = goal thy "inj(f) ==> (f(x) = f(y)) = (x=y)";
57 by (etac (major RS injD) 1);
61 val [major] = goal thy "inj(f) ==> (@x. f(x)=f(y)) = y";
62 by (rtac (major RS injD) 1);
67 (*A one-to-one function has an inverse (given using select).*)
68 val [major] = goalw thy [inv_def] "inj(f) ==> inv f (f x) = x";
69 by (EVERY1 [rtac (major RS inj_select)]);
73 val [oneone,minor] = goal thy
74 "[| inj(f); !!y. y: range(f) ==> P(inv f y) |] ==> P(x)";
75 by (res_inst_tac [("t", "x")] (oneone RS (inv_f_f RS subst)) 1);
76 by (rtac (rangeI RS minor) 1);
80 (*** inj_onto f A: f is one-to-one over A ***)
82 val prems = goalw thy [inj_onto_def]
83 "(!! x y. [| f(x) = f(y); x:A; y:A |] ==> x=y) ==> inj_onto f A";
84 by (blast_tac (claset() addIs prems) 1);
87 val [major] = goal thy
88 "(!!x. x:A ==> g(f(x)) = x) ==> inj_onto f A";
89 by (rtac inj_ontoI 1);
90 by (etac (apply_inverse RS trans) 1);
91 by (REPEAT (eresolve_tac [asm_rl,major] 1));
92 qed "inj_onto_inverseI";
94 val major::prems = goalw thy [inj_onto_def]
95 "[| inj_onto f A; f(x)=f(y); x:A; y:A |] ==> x=y";
96 by (rtac (major RS bspec RS bspec RS mp) 1);
97 by (REPEAT (resolve_tac prems 1));
100 goal thy "!!x y.[| inj_onto f A; x:A; y:A |] ==> (f(x)=f(y)) = (x=y)";
101 by (blast_tac (claset() addSDs [inj_ontoD]) 1);
104 val major::prems = goal thy
105 "[| inj_onto f A; ~x=y; x:A; y:A |] ==> ~ f(x)=f(y)";
106 by (rtac contrapos 1);
107 by (etac (major RS inj_ontoD) 2);
108 by (REPEAT (resolve_tac prems 1));
109 qed "inj_onto_contraD";
111 goalw thy [inj_onto_def]
112 "!!A B. [| A<=B; inj_onto f B |] ==> inj_onto f A";
114 qed "subset_inj_onto";
117 (*** Lemmas about inj ***)
120 "!!f g. [| inj(f); inj_onto g (range f) |] ==> inj(g o f)";
121 by (fast_tac (claset() addIs [injI] addEs [injD, inj_ontoD]) 1);
124 val [prem] = goal thy "inj(f) ==> inj_onto f A";
125 by (blast_tac (claset() addIs [prem RS injD, inj_ontoI]) 1);
128 val [prem] = goalw thy [inv_def] "y : range(f) ==> f(inv f y) = y";
129 by (EVERY1 [rtac (prem RS rangeE), rtac selectI, etac sym]);
133 "[| inv f x=inv f y; x: range(f); y: range(f) |] ==> x=y";
134 by (rtac (arg_cong RS box_equals) 1);
135 by (REPEAT (resolve_tac (prems @ [f_inv_f]) 1));
138 goal thy "!!f. [| inj(f); A<=range(f) |] ==> inj_onto (inv f) A";
139 by (fast_tac (claset() addIs [inj_ontoI]
140 addEs [inv_injective,injD]) 1);
143 goalw thy [inj_onto_def]
144 "!!f. [| inj_onto f C; A<=C; B<=C |] ==> f``(A Int B) = f``A Int f``B";
146 qed "inj_onto_image_Int";
148 goalw thy [inj_onto_def]
149 "!!f. [| inj_onto f C; A<=C; B<=C |] ==> f``(A-B) = f``A - f``B";
151 qed "inj_onto_image_set_diff";
153 goalw thy [inj_def] "!!f. inj f ==> f``(A Int B) = f``A Int f``B";
157 goalw thy [inj_def] "!!f. inj f ==> f``(A-B) = f``A - f``B";
159 qed "image_set_diff";
162 val set_cs = claset() delrules [equalityI];