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