2 theory Examples imports Main Binomial begin
4 ML "reset eta_contract"
5 ML "Pretty.setmargin 64"
7 text{*membership, intersection *}
8 text{*difference and empty set*}
9 text{*complement, union and universal set*}
11 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)"
29 @{thm[display] Compl_iff[no_vars]}
33 lemma "- (A \<union> B) = -A \<inter> -B"
37 @{thm[display] Compl_Un[no_vars]}
45 @{thm[display] Diff_disjoint[no_vars]}
46 \rulename{Diff_disjoint}
51 lemma "A \<union> -A = UNIV"
55 @{thm[display] Compl_partition[no_vars]}
56 \rulename{Compl_partition}
59 text{*subset relation*}
63 @{thm[display] subsetI[no_vars]}
66 @{thm[display] subsetD[no_vars]}
70 lemma "((A \<union> B) \<subseteq> C) = (A \<subseteq> C \<and> B \<subseteq> C)"
74 @{thm[display] Un_subset_iff[no_vars]}
75 \rulename{Un_subset_iff}
78 lemma "(A \<subseteq> -B) = (B \<subseteq> -A)"
81 lemma "(A <= -B) = (B <= -A)"
84 text{*ASCII version: blast fails because of overloading because
85 it doesn't have to be sets*}
87 lemma "((A:: 'a set) <= -B) = (B <= -A)"
90 text{*A type constraint lets it work*}
92 text{*An issue here: how do we discuss the distinction between ASCII and
93 symbol notation? Here the latter disambiguates.*}
99 @{thm[display] set_ext[no_vars]}
102 @{thm[display] equalityI[no_vars]}
105 @{thm[display] equalityE[no_vars]}
110 text{*finite sets: insertion and membership relation*}
111 text{*finite set notation*}
113 lemma "insert x A = {x} \<union> A"
117 @{thm[display] insert_is_Un[no_vars]}
118 \rulename{insert_is_Un}
121 lemma "{a,b} \<union> {c,d} = {a,b,c,d}"
124 lemma "{a,b} \<inter> {b,c} = {b}"
127 text{*fails because it isn't valid*}
129 lemma "{a,b} \<inter> {b,c} = (if a=c then {a,b} else {b})"
133 text{*or just force or auto. blast alone can't handle the if-then-else*}
135 text{*next: some comprehension examples*}
137 lemma "(a \<in> {z. P z}) = P a"
141 @{thm[display] mem_Collect_eq[no_vars]}
142 \rulename{mem_Collect_eq}
145 lemma "{x. x \<in> A} = A"
149 @{thm[display] Collect_mem_eq[no_vars]}
150 \rulename{Collect_mem_eq}
153 lemma "{x. P x \<or> x \<in> A} = {x. P x} \<union> A"
156 lemma "{x. P x \<longrightarrow> Q x} = -{x. P x} \<union> {x. Q x}"
161 "prime == {p. 1<p & (ALL m. m dvd p --> m=1 | m=p)}"
163 lemma "{p*q | p q. p\<in>prime \<and> q\<in>prime} =
164 {z. \<exists>p q. z = p*q \<and> p\<in>prime \<and> q\<in>prime}"
169 text{*bounded quantifiers*}
171 lemma "(\<exists>x\<in>A. P x) = (\<exists>x. x\<in>A \<and> P x)"
175 @{thm[display] bexI[no_vars]}
180 @{thm[display] bexE[no_vars]}
184 lemma "(\<forall>x\<in>A. P x) = (\<forall>x. x\<in>A \<longrightarrow> P x)"
188 @{thm[display] ballI[no_vars]}
193 @{thm[display] bspec[no_vars]}
197 text{*indexed unions and variations*}
199 lemma "(\<Union>x. B x) = (\<Union>x\<in>UNIV. B x)"
203 @{thm[display] UN_iff[no_vars]}
208 @{thm[display] Union_iff[no_vars]}
212 lemma "(\<Union>x\<in>A. B x) = {y. \<exists>x\<in>A. y \<in> B x}"
215 lemma "\<Union>S = (\<Union>x\<in>S. x)"
219 @{thm[display] UN_I[no_vars]}
224 @{thm[display] UN_E[no_vars]}
228 text{*indexed intersections*}
230 lemma "(\<Inter>x. B x) = {y. \<forall>x. y \<in> B x}"
234 @{thm[display] INT_iff[no_vars]}
239 @{thm[display] Inter_iff[no_vars]}
243 text{*mention also card, Pow, etc.*}
247 @{thm[display] card_Un_Int[no_vars]}
248 \rulename{card_Un_Int}
250 @{thm[display] card_Pow[no_vars]}
253 @{thm[display] n_subsets[no_vars]}