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