author | wenzelm |
Wed, 17 Aug 2022 15:18:17 +0200 | |
changeset 75885 | 8342cba8eae8 |
parent 75669 | 43f5dfb7fa35 |
child 76056 | c2fd8b88d262 |
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 |
63575 | 10 |
imports Set |
69913 | 11 |
keywords "functor" :: thy_goal_defn |
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 |
||
63575 | 66 |
lemma comp_eq_dest: "a \<circ> b = c \<circ> d \<Longrightarrow> a (b v) = c (d v)" |
49739 | 67 |
by (simp add: fun_eq_iff) |
34150 | 68 |
|
63575 | 69 |
lemma comp_eq_elim: "a \<circ> b = c \<circ> d \<Longrightarrow> ((\<And>v. a (b v) = c (d v)) \<Longrightarrow> R) \<Longrightarrow> R" |
61204 | 70 |
by (simp add: fun_eq_iff) |
34150 | 71 |
|
63322 | 72 |
lemma comp_eq_dest_lhs: "a \<circ> b = c \<Longrightarrow> a (b v) = c v" |
55066 | 73 |
by clarsimp |
74 |
||
63322 | 75 |
lemma comp_eq_id_dest: "a \<circ> b = id \<circ> c \<Longrightarrow> a (b v) = c v" |
76 |
by clarsimp |
|
77 |
||
78 |
lemma image_comp: "f ` (g ` r) = (f \<circ> g) ` r" |
|
33044 | 79 |
by auto |
80 |
||
63322 | 81 |
lemma vimage_comp: "f -` (g -` x) = (g \<circ> f) -` x" |
49739 | 82 |
by auto |
83 |
||
63322 | 84 |
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
|
85 |
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
|
86 |
|
67399 | 87 |
lemma image_bind: "f ` (Set.bind A g) = Set.bind A ((`) f \<circ> g)" |
63322 | 88 |
by (auto simp add: Set.bind_def) |
59512 | 89 |
|
90 |
lemma bind_image: "Set.bind (f ` A) g = Set.bind A (g \<circ> f)" |
|
63322 | 91 |
by (auto simp add: Set.bind_def) |
59512 | 92 |
|
63322 | 93 |
lemma (in group_add) minus_comp_minus [simp]: "uminus \<circ> uminus = id" |
60929 | 94 |
by (simp add: fun_eq_iff) |
95 |
||
74123
7c5842b06114
clarified abstract and concrete boolean algebras
haftmann
parents:
74101
diff
changeset
|
96 |
lemma (in boolean_algebra) minus_comp_minus [simp]: "uminus \<circ> uminus = id" |
60929 | 97 |
by (simp add: fun_eq_iff) |
98 |
||
52435
6646bb548c6b
migration from code_(const|type|class|instance) to code_printing and from code_module to code_identifier
haftmann
parents:
51717
diff
changeset
|
99 |
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
|
100 |
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
|
101 |
|
13585 | 102 |
|
61799 | 103 |
subsection \<open>The Forward Composition Operator \<open>fcomp\<close>\<close> |
26357 | 104 |
|
63575 | 105 |
definition fcomp :: "('a \<Rightarrow> 'b) \<Rightarrow> ('b \<Rightarrow> 'c) \<Rightarrow> 'a \<Rightarrow> 'c" (infixl "\<circ>>" 60) |
63322 | 106 |
where "f \<circ>> g = (\<lambda>x. g (f x))" |
26357 | 107 |
|
37751 | 108 |
lemma fcomp_apply [simp]: "(f \<circ>> g) x = g (f x)" |
26357 | 109 |
by (simp add: fcomp_def) |
110 |
||
37751 | 111 |
lemma fcomp_assoc: "(f \<circ>> g) \<circ>> h = f \<circ>> (g \<circ>> h)" |
26357 | 112 |
by (simp add: fcomp_def) |
113 |
||
37751 | 114 |
lemma id_fcomp [simp]: "id \<circ>> g = g" |
26357 | 115 |
by (simp add: fcomp_def) |
116 |
||
37751 | 117 |
lemma fcomp_id [simp]: "f \<circ>> id = f" |
26357 | 118 |
by (simp add: fcomp_def) |
119 |
||
63322 | 120 |
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
|
121 |
by (simp add: ext) |
a81dc5c4d6a9
New theorems mostly from Peter Gammie
paulson <lp15@cam.ac.uk>
parents:
61630
diff
changeset
|
122 |
|
52435
6646bb548c6b
migration from code_(const|type|class|instance) to code_printing and from code_module to code_identifier
haftmann
parents:
51717
diff
changeset
|
123 |
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
|
124 |
constant fcomp \<rightharpoonup> (Eval) infixl 1 "#>" |
31202
52d332f8f909
pretty printing of functional combinators for evaluation code
haftmann
parents:
31080
diff
changeset
|
125 |
|
37751 | 126 |
no_notation fcomp (infixl "\<circ>>" 60) |
26588
d83271bfaba5
removed syntax from monad combinators; renamed mbind to scomp
haftmann
parents:
26357
diff
changeset
|
127 |
|
26357 | 128 |
|
60758 | 129 |
subsection \<open>Mapping functions\<close> |
40602 | 130 |
|
63322 | 131 |
definition map_fun :: "('c \<Rightarrow> 'a) \<Rightarrow> ('b \<Rightarrow> 'd) \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'c \<Rightarrow> 'd" |
132 |
where "map_fun f g h = g \<circ> h \<circ> f" |
|
40602 | 133 |
|
63322 | 134 |
lemma map_fun_apply [simp]: "map_fun f g h x = g (h (f x))" |
40602 | 135 |
by (simp add: map_fun_def) |
136 |
||
137 |
||
60758 | 138 |
subsection \<open>Injectivity and Bijectivity\<close> |
39076
b3a9b6734663
Introduce surj_on and replace surj and bij by abbreviations.
hoelzl
parents:
39075
diff
changeset
|
139 |
|
63322 | 140 |
definition inj_on :: "('a \<Rightarrow> 'b) \<Rightarrow> 'a set \<Rightarrow> bool" \<comment> \<open>injective\<close> |
141 |
where "inj_on f A \<longleftrightarrow> (\<forall>x\<in>A. \<forall>y\<in>A. f x = f y \<longrightarrow> x = y)" |
|
26147 | 142 |
|
63322 | 143 |
definition bij_betw :: "('a \<Rightarrow> 'b) \<Rightarrow> 'a set \<Rightarrow> 'b set \<Rightarrow> bool" \<comment> \<open>bijective\<close> |
144 |
where "bij_betw f A B \<longleftrightarrow> inj_on f A \<and> f ` A = B" |
|
26147 | 145 |
|
63575 | 146 |
text \<open> |
147 |
A common special case: functions injective, surjective or bijective over |
|
148 |
the entire domain type. |
|
149 |
\<close> |
|
26147 | 150 |
|
65170
53675f36820d
restored surj as output abbreviation, amending 6af79184bef3
haftmann
parents:
64966
diff
changeset
|
151 |
abbreviation inj :: "('a \<Rightarrow> 'b) \<Rightarrow> bool" |
53675f36820d
restored surj as output abbreviation, amending 6af79184bef3
haftmann
parents:
64966
diff
changeset
|
152 |
where "inj f \<equiv> inj_on f UNIV" |
26147 | 153 |
|
65170
53675f36820d
restored surj as output abbreviation, amending 6af79184bef3
haftmann
parents:
64966
diff
changeset
|
154 |
abbreviation surj :: "('a \<Rightarrow> 'b) \<Rightarrow> bool" |
63322 | 155 |
where "surj f \<equiv> range f = UNIV" |
13585 | 156 |
|
67226 | 157 |
translations \<comment> \<open>The negated case:\<close> |
65170
53675f36820d
restored surj as output abbreviation, amending 6af79184bef3
haftmann
parents:
64966
diff
changeset
|
158 |
"\<not> CONST surj f" \<leftharpoondown> "CONST range f \<noteq> CONST UNIV" |
53675f36820d
restored surj as output abbreviation, amending 6af79184bef3
haftmann
parents:
64966
diff
changeset
|
159 |
|
53675f36820d
restored surj as output abbreviation, amending 6af79184bef3
haftmann
parents:
64966
diff
changeset
|
160 |
abbreviation bij :: "('a \<Rightarrow> 'b) \<Rightarrow> bool" |
53675f36820d
restored surj as output abbreviation, amending 6af79184bef3
haftmann
parents:
64966
diff
changeset
|
161 |
where "bij f \<equiv> bij_betw f UNIV UNIV" |
26147 | 162 |
|
64966
d53d7ca3303e
added inj_def (redundant, analogous to surj_def, bij_def);
wenzelm
parents:
64965
diff
changeset
|
163 |
lemma inj_def: "inj f \<longleftrightarrow> (\<forall>x y. f x = f y \<longrightarrow> x = y)" |
d53d7ca3303e
added inj_def (redundant, analogous to surj_def, bij_def);
wenzelm
parents:
64965
diff
changeset
|
164 |
unfolding inj_on_def by blast |
d53d7ca3303e
added inj_def (redundant, analogous to surj_def, bij_def);
wenzelm
parents:
64965
diff
changeset
|
165 |
|
63322 | 166 |
lemma injI: "(\<And>x y. f x = f y \<Longrightarrow> x = y) \<Longrightarrow> inj f" |
64966
d53d7ca3303e
added inj_def (redundant, analogous to surj_def, bij_def);
wenzelm
parents:
64965
diff
changeset
|
167 |
unfolding inj_def by blast |
13585 | 168 |
|
63322 | 169 |
theorem range_ex1_eq: "inj f \<Longrightarrow> b \<in> range f \<longleftrightarrow> (\<exists>!x. b = f x)" |
64966
d53d7ca3303e
added inj_def (redundant, analogous to surj_def, bij_def);
wenzelm
parents:
64965
diff
changeset
|
170 |
unfolding inj_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
|
171 |
|
63322 | 172 |
lemma injD: "inj f \<Longrightarrow> f x = f y \<Longrightarrow> x = y" |
64966
d53d7ca3303e
added inj_def (redundant, analogous to surj_def, bij_def);
wenzelm
parents:
64965
diff
changeset
|
173 |
by (simp add: inj_def) |
63322 | 174 |
|
175 |
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" |
|
64966
d53d7ca3303e
added inj_def (redundant, analogous to surj_def, bij_def);
wenzelm
parents:
64965
diff
changeset
|
176 |
by (auto simp: inj_on_def) |
63322 | 177 |
|
64965 | 178 |
lemma inj_on_cong: "(\<And>a. a \<in> A \<Longrightarrow> f a = g a) \<Longrightarrow> inj_on f A \<longleftrightarrow> inj_on g A" |
64966
d53d7ca3303e
added inj_def (redundant, analogous to surj_def, bij_def);
wenzelm
parents:
64965
diff
changeset
|
179 |
by (auto simp: inj_on_def) |
63322 | 180 |
|
181 |
lemma inj_on_strict_subset: "inj_on f B \<Longrightarrow> A \<subset> B \<Longrightarrow> f ` A \<subset> f ` B" |
|
182 |
unfolding inj_on_def by blast |
|
183 |
||
69700
7a92cbec7030
new material about summations and powers, along with some tweaks
paulson <lp15@cam.ac.uk>
parents:
69661
diff
changeset
|
184 |
lemma inj_compose: "inj f \<Longrightarrow> inj g \<Longrightarrow> inj (f \<circ> g)" |
64966
d53d7ca3303e
added inj_def (redundant, analogous to surj_def, bij_def);
wenzelm
parents:
64965
diff
changeset
|
185 |
by (simp add: inj_def) |
38620 | 186 |
|
187 |
lemma inj_fun: "inj f \<Longrightarrow> inj (\<lambda>x y. f x)" |
|
64966
d53d7ca3303e
added inj_def (redundant, analogous to surj_def, bij_def);
wenzelm
parents:
64965
diff
changeset
|
188 |
by (simp add: inj_def fun_eq_iff) |
38620 | 189 |
|
63322 | 190 |
lemma inj_eq: "inj f \<Longrightarrow> f x = f y \<longleftrightarrow> x = y" |
191 |
by (simp add: inj_on_eq_iff) |
|
32988 | 192 |
|
71827 | 193 |
lemma inj_on_iff_Uniq: "inj_on f A \<longleftrightarrow> (\<forall>x\<in>A. \<exists>\<^sub>\<le>\<^sub>1y. y\<in>A \<and> f x = f y)" |
194 |
by (auto simp: Uniq_def inj_on_def) |
|
195 |
||
26147 | 196 |
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
|
197 |
by (simp add: inj_on_def) |
13585 | 198 |
|
63322 | 199 |
lemma inj_on_id2[simp]: "inj_on (\<lambda>x. x) A" |
200 |
by (simp add: inj_on_def) |
|
26147 | 201 |
|
46586 | 202 |
lemma inj_on_Int: "inj_on f A \<or> inj_on f B \<Longrightarrow> inj_on f (A \<inter> B)" |
63322 | 203 |
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
|
204 |
|
40702 | 205 |
lemma surj_id: "surj id" |
63322 | 206 |
by simp |
26147 | 207 |
|
39101
606432dd1896
Revert bij_betw changes to simp set (Problem in afp/Ordinals_and_Cardinals)
hoelzl
parents:
39076
diff
changeset
|
208 |
lemma bij_id[simp]: "bij id" |
63322 | 209 |
by (simp add: bij_betw_def) |
13585 | 210 |
|
63322 | 211 |
lemma bij_uminus: "bij (uminus :: 'a \<Rightarrow> 'a::ab_group_add)" |
212 |
unfolding bij_betw_def inj_on_def |
|
213 |
by (force intro: minus_minus [symmetric]) |
|
63072 | 214 |
|
72125
cf8399df4d76
elimination of some needless assumptions
paulson <lp15@cam.ac.uk>
parents:
71857
diff
changeset
|
215 |
lemma bij_betwE: "bij_betw f A B \<Longrightarrow> \<forall>a\<in>A. f a \<in> B" |
cf8399df4d76
elimination of some needless assumptions
paulson <lp15@cam.ac.uk>
parents:
71857
diff
changeset
|
216 |
unfolding bij_betw_def by auto |
cf8399df4d76
elimination of some needless assumptions
paulson <lp15@cam.ac.uk>
parents:
71857
diff
changeset
|
217 |
|
63322 | 218 |
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" |
219 |
by (simp add: inj_on_def) |
|
13585 | 220 |
|
63322 | 221 |
lemma inj_on_inverseI: "(\<And>x. x \<in> A \<Longrightarrow> g (f x) = x) \<Longrightarrow> inj_on f A" |
64965 | 222 |
by (auto dest: arg_cong [of concl: g] simp add: inj_on_def) |
13585 | 223 |
|
63322 | 224 |
lemma inj_onD: "inj_on f A \<Longrightarrow> f x = f y \<Longrightarrow> x \<in> A \<Longrightarrow> y \<in> A \<Longrightarrow> x = y" |
225 |
unfolding inj_on_def by blast |
|
13585 | 226 |
|
63365 | 227 |
lemma inj_on_subset: |
228 |
assumes "inj_on f A" |
|
63575 | 229 |
and "B \<subseteq> A" |
63365 | 230 |
shows "inj_on f B" |
231 |
proof (rule inj_onI) |
|
232 |
fix a b |
|
233 |
assume "a \<in> B" and "b \<in> B" |
|
234 |
with assms have "a \<in> A" and "b \<in> A" |
|
235 |
by auto |
|
236 |
moreover assume "f a = f b" |
|
64965 | 237 |
ultimately show "a = b" |
238 |
using assms by (auto dest: inj_onD) |
|
63365 | 239 |
qed |
240 |
||
63322 | 241 |
lemma comp_inj_on: "inj_on f A \<Longrightarrow> inj_on g (f ` A) \<Longrightarrow> inj_on (g \<circ> f) A" |
242 |
by (simp add: comp_def inj_on_def) |
|
243 |
||
244 |
lemma inj_on_imageI: "inj_on (g \<circ> f) A \<Longrightarrow> inj_on g (f ` A)" |
|
63072 | 245 |
by (auto simp add: inj_on_def) |
15303 | 246 |
|
63322 | 247 |
lemma inj_on_image_iff: |
64965 | 248 |
"\<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) \<longleftrightarrow> inj_on g A" |
63322 | 249 |
unfolding inj_on_def by blast |
15439 | 250 |
|
63322 | 251 |
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" |
252 |
unfolding inj_on_def by blast |
|
12258 | 253 |
|
63072 | 254 |
lemma inj_singleton [simp]: "inj_on (\<lambda>x. {x}) A" |
255 |
by (simp add: inj_on_def) |
|
13585 | 256 |
|
15111 | 257 |
lemma inj_on_empty[iff]: "inj_on f {}" |
63322 | 258 |
by (simp add: inj_on_def) |
13585 | 259 |
|
63322 | 260 |
lemma subset_inj_on: "inj_on f B \<Longrightarrow> A \<subseteq> B \<Longrightarrow> inj_on f A" |
261 |
unfolding inj_on_def by blast |
|
262 |
||
263 |
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) = {}" |
|
264 |
unfolding inj_on_def by (blast intro: sym) |
|
15111 | 265 |
|
63322 | 266 |
lemma inj_on_insert [iff]: "inj_on f (insert a A) \<longleftrightarrow> inj_on f A \<and> f a \<notin> f ` (A - {a})" |
267 |
unfolding inj_on_def by (blast intro: sym) |
|
268 |
||
269 |
lemma inj_on_diff: "inj_on f A \<Longrightarrow> inj_on f (A - B)" |
|
270 |
unfolding inj_on_def by blast |
|
15111 | 271 |
|
63322 | 272 |
lemma comp_inj_on_iff: "inj_on f A \<Longrightarrow> inj_on f' (f ` A) \<longleftrightarrow> inj_on (f' \<circ> f) A" |
64965 | 273 |
by (auto simp: comp_inj_on inj_on_def) |
15111 | 274 |
|
63322 | 275 |
lemma inj_on_imageI2: "inj_on (f' \<circ> f) A \<Longrightarrow> inj_on f A" |
64965 | 276 |
by (auto simp: 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
|
277 |
|
51598
5dbe537087aa
generalized lemma fold_image thanks to Peter Lammich
haftmann
parents:
49905
diff
changeset
|
278 |
lemma inj_img_insertE: |
5dbe537087aa
generalized lemma fold_image thanks to Peter Lammich
haftmann
parents:
49905
diff
changeset
|
279 |
assumes "inj_on f A" |
63322 | 280 |
assumes "x \<notin> B" |
281 |
and "insert x B = f ` A" |
|
282 |
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
|
283 |
proof - |
5dbe537087aa
generalized lemma fold_image thanks to Peter Lammich
haftmann
parents:
49905
diff
changeset
|
284 |
from assms have "x \<in> f ` A" by auto |
5dbe537087aa
generalized lemma fold_image thanks to Peter Lammich
haftmann
parents:
49905
diff
changeset
|
285 |
then obtain x' where *: "x' \<in> A" "x = f x'" by auto |
63322 | 286 |
then have A: "A = insert x' (A - {x'})" by auto |
287 |
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
|
288 |
have "x' \<notin> A - {x'}" by simp |
63322 | 289 |
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
|
290 |
qed |
5dbe537087aa
generalized lemma fold_image thanks to Peter Lammich
haftmann
parents:
49905
diff
changeset
|
291 |
|
71404
f2b783abfbe7
A few lemmas connected with orderings
paulson <lp15@cam.ac.uk>
parents:
69913
diff
changeset
|
292 |
lemma linorder_inj_onI: |
f2b783abfbe7
A few lemmas connected with orderings
paulson <lp15@cam.ac.uk>
parents:
69913
diff
changeset
|
293 |
fixes A :: "'a::order set" |
f2b783abfbe7
A few lemmas connected with orderings
paulson <lp15@cam.ac.uk>
parents:
69913
diff
changeset
|
294 |
assumes ne: "\<And>x y. \<lbrakk>x < y; x\<in>A; y\<in>A\<rbrakk> \<Longrightarrow> f x \<noteq> f y" and lin: "\<And>x y. \<lbrakk>x\<in>A; y\<in>A\<rbrakk> \<Longrightarrow> x\<le>y \<or> y\<le>x" |
f2b783abfbe7
A few lemmas connected with orderings
paulson <lp15@cam.ac.uk>
parents:
69913
diff
changeset
|
295 |
shows "inj_on f A" |
f2b783abfbe7
A few lemmas connected with orderings
paulson <lp15@cam.ac.uk>
parents:
69913
diff
changeset
|
296 |
proof (rule inj_onI) |
f2b783abfbe7
A few lemmas connected with orderings
paulson <lp15@cam.ac.uk>
parents:
69913
diff
changeset
|
297 |
fix x y |
f2b783abfbe7
A few lemmas connected with orderings
paulson <lp15@cam.ac.uk>
parents:
69913
diff
changeset
|
298 |
assume eq: "f x = f y" and "x\<in>A" "y\<in>A" |
f2b783abfbe7
A few lemmas connected with orderings
paulson <lp15@cam.ac.uk>
parents:
69913
diff
changeset
|
299 |
then show "x = y" |
f2b783abfbe7
A few lemmas connected with orderings
paulson <lp15@cam.ac.uk>
parents:
69913
diff
changeset
|
300 |
using lin [of x y] ne by (force simp: dual_order.order_iff_strict) |
f2b783abfbe7
A few lemmas connected with orderings
paulson <lp15@cam.ac.uk>
parents:
69913
diff
changeset
|
301 |
qed |
f2b783abfbe7
A few lemmas connected with orderings
paulson <lp15@cam.ac.uk>
parents:
69913
diff
changeset
|
302 |
|
54578
9387251b6a46
eliminated dependence of BNF on Infinite_Set by moving 3 theorems from the latter to Main
traytel
parents:
54147
diff
changeset
|
303 |
lemma linorder_injI: |
64965 | 304 |
assumes "\<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
|
305 |
shows "inj f" |
71404
f2b783abfbe7
A few lemmas connected with orderings
paulson <lp15@cam.ac.uk>
parents:
69913
diff
changeset
|
306 |
\<comment> \<open>Courtesy of Stephan Merz\<close> |
f2b783abfbe7
A few lemmas connected with orderings
paulson <lp15@cam.ac.uk>
parents:
69913
diff
changeset
|
307 |
using assms by (auto intro: linorder_inj_onI linear) |
69735
8230dca028eb
the theory of Equipollence, and moving Fpow from Cardinals into Main
paulson <lp15@cam.ac.uk>
parents:
69700
diff
changeset
|
308 |
|
8230dca028eb
the theory of Equipollence, and moving Fpow from Cardinals into Main
paulson <lp15@cam.ac.uk>
parents:
69700
diff
changeset
|
309 |
lemma inj_on_image_Pow: "inj_on f A \<Longrightarrow>inj_on (image f) (Pow A)" |
8230dca028eb
the theory of Equipollence, and moving Fpow from Cardinals into Main
paulson <lp15@cam.ac.uk>
parents:
69700
diff
changeset
|
310 |
unfolding Pow_def inj_on_def by blast |
8230dca028eb
the theory of Equipollence, and moving Fpow from Cardinals into Main
paulson <lp15@cam.ac.uk>
parents:
69700
diff
changeset
|
311 |
|
8230dca028eb
the theory of Equipollence, and moving Fpow from Cardinals into Main
paulson <lp15@cam.ac.uk>
parents:
69700
diff
changeset
|
312 |
lemma bij_betw_image_Pow: "bij_betw f A B \<Longrightarrow> bij_betw (image f) (Pow A) (Pow B)" |
8230dca028eb
the theory of Equipollence, and moving Fpow from Cardinals into Main
paulson <lp15@cam.ac.uk>
parents:
69700
diff
changeset
|
313 |
by (auto simp add: bij_betw_def inj_on_image_Pow image_Pow_surj) |
8230dca028eb
the theory of Equipollence, and moving Fpow from Cardinals into Main
paulson <lp15@cam.ac.uk>
parents:
69700
diff
changeset
|
314 |
|
40702 | 315 |
lemma surj_def: "surj f \<longleftrightarrow> (\<forall>y. \<exists>x. y = f x)" |
316 |
by auto |
|
39076
b3a9b6734663
Introduce surj_on and replace surj and bij by abbreviations.
hoelzl
parents:
39075
diff
changeset
|
317 |
|
63322 | 318 |
lemma surjI: |
64965 | 319 |
assumes "\<And>x. g (f x) = x" |
63322 | 320 |
shows "surj g" |
64965 | 321 |
using assms [symmetric] by auto |
13585 | 322 |
|
39076
b3a9b6734663
Introduce surj_on and replace surj and bij by abbreviations.
hoelzl
parents:
39075
diff
changeset
|
323 |
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
|
324 |
by (simp add: surj_def) |
13585 | 325 |
|
39076
b3a9b6734663
Introduce surj_on and replace surj and bij by abbreviations.
hoelzl
parents:
39075
diff
changeset
|
326 |
lemma surjE: "surj f \<Longrightarrow> (\<And>x. y = f x \<Longrightarrow> C) \<Longrightarrow> C" |
63575 | 327 |
by (simp add: surj_def) blast |
13585 | 328 |
|
63322 | 329 |
lemma comp_surj: "surj f \<Longrightarrow> surj g \<Longrightarrow> surj (g \<circ> f)" |
69768 | 330 |
using image_comp [of g f UNIV] by simp |
13585 | 331 |
|
63322 | 332 |
lemma bij_betw_imageI: "inj_on f A \<Longrightarrow> f ` A = B \<Longrightarrow> bij_betw f A B" |
333 |
unfolding bij_betw_def by clarify |
|
57282 | 334 |
|
335 |
lemma bij_betw_imp_surj_on: "bij_betw f A B \<Longrightarrow> f ` A = B" |
|
336 |
unfolding bij_betw_def by clarify |
|
337 |
||
39074 | 338 |
lemma bij_betw_imp_surj: "bij_betw f A UNIV \<Longrightarrow> surj f" |
40702 | 339 |
unfolding bij_betw_def by auto |
39074 | 340 |
|
63322 | 341 |
lemma bij_betw_empty1: "bij_betw f {} A \<Longrightarrow> A = {}" |
342 |
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
|
343 |
|
63322 | 344 |
lemma bij_betw_empty2: "bij_betw f A {} \<Longrightarrow> A = {}" |
345 |
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
|
346 |
|
63322 | 347 |
lemma inj_on_imp_bij_betw: "inj_on f A \<Longrightarrow> bij_betw f A (f ` A)" |
348 |
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
|
349 |
|
71464 | 350 |
lemma bij_betw_apply: "\<lbrakk>bij_betw f A B; a \<in> A\<rbrakk> \<Longrightarrow> f a \<in> B" |
351 |
unfolding bij_betw_def by auto |
|
352 |
||
39076
b3a9b6734663
Introduce surj_on and replace surj and bij by abbreviations.
hoelzl
parents:
39075
diff
changeset
|
353 |
lemma bij_def: "bij f \<longleftrightarrow> inj f \<and> surj f" |
64965 | 354 |
by (rule bij_betw_def) |
39074 | 355 |
|
63322 | 356 |
lemma bijI: "inj f \<Longrightarrow> surj f \<Longrightarrow> bij f" |
64965 | 357 |
by (rule bij_betw_imageI) |
13585 | 358 |
|
63322 | 359 |
lemma bij_is_inj: "bij f \<Longrightarrow> inj f" |
360 |
by (simp add: bij_def) |
|
13585 | 361 |
|
63322 | 362 |
lemma bij_is_surj: "bij f \<Longrightarrow> surj f" |
363 |
by (simp add: bij_def) |
|
13585 | 364 |
|
26105
ae06618225ec
moved bij_betw from Library/FuncSet to Fun, redistributed some lemmas, and
nipkow
parents:
25886
diff
changeset
|
365 |
lemma bij_betw_imp_inj_on: "bij_betw f A B \<Longrightarrow> inj_on f A" |
63322 | 366 |
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
|
367 |
|
63322 | 368 |
lemma bij_betw_trans: "bij_betw f A B \<Longrightarrow> bij_betw g B C \<Longrightarrow> bij_betw (g \<circ> f) A C" |
369 |
by (auto simp add:bij_betw_def comp_inj_on) |
|
31438 | 370 |
|
63322 | 371 |
lemma bij_comp: "bij f \<Longrightarrow> bij g \<Longrightarrow> bij (g \<circ> f)" |
40702 | 372 |
by (rule bij_betw_trans) |
373 |
||
63322 | 374 |
lemma bij_betw_comp_iff: "bij_betw f A A' \<Longrightarrow> bij_betw f' A' A'' \<longleftrightarrow> bij_betw (f' \<circ> f) A A''" |
375 |
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
|
376 |
|
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
377 |
lemma bij_betw_comp_iff2: |
63322 | 378 |
assumes bij: "bij_betw f' A' A''" |
379 |
and img: "f ` A \<le> A'" |
|
75669
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents:
75624
diff
changeset
|
380 |
shows "bij_betw f A A' \<longleftrightarrow> bij_betw (f' \<circ> f) A A''" (is "?L \<longleftrightarrow> ?R") |
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents:
75624
diff
changeset
|
381 |
proof |
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents:
75624
diff
changeset
|
382 |
assume "?L" |
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents:
75624
diff
changeset
|
383 |
then show "?R" |
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents:
75624
diff
changeset
|
384 |
using assms by (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
|
385 |
next |
75669
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents:
75624
diff
changeset
|
386 |
assume *: "?R" |
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents:
75624
diff
changeset
|
387 |
have "inj_on (f' \<circ> f) A \<Longrightarrow> inj_on f A" |
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents:
75624
diff
changeset
|
388 |
using inj_on_imageI2 by blast |
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents:
75624
diff
changeset
|
389 |
moreover have "A' \<subseteq> f ` A" |
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents:
75624
diff
changeset
|
390 |
proof |
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents:
75624
diff
changeset
|
391 |
fix a' |
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents:
75624
diff
changeset
|
392 |
assume **: "a' \<in> A'" |
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents:
75624
diff
changeset
|
393 |
with bij have "f' a' \<in> A''" |
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents:
75624
diff
changeset
|
394 |
unfolding bij_betw_def by auto |
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents:
75624
diff
changeset
|
395 |
with * obtain a where 1: "a \<in> A \<and> f' (f a) = f' a'" |
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents:
75624
diff
changeset
|
396 |
unfolding bij_betw_def by force |
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents:
75624
diff
changeset
|
397 |
with img have "f a \<in> A'" by auto |
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents:
75624
diff
changeset
|
398 |
with bij ** 1 have "f a = a'" |
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents:
75624
diff
changeset
|
399 |
unfolding bij_betw_def inj_on_def by auto |
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents:
75624
diff
changeset
|
400 |
with 1 show "a' \<in> f ` A" by auto |
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents:
75624
diff
changeset
|
401 |
qed |
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents:
75624
diff
changeset
|
402 |
ultimately show "?L" |
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents:
75624
diff
changeset
|
403 |
using img * 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
|
404 |
qed |
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
405 |
|
63322 | 406 |
lemma bij_betw_inv: |
407 |
assumes "bij_betw f A B" |
|
408 |
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
|
409 |
proof - |
ae06618225ec
moved bij_betw from Library/FuncSet to Fun, redistributed some lemmas, and
nipkow
parents:
25886
diff
changeset
|
410 |
have i: "inj_on f A" and s: "f ` A = B" |
63322 | 411 |
using assms by (auto simp: bij_betw_def) |
412 |
let ?P = "\<lambda>b a. a \<in> A \<and> f a = b" |
|
413 |
let ?g = "\<lambda>b. The (?P b)" |
|
414 |
have g: "?g b = a" if P: "?P b a" for a b |
|
415 |
proof - |
|
63575 | 416 |
from that s have ex1: "\<exists>a. ?P b a" by blast |
63322 | 417 |
then have uex1: "\<exists>!a. ?P b a" by (blast dest:inj_onD[OF i]) |
63575 | 418 |
then show ?thesis |
419 |
using the1_equality[OF uex1, OF P] P by simp |
|
63322 | 420 |
qed |
26105
ae06618225ec
moved bij_betw from Library/FuncSet to Fun, redistributed some lemmas, and
nipkow
parents:
25886
diff
changeset
|
421 |
have "inj_on ?g B" |
63322 | 422 |
proof (rule inj_onI) |
423 |
fix x y |
|
424 |
assume "x \<in> B" "y \<in> B" "?g x = ?g y" |
|
425 |
from s \<open>x \<in> B\<close> obtain a1 where a1: "?P x a1" by blast |
|
426 |
from s \<open>y \<in> B\<close> obtain a2 where a2: "?P y a2" by blast |
|
427 |
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
|
428 |
qed |
ae06618225ec
moved bij_betw from Library/FuncSet to Fun, redistributed some lemmas, and
nipkow
parents:
25886
diff
changeset
|
429 |
moreover have "?g ` B = A" |
75669
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents:
75624
diff
changeset
|
430 |
proof safe |
63322 | 431 |
fix b |
432 |
assume "b \<in> B" |
|
56077 | 433 |
with s obtain a where P: "?P b a" by blast |
63575 | 434 |
with g[OF P] show "?g b \<in> A" by auto |
26105
ae06618225ec
moved bij_betw from Library/FuncSet to Fun, redistributed some lemmas, and
nipkow
parents:
25886
diff
changeset
|
435 |
next |
63322 | 436 |
fix a |
437 |
assume "a \<in> A" |
|
63575 | 438 |
with s obtain b where P: "?P b a" by blast |
439 |
with s have "b \<in> B" by blast |
|
75669
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents:
75624
diff
changeset
|
440 |
with g[OF P] have "\<exists>b\<in>B. a = ?g b" by blast |
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents:
75624
diff
changeset
|
441 |
then show "a \<in> ?g ` B" |
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents:
75624
diff
changeset
|
442 |
by auto |
26105
ae06618225ec
moved bij_betw from Library/FuncSet to Fun, redistributed some lemmas, and
nipkow
parents:
25886
diff
changeset
|
443 |
qed |
63575 | 444 |
ultimately show ?thesis |
445 |
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
|
446 |
qed |
ae06618225ec
moved bij_betw from Library/FuncSet to Fun, redistributed some lemmas, and
nipkow
parents:
25886
diff
changeset
|
447 |
|
63588 | 448 |
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'" |
63591 | 449 |
unfolding bij_betw_def inj_on_def by safe force+ (* somewhat slow *) |
40703
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
hoelzl
parents:
40702
diff
changeset
|
450 |
|
63322 | 451 |
lemma bij_betw_id[intro, simp]: "bij_betw id A A" |
452 |
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
|
453 |
|
63322 | 454 |
lemma bij_betw_id_iff: "bij_betw id A B \<longleftrightarrow> A = B" |
455 |
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
|
456 |
|
39075 | 457 |
lemma bij_betw_combine: |
63400 | 458 |
"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)" |
459 |
unfolding bij_betw_def inj_on_Un image_Un by auto |
|
39075 | 460 |
|
64966
d53d7ca3303e
added inj_def (redundant, analogous to surj_def, bij_def);
wenzelm
parents:
64965
diff
changeset
|
461 |
lemma bij_betw_subset: "bij_betw f A A' \<Longrightarrow> B \<subseteq> A \<Longrightarrow> f ` B = B' \<Longrightarrow> bij_betw f B B'" |
63322 | 462 |
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
|
463 |
|
75624 | 464 |
lemma bij_betw_ball: "bij_betw f A B \<Longrightarrow> (\<forall>b \<in> B. phi b) = (\<forall>a \<in> A. phi (f a))" |
465 |
unfolding bij_betw_def inj_on_def by blast |
|
466 |
||
58195 | 467 |
lemma bij_pointE: |
468 |
assumes "bij f" |
|
469 |
obtains x where "y = f x" and "\<And>x'. y = f x' \<Longrightarrow> x' = x" |
|
470 |
proof - |
|
471 |
from assms have "inj f" by (rule bij_is_inj) |
|
472 |
moreover from assms have "surj f" by (rule bij_is_surj) |
|
473 |
then have "y \<in> range f" by simp |
|
474 |
ultimately have "\<exists>!x. y = f x" by (simp add: range_ex1_eq) |
|
475 |
with that show thesis by blast |
|
476 |
qed |
|
477 |
||
73326 | 478 |
lemma bij_iff: \<^marker>\<open>contributor \<open>Amine Chaieb\<close>\<close> |
479 |
\<open>bij f \<longleftrightarrow> (\<forall>x. \<exists>!y. f y = x)\<close> (is \<open>?P \<longleftrightarrow> ?Q\<close>) |
|
480 |
proof |
|
481 |
assume ?P |
|
482 |
then have \<open>inj f\<close> \<open>surj f\<close> |
|
483 |
by (simp_all add: bij_def) |
|
484 |
show ?Q |
|
485 |
proof |
|
486 |
fix y |
|
487 |
from \<open>surj f\<close> obtain x where \<open>y = f x\<close> |
|
488 |
by (auto simp add: surj_def) |
|
489 |
with \<open>inj f\<close> show \<open>\<exists>!x. f x = y\<close> |
|
490 |
by (auto simp add: inj_def) |
|
491 |
qed |
|
492 |
next |
|
493 |
assume ?Q |
|
494 |
then have \<open>inj f\<close> |
|
495 |
by (auto simp add: inj_def) |
|
496 |
moreover have \<open>\<exists>x. y = f x\<close> for y |
|
497 |
proof - |
|
498 |
from \<open>?Q\<close> obtain x where \<open>f x = y\<close> |
|
499 |
by blast |
|
500 |
then have \<open>y = f x\<close> |
|
501 |
by simp |
|
502 |
then show ?thesis .. |
|
503 |
qed |
|
504 |
then have \<open>surj f\<close> |
|
505 |
by (auto simp add: surj_def) |
|
506 |
ultimately show ?P |
|
507 |
by (rule bijI) |
|
508 |
qed |
|
509 |
||
73466 | 510 |
lemma bij_betw_partition: |
511 |
\<open>bij_betw f A B\<close> |
|
512 |
if \<open>bij_betw f (A \<union> C) (B \<union> D)\<close> \<open>bij_betw f C D\<close> \<open>A \<inter> C = {}\<close> \<open>B \<inter> D = {}\<close> |
|
513 |
proof - |
|
514 |
from that have \<open>inj_on f (A \<union> C)\<close> \<open>inj_on f C\<close> \<open>f ` (A \<union> C) = B \<union> D\<close> \<open>f ` C = D\<close> |
|
515 |
by (simp_all add: bij_betw_def) |
|
516 |
then have \<open>inj_on f A\<close> and \<open>f ` (A - C) \<inter> f ` (C - A) = {}\<close> |
|
517 |
by (simp_all add: inj_on_Un) |
|
518 |
with \<open>A \<inter> C = {}\<close> have \<open>f ` A \<inter> f ` C = {}\<close> |
|
519 |
by auto |
|
520 |
with \<open>f ` (A \<union> C) = B \<union> D\<close> \<open>f ` C = D\<close> \<open>B \<inter> D = {}\<close> |
|
521 |
have \<open>f ` A = B\<close> |
|
522 |
by blast |
|
523 |
with \<open>inj_on f A\<close> show ?thesis |
|
524 |
by (simp add: bij_betw_def) |
|
525 |
qed |
|
526 |
||
63322 | 527 |
lemma surj_image_vimage_eq: "surj f \<Longrightarrow> f ` (f -` A) = A" |
528 |
by simp |
|
13585 | 529 |
|
42903 | 530 |
lemma surj_vimage_empty: |
63322 | 531 |
assumes "surj f" |
532 |
shows "f -` A = {} \<longleftrightarrow> A = {}" |
|
533 |
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
|
534 |
by (intro iffI) fastforce+ |
42903 | 535 |
|
63322 | 536 |
lemma inj_vimage_image_eq: "inj f \<Longrightarrow> f -` (f ` A) = A" |
64966
d53d7ca3303e
added inj_def (redundant, analogous to surj_def, bij_def);
wenzelm
parents:
64965
diff
changeset
|
537 |
unfolding inj_def by blast |
13585 | 538 |
|
63322 | 539 |
lemma vimage_subsetD: "surj f \<Longrightarrow> f -` B \<subseteq> A \<Longrightarrow> B \<subseteq> f ` A" |
540 |
by (blast intro: sym) |
|
13585 | 541 |
|
63322 | 542 |
lemma vimage_subsetI: "inj f \<Longrightarrow> B \<subseteq> f ` A \<Longrightarrow> f -` B \<subseteq> A" |
64966
d53d7ca3303e
added inj_def (redundant, analogous to surj_def, bij_def);
wenzelm
parents:
64965
diff
changeset
|
543 |
unfolding inj_def by blast |
13585 | 544 |
|
63322 | 545 |
lemma vimage_subset_eq: "bij f \<Longrightarrow> f -` B \<subseteq> A \<longleftrightarrow> B \<subseteq> f ` A" |
546 |
unfolding bij_def by (blast del: subsetI intro: vimage_subsetI vimage_subsetD) |
|
13585 | 547 |
|
63322 | 548 |
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" |
64965 | 549 |
by (fastforce simp: inj_on_def) |
53927 | 550 |
|
31438 | 551 |
lemma inj_on_Un_image_eq_iff: "inj_on f (A \<union> B) \<Longrightarrow> f ` A = f ` B \<longleftrightarrow> A = B" |
63322 | 552 |
by (erule inj_on_image_eq_iff) simp_all |
31438 | 553 |
|
63322 | 554 |
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" |
555 |
unfolding inj_on_def by blast |
|
556 |
||
557 |
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" |
|
558 |
unfolding inj_on_def by blast |
|
13585 | 559 |
|
63322 | 560 |
lemma image_Int: "inj f \<Longrightarrow> f ` (A \<inter> B) = f ` A \<inter> f ` B" |
64966
d53d7ca3303e
added inj_def (redundant, analogous to surj_def, bij_def);
wenzelm
parents:
64965
diff
changeset
|
561 |
unfolding inj_def by blast |
13585 | 562 |
|
63322 | 563 |
lemma image_set_diff: "inj f \<Longrightarrow> f ` (A - B) = f ` A - f ` B" |
64966
d53d7ca3303e
added inj_def (redundant, analogous to surj_def, bij_def);
wenzelm
parents:
64965
diff
changeset
|
564 |
unfolding inj_def by blast |
13585 | 565 |
|
63322 | 566 |
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
|
567 |
by (auto simp: inj_on_def) |
8c6747dba731
New lemmas and a bit of tidying up.
paulson <lp15@cam.ac.uk>
parents:
58889
diff
changeset
|
568 |
|
63322 | 569 |
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
|
570 |
by (blast dest: injD) |
13585 | 571 |
|
63322 | 572 |
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
|
573 |
by (blast dest: injD) |
13585 | 574 |
|
63322 | 575 |
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
|
576 |
by (blast dest: injD) |
13585 | 577 |
|
63322 | 578 |
lemma surj_Compl_image_subset: "surj f \<Longrightarrow> - (f ` A) \<subseteq> f ` (- A)" |
579 |
by auto |
|
5852 | 580 |
|
63322 | 581 |
lemma inj_image_Compl_subset: "inj f \<Longrightarrow> f ` (- A) \<subseteq> - (f ` A)" |
64966
d53d7ca3303e
added inj_def (redundant, analogous to surj_def, bij_def);
wenzelm
parents:
64965
diff
changeset
|
582 |
by (auto simp: inj_def) |
63322 | 583 |
|
584 |
lemma bij_image_Compl_eq: "bij f \<Longrightarrow> f ` (- A) = - (f ` A)" |
|
585 |
by (simp add: bij_def inj_image_Compl_subset surj_Compl_image_subset equalityI) |
|
13585 | 586 |
|
41657 | 587 |
lemma inj_vimage_singleton: "inj f \<Longrightarrow> f -` {a} \<subseteq> {THE x. f x = a}" |
63322 | 588 |
\<comment> \<open>The inverse image of a singleton under an injective function is included in a singleton.\<close> |
64966
d53d7ca3303e
added inj_def (redundant, analogous to surj_def, bij_def);
wenzelm
parents:
64965
diff
changeset
|
589 |
by (simp add: inj_def) (blast intro: the_equality [symmetric]) |
41657 | 590 |
|
63322 | 591 |
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 | 592 |
by (auto simp add: inj_on_def intro: the_equality [symmetric]) |
593 |
||
35584
768f8d92b767
generalized inj_uminus; added strict_mono_imp_inj_on
hoelzl
parents:
35580
diff
changeset
|
594 |
lemma (in ordered_ab_group_add) inj_uminus[simp, intro]: "inj_on uminus A" |
35580 | 595 |
by (auto intro!: inj_onI) |
13585 | 596 |
|
35584
768f8d92b767
generalized inj_uminus; added strict_mono_imp_inj_on
hoelzl
parents:
35580
diff
changeset
|
597 |
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
|
598 |
by (auto intro!: inj_onI dest: strict_mono_eq) |
768f8d92b767
generalized inj_uminus; added strict_mono_imp_inj_on
hoelzl
parents:
35580
diff
changeset
|
599 |
|
55019
0d5e831175de
moved lemmas from 'Fun_More_FP' to where they belong
blanchet
parents:
54578
diff
changeset
|
600 |
lemma bij_betw_byWitness: |
63322 | 601 |
assumes left: "\<forall>a \<in> A. f' (f a) = a" |
602 |
and right: "\<forall>a' \<in> A'. f (f' a') = a'" |
|
63575 | 603 |
and "f ` A \<subseteq> A'" |
604 |
and img2: "f' ` A' \<subseteq> A" |
|
63322 | 605 |
shows "bij_betw f A A'" |
606 |
using assms |
|
63400 | 607 |
unfolding bij_betw_def inj_on_def |
608 |
proof safe |
|
63322 | 609 |
fix a b |
63575 | 610 |
assume "a \<in> A" "b \<in> A" |
611 |
with left have "a = f' (f a) \<and> b = f' (f b)" by simp |
|
612 |
moreover assume "f a = f b" |
|
613 |
ultimately show "a = b" by simp |
|
55019
0d5e831175de
moved lemmas from 'Fun_More_FP' to where they belong
blanchet
parents:
54578
diff
changeset
|
614 |
next |
0d5e831175de
moved lemmas from 'Fun_More_FP' to where they belong
blanchet
parents:
54578
diff
changeset
|
615 |
fix a' assume *: "a' \<in> A'" |
63575 | 616 |
with img2 have "f' a' \<in> A" by blast |
617 |
moreover from * right have "a' = f (f' a')" by simp |
|
55019
0d5e831175de
moved lemmas from 'Fun_More_FP' to where they belong
blanchet
parents:
54578
diff
changeset
|
618 |
ultimately show "a' \<in> f ` A" by blast |
0d5e831175de
moved lemmas from 'Fun_More_FP' to where they belong
blanchet
parents:
54578
diff
changeset
|
619 |
qed |
0d5e831175de
moved lemmas from 'Fun_More_FP' to where they belong
blanchet
parents:
54578
diff
changeset
|
620 |
|
0d5e831175de
moved lemmas from 'Fun_More_FP' to where they belong
blanchet
parents:
54578
diff
changeset
|
621 |
corollary notIn_Un_bij_betw: |
63322 | 622 |
assumes "b \<notin> A" |
623 |
and "f b \<notin> A'" |
|
624 |
and "bij_betw f A A'" |
|
625 |
shows "bij_betw f (A \<union> {b}) (A' \<union> {f b})" |
|
626 |
proof - |
|
55019
0d5e831175de
moved lemmas from 'Fun_More_FP' to where they belong
blanchet
parents:
54578
diff
changeset
|
627 |
have "bij_betw f {b} {f b}" |
63322 | 628 |
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
|
629 |
with assms show ?thesis |
63322 | 630 |
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
|
631 |
qed |
0d5e831175de
moved lemmas from 'Fun_More_FP' to where they belong
blanchet
parents:
54578
diff
changeset
|
632 |
|
0d5e831175de
moved lemmas from 'Fun_More_FP' to where they belong
blanchet
parents:
54578
diff
changeset
|
633 |
lemma notIn_Un_bij_betw3: |
63322 | 634 |
assumes "b \<notin> A" |
635 |
and "f b \<notin> A'" |
|
636 |
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
|
637 |
proof |
0d5e831175de
moved lemmas from 'Fun_More_FP' to where they belong
blanchet
parents:
54578
diff
changeset
|
638 |
assume "bij_betw f A A'" |
63322 | 639 |
then show "bij_betw f (A \<union> {b}) (A' \<union> {f b})" |
640 |
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
|
641 |
next |
0d5e831175de
moved lemmas from 'Fun_More_FP' to where they belong
blanchet
parents:
54578
diff
changeset
|
642 |
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
|
643 |
have "f ` A = A'" |
75669
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents:
75624
diff
changeset
|
644 |
proof safe |
63322 | 645 |
fix a |
646 |
assume **: "a \<in> A" |
|
647 |
then have "f a \<in> A' \<union> {f b}" |
|
648 |
using * unfolding bij_betw_def by blast |
|
55019
0d5e831175de
moved lemmas from 'Fun_More_FP' to where they belong
blanchet
parents:
54578
diff
changeset
|
649 |
moreover |
63322 | 650 |
have False if "f a = f b" |
651 |
proof - |
|
63575 | 652 |
have "a = b" |
653 |
using * ** that unfolding bij_betw_def inj_on_def by blast |
|
63322 | 654 |
with \<open>b \<notin> A\<close> ** show ?thesis by blast |
655 |
qed |
|
55019
0d5e831175de
moved lemmas from 'Fun_More_FP' to where they belong
blanchet
parents:
54578
diff
changeset
|
656 |
ultimately show "f a \<in> A'" by blast |
0d5e831175de
moved lemmas from 'Fun_More_FP' to where they belong
blanchet
parents:
54578
diff
changeset
|
657 |
next |
63322 | 658 |
fix a' |
659 |
assume **: "a' \<in> A'" |
|
660 |
then have "a' \<in> f ` (A \<union> {b})" |
|
661 |
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
|
662 |
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
|
663 |
moreover |
63322 | 664 |
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
|
665 |
ultimately have "a \<in> A" by blast |
0d5e831175de
moved lemmas from 'Fun_More_FP' to where they belong
blanchet
parents:
54578
diff
changeset
|
666 |
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
|
667 |
qed |
63322 | 668 |
then show "bij_betw f A A'" |
669 |
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
|
670 |
qed |
0d5e831175de
moved lemmas from 'Fun_More_FP' to where they belong
blanchet
parents:
54578
diff
changeset
|
671 |
|
71857
d73955442df5
a few new lemmas about functions
paulson <lp15@cam.ac.uk>
parents:
71827
diff
changeset
|
672 |
lemma inj_on_disjoint_Un: |
d73955442df5
a few new lemmas about functions
paulson <lp15@cam.ac.uk>
parents:
71827
diff
changeset
|
673 |
assumes "inj_on f A" and "inj_on g B" |
d73955442df5
a few new lemmas about functions
paulson <lp15@cam.ac.uk>
parents:
71827
diff
changeset
|
674 |
and "f ` A \<inter> g ` B = {}" |
d73955442df5
a few new lemmas about functions
paulson <lp15@cam.ac.uk>
parents:
71827
diff
changeset
|
675 |
shows "inj_on (\<lambda>x. if x \<in> A then f x else g x) (A \<union> B)" |
d73955442df5
a few new lemmas about functions
paulson <lp15@cam.ac.uk>
parents:
71827
diff
changeset
|
676 |
using assms by (simp add: inj_on_def disjoint_iff) (blast) |
d73955442df5
a few new lemmas about functions
paulson <lp15@cam.ac.uk>
parents:
71827
diff
changeset
|
677 |
|
d73955442df5
a few new lemmas about functions
paulson <lp15@cam.ac.uk>
parents:
71827
diff
changeset
|
678 |
lemma bij_betw_disjoint_Un: |
d73955442df5
a few new lemmas about functions
paulson <lp15@cam.ac.uk>
parents:
71827
diff
changeset
|
679 |
assumes "bij_betw f A C" and "bij_betw g B D" |
d73955442df5
a few new lemmas about functions
paulson <lp15@cam.ac.uk>
parents:
71827
diff
changeset
|
680 |
and "A \<inter> B = {}" |
d73955442df5
a few new lemmas about functions
paulson <lp15@cam.ac.uk>
parents:
71827
diff
changeset
|
681 |
and "C \<inter> D = {}" |
d73955442df5
a few new lemmas about functions
paulson <lp15@cam.ac.uk>
parents:
71827
diff
changeset
|
682 |
shows "bij_betw (\<lambda>x. if x \<in> A then f x else g x) (A \<union> B) (C \<union> D)" |
d73955442df5
a few new lemmas about functions
paulson <lp15@cam.ac.uk>
parents:
71827
diff
changeset
|
683 |
using assms by (auto simp: inj_on_disjoint_Un bij_betw_def) |
d73955442df5
a few new lemmas about functions
paulson <lp15@cam.ac.uk>
parents:
71827
diff
changeset
|
684 |
|
73594 | 685 |
lemma involuntory_imp_bij: |
686 |
\<open>bij f\<close> if \<open>\<And>x. f (f x) = x\<close> |
|
687 |
proof (rule bijI) |
|
688 |
from that show \<open>surj f\<close> |
|
689 |
by (rule surjI) |
|
690 |
show \<open>inj f\<close> |
|
691 |
proof (rule injI) |
|
692 |
fix x y |
|
693 |
assume \<open>f x = f y\<close> |
|
694 |
then have \<open>f (f x) = f (f y)\<close> |
|
695 |
by simp |
|
696 |
then show \<open>x = y\<close> |
|
697 |
by (simp add: that) |
|
698 |
qed |
|
699 |
qed |
|
700 |
||
701 |
||
71857
d73955442df5
a few new lemmas about functions
paulson <lp15@cam.ac.uk>
parents:
71827
diff
changeset
|
702 |
subsubsection \<open>Important examples\<close> |
69502 | 703 |
|
704 |
context cancel_semigroup_add |
|
705 |
begin |
|
706 |
||
69661 | 707 |
lemma inj_on_add [simp]: |
708 |
"inj_on ((+) a) A" |
|
709 |
by (rule inj_onI) simp |
|
710 |
||
711 |
lemma inj_add_left: |
|
712 |
\<open>inj ((+) a)\<close> |
|
713 |
by simp |
|
714 |
||
715 |
lemma inj_on_add' [simp]: |
|
716 |
"inj_on (\<lambda>b. b + a) A" |
|
717 |
by (rule inj_onI) simp |
|
718 |
||
719 |
lemma bij_betw_add [simp]: |
|
720 |
"bij_betw ((+) a) A B \<longleftrightarrow> (+) a ` A = B" |
|
721 |
by (simp add: bij_betw_def) |
|
69502 | 722 |
|
723 |
end |
|
724 |
||
725 |
context ab_group_add |
|
726 |
begin |
|
727 |
||
69661 | 728 |
lemma surj_plus [simp]: |
729 |
"surj ((+) a)" |
|
69768 | 730 |
by (auto intro!: range_eqI [of b "(+) a" "b - a" for b]) (simp add: algebra_simps) |
69661 | 731 |
|
732 |
lemma inj_diff_right [simp]: |
|
733 |
\<open>inj (\<lambda>b. b - a)\<close> |
|
69502 | 734 |
proof - |
735 |
have \<open>inj ((+) (- a))\<close> |
|
736 |
by (fact inj_add_left) |
|
737 |
also have \<open>(+) (- a) = (\<lambda>b. b - a)\<close> |
|
738 |
by (simp add: fun_eq_iff) |
|
739 |
finally show ?thesis . |
|
740 |
qed |
|
741 |
||
69661 | 742 |
lemma surj_diff_right [simp]: |
743 |
"surj (\<lambda>x. x - a)" |
|
744 |
using surj_plus [of "- a"] by (simp cong: image_cong_simp) |
|
745 |
||
746 |
lemma translation_Compl: |
|
747 |
"(+) a ` (- t) = - ((+) a ` t)" |
|
748 |
proof (rule set_eqI) |
|
749 |
fix b |
|
750 |
show "b \<in> (+) a ` (- t) \<longleftrightarrow> b \<in> - (+) a ` t" |
|
751 |
by (auto simp: image_iff algebra_simps intro!: bexI [of _ "b - a"]) |
|
752 |
qed |
|
753 |
||
754 |
lemma translation_subtract_Compl: |
|
755 |
"(\<lambda>x. x - a) ` (- t) = - ((\<lambda>x. x - a) ` t)" |
|
756 |
using translation_Compl [of "- a" t] by (simp cong: image_cong_simp) |
|
757 |
||
758 |
lemma translation_diff: |
|
759 |
"(+) a ` (s - t) = ((+) a ` s) - ((+) a ` t)" |
|
760 |
by auto |
|
761 |
||
762 |
lemma translation_subtract_diff: |
|
763 |
"(\<lambda>x. x - a) ` (s - t) = ((\<lambda>x. x - a) ` s) - ((\<lambda>x. x - a) ` t)" |
|
764 |
using translation_diff [of "- a"] by (simp cong: image_cong_simp) |
|
765 |
||
766 |
lemma translation_Int: |
|
767 |
"(+) a ` (s \<inter> t) = ((+) a ` s) \<inter> ((+) a ` t)" |
|
768 |
by auto |
|
769 |
||
770 |
lemma translation_subtract_Int: |
|
771 |
"(\<lambda>x. x - a) ` (s \<inter> t) = ((\<lambda>x. x - a) ` s) \<inter> ((\<lambda>x. x - a) ` t)" |
|
772 |
using translation_Int [of " -a"] by (simp cong: image_cong_simp) |
|
773 |
||
69502 | 774 |
end |
775 |
||
41657 | 776 |
|
63322 | 777 |
subsection \<open>Function Updating\<close> |
13585 | 778 |
|
63322 | 779 |
definition fun_upd :: "('a \<Rightarrow> 'b) \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> ('a \<Rightarrow> 'b)" |
63324 | 780 |
where "fun_upd f a b = (\<lambda>x. if x = a then b else f x)" |
26147 | 781 |
|
41229
d797baa3d57c
replaced command 'nonterminals' by slightly modernized version 'nonterminal';
wenzelm
parents:
40969
diff
changeset
|
782 |
nonterminal updbinds and updbind |
d797baa3d57c
replaced command 'nonterminals' by slightly modernized version 'nonterminal';
wenzelm
parents:
40969
diff
changeset
|
783 |
|
26147 | 784 |
syntax |
63322 | 785 |
"_updbind" :: "'a \<Rightarrow> 'a \<Rightarrow> updbind" ("(2_ :=/ _)") |
786 |
"" :: "updbind \<Rightarrow> updbinds" ("_") |
|
787 |
"_updbinds":: "updbind \<Rightarrow> updbinds \<Rightarrow> updbinds" ("_,/ _") |
|
788 |
"_Update" :: "'a \<Rightarrow> updbinds \<Rightarrow> 'a" ("_/'((_)')" [1000, 0] 900) |
|
26147 | 789 |
|
790 |
translations |
|
63322 | 791 |
"_Update f (_updbinds b bs)" \<rightleftharpoons> "_Update (_Update f b) bs" |
792 |
"f(x:=y)" \<rightleftharpoons> "CONST fun_upd f x y" |
|
26147 | 793 |
|
55414
eab03e9cee8a
renamed '{prod,sum,bool,unit}_case' to 'case_...'
blanchet
parents:
55066
diff
changeset
|
794 |
(* Hint: to define the sum of two functions (or maps), use case_sum. |
58111 | 795 |
A nice infix syntax could be defined by |
35115 | 796 |
notation |
55414
eab03e9cee8a
renamed '{prod,sum,bool,unit}_case' to 'case_...'
blanchet
parents:
55066
diff
changeset
|
797 |
case_sum (infixr "'(+')"80) |
26147 | 798 |
*) |
799 |
||
63322 | 800 |
lemma fun_upd_idem_iff: "f(x:=y) = f \<longleftrightarrow> f x = y" |
801 |
unfolding fun_upd_def |
|
802 |
apply safe |
|
63575 | 803 |
apply (erule subst) |
804 |
apply auto |
|
63322 | 805 |
done |
13585 | 806 |
|
63322 | 807 |
lemma fun_upd_idem: "f x = y \<Longrightarrow> f(x := y) = f" |
45603 | 808 |
by (simp only: fun_upd_idem_iff) |
13585 | 809 |
|
45603 | 810 |
lemma fun_upd_triv [iff]: "f(x := f x) = f" |
811 |
by (simp only: fun_upd_idem) |
|
13585 | 812 |
|
63322 | 813 |
lemma fun_upd_apply [simp]: "(f(x := y)) z = (if z = x then y else f z)" |
814 |
by (simp add: fun_upd_def) |
|
13585 | 815 |
|
63322 | 816 |
(* fun_upd_apply supersedes these two, but they are useful |
13585 | 817 |
if fun_upd_apply is intentionally removed from the simpset *) |
63322 | 818 |
lemma fun_upd_same: "(f(x := y)) x = y" |
819 |
by simp |
|
13585 | 820 |
|
63322 | 821 |
lemma fun_upd_other: "z \<noteq> x \<Longrightarrow> (f(x := y)) z = f z" |
822 |
by simp |
|
13585 | 823 |
|
63322 | 824 |
lemma fun_upd_upd [simp]: "f(x := y, x := z) = f(x := z)" |
825 |
by (simp add: fun_eq_iff) |
|
13585 | 826 |
|
63322 | 827 |
lemma fun_upd_twist: "a \<noteq> c \<Longrightarrow> (m(a := b))(c := d) = (m(c := d))(a := b)" |
71616
a9de39608b1a
more tidying up of old apply-proofs
paulson <lp15@cam.ac.uk>
parents:
71472
diff
changeset
|
828 |
by auto |
63322 | 829 |
|
830 |
lemma inj_on_fun_updI: "inj_on f A \<Longrightarrow> y \<notin> f ` A \<Longrightarrow> inj_on (f(x := y)) A" |
|
64966
d53d7ca3303e
added inj_def (redundant, analogous to surj_def, bij_def);
wenzelm
parents:
64965
diff
changeset
|
831 |
by (auto simp: inj_on_def) |
15303 | 832 |
|
63322 | 833 |
lemma fun_upd_image: "f(x := y) ` A = (if x \<in> A then insert y (f ` (A - {x})) else f ` A)" |
834 |
by auto |
|
15510 | 835 |
|
31080 | 836 |
lemma fun_upd_comp: "f \<circ> (g(x := y)) = (f \<circ> g)(x := f y)" |
44921 | 837 |
by auto |
31080 | 838 |
|
61630 | 839 |
lemma fun_upd_eqD: "f(x := y) = g(x := z) \<Longrightarrow> y = z" |
63322 | 840 |
by (simp add: fun_eq_iff split: if_split_asm) |
841 |
||
26147 | 842 |
|
61799 | 843 |
subsection \<open>\<open>override_on\<close>\<close> |
26147 | 844 |
|
63322 | 845 |
definition override_on :: "('a \<Rightarrow> 'b) \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'a set \<Rightarrow> 'a \<Rightarrow> 'b" |
846 |
where "override_on f g A = (\<lambda>a. if a \<in> A then g a else f a)" |
|
13910 | 847 |
|
15691 | 848 |
lemma override_on_emptyset[simp]: "override_on f g {} = f" |
64965 | 849 |
by (simp add: override_on_def) |
13910 | 850 |
|
63322 | 851 |
lemma override_on_apply_notin[simp]: "a \<notin> A \<Longrightarrow> (override_on f g A) a = f a" |
64965 | 852 |
by (simp add: override_on_def) |
13910 | 853 |
|
63322 | 854 |
lemma override_on_apply_in[simp]: "a \<in> A \<Longrightarrow> (override_on f g A) a = g a" |
64965 | 855 |
by (simp add: override_on_def) |
13910 | 856 |
|
63561
fba08009ff3e
add lemmas contributed by Peter Gammie
Andreas Lochbihler
parents:
63416
diff
changeset
|
857 |
lemma override_on_insert: "override_on f g (insert x X) = (override_on f g X)(x:=g x)" |
64965 | 858 |
by (simp add: override_on_def fun_eq_iff) |
63561
fba08009ff3e
add lemmas contributed by Peter Gammie
Andreas Lochbihler
parents:
63416
diff
changeset
|
859 |
|
fba08009ff3e
add lemmas contributed by Peter Gammie
Andreas Lochbihler
parents:
63416
diff
changeset
|
860 |
lemma override_on_insert': "override_on f g (insert x X) = (override_on (f(x:=g x)) g X)" |
64965 | 861 |
by (simp add: override_on_def fun_eq_iff) |
63561
fba08009ff3e
add lemmas contributed by Peter Gammie
Andreas Lochbihler
parents:
63416
diff
changeset
|
862 |
|
26147 | 863 |
|
60758 | 864 |
subsection \<open>Inversion of injective functions\<close> |
31949 | 865 |
|
63322 | 866 |
definition the_inv_into :: "'a set \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> ('b \<Rightarrow> 'a)" |
63324 | 867 |
where "the_inv_into A f = (\<lambda>x. THE y. y \<in> A \<and> f y = x)" |
63322 | 868 |
|
869 |
lemma the_inv_into_f_f: "inj_on f A \<Longrightarrow> x \<in> A \<Longrightarrow> the_inv_into A f (f x) = x" |
|
870 |
unfolding the_inv_into_def inj_on_def by blast |
|
32961 | 871 |
|
63322 | 872 |
lemma f_the_inv_into_f: "inj_on f A \<Longrightarrow> y \<in> f ` A \<Longrightarrow> f (the_inv_into A f y) = y" |
71857
d73955442df5
a few new lemmas about functions
paulson <lp15@cam.ac.uk>
parents:
71827
diff
changeset
|
873 |
unfolding the_inv_into_def |
d73955442df5
a few new lemmas about functions
paulson <lp15@cam.ac.uk>
parents:
71827
diff
changeset
|
874 |
by (rule the1I2; blast dest: inj_onD) |
32961 | 875 |
|
72125
cf8399df4d76
elimination of some needless assumptions
paulson <lp15@cam.ac.uk>
parents:
71857
diff
changeset
|
876 |
lemma f_the_inv_into_f_bij_betw: |
cf8399df4d76
elimination of some needless assumptions
paulson <lp15@cam.ac.uk>
parents:
71857
diff
changeset
|
877 |
"bij_betw f A B \<Longrightarrow> (bij_betw f A B \<Longrightarrow> x \<in> B) \<Longrightarrow> f (the_inv_into A f x) = x" |
cf8399df4d76
elimination of some needless assumptions
paulson <lp15@cam.ac.uk>
parents:
71857
diff
changeset
|
878 |
unfolding bij_betw_def by (blast intro: f_the_inv_into_f) |
cf8399df4d76
elimination of some needless assumptions
paulson <lp15@cam.ac.uk>
parents:
71857
diff
changeset
|
879 |
|
63322 | 880 |
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" |
71857
d73955442df5
a few new lemmas about functions
paulson <lp15@cam.ac.uk>
parents:
71827
diff
changeset
|
881 |
unfolding the_inv_into_def |
d73955442df5
a few new lemmas about functions
paulson <lp15@cam.ac.uk>
parents:
71827
diff
changeset
|
882 |
by (rule the1I2; blast dest: inj_onD) |
32961 | 883 |
|
63322 | 884 |
lemma the_inv_into_onto [simp]: "inj_on f A \<Longrightarrow> the_inv_into A f ` (f ` A) = A" |
885 |
by (fast intro: the_inv_into_into the_inv_into_f_f [symmetric]) |
|
32961 | 886 |
|
63322 | 887 |
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" |
71857
d73955442df5
a few new lemmas about functions
paulson <lp15@cam.ac.uk>
parents:
71827
diff
changeset
|
888 |
by (force simp add: the_inv_into_f_f) |
32961 | 889 |
|
33057 | 890 |
lemma the_inv_into_comp: |
63322 | 891 |
"inj_on f (g ` A) \<Longrightarrow> inj_on g A \<Longrightarrow> x \<in> f ` g ` A \<Longrightarrow> |
892 |
the_inv_into A (f \<circ> g) x = (the_inv_into A g \<circ> the_inv_into (g ` A) f) x" |
|
893 |
apply (rule the_inv_into_f_eq) |
|
894 |
apply (fast intro: comp_inj_on) |
|
895 |
apply (simp add: f_the_inv_into_f the_inv_into_into) |
|
896 |
apply (simp add: the_inv_into_into) |
|
897 |
done |
|
32961 | 898 |
|
63322 | 899 |
lemma inj_on_the_inv_into: "inj_on f A \<Longrightarrow> inj_on (the_inv_into A f) (f ` A)" |
900 |
by (auto intro: inj_onI simp: the_inv_into_f_f) |
|
32961 | 901 |
|
63322 | 902 |
lemma bij_betw_the_inv_into: "bij_betw f A B \<Longrightarrow> bij_betw (the_inv_into A f) B A" |
903 |
by (auto simp add: bij_betw_def inj_on_the_inv_into the_inv_into_into) |
|
32961 | 904 |
|
71857
d73955442df5
a few new lemmas about functions
paulson <lp15@cam.ac.uk>
parents:
71827
diff
changeset
|
905 |
lemma bij_betw_iff_bijections: |
d73955442df5
a few new lemmas about functions
paulson <lp15@cam.ac.uk>
parents:
71827
diff
changeset
|
906 |
"bij_betw f A B \<longleftrightarrow> (\<exists>g. (\<forall>x \<in> A. f x \<in> B \<and> g(f x) = x) \<and> (\<forall>y \<in> B. g y \<in> A \<and> f(g y) = y))" |
d73955442df5
a few new lemmas about functions
paulson <lp15@cam.ac.uk>
parents:
71827
diff
changeset
|
907 |
(is "?lhs = ?rhs") |
d73955442df5
a few new lemmas about functions
paulson <lp15@cam.ac.uk>
parents:
71827
diff
changeset
|
908 |
proof |
75669
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents:
75624
diff
changeset
|
909 |
show "?lhs \<Longrightarrow> ?rhs" |
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents:
75624
diff
changeset
|
910 |
by (auto simp: bij_betw_def f_the_inv_into_f the_inv_into_f_f the_inv_into_into |
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents:
75624
diff
changeset
|
911 |
exI[where ?x="the_inv_into A f"]) |
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents:
75624
diff
changeset
|
912 |
next |
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents:
75624
diff
changeset
|
913 |
show "?rhs \<Longrightarrow> ?lhs" |
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents:
75624
diff
changeset
|
914 |
by (force intro: bij_betw_byWitness) |
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents:
75624
diff
changeset
|
915 |
qed |
71857
d73955442df5
a few new lemmas about functions
paulson <lp15@cam.ac.uk>
parents:
71827
diff
changeset
|
916 |
|
63322 | 917 |
abbreviation the_inv :: "('a \<Rightarrow> 'b) \<Rightarrow> ('b \<Rightarrow> 'a)" |
918 |
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
|
919 |
|
64965 | 920 |
lemma the_inv_f_f: "the_inv f (f x) = x" if "inj f" |
921 |
using that 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
|
922 |
|
44277
bcb696533579
moved fundamental lemma fun_eq_iff to theory HOL; tuned whitespace
haftmann
parents:
43991
diff
changeset
|
923 |
|
60758 | 924 |
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
|
925 |
|
63323 | 926 |
theorem Cantors_paradox: "\<nexists>f. f ` A = Pow A" |
927 |
proof |
|
928 |
assume "\<exists>f. f ` A = Pow A" |
|
929 |
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
|
930 |
let ?X = "{a \<in> A. a \<notin> f a}" |
63323 | 931 |
have "?X \<in> Pow A" by blast |
932 |
then have "?X \<in> f ` A" by (simp only: f) |
|
933 |
then obtain x where "x \<in> A" and "f x = ?X" by blast |
|
934 |
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
|
935 |
qed |
31949 | 936 |
|
75582
6fb4a0829cc4
added predicate monotone_on and redefined monotone to be an abbreviation.
desharna
parents:
74123
diff
changeset
|
937 |
|
71472
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
938 |
subsection \<open>Monotonic functions over a set\<close> |
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
939 |
|
75582
6fb4a0829cc4
added predicate monotone_on and redefined monotone to be an abbreviation.
desharna
parents:
74123
diff
changeset
|
940 |
definition monotone_on :: "'a set \<Rightarrow> ('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> ('b \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> bool" |
6fb4a0829cc4
added predicate monotone_on and redefined monotone to be an abbreviation.
desharna
parents:
74123
diff
changeset
|
941 |
where "monotone_on A orda ordb f \<longleftrightarrow> (\<forall>x\<in>A. \<forall>y\<in>A. orda x y \<longrightarrow> ordb (f x) (f y))" |
6fb4a0829cc4
added predicate monotone_on and redefined monotone to be an abbreviation.
desharna
parents:
74123
diff
changeset
|
942 |
|
6fb4a0829cc4
added predicate monotone_on and redefined monotone to be an abbreviation.
desharna
parents:
74123
diff
changeset
|
943 |
abbreviation monotone :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> ('b \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> bool" |
6fb4a0829cc4
added predicate monotone_on and redefined monotone to be an abbreviation.
desharna
parents:
74123
diff
changeset
|
944 |
where "monotone \<equiv> monotone_on UNIV" |
6fb4a0829cc4
added predicate monotone_on and redefined monotone to be an abbreviation.
desharna
parents:
74123
diff
changeset
|
945 |
|
6fb4a0829cc4
added predicate monotone_on and redefined monotone to be an abbreviation.
desharna
parents:
74123
diff
changeset
|
946 |
lemma monotone_def[no_atp]: "monotone orda ordb f \<longleftrightarrow> (\<forall>x y. orda x y \<longrightarrow> ordb (f x) (f y))" |
6fb4a0829cc4
added predicate monotone_on and redefined monotone to be an abbreviation.
desharna
parents:
74123
diff
changeset
|
947 |
by (simp add: monotone_on_def) |
6fb4a0829cc4
added predicate monotone_on and redefined monotone to be an abbreviation.
desharna
parents:
74123
diff
changeset
|
948 |
|
6fb4a0829cc4
added predicate monotone_on and redefined monotone to be an abbreviation.
desharna
parents:
74123
diff
changeset
|
949 |
text \<open>Lemma @{thm [source] monotone_def} is provided for backward compatibility.\<close> |
6fb4a0829cc4
added predicate monotone_on and redefined monotone to be an abbreviation.
desharna
parents:
74123
diff
changeset
|
950 |
|
6fb4a0829cc4
added predicate monotone_on and redefined monotone to be an abbreviation.
desharna
parents:
74123
diff
changeset
|
951 |
lemma monotone_onI: |
6fb4a0829cc4
added predicate monotone_on and redefined monotone to be an abbreviation.
desharna
parents:
74123
diff
changeset
|
952 |
"(\<And>x y. x \<in> A \<Longrightarrow> y \<in> A \<Longrightarrow> orda x y \<Longrightarrow> ordb (f x) (f y)) \<Longrightarrow> monotone_on A orda ordb f" |
6fb4a0829cc4
added predicate monotone_on and redefined monotone to be an abbreviation.
desharna
parents:
74123
diff
changeset
|
953 |
by (simp add: monotone_on_def) |
6fb4a0829cc4
added predicate monotone_on and redefined monotone to be an abbreviation.
desharna
parents:
74123
diff
changeset
|
954 |
|
6fb4a0829cc4
added predicate monotone_on and redefined monotone to be an abbreviation.
desharna
parents:
74123
diff
changeset
|
955 |
lemma monotoneI[intro?]: "(\<And>x y. orda x y \<Longrightarrow> ordb (f x) (f y)) \<Longrightarrow> monotone orda ordb f" |
6fb4a0829cc4
added predicate monotone_on and redefined monotone to be an abbreviation.
desharna
parents:
74123
diff
changeset
|
956 |
by (rule monotone_onI) |
6fb4a0829cc4
added predicate monotone_on and redefined monotone to be an abbreviation.
desharna
parents:
74123
diff
changeset
|
957 |
|
6fb4a0829cc4
added predicate monotone_on and redefined monotone to be an abbreviation.
desharna
parents:
74123
diff
changeset
|
958 |
lemma monotone_onD: |
6fb4a0829cc4
added predicate monotone_on and redefined monotone to be an abbreviation.
desharna
parents:
74123
diff
changeset
|
959 |
"monotone_on A orda ordb f \<Longrightarrow> x \<in> A \<Longrightarrow> y \<in> A \<Longrightarrow> orda x y \<Longrightarrow> ordb (f x) (f y)" |
6fb4a0829cc4
added predicate monotone_on and redefined monotone to be an abbreviation.
desharna
parents:
74123
diff
changeset
|
960 |
by (simp add: monotone_on_def) |
6fb4a0829cc4
added predicate monotone_on and redefined monotone to be an abbreviation.
desharna
parents:
74123
diff
changeset
|
961 |
|
6fb4a0829cc4
added predicate monotone_on and redefined monotone to be an abbreviation.
desharna
parents:
74123
diff
changeset
|
962 |
lemma monotoneD[dest?]: "monotone orda ordb f \<Longrightarrow> orda x y \<Longrightarrow> ordb (f x) (f y)" |
75607
3c544d64c218
changed argument order of mono_on and strict_mono_on to uniformize with monotone_on and other predicates
desharna
parents:
75583
diff
changeset
|
963 |
by (rule monotone_onD[of UNIV, simplified]) |
75582
6fb4a0829cc4
added predicate monotone_on and redefined monotone to be an abbreviation.
desharna
parents:
74123
diff
changeset
|
964 |
|
75583
451e17e0ba9d
added lemmas monotone_on_empty[simp] and monotone_on_subset
desharna
parents:
75582
diff
changeset
|
965 |
lemma monotone_on_subset: "monotone_on A orda ordb f \<Longrightarrow> B \<subseteq> A \<Longrightarrow> monotone_on B orda ordb f" |
451e17e0ba9d
added lemmas monotone_on_empty[simp] and monotone_on_subset
desharna
parents:
75582
diff
changeset
|
966 |
by (auto intro: monotone_onI dest: monotone_onD) |
451e17e0ba9d
added lemmas monotone_on_empty[simp] and monotone_on_subset
desharna
parents:
75582
diff
changeset
|
967 |
|
451e17e0ba9d
added lemmas monotone_on_empty[simp] and monotone_on_subset
desharna
parents:
75582
diff
changeset
|
968 |
lemma monotone_on_empty[simp]: "monotone_on {} orda ordb f" |
451e17e0ba9d
added lemmas monotone_on_empty[simp] and monotone_on_subset
desharna
parents:
75582
diff
changeset
|
969 |
by (auto intro: monotone_onI dest: monotone_onD) |
451e17e0ba9d
added lemmas monotone_on_empty[simp] and monotone_on_subset
desharna
parents:
75582
diff
changeset
|
970 |
|
75609 | 971 |
lemma monotone_on_o: |
972 |
assumes |
|
973 |
mono_f: "monotone_on A orda ordb f" and |
|
974 |
mono_g: "monotone_on B ordc orda g" and |
|
975 |
"g ` B \<subseteq> A" |
|
976 |
shows "monotone_on B ordc ordb (f \<circ> g)" |
|
977 |
proof (rule monotone_onI) |
|
978 |
fix x y assume "x \<in> B" and "y \<in> B" and "ordc x y" |
|
979 |
hence "orda (g x) (g y)" |
|
980 |
by (rule mono_g[THEN monotone_onD]) |
|
981 |
moreover from \<open>g ` B \<subseteq> A\<close> \<open>x \<in> B\<close> \<open>y \<in> B\<close> have "g x \<in> A" and "g y \<in> A" |
|
982 |
unfolding image_subset_iff by simp_all |
|
983 |
ultimately show "ordb ((f \<circ> g) x) ((f \<circ> g) y)" |
|
984 |
using mono_f[THEN monotone_onD] by simp |
|
985 |
qed |
|
986 |
||
75608
6c542e152b8a
redefined mono_on and strict_mono_on as an abbreviation of monotone_on
desharna
parents:
75607
diff
changeset
|
987 |
abbreviation mono_on :: "('a :: ord) set \<Rightarrow> ('a \<Rightarrow> 'b :: ord) \<Rightarrow> bool" |
6c542e152b8a
redefined mono_on and strict_mono_on as an abbreviation of monotone_on
desharna
parents:
75607
diff
changeset
|
988 |
where "mono_on A \<equiv> monotone_on A (\<le>) (\<le>)" |
6c542e152b8a
redefined mono_on and strict_mono_on as an abbreviation of monotone_on
desharna
parents:
75607
diff
changeset
|
989 |
|
6c542e152b8a
redefined mono_on and strict_mono_on as an abbreviation of monotone_on
desharna
parents:
75607
diff
changeset
|
990 |
lemma mono_on_def: "mono_on A f \<longleftrightarrow> (\<forall>r s. r \<in> A \<and> s \<in> A \<and> r \<le> s \<longrightarrow> f r \<le> f s)" |
6c542e152b8a
redefined mono_on and strict_mono_on as an abbreviation of monotone_on
desharna
parents:
75607
diff
changeset
|
991 |
by (auto simp add: monotone_on_def) |
71472
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
992 |
|
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
993 |
lemma mono_onI: |
75607
3c544d64c218
changed argument order of mono_on and strict_mono_on to uniformize with monotone_on and other predicates
desharna
parents:
75583
diff
changeset
|
994 |
"(\<And>r s. r \<in> A \<Longrightarrow> s \<in> A \<Longrightarrow> r \<le> s \<Longrightarrow> f r \<le> f s) \<Longrightarrow> mono_on A f" |
75608
6c542e152b8a
redefined mono_on and strict_mono_on as an abbreviation of monotone_on
desharna
parents:
75607
diff
changeset
|
995 |
by (rule monotone_onI) |
71472
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
996 |
|
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
997 |
lemma mono_onD: |
75607
3c544d64c218
changed argument order of mono_on and strict_mono_on to uniformize with monotone_on and other predicates
desharna
parents:
75583
diff
changeset
|
998 |
"\<lbrakk>mono_on A f; r \<in> A; s \<in> A; r \<le> s\<rbrakk> \<Longrightarrow> f r \<le> f s" |
75608
6c542e152b8a
redefined mono_on and strict_mono_on as an abbreviation of monotone_on
desharna
parents:
75607
diff
changeset
|
999 |
by (rule monotone_onD) |
71472
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
1000 |
|
75607
3c544d64c218
changed argument order of mono_on and strict_mono_on to uniformize with monotone_on and other predicates
desharna
parents:
75583
diff
changeset
|
1001 |
lemma mono_imp_mono_on: "mono f \<Longrightarrow> mono_on A f" |
71472
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
1002 |
unfolding mono_def mono_on_def by auto |
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
1003 |
|
75607
3c544d64c218
changed argument order of mono_on and strict_mono_on to uniformize with monotone_on and other predicates
desharna
parents:
75583
diff
changeset
|
1004 |
lemma mono_on_subset: "mono_on A f \<Longrightarrow> B \<subseteq> A \<Longrightarrow> mono_on B f" |
75608
6c542e152b8a
redefined mono_on and strict_mono_on as an abbreviation of monotone_on
desharna
parents:
75607
diff
changeset
|
1005 |
by (rule monotone_on_subset) |
71472
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
1006 |
|
75608
6c542e152b8a
redefined mono_on and strict_mono_on as an abbreviation of monotone_on
desharna
parents:
75607
diff
changeset
|
1007 |
abbreviation strict_mono_on :: "('a :: ord) set \<Rightarrow> ('a \<Rightarrow> 'b :: ord) \<Rightarrow> bool" |
6c542e152b8a
redefined mono_on and strict_mono_on as an abbreviation of monotone_on
desharna
parents:
75607
diff
changeset
|
1008 |
where "strict_mono_on A \<equiv> monotone_on A (<) (<)" |
6c542e152b8a
redefined mono_on and strict_mono_on as an abbreviation of monotone_on
desharna
parents:
75607
diff
changeset
|
1009 |
|
6c542e152b8a
redefined mono_on and strict_mono_on as an abbreviation of monotone_on
desharna
parents:
75607
diff
changeset
|
1010 |
lemma strict_mono_on_def: "strict_mono_on A f \<longleftrightarrow> (\<forall>r s. r \<in> A \<and> s \<in> A \<and> r < s \<longrightarrow> f r < f s)" |
6c542e152b8a
redefined mono_on and strict_mono_on as an abbreviation of monotone_on
desharna
parents:
75607
diff
changeset
|
1011 |
by (auto simp add: monotone_on_def) |
71472
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
1012 |
|
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
1013 |
lemma strict_mono_onI: |
75607
3c544d64c218
changed argument order of mono_on and strict_mono_on to uniformize with monotone_on and other predicates
desharna
parents:
75583
diff
changeset
|
1014 |
"(\<And>r s. r \<in> A \<Longrightarrow> s \<in> A \<Longrightarrow> r < s \<Longrightarrow> f r < f s) \<Longrightarrow> strict_mono_on A f" |
75608
6c542e152b8a
redefined mono_on and strict_mono_on as an abbreviation of monotone_on
desharna
parents:
75607
diff
changeset
|
1015 |
by (rule monotone_onI) |
71472
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
1016 |
|
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
1017 |
lemma strict_mono_onD: |
75607
3c544d64c218
changed argument order of mono_on and strict_mono_on to uniformize with monotone_on and other predicates
desharna
parents:
75583
diff
changeset
|
1018 |
"\<lbrakk>strict_mono_on A f; r \<in> A; s \<in> A; r < s\<rbrakk> \<Longrightarrow> f r < f s" |
75608
6c542e152b8a
redefined mono_on and strict_mono_on as an abbreviation of monotone_on
desharna
parents:
75607
diff
changeset
|
1019 |
by (rule monotone_onD) |
71472
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
1020 |
|
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
1021 |
lemma mono_on_greaterD: |
75607
3c544d64c218
changed argument order of mono_on and strict_mono_on to uniformize with monotone_on and other predicates
desharna
parents:
75583
diff
changeset
|
1022 |
assumes "mono_on A g" "x \<in> A" "y \<in> A" "g x > (g (y::_::linorder) :: _ :: linorder)" |
71472
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
1023 |
shows "x > y" |
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
1024 |
proof (rule ccontr) |
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
1025 |
assume "\<not>x > y" |
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
1026 |
hence "x \<le> y" by (simp add: not_less) |
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
1027 |
from assms(1-3) and this have "g x \<le> g y" by (rule mono_onD) |
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
1028 |
with assms(4) show False by simp |
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
1029 |
qed |
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
1030 |
|
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
1031 |
lemma strict_mono_inv: |
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
1032 |
fixes f :: "('a::linorder) \<Rightarrow> ('b::linorder)" |
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
1033 |
assumes "strict_mono f" and "surj f" and inv: "\<And>x. g (f x) = x" |
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
1034 |
shows "strict_mono g" |
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
1035 |
proof |
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
1036 |
fix x y :: 'b assume "x < y" |
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
1037 |
from \<open>surj f\<close> obtain x' y' where [simp]: "x = f x'" "y = f y'" by blast |
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
1038 |
with \<open>x < y\<close> and \<open>strict_mono f\<close> have "x' < y'" by (simp add: strict_mono_less) |
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
1039 |
with inv show "g x < g y" by simp |
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
1040 |
qed |
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
1041 |
|
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
1042 |
lemma strict_mono_on_imp_inj_on: |
75607
3c544d64c218
changed argument order of mono_on and strict_mono_on to uniformize with monotone_on and other predicates
desharna
parents:
75583
diff
changeset
|
1043 |
assumes "strict_mono_on A (f :: (_ :: linorder) \<Rightarrow> (_ :: preorder))" |
71472
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
1044 |
shows "inj_on f A" |
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
1045 |
proof (rule inj_onI) |
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
1046 |
fix x y assume "x \<in> A" "y \<in> A" "f x = f y" |
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
1047 |
thus "x = y" |
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
1048 |
by (cases x y rule: linorder_cases) |
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
1049 |
(auto dest: strict_mono_onD[OF assms, of x y] strict_mono_onD[OF assms, of y x]) |
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
1050 |
qed |
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
1051 |
|
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
1052 |
lemma strict_mono_on_leD: |
75607
3c544d64c218
changed argument order of mono_on and strict_mono_on to uniformize with monotone_on and other predicates
desharna
parents:
75583
diff
changeset
|
1053 |
assumes "strict_mono_on A (f :: (_ :: linorder) \<Rightarrow> _ :: preorder)" "x \<in> A" "y \<in> A" "x \<le> y" |
71472
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
1054 |
shows "f x \<le> f y" |
75669
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents:
75624
diff
changeset
|
1055 |
proof (cases "x = y") |
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents:
75624
diff
changeset
|
1056 |
case True |
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents:
75624
diff
changeset
|
1057 |
then show ?thesis by simp |
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents:
75624
diff
changeset
|
1058 |
next |
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents:
75624
diff
changeset
|
1059 |
case False |
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents:
75624
diff
changeset
|
1060 |
with assms have "f x < f y" |
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents:
75624
diff
changeset
|
1061 |
using strict_mono_onD[OF assms(1)] by simp |
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents:
75624
diff
changeset
|
1062 |
then show ?thesis by (rule less_imp_le) |
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents:
75624
diff
changeset
|
1063 |
qed |
71472
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
1064 |
|
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
1065 |
lemma strict_mono_on_eqD: |
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
1066 |
fixes f :: "(_ :: linorder) \<Rightarrow> (_ :: preorder)" |
75607
3c544d64c218
changed argument order of mono_on and strict_mono_on to uniformize with monotone_on and other predicates
desharna
parents:
75583
diff
changeset
|
1067 |
assumes "strict_mono_on A f" "f x = f y" "x \<in> A" "y \<in> A" |
71472
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
1068 |
shows "y = x" |
75669
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
Fabian Huch <huch@in.tum.de>
parents:
75624
diff
changeset
|
1069 |
using assms by (cases rule: linorder_cases) (auto dest: strict_mono_onD) |
71472
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
1070 |
|
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
1071 |
lemma strict_mono_on_imp_mono_on: |
75607
3c544d64c218
changed argument order of mono_on and strict_mono_on to uniformize with monotone_on and other predicates
desharna
parents:
75583
diff
changeset
|
1072 |
"strict_mono_on A (f :: (_ :: linorder) \<Rightarrow> _ :: preorder) \<Longrightarrow> mono_on A f" |
71472
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
1073 |
by (rule mono_onI, rule strict_mono_on_leD) |
c213d067e60f
Moved a number of general-purpose lemmas into HOL
paulson <lp15@cam.ac.uk>
parents:
71464
diff
changeset
|
1074 |
|
63322 | 1075 |
|
61204 | 1076 |
subsection \<open>Setup\<close> |
40969 | 1077 |
|
60758 | 1078 |
subsubsection \<open>Proof tools\<close> |
22845 | 1079 |
|
63400 | 1080 |
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 | 1081 |
|
60758 | 1082 |
simproc_setup fun_upd2 ("f(v := w, x := y)") = \<open>fn _ => |
63322 | 1083 |
let |
1084 |
fun gen_fun_upd NONE T _ _ = NONE |
|
69593 | 1085 |
| gen_fun_upd (SOME f) T x y = SOME (Const (\<^const_name>\<open>fun_upd\<close>, T) $ f $ x $ y) |
63322 | 1086 |
fun dest_fun_T1 (Type (_, T :: Ts)) = T |
69593 | 1087 |
fun find_double (t as Const (\<^const_name>\<open>fun_upd\<close>,T) $ f $ x $ y) = |
63322 | 1088 |
let |
69593 | 1089 |
fun find (Const (\<^const_name>\<open>fun_upd\<close>,T) $ g $ v $ w) = |
63322 | 1090 |
if v aconv x then SOME g else gen_fun_upd (find g) T v w |
1091 |
| find t = NONE |
|
1092 |
in (dest_fun_T1 T, gen_fun_upd (find f) T x y) end |
|
24017 | 1093 |
|
69593 | 1094 |
val ss = simpset_of \<^context> |
51717
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
wenzelm
parents:
51598
diff
changeset
|
1095 |
|
63322 | 1096 |
fun proc ctxt ct = |
1097 |
let |
|
1098 |
val t = Thm.term_of ct |
|
1099 |
in |
|
63400 | 1100 |
(case find_double t of |
63322 | 1101 |
(T, NONE) => NONE |
1102 |
| (T, SOME rhs) => |
|
1103 |
SOME (Goal.prove ctxt [] [] (Logic.mk_equals (t, rhs)) |
|
1104 |
(fn _ => |
|
1105 |
resolve_tac ctxt [eq_reflection] 1 THEN |
|
1106 |
resolve_tac ctxt @{thms ext} 1 THEN |
|
63400 | 1107 |
simp_tac (put_simpset ss ctxt) 1))) |
63322 | 1108 |
end |
1109 |
in proc end |
|
60758 | 1110 |
\<close> |
22845 | 1111 |
|
1112 |
||
60758 | 1113 |
subsubsection \<open>Functorial structure of types\<close> |
40969 | 1114 |
|
69605 | 1115 |
ML_file \<open>Tools/functor.ML\<close> |
40969 | 1116 |
|
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
|
1117 |
functor map_fun: map_fun |
47488
be6dd389639d
centralized enriched_type declaration, thanks to in-situ available Isar commands
haftmann
parents:
46950
diff
changeset
|
1118 |
by (simp_all add: fun_eq_iff) |
be6dd389639d
centralized enriched_type declaration, thanks to in-situ available Isar commands
haftmann
parents:
46950
diff
changeset
|
1119 |
|
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
|
1120 |
functor vimage |
49739 | 1121 |
by (simp_all add: fun_eq_iff vimage_comp) |
1122 |
||
63322 | 1123 |
|
60758 | 1124 |
text \<open>Legacy theorem names\<close> |
49739 | 1125 |
|
1126 |
lemmas o_def = comp_def |
|
1127 |
lemmas o_apply = comp_apply |
|
1128 |
lemmas o_assoc = comp_assoc [symmetric] |
|
1129 |
lemmas id_o = id_comp |
|
1130 |
lemmas o_id = comp_id |
|
1131 |
lemmas o_eq_dest = comp_eq_dest |
|
1132 |
lemmas o_eq_elim = comp_eq_elim |
|
55066 | 1133 |
lemmas o_eq_dest_lhs = comp_eq_dest_lhs |
1134 |
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
|
1135 |
|
2912 | 1136 |
end |