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