author | kleing |
Mon, 01 Mar 2004 05:21:43 +0100 | |
changeset 14418 | b62323c85134 |
parent 14398 | c5c47703f763 |
child 14478 | bdf6b7adc3ec |
permissions | -rw-r--r-- |
8924 | 1 |
(* Title: HOL/SetInterval.thy |
2 |
ID: $Id$ |
|
13735 | 3 |
Author: Tobias Nipkow and Clemens Ballarin |
8957 | 4 |
Copyright 2000 TU Muenchen |
8924 | 5 |
|
13735 | 6 |
lessThan, greaterThan, atLeast, atMost and two-sided intervals |
8924 | 7 |
*) |
8 |
||
13735 | 9 |
theory SetInterval = NatArith: |
8924 | 10 |
|
11 |
constdefs |
|
11609
3f3d1add4d94
eliminated theories "equalities" and "mono" (made part of "Typedef",
wenzelm
parents:
10214
diff
changeset
|
12 |
lessThan :: "('a::ord) => 'a set" ("(1{.._'(})") |
3f3d1add4d94
eliminated theories "equalities" and "mono" (made part of "Typedef",
wenzelm
parents:
10214
diff
changeset
|
13 |
"{..u(} == {x. x<u}" |
8924 | 14 |
|
11609
3f3d1add4d94
eliminated theories "equalities" and "mono" (made part of "Typedef",
wenzelm
parents:
10214
diff
changeset
|
15 |
atMost :: "('a::ord) => 'a set" ("(1{.._})") |
3f3d1add4d94
eliminated theories "equalities" and "mono" (made part of "Typedef",
wenzelm
parents:
10214
diff
changeset
|
16 |
"{..u} == {x. x<=u}" |
8924 | 17 |
|
11609
3f3d1add4d94
eliminated theories "equalities" and "mono" (made part of "Typedef",
wenzelm
parents:
10214
diff
changeset
|
18 |
greaterThan :: "('a::ord) => 'a set" ("(1{')_..})") |
3f3d1add4d94
eliminated theories "equalities" and "mono" (made part of "Typedef",
wenzelm
parents:
10214
diff
changeset
|
19 |
"{)l..} == {x. l<x}" |
8924 | 20 |
|
11609
3f3d1add4d94
eliminated theories "equalities" and "mono" (made part of "Typedef",
wenzelm
parents:
10214
diff
changeset
|
21 |
atLeast :: "('a::ord) => 'a set" ("(1{_..})") |
3f3d1add4d94
eliminated theories "equalities" and "mono" (made part of "Typedef",
wenzelm
parents:
10214
diff
changeset
|
22 |
"{l..} == {x. l<=x}" |
8924 | 23 |
|
13735 | 24 |
greaterThanLessThan :: "['a::ord, 'a] => 'a set" ("(1{')_.._'(})") |
25 |
"{)l..u(} == {)l..} Int {..u(}" |
|
26 |
||
27 |
atLeastLessThan :: "['a::ord, 'a] => 'a set" ("(1{_.._'(})") |
|
28 |
"{l..u(} == {l..} Int {..u(}" |
|
29 |
||
30 |
greaterThanAtMost :: "['a::ord, 'a] => 'a set" ("(1{')_.._})") |
|
31 |
"{)l..u} == {)l..} Int {..u}" |
|
32 |
||
33 |
atLeastAtMost :: "['a::ord, 'a] => 'a set" ("(1{_.._})") |
|
34 |
"{l..u} == {l..} Int {..u}" |
|
35 |
||
14418 | 36 |
syntax |
37 |
"@UNION_le" :: "nat => nat => 'b set => 'b set" ("(3UN _<=_./ _)" 10) |
|
38 |
"@UNION_less" :: "nat => nat => 'b set => 'b set" ("(3UN _<_./ _)" 10) |
|
39 |
"@INTER_le" :: "nat => nat => 'b set => 'b set" ("(3INT _<=_./ _)" 10) |
|
40 |
"@INTER_less" :: "nat => nat => 'b set => 'b set" ("(3INT _<_./ _)" 10) |
|
41 |
||
42 |
syntax (input) |
|
43 |
"@UNION_le" :: "nat => nat => 'b set => 'b set" ("(3\<Union> _\<le>_./ _)" 10) |
|
44 |
"@UNION_less" :: "nat => nat => 'b set => 'b set" ("(3\<Union> _<_./ _)" 10) |
|
45 |
"@INTER_le" :: "nat => nat => 'b set => 'b set" ("(3\<Inter> _\<le>_./ _)" 10) |
|
46 |
"@INTER_less" :: "nat => nat => 'b set => 'b set" ("(3\<Inter> _<_./ _)" 10) |
|
47 |
||
48 |
syntax (xsymbols) |
|
49 |
"@UNION_le" :: "nat \<Rightarrow> nat => 'b set => 'b set" ("(3\<Union>\<^bsub>_ \<le> _\<^esub>/ _)" 10) |
|
50 |
"@UNION_less" :: "nat \<Rightarrow> nat => 'b set => 'b set" ("(3\<Union>\<^bsub>_ < _\<^esub>/ _)" 10) |
|
51 |
"@INTER_le" :: "nat \<Rightarrow> nat => 'b set => 'b set" ("(3\<Inter>\<^bsub>_ \<le> _\<^esub>/ _)" 10) |
|
52 |
"@INTER_less" :: "nat \<Rightarrow> nat => 'b set => 'b set" ("(3\<Inter>\<^bsub>_ < _\<^esub>/ _)" 10) |
|
53 |
||
54 |
translations |
|
55 |
"UN i<=n. A" == "UN i:{..n}. A" |
|
56 |
"UN i<n. A" == "UN i:{..n(}. A" |
|
57 |
"INT i<=n. A" == "INT i:{..n}. A" |
|
58 |
"INT i<n. A" == "INT i:{..n(}. A" |
|
59 |
||
60 |
||
13850 | 61 |
subsection {*lessThan*} |
13735 | 62 |
|
13850 | 63 |
lemma lessThan_iff [iff]: "(i: lessThan k) = (i<k)" |
64 |
by (simp add: lessThan_def) |
|
13735 | 65 |
|
13850 | 66 |
lemma lessThan_0 [simp]: "lessThan (0::nat) = {}" |
67 |
by (simp add: lessThan_def) |
|
13735 | 68 |
|
69 |
lemma lessThan_Suc: "lessThan (Suc k) = insert k (lessThan k)" |
|
13850 | 70 |
by (simp add: lessThan_def less_Suc_eq, blast) |
13735 | 71 |
|
72 |
lemma lessThan_Suc_atMost: "lessThan (Suc k) = atMost k" |
|
13850 | 73 |
by (simp add: lessThan_def atMost_def less_Suc_eq_le) |
13735 | 74 |
|
75 |
lemma UN_lessThan_UNIV: "(UN m::nat. lessThan m) = UNIV" |
|
13850 | 76 |
by blast |
13735 | 77 |
|
13850 | 78 |
lemma Compl_lessThan [simp]: |
13735 | 79 |
"!!k:: 'a::linorder. -lessThan k = atLeast k" |
13850 | 80 |
apply (auto simp add: lessThan_def atLeast_def) |
13735 | 81 |
done |
82 |
||
13850 | 83 |
lemma single_Diff_lessThan [simp]: "!!k:: 'a::order. {k} - lessThan k = {k}" |
84 |
by auto |
|
13735 | 85 |
|
13850 | 86 |
subsection {*greaterThan*} |
13735 | 87 |
|
13850 | 88 |
lemma greaterThan_iff [iff]: "(i: greaterThan k) = (k<i)" |
89 |
by (simp add: greaterThan_def) |
|
13735 | 90 |
|
13850 | 91 |
lemma greaterThan_0 [simp]: "greaterThan 0 = range Suc" |
92 |
apply (simp add: greaterThan_def) |
|
13735 | 93 |
apply (blast dest: gr0_conv_Suc [THEN iffD1]) |
94 |
done |
|
95 |
||
96 |
lemma greaterThan_Suc: "greaterThan (Suc k) = greaterThan k - {Suc k}" |
|
13850 | 97 |
apply (simp add: greaterThan_def) |
13735 | 98 |
apply (auto elim: linorder_neqE) |
99 |
done |
|
100 |
||
101 |
lemma INT_greaterThan_UNIV: "(INT m::nat. greaterThan m) = {}" |
|
13850 | 102 |
by blast |
13735 | 103 |
|
13850 | 104 |
lemma Compl_greaterThan [simp]: |
13735 | 105 |
"!!k:: 'a::linorder. -greaterThan k = atMost k" |
13850 | 106 |
apply (simp add: greaterThan_def atMost_def le_def, auto) |
13735 | 107 |
done |
108 |
||
13850 | 109 |
lemma Compl_atMost [simp]: "!!k:: 'a::linorder. -atMost k = greaterThan k" |
110 |
apply (subst Compl_greaterThan [symmetric]) |
|
111 |
apply (rule double_complement) |
|
13735 | 112 |
done |
113 |
||
114 |
||
13850 | 115 |
subsection {*atLeast*} |
13735 | 116 |
|
13850 | 117 |
lemma atLeast_iff [iff]: "(i: atLeast k) = (k<=i)" |
118 |
by (simp add: atLeast_def) |
|
13735 | 119 |
|
13850 | 120 |
lemma atLeast_0 [simp]: "atLeast (0::nat) = UNIV" |
121 |
by (unfold atLeast_def UNIV_def, simp) |
|
13735 | 122 |
|
123 |
lemma atLeast_Suc: "atLeast (Suc k) = atLeast k - {k}" |
|
13850 | 124 |
apply (simp add: atLeast_def) |
125 |
apply (simp add: Suc_le_eq) |
|
126 |
apply (simp add: order_le_less, blast) |
|
13735 | 127 |
done |
128 |
||
129 |
lemma UN_atLeast_UNIV: "(UN m::nat. atLeast m) = UNIV" |
|
13850 | 130 |
by blast |
13735 | 131 |
|
13850 | 132 |
lemma Compl_atLeast [simp]: |
13735 | 133 |
"!!k:: 'a::linorder. -atLeast k = lessThan k" |
13850 | 134 |
apply (simp add: lessThan_def atLeast_def le_def, auto) |
13735 | 135 |
done |
136 |
||
137 |
||
13850 | 138 |
subsection {*atMost*} |
13735 | 139 |
|
13850 | 140 |
lemma atMost_iff [iff]: "(i: atMost k) = (i<=k)" |
141 |
by (simp add: atMost_def) |
|
13735 | 142 |
|
13850 | 143 |
lemma atMost_0 [simp]: "atMost (0::nat) = {0}" |
144 |
by (simp add: atMost_def) |
|
13735 | 145 |
|
146 |
lemma atMost_Suc: "atMost (Suc k) = insert (Suc k) (atMost k)" |
|
13850 | 147 |
apply (simp add: atMost_def) |
148 |
apply (simp add: less_Suc_eq order_le_less, blast) |
|
13735 | 149 |
done |
150 |
||
151 |
lemma UN_atMost_UNIV: "(UN m::nat. atMost m) = UNIV" |
|
13850 | 152 |
by blast |
153 |
||
154 |
||
155 |
subsection {*Logical Equivalences for Set Inclusion and Equality*} |
|
156 |
||
157 |
lemma atLeast_subset_iff [iff]: |
|
158 |
"(atLeast x \<subseteq> atLeast y) = (y \<le> (x::'a::order))" |
|
159 |
by (blast intro: order_trans) |
|
160 |
||
161 |
lemma atLeast_eq_iff [iff]: |
|
162 |
"(atLeast x = atLeast y) = (x = (y::'a::linorder))" |
|
163 |
by (blast intro: order_antisym order_trans) |
|
164 |
||
165 |
lemma greaterThan_subset_iff [iff]: |
|
166 |
"(greaterThan x \<subseteq> greaterThan y) = (y \<le> (x::'a::linorder))" |
|
167 |
apply (auto simp add: greaterThan_def) |
|
168 |
apply (subst linorder_not_less [symmetric], blast) |
|
169 |
done |
|
170 |
||
171 |
lemma greaterThan_eq_iff [iff]: |
|
172 |
"(greaterThan x = greaterThan y) = (x = (y::'a::linorder))" |
|
173 |
apply (rule iffI) |
|
174 |
apply (erule equalityE) |
|
175 |
apply (simp add: greaterThan_subset_iff order_antisym, simp) |
|
176 |
done |
|
177 |
||
178 |
lemma atMost_subset_iff [iff]: "(atMost x \<subseteq> atMost y) = (x \<le> (y::'a::order))" |
|
179 |
by (blast intro: order_trans) |
|
180 |
||
181 |
lemma atMost_eq_iff [iff]: "(atMost x = atMost y) = (x = (y::'a::linorder))" |
|
182 |
by (blast intro: order_antisym order_trans) |
|
183 |
||
184 |
lemma lessThan_subset_iff [iff]: |
|
185 |
"(lessThan x \<subseteq> lessThan y) = (x \<le> (y::'a::linorder))" |
|
186 |
apply (auto simp add: lessThan_def) |
|
187 |
apply (subst linorder_not_less [symmetric], blast) |
|
188 |
done |
|
189 |
||
190 |
lemma lessThan_eq_iff [iff]: |
|
191 |
"(lessThan x = lessThan y) = (x = (y::'a::linorder))" |
|
192 |
apply (rule iffI) |
|
193 |
apply (erule equalityE) |
|
194 |
apply (simp add: lessThan_subset_iff order_antisym, simp) |
|
13735 | 195 |
done |
196 |
||
197 |
||
13850 | 198 |
subsection {*Combined properties*} |
13735 | 199 |
|
200 |
lemma atMost_Int_atLeast: "!!n:: 'a::order. atMost n Int atLeast n = {n}" |
|
13850 | 201 |
by (blast intro: order_antisym) |
13735 | 202 |
|
13850 | 203 |
subsection {*Two-sided intervals*} |
13735 | 204 |
|
205 |
(* greaterThanLessThan *) |
|
206 |
||
207 |
lemma greaterThanLessThan_iff [simp]: |
|
208 |
"(i : {)l..u(}) = (l < i & i < u)" |
|
209 |
by (simp add: greaterThanLessThan_def) |
|
210 |
||
211 |
(* atLeastLessThan *) |
|
212 |
||
213 |
lemma atLeastLessThan_iff [simp]: |
|
214 |
"(i : {l..u(}) = (l <= i & i < u)" |
|
215 |
by (simp add: atLeastLessThan_def) |
|
216 |
||
217 |
(* greaterThanAtMost *) |
|
218 |
||
219 |
lemma greaterThanAtMost_iff [simp]: |
|
220 |
"(i : {)l..u}) = (l < i & i <= u)" |
|
221 |
by (simp add: greaterThanAtMost_def) |
|
222 |
||
223 |
(* atLeastAtMost *) |
|
224 |
||
225 |
lemma atLeastAtMost_iff [simp]: |
|
226 |
"(i : {l..u}) = (l <= i & i <= u)" |
|
227 |
by (simp add: atLeastAtMost_def) |
|
228 |
||
229 |
(* The above four lemmas could be declared as iffs. |
|
230 |
If we do so, a call to blast in Hyperreal/Star.ML, lemma STAR_Int |
|
231 |
seems to take forever (more than one hour). *) |
|
232 |
||
13850 | 233 |
subsection {*Lemmas useful with the summation operator setsum*} |
234 |
||
13735 | 235 |
(* For examples, see Algebra/poly/UnivPoly.thy *) |
236 |
||
237 |
(** Disjoint Unions **) |
|
238 |
||
239 |
(* Singletons and open intervals *) |
|
240 |
||
241 |
lemma ivl_disj_un_singleton: |
|
242 |
"{l::'a::linorder} Un {)l..} = {l..}" |
|
243 |
"{..u(} Un {u::'a::linorder} = {..u}" |
|
244 |
"(l::'a::linorder) < u ==> {l} Un {)l..u(} = {l..u(}" |
|
245 |
"(l::'a::linorder) < u ==> {)l..u(} Un {u} = {)l..u}" |
|
246 |
"(l::'a::linorder) <= u ==> {l} Un {)l..u} = {l..u}" |
|
247 |
"(l::'a::linorder) <= u ==> {l..u(} Un {u} = {l..u}" |
|
14398
c5c47703f763
Efficient, graph-based reasoner for linear and partial orders.
ballarin
parents:
13850
diff
changeset
|
248 |
by auto |
13735 | 249 |
|
250 |
(* One- and two-sided intervals *) |
|
251 |
||
252 |
lemma ivl_disj_un_one: |
|
253 |
"(l::'a::linorder) < u ==> {..l} Un {)l..u(} = {..u(}" |
|
254 |
"(l::'a::linorder) <= u ==> {..l(} Un {l..u(} = {..u(}" |
|
255 |
"(l::'a::linorder) <= u ==> {..l} Un {)l..u} = {..u}" |
|
256 |
"(l::'a::linorder) <= u ==> {..l(} Un {l..u} = {..u}" |
|
257 |
"(l::'a::linorder) <= u ==> {)l..u} Un {)u..} = {)l..}" |
|
258 |
"(l::'a::linorder) < u ==> {)l..u(} Un {u..} = {)l..}" |
|
259 |
"(l::'a::linorder) <= u ==> {l..u} Un {)u..} = {l..}" |
|
260 |
"(l::'a::linorder) <= u ==> {l..u(} Un {u..} = {l..}" |
|
14398
c5c47703f763
Efficient, graph-based reasoner for linear and partial orders.
ballarin
parents:
13850
diff
changeset
|
261 |
by auto |
13735 | 262 |
|
263 |
(* Two- and two-sided intervals *) |
|
264 |
||
265 |
lemma ivl_disj_un_two: |
|
266 |
"[| (l::'a::linorder) < m; m <= u |] ==> {)l..m(} Un {m..u(} = {)l..u(}" |
|
267 |
"[| (l::'a::linorder) <= m; m < u |] ==> {)l..m} Un {)m..u(} = {)l..u(}" |
|
268 |
"[| (l::'a::linorder) <= m; m <= u |] ==> {l..m(} Un {m..u(} = {l..u(}" |
|
269 |
"[| (l::'a::linorder) <= m; m < u |] ==> {l..m} Un {)m..u(} = {l..u(}" |
|
270 |
"[| (l::'a::linorder) < m; m <= u |] ==> {)l..m(} Un {m..u} = {)l..u}" |
|
271 |
"[| (l::'a::linorder) <= m; m <= u |] ==> {)l..m} Un {)m..u} = {)l..u}" |
|
272 |
"[| (l::'a::linorder) <= m; m <= u |] ==> {l..m(} Un {m..u} = {l..u}" |
|
273 |
"[| (l::'a::linorder) <= m; m <= u |] ==> {l..m} Un {)m..u} = {l..u}" |
|
14398
c5c47703f763
Efficient, graph-based reasoner for linear and partial orders.
ballarin
parents:
13850
diff
changeset
|
274 |
by auto |
13735 | 275 |
|
276 |
lemmas ivl_disj_un = ivl_disj_un_singleton ivl_disj_un_one ivl_disj_un_two |
|
277 |
||
278 |
(** Disjoint Intersections **) |
|
279 |
||
280 |
(* Singletons and open intervals *) |
|
281 |
||
282 |
lemma ivl_disj_int_singleton: |
|
283 |
"{l::'a::order} Int {)l..} = {}" |
|
284 |
"{..u(} Int {u} = {}" |
|
285 |
"{l} Int {)l..u(} = {}" |
|
286 |
"{)l..u(} Int {u} = {}" |
|
287 |
"{l} Int {)l..u} = {}" |
|
288 |
"{l..u(} Int {u} = {}" |
|
289 |
by simp+ |
|
290 |
||
291 |
(* One- and two-sided intervals *) |
|
292 |
||
293 |
lemma ivl_disj_int_one: |
|
294 |
"{..l::'a::order} Int {)l..u(} = {}" |
|
295 |
"{..l(} Int {l..u(} = {}" |
|
296 |
"{..l} Int {)l..u} = {}" |
|
297 |
"{..l(} Int {l..u} = {}" |
|
298 |
"{)l..u} Int {)u..} = {}" |
|
299 |
"{)l..u(} Int {u..} = {}" |
|
300 |
"{l..u} Int {)u..} = {}" |
|
301 |
"{l..u(} Int {u..} = {}" |
|
14398
c5c47703f763
Efficient, graph-based reasoner for linear and partial orders.
ballarin
parents:
13850
diff
changeset
|
302 |
by auto |
13735 | 303 |
|
304 |
(* Two- and two-sided intervals *) |
|
305 |
||
306 |
lemma ivl_disj_int_two: |
|
307 |
"{)l::'a::order..m(} Int {m..u(} = {}" |
|
308 |
"{)l..m} Int {)m..u(} = {}" |
|
309 |
"{l..m(} Int {m..u(} = {}" |
|
310 |
"{l..m} Int {)m..u(} = {}" |
|
311 |
"{)l..m(} Int {m..u} = {}" |
|
312 |
"{)l..m} Int {)m..u} = {}" |
|
313 |
"{l..m(} Int {m..u} = {}" |
|
314 |
"{l..m} Int {)m..u} = {}" |
|
14398
c5c47703f763
Efficient, graph-based reasoner for linear and partial orders.
ballarin
parents:
13850
diff
changeset
|
315 |
by auto |
13735 | 316 |
|
317 |
lemmas ivl_disj_int = ivl_disj_int_singleton ivl_disj_int_one ivl_disj_int_two |
|
318 |
||
8924 | 319 |
end |