src/HOL/SetInterval.thy
author paulson
Thu Mar 06 15:03:16 2003 +0100 (2003-03-06)
changeset 13850 6d1bb3059818
parent 13735 7de9342aca7a
child 14398 c5c47703f763
permissions -rw-r--r--
new logical equivalences
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
paulson@13850
    36
paulson@13850
    37
subsection {* Setup of transitivity reasoner *}
ballarin@13735
    38
ballarin@13735
    39
ML {*
ballarin@13735
    40
ballarin@13735
    41
structure Trans_Tac = Trans_Tac_Fun (
ballarin@13735
    42
  struct
ballarin@13735
    43
    val less_reflE = thm "order_less_irrefl" RS thm "notE";
ballarin@13735
    44
    val le_refl = thm "order_refl";
ballarin@13735
    45
    val less_imp_le = thm "order_less_imp_le";
ballarin@13735
    46
    val not_lessI = thm "linorder_not_less" RS thm "iffD2";
ballarin@13735
    47
    val not_leI = thm "linorder_not_less" RS thm "iffD2";
ballarin@13735
    48
    val not_lessD = thm "linorder_not_less" RS thm "iffD1";
ballarin@13735
    49
    val not_leD = thm "linorder_not_le" RS thm "iffD1";
ballarin@13735
    50
    val eqI = thm "order_antisym";
ballarin@13735
    51
    val eqD1 = thm "order_eq_refl";
ballarin@13735
    52
    val eqD2 = thm "sym" RS thm "order_eq_refl";
ballarin@13735
    53
    val less_trans = thm "order_less_trans";
ballarin@13735
    54
    val less_le_trans = thm "order_less_le_trans";
ballarin@13735
    55
    val le_less_trans = thm "order_le_less_trans";
ballarin@13735
    56
    val le_trans = thm "order_trans";
ballarin@13735
    57
    fun decomp (Trueprop $ t) =
ballarin@13735
    58
      let fun dec (Const ("Not", _) $ t) = (
ballarin@13735
    59
              case dec t of
ballarin@13735
    60
		None => None
ballarin@13735
    61
	      | Some (t1, rel, t2) => Some (t1, "~" ^ rel, t2))
ballarin@13735
    62
	    | dec (Const (rel, _) $ t1 $ t2) = 
ballarin@13735
    63
                Some (t1, implode (drop (3, explode rel)), t2)
ballarin@13735
    64
	    | dec _ = None
ballarin@13735
    65
      in dec t end
ballarin@13735
    66
      | decomp _ = None
ballarin@13735
    67
  end);
ballarin@13735
    68
ballarin@13735
    69
val trans_tac = Trans_Tac.trans_tac;
ballarin@13735
    70
ballarin@13735
    71
*}
ballarin@13735
    72
ballarin@13735
    73
