8 |
8 |
9 typedecl 'a set |
9 typedecl 'a set |
10 instance set :: ("term") "term" .. |
10 instance set :: ("term") "term" .. |
11 |
11 |
12 consts |
12 consts |
13 Collect :: "['a => o] => 'a set" (*comprehension*) |
13 Collect :: "['a \<Rightarrow> o] \<Rightarrow> 'a set" (*comprehension*) |
14 Compl :: "('a set) => 'a set" (*complement*) |
14 Compl :: "('a set) \<Rightarrow> 'a set" (*complement*) |
15 Int :: "['a set, 'a set] => 'a set" (infixl "Int" 70) |
15 Int :: "['a set, 'a set] \<Rightarrow> 'a set" (infixl "Int" 70) |
16 Un :: "['a set, 'a set] => 'a set" (infixl "Un" 65) |
16 Un :: "['a set, 'a set] \<Rightarrow> 'a set" (infixl "Un" 65) |
17 Union :: "(('a set)set) => 'a set" (*...of a set*) |
17 Union :: "(('a set)set) \<Rightarrow> 'a set" (*...of a set*) |
18 Inter :: "(('a set)set) => 'a set" (*...of a set*) |
18 Inter :: "(('a set)set) \<Rightarrow> 'a set" (*...of a set*) |
19 UNION :: "['a set, 'a => 'b set] => 'b set" (*general*) |
19 UNION :: "['a set, 'a \<Rightarrow> 'b set] \<Rightarrow> 'b set" (*general*) |
20 INTER :: "['a set, 'a => 'b set] => 'b set" (*general*) |
20 INTER :: "['a set, 'a \<Rightarrow> 'b set] \<Rightarrow> 'b set" (*general*) |
21 Ball :: "['a set, 'a => o] => o" (*bounded quants*) |
21 Ball :: "['a set, 'a \<Rightarrow> o] \<Rightarrow> o" (*bounded quants*) |
22 Bex :: "['a set, 'a => o] => o" (*bounded quants*) |
22 Bex :: "['a set, 'a \<Rightarrow> o] \<Rightarrow> o" (*bounded quants*) |
23 mono :: "['a set => 'b set] => o" (*monotonicity*) |
23 mono :: "['a set \<Rightarrow> 'b set] \<Rightarrow> o" (*monotonicity*) |
24 mem :: "['a, 'a set] => o" (infixl ":" 50) (*membership*) |
24 mem :: "['a, 'a set] \<Rightarrow> o" (infixl ":" 50) (*membership*) |
25 subset :: "['a set, 'a set] => o" (infixl "<=" 50) |
25 subset :: "['a set, 'a set] \<Rightarrow> o" (infixl "<=" 50) |
26 singleton :: "'a => 'a set" ("{_}") |
26 singleton :: "'a \<Rightarrow> 'a set" ("{_}") |
27 empty :: "'a set" ("{}") |
27 empty :: "'a set" ("{}") |
28 |
28 |
29 syntax |
29 syntax |
30 "_Coll" :: "[idt, o] => 'a set" ("(1{_./ _})") (*collection*) |
30 "_Coll" :: "[idt, o] \<Rightarrow> 'a set" ("(1{_./ _})") (*collection*) |
31 |
31 |
32 (* Big Intersection / Union *) |
32 (* Big Intersection / Union *) |
33 |
33 |
34 "_INTER" :: "[idt, 'a set, 'b set] => 'b set" ("(INT _:_./ _)" [0, 0, 0] 10) |
34 "_INTER" :: "[idt, 'a set, 'b set] \<Rightarrow> 'b set" ("(INT _:_./ _)" [0, 0, 0] 10) |
35 "_UNION" :: "[idt, 'a set, 'b set] => 'b set" ("(UN _:_./ _)" [0, 0, 0] 10) |
35 "_UNION" :: "[idt, 'a set, 'b set] \<Rightarrow> 'b set" ("(UN _:_./ _)" [0, 0, 0] 10) |
36 |
36 |
37 (* Bounded Quantifiers *) |
37 (* Bounded Quantifiers *) |
38 |
38 |
39 "_Ball" :: "[idt, 'a set, o] => o" ("(ALL _:_./ _)" [0, 0, 0] 10) |
39 "_Ball" :: "[idt, 'a set, o] \<Rightarrow> o" ("(ALL _:_./ _)" [0, 0, 0] 10) |
40 "_Bex" :: "[idt, 'a set, o] => o" ("(EX _:_./ _)" [0, 0, 0] 10) |
40 "_Bex" :: "[idt, 'a set, o] \<Rightarrow> o" ("(EX _:_./ _)" [0, 0, 0] 10) |
41 |
41 |
42 translations |
42 translations |
43 "{x. P}" == "CONST Collect(%x. P)" |
43 "{x. P}" == "CONST Collect(\<lambda>x. P)" |
44 "INT x:A. B" == "CONST INTER(A, %x. B)" |
44 "INT x:A. B" == "CONST INTER(A, \<lambda>x. B)" |
45 "UN x:A. B" == "CONST UNION(A, %x. B)" |
45 "UN x:A. B" == "CONST UNION(A, \<lambda>x. B)" |
46 "ALL x:A. P" == "CONST Ball(A, %x. P)" |
46 "ALL x:A. P" == "CONST Ball(A, \<lambda>x. P)" |
47 "EX x:A. P" == "CONST Bex(A, %x. P)" |
47 "EX x:A. P" == "CONST Bex(A, \<lambda>x. P)" |
48 |
48 |
49 axiomatization where |
49 axiomatization where |
50 mem_Collect_iff: "(a : {x. P(x)}) <-> P(a)" and |
50 mem_Collect_iff: "(a : {x. P(x)}) \<longleftrightarrow> P(a)" and |
51 set_extension: "A = B <-> (ALL x. x:A <-> x:B)" |
51 set_extension: "A = B \<longleftrightarrow> (ALL x. x:A \<longleftrightarrow> x:B)" |
52 |
52 |
53 defs |
53 defs |
54 Ball_def: "Ball(A, P) == ALL x. x:A --> P(x)" |
54 Ball_def: "Ball(A, P) == ALL x. x:A \<longrightarrow> P(x)" |
55 Bex_def: "Bex(A, P) == EX x. x:A & P(x)" |
55 Bex_def: "Bex(A, P) == EX x. x:A \<and> P(x)" |
56 mono_def: "mono(f) == (ALL A B. A <= B --> f(A) <= f(B))" |
56 mono_def: "mono(f) == (ALL A B. A <= B \<longrightarrow> f(A) <= f(B))" |
57 subset_def: "A <= B == ALL x:A. x:B" |
57 subset_def: "A <= B == ALL x:A. x:B" |
58 singleton_def: "{a} == {x. x=a}" |
58 singleton_def: "{a} == {x. x=a}" |
59 empty_def: "{} == {x. False}" |
59 empty_def: "{} == {x. False}" |
60 Un_def: "A Un B == {x. x:A | x:B}" |
60 Un_def: "A Un B == {x. x:A | x:B}" |
61 Int_def: "A Int B == {x. x:A & x:B}" |
61 Int_def: "A Int B == {x. x:A \<and> x:B}" |
62 Compl_def: "Compl(A) == {x. ~x:A}" |
62 Compl_def: "Compl(A) == {x. \<not>x:A}" |
63 INTER_def: "INTER(A, B) == {y. ALL x:A. y: B(x)}" |
63 INTER_def: "INTER(A, B) == {y. ALL x:A. y: B(x)}" |
64 UNION_def: "UNION(A, B) == {y. EX x:A. y: B(x)}" |
64 UNION_def: "UNION(A, B) == {y. EX x:A. y: B(x)}" |
65 Inter_def: "Inter(S) == (INT x:S. x)" |
65 Inter_def: "Inter(S) == (INT x:S. x)" |
66 Union_def: "Union(S) == (UN x:S. x)" |
66 Union_def: "Union(S) == (UN x:S. x)" |
67 |
67 |
68 |
68 |
69 lemma CollectI: "[| P(a) |] ==> a : {x. P(x)}" |
69 lemma CollectI: "P(a) \<Longrightarrow> a : {x. P(x)}" |
70 apply (rule mem_Collect_iff [THEN iffD2]) |
70 apply (rule mem_Collect_iff [THEN iffD2]) |
71 apply assumption |
71 apply assumption |
72 done |
72 done |
73 |
73 |
74 lemma CollectD: "[| a : {x. P(x)} |] ==> P(a)" |
74 lemma CollectD: "a : {x. P(x)} \<Longrightarrow> P(a)" |
75 apply (erule mem_Collect_iff [THEN iffD1]) |
75 apply (erule mem_Collect_iff [THEN iffD1]) |
76 done |
76 done |
77 |
77 |
78 lemmas CollectE = CollectD [elim_format] |
78 lemmas CollectE = CollectD [elim_format] |
79 |
79 |
80 lemma set_ext: "[| !!x. x:A <-> x:B |] ==> A = B" |
80 lemma set_ext: "(\<And>x. x:A \<longleftrightarrow> x:B) \<Longrightarrow> A = B" |
81 apply (rule set_extension [THEN iffD2]) |
81 apply (rule set_extension [THEN iffD2]) |
82 apply simp |
82 apply simp |
83 done |
83 done |
84 |
84 |
85 |
85 |
86 subsection {* Bounded quantifiers *} |
86 subsection {* Bounded quantifiers *} |
87 |
87 |
88 lemma ballI: "[| !!x. x:A ==> P(x) |] ==> ALL x:A. P(x)" |
88 lemma ballI: "(\<And>x. x:A \<Longrightarrow> P(x)) \<Longrightarrow> ALL x:A. P(x)" |
89 by (simp add: Ball_def) |
89 by (simp add: Ball_def) |
90 |
90 |
91 lemma bspec: "[| ALL x:A. P(x); x:A |] ==> P(x)" |
91 lemma bspec: "\<lbrakk>ALL x:A. P(x); x:A\<rbrakk> \<Longrightarrow> P(x)" |
92 by (simp add: Ball_def) |
92 by (simp add: Ball_def) |
93 |
93 |
94 lemma ballE: "[| ALL x:A. P(x); P(x) ==> Q; ~ x:A ==> Q |] ==> Q" |
94 lemma ballE: "\<lbrakk>ALL x:A. P(x); P(x) \<Longrightarrow> Q; \<not> x:A \<Longrightarrow> Q\<rbrakk> \<Longrightarrow> Q" |
95 unfolding Ball_def by blast |
95 unfolding Ball_def by blast |
96 |
96 |
97 lemma bexI: "[| P(x); x:A |] ==> EX x:A. P(x)" |
97 lemma bexI: "\<lbrakk>P(x); x:A\<rbrakk> \<Longrightarrow> EX x:A. P(x)" |
98 unfolding Bex_def by blast |
98 unfolding Bex_def by blast |
99 |
99 |
100 lemma bexCI: "[| EX x:A. ~P(x) ==> P(a); a:A |] ==> EX x:A. P(x)" |
100 lemma bexCI: "\<lbrakk>EX x:A. \<not>P(x) \<Longrightarrow> P(a); a:A\<rbrakk> \<Longrightarrow> EX x:A. P(x)" |
101 unfolding Bex_def by blast |
101 unfolding Bex_def by blast |
102 |
102 |
103 lemma bexE: "[| EX x:A. P(x); !!x. [| x:A; P(x) |] ==> Q |] ==> Q" |
103 lemma bexE: "\<lbrakk>EX x:A. P(x); \<And>x. \<lbrakk>x:A; P(x)\<rbrakk> \<Longrightarrow> Q\<rbrakk> \<Longrightarrow> Q" |
104 unfolding Bex_def by blast |
104 unfolding Bex_def by blast |
105 |
105 |
106 (*Trival rewrite rule; (! x:A.P)=P holds only if A is nonempty!*) |
106 (*Trival rewrite rule; (! x:A.P)=P holds only if A is nonempty!*) |
107 lemma ball_rew: "(ALL x:A. True) <-> True" |
107 lemma ball_rew: "(ALL x:A. True) \<longleftrightarrow> True" |
108 by (blast intro: ballI) |
108 by (blast intro: ballI) |
109 |
109 |
110 |
110 |
111 subsection {* Congruence rules *} |
111 subsection {* Congruence rules *} |
112 |
112 |
113 lemma ball_cong: |
113 lemma ball_cong: |
114 "[| A=A'; !!x. x:A' ==> P(x) <-> P'(x) |] ==> |
114 "\<lbrakk>A = A'; \<And>x. x:A' \<Longrightarrow> P(x) \<longleftrightarrow> P'(x)\<rbrakk> \<Longrightarrow> |
115 (ALL x:A. P(x)) <-> (ALL x:A'. P'(x))" |
115 (ALL x:A. P(x)) \<longleftrightarrow> (ALL x:A'. P'(x))" |
116 by (blast intro: ballI elim: ballE) |
116 by (blast intro: ballI elim: ballE) |
117 |
117 |
118 lemma bex_cong: |
118 lemma bex_cong: |
119 "[| A=A'; !!x. x:A' ==> P(x) <-> P'(x) |] ==> |
119 "\<lbrakk>A = A'; \<And>x. x:A' \<Longrightarrow> P(x) \<longleftrightarrow> P'(x)\<rbrakk> \<Longrightarrow> |
120 (EX x:A. P(x)) <-> (EX x:A'. P'(x))" |
120 (EX x:A. P(x)) \<longleftrightarrow> (EX x:A'. P'(x))" |
121 by (blast intro: bexI elim: bexE) |
121 by (blast intro: bexI elim: bexE) |
122 |
122 |
123 |
123 |
124 subsection {* Rules for subsets *} |
124 subsection {* Rules for subsets *} |
125 |
125 |
126 lemma subsetI: "(!!x. x:A ==> x:B) ==> A <= B" |
126 lemma subsetI: "(\<And>x. x:A \<Longrightarrow> x:B) \<Longrightarrow> A <= B" |
127 unfolding subset_def by (blast intro: ballI) |
127 unfolding subset_def by (blast intro: ballI) |
128 |
128 |
129 (*Rule in Modus Ponens style*) |
129 (*Rule in Modus Ponens style*) |
130 lemma subsetD: "[| A <= B; c:A |] ==> c:B" |
130 lemma subsetD: "\<lbrakk>A <= B; c:A\<rbrakk> \<Longrightarrow> c:B" |
131 unfolding subset_def by (blast elim: ballE) |
131 unfolding subset_def by (blast elim: ballE) |
132 |
132 |
133 (*Classical elimination rule*) |
133 (*Classical elimination rule*) |
134 lemma subsetCE: "[| A <= B; ~(c:A) ==> P; c:B ==> P |] ==> P" |
134 lemma subsetCE: "\<lbrakk>A <= B; \<not>(c:A) \<Longrightarrow> P; c:B \<Longrightarrow> P\<rbrakk> \<Longrightarrow> P" |
135 by (blast dest: subsetD) |
135 by (blast dest: subsetD) |
136 |
136 |
137 lemma subset_refl: "A <= A" |
137 lemma subset_refl: "A <= A" |
138 by (blast intro: subsetI) |
138 by (blast intro: subsetI) |
139 |
139 |
140 lemma subset_trans: "[| A<=B; B<=C |] ==> A<=C" |
140 lemma subset_trans: "\<lbrakk>A <= B; B <= C\<rbrakk> \<Longrightarrow> A <= C" |
141 by (blast intro: subsetI dest: subsetD) |
141 by (blast intro: subsetI dest: subsetD) |
142 |
142 |
143 |
143 |
144 subsection {* Rules for equality *} |
144 subsection {* Rules for equality *} |
145 |
145 |
146 (*Anti-symmetry of the subset relation*) |
146 (*Anti-symmetry of the subset relation*) |
147 lemma subset_antisym: "[| A <= B; B <= A |] ==> A = B" |
147 lemma subset_antisym: "\<lbrakk>A <= B; B <= A\<rbrakk> \<Longrightarrow> A = B" |
148 by (blast intro: set_ext dest: subsetD) |
148 by (blast intro: set_ext dest: subsetD) |
149 |
149 |
150 lemmas equalityI = subset_antisym |
150 lemmas equalityI = subset_antisym |
151 |
151 |
152 (* Equality rules from ZF set theory -- are they appropriate here? *) |
152 (* Equality rules from ZF set theory -- are they appropriate here? *) |
153 lemma equalityD1: "A = B ==> A<=B" |
153 lemma equalityD1: "A = B \<Longrightarrow> A<=B" |
154 and equalityD2: "A = B ==> B<=A" |
154 and equalityD2: "A = B \<Longrightarrow> B<=A" |
155 by (simp_all add: subset_refl) |
155 by (simp_all add: subset_refl) |
156 |
156 |
157 lemma equalityE: "[| A = B; [| A<=B; B<=A |] ==> P |] ==> P" |
157 lemma equalityE: "\<lbrakk>A = B; \<lbrakk>A <= B; B <= A\<rbrakk> \<Longrightarrow> P\<rbrakk> \<Longrightarrow> P" |
158 by (simp add: subset_refl) |
158 by (simp add: subset_refl) |
159 |
159 |
160 lemma equalityCE: |
160 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" |
161 "[| A = B; [| c:A; c:B |] ==> P; [| ~ c:A; ~ c:B |] ==> P |] ==> P" |
|
162 by (blast elim: equalityE subsetCE) |
161 by (blast elim: equalityE subsetCE) |
163 |
162 |
164 lemma trivial_set: "{x. x:A} = A" |
163 lemma trivial_set: "{x. x:A} = A" |
165 by (blast intro: equalityI subsetI CollectI dest: CollectD) |
164 by (blast intro: equalityI subsetI CollectI dest: CollectD) |
166 |
165 |
167 |
166 |
168 subsection {* Rules for binary union *} |
167 subsection {* Rules for binary union *} |
169 |
168 |
170 lemma UnI1: "c:A ==> c : A Un B" |
169 lemma UnI1: "c:A \<Longrightarrow> c : A Un B" |
171 and UnI2: "c:B ==> c : A Un B" |
170 and UnI2: "c:B \<Longrightarrow> c : A Un B" |
172 unfolding Un_def by (blast intro: CollectI)+ |
171 unfolding Un_def by (blast intro: CollectI)+ |
173 |
172 |
174 (*Classical introduction rule: no commitment to A vs B*) |
173 (*Classical introduction rule: no commitment to A vs B*) |
175 lemma UnCI: "(~c:B ==> c:A) ==> c : A Un B" |
174 lemma UnCI: "(\<not>c:B \<Longrightarrow> c:A) \<Longrightarrow> c : A Un B" |
176 by (blast intro: UnI1 UnI2) |
175 by (blast intro: UnI1 UnI2) |
177 |
176 |
178 lemma UnE: "[| c : A Un B; c:A ==> P; c:B ==> P |] ==> P" |
177 lemma UnE: "\<lbrakk>c : A Un B; c:A \<Longrightarrow> P; c:B \<Longrightarrow> P\<rbrakk> \<Longrightarrow> P" |
179 unfolding Un_def by (blast dest: CollectD) |
178 unfolding Un_def by (blast dest: CollectD) |
180 |
179 |
181 |
180 |
182 subsection {* Rules for small intersection *} |
181 subsection {* Rules for small intersection *} |
183 |
182 |
184 lemma IntI: "[| c:A; c:B |] ==> c : A Int B" |
183 lemma IntI: "\<lbrakk>c:A; c:B\<rbrakk> \<Longrightarrow> c : A Int B" |
185 unfolding Int_def by (blast intro: CollectI) |
184 unfolding Int_def by (blast intro: CollectI) |
186 |
185 |
187 lemma IntD1: "c : A Int B ==> c:A" |
186 lemma IntD1: "c : A Int B \<Longrightarrow> c:A" |
188 and IntD2: "c : A Int B ==> c:B" |
187 and IntD2: "c : A Int B \<Longrightarrow> c:B" |
189 unfolding Int_def by (blast dest: CollectD)+ |
188 unfolding Int_def by (blast dest: CollectD)+ |
190 |
189 |
191 lemma IntE: "[| c : A Int B; [| c:A; c:B |] ==> P |] ==> P" |
190 lemma IntE: "\<lbrakk>c : A Int B; \<lbrakk>c:A; c:B\<rbrakk> \<Longrightarrow> P\<rbrakk> \<Longrightarrow> P" |
192 by (blast dest: IntD1 IntD2) |
191 by (blast dest: IntD1 IntD2) |
193 |
192 |
194 |
193 |
195 subsection {* Rules for set complement *} |
194 subsection {* Rules for set complement *} |
196 |
195 |
197 lemma ComplI: "[| c:A ==> False |] ==> c : Compl(A)" |
196 lemma ComplI: "(c:A \<Longrightarrow> False) \<Longrightarrow> c : Compl(A)" |
198 unfolding Compl_def by (blast intro: CollectI) |
197 unfolding Compl_def by (blast intro: CollectI) |
199 |
198 |
200 (*This form, with negated conclusion, works well with the Classical prover. |
199 (*This form, with negated conclusion, works well with the Classical prover. |
201 Negated assumptions behave like formulae on the right side of the notional |
200 Negated assumptions behave like formulae on the right side of the notional |
202 turnstile...*) |
201 turnstile...*) |
203 lemma ComplD: "[| c : Compl(A) |] ==> ~c:A" |
202 lemma ComplD: "c : Compl(A) \<Longrightarrow> \<not>c:A" |
204 unfolding Compl_def by (blast dest: CollectD) |
203 unfolding Compl_def by (blast dest: CollectD) |
205 |
204 |
206 lemmas ComplE = ComplD [elim_format] |
205 lemmas ComplE = ComplD [elim_format] |
207 |
206 |
208 |
207 |
209 subsection {* Empty sets *} |
208 subsection {* Empty sets *} |
210 |
209 |
211 lemma empty_eq: "{x. False} = {}" |
210 lemma empty_eq: "{x. False} = {}" |
212 by (simp add: empty_def) |
211 by (simp add: empty_def) |
213 |
212 |
214 lemma emptyD: "a : {} ==> P" |
213 lemma emptyD: "a : {} \<Longrightarrow> P" |
215 unfolding empty_def by (blast dest: CollectD) |
214 unfolding empty_def by (blast dest: CollectD) |
216 |
215 |
217 lemmas emptyE = emptyD [elim_format] |
216 lemmas emptyE = emptyD [elim_format] |
218 |
217 |
219 lemma not_emptyD: |
218 lemma not_emptyD: |
220 assumes "~ A={}" |
219 assumes "\<not> A={}" |
221 shows "EX x. x:A" |
220 shows "EX x. x:A" |
222 proof - |
221 proof - |
223 have "\<not> (EX x. x:A) \<Longrightarrow> A = {}" |
222 have "\<not> (EX x. x:A) \<Longrightarrow> A = {}" |
224 by (rule equalityI) (blast intro!: subsetI elim!: emptyD)+ |
223 by (rule equalityI) (blast intro!: subsetI elim!: emptyD)+ |
225 with assms show ?thesis by blast |
224 with assms show ?thesis by blast |
229 subsection {* Singleton sets *} |
228 subsection {* Singleton sets *} |
230 |
229 |
231 lemma singletonI: "a : {a}" |
230 lemma singletonI: "a : {a}" |
232 unfolding singleton_def by (blast intro: CollectI) |
231 unfolding singleton_def by (blast intro: CollectI) |
233 |
232 |
234 lemma singletonD: "b : {a} ==> b=a" |
233 lemma singletonD: "b : {a} \<Longrightarrow> b=a" |
235 unfolding singleton_def by (blast dest: CollectD) |
234 unfolding singleton_def by (blast dest: CollectD) |
236 |
235 |
237 lemmas singletonE = singletonD [elim_format] |
236 lemmas singletonE = singletonD [elim_format] |
238 |
237 |
239 |
238 |
240 subsection {* Unions of families *} |
239 subsection {* Unions of families *} |
241 |
240 |
242 (*The order of the premises presupposes that A is rigid; b may be flexible*) |
241 (*The order of the premises presupposes that A is rigid; b may be flexible*) |
243 lemma UN_I: "[| a:A; b: B(a) |] ==> b: (UN x:A. B(x))" |
242 lemma UN_I: "\<lbrakk>a:A; b: B(a)\<rbrakk> \<Longrightarrow> b: (UN x:A. B(x))" |
244 unfolding UNION_def by (blast intro: bexI CollectI) |
243 unfolding UNION_def by (blast intro: bexI CollectI) |
245 |
244 |
246 lemma UN_E: "[| b : (UN x:A. B(x)); !!x.[| x:A; b: B(x) |] ==> R |] ==> R" |
245 lemma UN_E: "\<lbrakk>b : (UN x:A. B(x)); \<And>x. \<lbrakk>x:A; b: B(x)\<rbrakk> \<Longrightarrow> R\<rbrakk> \<Longrightarrow> R" |
247 unfolding UNION_def by (blast dest: CollectD elim: bexE) |
246 unfolding UNION_def by (blast dest: CollectD elim: bexE) |
248 |
247 |
249 lemma UN_cong: |
248 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))" |
250 "[| A=B; !!x. x:B ==> C(x) = D(x) |] ==> |
|
251 (UN x:A. C(x)) = (UN x:B. D(x))" |
|
252 by (simp add: UNION_def cong: bex_cong) |
249 by (simp add: UNION_def cong: bex_cong) |
253 |
250 |
254 |
251 |
255 subsection {* Intersections of families *} |
252 subsection {* Intersections of families *} |
256 |
253 |
257 lemma INT_I: "(!!x. x:A ==> b: B(x)) ==> b : (INT x:A. B(x))" |
254 lemma INT_I: "(\<And>x. x:A \<Longrightarrow> b: B(x)) \<Longrightarrow> b : (INT x:A. B(x))" |
258 unfolding INTER_def by (blast intro: CollectI ballI) |
255 unfolding INTER_def by (blast intro: CollectI ballI) |
259 |
256 |
260 lemma INT_D: "[| b : (INT x:A. B(x)); a:A |] ==> b: B(a)" |
257 lemma INT_D: "\<lbrakk>b : (INT x:A. B(x)); a:A\<rbrakk> \<Longrightarrow> b: B(a)" |
261 unfolding INTER_def by (blast dest: CollectD bspec) |
258 unfolding INTER_def by (blast dest: CollectD bspec) |
262 |
259 |
263 (*"Classical" elimination rule -- does not require proving X:C *) |
260 (*"Classical" elimination rule -- does not require proving X:C *) |
264 lemma INT_E: "[| b : (INT x:A. B(x)); b: B(a) ==> R; ~ a:A ==> R |] ==> R" |
261 lemma INT_E: "\<lbrakk>b : (INT x:A. B(x)); b: B(a) \<Longrightarrow> R; \<not> a:A \<Longrightarrow> R\<rbrakk> \<Longrightarrow> R" |
265 unfolding INTER_def by (blast dest: CollectD bspec) |
262 unfolding INTER_def by (blast dest: CollectD bspec) |
266 |
263 |
267 lemma INT_cong: |
264 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))" |
268 "[| A=B; !!x. x:B ==> C(x) = D(x) |] ==> |
|
269 (INT x:A. C(x)) = (INT x:B. D(x))" |
|
270 by (simp add: INTER_def cong: ball_cong) |
265 by (simp add: INTER_def cong: ball_cong) |
271 |
266 |
272 |
267 |
273 subsection {* Rules for Unions *} |
268 subsection {* Rules for Unions *} |
274 |
269 |
275 (*The order of the premises presupposes that C is rigid; A may be flexible*) |
270 (*The order of the premises presupposes that C is rigid; A may be flexible*) |
276 lemma UnionI: "[| X:C; A:X |] ==> A : Union(C)" |
271 lemma UnionI: "\<lbrakk>X:C; A:X\<rbrakk> \<Longrightarrow> A : Union(C)" |
277 unfolding Union_def by (blast intro: UN_I) |
272 unfolding Union_def by (blast intro: UN_I) |
278 |
273 |
279 lemma UnionE: "[| A : Union(C); !!X.[| A:X; X:C |] ==> R |] ==> R" |
274 lemma UnionE: "\<lbrakk>A : Union(C); \<And>X. \<lbrakk> A:X; X:C\<rbrakk> \<Longrightarrow> R\<rbrakk> \<Longrightarrow> R" |
280 unfolding Union_def by (blast elim: UN_E) |
275 unfolding Union_def by (blast elim: UN_E) |
281 |
276 |
282 |
277 |
283 subsection {* Rules for Inter *} |
278 subsection {* Rules for Inter *} |
284 |
279 |
285 lemma InterI: "[| !!X. X:C ==> A:X |] ==> A : Inter(C)" |
280 lemma InterI: "(\<And>X. X:C \<Longrightarrow> A:X) \<Longrightarrow> A : Inter(C)" |
286 unfolding Inter_def by (blast intro: INT_I) |
281 unfolding Inter_def by (blast intro: INT_I) |
287 |
282 |
288 (*A "destruct" rule -- every X in C contains A as an element, but |
283 (*A "destruct" rule -- every X in C contains A as an element, but |
289 A:X can hold when X:C does not! This rule is analogous to "spec". *) |
284 A:X can hold when X:C does not! This rule is analogous to "spec". *) |
290 lemma InterD: "[| A : Inter(C); X:C |] ==> A:X" |
285 lemma InterD: "\<lbrakk>A : Inter(C); X:C\<rbrakk> \<Longrightarrow> A:X" |
291 unfolding Inter_def by (blast dest: INT_D) |
286 unfolding Inter_def by (blast dest: INT_D) |
292 |
287 |
293 (*"Classical" elimination rule -- does not require proving X:C *) |
288 (*"Classical" elimination rule -- does not require proving X:C *) |
294 lemma InterE: "[| A : Inter(C); A:X ==> R; ~ X:C ==> R |] ==> R" |
289 lemma InterE: "\<lbrakk>A : Inter(C); A:X \<Longrightarrow> R; \<not> X:C \<Longrightarrow> R\<rbrakk> \<Longrightarrow> R" |
295 unfolding Inter_def by (blast elim: INT_E) |
290 unfolding Inter_def by (blast elim: INT_E) |
296 |
291 |
297 |
292 |
298 section {* Derived rules involving subsets; Union and Intersection as lattice operations *} |
293 section {* Derived rules involving subsets; Union and Intersection as lattice operations *} |
299 |
294 |
300 subsection {* Big Union -- least upper bound of a set *} |
295 subsection {* Big Union -- least upper bound of a set *} |
301 |
296 |
302 lemma Union_upper: "B:A ==> B <= Union(A)" |
297 lemma Union_upper: "B:A \<Longrightarrow> B <= Union(A)" |
303 by (blast intro: subsetI UnionI) |
298 by (blast intro: subsetI UnionI) |
304 |
299 |
305 lemma Union_least: "[| !!X. X:A ==> X<=C |] ==> Union(A) <= C" |
300 lemma Union_least: "(\<And>X. X:A \<Longrightarrow> X<=C) \<Longrightarrow> Union(A) <= C" |
306 by (blast intro: subsetI dest: subsetD elim: UnionE) |
301 by (blast intro: subsetI dest: subsetD elim: UnionE) |
307 |
302 |
308 |
303 |
309 subsection {* Big Intersection -- greatest lower bound of a set *} |
304 subsection {* Big Intersection -- greatest lower bound of a set *} |
310 |
305 |
311 lemma Inter_lower: "B:A ==> Inter(A) <= B" |
306 lemma Inter_lower: "B:A \<Longrightarrow> Inter(A) <= B" |
312 by (blast intro: subsetI dest: InterD) |
307 by (blast intro: subsetI dest: InterD) |
313 |
308 |
314 lemma Inter_greatest: "[| !!X. X:A ==> C<=X |] ==> C <= Inter(A)" |
309 lemma Inter_greatest: "(\<And>X. X:A \<Longrightarrow> C<=X) \<Longrightarrow> C <= Inter(A)" |
315 by (blast intro: subsetI InterI dest: subsetD) |
310 by (blast intro: subsetI InterI dest: subsetD) |
316 |
311 |
317 |
312 |
318 subsection {* Finite Union -- the least upper bound of 2 sets *} |
313 subsection {* Finite Union -- the least upper bound of 2 sets *} |
319 |
314 |