| author | wenzelm |
| Sun, 31 Jul 2016 17:25:38 +0200 | |
| changeset 63569 | 7e0b0db5e9ac |
| parent 63561 | fba08009ff3e |
| child 63575 | b9bd9e61fd63 |
| permissions | -rw-r--r-- |
| 1475 | 1 |
(* Title: HOL/Fun.thy |
2 |
Author: Tobias Nipkow, Cambridge University Computer Laboratory |
|
|
55019
0d5e831175de
moved lemmas from 'Fun_More_FP' to where they belong
blanchet
parents:
54578
diff
changeset
|
3 |
Author: Andrei Popescu, TU Muenchen |
|
0d5e831175de
moved lemmas from 'Fun_More_FP' to where they belong
blanchet
parents:
54578
diff
changeset
|
4 |
Copyright 1994, 2012 |
| 18154 | 5 |
*) |
| 923 | 6 |
|
| 60758 | 7 |
section \<open>Notions about functions\<close> |
| 923 | 8 |
|
| 15510 | 9 |
theory Fun |
|
56015
57e2cfba9c6e
bootstrap fundamental Fun theory immediately after Set theory, without dependency on complete lattices
haftmann
parents:
55990
diff
changeset
|
10 |
imports Set |
|
55467
a5c9002bc54d
renamed 'enriched_type' to more informative 'functor' (following the renaming of enriched type constructors to bounded natural functors)
blanchet
parents:
55414
diff
changeset
|
11 |
keywords "functor" :: thy_goal |
| 15131 | 12 |
begin |
| 2912 | 13 |
|
| 63322 | 14 |
lemma apply_inverse: "f x = u \<Longrightarrow> (\<And>x. P x \<Longrightarrow> g (f x) = x) \<Longrightarrow> P x \<Longrightarrow> x = g u" |
| 26147 | 15 |
by auto |
| 2912 | 16 |
|
| 63322 | 17 |
text \<open>Uniqueness, so NOT the axiom of choice.\<close> |
|
59504
8c6747dba731
New lemmas and a bit of tidying up.
paulson <lp15@cam.ac.uk>
parents:
58889
diff
changeset
|
18 |
lemma uniq_choice: "\<forall>x. \<exists>!y. Q x y \<Longrightarrow> \<exists>f. \<forall>x. Q x (f x)" |
|
8c6747dba731
New lemmas and a bit of tidying up.
paulson <lp15@cam.ac.uk>
parents:
58889
diff
changeset
|
19 |
by (force intro: theI') |
|
8c6747dba731
New lemmas and a bit of tidying up.
paulson <lp15@cam.ac.uk>
parents:
58889
diff
changeset
|
20 |
|
|
8c6747dba731
New lemmas and a bit of tidying up.
paulson <lp15@cam.ac.uk>
parents:
58889
diff
changeset
|
21 |
lemma b_uniq_choice: "\<forall>x\<in>S. \<exists>!y. Q x y \<Longrightarrow> \<exists>f. \<forall>x\<in>S. Q x (f x)" |
|
8c6747dba731
New lemmas and a bit of tidying up.
paulson <lp15@cam.ac.uk>
parents:
58889
diff
changeset
|
22 |
by (force intro: theI') |
| 12258 | 23 |
|
| 63400 | 24 |
|
| 61799 | 25 |
subsection \<open>The Identity Function \<open>id\<close>\<close> |
| 6171 | 26 |
|
| 63322 | 27 |
definition id :: "'a \<Rightarrow> 'a" |
28 |
where "id = (\<lambda>x. x)" |
|
| 13910 | 29 |
|
| 26147 | 30 |
lemma id_apply [simp]: "id x = x" |
31 |
by (simp add: id_def) |
|
32 |
||
| 47579 | 33 |
lemma image_id [simp]: "image id = id" |
34 |
by (simp add: id_def fun_eq_iff) |
|
| 26147 | 35 |
|
| 47579 | 36 |
lemma vimage_id [simp]: "vimage id = id" |
37 |
by (simp add: id_def fun_eq_iff) |
|
| 26147 | 38 |
|
|
62843
313d3b697c9a
Mostly renaming (from HOL Light to Isabelle conventions), with a couple of new results
paulson <lp15@cam.ac.uk>
parents:
62618
diff
changeset
|
39 |
lemma eq_id_iff: "(\<forall>x. f x = x) \<longleftrightarrow> f = id" |
|
313d3b697c9a
Mostly renaming (from HOL Light to Isabelle conventions), with a couple of new results
paulson <lp15@cam.ac.uk>
parents:
62618
diff
changeset
|
40 |
by auto |
|
313d3b697c9a
Mostly renaming (from HOL Light to Isabelle conventions), with a couple of new results
paulson <lp15@cam.ac.uk>
parents:
62618
diff
changeset
|
41 |
|
|
52435
6646bb548c6b
migration from code_(const|type|class|instance) to code_printing and from code_module to code_identifier
haftmann
parents:
51717
diff
changeset
|
42 |
code_printing |
|
6646bb548c6b
migration from code_(const|type|class|instance) to code_printing and from code_module to code_identifier
haftmann
parents:
51717
diff
changeset
|
43 |
constant id \<rightharpoonup> (Haskell) "id" |
|
6646bb548c6b
migration from code_(const|type|class|instance) to code_printing and from code_module to code_identifier
haftmann
parents:
51717
diff
changeset
|
44 |
|
| 26147 | 45 |
|
| 61799 | 46 |
subsection \<open>The Composition Operator \<open>f \<circ> g\<close>\<close> |
| 26147 | 47 |
|
|
61955
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
wenzelm
parents:
61799
diff
changeset
|
48 |
definition comp :: "('b \<Rightarrow> 'c) \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'a \<Rightarrow> 'c" (infixl "\<circ>" 55)
|
|
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
wenzelm
parents:
61799
diff
changeset
|
49 |
where "f \<circ> g = (\<lambda>x. f (g x))" |
| 11123 | 50 |
|
|
61955
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
wenzelm
parents:
61799
diff
changeset
|
51 |
notation (ASCII) |
|
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
wenzelm
parents:
61799
diff
changeset
|
52 |
comp (infixl "o" 55) |
|
19656
09be06943252
tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents:
19536
diff
changeset
|
53 |
|
| 63322 | 54 |
lemma comp_apply [simp]: "(f \<circ> g) x = f (g x)" |
| 49739 | 55 |
by (simp add: comp_def) |
| 13585 | 56 |
|
| 63322 | 57 |
lemma comp_assoc: "(f \<circ> g) \<circ> h = f \<circ> (g \<circ> h)" |
| 49739 | 58 |
by (simp add: fun_eq_iff) |
| 13585 | 59 |
|
| 63322 | 60 |
lemma id_comp [simp]: "id \<circ> g = g" |
| 49739 | 61 |
by (simp add: fun_eq_iff) |
| 13585 | 62 |
|
| 63322 | 63 |
lemma comp_id [simp]: "f \<circ> id = f" |
| 49739 | 64 |
by (simp add: fun_eq_iff) |
65 |
||
66 |
lemma comp_eq_dest: |
|
| 63322 | 67 |
"a \<circ> b = c \<circ> d \<Longrightarrow> a (b v) = c (d v)" |
| 49739 | 68 |
by (simp add: fun_eq_iff) |
| 34150 | 69 |
|
| 49739 | 70 |
lemma comp_eq_elim: |
| 63322 | 71 |
"a \<circ> b = c \<circ> d \<Longrightarrow> ((\<And>v. a (b v) = c (d v)) \<Longrightarrow> R) \<Longrightarrow> R" |
| 61204 | 72 |
by (simp add: fun_eq_iff) |
| 34150 | 73 |
|
| 63322 | 74 |
lemma comp_eq_dest_lhs: "a \<circ> b = c \<Longrightarrow> a (b v) = c v" |
| 55066 | 75 |
by clarsimp |
76 |
||
| 63322 | 77 |
lemma comp_eq_id_dest: "a \<circ> b = id \<circ> c \<Longrightarrow> a (b v) = c v" |
78 |
by clarsimp |
|
79 |
||
80 |
lemma image_comp: "f ` (g ` r) = (f \<circ> g) ` r" |
|
| 33044 | 81 |
by auto |
82 |
||
| 63322 | 83 |
lemma vimage_comp: "f -` (g -` x) = (g \<circ> f) -` x" |
| 49739 | 84 |
by auto |
85 |
||
| 63322 | 86 |
lemma image_eq_imp_comp: "f ` A = g ` B \<Longrightarrow> (h \<circ> f) ` A = (h \<circ> g) ` B" |
|
59504
8c6747dba731
New lemmas and a bit of tidying up.
paulson <lp15@cam.ac.uk>
parents:
58889
diff
changeset
|
87 |
by (auto simp: comp_def elim!: equalityE) |
|
8c6747dba731
New lemmas and a bit of tidying up.
paulson <lp15@cam.ac.uk>
parents:
58889
diff
changeset
|
88 |
|
| 59512 | 89 |
lemma image_bind: "f ` (Set.bind A g) = Set.bind A (op ` f \<circ> g)" |
| 63322 | 90 |
by (auto simp add: Set.bind_def) |
| 59512 | 91 |
|
92 |
lemma bind_image: "Set.bind (f ` A) g = Set.bind A (g \<circ> f)" |
|
| 63322 | 93 |
by (auto simp add: Set.bind_def) |
| 59512 | 94 |
|
| 63322 | 95 |
lemma (in group_add) minus_comp_minus [simp]: "uminus \<circ> uminus = id" |
| 60929 | 96 |
by (simp add: fun_eq_iff) |
97 |
||
| 63322 | 98 |
lemma (in boolean_algebra) minus_comp_minus [simp]: "uminus \<circ> uminus = id" |
| 60929 | 99 |
by (simp add: fun_eq_iff) |
100 |
||
|
52435
6646bb548c6b
migration from code_(const|type|class|instance) to code_printing and from code_module to code_identifier
haftmann
parents:
51717
diff
changeset
|
101 |
code_printing |
|
6646bb548c6b
migration from code_(const|type|class|instance) to code_printing and from code_module to code_identifier
haftmann
parents:
51717
diff
changeset
|
102 |
constant comp \<rightharpoonup> (SML) infixl 5 "o" and (Haskell) infixr 9 "." |
|
6646bb548c6b
migration from code_(const|type|class|instance) to code_printing and from code_module to code_identifier
haftmann
parents:
51717
diff
changeset
|
103 |
|
| 13585 | 104 |
|
| 61799 | 105 |
subsection \<open>The Forward Composition Operator \<open>fcomp\<close>\<close> |
| 26357 | 106 |
|
| 63322 | 107 |
definition fcomp :: "('a \<Rightarrow> 'b) \<Rightarrow> ('b \<Rightarrow> 'c) \<Rightarrow> 'a \<Rightarrow> 'c" (infixl "\<circ>>" 60)
|
108 |
where "f \<circ>> g = (\<lambda>x. g (f x))" |
|
| 26357 | 109 |
|
| 37751 | 110 |
lemma fcomp_apply [simp]: "(f \<circ>> g) x = g (f x)" |
| 26357 | 111 |
by (simp add: fcomp_def) |
112 |
||
| 37751 | 113 |
lemma fcomp_assoc: "(f \<circ>> g) \<circ>> h = f \<circ>> (g \<circ>> h)" |
| 26357 | 114 |
by (simp add: fcomp_def) |
115 |
||
| 37751 | 116 |
lemma id_fcomp [simp]: "id \<circ>> g = g" |
| 26357 | 117 |
by (simp add: fcomp_def) |
118 |
||
| 37751 | 119 |
lemma fcomp_id [simp]: "f \<circ>> id = f" |
| 26357 | 120 |
by (simp add: fcomp_def) |
121 |
||
| 63322 | 122 |
lemma fcomp_comp: "fcomp f g = comp g f" |
|
61699
a81dc5c4d6a9
New theorems mostly from Peter Gammie
paulson <lp15@cam.ac.uk>
parents:
61630
diff
changeset
|
123 |
by (simp add: ext) |
|
a81dc5c4d6a9
New theorems mostly from Peter Gammie
paulson <lp15@cam.ac.uk>
parents:
61630
diff
changeset
|
124 |
|
|
52435
6646bb548c6b
migration from code_(const|type|class|instance) to code_printing and from code_module to code_identifier
haftmann
parents:
51717
diff
changeset
|
125 |
code_printing |
|
6646bb548c6b
migration from code_(const|type|class|instance) to code_printing and from code_module to code_identifier
haftmann
parents:
51717
diff
changeset
|
126 |
constant fcomp \<rightharpoonup> (Eval) infixl 1 "#>" |
|
31202
52d332f8f909
pretty printing of functional combinators for evaluation code
haftmann
parents:
31080
diff
changeset
|
127 |
|
| 37751 | 128 |
no_notation fcomp (infixl "\<circ>>" 60) |
|
26588
d83271bfaba5
removed syntax from monad combinators; renamed mbind to scomp
haftmann
parents:
26357
diff
changeset
|
129 |
|
| 26357 | 130 |
|
| 60758 | 131 |
subsection \<open>Mapping functions\<close> |
| 40602 | 132 |
|
| 63322 | 133 |
definition map_fun :: "('c \<Rightarrow> 'a) \<Rightarrow> ('b \<Rightarrow> 'd) \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'c \<Rightarrow> 'd"
|
134 |
where "map_fun f g h = g \<circ> h \<circ> f" |
|
| 40602 | 135 |
|
| 63322 | 136 |
lemma map_fun_apply [simp]: "map_fun f g h x = g (h (f x))" |
| 40602 | 137 |
by (simp add: map_fun_def) |
138 |
||
139 |
||
| 60758 | 140 |
subsection \<open>Injectivity and Bijectivity\<close> |
|
39076
b3a9b6734663
Introduce surj_on and replace surj and bij by abbreviations.
hoelzl
parents:
39075
diff
changeset
|
141 |
|
| 63322 | 142 |
definition inj_on :: "('a \<Rightarrow> 'b) \<Rightarrow> 'a set \<Rightarrow> bool" \<comment> \<open>injective\<close>
|
143 |
where "inj_on f A \<longleftrightarrow> (\<forall>x\<in>A. \<forall>y\<in>A. f x = f y \<longrightarrow> x = y)" |
|
| 26147 | 144 |
|
| 63322 | 145 |
definition bij_betw :: "('a \<Rightarrow> 'b) \<Rightarrow> 'a set \<Rightarrow> 'b set \<Rightarrow> bool" \<comment> \<open>bijective\<close>
|
146 |
where "bij_betw f A B \<longleftrightarrow> inj_on f A \<and> f ` A = B" |
|
| 26147 | 147 |
|
| 63322 | 148 |
text \<open>A common special case: functions injective, surjective or bijective over |
149 |
the entire domain type.\<close> |
|
| 26147 | 150 |
|
| 63322 | 151 |
abbreviation "inj f \<equiv> inj_on f UNIV" |
| 26147 | 152 |
|
|
63416
6af79184bef3
avoid to hide equality behind (output) abbreviation
haftmann
parents:
63400
diff
changeset
|
153 |
abbreviation (input) surj :: "('a \<Rightarrow> 'b) \<Rightarrow> bool"
|
| 63322 | 154 |
where "surj f \<equiv> range f = UNIV" |
| 13585 | 155 |
|
| 63322 | 156 |
abbreviation "bij f \<equiv> bij_betw f UNIV UNIV" |
| 26147 | 157 |
|
| 63322 | 158 |
lemma injI: "(\<And>x y. f x = f y \<Longrightarrow> x = y) \<Longrightarrow> inj f" |
159 |
unfolding inj_on_def by auto |
|
| 13585 | 160 |
|
| 63322 | 161 |
theorem range_ex1_eq: "inj f \<Longrightarrow> b \<in> range f \<longleftrightarrow> (\<exists>!x. b = f x)" |
| 56077 | 162 |
unfolding inj_on_def by blast |
|
40703
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
163 |
|
| 63322 | 164 |
lemma injD: "inj f \<Longrightarrow> f x = f y \<Longrightarrow> x = y" |
165 |
by (simp add: inj_on_def) |
|
166 |
||
167 |
lemma inj_on_eq_iff: "inj_on f A \<Longrightarrow> x \<in> A \<Longrightarrow> y \<in> A \<Longrightarrow> f x = f y \<longleftrightarrow> x = y" |
|
168 |
by (force simp add: inj_on_def) |
|
169 |
||
170 |
lemma inj_on_cong: "(\<And>a. a \<in> A \<Longrightarrow> f a = g a) \<Longrightarrow> inj_on f A = inj_on g A" |
|
171 |
unfolding inj_on_def by auto |
|
172 |
||
173 |
lemma inj_on_strict_subset: "inj_on f B \<Longrightarrow> A \<subset> B \<Longrightarrow> f ` A \<subset> f ` B" |
|
174 |
unfolding inj_on_def by blast |
|
175 |
||
176 |
lemma inj_comp: "inj f \<Longrightarrow> inj g \<Longrightarrow> inj (f \<circ> g)" |
|
| 38620 | 177 |
by (simp add: inj_on_def) |
178 |
||
179 |
lemma inj_fun: "inj f \<Longrightarrow> inj (\<lambda>x y. f x)" |
|
|
39302
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents:
39213
diff
changeset
|
180 |
by (simp add: inj_on_def fun_eq_iff) |
| 38620 | 181 |
|
| 63322 | 182 |
lemma inj_eq: "inj f \<Longrightarrow> f x = f y \<longleftrightarrow> x = y" |
183 |
by (simp add: inj_on_eq_iff) |
|
| 32988 | 184 |
|
| 26147 | 185 |
lemma inj_on_id[simp]: "inj_on id A" |
|
39076
b3a9b6734663
Introduce surj_on and replace surj and bij by abbreviations.
hoelzl
parents:
39075
diff
changeset
|
186 |
by (simp add: inj_on_def) |
| 13585 | 187 |
|
| 63322 | 188 |
lemma inj_on_id2[simp]: "inj_on (\<lambda>x. x) A" |
189 |
by (simp add: inj_on_def) |
|
| 26147 | 190 |
|
| 46586 | 191 |
lemma inj_on_Int: "inj_on f A \<or> inj_on f B \<Longrightarrow> inj_on f (A \<inter> B)" |
| 63322 | 192 |
unfolding inj_on_def by blast |
|
40703
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
193 |
|
| 40702 | 194 |
lemma surj_id: "surj id" |
| 63322 | 195 |
by simp |
| 26147 | 196 |
|
|
39101
606432dd1896
Revert bij_betw changes to simp set (Problem in afp/Ordinals_and_Cardinals)
hoelzl
parents:
39076
diff
changeset
|
197 |
lemma bij_id[simp]: "bij id" |
| 63322 | 198 |
by (simp add: bij_betw_def) |
| 13585 | 199 |
|
| 63322 | 200 |
lemma bij_uminus: "bij (uminus :: 'a \<Rightarrow> 'a::ab_group_add)" |
201 |
unfolding bij_betw_def inj_on_def |
|
202 |
by (force intro: minus_minus [symmetric]) |
|
| 63072 | 203 |
|
| 63322 | 204 |
lemma inj_onI [intro?]: "(\<And>x y. x \<in> A \<Longrightarrow> y \<in> A \<Longrightarrow> f x = f y \<Longrightarrow> x = y) \<Longrightarrow> inj_on f A" |
205 |
by (simp add: inj_on_def) |
|
| 13585 | 206 |
|
| 63322 | 207 |
lemma inj_on_inverseI: "(\<And>x. x \<in> A \<Longrightarrow> g (f x) = x) \<Longrightarrow> inj_on f A" |
208 |
by (auto dest: arg_cong [of concl: g] simp add: inj_on_def) |
|
| 13585 | 209 |
|
| 63322 | 210 |
lemma inj_onD: "inj_on f A \<Longrightarrow> f x = f y \<Longrightarrow> x \<in> A \<Longrightarrow> y \<in> A \<Longrightarrow> x = y" |
211 |
unfolding inj_on_def by blast |
|
| 13585 | 212 |
|
| 63365 | 213 |
lemma inj_on_subset: |
214 |
assumes "inj_on f A" |
|
215 |
assumes "B \<subseteq> A" |
|
216 |
shows "inj_on f B" |
|
217 |
proof (rule inj_onI) |
|
218 |
fix a b |
|
219 |
assume "a \<in> B" and "b \<in> B" |
|
220 |
with assms have "a \<in> A" and "b \<in> A" |
|
221 |
by auto |
|
222 |
moreover assume "f a = f b" |
|
223 |
ultimately show "a = b" using assms |
|
224 |
by (auto dest: inj_onD) |
|
225 |
qed |
|
226 |
||
| 63322 | 227 |
lemma comp_inj_on: "inj_on f A \<Longrightarrow> inj_on g (f ` A) \<Longrightarrow> inj_on (g \<circ> f) A" |
228 |
by (simp add: comp_def inj_on_def) |
|
229 |
||
230 |
lemma inj_on_imageI: "inj_on (g \<circ> f) A \<Longrightarrow> inj_on g (f ` A)" |
|
| 63072 | 231 |
by (auto simp add: inj_on_def) |
| 15303 | 232 |
|
| 63322 | 233 |
lemma inj_on_image_iff: |
234 |
"\<forall>x\<in>A. \<forall>y\<in>A. g (f x) = g (f y) \<longleftrightarrow> g x = g y \<Longrightarrow> inj_on f A \<Longrightarrow> inj_on g (f ` A) = inj_on g A" |
|
235 |
unfolding inj_on_def by blast |
|
| 15439 | 236 |
|
| 63322 | 237 |
lemma inj_on_contraD: "inj_on f A \<Longrightarrow> x \<noteq> y \<Longrightarrow> x \<in> A \<Longrightarrow> y \<in> A \<Longrightarrow> f x \<noteq> f y" |
238 |
unfolding inj_on_def by blast |
|
| 12258 | 239 |
|
| 63072 | 240 |
lemma inj_singleton [simp]: "inj_on (\<lambda>x. {x}) A"
|
241 |
by (simp add: inj_on_def) |
|
| 13585 | 242 |
|
| 15111 | 243 |
lemma inj_on_empty[iff]: "inj_on f {}"
|
| 63322 | 244 |
by (simp add: inj_on_def) |
| 13585 | 245 |
|
| 63322 | 246 |
lemma subset_inj_on: "inj_on f B \<Longrightarrow> A \<subseteq> B \<Longrightarrow> inj_on f A" |
247 |
unfolding inj_on_def by blast |
|
248 |
||
249 |
lemma inj_on_Un: "inj_on f (A \<union> B) \<longleftrightarrow> inj_on f A \<and> inj_on f B \<and> f ` (A - B) \<inter> f ` (B - A) = {}"
|
|
250 |
unfolding inj_on_def by (blast intro: sym) |
|
| 15111 | 251 |
|
| 63322 | 252 |
lemma inj_on_insert [iff]: "inj_on f (insert a A) \<longleftrightarrow> inj_on f A \<and> f a \<notin> f ` (A - {a})"
|
253 |
unfolding inj_on_def by (blast intro: sym) |
|
254 |
||
255 |
lemma inj_on_diff: "inj_on f A \<Longrightarrow> inj_on f (A - B)" |
|
256 |
unfolding inj_on_def by blast |
|
| 15111 | 257 |
|
| 63322 | 258 |
lemma comp_inj_on_iff: "inj_on f A \<Longrightarrow> inj_on f' (f ` A) \<longleftrightarrow> inj_on (f' \<circ> f) A" |
259 |
by (auto simp add: comp_inj_on inj_on_def) |
|
| 15111 | 260 |
|
| 63322 | 261 |
lemma inj_on_imageI2: "inj_on (f' \<circ> f) A \<Longrightarrow> inj_on f A" |
262 |
by (auto simp add: comp_inj_on inj_on_def) |
|
|
40703
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
263 |
|
|
51598
5dbe537087aa
generalized lemma fold_image thanks to Peter Lammich
haftmann
parents:
49905
diff
changeset
|
264 |
lemma inj_img_insertE: |
|
5dbe537087aa
generalized lemma fold_image thanks to Peter Lammich
haftmann
parents:
49905
diff
changeset
|
265 |
assumes "inj_on f A" |
| 63322 | 266 |
assumes "x \<notin> B" |
267 |
and "insert x B = f ` A" |
|
268 |
obtains x' A' where "x' \<notin> A'" and "A = insert x' A'" and "x = f x'" and "B = f ` A'" |
|
|
51598
5dbe537087aa
generalized lemma fold_image thanks to Peter Lammich
haftmann
parents:
49905
diff
changeset
|
269 |
proof - |
|
5dbe537087aa
generalized lemma fold_image thanks to Peter Lammich
haftmann
parents:
49905
diff
changeset
|
270 |
from assms have "x \<in> f ` A" by auto |
|
5dbe537087aa
generalized lemma fold_image thanks to Peter Lammich
haftmann
parents:
49905
diff
changeset
|
271 |
then obtain x' where *: "x' \<in> A" "x = f x'" by auto |
| 63322 | 272 |
then have A: "A = insert x' (A - {x'})" by auto
|
273 |
with assms * have B: "B = f ` (A - {x'})" by (auto dest: inj_on_contraD)
|
|
|
51598
5dbe537087aa
generalized lemma fold_image thanks to Peter Lammich
haftmann
parents:
49905
diff
changeset
|
274 |
have "x' \<notin> A - {x'}" by simp
|
| 63322 | 275 |
from this A \<open>x = f x'\<close> B show ?thesis .. |
|
51598
5dbe537087aa
generalized lemma fold_image thanks to Peter Lammich
haftmann
parents:
49905
diff
changeset
|
276 |
qed |
|
5dbe537087aa
generalized lemma fold_image thanks to Peter Lammich
haftmann
parents:
49905
diff
changeset
|
277 |
|
|
54578
9387251b6a46
eliminated dependence of BNF on Infinite_Set by moving 3 theorems from the latter to Main
traytel
parents:
54147
diff
changeset
|
278 |
lemma linorder_injI: |
| 63322 | 279 |
assumes hyp: "\<And>x y::'a::linorder. x < y \<Longrightarrow> f x \<noteq> f y" |
|
54578
9387251b6a46
eliminated dependence of BNF on Infinite_Set by moving 3 theorems from the latter to Main
traytel
parents:
54147
diff
changeset
|
280 |
shows "inj f" |
| 61799 | 281 |
\<comment> \<open>Courtesy of Stephan Merz\<close> |
|
54578
9387251b6a46
eliminated dependence of BNF on Infinite_Set by moving 3 theorems from the latter to Main
traytel
parents:
54147
diff
changeset
|
282 |
proof (rule inj_onI) |
| 63400 | 283 |
show "x = y" if "f x = f y" for x y |
284 |
by (rule linorder_cases) (auto dest: hyp simp: that) |
|
|
54578
9387251b6a46
eliminated dependence of BNF on Infinite_Set by moving 3 theorems from the latter to Main
traytel
parents:
54147
diff
changeset
|
285 |
qed |
|
9387251b6a46
eliminated dependence of BNF on Infinite_Set by moving 3 theorems from the latter to Main
traytel
parents:
54147
diff
changeset
|
286 |
|
| 40702 | 287 |
lemma surj_def: "surj f \<longleftrightarrow> (\<forall>y. \<exists>x. y = f x)" |
288 |
by auto |
|
|
39076
b3a9b6734663
Introduce surj_on and replace surj and bij by abbreviations.
hoelzl
parents:
39075
diff
changeset
|
289 |
|
| 63322 | 290 |
lemma surjI: |
291 |
assumes *: "\<And> x. g (f x) = x" |
|
292 |
shows "surj g" |
|
| 40702 | 293 |
using *[symmetric] by auto |
| 13585 | 294 |
|
|
39076
b3a9b6734663
Introduce surj_on and replace surj and bij by abbreviations.
hoelzl
parents:
39075
diff
changeset
|
295 |
lemma surjD: "surj f \<Longrightarrow> \<exists>x. y = f x" |
|
b3a9b6734663
Introduce surj_on and replace surj and bij by abbreviations.
hoelzl
parents:
39075
diff
changeset
|
296 |
by (simp add: surj_def) |
| 13585 | 297 |
|
|
39076
b3a9b6734663
Introduce surj_on and replace surj and bij by abbreviations.
hoelzl
parents:
39075
diff
changeset
|
298 |
lemma surjE: "surj f \<Longrightarrow> (\<And>x. y = f x \<Longrightarrow> C) \<Longrightarrow> C" |
|
b3a9b6734663
Introduce surj_on and replace surj and bij by abbreviations.
hoelzl
parents:
39075
diff
changeset
|
299 |
by (simp add: surj_def, blast) |
| 13585 | 300 |
|
| 63322 | 301 |
lemma comp_surj: "surj f \<Longrightarrow> surj g \<Longrightarrow> surj (g \<circ> f)" |
|
63416
6af79184bef3
avoid to hide equality behind (output) abbreviation
haftmann
parents:
63400
diff
changeset
|
302 |
by (simp add: image_comp [symmetric]) |
| 13585 | 303 |
|
| 63322 | 304 |
lemma bij_betw_imageI: "inj_on f A \<Longrightarrow> f ` A = B \<Longrightarrow> bij_betw f A B" |
305 |
unfolding bij_betw_def by clarify |
|
| 57282 | 306 |
|
307 |
lemma bij_betw_imp_surj_on: "bij_betw f A B \<Longrightarrow> f ` A = B" |
|
308 |
unfolding bij_betw_def by clarify |
|
309 |
||
| 39074 | 310 |
lemma bij_betw_imp_surj: "bij_betw f A UNIV \<Longrightarrow> surj f" |
| 40702 | 311 |
unfolding bij_betw_def by auto |
| 39074 | 312 |
|
| 63322 | 313 |
lemma bij_betw_empty1: "bij_betw f {} A \<Longrightarrow> A = {}"
|
314 |
unfolding bij_betw_def by blast |
|
|
40703
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
315 |
|
| 63322 | 316 |
lemma bij_betw_empty2: "bij_betw f A {} \<Longrightarrow> A = {}"
|
317 |
unfolding bij_betw_def by blast |
|
|
40703
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
318 |
|
| 63322 | 319 |
lemma inj_on_imp_bij_betw: "inj_on f A \<Longrightarrow> bij_betw f A (f ` A)" |
320 |
unfolding bij_betw_def by simp |
|
|
40703
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
321 |
|
|
39076
b3a9b6734663
Introduce surj_on and replace surj and bij by abbreviations.
hoelzl
parents:
39075
diff
changeset
|
322 |
lemma bij_def: "bij f \<longleftrightarrow> inj f \<and> surj f" |
| 40702 | 323 |
unfolding bij_betw_def .. |
| 39074 | 324 |
|
| 63322 | 325 |
lemma bijI: "inj f \<Longrightarrow> surj f \<Longrightarrow> bij f" |
326 |
by (simp add: bij_def) |
|
| 13585 | 327 |
|
| 63322 | 328 |
lemma bij_is_inj: "bij f \<Longrightarrow> inj f" |
329 |
by (simp add: bij_def) |
|
| 13585 | 330 |
|
| 63322 | 331 |
lemma bij_is_surj: "bij f \<Longrightarrow> surj f" |
332 |
by (simp add: bij_def) |
|
| 13585 | 333 |
|
|
26105
ae06618225ec
moved bij_betw from Library/FuncSet to Fun, redistributed some lemmas, and
nipkow
parents:
25886
diff
changeset
|
334 |
lemma bij_betw_imp_inj_on: "bij_betw f A B \<Longrightarrow> inj_on f A" |
| 63322 | 335 |
by (simp add: bij_betw_def) |
|
26105
ae06618225ec
moved bij_betw from Library/FuncSet to Fun, redistributed some lemmas, and
nipkow
parents:
25886
diff
changeset
|
336 |
|
| 63322 | 337 |
lemma bij_betw_trans: "bij_betw f A B \<Longrightarrow> bij_betw g B C \<Longrightarrow> bij_betw (g \<circ> f) A C" |
338 |
by (auto simp add:bij_betw_def comp_inj_on) |
|
| 31438 | 339 |
|
| 63322 | 340 |
lemma bij_comp: "bij f \<Longrightarrow> bij g \<Longrightarrow> bij (g \<circ> f)" |
| 40702 | 341 |
by (rule bij_betw_trans) |
342 |
||
| 63322 | 343 |
lemma bij_betw_comp_iff: "bij_betw f A A' \<Longrightarrow> bij_betw f' A' A'' \<longleftrightarrow> bij_betw (f' \<circ> f) A A''" |
344 |
by (auto simp add: bij_betw_def inj_on_def) |
|
|
40703
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
345 |
|
|
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
346 |
lemma bij_betw_comp_iff2: |
| 63322 | 347 |
assumes bij: "bij_betw f' A' A''" |
348 |
and img: "f ` A \<le> A'" |
|
349 |
shows "bij_betw f A A' \<longleftrightarrow> bij_betw (f' \<circ> f) A A''" |
|
350 |
using assms |
|
351 |
proof (auto simp add: bij_betw_comp_iff) |
|
|
40703
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
352 |
assume *: "bij_betw (f' \<circ> f) A A''" |
| 63322 | 353 |
then show "bij_betw f A A'" |
354 |
using img |
|
355 |
proof (auto simp add: bij_betw_def) |
|
|
40703
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
356 |
assume "inj_on (f' \<circ> f) A" |
| 63322 | 357 |
then show "inj_on f A" using inj_on_imageI2 by blast |
|
40703
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
358 |
next |
| 63322 | 359 |
fix a' |
360 |
assume **: "a' \<in> A'" |
|
361 |
then have "f' a' \<in> A''" using bij unfolding bij_betw_def by auto |
|
362 |
then obtain a where 1: "a \<in> A \<and> f'(f a) = f' a'" |
|
363 |
using * unfolding bij_betw_def by force |
|
364 |
then have "f a \<in> A'" using img by auto |
|
365 |
then have "f a = a'" |
|
366 |
using bij ** 1 unfolding bij_betw_def inj_on_def by auto |
|
367 |
then show "a' \<in> f ` A" |
|
368 |
using 1 by auto |
|
|
40703
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
369 |
qed |
|
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
370 |
qed |
|
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
371 |
|
| 63322 | 372 |
lemma bij_betw_inv: |
373 |
assumes "bij_betw f A B" |
|
374 |
shows "\<exists>g. bij_betw g B A" |
|
|
26105
ae06618225ec
moved bij_betw from Library/FuncSet to Fun, redistributed some lemmas, and
nipkow
parents:
25886
diff
changeset
|
375 |
proof - |
|
ae06618225ec
moved bij_betw from Library/FuncSet to Fun, redistributed some lemmas, and
nipkow
parents:
25886
diff
changeset
|
376 |
have i: "inj_on f A" and s: "f ` A = B" |
| 63322 | 377 |
using assms by (auto simp: bij_betw_def) |
378 |
let ?P = "\<lambda>b a. a \<in> A \<and> f a = b" |
|
379 |
let ?g = "\<lambda>b. The (?P b)" |
|
380 |
have g: "?g b = a" if P: "?P b a" for a b |
|
381 |
proof - |
|
382 |
from that have ex1: "\<exists>a. ?P b a" using s by blast |
|
383 |
then have uex1: "\<exists>!a. ?P b a" by (blast dest:inj_onD[OF i]) |
|
384 |
then show ?thesis using the1_equality[OF uex1, OF P] P by simp |
|
385 |
qed |
|
|
26105
ae06618225ec
moved bij_betw from Library/FuncSet to Fun, redistributed some lemmas, and
nipkow
parents:
25886
diff
changeset
|
386 |
have "inj_on ?g B" |
| 63322 | 387 |
proof (rule inj_onI) |
388 |
fix x y |
|
389 |
assume "x \<in> B" "y \<in> B" "?g x = ?g y" |
|
390 |
from s \<open>x \<in> B\<close> obtain a1 where a1: "?P x a1" by blast |
|
391 |
from s \<open>y \<in> B\<close> obtain a2 where a2: "?P y a2" by blast |
|
392 |
from g [OF a1] a1 g [OF a2] a2 \<open>?g x = ?g y\<close> show "x = y" by simp |
|
|
26105
ae06618225ec
moved bij_betw from Library/FuncSet to Fun, redistributed some lemmas, and
nipkow
parents:
25886
diff
changeset
|
393 |
qed |
|
ae06618225ec
moved bij_betw from Library/FuncSet to Fun, redistributed some lemmas, and
nipkow
parents:
25886
diff
changeset
|
394 |
moreover have "?g ` B = A" |
| 63322 | 395 |
proof (auto simp: image_def) |
396 |
fix b |
|
397 |
assume "b \<in> B" |
|
| 56077 | 398 |
with s obtain a where P: "?P b a" by blast |
| 63322 | 399 |
then show "?g b \<in> A" using g[OF P] by auto |
|
26105
ae06618225ec
moved bij_betw from Library/FuncSet to Fun, redistributed some lemmas, and
nipkow
parents:
25886
diff
changeset
|
400 |
next |
| 63322 | 401 |
fix a |
402 |
assume "a \<in> A" |
|
| 56077 | 403 |
then obtain b where P: "?P b a" using s by blast |
| 63322 | 404 |
then have "b \<in> B" using s by blast |
|
26105
ae06618225ec
moved bij_betw from Library/FuncSet to Fun, redistributed some lemmas, and
nipkow
parents:
25886
diff
changeset
|
405 |
with g[OF P] show "\<exists>b\<in>B. a = ?g b" by blast |
|
ae06618225ec
moved bij_betw from Library/FuncSet to Fun, redistributed some lemmas, and
nipkow
parents:
25886
diff
changeset
|
406 |
qed |
| 63322 | 407 |
ultimately show ?thesis by (auto simp: bij_betw_def) |
|
26105
ae06618225ec
moved bij_betw from Library/FuncSet to Fun, redistributed some lemmas, and
nipkow
parents:
25886
diff
changeset
|
408 |
qed |
|
ae06618225ec
moved bij_betw from Library/FuncSet to Fun, redistributed some lemmas, and
nipkow
parents:
25886
diff
changeset
|
409 |
|
| 63322 | 410 |
lemma bij_betw_cong: "(\<And> a. a \<in> A \<Longrightarrow> f a = g a) \<Longrightarrow> bij_betw f A A' = bij_betw g A A'" |
411 |
unfolding bij_betw_def inj_on_def by force |
|
|
40703
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
412 |
|
| 63322 | 413 |
lemma bij_betw_id[intro, simp]: "bij_betw id A A" |
414 |
unfolding bij_betw_def id_def by auto |
|
|
40703
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
415 |
|
| 63322 | 416 |
lemma bij_betw_id_iff: "bij_betw id A B \<longleftrightarrow> A = B" |
417 |
by (auto simp add: bij_betw_def) |
|
|
40703
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
418 |
|
| 39075 | 419 |
lemma bij_betw_combine: |
| 63400 | 420 |
"bij_betw f A B \<Longrightarrow> bij_betw f C D \<Longrightarrow> B \<inter> D = {} \<Longrightarrow> bij_betw f (A \<union> C) (B \<union> D)"
|
421 |
unfolding bij_betw_def inj_on_Un image_Un by auto |
|
| 39075 | 422 |
|
| 63322 | 423 |
lemma bij_betw_subset: "bij_betw f A A' \<Longrightarrow> B \<le> A \<Longrightarrow> f ` B = B' \<Longrightarrow> bij_betw f B B'" |
424 |
by (auto simp add: bij_betw_def inj_on_def) |
|
|
40703
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
425 |
|
| 58195 | 426 |
lemma bij_pointE: |
427 |
assumes "bij f" |
|
428 |
obtains x where "y = f x" and "\<And>x'. y = f x' \<Longrightarrow> x' = x" |
|
429 |
proof - |
|
430 |
from assms have "inj f" by (rule bij_is_inj) |
|
431 |
moreover from assms have "surj f" by (rule bij_is_surj) |
|
432 |
then have "y \<in> range f" by simp |
|
433 |
ultimately have "\<exists>!x. y = f x" by (simp add: range_ex1_eq) |
|
434 |
with that show thesis by blast |
|
435 |
qed |
|
436 |
||
| 63322 | 437 |
lemma surj_image_vimage_eq: "surj f \<Longrightarrow> f ` (f -` A) = A" |
438 |
by simp |
|
| 13585 | 439 |
|
| 42903 | 440 |
lemma surj_vimage_empty: |
| 63322 | 441 |
assumes "surj f" |
442 |
shows "f -` A = {} \<longleftrightarrow> A = {}"
|
|
443 |
using surj_image_vimage_eq [OF \<open>surj f\<close>, of A] |
|
|
44890
22f665a2e91c
new fastforce replacing fastsimp - less confusing name
nipkow
parents:
44860
diff
changeset
|
444 |
by (intro iffI) fastforce+ |
| 42903 | 445 |
|
| 63322 | 446 |
lemma inj_vimage_image_eq: "inj f \<Longrightarrow> f -` (f ` A) = A" |
447 |
unfolding inj_on_def by blast |
|
| 13585 | 448 |
|
| 63322 | 449 |
lemma vimage_subsetD: "surj f \<Longrightarrow> f -` B \<subseteq> A \<Longrightarrow> B \<subseteq> f ` A" |
450 |
by (blast intro: sym) |
|
| 13585 | 451 |
|
| 63322 | 452 |
lemma vimage_subsetI: "inj f \<Longrightarrow> B \<subseteq> f ` A \<Longrightarrow> f -` B \<subseteq> A" |
453 |
unfolding inj_on_def by blast |
|
| 13585 | 454 |
|
| 63322 | 455 |
lemma vimage_subset_eq: "bij f \<Longrightarrow> f -` B \<subseteq> A \<longleftrightarrow> B \<subseteq> f ` A" |
456 |
unfolding bij_def by (blast del: subsetI intro: vimage_subsetI vimage_subsetD) |
|
| 13585 | 457 |
|
| 63322 | 458 |
lemma inj_on_image_eq_iff: "inj_on f C \<Longrightarrow> A \<subseteq> C \<Longrightarrow> B \<subseteq> C \<Longrightarrow> f ` A = f ` B \<longleftrightarrow> A = B" |
459 |
by (fastforce simp add: inj_on_def) |
|
| 53927 | 460 |
|
| 31438 | 461 |
lemma inj_on_Un_image_eq_iff: "inj_on f (A \<union> B) \<Longrightarrow> f ` A = f ` B \<longleftrightarrow> A = B" |
| 63322 | 462 |
by (erule inj_on_image_eq_iff) simp_all |
| 31438 | 463 |
|
| 63322 | 464 |
lemma inj_on_image_Int: "inj_on f C \<Longrightarrow> A \<subseteq> C \<Longrightarrow> B \<subseteq> C \<Longrightarrow> f ` (A \<inter> B) = f ` A \<inter> f ` B" |
465 |
unfolding inj_on_def by blast |
|
466 |
||
467 |
lemma inj_on_image_set_diff: "inj_on f C \<Longrightarrow> A - B \<subseteq> C \<Longrightarrow> B \<subseteq> C \<Longrightarrow> f ` (A - B) = f ` A - f ` B" |
|
468 |
unfolding inj_on_def by blast |
|
| 13585 | 469 |
|
| 63322 | 470 |
lemma image_Int: "inj f \<Longrightarrow> f ` (A \<inter> B) = f ` A \<inter> f ` B" |
471 |
unfolding inj_on_def by blast |
|
| 13585 | 472 |
|
| 63322 | 473 |
lemma image_set_diff: "inj f \<Longrightarrow> f ` (A - B) = f ` A - f ` B" |
474 |
unfolding inj_on_def by blast |
|
| 13585 | 475 |
|
| 63322 | 476 |
lemma inj_on_image_mem_iff: "inj_on f B \<Longrightarrow> a \<in> B \<Longrightarrow> A \<subseteq> B \<Longrightarrow> f a \<in> f ` A \<longleftrightarrow> a \<in> A" |
|
59504
8c6747dba731
New lemmas and a bit of tidying up.
paulson <lp15@cam.ac.uk>
parents:
58889
diff
changeset
|
477 |
by (auto simp: inj_on_def) |
|
8c6747dba731
New lemmas and a bit of tidying up.
paulson <lp15@cam.ac.uk>
parents:
58889
diff
changeset
|
478 |
|
|
61520
8f85bb443d33
Cauchy's integral formula, required lemmas, and a bit of reorganisation
paulson <lp15@cam.ac.uk>
parents:
61378
diff
changeset
|
479 |
(*FIXME DELETE*) |
| 63322 | 480 |
lemma inj_on_image_mem_iff_alt: "inj_on f B \<Longrightarrow> A \<subseteq> B \<Longrightarrow> f a \<in> f ` A \<Longrightarrow> a \<in> B \<Longrightarrow> a \<in> A" |
|
61520
8f85bb443d33
Cauchy's integral formula, required lemmas, and a bit of reorganisation
paulson <lp15@cam.ac.uk>
parents:
61378
diff
changeset
|
481 |
by (blast dest: inj_onD) |
|
8f85bb443d33
Cauchy's integral formula, required lemmas, and a bit of reorganisation
paulson <lp15@cam.ac.uk>
parents:
61378
diff
changeset
|
482 |
|
| 63322 | 483 |
lemma inj_image_mem_iff: "inj f \<Longrightarrow> f a \<in> f ` A \<longleftrightarrow> a \<in> A" |
|
59504
8c6747dba731
New lemmas and a bit of tidying up.
paulson <lp15@cam.ac.uk>
parents:
58889
diff
changeset
|
484 |
by (blast dest: injD) |
| 13585 | 485 |
|
| 63322 | 486 |
lemma inj_image_subset_iff: "inj f \<Longrightarrow> f ` A \<subseteq> f ` B \<longleftrightarrow> A \<subseteq> B" |
|
59504
8c6747dba731
New lemmas and a bit of tidying up.
paulson <lp15@cam.ac.uk>
parents:
58889
diff
changeset
|
487 |
by (blast dest: injD) |
| 13585 | 488 |
|
| 63322 | 489 |
lemma inj_image_eq_iff: "inj f \<Longrightarrow> f ` A = f ` B \<longleftrightarrow> A = B" |
|
59504
8c6747dba731
New lemmas and a bit of tidying up.
paulson <lp15@cam.ac.uk>
parents:
58889
diff
changeset
|
490 |
by (blast dest: injD) |
| 13585 | 491 |
|
| 63322 | 492 |
lemma surj_Compl_image_subset: "surj f \<Longrightarrow> - (f ` A) \<subseteq> f ` (- A)" |
493 |
by auto |
|
| 5852 | 494 |
|
| 63322 | 495 |
lemma inj_image_Compl_subset: "inj f \<Longrightarrow> f ` (- A) \<subseteq> - (f ` A)" |
496 |
by (auto simp add: inj_on_def) |
|
497 |
||
498 |
lemma bij_image_Compl_eq: "bij f \<Longrightarrow> f ` (- A) = - (f ` A)" |
|
499 |
by (simp add: bij_def inj_image_Compl_subset surj_Compl_image_subset equalityI) |
|
| 13585 | 500 |
|
| 41657 | 501 |
lemma inj_vimage_singleton: "inj f \<Longrightarrow> f -` {a} \<subseteq> {THE x. f x = a}"
|
| 63322 | 502 |
\<comment> \<open>The inverse image of a singleton under an injective function is included in a singleton.\<close> |
| 41657 | 503 |
apply (auto simp add: inj_on_def) |
504 |
apply (blast intro: the_equality [symmetric]) |
|
505 |
done |
|
506 |
||
| 63322 | 507 |
lemma inj_on_vimage_singleton: "inj_on f A \<Longrightarrow> f -` {a} \<inter> A \<subseteq> {THE x. x \<in> A \<and> f x = a}"
|
| 43991 | 508 |
by (auto simp add: inj_on_def intro: the_equality [symmetric]) |
509 |
||
|
35584
768f8d92b767
generalized inj_uminus; added strict_mono_imp_inj_on
hoelzl
parents:
35580
diff
changeset
|
510 |
lemma (in ordered_ab_group_add) inj_uminus[simp, intro]: "inj_on uminus A" |
| 35580 | 511 |
by (auto intro!: inj_onI) |
| 13585 | 512 |
|
|
35584
768f8d92b767
generalized inj_uminus; added strict_mono_imp_inj_on
hoelzl
parents:
35580
diff
changeset
|
513 |
lemma (in linorder) strict_mono_imp_inj_on: "strict_mono f \<Longrightarrow> inj_on f A" |
|
768f8d92b767
generalized inj_uminus; added strict_mono_imp_inj_on
hoelzl
parents:
35580
diff
changeset
|
514 |
by (auto intro!: inj_onI dest: strict_mono_eq) |
|
768f8d92b767
generalized inj_uminus; added strict_mono_imp_inj_on
hoelzl
parents:
35580
diff
changeset
|
515 |
|
|
55019
0d5e831175de
moved lemmas from 'Fun_More_FP' to where they belong
blanchet
parents:
54578
diff
changeset
|
516 |
lemma bij_betw_byWitness: |
| 63322 | 517 |
assumes left: "\<forall>a \<in> A. f' (f a) = a" |
518 |
and right: "\<forall>a' \<in> A'. f (f' a') = a'" |
|
519 |
and "f ` A \<le> A'" |
|
520 |
and img2: "f' ` A' \<le> A" |
|
521 |
shows "bij_betw f A A'" |
|
522 |
using assms |
|
| 63400 | 523 |
unfolding bij_betw_def inj_on_def |
524 |
proof safe |
|
| 63322 | 525 |
fix a b |
526 |
assume *: "a \<in> A" "b \<in> A" and **: "f a = f b" |
|
527 |
have "a = f' (f a) \<and> b = f'(f b)" using * left by simp |
|
|
55019
0d5e831175de
moved lemmas from 'Fun_More_FP' to where they belong
blanchet
parents:
54578
diff
changeset
|
528 |
with ** show "a = b" by simp |
|
0d5e831175de
moved lemmas from 'Fun_More_FP' to where they belong
blanchet
parents:
54578
diff
changeset
|
529 |
next |
|
0d5e831175de
moved lemmas from 'Fun_More_FP' to where they belong
blanchet
parents:
54578
diff
changeset
|
530 |
fix a' assume *: "a' \<in> A'" |
| 63400 | 531 |
then have "f' a' \<in> A" using img2 by blast |
|
55019
0d5e831175de
moved lemmas from 'Fun_More_FP' to where they belong
blanchet
parents:
54578
diff
changeset
|
532 |
moreover |
| 63322 | 533 |
have "a' = f (f' a')" using * right by simp |
|
55019
0d5e831175de
moved lemmas from 'Fun_More_FP' to where they belong
blanchet
parents:
54578
diff
changeset
|
534 |
ultimately show "a' \<in> f ` A" by blast |
|
0d5e831175de
moved lemmas from 'Fun_More_FP' to where they belong
blanchet
parents:
54578
diff
changeset
|
535 |
qed |
|
0d5e831175de
moved lemmas from 'Fun_More_FP' to where they belong
blanchet
parents:
54578
diff
changeset
|
536 |
|
|
0d5e831175de
moved lemmas from 'Fun_More_FP' to where they belong
blanchet
parents:
54578
diff
changeset
|
537 |
corollary notIn_Un_bij_betw: |
| 63322 | 538 |
assumes "b \<notin> A" |
539 |
and "f b \<notin> A'" |
|
540 |
and "bij_betw f A A'" |
|
541 |
shows "bij_betw f (A \<union> {b}) (A' \<union> {f b})"
|
|
542 |
proof - |
|
|
55019
0d5e831175de
moved lemmas from 'Fun_More_FP' to where they belong
blanchet
parents:
54578
diff
changeset
|
543 |
have "bij_betw f {b} {f b}"
|
| 63322 | 544 |
unfolding bij_betw_def inj_on_def by simp |
|
55019
0d5e831175de
moved lemmas from 'Fun_More_FP' to where they belong
blanchet
parents:
54578
diff
changeset
|
545 |
with assms show ?thesis |
| 63322 | 546 |
using bij_betw_combine[of f A A' "{b}" "{f b}"] by blast
|
|
55019
0d5e831175de
moved lemmas from 'Fun_More_FP' to where they belong
blanchet
parents:
54578
diff
changeset
|
547 |
qed |
|
0d5e831175de
moved lemmas from 'Fun_More_FP' to where they belong
blanchet
parents:
54578
diff
changeset
|
548 |
|
|
0d5e831175de
moved lemmas from 'Fun_More_FP' to where they belong
blanchet
parents:
54578
diff
changeset
|
549 |
lemma notIn_Un_bij_betw3: |
| 63322 | 550 |
assumes "b \<notin> A" |
551 |
and "f b \<notin> A'" |
|
552 |
shows "bij_betw f A A' = bij_betw f (A \<union> {b}) (A' \<union> {f b})"
|
|
|
55019
0d5e831175de
moved lemmas from 'Fun_More_FP' to where they belong
blanchet
parents:
54578
diff
changeset
|
553 |
proof |
|
0d5e831175de
moved lemmas from 'Fun_More_FP' to where they belong
blanchet
parents:
54578
diff
changeset
|
554 |
assume "bij_betw f A A'" |
| 63322 | 555 |
then show "bij_betw f (A \<union> {b}) (A' \<union> {f b})"
|
556 |
using assms notIn_Un_bij_betw [of b A f A'] by blast |
|
|
55019
0d5e831175de
moved lemmas from 'Fun_More_FP' to where they belong
blanchet
parents:
54578
diff
changeset
|
557 |
next |
|
0d5e831175de
moved lemmas from 'Fun_More_FP' to where they belong
blanchet
parents:
54578
diff
changeset
|
558 |
assume *: "bij_betw f (A \<union> {b}) (A' \<union> {f b})"
|
|
0d5e831175de
moved lemmas from 'Fun_More_FP' to where they belong
blanchet
parents:
54578
diff
changeset
|
559 |
have "f ` A = A'" |
| 63322 | 560 |
proof auto |
561 |
fix a |
|
562 |
assume **: "a \<in> A" |
|
563 |
then have "f a \<in> A' \<union> {f b}"
|
|
564 |
using * unfolding bij_betw_def by blast |
|
|
55019
0d5e831175de
moved lemmas from 'Fun_More_FP' to where they belong
blanchet
parents:
54578
diff
changeset
|
565 |
moreover |
| 63322 | 566 |
have False if "f a = f b" |
567 |
proof - |
|
568 |
have "a = b" using * ** that unfolding bij_betw_def inj_on_def by blast |
|
569 |
with \<open>b \<notin> A\<close> ** show ?thesis by blast |
|
570 |
qed |
|
|
55019
0d5e831175de
moved lemmas from 'Fun_More_FP' to where they belong
blanchet
parents:
54578
diff
changeset
|
571 |
ultimately show "f a \<in> A'" by blast |
|
0d5e831175de
moved lemmas from 'Fun_More_FP' to where they belong
blanchet
parents:
54578
diff
changeset
|
572 |
next |
| 63322 | 573 |
fix a' |
574 |
assume **: "a' \<in> A'" |
|
575 |
then have "a' \<in> f ` (A \<union> {b})"
|
|
576 |
using * by (auto simp add: bij_betw_def) |
|
|
55019
0d5e831175de
moved lemmas from 'Fun_More_FP' to where they belong
blanchet
parents:
54578
diff
changeset
|
577 |
then obtain a where 1: "a \<in> A \<union> {b} \<and> f a = a'" by blast
|
|
0d5e831175de
moved lemmas from 'Fun_More_FP' to where they belong
blanchet
parents:
54578
diff
changeset
|
578 |
moreover |
| 63322 | 579 |
have False if "a = b" using 1 ** \<open>f b \<notin> A'\<close> that by blast |
|
55019
0d5e831175de
moved lemmas from 'Fun_More_FP' to where they belong
blanchet
parents:
54578
diff
changeset
|
580 |
ultimately have "a \<in> A" by blast |
|
0d5e831175de
moved lemmas from 'Fun_More_FP' to where they belong
blanchet
parents:
54578
diff
changeset
|
581 |
with 1 show "a' \<in> f ` A" by blast |
|
0d5e831175de
moved lemmas from 'Fun_More_FP' to where they belong
blanchet
parents:
54578
diff
changeset
|
582 |
qed |
| 63322 | 583 |
then show "bij_betw f A A'" |
584 |
using * bij_betw_subset[of f "A \<union> {b}" _ A] by blast
|
|
|
55019
0d5e831175de
moved lemmas from 'Fun_More_FP' to where they belong
blanchet
parents:
54578
diff
changeset
|
585 |
qed |
|
0d5e831175de
moved lemmas from 'Fun_More_FP' to where they belong
blanchet
parents:
54578
diff
changeset
|
586 |
|
| 41657 | 587 |
|
| 63322 | 588 |
subsection \<open>Function Updating\<close> |
| 13585 | 589 |
|
| 63322 | 590 |
definition fun_upd :: "('a \<Rightarrow> 'b) \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> ('a \<Rightarrow> 'b)"
|
| 63324 | 591 |
where "fun_upd f a b = (\<lambda>x. if x = a then b else f x)" |
| 26147 | 592 |
|
|
41229
d797baa3d57c
replaced command 'nonterminals' by slightly modernized version 'nonterminal';
wenzelm
parents:
40969
diff
changeset
|
593 |
nonterminal updbinds and updbind |
|
d797baa3d57c
replaced command 'nonterminals' by slightly modernized version 'nonterminal';
wenzelm
parents:
40969
diff
changeset
|
594 |
|
| 26147 | 595 |
syntax |
| 63322 | 596 |
"_updbind" :: "'a \<Rightarrow> 'a \<Rightarrow> updbind" ("(2_ :=/ _)")
|
597 |
"" :: "updbind \<Rightarrow> updbinds" ("_")
|
|
598 |
"_updbinds":: "updbind \<Rightarrow> updbinds \<Rightarrow> updbinds" ("_,/ _")
|
|
599 |
"_Update" :: "'a \<Rightarrow> updbinds \<Rightarrow> 'a" ("_/'((_)')" [1000, 0] 900)
|
|
| 26147 | 600 |
|
601 |
translations |
|
| 63322 | 602 |
"_Update f (_updbinds b bs)" \<rightleftharpoons> "_Update (_Update f b) bs" |
603 |
"f(x:=y)" \<rightleftharpoons> "CONST fun_upd f x y" |
|
| 26147 | 604 |
|
|
55414
eab03e9cee8a
renamed '{prod,sum,bool,unit}_case' to 'case_...'
blanchet
parents:
55066
diff
changeset
|
605 |
(* Hint: to define the sum of two functions (or maps), use case_sum. |
| 58111 | 606 |
A nice infix syntax could be defined by |
| 35115 | 607 |
notation |
|
55414
eab03e9cee8a
renamed '{prod,sum,bool,unit}_case' to 'case_...'
blanchet
parents:
55066
diff
changeset
|
608 |
case_sum (infixr "'(+')"80) |
| 26147 | 609 |
*) |
610 |
||
| 63322 | 611 |
lemma fun_upd_idem_iff: "f(x:=y) = f \<longleftrightarrow> f x = y" |
612 |
unfolding fun_upd_def |
|
613 |
apply safe |
|
614 |
apply (erule subst) |
|
615 |
apply (rule_tac [2] ext) |
|
616 |
apply auto |
|
617 |
done |
|
| 13585 | 618 |
|
| 63322 | 619 |
lemma fun_upd_idem: "f x = y \<Longrightarrow> f(x := y) = f" |
| 45603 | 620 |
by (simp only: fun_upd_idem_iff) |
| 13585 | 621 |
|
| 45603 | 622 |
lemma fun_upd_triv [iff]: "f(x := f x) = f" |
623 |
by (simp only: fun_upd_idem) |
|
| 13585 | 624 |
|
| 63322 | 625 |
lemma fun_upd_apply [simp]: "(f(x := y)) z = (if z = x then y else f z)" |
626 |
by (simp add: fun_upd_def) |
|
| 13585 | 627 |
|
| 63322 | 628 |
(* fun_upd_apply supersedes these two, but they are useful |
| 13585 | 629 |
if fun_upd_apply is intentionally removed from the simpset *) |
| 63322 | 630 |
lemma fun_upd_same: "(f(x := y)) x = y" |
631 |
by simp |
|
| 13585 | 632 |
|
| 63322 | 633 |
lemma fun_upd_other: "z \<noteq> x \<Longrightarrow> (f(x := y)) z = f z" |
634 |
by simp |
|
| 13585 | 635 |
|
| 63322 | 636 |
lemma fun_upd_upd [simp]: "f(x := y, x := z) = f(x := z)" |
637 |
by (simp add: fun_eq_iff) |
|
| 13585 | 638 |
|
| 63322 | 639 |
lemma fun_upd_twist: "a \<noteq> c \<Longrightarrow> (m(a := b))(c := d) = (m(c := d))(a := b)" |
640 |
by (rule ext) auto |
|
641 |
||
642 |
lemma inj_on_fun_updI: "inj_on f A \<Longrightarrow> y \<notin> f ` A \<Longrightarrow> inj_on (f(x := y)) A" |
|
| 56077 | 643 |
by (fastforce simp: inj_on_def) |
| 15303 | 644 |
|
| 63322 | 645 |
lemma fun_upd_image: "f(x := y) ` A = (if x \<in> A then insert y (f ` (A - {x})) else f ` A)"
|
646 |
by auto |
|
| 15510 | 647 |
|
| 31080 | 648 |
lemma fun_upd_comp: "f \<circ> (g(x := y)) = (f \<circ> g)(x := f y)" |
| 44921 | 649 |
by auto |
| 31080 | 650 |
|
| 61630 | 651 |
lemma fun_upd_eqD: "f(x := y) = g(x := z) \<Longrightarrow> y = z" |
| 63322 | 652 |
by (simp add: fun_eq_iff split: if_split_asm) |
653 |
||
| 26147 | 654 |
|
| 61799 | 655 |
subsection \<open>\<open>override_on\<close>\<close> |
| 26147 | 656 |
|
| 63322 | 657 |
definition override_on :: "('a \<Rightarrow> 'b) \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'a set \<Rightarrow> 'a \<Rightarrow> 'b"
|
658 |
where "override_on f g A = (\<lambda>a. if a \<in> A then g a else f a)" |
|
| 13910 | 659 |
|
| 15691 | 660 |
lemma override_on_emptyset[simp]: "override_on f g {} = f"
|
| 63322 | 661 |
by (simp add:override_on_def) |
| 13910 | 662 |
|
| 63322 | 663 |
lemma override_on_apply_notin[simp]: "a \<notin> A \<Longrightarrow> (override_on f g A) a = f a" |
664 |
by (simp add:override_on_def) |
|
| 13910 | 665 |
|
| 63322 | 666 |
lemma override_on_apply_in[simp]: "a \<in> A \<Longrightarrow> (override_on f g A) a = g a" |
667 |
by (simp add:override_on_def) |
|
| 13910 | 668 |
|
|
63561
fba08009ff3e
add lemmas contributed by Peter Gammie
Andreas Lochbihler
parents:
63416
diff
changeset
|
669 |
lemma override_on_insert: "override_on f g (insert x X) = (override_on f g X)(x:=g x)" |
|
fba08009ff3e
add lemmas contributed by Peter Gammie
Andreas Lochbihler
parents:
63416
diff
changeset
|
670 |
unfolding override_on_def by (simp add: fun_eq_iff) |
|
fba08009ff3e
add lemmas contributed by Peter Gammie
Andreas Lochbihler
parents:
63416
diff
changeset
|
671 |
|
|
fba08009ff3e
add lemmas contributed by Peter Gammie
Andreas Lochbihler
parents:
63416
diff
changeset
|
672 |
lemma override_on_insert': "override_on f g (insert x X) = (override_on (f(x:=g x)) g X)" |
|
fba08009ff3e
add lemmas contributed by Peter Gammie
Andreas Lochbihler
parents:
63416
diff
changeset
|
673 |
unfolding override_on_def by (simp add: fun_eq_iff) |
|
fba08009ff3e
add lemmas contributed by Peter Gammie
Andreas Lochbihler
parents:
63416
diff
changeset
|
674 |
|
| 26147 | 675 |
|
| 61799 | 676 |
subsection \<open>\<open>swap\<close>\<close> |
| 15510 | 677 |
|
| 56608 | 678 |
definition swap :: "'a \<Rightarrow> 'a \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> ('a \<Rightarrow> 'b)"
|
| 63322 | 679 |
where "swap a b f = f (a := f b, b:= f a)" |
| 15510 | 680 |
|
| 56608 | 681 |
lemma swap_apply [simp]: |
682 |
"swap a b f a = f b" |
|
683 |
"swap a b f b = f a" |
|
684 |
"c \<noteq> a \<Longrightarrow> c \<noteq> b \<Longrightarrow> swap a b f c = f c" |
|
685 |
by (simp_all add: swap_def) |
|
686 |
||
| 63322 | 687 |
lemma swap_self [simp]: "swap a a f = f" |
| 56608 | 688 |
by (simp add: swap_def) |
| 15510 | 689 |
|
| 63322 | 690 |
lemma swap_commute: "swap a b f = swap b a f" |
| 56608 | 691 |
by (simp add: fun_upd_def swap_def fun_eq_iff) |
| 15510 | 692 |
|
| 63322 | 693 |
lemma swap_nilpotent [simp]: "swap a b (swap a b f) = f" |
| 56608 | 694 |
by (rule ext, simp add: fun_upd_def swap_def) |
695 |
||
| 63322 | 696 |
lemma swap_comp_involutory [simp]: "swap a b \<circ> swap a b = id" |
| 56608 | 697 |
by (rule ext) simp |
| 15510 | 698 |
|
| 34145 | 699 |
lemma swap_triple: |
700 |
assumes "a \<noteq> c" and "b \<noteq> c" |
|
701 |
shows "swap a b (swap b c (swap a b f)) = swap a c f" |
|
|
39302
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents:
39213
diff
changeset
|
702 |
using assms by (simp add: fun_eq_iff swap_def) |
| 34145 | 703 |
|
| 34101 | 704 |
lemma comp_swap: "f \<circ> swap a b g = swap a b (f \<circ> g)" |
| 63322 | 705 |
by (rule ext) (simp add: fun_upd_def swap_def) |
| 34101 | 706 |
|
|
39076
b3a9b6734663
Introduce surj_on and replace surj and bij by abbreviations.
hoelzl
parents:
39075
diff
changeset
|
707 |
lemma swap_image_eq [simp]: |
| 63322 | 708 |
assumes "a \<in> A" "b \<in> A" |
709 |
shows "swap a b f ` A = f ` A" |
|
|
39076
b3a9b6734663
Introduce surj_on and replace surj and bij by abbreviations.
hoelzl
parents:
39075
diff
changeset
|
710 |
proof - |
|
b3a9b6734663
Introduce surj_on and replace surj and bij by abbreviations.
hoelzl
parents:
39075
diff
changeset
|
711 |
have subset: "\<And>f. swap a b f ` A \<subseteq> f ` A" |
|
b3a9b6734663
Introduce surj_on and replace surj and bij by abbreviations.
hoelzl
parents:
39075
diff
changeset
|
712 |
using assms by (auto simp: image_iff swap_def) |
|
b3a9b6734663
Introduce surj_on and replace surj and bij by abbreviations.
hoelzl
parents:
39075
diff
changeset
|
713 |
then have "swap a b (swap a b f) ` A \<subseteq> (swap a b f) ` A" . |
|
b3a9b6734663
Introduce surj_on and replace surj and bij by abbreviations.
hoelzl
parents:
39075
diff
changeset
|
714 |
with subset[of f] show ?thesis by auto |
|
b3a9b6734663
Introduce surj_on and replace surj and bij by abbreviations.
hoelzl
parents:
39075
diff
changeset
|
715 |
qed |
|
b3a9b6734663
Introduce surj_on and replace surj and bij by abbreviations.
hoelzl
parents:
39075
diff
changeset
|
716 |
|
| 63322 | 717 |
lemma inj_on_imp_inj_on_swap: "inj_on f A \<Longrightarrow> a \<in> A \<Longrightarrow> b \<in> A \<Longrightarrow> inj_on (swap a b f) A" |
718 |
by (auto simp add: inj_on_def swap_def) |
|
| 15510 | 719 |
|
720 |
lemma inj_on_swap_iff [simp]: |
|
| 63322 | 721 |
assumes A: "a \<in> A" "b \<in> A" |
722 |
shows "inj_on (swap a b f) A \<longleftrightarrow> inj_on f A" |
|
| 39075 | 723 |
proof |
| 15510 | 724 |
assume "inj_on (swap a b f) A" |
| 39075 | 725 |
with A have "inj_on (swap a b (swap a b f)) A" |
726 |
by (iprover intro: inj_on_imp_inj_on_swap) |
|
| 63322 | 727 |
then show "inj_on f A" by simp |
| 15510 | 728 |
next |
729 |
assume "inj_on f A" |
|
| 63322 | 730 |
with A show "inj_on (swap a b f) A" |
731 |
by (iprover intro: inj_on_imp_inj_on_swap) |
|
| 15510 | 732 |
qed |
733 |
||
|
39076
b3a9b6734663
Introduce surj_on and replace surj and bij by abbreviations.
hoelzl
parents:
39075
diff
changeset
|
734 |
lemma surj_imp_surj_swap: "surj f \<Longrightarrow> surj (swap a b f)" |
| 40702 | 735 |
by simp |
| 15510 | 736 |
|
|
39076
b3a9b6734663
Introduce surj_on and replace surj and bij by abbreviations.
hoelzl
parents:
39075
diff
changeset
|
737 |
lemma surj_swap_iff [simp]: "surj (swap a b f) \<longleftrightarrow> surj f" |
| 40702 | 738 |
by simp |
|
21547
9c9fdf4c2949
moved order arities for fun and bool to Fun/Orderings
haftmann
parents:
21327
diff
changeset
|
739 |
|
| 63322 | 740 |
lemma bij_betw_swap_iff [simp]: "x \<in> A \<Longrightarrow> y \<in> A \<Longrightarrow> bij_betw (swap x y f) A B \<longleftrightarrow> bij_betw f A B" |
|
39076
b3a9b6734663
Introduce surj_on and replace surj and bij by abbreviations.
hoelzl
parents:
39075
diff
changeset
|
741 |
by (auto simp: bij_betw_def) |
|
b3a9b6734663
Introduce surj_on and replace surj and bij by abbreviations.
hoelzl
parents:
39075
diff
changeset
|
742 |
|
|
b3a9b6734663
Introduce surj_on and replace surj and bij by abbreviations.
hoelzl
parents:
39075
diff
changeset
|
743 |
lemma bij_swap_iff [simp]: "bij (swap a b f) \<longleftrightarrow> bij f" |
|
b3a9b6734663
Introduce surj_on and replace surj and bij by abbreviations.
hoelzl
parents:
39075
diff
changeset
|
744 |
by simp |
| 39075 | 745 |
|
|
36176
3fe7e97ccca8
replaced generic 'hide' command by more conventional 'hide_class', 'hide_type', 'hide_const', 'hide_fact' -- frees some popular keywords;
wenzelm
parents:
35584
diff
changeset
|
746 |
hide_const (open) swap |
|
21547
9c9fdf4c2949
moved order arities for fun and bool to Fun/Orderings
haftmann
parents:
21327
diff
changeset
|
747 |
|
| 56608 | 748 |
|
| 60758 | 749 |
subsection \<open>Inversion of injective functions\<close> |
| 31949 | 750 |
|
| 63322 | 751 |
definition the_inv_into :: "'a set \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> ('b \<Rightarrow> 'a)"
|
| 63324 | 752 |
where "the_inv_into A f = (\<lambda>x. THE y. y \<in> A \<and> f y = x)" |
| 63322 | 753 |
|
754 |
lemma the_inv_into_f_f: "inj_on f A \<Longrightarrow> x \<in> A \<Longrightarrow> the_inv_into A f (f x) = x" |
|
755 |
unfolding the_inv_into_def inj_on_def by blast |
|
| 32961 | 756 |
|
| 63322 | 757 |
lemma f_the_inv_into_f: "inj_on f A \<Longrightarrow> y \<in> f ` A \<Longrightarrow> f (the_inv_into A f y) = y" |
758 |
apply (simp add: the_inv_into_def) |
|
759 |
apply (rule the1I2) |
|
760 |
apply(blast dest: inj_onD) |
|
761 |
apply blast |
|
762 |
done |
|
| 32961 | 763 |
|
| 63322 | 764 |
lemma the_inv_into_into: "inj_on f A \<Longrightarrow> x \<in> f ` A \<Longrightarrow> A \<subseteq> B \<Longrightarrow> the_inv_into A f x \<in> B" |
765 |
apply (simp add: the_inv_into_def) |
|
766 |
apply (rule the1I2) |
|
767 |
apply(blast dest: inj_onD) |
|
768 |
apply blast |
|
769 |
done |
|
| 32961 | 770 |
|
| 63322 | 771 |
lemma the_inv_into_onto [simp]: "inj_on f A \<Longrightarrow> the_inv_into A f ` (f ` A) = A" |
772 |
by (fast intro: the_inv_into_into the_inv_into_f_f [symmetric]) |
|
| 32961 | 773 |
|
| 63322 | 774 |
lemma the_inv_into_f_eq: "inj_on f A \<Longrightarrow> f x = y \<Longrightarrow> x \<in> A \<Longrightarrow> the_inv_into A f y = x" |
| 32961 | 775 |
apply (erule subst) |
| 63322 | 776 |
apply (erule the_inv_into_f_f) |
777 |
apply assumption |
|
| 32961 | 778 |
done |
779 |
||
| 33057 | 780 |
lemma the_inv_into_comp: |
| 63322 | 781 |
"inj_on f (g ` A) \<Longrightarrow> inj_on g A \<Longrightarrow> x \<in> f ` g ` A \<Longrightarrow> |
782 |
the_inv_into A (f \<circ> g) x = (the_inv_into A g \<circ> the_inv_into (g ` A) f) x" |
|
783 |
apply (rule the_inv_into_f_eq) |
|
784 |
apply (fast intro: comp_inj_on) |
|
785 |
apply (simp add: f_the_inv_into_f the_inv_into_into) |
|
786 |
apply (simp add: the_inv_into_into) |
|
787 |
done |
|
| 32961 | 788 |
|
| 63322 | 789 |
lemma inj_on_the_inv_into: "inj_on f A \<Longrightarrow> inj_on (the_inv_into A f) (f ` A)" |
790 |
by (auto intro: inj_onI simp: the_inv_into_f_f) |
|
| 32961 | 791 |
|
| 63322 | 792 |
lemma bij_betw_the_inv_into: "bij_betw f A B \<Longrightarrow> bij_betw (the_inv_into A f) B A" |
793 |
by (auto simp add: bij_betw_def inj_on_the_inv_into the_inv_into_into) |
|
| 32961 | 794 |
|
| 63322 | 795 |
abbreviation the_inv :: "('a \<Rightarrow> 'b) \<Rightarrow> ('b \<Rightarrow> 'a)"
|
796 |
where "the_inv f \<equiv> the_inv_into UNIV f" |
|
|
32998
31b19fa0de0b
Renamed inv to the_inv and turned it into an abbreviation (based on the_inv_onto).
berghofe
parents:
32988
diff
changeset
|
797 |
|
|
31b19fa0de0b
Renamed inv to the_inv and turned it into an abbreviation (based on the_inv_onto).
berghofe
parents:
32988
diff
changeset
|
798 |
lemma the_inv_f_f: |
|
31b19fa0de0b
Renamed inv to the_inv and turned it into an abbreviation (based on the_inv_onto).
berghofe
parents:
32988
diff
changeset
|
799 |
assumes "inj f" |
| 63322 | 800 |
shows "the_inv f (f x) = x" |
801 |
using assms UNIV_I by (rule the_inv_into_f_f) |
|
|
32998
31b19fa0de0b
Renamed inv to the_inv and turned it into an abbreviation (based on the_inv_onto).
berghofe
parents:
32988
diff
changeset
|
802 |
|
|
44277
bcb696533579
moved fundamental lemma fun_eq_iff to theory HOL; tuned whitespace
haftmann
parents:
43991
diff
changeset
|
803 |
|
| 60758 | 804 |
subsection \<open>Cantor's Paradox\<close> |
|
40703
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
805 |
|
| 63323 | 806 |
theorem Cantors_paradox: "\<nexists>f. f ` A = Pow A" |
807 |
proof |
|
808 |
assume "\<exists>f. f ` A = Pow A" |
|
809 |
then obtain f where f: "f ` A = Pow A" .. |
|
|
40703
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
810 |
let ?X = "{a \<in> A. a \<notin> f a}"
|
| 63323 | 811 |
have "?X \<in> Pow A" by blast |
812 |
then have "?X \<in> f ` A" by (simp only: f) |
|
813 |
then obtain x where "x \<in> A" and "f x = ?X" by blast |
|
814 |
then show False by blast |
|
|
40703
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
815 |
qed |
| 31949 | 816 |
|
| 63322 | 817 |
|
| 61204 | 818 |
subsection \<open>Setup\<close> |
| 40969 | 819 |
|
| 60758 | 820 |
subsubsection \<open>Proof tools\<close> |
| 22845 | 821 |
|
| 63400 | 822 |
text \<open>Simplify terms of the form \<open>f(\<dots>,x:=y,\<dots>,x:=z,\<dots>)\<close> to \<open>f(\<dots>,x:=z,\<dots>)\<close>\<close> |
| 22845 | 823 |
|
| 60758 | 824 |
simproc_setup fun_upd2 ("f(v := w, x := y)") = \<open>fn _ =>
|
| 63322 | 825 |
let |
826 |
fun gen_fun_upd NONE T _ _ = NONE |
|
827 |
| gen_fun_upd (SOME f) T x y = SOME (Const (@{const_name fun_upd}, T) $ f $ x $ y)
|
|
828 |
fun dest_fun_T1 (Type (_, T :: Ts)) = T |
|
829 |
fun find_double (t as Const (@{const_name fun_upd},T) $ f $ x $ y) =
|
|
830 |
let |
|
831 |
fun find (Const (@{const_name fun_upd},T) $ g $ v $ w) =
|
|
832 |
if v aconv x then SOME g else gen_fun_upd (find g) T v w |
|
833 |
| find t = NONE |
|
834 |
in (dest_fun_T1 T, gen_fun_upd (find f) T x y) end |
|
| 24017 | 835 |
|
| 63322 | 836 |
val ss = simpset_of @{context}
|
|
51717
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
wenzelm
parents:
51598
diff
changeset
|
837 |
|
| 63322 | 838 |
fun proc ctxt ct = |
839 |
let |
|
840 |
val t = Thm.term_of ct |
|
841 |
in |
|
| 63400 | 842 |
(case find_double t of |
| 63322 | 843 |
(T, NONE) => NONE |
844 |
| (T, SOME rhs) => |
|
845 |
SOME (Goal.prove ctxt [] [] (Logic.mk_equals (t, rhs)) |
|
846 |
(fn _ => |
|
847 |
resolve_tac ctxt [eq_reflection] 1 THEN |
|
848 |
resolve_tac ctxt @{thms ext} 1 THEN
|
|
| 63400 | 849 |
simp_tac (put_simpset ss ctxt) 1))) |
| 63322 | 850 |
end |
851 |
in proc end |
|
| 60758 | 852 |
\<close> |
| 22845 | 853 |
|
854 |
||
| 60758 | 855 |
subsubsection \<open>Functorial structure of types\<close> |
| 40969 | 856 |
|
|
55467
a5c9002bc54d
renamed 'enriched_type' to more informative 'functor' (following the renaming of enriched type constructors to bounded natural functors)
blanchet
parents:
55414
diff
changeset
|
857 |
ML_file "Tools/functor.ML" |
| 40969 | 858 |
|
|
55467
a5c9002bc54d
renamed 'enriched_type' to more informative 'functor' (following the renaming of enriched type constructors to bounded natural functors)
blanchet
parents:
55414
diff
changeset
|
859 |
functor map_fun: map_fun |
|
47488
be6dd389639d
centralized enriched_type declaration, thanks to in-situ available Isar commands
haftmann
parents:
46950
diff
changeset
|
860 |
by (simp_all add: fun_eq_iff) |
|
be6dd389639d
centralized enriched_type declaration, thanks to in-situ available Isar commands
haftmann
parents:
46950
diff
changeset
|
861 |
|
|
55467
a5c9002bc54d
renamed 'enriched_type' to more informative 'functor' (following the renaming of enriched type constructors to bounded natural functors)
blanchet
parents:
55414
diff
changeset
|
862 |
functor vimage |
| 49739 | 863 |
by (simp_all add: fun_eq_iff vimage_comp) |
864 |
||
| 63322 | 865 |
|
| 60758 | 866 |
text \<open>Legacy theorem names\<close> |
| 49739 | 867 |
|
868 |
lemmas o_def = comp_def |
|
869 |
lemmas o_apply = comp_apply |
|
870 |
lemmas o_assoc = comp_assoc [symmetric] |
|
871 |
lemmas id_o = id_comp |
|
872 |
lemmas o_id = comp_id |
|
873 |
lemmas o_eq_dest = comp_eq_dest |
|
874 |
lemmas o_eq_elim = comp_eq_elim |
|
| 55066 | 875 |
lemmas o_eq_dest_lhs = comp_eq_dest_lhs |
876 |
lemmas o_eq_id_dest = comp_eq_id_dest |
|
|
47488
be6dd389639d
centralized enriched_type declaration, thanks to in-situ available Isar commands
haftmann
parents:
46950
diff
changeset
|
877 |
|
| 2912 | 878 |
end |