method_setup trans =
ballarin@13735
    74
  {* Method.no_args (Method.SIMPLE_METHOD' HEADGOAL (trans_tac)) *}
ballarin@13735
    75
  {* simple transitivity reasoner *}
ballarin@13735
    76
ballarin@13735
    77
paulson@13850
    78
subsection {*lessThan*}
ballarin@13735
    79
paulson@13850
    80
lemma lessThan_iff [iff]: "(i: lessThan k) = (i<k)"
paulson@13850
    81
by (simp add: lessThan_def)
ballarin@13735
    82
paulson@13850
    83
lemma lessThan_0 [simp]: "lessThan (0::nat) = {}"
paulson@13850
    84
by (simp add: lessThan_def)
ballarin@13735
    85
ballarin@13735
    86
lemma lessThan_Suc: "lessThan (Suc k) = insert k (lessThan k)"
paulson@13850
    87
by (simp add: lessThan_def less_Suc_eq, blast)
ballarin@13735
    88
ballarin@13735
    89
lemma lessThan_Suc_atMost: "lessThan (Suc k) = atMost k"
paulson@13850
    90
by (simp add: lessThan_def atMost_def less_Suc_eq_le)
ballarin@13735
    91
ballarin@13735
    92
lemma UN_lessThan_UNIV: "(UN m::nat. lessThan m) = UNIV"
paulson@13850
    93
by blast
ballarin@13735
    94
paulson@13850
    95
lemma Compl_lessThan [simp]: 
ballarin@13735
    96
    "!!k:: 'a::linorder. -lessThan k = atLeast k"
paulson@13850
    97
apply (auto simp add: lessThan_def atLeast_def)
paulson@13850
    98
 apply (blast intro: linorder_not_less [THEN iffD1])
ballarin@13735
    99
apply (blast dest: order_le_less_trans)
ballarin@13735
   100
done
ballarin@13735
   101
paulson@13850
   102
lemma single_Diff_lessThan [simp]: "!!k:: 'a::order. {k} - lessThan k = {k}"
paulson@13850
   103
by auto
ballarin@13735
   104
paulson@13850
   105
subsection {*greaterThan*}
ballarin@13735
   106
paulson@13850
   107
lemma greaterThan_iff [iff]: "(i: greaterThan k) = (k<i)"
paulson@13850
   108
by (simp add: greaterThan_def)
ballarin@13735
   109
paulson@13850
   110
lemma greaterThan_0 [simp]: "greaterThan 0 = range Suc"
paulson@13850
   111
apply (simp add: greaterThan_def)
ballarin@13735
   112
apply (blast dest: gr0_conv_Suc [THEN iffD1])
ballarin@13735
   113
done
ballarin@13735
   114
ballarin@13735
   115
lemma greaterThan_Suc: "greaterThan (Suc k) = greaterThan k - {Suc k}"
paulson@13850
   116
apply (simp add: greaterThan_def)
ballarin@13735
   117
apply (auto elim: linorder_neqE)
ballarin@13735
   118
done
ballarin@13735
   119
ballarin@13735
   120
lemma INT_greaterThan_UNIV: "(INT m::nat. greaterThan m) = {}"
paulson@13850
   121
by blast
ballarin@13735
   122
paulson@13850
   123
lemma Compl_greaterThan [simp]: 
ballarin@13735
   124
    "!!k:: 'a::linorder. -greaterThan k = atMost k"
paulson@13850
   125
apply (simp add: greaterThan_def atMost_def le_def, auto)
ballarin@13735
   126
apply (blast intro: linorder_not_less [THEN iffD1])
ballarin@13735
   127
apply (blast dest: order_le_less_trans)
ballarin@13735
   128
done
ballarin@13735
   129
paulson@13850
   130
lemma Compl_atMost [simp]: "!!k:: 'a::linorder. -atMost k = greaterThan k"
paulson@13850
   131
apply (subst Compl_greaterThan [symmetric])
paulson@13850
   132
apply (rule double_complement) 
ballarin@13735
   133
done
ballarin@13735
   134
ballarin@13735
   135
paulson@13850
   136
subsection {*atLeast*}
ballarin@13735
   137
paulson@13850
   138
lemma atLeast_iff [iff]: "(i: atLeast k) = (k<=i)"
paulson@13850
   139
by (simp add: atLeast_def)
ballarin@13735
   140
paulson@13850
   141
lemma atLeast_0 [simp]: "atLeast (0::nat) = UNIV"
paulson@13850
   142
by (unfold atLeast_def UNIV_def, simp)
ballarin@13735
   143
ballarin@13735
   144
lemma atLeast_Suc: "atLeast (Suc k) = atLeast k - {k}"
paulson@13850
   145
apply (simp add: atLeast_def)
paulson@13850
   146
apply (simp add: Suc_le_eq)
paulson@13850
   147
apply (simp add: order_le_less, blast)
ballarin@13735
   148
done
ballarin@13735
   149
ballarin@13735
   150
lemma UN_atLeast_UNIV: "(UN m::nat. atLeast m) = UNIV"
paulson@13850
   151
by blast
ballarin@13735
   152
paulson@13850
   153
lemma Compl_atLeast [simp]: 
ballarin@13735
   154
    "!!k:: 'a::linorder. -atLeast k = lessThan k"
paulson@13850
   155
apply (simp add: lessThan_def atLeast_def le_def, auto)
ballarin@13735
   156
apply (blast intro: linorder_not_less [THEN iffD1])
ballarin@13735
   157
apply (blast dest: order_le_less_trans)
ballarin@13735
   158
done
ballarin@13735
   159
ballarin@13735
   160
paulson@13850
   161
subsection {*atMost*}
ballarin@13735
   162
paulson@13850
   163
lemma atMost_iff [iff]: "(i: atMost k) = (i<=k)"
paulson@13850
   164
by (simp add: atMost_def)
ballarin@13735
   165
paulson@13850
   166
lemma atMost_0 [simp]: "atMost (0::nat) = {0}"
paulson@13850
   167
by (simp add: atMost_def)
ballarin@13735
   168
ballarin@13735
   169
lemma atMost_Suc: "atMost (Suc k) = insert (Suc k) (atMost k)"
paulson@13850
   170
apply (simp add: atMost_def)
paulson@13850
   171
apply (simp add: less_Suc_eq order_le_less, blast)
ballarin@13735
   172
done
ballarin@13735
   173
ballarin@13735
   174
lemma UN_atMost_UNIV: "(UN m::nat. atMost m) = UNIV"
paulson@13850
   175
by blast
paulson@13850
   176
paulson@13850
   177
paulson@13850
   178
subsection {*Logical Equivalences for Set Inclusion and Equality*}
paulson@13850
   179
paulson@13850
   180
lemma atLeast_subset_iff [iff]:
paulson@13850
   181
     "(atLeast x \<subseteq> atLeast y) = (y \<le> (x::'a::order))" 
paulson@13850
   182
by (blast intro: order_trans) 
paulson@13850
   183
paulson@13850
   184
lemma atLeast_eq_iff [iff]:
paulson@13850
   185
     "(atLeast x = atLeast y) = (x = (y::'a::linorder))" 
paulson@13850
   186
by (blast intro: order_antisym order_trans)
paulson@13850
   187
paulson@13850
   188
lemma greaterThan_subset_iff [iff]:
paulson@13850
   189
     "(greaterThan x \<subseteq> greaterThan y) = (y \<le> (x::'a::linorder))" 
paulson@13850
   190
apply (auto simp add: greaterThan_def) 
paulson@13850
   191
 apply (subst linorder_not_less [symmetric], blast) 
paulson@13850
   192
apply (blast intro: order_le_less_trans) 
paulson@13850
   193
done
paulson@13850
   194
paulson@13850
   195
lemma greaterThan_eq_iff [iff]:
paulson@13850
   196
     "(greaterThan x = greaterThan y) = (x = (y::'a::linorder))" 
paulson@13850
   197
apply (rule iffI) 
paulson@13850
   198
 apply (erule equalityE) 
paulson@13850
   199
 apply (simp add: greaterThan_subset_iff order_antisym, simp) 
paulson@13850
   200
done
paulson@13850
   201
paulson@13850
   202
lemma atMost_subset_iff [iff]: "(atMost x \<subseteq> atMost y) = (x \<le> (y::'a::order))" 
paulson@13850
   203
by (blast intro: order_trans)
paulson@13850
   204
paulson@13850
   205
lemma atMost_eq_iff [iff]: "(atMost x = atMost y) = (x = (y::'a::linorder))" 
paulson@13850
   206
by (blast intro: order_antisym order_trans)
paulson@13850
   207
paulson@13850
   208
lemma lessThan_subset_iff [iff]:
paulson@13850
   209
     "(lessThan x \<subseteq> lessThan y) = (x \<le> (y::'a::linorder))" 
paulson@13850
   210
apply (auto simp add: lessThan_def) 
paulson@13850
   211
 apply (subst linorder_not_less [symmetric], blast) 
paulson@13850
   212
apply (blast intro: order_less_le_trans) 
paulson@13850
   213
done
paulson@13850
   214
paulson@13850
   215
lemma lessThan_eq_iff [iff]:
paulson@13850
   216
     "(lessThan x = lessThan y) = (x = (y::'a::linorder))" 
paulson@13850
   217
apply (rule iffI) 
paulson@13850
   218
 apply (erule equalityE) 
paulson@13850
   219
 apply (simp add: lessThan_subset_iff order_antisym, simp) 
ballarin@13735
   220
done
ballarin@13735
   221
ballarin@13735
   222
paulson@13850
   223
subsection {*Combined properties*}
ballarin@13735
   224
ballarin@13735
   225
lemma atMost_Int_atLeast: "!!n:: 'a::order. atMost n Int atLeast n = {n}"
paulson@13850
   226
by (blast intro: order_antisym)
ballarin@13735
   227
paulson@13850
   228
subsection {*Two-sided intervals*}
ballarin@13735
   229
ballarin@13735
   230
(* greaterThanLessThan *)
ballarin@13735
   231
ballarin@13735
   232
lemma greaterThanLessThan_iff [simp]:
ballarin@13735
   233
  "(i : {)l..u(}) = (l < i & i < u)"
ballarin@13735
   234
by (simp add: greaterThanLessThan_def)
ballarin@13735
   235
ballarin@13735
   236
(* atLeastLessThan *)
ballarin@13735
   237
ballarin@13735
   238
lemma atLeastLessThan_iff [simp]:
ballarin@13735
   239
  "(i : {l..u(}) = (l <= i & i < u)"
ballarin@13735
   240
by (simp add: atLeastLessThan_def)
ballarin@13735
   241
ballarin@13735
   242
(* greaterThanAtMost *)
ballarin@13735
   243
ballarin@13735
   244
lemma greaterThanAtMost_iff [simp]:
ballarin@13735
   245
  "(i : {)l..u}) = (l < i & i <= u)"
ballarin@13735
   246
by (simp add: greaterThanAtMost_def)
ballarin@13735
   247
ballarin@13735
   248
(* atLeastAtMost *)
ballarin@13735
   249
ballarin@13735
   250
lemma atLeastAtMost_iff [simp]:
ballarin@13735
   251
  "(i : {l..u}) = (l <= i & i <= u)"
ballarin@13735
   252
by (simp add: atLeastAtMost_def)
ballarin@13735
   253
ballarin@13735
   254
(* The above four lemmas could be declared as iffs.
ballarin@13735
   255
   If we do so, a call to blast in Hyperreal/Star.ML, lemma STAR_Int
ballarin@13735
   256
   seems to take forever (more than one hour). *)
ballarin@13735
   257
paulson@13850
   258
subsection {*Lemmas useful with the summation operator setsum*}
paulson@13850
   259
ballarin@13735
   260
(* For examples, see Algebra/poly/UnivPoly.thy *)
ballarin@13735
   261
ballarin@13735
   262
(** Disjoint Unions **)
ballarin@13735
   263
ballarin@13735
   264
(* Singletons and open intervals *)
ballarin@13735
   265
ballarin@13735
   266
lemma ivl_disj_un_singleton:
ballarin@13735
   267
  "{l::'a::linorder} Un {)l..} = {l..}"
ballarin@13735
   268
  "{..u(} Un {u::'a::linorder} = {..u}"
ballarin@13735
   269
  "(l::'a::linorder) < u ==> {l} Un {)l..u(} = {l..u(}"
ballarin@13735
   270
  "(l::'a::linorder) < u ==> {)l..u(} Un {u} = {)l..u}"
ballarin@13735
   271
  "(l::'a::linorder) <= u ==> {l} Un {)l..u} = {l..u}"
ballarin@13735
   272
  "(l::'a::linorder) <= u ==> {l..u(} Un {u} = {l..u}"
ballarin@13735
   273
by auto (elim linorder_neqE | trans+)+
ballarin@13735
   274
ballarin@13735
   275
(* One- and two-sided intervals *)
ballarin@13735
   276
ballarin@13735
   277
lemma ivl_disj_un_one:
ballarin@13735
   278
  "(l::'a::linorder) < u ==> {..l} Un {)l..u(} = {..u(}"
ballarin@13735
   279
  "(l::'a::linorder) <= u ==> {..l(} Un {l..u(} = {..u(}"
ballarin@13735
   280
  "(l::'a::linorder) <= u ==> {..l} Un {)l..u} = {..u}"
ballarin@13735
   281
  "(l::'a::linorder) <= u ==> {..l(} Un {l..u} = {..u}"
ballarin@13735
   282
  "(l::'a::linorder) <= u ==> {)l..u} Un {)u..} = {)l..}"
ballarin@13735
   283
  "(l::'a::linorder) < u ==> {)l..u(} Un {u..} = {)l..}"
ballarin@13735
   284
  "(l::'a::linorder) <= u ==> {l..u} Un {)u..} = {l..}"
ballarin@13735
   285
  "(l::'a::linorder) <= u ==> {l..u(} Un {u..} = {l..}"
ballarin@13735
   286
by auto trans+
ballarin@13735
   287
ballarin@13735
   288
(* Two- and two-sided intervals *)
ballarin@13735
   289
ballarin@13735
   290
lemma ivl_disj_un_two:
ballarin@13735
   291
  "[| (l::'a::linorder) < m; m <= u |] ==> {)l..m(} Un {m..u(} = {)l..u(}"
ballarin@13735
   292
  "[| (l::'a::linorder) <= m; m < u |] ==> {)l..m} Un {)m..u(} = {)l..u(}"
ballarin@13735
   293
  "[| (l::'a::linorder) <= m; m <= u |] ==> {l..m(} Un {m..u(} = {l..u(}"
ballarin@13735
   294
  "[| (l::'a::linorder) <= m; m < u |] ==> {l..m} Un {)m..u(} = {l..u(}"
ballarin@13735
   295
  "[| (l::'a::linorder) < m; m <= u |] ==> {)l..m(} Un {m..u} = {)l..u}"
ballarin@13735
   296
  "[| (l::'a::linorder) <= m; m <= u |] ==> {)l..m} Un {)m..u} = {)l..u}"
ballarin@13735
   297
  "[| (l::'a::linorder) <= m; m <= u |] ==> {l..m(} Un {m..u} = {l..u}"
ballarin@13735
   298
  "[| (l::'a::linorder) <= m; m <= u |] ==> {l..m} Un {)m..u} = {l..u}"
ballarin@13735
   299
by auto trans+
ballarin@13735
   300
ballarin@13735
   301
lemmas ivl_disj_un = ivl_disj_un_singleton ivl_disj_un_one ivl_disj_un_two
ballarin@13735
   302
ballarin@13735
   303
(** Disjoint Intersections **)
ballarin@13735
   304
ballarin@13735
   305
(* Singletons and open intervals *)
ballarin@13735
   306
ballarin@13735
   307
lemma ivl_disj_int_singleton:
ballarin@13735
   308
  "{l::'a::order} Int {)l..} = {}"
ballarin@13735
   309
  "{..u(} Int {u} = {}"
ballarin@13735
   310
  "{l} Int {)l..u(} = {}"
ballarin@13735
   311
  "{)l..u(} Int {u} = {}"
ballarin@13735
   312
  "{l} Int {)l..u} = {}"
ballarin@13735
   313
  "{l..u(} Int {u} = {}"
ballarin@13735
   314
  by simp+
ballarin@13735
   315
ballarin@13735
   316
(* One- and two-sided intervals *)
ballarin@13735
   317
ballarin@13735
   318
lemma ivl_disj_int_one:
ballarin@13735
   319
  "{..l::'a::order} Int {)l..u(} = {}"
ballarin@13735
   320
  "{..l(} Int {l..u(} = {}"
ballarin@13735
   321
  "{..l} Int {)l..u} = {}"
ballarin@13735
   322
  "{..l(} Int {l..u} = {}"
ballarin@13735
   323
  "{)l..u} Int {)u..} = {}"
ballarin@13735
   324
  "{)l..u(} Int {u..} = {}"
ballarin@13735
   325
  "{l..u} Int {)u..} = {}"
ballarin@13735
   326
  "{l..u(} Int {u..} = {}"
ballarin@13735
   327
  by auto trans+
ballarin@13735
   328
ballarin@13735
   329
(* Two- and two-sided intervals *)
ballarin@13735
   330
ballarin@13735
   331
lemma ivl_disj_int_two:
ballarin@13735
   332
  "{)l::'a::order..m(} Int {m..u(} = {}"
ballarin@13735
   333
  "{)l..m} Int {)m..u(} = {}"
ballarin@13735
   334
  "{l..m(} Int {m..u(} = {}"
ballarin@13735
   335
  "{l..m} Int {)m..u(} = {}"
ballarin@13735
   336
  "{)l..m(} Int {m..u} = {}"
ballarin@13735
   337
  "{)l..m} Int {)m..u} = {}"
ballarin@13735
   338
  "{l..m(} Int {m..u} = {}"
ballarin@13735
   339
  "{l..m} Int {)m..u} = {}"
ballarin@13735
   340
  by auto trans+
ballarin@13735
   341
ballarin@13735
   342
lemmas ivl_disj_int = ivl_disj_int_singleton ivl_disj_int_one ivl_disj_int_two
ballarin@13735
   343
nipkow@8924
   344
end