33 |
33 |
34 lemma disjointD: |
34 lemma disjointD: |
35 "disjoint A \<Longrightarrow> a \<in> A \<Longrightarrow> b \<in> A \<Longrightarrow> a \<noteq> b \<Longrightarrow> a \<inter> b = {}" |
35 "disjoint A \<Longrightarrow> a \<in> A \<Longrightarrow> b \<in> A \<Longrightarrow> a \<noteq> b \<Longrightarrow> a \<inter> b = {}" |
36 unfolding disjoint_def by auto |
36 unfolding disjoint_def by auto |
37 |
37 |
|
38 lemma disjoint_image: "inj_on f (\<Union>A) \<Longrightarrow> disjoint A \<Longrightarrow> disjoint (op ` f ` A)" |
|
39 unfolding inj_on_def disjoint_def by blast |
|
40 |
|
41 lemma assumes "disjoint (A \<union> B)" |
|
42 shows disjoint_unionD1: "disjoint A" and disjoint_unionD2: "disjoint B" |
|
43 using assms by (simp_all add: disjoint_def) |
|
44 |
38 lemma disjoint_INT: |
45 lemma disjoint_INT: |
39 assumes *: "\<And>i. i \<in> I \<Longrightarrow> disjoint (F i)" |
46 assumes *: "\<And>i. i \<in> I \<Longrightarrow> disjoint (F i)" |
40 shows "disjoint {\<Inter>i\<in>I. X i | X. \<forall>i\<in>I. X i \<in> F i}" |
47 shows "disjoint {\<Inter>i\<in>I. X i | X. \<forall>i\<in>I. X i \<in> F i}" |
41 proof (safe intro!: disjointI del: equalityI) |
48 proof (safe intro!: disjointI del: equalityI) |
42 fix A B :: "'a \<Rightarrow> 'b set" assume "(\<Inter>i\<in>I. A i) \<noteq> (\<Inter>i\<in>I. B i)" |
49 fix A B :: "'a \<Rightarrow> 'b set" assume "(\<Inter>i\<in>I. A i) \<noteq> (\<Inter>i\<in>I. B i)" |
79 (metis insert_absorb insert_subset le_SucE le_antisym not_le_imp_less less_imp_le) |
86 (metis insert_absorb insert_subset le_SucE le_antisym not_le_imp_less less_imp_le) |
80 |
87 |
81 lemma disjoint_family_on_disjoint_image: |
88 lemma disjoint_family_on_disjoint_image: |
82 "disjoint_family_on A I \<Longrightarrow> disjoint (A ` I)" |
89 "disjoint_family_on A I \<Longrightarrow> disjoint (A ` I)" |
83 unfolding disjoint_family_on_def disjoint_def by force |
90 unfolding disjoint_family_on_def disjoint_def by force |
84 |
91 |
85 lemma disjoint_family_on_vimageI: "disjoint_family_on F I \<Longrightarrow> disjoint_family_on (\<lambda>i. f -` F i) I" |
92 lemma disjoint_family_on_vimageI: "disjoint_family_on F I \<Longrightarrow> disjoint_family_on (\<lambda>i. f -` F i) I" |
86 by (auto simp: disjoint_family_on_def) |
93 by (auto simp: disjoint_family_on_def) |
87 |
94 |
88 lemma disjoint_image_disjoint_family_on: |
95 lemma disjoint_image_disjoint_family_on: |
89 assumes d: "disjoint (A ` I)" and i: "inj_on A I" |
96 assumes d: "disjoint (A ` I)" and i: "inj_on A I" |
112 show "A \<inter> B = {}" |
119 show "A \<inter> B = {}" |
113 by auto |
120 by auto |
114 qed |
121 qed |
115 qed |
122 qed |
116 |
123 |
|
124 lemma distinct_list_bind: |
|
125 assumes "distinct xs" "\<And>x. x \<in> set xs \<Longrightarrow> distinct (f x)" |
|
126 "disjoint_family_on (set \<circ> f) (set xs)" |
|
127 shows "distinct (List.bind xs f)" |
|
128 using assms |
|
129 by (induction xs) |
|
130 (auto simp: disjoint_family_on_def distinct_map inj_on_def set_list_bind) |
|
131 |
|
132 lemma bij_betw_UNION_disjoint: |
|
133 assumes disj: "disjoint_family_on A' I" |
|
134 assumes bij: "\<And>i. i \<in> I \<Longrightarrow> bij_betw f (A i) (A' i)" |
|
135 shows "bij_betw f (\<Union>i\<in>I. A i) (\<Union>i\<in>I. A' i)" |
|
136 unfolding bij_betw_def |
|
137 proof |
|
138 from bij show eq: "f ` UNION I A = UNION I A'" |
|
139 by (auto simp: bij_betw_def image_UN) |
|
140 show "inj_on f (UNION I A)" |
|
141 proof (rule inj_onI, clarify) |
|
142 fix i j x y assume A: "i \<in> I" "j \<in> I" "x \<in> A i" "y \<in> A j" and B: "f x = f y" |
|
143 from A bij[of i] bij[of j] have "f x \<in> A' i" "f y \<in> A' j" |
|
144 by (auto simp: bij_betw_def) |
|
145 with B have "A' i \<inter> A' j \<noteq> {}" by auto |
|
146 with disj A have "i = j" unfolding disjoint_family_on_def by blast |
|
147 with A B bij[of i] show "x = y" by (auto simp: bij_betw_def dest: inj_onD) |
|
148 qed |
|
149 qed |
|
150 |
117 lemma disjoint_union: "disjoint C \<Longrightarrow> disjoint B \<Longrightarrow> \<Union>C \<inter> \<Union>B = {} \<Longrightarrow> disjoint (C \<union> B)" |
151 lemma disjoint_union: "disjoint C \<Longrightarrow> disjoint B \<Longrightarrow> \<Union>C \<inter> \<Union>B = {} \<Longrightarrow> disjoint (C \<union> B)" |
118 using disjoint_UN[of "{C, B}" "\<lambda>x. x"] by (auto simp add: disjoint_family_on_def) |
152 using disjoint_UN[of "{C, B}" "\<lambda>x. x"] by (auto simp add: disjoint_family_on_def) |
|
153 |
|
154 text \<open> |
|
155 The union of an infinite disjoint family of non-empty sets is infinite. |
|
156 \<close> |
|
157 lemma infinite_disjoint_family_imp_infinite_UNION: |
|
158 assumes "\<not>finite A" "\<And>x. x \<in> A \<Longrightarrow> f x \<noteq> {}" "disjoint_family_on f A" |
|
159 shows "\<not>finite (UNION A f)" |
|
160 proof - |
|
161 def g \<equiv> "\<lambda>x. SOME y. y \<in> f x" |
|
162 have g: "g x \<in> f x" if "x \<in> A" for x |
|
163 unfolding g_def by (rule someI_ex, insert assms(2) that) blast |
|
164 have inj_on_g: "inj_on g A" |
|
165 proof (rule inj_onI, rule ccontr) |
|
166 fix x y assume A: "x \<in> A" "y \<in> A" "g x = g y" "x \<noteq> y" |
|
167 with g[of x] g[of y] have "g x \<in> f x" "g x \<in> f y" by auto |
|
168 with A `x \<noteq> y` assms show False |
|
169 by (auto simp: disjoint_family_on_def inj_on_def) |
|
170 qed |
|
171 from g have "g ` A \<subseteq> UNION A f" by blast |
|
172 moreover from inj_on_g \<open>\<not>finite A\<close> have "\<not>finite (g ` A)" |
|
173 using finite_imageD by blast |
|
174 ultimately show ?thesis using finite_subset by blast |
|
175 qed |
|
176 |
119 |
177 |
120 subsection \<open>Construct Disjoint Sequences\<close> |
178 subsection \<open>Construct Disjoint Sequences\<close> |
121 |
179 |
122 definition disjointed :: "(nat \<Rightarrow> 'a set) \<Rightarrow> nat \<Rightarrow> 'a set" where |
180 definition disjointed :: "(nat \<Rightarrow> 'a set) \<Rightarrow> nat \<Rightarrow> 'a set" where |
123 "disjointed A n = A n - (\<Union>i\<in>{0..<n}. A i)" |
181 "disjointed A n = A n - (\<Union>i\<in>{0..<n}. A i)" |