author | paulson |
Mon, 26 Aug 2024 22:14:19 +0100 | |
changeset 80778 | 94bc8f62c835 |
parent 80761 | bc936d3d8b45 |
child 80914 | d97fdabd9e2b |
permissions | -rw-r--r-- |
60770 | 1 |
section \<open>Extending FOL by a modified version of HOL set theory\<close> |
17456 | 2 |
|
3 |
theory Set |
|
66453
cc19f7ca2ed6
session-qualified theory imports: isabelle imports -U -i -d '~~/src/Benchmarks' -a;
wenzelm
parents:
62143
diff
changeset
|
4 |
imports FOL |
17456 | 5 |
begin |
0 | 6 |
|
39128
93a7365fb4ee
turned eta_contract into proper configuration option;
wenzelm
parents:
38499
diff
changeset
|
7 |
declare [[eta_contract]] |
93a7365fb4ee
turned eta_contract into proper configuration option;
wenzelm
parents:
38499
diff
changeset
|
8 |
|
17456 | 9 |
typedecl 'a set |
55380
4de48353034e
prefer vacuous definitional type classes over axiomatic ones;
wenzelm
parents:
48475
diff
changeset
|
10 |
instance set :: ("term") "term" .. |
0 | 11 |
|
62143 | 12 |
|
13 |
subsection \<open>Set comprehension and membership\<close> |
|
14 |
||
15 |
axiomatization Collect :: "['a \<Rightarrow> o] \<Rightarrow> 'a set" |
|
16 |
and mem :: "['a, 'a set] \<Rightarrow> o" (infixl ":" 50) |
|
17 |
where mem_Collect_iff: "(a : Collect(P)) \<longleftrightarrow> P(a)" |
|
18 |
and set_extension: "A = B \<longleftrightarrow> (ALL x. x:A \<longleftrightarrow> x:B)" |
|
0 | 19 |
|
3935 | 20 |
syntax |
62143 | 21 |
"_Coll" :: "[idt, o] \<Rightarrow> 'a set" ("(1{_./ _})") |
80761 | 22 |
syntax_consts |
23 |
"_Coll" == Collect |
|
0 | 24 |
translations |
62143 | 25 |
"{x. P}" == "CONST Collect(\<lambda>x. P)" |
20140 | 26 |
|
58977 | 27 |
lemma CollectI: "P(a) \<Longrightarrow> a : {x. P(x)}" |
20140 | 28 |
apply (rule mem_Collect_iff [THEN iffD2]) |
29 |
apply assumption |
|
30 |
done |
|
31 |
||
58977 | 32 |
lemma CollectD: "a : {x. P(x)} \<Longrightarrow> P(a)" |
20140 | 33 |
apply (erule mem_Collect_iff [THEN iffD1]) |
34 |
done |
|
35 |
||
36 |
lemmas CollectE = CollectD [elim_format] |
|
37 |
||
58977 | 38 |
lemma set_ext: "(\<And>x. x:A \<longleftrightarrow> x:B) \<Longrightarrow> A = B" |
20140 | 39 |
apply (rule set_extension [THEN iffD2]) |
40 |
apply simp |
|
41 |
done |
|
42 |
||
43 |
||
60770 | 44 |
subsection \<open>Bounded quantifiers\<close> |
20140 | 45 |
|
62143 | 46 |
definition Ball :: "['a set, 'a \<Rightarrow> o] \<Rightarrow> o" |
47 |
where "Ball(A, P) == ALL x. x:A \<longrightarrow> P(x)" |
|
48 |
||
49 |
definition Bex :: "['a set, 'a \<Rightarrow> o] \<Rightarrow> o" |
|
50 |
where "Bex(A, P) == EX x. x:A \<and> P(x)" |
|
51 |
||
52 |
syntax |
|
53 |
"_Ball" :: "[idt, 'a set, o] \<Rightarrow> o" ("(ALL _:_./ _)" [0, 0, 0] 10) |
|
54 |
"_Bex" :: "[idt, 'a set, o] \<Rightarrow> o" ("(EX _:_./ _)" [0, 0, 0] 10) |
|
80761 | 55 |
syntax_consts |
56 |
"_Ball" == Ball and |
|
57 |
"_Bex" == Bex |
|
62143 | 58 |
translations |
59 |
"ALL x:A. P" == "CONST Ball(A, \<lambda>x. P)" |
|
60 |
"EX x:A. P" == "CONST Bex(A, \<lambda>x. P)" |
|
61 |
||
58977 | 62 |
lemma ballI: "(\<And>x. x:A \<Longrightarrow> P(x)) \<Longrightarrow> ALL x:A. P(x)" |
20140 | 63 |
by (simp add: Ball_def) |
64 |
||
58977 | 65 |
lemma bspec: "\<lbrakk>ALL x:A. P(x); x:A\<rbrakk> \<Longrightarrow> P(x)" |
20140 | 66 |
by (simp add: Ball_def) |
67 |
||
58977 | 68 |
lemma ballE: "\<lbrakk>ALL x:A. P(x); P(x) \<Longrightarrow> Q; \<not> x:A \<Longrightarrow> Q\<rbrakk> \<Longrightarrow> Q" |
20140 | 69 |
unfolding Ball_def by blast |
70 |
||
58977 | 71 |
lemma bexI: "\<lbrakk>P(x); x:A\<rbrakk> \<Longrightarrow> EX x:A. P(x)" |
20140 | 72 |
unfolding Bex_def by blast |
73 |
||
58977 | 74 |
lemma bexCI: "\<lbrakk>EX x:A. \<not>P(x) \<Longrightarrow> P(a); a:A\<rbrakk> \<Longrightarrow> EX x:A. P(x)" |
20140 | 75 |
unfolding Bex_def by blast |
76 |
||
58977 | 77 |
lemma bexE: "\<lbrakk>EX x:A. P(x); \<And>x. \<lbrakk>x:A; P(x)\<rbrakk> \<Longrightarrow> Q\<rbrakk> \<Longrightarrow> Q" |
20140 | 78 |
unfolding Bex_def by blast |
79 |
||
80 |
(*Trival rewrite rule; (! x:A.P)=P holds only if A is nonempty!*) |
|
58977 | 81 |
lemma ball_rew: "(ALL x:A. True) \<longleftrightarrow> True" |
20140 | 82 |
by (blast intro: ballI) |
83 |
||
62143 | 84 |
subsubsection \<open>Congruence rules\<close> |
20140 | 85 |
|
86 |
lemma ball_cong: |
|
58977 | 87 |
"\<lbrakk>A = A'; \<And>x. x:A' \<Longrightarrow> P(x) \<longleftrightarrow> P'(x)\<rbrakk> \<Longrightarrow> |
88 |
(ALL x:A. P(x)) \<longleftrightarrow> (ALL x:A'. P'(x))" |
|
20140 | 89 |
by (blast intro: ballI elim: ballE) |
90 |
||
91 |
lemma bex_cong: |
|
58977 | 92 |
"\<lbrakk>A = A'; \<And>x. x:A' \<Longrightarrow> P(x) \<longleftrightarrow> P'(x)\<rbrakk> \<Longrightarrow> |
93 |
(EX x:A. P(x)) \<longleftrightarrow> (EX x:A'. P'(x))" |
|
20140 | 94 |
by (blast intro: bexI elim: bexE) |
95 |
||
96 |
||
62143 | 97 |
subsection \<open>Further operations\<close> |
98 |
||
99 |
definition subset :: "['a set, 'a set] \<Rightarrow> o" (infixl "<=" 50) |
|
100 |
where "A <= B == ALL x:A. x:B" |
|
101 |
||
102 |
definition mono :: "['a set \<Rightarrow> 'b set] \<Rightarrow> o" |
|
103 |
where "mono(f) == (ALL A B. A <= B \<longrightarrow> f(A) <= f(B))" |
|
104 |
||
105 |
definition singleton :: "'a \<Rightarrow> 'a set" ("{_}") |
|
106 |
where "{a} == {x. x=a}" |
|
107 |
||
108 |
definition empty :: "'a set" ("{}") |
|
109 |
where "{} == {x. False}" |
|
110 |
||
111 |
definition Un :: "['a set, 'a set] \<Rightarrow> 'a set" (infixl "Un" 65) |
|
112 |
where "A Un B == {x. x:A | x:B}" |
|
113 |
||
114 |
definition Int :: "['a set, 'a set] \<Rightarrow> 'a set" (infixl "Int" 70) |
|
115 |
where "A Int B == {x. x:A \<and> x:B}" |
|
116 |
||
117 |
definition Compl :: "('a set) \<Rightarrow> 'a set" |
|
118 |
where "Compl(A) == {x. \<not>x:A}" |
|
119 |
||
120 |
||
121 |
subsection \<open>Big Intersection / Union\<close> |
|
122 |
||
123 |
definition INTER :: "['a set, 'a \<Rightarrow> 'b set] \<Rightarrow> 'b set" |
|
124 |
where "INTER(A, B) == {y. ALL x:A. y: B(x)}" |
|
125 |
||
126 |
definition UNION :: "['a set, 'a \<Rightarrow> 'b set] \<Rightarrow> 'b set" |
|
127 |
where "UNION(A, B) == {y. EX x:A. y: B(x)}" |
|
128 |
||
129 |
syntax |
|
130 |
"_INTER" :: "[idt, 'a set, 'b set] \<Rightarrow> 'b set" ("(INT _:_./ _)" [0, 0, 0] 10) |
|
131 |
"_UNION" :: "[idt, 'a set, 'b set] \<Rightarrow> 'b set" ("(UN _:_./ _)" [0, 0, 0] 10) |
|
80761 | 132 |
syntax_consts |
133 |
"_INTER" == INTER and |
|
134 |
"_UNION" == UNION |
|
62143 | 135 |
translations |
136 |
"INT x:A. B" == "CONST INTER(A, \<lambda>x. B)" |
|
137 |
"UN x:A. B" == "CONST UNION(A, \<lambda>x. B)" |
|
138 |
||
139 |
definition Inter :: "(('a set)set) \<Rightarrow> 'a set" |
|
140 |
where "Inter(S) == (INT x:S. x)" |
|
141 |
||
142 |
definition Union :: "(('a set)set) \<Rightarrow> 'a set" |
|
143 |
where "Union(S) == (UN x:S. x)" |
|
144 |
||
145 |
||
60770 | 146 |
subsection \<open>Rules for subsets\<close> |
20140 | 147 |
|
58977 | 148 |
lemma subsetI: "(\<And>x. x:A \<Longrightarrow> x:B) \<Longrightarrow> A <= B" |
20140 | 149 |
unfolding subset_def by (blast intro: ballI) |
150 |
||
151 |
(*Rule in Modus Ponens style*) |
|
58977 | 152 |
lemma subsetD: "\<lbrakk>A <= B; c:A\<rbrakk> \<Longrightarrow> c:B" |
20140 | 153 |
unfolding subset_def by (blast elim: ballE) |
154 |
||
155 |
(*Classical elimination rule*) |
|
58977 | 156 |
lemma subsetCE: "\<lbrakk>A <= B; \<not>(c:A) \<Longrightarrow> P; c:B \<Longrightarrow> P\<rbrakk> \<Longrightarrow> P" |
20140 | 157 |
by (blast dest: subsetD) |
158 |
||
159 |
lemma subset_refl: "A <= A" |
|
160 |
by (blast intro: subsetI) |
|
161 |
||
58977 | 162 |
lemma subset_trans: "\<lbrakk>A <= B; B <= C\<rbrakk> \<Longrightarrow> A <= C" |
20140 | 163 |
by (blast intro: subsetI dest: subsetD) |
164 |
||
165 |
||
60770 | 166 |
subsection \<open>Rules for equality\<close> |
20140 | 167 |
|
168 |
(*Anti-symmetry of the subset relation*) |
|
58977 | 169 |
lemma subset_antisym: "\<lbrakk>A <= B; B <= A\<rbrakk> \<Longrightarrow> A = B" |
20140 | 170 |
by (blast intro: set_ext dest: subsetD) |
171 |
||
172 |
lemmas equalityI = subset_antisym |
|
173 |
||
174 |
(* Equality rules from ZF set theory -- are they appropriate here? *) |
|
58977 | 175 |
lemma equalityD1: "A = B \<Longrightarrow> A<=B" |
176 |
and equalityD2: "A = B \<Longrightarrow> B<=A" |
|
20140 | 177 |
by (simp_all add: subset_refl) |
178 |
||
58977 | 179 |
lemma equalityE: "\<lbrakk>A = B; \<lbrakk>A <= B; B <= A\<rbrakk> \<Longrightarrow> P\<rbrakk> \<Longrightarrow> P" |
20140 | 180 |
by (simp add: subset_refl) |
181 |
||
58977 | 182 |
lemma equalityCE: "\<lbrakk>A = B; \<lbrakk>c:A; c:B\<rbrakk> \<Longrightarrow> P; \<lbrakk>\<not> c:A; \<not> c:B\<rbrakk> \<Longrightarrow> P\<rbrakk> \<Longrightarrow> P" |
20140 | 183 |
by (blast elim: equalityE subsetCE) |
184 |
||
185 |
lemma trivial_set: "{x. x:A} = A" |
|
186 |
by (blast intro: equalityI subsetI CollectI dest: CollectD) |
|
187 |
||
188 |
||
60770 | 189 |
subsection \<open>Rules for binary union\<close> |
20140 | 190 |
|
58977 | 191 |
lemma UnI1: "c:A \<Longrightarrow> c : A Un B" |
192 |
and UnI2: "c:B \<Longrightarrow> c : A Un B" |
|
20140 | 193 |
unfolding Un_def by (blast intro: CollectI)+ |
194 |
||
195 |
(*Classical introduction rule: no commitment to A vs B*) |
|
58977 | 196 |
lemma UnCI: "(\<not>c:B \<Longrightarrow> c:A) \<Longrightarrow> c : A Un B" |
20140 | 197 |
by (blast intro: UnI1 UnI2) |
198 |
||
58977 | 199 |
lemma UnE: "\<lbrakk>c : A Un B; c:A \<Longrightarrow> P; c:B \<Longrightarrow> P\<rbrakk> \<Longrightarrow> P" |
20140 | 200 |
unfolding Un_def by (blast dest: CollectD) |
201 |
||
202 |
||
60770 | 203 |
subsection \<open>Rules for small intersection\<close> |
20140 | 204 |
|
58977 | 205 |
lemma IntI: "\<lbrakk>c:A; c:B\<rbrakk> \<Longrightarrow> c : A Int B" |
20140 | 206 |
unfolding Int_def by (blast intro: CollectI) |
207 |
||
58977 | 208 |
lemma IntD1: "c : A Int B \<Longrightarrow> c:A" |
209 |
and IntD2: "c : A Int B \<Longrightarrow> c:B" |
|
20140 | 210 |
unfolding Int_def by (blast dest: CollectD)+ |
211 |
||
58977 | 212 |
lemma IntE: "\<lbrakk>c : A Int B; \<lbrakk>c:A; c:B\<rbrakk> \<Longrightarrow> P\<rbrakk> \<Longrightarrow> P" |
20140 | 213 |
by (blast dest: IntD1 IntD2) |
214 |
||
215 |
||
60770 | 216 |
subsection \<open>Rules for set complement\<close> |
20140 | 217 |
|
58977 | 218 |
lemma ComplI: "(c:A \<Longrightarrow> False) \<Longrightarrow> c : Compl(A)" |
20140 | 219 |
unfolding Compl_def by (blast intro: CollectI) |
220 |
||
221 |
(*This form, with negated conclusion, works well with the Classical prover. |
|
222 |
Negated assumptions behave like formulae on the right side of the notional |
|
223 |
turnstile...*) |
|
58977 | 224 |
lemma ComplD: "c : Compl(A) \<Longrightarrow> \<not>c:A" |
20140 | 225 |
unfolding Compl_def by (blast dest: CollectD) |
226 |
||
227 |
lemmas ComplE = ComplD [elim_format] |
|
228 |
||
229 |
||
60770 | 230 |
subsection \<open>Empty sets\<close> |
20140 | 231 |
|
232 |
lemma empty_eq: "{x. False} = {}" |
|
233 |
by (simp add: empty_def) |
|
234 |
||
58977 | 235 |
lemma emptyD: "a : {} \<Longrightarrow> P" |
20140 | 236 |
unfolding empty_def by (blast dest: CollectD) |
237 |
||
238 |
lemmas emptyE = emptyD [elim_format] |
|
239 |
||
240 |
lemma not_emptyD: |
|
58977 | 241 |
assumes "\<not> A={}" |
20140 | 242 |
shows "EX x. x:A" |
243 |
proof - |
|
244 |
have "\<not> (EX x. x:A) \<Longrightarrow> A = {}" |
|
245 |
by (rule equalityI) (blast intro!: subsetI elim!: emptyD)+ |
|
41526 | 246 |
with assms show ?thesis by blast |
20140 | 247 |
qed |
248 |
||
249 |
||
60770 | 250 |
subsection \<open>Singleton sets\<close> |
20140 | 251 |
|
252 |
lemma singletonI: "a : {a}" |
|
253 |
unfolding singleton_def by (blast intro: CollectI) |
|
254 |
||
58977 | 255 |
lemma singletonD: "b : {a} \<Longrightarrow> b=a" |
20140 | 256 |
unfolding singleton_def by (blast dest: CollectD) |
257 |
||
258 |
lemmas singletonE = singletonD [elim_format] |
|
259 |
||
260 |
||
60770 | 261 |
subsection \<open>Unions of families\<close> |
20140 | 262 |
|
263 |
(*The order of the premises presupposes that A is rigid; b may be flexible*) |
|
58977 | 264 |
lemma UN_I: "\<lbrakk>a:A; b: B(a)\<rbrakk> \<Longrightarrow> b: (UN x:A. B(x))" |
20140 | 265 |
unfolding UNION_def by (blast intro: bexI CollectI) |
266 |
||
58977 | 267 |
lemma UN_E: "\<lbrakk>b : (UN x:A. B(x)); \<And>x. \<lbrakk>x:A; b: B(x)\<rbrakk> \<Longrightarrow> R\<rbrakk> \<Longrightarrow> R" |
20140 | 268 |
unfolding UNION_def by (blast dest: CollectD elim: bexE) |
269 |
||
58977 | 270 |
lemma UN_cong: "\<lbrakk>A = B; \<And>x. x:B \<Longrightarrow> C(x) = D(x)\<rbrakk> \<Longrightarrow> (UN x:A. C(x)) = (UN x:B. D(x))" |
20140 | 271 |
by (simp add: UNION_def cong: bex_cong) |
272 |
||
273 |
||
60770 | 274 |
subsection \<open>Intersections of families\<close> |
20140 | 275 |
|
58977 | 276 |
lemma INT_I: "(\<And>x. x:A \<Longrightarrow> b: B(x)) \<Longrightarrow> b : (INT x:A. B(x))" |
20140 | 277 |
unfolding INTER_def by (blast intro: CollectI ballI) |
278 |
||
58977 | 279 |
lemma INT_D: "\<lbrakk>b : (INT x:A. B(x)); a:A\<rbrakk> \<Longrightarrow> b: B(a)" |
20140 | 280 |
unfolding INTER_def by (blast dest: CollectD bspec) |
281 |
||
282 |
(*"Classical" elimination rule -- does not require proving X:C *) |
|
58977 | 283 |
lemma INT_E: "\<lbrakk>b : (INT x:A. B(x)); b: B(a) \<Longrightarrow> R; \<not> a:A \<Longrightarrow> R\<rbrakk> \<Longrightarrow> R" |
20140 | 284 |
unfolding INTER_def by (blast dest: CollectD bspec) |
285 |
||
58977 | 286 |
lemma INT_cong: "\<lbrakk>A = B; \<And>x. x:B \<Longrightarrow> C(x) = D(x)\<rbrakk> \<Longrightarrow> (INT x:A. C(x)) = (INT x:B. D(x))" |
20140 | 287 |
by (simp add: INTER_def cong: ball_cong) |
288 |
||
289 |
||
60770 | 290 |
subsection \<open>Rules for Unions\<close> |
20140 | 291 |
|
292 |
(*The order of the premises presupposes that C is rigid; A may be flexible*) |
|
58977 | 293 |
lemma UnionI: "\<lbrakk>X:C; A:X\<rbrakk> \<Longrightarrow> A : Union(C)" |
20140 | 294 |
unfolding Union_def by (blast intro: UN_I) |
295 |
||
58977 | 296 |
lemma UnionE: "\<lbrakk>A : Union(C); \<And>X. \<lbrakk> A:X; X:C\<rbrakk> \<Longrightarrow> R\<rbrakk> \<Longrightarrow> R" |
20140 | 297 |
unfolding Union_def by (blast elim: UN_E) |
298 |
||
299 |
||
60770 | 300 |
subsection \<open>Rules for Inter\<close> |
20140 | 301 |
|
58977 | 302 |
lemma InterI: "(\<And>X. X:C \<Longrightarrow> A:X) \<Longrightarrow> A : Inter(C)" |
20140 | 303 |
unfolding Inter_def by (blast intro: INT_I) |
304 |
||
305 |
(*A "destruct" rule -- every X in C contains A as an element, but |
|
306 |
A:X can hold when X:C does not! This rule is analogous to "spec". *) |
|
58977 | 307 |
lemma InterD: "\<lbrakk>A : Inter(C); X:C\<rbrakk> \<Longrightarrow> A:X" |
20140 | 308 |
unfolding Inter_def by (blast dest: INT_D) |
309 |
||
310 |
(*"Classical" elimination rule -- does not require proving X:C *) |
|
58977 | 311 |
lemma InterE: "\<lbrakk>A : Inter(C); A:X \<Longrightarrow> R; \<not> X:C \<Longrightarrow> R\<rbrakk> \<Longrightarrow> R" |
20140 | 312 |
unfolding Inter_def by (blast elim: INT_E) |
313 |
||
314 |
||
60770 | 315 |
section \<open>Derived rules involving subsets; Union and Intersection as lattice operations\<close> |
20140 | 316 |
|
60770 | 317 |
subsection \<open>Big Union -- least upper bound of a set\<close> |
20140 | 318 |
|
58977 | 319 |
lemma Union_upper: "B:A \<Longrightarrow> B <= Union(A)" |
20140 | 320 |
by (blast intro: subsetI UnionI) |
321 |
||
58977 | 322 |
lemma Union_least: "(\<And>X. X:A \<Longrightarrow> X<=C) \<Longrightarrow> Union(A) <= C" |
20140 | 323 |
by (blast intro: subsetI dest: subsetD elim: UnionE) |
324 |
||
325 |
||
60770 | 326 |
subsection \<open>Big Intersection -- greatest lower bound of a set\<close> |
20140 | 327 |
|
58977 | 328 |
lemma Inter_lower: "B:A \<Longrightarrow> Inter(A) <= B" |
20140 | 329 |
by (blast intro: subsetI dest: InterD) |
330 |
||
58977 | 331 |
lemma Inter_greatest: "(\<And>X. X:A \<Longrightarrow> C<=X) \<Longrightarrow> C <= Inter(A)" |
20140 | 332 |
by (blast intro: subsetI InterI dest: subsetD) |
333 |
||
334 |
||
60770 | 335 |
subsection \<open>Finite Union -- the least upper bound of 2 sets\<close> |
20140 | 336 |
|
337 |
lemma Un_upper1: "A <= A Un B" |
|
338 |
by (blast intro: subsetI UnI1) |
|
339 |
||
340 |
lemma Un_upper2: "B <= A Un B" |
|
341 |
by (blast intro: subsetI UnI2) |
|
342 |
||
58977 | 343 |
lemma Un_least: "\<lbrakk>A<=C; B<=C\<rbrakk> \<Longrightarrow> A Un B <= C" |
20140 | 344 |
by (blast intro: subsetI elim: UnE dest: subsetD) |
345 |
||
346 |
||
60770 | 347 |
subsection \<open>Finite Intersection -- the greatest lower bound of 2 sets\<close> |
20140 | 348 |
|
349 |
lemma Int_lower1: "A Int B <= A" |
|
350 |
by (blast intro: subsetI elim: IntE) |
|
351 |
||
352 |
lemma Int_lower2: "A Int B <= B" |
|
353 |
by (blast intro: subsetI elim: IntE) |
|
354 |
||
58977 | 355 |
lemma Int_greatest: "\<lbrakk>C<=A; C<=B\<rbrakk> \<Longrightarrow> C <= A Int B" |
20140 | 356 |
by (blast intro: subsetI IntI dest: subsetD) |
357 |
||
358 |
||
60770 | 359 |
subsection \<open>Monotonicity\<close> |
20140 | 360 |
|
58977 | 361 |
lemma monoI: "(\<And>A B. A <= B \<Longrightarrow> f(A) <= f(B)) \<Longrightarrow> mono(f)" |
20140 | 362 |
unfolding mono_def by blast |
363 |
||
58977 | 364 |
lemma monoD: "\<lbrakk>mono(f); A <= B\<rbrakk> \<Longrightarrow> f(A) <= f(B)" |
20140 | 365 |
unfolding mono_def by blast |
366 |
||
58977 | 367 |
lemma mono_Un: "mono(f) \<Longrightarrow> f(A) Un f(B) <= f(A Un B)" |
20140 | 368 |
by (blast intro: Un_least dest: monoD intro: Un_upper1 Un_upper2) |
369 |
||
58977 | 370 |
lemma mono_Int: "mono(f) \<Longrightarrow> f(A Int B) <= f(A) Int f(B)" |
20140 | 371 |
by (blast intro: Int_greatest dest: monoD intro: Int_lower1 Int_lower2) |
372 |
||
373 |
||
60770 | 374 |
subsection \<open>Automated reasoning setup\<close> |
20140 | 375 |
|
376 |
lemmas [intro!] = ballI subsetI InterI INT_I CollectI ComplI IntI UnCI singletonI |
|
377 |
and [intro] = bexI UnionI UN_I |
|
378 |
and [elim!] = bexE UnionE UN_E CollectE ComplE IntE UnE emptyE singletonE |
|
379 |
and [elim] = ballE InterD InterE INT_D INT_E subsetD subsetCE |
|
380 |
||
381 |
lemma mem_rews: |
|
58977 | 382 |
"(a : A Un B) \<longleftrightarrow> (a:A | a:B)" |
383 |
"(a : A Int B) \<longleftrightarrow> (a:A \<and> a:B)" |
|
384 |
"(a : Compl(B)) \<longleftrightarrow> (\<not>a:B)" |
|
385 |
"(a : {b}) \<longleftrightarrow> (a=b)" |
|
386 |
"(a : {}) \<longleftrightarrow> False" |
|
387 |
"(a : {x. P(x)}) \<longleftrightarrow> P(a)" |
|
20140 | 388 |
by blast+ |
389 |
||
390 |
lemmas [simp] = trivial_set empty_eq mem_rews |
|
391 |
and [cong] = ball_cong bex_cong INT_cong UN_cong |
|
392 |
||
393 |
||
60770 | 394 |
section \<open>Equalities involving union, intersection, inclusion, etc.\<close> |
20140 | 395 |
|
60770 | 396 |
subsection \<open>Binary Intersection\<close> |
20140 | 397 |
|
398 |
lemma Int_absorb: "A Int A = A" |
|
399 |
by (blast intro: equalityI) |
|
400 |
||
401 |
lemma Int_commute: "A Int B = B Int A" |
|
402 |
by (blast intro: equalityI) |
|
403 |
||
404 |
lemma Int_assoc: "(A Int B) Int C = A Int (B Int C)" |
|
405 |
by (blast intro: equalityI) |
|
406 |
||
407 |
lemma Int_Un_distrib: "(A Un B) Int C = (A Int C) Un (B Int C)" |
|
408 |
by (blast intro: equalityI) |
|
409 |
||
58977 | 410 |
lemma subset_Int_eq: "(A<=B) \<longleftrightarrow> (A Int B = A)" |
20140 | 411 |
by (blast intro: equalityI elim: equalityE) |
412 |
||
413 |
||
60770 | 414 |
subsection \<open>Binary Union\<close> |
20140 | 415 |
|
416 |
lemma Un_absorb: "A Un A = A" |
|
417 |
by (blast intro: equalityI) |
|
418 |
||
419 |
lemma Un_commute: "A Un B = B Un A" |
|
420 |
by (blast intro: equalityI) |
|
421 |
||
422 |
lemma Un_assoc: "(A Un B) Un C = A Un (B Un C)" |
|
423 |
by (blast intro: equalityI) |
|
424 |
||
425 |
lemma Un_Int_distrib: "(A Int B) Un C = (A Un C) Int (B Un C)" |
|
426 |
by (blast intro: equalityI) |
|
427 |
||
428 |
lemma Un_Int_crazy: |
|
429 |
"(A Int B) Un (B Int C) Un (C Int A) = (A Un B) Int (B Un C) Int (C Un A)" |
|
430 |
by (blast intro: equalityI) |
|
431 |
||
58977 | 432 |
lemma subset_Un_eq: "(A<=B) \<longleftrightarrow> (A Un B = B)" |
20140 | 433 |
by (blast intro: equalityI elim: equalityE) |
434 |
||
435 |
||
62020 | 436 |
subsection \<open>Simple properties of \<open>Compl\<close> -- complement of a set\<close> |
20140 | 437 |
|
438 |
lemma Compl_disjoint: "A Int Compl(A) = {x. False}" |
|
439 |
by (blast intro: equalityI) |
|
440 |
||
441 |
lemma Compl_partition: "A Un Compl(A) = {x. True}" |
|
442 |
by (blast intro: equalityI) |
|
443 |
||
444 |
lemma double_complement: "Compl(Compl(A)) = A" |
|
445 |
by (blast intro: equalityI) |
|
446 |
||
447 |
lemma Compl_Un: "Compl(A Un B) = Compl(A) Int Compl(B)" |
|
448 |
by (blast intro: equalityI) |
|
449 |
||
450 |
lemma Compl_Int: "Compl(A Int B) = Compl(A) Un Compl(B)" |
|
451 |
by (blast intro: equalityI) |
|
452 |
||
453 |
lemma Compl_UN: "Compl(UN x:A. B(x)) = (INT x:A. Compl(B(x)))" |
|
454 |
by (blast intro: equalityI) |
|
455 |
||
456 |
lemma Compl_INT: "Compl(INT x:A. B(x)) = (UN x:A. Compl(B(x)))" |
|
457 |
by (blast intro: equalityI) |
|
458 |
||
459 |
(*Halmos, Naive Set Theory, page 16.*) |
|
58977 | 460 |
lemma Un_Int_assoc_eq: "((A Int B) Un C = A Int (B Un C)) \<longleftrightarrow> (C<=A)" |
20140 | 461 |
by (blast intro: equalityI elim: equalityE) |
462 |
||
463 |
||
60770 | 464 |
subsection \<open>Big Union and Intersection\<close> |
20140 | 465 |
|
466 |
lemma Union_Un_distrib: "Union(A Un B) = Union(A) Un Union(B)" |
|
467 |
by (blast intro: equalityI) |
|
468 |
||
469 |
lemma Union_disjoint: |
|
58977 | 470 |
"(Union(C) Int A = {x. False}) \<longleftrightarrow> (ALL B:C. B Int A = {x. False})" |
20140 | 471 |
by (blast intro: equalityI elim: equalityE) |
472 |
||
473 |
lemma Inter_Un_distrib: "Inter(A Un B) = Inter(A) Int Inter(B)" |
|
474 |
by (blast intro: equalityI) |
|
475 |
||
476 |
||
60770 | 477 |
subsection \<open>Unions and Intersections of Families\<close> |
20140 | 478 |
|
479 |
lemma UN_eq: "(UN x:A. B(x)) = Union({Y. EX x:A. Y=B(x)})" |
|
480 |
by (blast intro: equalityI) |
|
481 |
||
482 |
(*Look: it has an EXISTENTIAL quantifier*) |
|
483 |
lemma INT_eq: "(INT x:A. B(x)) = Inter({Y. EX x:A. Y=B(x)})" |
|
484 |
by (blast intro: equalityI) |
|
485 |
||
486 |
lemma Int_Union_image: "A Int Union(B) = (UN C:B. A Int C)" |
|
487 |
by (blast intro: equalityI) |
|
488 |
||
489 |
lemma Un_Inter_image: "A Un Inter(B) = (INT C:B. A Un C)" |
|
490 |
by (blast intro: equalityI) |
|
491 |
||
492 |
||
60770 | 493 |
section \<open>Monotonicity of various operations\<close> |
20140 | 494 |
|
58977 | 495 |
lemma Union_mono: "A<=B \<Longrightarrow> Union(A) <= Union(B)" |
20140 | 496 |
by blast |
497 |
||
58977 | 498 |
lemma Inter_anti_mono: "B <= A \<Longrightarrow> Inter(A) <= Inter(B)" |
20140 | 499 |
by blast |
500 |
||
58977 | 501 |
lemma UN_mono: "\<lbrakk>A <= B; \<And>x. x:A \<Longrightarrow> f(x)<=g(x)\<rbrakk> \<Longrightarrow> (UN x:A. f(x)) <= (UN x:B. g(x))" |
20140 | 502 |
by blast |
503 |
||
58977 | 504 |
lemma INT_anti_mono: "\<lbrakk>B <= A; \<And>x. x:A \<Longrightarrow> f(x) <= g(x)\<rbrakk> \<Longrightarrow> (INT x:A. f(x)) <= (INT x:A. g(x))" |
20140 | 505 |
by blast |
506 |
||
58977 | 507 |
lemma Un_mono: "\<lbrakk>A <= C; B <= D\<rbrakk> \<Longrightarrow> A Un B <= C Un D" |
20140 | 508 |
by blast |
509 |
||
58977 | 510 |
lemma Int_mono: "\<lbrakk>A <= C; B <= D\<rbrakk> \<Longrightarrow> A Int B <= C Int D" |
20140 | 511 |
by blast |
512 |
||
58977 | 513 |
lemma Compl_anti_mono: "A <= B \<Longrightarrow> Compl(B) <= Compl(A)" |
20140 | 514 |
by blast |
0 | 515 |
|
516 |
end |