author | paulson |
Thu, 15 Jul 2004 15:32:32 +0200 | |
changeset 15047 | fa62de5862b9 |
parent 15045 | d59f7e2e18d3 |
child 15048 | 11b4dce71d73 |
permissions | -rw-r--r-- |
8924 | 1 |
(* Title: HOL/SetInterval.thy |
2 |
ID: $Id$ |
|
13735 | 3 |
Author: Tobias Nipkow and Clemens Ballarin |
14485 | 4 |
Additions by Jeremy Avigad in March 2004 |
8957 | 5 |
Copyright 2000 TU Muenchen |
8924 | 6 |
|
13735 | 7 |
lessThan, greaterThan, atLeast, atMost and two-sided intervals |
8924 | 8 |
*) |
9 |
||
14577 | 10 |
header {* Set intervals *} |
11 |
||
14485 | 12 |
theory SetInterval = IntArith: |
8924 | 13 |
|
14 |
constdefs |
|
15045 | 15 |
lessThan :: "('a::ord) => 'a set" ("(1{..<_})") |
16 |
"{..<u} == {x. x<u}" |
|
8924 | 17 |
|
11609
3f3d1add4d94
eliminated theories "equalities" and "mono" (made part of "Typedef",
wenzelm
parents:
10214
diff
changeset
|
18 |
atMost :: "('a::ord) => 'a set" ("(1{.._})") |
3f3d1add4d94
eliminated theories "equalities" and "mono" (made part of "Typedef",
wenzelm
parents:
10214
diff
changeset
|
19 |
"{..u} == {x. x<=u}" |
8924 | 20 |
|
15045 | 21 |
greaterThan :: "('a::ord) => 'a set" ("(1{_<..})") |
22 |
"{l<..} == {x. l<x}" |
|
8924 | 23 |
|
11609
3f3d1add4d94
eliminated theories "equalities" and "mono" (made part of "Typedef",
wenzelm
parents:
10214
diff
changeset
|
24 |
atLeast :: "('a::ord) => 'a set" ("(1{_..})") |
3f3d1add4d94
eliminated theories "equalities" and "mono" (made part of "Typedef",
wenzelm
parents:
10214
diff
changeset
|
25 |
"{l..} == {x. l<=x}" |
8924 | 26 |
|
15045 | 27 |
greaterThanLessThan :: "['a::ord, 'a] => 'a set" ("(1{_<..<_})") |
28 |
"{l<..<u} == {l<..} Int {..<u}" |
|
13735 | 29 |
|
15045 | 30 |
atLeastLessThan :: "['a::ord, 'a] => 'a set" ("(1{_..<_})") |
31 |
"{l..<u} == {l..} Int {..<u}" |
|
13735 | 32 |
|
15045 | 33 |
greaterThanAtMost :: "['a::ord, 'a] => 'a set" ("(1{_<.._})") |
34 |
"{l<..u} == {l<..} Int {..u}" |
|
13735 | 35 |
|
36 |
atLeastAtMost :: "['a::ord, 'a] => 'a set" ("(1{_.._})") |
|
37 |
"{l..u} == {l..} Int {..u}" |
|
38 |
||
15045 | 39 |
(* Old syntax, will disappear! *) |
40 |
syntax |
|
41 |
"_lessThan" :: "('a::ord) => 'a set" ("(1{.._'(})") |
|
42 |
"_greaterThan" :: "('a::ord) => 'a set" ("(1{')_..})") |
|
43 |
"_greaterThanLessThan" :: "['a::ord, 'a] => 'a set" ("(1{')_.._'(})") |
|
44 |
"_atLeastLessThan" :: "['a::ord, 'a] => 'a set" ("(1{_.._'(})") |
|
45 |
"_greaterThanAtMost" :: "['a::ord, 'a] => 'a set" ("(1{')_.._})") |
|
46 |
translations |
|
47 |
"{..m(}" => "{..<m}" |
|
48 |
"{)m..}" => "{m<..}" |
|
49 |
"{)m..n(}" => "{m<..<n}" |
|
50 |
"{m..n(}" => "{m..<n}" |
|
51 |
"{)m..n}" => "{m<..n}" |
|
52 |
||
14418 | 53 |
syntax |
54 |
"@UNION_le" :: "nat => nat => 'b set => 'b set" ("(3UN _<=_./ _)" 10) |
|
55 |
"@UNION_less" :: "nat => nat => 'b set => 'b set" ("(3UN _<_./ _)" 10) |
|
56 |
"@INTER_le" :: "nat => nat => 'b set => 'b set" ("(3INT _<=_./ _)" 10) |
|
57 |
"@INTER_less" :: "nat => nat => 'b set => 'b set" ("(3INT _<_./ _)" 10) |
|
58 |
||
59 |
syntax (input) |
|
60 |
"@UNION_le" :: "nat => nat => 'b set => 'b set" ("(3\<Union> _\<le>_./ _)" 10) |
|
61 |
"@UNION_less" :: "nat => nat => 'b set => 'b set" ("(3\<Union> _<_./ _)" 10) |
|
62 |
"@INTER_le" :: "nat => nat => 'b set => 'b set" ("(3\<Inter> _\<le>_./ _)" 10) |
|
63 |
"@INTER_less" :: "nat => nat => 'b set => 'b set" ("(3\<Inter> _<_./ _)" 10) |
|
64 |
||
65 |
syntax (xsymbols) |
|
14846 | 66 |
"@UNION_le" :: "nat \<Rightarrow> nat => 'b set => 'b set" ("(3\<Union>(00\<^bsub>_ \<le> _\<^esub>)/ _)" 10) |
67 |
"@UNION_less" :: "nat \<Rightarrow> nat => 'b set => 'b set" ("(3\<Union>(00\<^bsub>_ < _\<^esub>)/ _)" 10) |
|
68 |
"@INTER_le" :: "nat \<Rightarrow> nat => 'b set => 'b set" ("(3\<Inter>(00\<^bsub>_ \<le> _\<^esub>)/ _)" 10) |
|
69 |
"@INTER_less" :: "nat \<Rightarrow> nat => 'b set => 'b set" ("(3\<Inter>(00\<^bsub>_ < _\<^esub>)/ _)" 10) |
|
14418 | 70 |
|
71 |
translations |
|
72 |
"UN i<=n. A" == "UN i:{..n}. A" |
|
15045 | 73 |
"UN i<n. A" == "UN i:{..<n}. A" |
14418 | 74 |
"INT i<=n. A" == "INT i:{..n}. A" |
15045 | 75 |
"INT i<n. A" == "INT i:{..<n}. A" |
14418 | 76 |
|
77 |
||
14485 | 78 |
subsection {* Various equivalences *} |
13735 | 79 |
|
13850 | 80 |
lemma lessThan_iff [iff]: "(i: lessThan k) = (i<k)" |
81 |
by (simp add: lessThan_def) |
|
13735 | 82 |
|
13850 | 83 |
lemma Compl_lessThan [simp]: |
13735 | 84 |
"!!k:: 'a::linorder. -lessThan k = atLeast k" |
13850 | 85 |
apply (auto simp add: lessThan_def atLeast_def) |
13735 | 86 |
done |
87 |
||
13850 | 88 |
lemma single_Diff_lessThan [simp]: "!!k:: 'a::order. {k} - lessThan k = {k}" |
89 |
by auto |
|
13735 | 90 |
|
13850 | 91 |
lemma greaterThan_iff [iff]: "(i: greaterThan k) = (k<i)" |
92 |
by (simp add: greaterThan_def) |
|
13735 | 93 |
|
13850 | 94 |
lemma Compl_greaterThan [simp]: |
13735 | 95 |
"!!k:: 'a::linorder. -greaterThan k = atMost k" |
13850 | 96 |
apply (simp add: greaterThan_def atMost_def le_def, auto) |
13735 | 97 |
done |
98 |
||
13850 | 99 |
lemma Compl_atMost [simp]: "!!k:: 'a::linorder. -atMost k = greaterThan k" |
100 |
apply (subst Compl_greaterThan [symmetric]) |
|
101 |
apply (rule double_complement) |
|
13735 | 102 |
done |
103 |
||
13850 | 104 |
lemma atLeast_iff [iff]: "(i: atLeast k) = (k<=i)" |
105 |
by (simp add: atLeast_def) |
|
13735 | 106 |
|
13850 | 107 |
lemma Compl_atLeast [simp]: |
13735 | 108 |
"!!k:: 'a::linorder. -atLeast k = lessThan k" |
13850 | 109 |
apply (simp add: lessThan_def atLeast_def le_def, auto) |
13735 | 110 |
done |
111 |
||
13850 | 112 |
lemma atMost_iff [iff]: "(i: atMost k) = (i<=k)" |
113 |
by (simp add: atMost_def) |
|
13735 | 114 |
|
14485 | 115 |
lemma atMost_Int_atLeast: "!!n:: 'a::order. atMost n Int atLeast n = {n}" |
116 |
by (blast intro: order_antisym) |
|
13850 | 117 |
|
118 |
||
14485 | 119 |
subsection {* Logical Equivalences for Set Inclusion and Equality *} |
13850 | 120 |
|
121 |
lemma atLeast_subset_iff [iff]: |
|
122 |
"(atLeast x \<subseteq> atLeast y) = (y \<le> (x::'a::order))" |
|
123 |
by (blast intro: order_trans) |
|
124 |
||
125 |
lemma atLeast_eq_iff [iff]: |
|
126 |
"(atLeast x = atLeast y) = (x = (y::'a::linorder))" |
|
127 |
by (blast intro: order_antisym order_trans) |
|
128 |
||
129 |
lemma greaterThan_subset_iff [iff]: |
|
130 |
"(greaterThan x \<subseteq> greaterThan y) = (y \<le> (x::'a::linorder))" |
|
131 |
apply (auto simp add: greaterThan_def) |
|
132 |
apply (subst linorder_not_less [symmetric], blast) |
|
133 |
done |
|
134 |
||
135 |
lemma greaterThan_eq_iff [iff]: |
|
136 |
"(greaterThan x = greaterThan y) = (x = (y::'a::linorder))" |
|
137 |
apply (rule iffI) |
|
138 |
apply (erule equalityE) |
|
139 |
apply (simp add: greaterThan_subset_iff order_antisym, simp) |
|
140 |
done |
|
141 |
||
142 |
lemma atMost_subset_iff [iff]: "(atMost x \<subseteq> atMost y) = (x \<le> (y::'a::order))" |
|
143 |
by (blast intro: order_trans) |
|
144 |
||
145 |
lemma atMost_eq_iff [iff]: "(atMost x = atMost y) = (x = (y::'a::linorder))" |
|
146 |
by (blast intro: order_antisym order_trans) |
|
147 |
||
148 |
lemma lessThan_subset_iff [iff]: |
|
149 |
"(lessThan x \<subseteq> lessThan y) = (x \<le> (y::'a::linorder))" |
|
150 |
apply (auto simp add: lessThan_def) |
|
151 |
apply (subst linorder_not_less [symmetric], blast) |
|
152 |
done |
|
153 |
||
154 |
lemma lessThan_eq_iff [iff]: |
|
155 |
"(lessThan x = lessThan y) = (x = (y::'a::linorder))" |
|
156 |
apply (rule iffI) |
|
157 |
apply (erule equalityE) |
|
158 |
apply (simp add: lessThan_subset_iff order_antisym, simp) |
|
13735 | 159 |
done |
160 |
||
161 |
||
13850 | 162 |
subsection {*Two-sided intervals*} |
13735 | 163 |
|
14577 | 164 |
text {* @{text greaterThanLessThan} *} |
13735 | 165 |
|
166 |
lemma greaterThanLessThan_iff [simp]: |
|
15045 | 167 |
"(i : {l<..<u}) = (l < i & i < u)" |
13735 | 168 |
by (simp add: greaterThanLessThan_def) |
169 |
||
14577 | 170 |
text {* @{text atLeastLessThan} *} |
13735 | 171 |
|
172 |
lemma atLeastLessThan_iff [simp]: |
|
15045 | 173 |
"(i : {l..<u}) = (l <= i & i < u)" |
13735 | 174 |
by (simp add: atLeastLessThan_def) |
175 |
||
14577 | 176 |
text {* @{text greaterThanAtMost} *} |
13735 | 177 |
|
178 |
lemma greaterThanAtMost_iff [simp]: |
|
15045 | 179 |
"(i : {l<..u}) = (l < i & i <= u)" |
13735 | 180 |
by (simp add: greaterThanAtMost_def) |
181 |
||
14577 | 182 |
text {* @{text atLeastAtMost} *} |
13735 | 183 |
|
184 |
lemma atLeastAtMost_iff [simp]: |
|
185 |
"(i : {l..u}) = (l <= i & i <= u)" |
|
186 |
by (simp add: atLeastAtMost_def) |
|
187 |
||
14577 | 188 |
text {* The above four lemmas could be declared as iffs. |
189 |
If we do so, a call to blast in Hyperreal/Star.ML, lemma @{text STAR_Int} |
|
190 |
seems to take forever (more than one hour). *} |
|
13735 | 191 |
|
14485 | 192 |
|
193 |
subsection {* Intervals of natural numbers *} |
|
194 |
||
15047 | 195 |
subsubsection {* The Constant @{term lessThan} *} |
196 |
||
14485 | 197 |
lemma lessThan_0 [simp]: "lessThan (0::nat) = {}" |
198 |
by (simp add: lessThan_def) |
|
199 |
||
200 |
lemma lessThan_Suc: "lessThan (Suc k) = insert k (lessThan k)" |
|
201 |
by (simp add: lessThan_def less_Suc_eq, blast) |
|
202 |
||
203 |
lemma lessThan_Suc_atMost: "lessThan (Suc k) = atMost k" |
|
204 |
by (simp add: lessThan_def atMost_def less_Suc_eq_le) |
|
205 |
||
206 |
lemma UN_lessThan_UNIV: "(UN m::nat. lessThan m) = UNIV" |
|
207 |
by blast |
|
208 |
||
15047 | 209 |
subsubsection {* The Constant @{term greaterThan} *} |
210 |
||
14485 | 211 |
lemma greaterThan_0 [simp]: "greaterThan 0 = range Suc" |
212 |
apply (simp add: greaterThan_def) |
|
213 |
apply (blast dest: gr0_conv_Suc [THEN iffD1]) |
|
214 |
done |
|
215 |
||
216 |
lemma greaterThan_Suc: "greaterThan (Suc k) = greaterThan k - {Suc k}" |
|
217 |
apply (simp add: greaterThan_def) |
|
218 |
apply (auto elim: linorder_neqE) |
|
219 |
done |
|
220 |
||
221 |
lemma INT_greaterThan_UNIV: "(INT m::nat. greaterThan m) = {}" |
|
222 |
by blast |
|
223 |
||
15047 | 224 |
subsubsection {* The Constant @{term atLeast} *} |
225 |
||
14485 | 226 |
lemma atLeast_0 [simp]: "atLeast (0::nat) = UNIV" |
227 |
by (unfold atLeast_def UNIV_def, simp) |
|
228 |
||
229 |
lemma atLeast_Suc: "atLeast (Suc k) = atLeast k - {k}" |
|
230 |
apply (simp add: atLeast_def) |
|
231 |
apply (simp add: Suc_le_eq) |
|
232 |
apply (simp add: order_le_less, blast) |
|
233 |
done |
|
234 |
||
235 |
lemma atLeast_Suc_greaterThan: "atLeast (Suc k) = greaterThan k" |
|
236 |
by (auto simp add: greaterThan_def atLeast_def less_Suc_eq_le) |
|
237 |
||
238 |
lemma UN_atLeast_UNIV: "(UN m::nat. atLeast m) = UNIV" |
|
239 |
by blast |
|
240 |
||
15047 | 241 |
subsubsection {* The Constant @{term atMost} *} |
242 |
||
14485 | 243 |
lemma atMost_0 [simp]: "atMost (0::nat) = {0}" |
244 |
by (simp add: atMost_def) |
|
245 |
||
246 |
lemma atMost_Suc: "atMost (Suc k) = insert (Suc k) (atMost k)" |
|
247 |
apply (simp add: atMost_def) |
|
248 |
apply (simp add: less_Suc_eq order_le_less, blast) |
|
249 |
done |
|
250 |
||
251 |
lemma UN_atMost_UNIV: "(UN m::nat. atMost m) = UNIV" |
|
252 |
by blast |
|
253 |
||
15047 | 254 |
subsubsection {* The Constant @{term atLeastLessThan} *} |
255 |
||
256 |
text{*But not a simprule because some concepts are better left in terms |
|
257 |
of @{term atLeastLessThan}*} |
|
258 |
lemma atLeast0LessThan: "{0::nat..<n} = {..<n}" |
|
15042 | 259 |
by(simp add:lessThan_def atLeastLessThan_def) |
260 |
||
15047 | 261 |
lemma atLeastLessThan0 [simp]: "{m..<0::nat} = {}" |
262 |
by (simp add: atLeastLessThan_def) |
|
263 |
||
264 |
lemma atLeastLessThan_self [simp]: "{n::'a::order..<n} = {}" |
|
265 |
by (auto simp add: atLeastLessThan_def) |
|
266 |
||
267 |
lemma atLeastLessThan_empty: "n \<le> m ==> {m..<n::'a::order} = {}" |
|
268 |
by (auto simp add: atLeastLessThan_def) |
|
269 |
||
270 |
subsubsection {* Intervals of nats with @{term Suc} *} |
|
271 |
||
272 |
text{*Not a simprule because the RHS is too messy.*} |
|
273 |
lemma atLeastLessThanSuc: |
|
274 |
"{m..<Suc n} = (if m \<le> n then insert n {m..<n} else {})" |
|
275 |
by (auto simp add: atLeastLessThan_def) |
|
276 |
||
277 |
lemma atLeastLessThan_singleton [simp]: "{m..<Suc m} = {m}" |
|
278 |
by (auto simp add: atLeastLessThan_def) |
|
279 |
||
280 |
lemma atLeast_sum_LessThan [simp]: "{m + k..<k::nat} = {}" |
|
281 |
by (induct k, simp_all add: atLeastLessThanSuc) |
|
282 |
||
283 |
lemma atLeastSucLessThan [simp]: "{Suc n..<n} = {}" |
|
284 |
by (auto simp add: atLeastLessThan_def) |
|
14485 | 285 |
|
15045 | 286 |
lemma atLeastLessThanSuc_atLeastAtMost: "{l..<Suc u} = {l..u}" |
14485 | 287 |
by (simp add: lessThan_Suc_atMost atLeastAtMost_def atLeastLessThan_def) |
288 |
||
15045 | 289 |
lemma atLeastSucAtMost_greaterThanAtMost: "{Suc l..u} = {l<..u}" |
14485 | 290 |
by (simp add: atLeast_Suc_greaterThan atLeastAtMost_def |
291 |
greaterThanAtMost_def) |
|
292 |
||
15045 | 293 |
lemma atLeastSucLessThan_greaterThanLessThan: "{Suc l..<u} = {l<..<u}" |
14485 | 294 |
by (simp add: atLeast_Suc_greaterThan atLeastLessThan_def |
295 |
greaterThanLessThan_def) |
|
296 |
||
297 |
subsubsection {* Finiteness *} |
|
298 |
||
15045 | 299 |
lemma finite_lessThan [iff]: fixes k :: nat shows "finite {..<k}" |
14485 | 300 |
by (induct k) (simp_all add: lessThan_Suc) |
301 |
||
302 |
lemma finite_atMost [iff]: fixes k :: nat shows "finite {..k}" |
|
303 |
by (induct k) (simp_all add: atMost_Suc) |
|
304 |
||
305 |
lemma finite_greaterThanLessThan [iff]: |
|
15045 | 306 |
fixes l :: nat shows "finite {l<..<u}" |
14485 | 307 |
by (simp add: greaterThanLessThan_def) |
308 |
||
309 |
lemma finite_atLeastLessThan [iff]: |
|
15045 | 310 |
fixes l :: nat shows "finite {l..<u}" |
14485 | 311 |
by (simp add: atLeastLessThan_def) |
312 |
||
313 |
lemma finite_greaterThanAtMost [iff]: |
|
15045 | 314 |
fixes l :: nat shows "finite {l<..u}" |
14485 | 315 |
by (simp add: greaterThanAtMost_def) |
316 |
||
317 |
lemma finite_atLeastAtMost [iff]: |
|
318 |
fixes l :: nat shows "finite {l..u}" |
|
319 |
by (simp add: atLeastAtMost_def) |
|
320 |
||
321 |
lemma bounded_nat_set_is_finite: |
|
322 |
"(ALL i:N. i < (n::nat)) ==> finite N" |
|
323 |
-- {* A bounded set of natural numbers is finite. *} |
|
324 |
apply (rule finite_subset) |
|
325 |
apply (rule_tac [2] finite_lessThan, auto) |
|
326 |
done |
|
327 |
||
328 |
subsubsection {* Cardinality *} |
|
329 |
||
15045 | 330 |
lemma card_lessThan [simp]: "card {..<u} = u" |
14485 | 331 |
by (induct_tac u, simp_all add: lessThan_Suc) |
332 |
||
333 |
lemma card_atMost [simp]: "card {..u} = Suc u" |
|
334 |
by (simp add: lessThan_Suc_atMost [THEN sym]) |
|
335 |
||
15045 | 336 |
lemma card_atLeastLessThan [simp]: "card {l..<u} = u - l" |
337 |
apply (subgoal_tac "card {l..<u} = card {..<u-l}") |
|
14485 | 338 |
apply (erule ssubst, rule card_lessThan) |
15045 | 339 |
apply (subgoal_tac "(%x. x + l) ` {..<u-l} = {l..<u}") |
14485 | 340 |
apply (erule subst) |
341 |
apply (rule card_image) |
|
342 |
apply (rule finite_lessThan) |
|
343 |
apply (simp add: inj_on_def) |
|
344 |
apply (auto simp add: image_def atLeastLessThan_def lessThan_def) |
|
345 |
apply arith |
|
346 |
apply (rule_tac x = "x - l" in exI) |
|
347 |
apply arith |
|
348 |
done |
|
349 |
||
15047 | 350 |
lemma card_atLeastAtMost [simp]: "card {l..u} = Suc u - l" |
14485 | 351 |
by (subst atLeastLessThanSuc_atLeastAtMost [THEN sym], simp) |
352 |
||
15045 | 353 |
lemma card_greaterThanAtMost [simp]: "card {l<..u} = u - l" |
14485 | 354 |
by (subst atLeastSucAtMost_greaterThanAtMost [THEN sym], simp) |
355 |
||
15045 | 356 |
lemma card_greaterThanLessThan [simp]: "card {l<..<u} = u - Suc l" |
14485 | 357 |
by (subst atLeastSucLessThan_greaterThanLessThan [THEN sym], simp) |
358 |
||
359 |
subsection {* Intervals of integers *} |
|
360 |
||
15045 | 361 |
lemma atLeastLessThanPlusOne_atLeastAtMost_int: "{l..<u+1} = {l..(u::int)}" |
14485 | 362 |
by (auto simp add: atLeastAtMost_def atLeastLessThan_def) |
363 |
||
15045 | 364 |
lemma atLeastPlusOneAtMost_greaterThanAtMost_int: "{l+1..u} = {l<..(u::int)}" |
14485 | 365 |
by (auto simp add: atLeastAtMost_def greaterThanAtMost_def) |
366 |
||
367 |
lemma atLeastPlusOneLessThan_greaterThanLessThan_int: |
|
15045 | 368 |
"{l+1..<u} = {l<..<u::int}" |
14485 | 369 |
by (auto simp add: atLeastLessThan_def greaterThanLessThan_def) |
370 |
||
371 |
subsubsection {* Finiteness *} |
|
372 |
||
373 |
lemma image_atLeastZeroLessThan_int: "0 \<le> u ==> |
|
15045 | 374 |
{(0::int)..<u} = int ` {..<nat u}" |
14485 | 375 |
apply (unfold image_def lessThan_def) |
376 |
apply auto |
|
377 |
apply (rule_tac x = "nat x" in exI) |
|
378 |
apply (auto simp add: zless_nat_conj zless_nat_eq_int_zless [THEN sym]) |
|
379 |
done |
|
380 |
||
15045 | 381 |
lemma finite_atLeastZeroLessThan_int: "finite {(0::int)..<u}" |
14485 | 382 |
apply (case_tac "0 \<le> u") |
383 |
apply (subst image_atLeastZeroLessThan_int, assumption) |
|
384 |
apply (rule finite_imageI) |
|
385 |
apply auto |
|
15045 | 386 |
apply (subgoal_tac "{0..<u} = {}") |
14485 | 387 |
apply auto |
388 |
done |
|
389 |
||
390 |
lemma image_atLeastLessThan_int_shift: |
|
15045 | 391 |
"(%x. x + (l::int)) ` {0..<u-l} = {l..<u}" |
14485 | 392 |
apply (auto simp add: image_def atLeastLessThan_iff) |
393 |
apply (rule_tac x = "x - l" in bexI) |
|
394 |
apply auto |
|
395 |
done |
|
396 |
||
15045 | 397 |
lemma finite_atLeastLessThan_int [iff]: "finite {l..<u::int}" |
398 |
apply (subgoal_tac "(%x. x + l) ` {0..<u-l} = {l..<u}") |
|
14485 | 399 |
apply (erule subst) |
400 |
apply (rule finite_imageI) |
|
401 |
apply (rule finite_atLeastZeroLessThan_int) |
|
402 |
apply (rule image_atLeastLessThan_int_shift) |
|
403 |
done |
|
404 |
||
405 |
lemma finite_atLeastAtMost_int [iff]: "finite {l..(u::int)}" |
|
406 |
by (subst atLeastLessThanPlusOne_atLeastAtMost_int [THEN sym], simp) |
|
407 |
||
15045 | 408 |
lemma finite_greaterThanAtMost_int [iff]: "finite {l<..(u::int)}" |
14485 | 409 |
by (subst atLeastPlusOneAtMost_greaterThanAtMost_int [THEN sym], simp) |
410 |
||
15045 | 411 |
lemma finite_greaterThanLessThan_int [iff]: "finite {l<..<u::int}" |
14485 | 412 |
by (subst atLeastPlusOneLessThan_greaterThanLessThan_int [THEN sym], simp) |
413 |
||
414 |
subsubsection {* Cardinality *} |
|
415 |
||
15045 | 416 |
lemma card_atLeastZeroLessThan_int: "card {(0::int)..<u} = nat u" |
14485 | 417 |
apply (case_tac "0 \<le> u") |
418 |
apply (subst image_atLeastZeroLessThan_int, assumption) |
|
419 |
apply (subst card_image) |
|
420 |
apply (auto simp add: inj_on_def) |
|
421 |
done |
|
422 |
||
15045 | 423 |
lemma card_atLeastLessThan_int [simp]: "card {l..<u} = nat (u - l)" |
424 |
apply (subgoal_tac "card {l..<u} = card {0..<u-l}") |
|
14485 | 425 |
apply (erule ssubst, rule card_atLeastZeroLessThan_int) |
15045 | 426 |
apply (subgoal_tac "(%x. x + l) ` {0..<u-l} = {l..<u}") |
14485 | 427 |
apply (erule subst) |
428 |
apply (rule card_image) |
|
429 |
apply (rule finite_atLeastZeroLessThan_int) |
|
430 |
apply (simp add: inj_on_def) |
|
431 |
apply (rule image_atLeastLessThan_int_shift) |
|
432 |
done |
|
433 |
||
434 |
lemma card_atLeastAtMost_int [simp]: "card {l..u} = nat (u - l + 1)" |
|
435 |
apply (subst atLeastLessThanPlusOne_atLeastAtMost_int [THEN sym]) |
|
436 |
apply (auto simp add: compare_rls) |
|
437 |
done |
|
438 |
||
15045 | 439 |
lemma card_greaterThanAtMost_int [simp]: "card {l<..u} = nat (u - l)" |
14485 | 440 |
by (subst atLeastPlusOneAtMost_greaterThanAtMost_int [THEN sym], simp) |
441 |
||
15045 | 442 |
lemma card_greaterThanLessThan_int [simp]: "card {l<..<u} = nat (u - (l + 1))" |
14485 | 443 |
by (subst atLeastPlusOneLessThan_greaterThanLessThan_int [THEN sym], simp) |
444 |
||
445 |
||
13850 | 446 |
subsection {*Lemmas useful with the summation operator setsum*} |
447 |
||
14577 | 448 |
text {* For examples, see Algebra/poly/UnivPoly.thy *} |
13735 | 449 |
|
14577 | 450 |
subsubsection {* Disjoint Unions *} |
13735 | 451 |
|
14577 | 452 |
text {* Singletons and open intervals *} |
13735 | 453 |
|
454 |
lemma ivl_disj_un_singleton: |
|
15045 | 455 |
"{l::'a::linorder} Un {l<..} = {l..}" |
456 |
"{..<u} Un {u::'a::linorder} = {..u}" |
|
457 |
"(l::'a::linorder) < u ==> {l} Un {l<..<u} = {l..<u}" |
|
458 |
"(l::'a::linorder) < u ==> {l<..<u} Un {u} = {l<..u}" |
|
459 |
"(l::'a::linorder) <= u ==> {l} Un {l<..u} = {l..u}" |
|
460 |
"(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
|
461 |
by auto |
13735 | 462 |
|
14577 | 463 |
text {* One- and two-sided intervals *} |
13735 | 464 |
|
465 |
lemma ivl_disj_un_one: |
|
15045 | 466 |
"(l::'a::linorder) < u ==> {..l} Un {l<..<u} = {..<u}" |
467 |
"(l::'a::linorder) <= u ==> {..<l} Un {l..<u} = {..<u}" |
|
468 |
"(l::'a::linorder) <= u ==> {..l} Un {l<..u} = {..u}" |
|
469 |
"(l::'a::linorder) <= u ==> {..<l} Un {l..u} = {..u}" |
|
470 |
"(l::'a::linorder) <= u ==> {l<..u} Un {u<..} = {l<..}" |
|
471 |
"(l::'a::linorder) < u ==> {l<..<u} Un {u..} = {l<..}" |
|
472 |
"(l::'a::linorder) <= u ==> {l..u} Un {u<..} = {l..}" |
|
473 |
"(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
|
474 |
by auto |
13735 | 475 |
|
14577 | 476 |
text {* Two- and two-sided intervals *} |
13735 | 477 |
|
478 |
lemma ivl_disj_un_two: |
|
15045 | 479 |
"[| (l::'a::linorder) < m; m <= u |] ==> {l<..<m} Un {m..<u} = {l<..<u}" |
480 |
"[| (l::'a::linorder) <= m; m < u |] ==> {l<..m} Un {m<..<u} = {l<..<u}" |
|
481 |
"[| (l::'a::linorder) <= m; m <= u |] ==> {l..<m} Un {m..<u} = {l..<u}" |
|
482 |
"[| (l::'a::linorder) <= m; m < u |] ==> {l..m} Un {m<..<u} = {l..<u}" |
|
483 |
"[| (l::'a::linorder) < m; m <= u |] ==> {l<..<m} Un {m..u} = {l<..u}" |
|
484 |
"[| (l::'a::linorder) <= m; m <= u |] ==> {l<..m} Un {m<..u} = {l<..u}" |
|
485 |
"[| (l::'a::linorder) <= m; m <= u |] ==> {l..<m} Un {m..u} = {l..u}" |
|
486 |
"[| (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
|
487 |
by auto |
13735 | 488 |
|
489 |
lemmas ivl_disj_un = ivl_disj_un_singleton ivl_disj_un_one ivl_disj_un_two |
|
490 |
||
14577 | 491 |
subsubsection {* Disjoint Intersections *} |
13735 | 492 |
|
14577 | 493 |
text {* Singletons and open intervals *} |
13735 | 494 |
|
495 |
lemma ivl_disj_int_singleton: |
|
15045 | 496 |
"{l::'a::order} Int {l<..} = {}" |
497 |
"{..<u} Int {u} = {}" |
|
498 |
"{l} Int {l<..<u} = {}" |
|
499 |
"{l<..<u} Int {u} = {}" |
|
500 |
"{l} Int {l<..u} = {}" |
|
501 |
"{l..<u} Int {u} = {}" |
|
13735 | 502 |
by simp+ |
503 |
||
14577 | 504 |
text {* One- and two-sided intervals *} |
13735 | 505 |
|
506 |
lemma ivl_disj_int_one: |
|
15045 | 507 |
"{..l::'a::order} Int {l<..<u} = {}" |
508 |
"{..<l} Int {l..<u} = {}" |
|
509 |
"{..l} Int {l<..u} = {}" |
|
510 |
"{..<l} Int {l..u} = {}" |
|
511 |
"{l<..u} Int {u<..} = {}" |
|
512 |
"{l<..<u} Int {u..} = {}" |
|
513 |
"{l..u} Int {u<..} = {}" |
|
514 |
"{l..<u} Int {u..} = {}" |
|
14398
c5c47703f763
Efficient, graph-based reasoner for linear and partial orders.
ballarin
parents:
13850
diff
changeset
|
515 |
by auto |
13735 | 516 |
|
14577 | 517 |
text {* Two- and two-sided intervals *} |
13735 | 518 |
|
519 |
lemma ivl_disj_int_two: |
|
15045 | 520 |
"{l::'a::order<..<m} Int {m..<u} = {}" |
521 |
"{l<..m} Int {m<..<u} = {}" |
|
522 |
"{l..<m} Int {m..<u} = {}" |
|
523 |
"{l..m} Int {m<..<u} = {}" |
|
524 |
"{l<..<m} Int {m..u} = {}" |
|
525 |
"{l<..m} Int {m<..u} = {}" |
|
526 |
"{l..<m} Int {m..u} = {}" |
|
527 |
"{l..m} Int {m<..u} = {}" |
|
14398
c5c47703f763
Efficient, graph-based reasoner for linear and partial orders.
ballarin
parents:
13850
diff
changeset
|
528 |
by auto |
13735 | 529 |
|
530 |
lemmas ivl_disj_int = ivl_disj_int_singleton ivl_disj_int_one ivl_disj_int_two |
|
531 |
||
15041
a6b1f0cef7b3
Got rid of Summation and made it a translation into setsum instead.
nipkow
parents:
14846
diff
changeset
|
532 |
|
15042 | 533 |
subsection {* Summation indexed over intervals *} |
534 |
||
535 |
text{* We introduce the obvious syntax @{text"\<Sum>x=a..b. e"} for |
|
536 |
@{term"\<Sum>x\<in>{a..b}. e"}. *} |
|
537 |
||
538 |
syntax |
|
539 |
"_from_to_setsum" :: "idt \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> 'b" ("(SUM _ = _.._./ _)" [0,0,0,10] 10) |
|
540 |
syntax (xsymbols) |
|
541 |
"_from_to_setsum" :: "idt \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> 'b" ("(3\<Sum>_ = _.._./ _)" [0,0,0,10] 10) |
|
542 |
syntax (HTML output) |
|
543 |
"_from_to_setsum" :: "idt \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> 'b" ("(3\<Sum>_ = _.._./ _)" [0,0,0,10] 10) |
|
544 |
||
545 |
translations "\<Sum>x=a..b. t" == "setsum (%x. t) {a..b}" |
|
546 |
||
547 |
||
548 |
subsection {* Summation up to *} |
|
15041
a6b1f0cef7b3
Got rid of Summation and made it a translation into setsum instead.
nipkow
parents:
14846
diff
changeset
|
549 |
|
a6b1f0cef7b3
Got rid of Summation and made it a translation into setsum instead.
nipkow
parents:
14846
diff
changeset
|
550 |
text{* Legacy, only used in HoareParallel and Isar-Examples. Really |
15042 | 551 |
needed? Probably better to replace it with above syntax. *} |
15041
a6b1f0cef7b3
Got rid of Summation and made it a translation into setsum instead.
nipkow
parents:
14846
diff
changeset
|
552 |
|
a6b1f0cef7b3
Got rid of Summation and made it a translation into setsum instead.
nipkow
parents:
14846
diff
changeset
|
553 |
syntax |
15042 | 554 |
"_Summation" :: "idt => 'a => 'b => 'b" ("\<Sum>_<_. _" [0, 51, 10] 10) |
15041
a6b1f0cef7b3
Got rid of Summation and made it a translation into setsum instead.
nipkow
parents:
14846
diff
changeset
|
555 |
translations |
15045 | 556 |
"\<Sum>i < n. b" == "setsum (\<lambda>i. b) {..<n}" |
15041
a6b1f0cef7b3
Got rid of Summation and made it a translation into setsum instead.
nipkow
parents:
14846
diff
changeset
|
557 |
|
a6b1f0cef7b3
Got rid of Summation and made it a translation into setsum instead.
nipkow
parents:
14846
diff
changeset
|
558 |
lemma Summation_Suc[simp]: "(\<Sum>i < Suc n. b i) = b n + (\<Sum>i < n. b i)" |
a6b1f0cef7b3
Got rid of Summation and made it a translation into setsum instead.
nipkow
parents:
14846
diff
changeset
|
559 |
by (simp add:lessThan_Suc) |
a6b1f0cef7b3
Got rid of Summation and made it a translation into setsum instead.
nipkow
parents:
14846
diff
changeset
|
560 |
|
8924 | 561 |
end |