1 theory Examples = Main:
3 ML "reset eta_contract"
4 ML "Pretty.setmargin 64"
6 text{*membership, intersection *}
7 text{*difference and empty set*}
8 text{*complement, union and universal set*}
10 lemma "(x \<in> A \<inter> B) = (x \<in> A \<and> x \<in> B)"
15 @{thm[display] IntI[no_vars]}
18 @{thm[display] IntD1[no_vars]}
21 @{thm[display] IntD2[no_vars]}
25 lemma "(x \<in> -A) = (x \<notin> A)"
30 @{thm[display] Compl_iff[no_vars]}
34 lemma "- (A \<union> B) = -A \<inter> -B"
39 @{thm[display] Compl_Un[no_vars]}
48 @{thm[display] Diff_disjoint[no_vars]}
49 \rulename{Diff_disjoint}
54 lemma "A \<union> -A = UNIV"
59 @{thm[display] Compl_partition[no_vars]}
60 \rulename{Compl_partition}
63 text{*subset relation*}
67 @{thm[display] subsetI[no_vars]}
70 @{thm[display] subsetD[no_vars]}
74 lemma "((A \<union> B) \<subseteq> C) = (A \<subseteq> C \<and> B \<subseteq> C)"
79 @{thm[display] Un_subset_iff[no_vars]}
80 \rulename{Un_subset_iff}
83 lemma "(A \<subseteq> -B) = (B \<subseteq> -A)"
87 lemma "(A <= -B) = (B <= -A)"
90 text{*ASCII version: blast fails because of overloading because
91 it doesn't have to be sets*}
93 lemma "((A:: 'a set) <= -B) = (B <= -A)"
97 text{*A type constraint lets it work*}
99 text{*An issue here: how do we discuss the distinction between ASCII and
100 X-symbol notation? Here the latter disambiguates.*}
106 @{thm[display] set_ext[no_vars]}
109 @{thm[display] equalityI[no_vars]}
112 @{thm[display] equalityE[no_vars]}
117 text{*finite sets: insertion and membership relation*}
118 text{*finite set notation*}
120 lemma "insert x A = {x} \<union> A"
125 @{thm[display] insert_is_Un[no_vars]}
126 \rulename{insert_is_Un}
129 lemma "{a,b} \<union> {c,d} = {a,b,c,d}"
133 lemma "{a,b} \<inter> {b,c} = {b}"
136 text{*fails because it isn't valid*}
138 lemma "{a,b} \<inter> {b,c} = (if a=c then {a,b} else {b})"
143 text{*or just force or auto. blast alone can't handle the if-then-else*}
145 text{*next: some comprehension examples*}
147 lemma "(a \<in> {z. P z}) = P a"
152 @{thm[display] mem_Collect_eq[no_vars]}
153 \rulename{mem_Collect_eq}
156 lemma "{x. x \<in> A} = A"
161 @{thm[display] Collect_mem_eq[no_vars]}
162 \rulename{Collect_mem_eq}
165 lemma "{x. P x \<or> x \<in> A} = {x. P x} \<union> A"
169 lemma "{x. P x \<longrightarrow> Q x} = -{x. P x} \<union> {x. Q x}"
175 "prime == {p. 1<p & (ALL m. m dvd p --> m=1 | m=p)}"
177 lemma "{p*q | p q. p\<in>prime \<and> q\<in>prime} =
178 {z. \<exists>p q. z = p*q \<and> p\<in>prime \<and> q\<in>prime}"
184 text{*bounded quantifiers*}
186 lemma "(\<exists>x\<in>A. P x) = (\<exists>x. x\<in>A \<and> P x)"
191 @{thm[display] bexI[no_vars]}
196 @{thm[display] bexE[no_vars]}
200 lemma "(\<forall>x\<in>A. P x) = (\<forall>x. x\<in>A \<longrightarrow> P x)"
205 @{thm[display] ballI[no_vars]}
210 @{thm[display] bspec[no_vars]}
214 text{*indexed unions and variations*}
216 lemma "(\<Union>x. B x) = (\<Union>x\<in>UNIV. B x)"
221 @{thm[display] UN_iff[no_vars]}
226 @{thm[display] Union_iff[no_vars]}
230 lemma "(\<Union>x\<in>A. B x) = {y. \<exists>x\<in>A. y \<in> B x}"
234 lemma "\<Union>S = (\<Union>x\<in>S. x)"
239 @{thm[display] UN_I[no_vars]}
244 @{thm[display] UN_E[no_vars]}
248 text{*indexed intersections*}
250 lemma "(\<Inter>x. B x) = {y. \<forall>x. y \<in> B x}"
255 @{thm[display] INT_iff[no_vars]}
260 @{thm[display] Inter_iff[no_vars]}
264 text{*mention also card, Pow, etc.*}
268 @{thm[display] card_Un_Int[no_vars]}
269 \rulename{card_Un_Int}
271 @{thm[display] card_Pow[no_vars]}
274 @{thm[display] n_subsets[no_vars]}