| author | wenzelm | 
| Tue, 27 Jun 2017 11:47:14 +0200 | |
| changeset 66200 | 02c66b71c013 | 
| parent 65578 | e4997c181cce | 
| child 66490 | cc66ab2373ce | 
| permissions | -rw-r--r-- | 
| 47317 
432b29a96f61
modernized obsolete old-style theory name with proper new-style underscore
 huffman parents: 
47222diff
changeset | 1 | (* Title: HOL/Set_Interval.thy | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32596diff
changeset | 2 | Author: Tobias Nipkow | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32596diff
changeset | 3 | Author: Clemens Ballarin | 
| 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32596diff
changeset | 4 | Author: Jeremy Avigad | 
| 8924 | 5 | |
| 13735 | 6 | lessThan, greaterThan, atLeast, atMost and two-sided intervals | 
| 51334 | 7 | |
| 8 | Modern convention: Ixy stands for an interval where x and y | |
| 9 | describe the lower and upper bound and x,y : {c,o,i}
 | |
| 10 | where c = closed, o = open, i = infinite. | |
| 11 | Examples: Ico = {_ ..< _} and Ici = {_ ..}
 | |
| 8924 | 12 | *) | 
| 13 | ||
| 60758 | 14 | section \<open>Set intervals\<close> | 
| 14577 | 15 | |
| 47317 
432b29a96f61
modernized obsolete old-style theory name with proper new-style underscore
 huffman parents: 
47222diff
changeset | 16 | theory Set_Interval | 
| 63365 | 17 | imports Lattices_Big Divides Nat_Transfer | 
| 15131 | 18 | begin | 
| 8924 | 19 | |
| 24691 | 20 | context ord | 
| 21 | begin | |
| 44008 | 22 | |
| 24691 | 23 | definition | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32596diff
changeset | 24 |   lessThan    :: "'a => 'a set" ("(1{..<_})") where
 | 
| 25062 | 25 |   "{..<u} == {x. x < u}"
 | 
| 24691 | 26 | |
| 27 | definition | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32596diff
changeset | 28 |   atMost      :: "'a => 'a set" ("(1{.._})") where
 | 
| 25062 | 29 |   "{..u} == {x. x \<le> u}"
 | 
| 24691 | 30 | |
| 31 | definition | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32596diff
changeset | 32 |   greaterThan :: "'a => 'a set" ("(1{_<..})") where
 | 
| 25062 | 33 |   "{l<..} == {x. l<x}"
 | 
| 24691 | 34 | |
| 35 | definition | |
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32596diff
changeset | 36 |   atLeast     :: "'a => 'a set" ("(1{_..})") where
 | 
| 25062 | 37 |   "{l..} == {x. l\<le>x}"
 | 
| 24691 | 38 | |
| 39 | definition | |
| 25062 | 40 |   greaterThanLessThan :: "'a => 'a => 'a set"  ("(1{_<..<_})") where
 | 
| 41 |   "{l<..<u} == {l<..} Int {..<u}"
 | |
| 24691 | 42 | |
| 43 | definition | |
| 25062 | 44 |   atLeastLessThan :: "'a => 'a => 'a set"      ("(1{_..<_})") where
 | 
| 45 |   "{l..<u} == {l..} Int {..<u}"
 | |
| 24691 | 46 | |
| 47 | definition | |
| 25062 | 48 |   greaterThanAtMost :: "'a => 'a => 'a set"    ("(1{_<.._})") where
 | 
| 49 |   "{l<..u} == {l<..} Int {..u}"
 | |
| 24691 | 50 | |
| 51 | definition | |
| 25062 | 52 |   atLeastAtMost :: "'a => 'a => 'a set"        ("(1{_.._})") where
 | 
| 53 |   "{l..u} == {l..} Int {..u}"
 | |
| 24691 | 54 | |
| 55 | end | |
| 8924 | 56 | |
| 13735 | 57 | |
| 60758 | 58 | text\<open>A note of warning when using @{term"{..<n}"} on type @{typ
 | 
| 15048 | 59 | nat}: it is equivalent to @{term"{0::nat..<n}"} but some lemmas involving
 | 
| 60758 | 60 | @{term"{m..<n}"} may not exist in @{term"{..<n}"}-form as well.\<close>
 | 
| 15048 | 61 | |
| 61955 
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
 wenzelm parents: 
61799diff
changeset | 62 | syntax (ASCII) | 
| 36364 
0e2679025aeb
fix syntax precedence declarations for UNION, INTER, SUP, INF
 huffman parents: 
36307diff
changeset | 63 |   "_UNION_le"   :: "'a => 'a => 'b set => 'b set"       ("(3UN _<=_./ _)" [0, 0, 10] 10)
 | 
| 
0e2679025aeb
fix syntax precedence declarations for UNION, INTER, SUP, INF
 huffman parents: 
36307diff
changeset | 64 |   "_UNION_less" :: "'a => 'a => 'b set => 'b set"       ("(3UN _<_./ _)" [0, 0, 10] 10)
 | 
| 
0e2679025aeb
fix syntax precedence declarations for UNION, INTER, SUP, INF
 huffman parents: 
36307diff
changeset | 65 |   "_INTER_le"   :: "'a => 'a => 'b set => 'b set"       ("(3INT _<=_./ _)" [0, 0, 10] 10)
 | 
| 
0e2679025aeb
fix syntax precedence declarations for UNION, INTER, SUP, INF
 huffman parents: 
36307diff
changeset | 66 |   "_INTER_less" :: "'a => 'a => 'b set => 'b set"       ("(3INT _<_./ _)" [0, 0, 10] 10)
 | 
| 14418 | 67 | |
| 30372 | 68 | syntax (latex output) | 
| 62789 | 69 |   "_UNION_le"   :: "'a \<Rightarrow> 'a => 'b set => 'b set"       ("(3\<Union>(\<open>unbreakable\<close>_ \<le> _)/ _)" [0, 0, 10] 10)
 | 
| 70 |   "_UNION_less" :: "'a \<Rightarrow> 'a => 'b set => 'b set"       ("(3\<Union>(\<open>unbreakable\<close>_ < _)/ _)" [0, 0, 10] 10)
 | |
| 71 |   "_INTER_le"   :: "'a \<Rightarrow> 'a => 'b set => 'b set"       ("(3\<Inter>(\<open>unbreakable\<close>_ \<le> _)/ _)" [0, 0, 10] 10)
 | |
| 72 |   "_INTER_less" :: "'a \<Rightarrow> 'a => 'b set => 'b set"       ("(3\<Inter>(\<open>unbreakable\<close>_ < _)/ _)" [0, 0, 10] 10)
 | |
| 14418 | 73 | |
| 61955 
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
 wenzelm parents: 
61799diff
changeset | 74 | syntax | 
| 
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
 wenzelm parents: 
61799diff
changeset | 75 |   "_UNION_le"   :: "'a => 'a => 'b set => 'b set"       ("(3\<Union>_\<le>_./ _)" [0, 0, 10] 10)
 | 
| 
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
 wenzelm parents: 
61799diff
changeset | 76 |   "_UNION_less" :: "'a => 'a => 'b set => 'b set"       ("(3\<Union>_<_./ _)" [0, 0, 10] 10)
 | 
| 
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
 wenzelm parents: 
61799diff
changeset | 77 |   "_INTER_le"   :: "'a => 'a => 'b set => 'b set"       ("(3\<Inter>_\<le>_./ _)" [0, 0, 10] 10)
 | 
| 
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
 wenzelm parents: 
61799diff
changeset | 78 |   "_INTER_less" :: "'a => 'a => 'b set => 'b set"       ("(3\<Inter>_<_./ _)" [0, 0, 10] 10)
 | 
| 
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
 wenzelm parents: 
61799diff
changeset | 79 | |
| 14418 | 80 | translations | 
| 61955 
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
 wenzelm parents: 
61799diff
changeset | 81 |   "\<Union>i\<le>n. A" \<rightleftharpoons> "\<Union>i\<in>{..n}. A"
 | 
| 
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
 wenzelm parents: 
61799diff
changeset | 82 |   "\<Union>i<n. A" \<rightleftharpoons> "\<Union>i\<in>{..<n}. A"
 | 
| 
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
 wenzelm parents: 
61799diff
changeset | 83 |   "\<Inter>i\<le>n. A" \<rightleftharpoons> "\<Inter>i\<in>{..n}. A"
 | 
| 
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
 wenzelm parents: 
61799diff
changeset | 84 |   "\<Inter>i<n. A" \<rightleftharpoons> "\<Inter>i\<in>{..<n}. A"
 | 
| 14418 | 85 | |
| 86 | ||
| 60758 | 87 | subsection \<open>Various equivalences\<close> | 
| 13735 | 88 | |
| 25062 | 89 | lemma (in ord) lessThan_iff [iff]: "(i: lessThan k) = (i<k)" | 
| 13850 | 90 | by (simp add: lessThan_def) | 
| 13735 | 91 | |
| 15418 
e28853da5df5
removed two looping simplifications in SetInterval.thy; deleted the .ML file
 paulson parents: 
15402diff
changeset | 92 | lemma Compl_lessThan [simp]: | 
| 13735 | 93 | "!!k:: 'a::linorder. -lessThan k = atLeast k" | 
| 13850 | 94 | apply (auto simp add: lessThan_def atLeast_def) | 
| 13735 | 95 | done | 
| 96 | ||
| 13850 | 97 | lemma single_Diff_lessThan [simp]: "!!k:: 'a::order. {k} - lessThan k = {k}"
 | 
| 98 | by auto | |
| 13735 | 99 | |
| 25062 | 100 | lemma (in ord) greaterThan_iff [iff]: "(i: greaterThan k) = (k<i)" | 
| 13850 | 101 | by (simp add: greaterThan_def) | 
| 13735 | 102 | |
| 15418 
e28853da5df5
removed two looping simplifications in SetInterval.thy; deleted the .ML file
 paulson parents: 
15402diff
changeset | 103 | lemma Compl_greaterThan [simp]: | 
| 13735 | 104 | "!!k:: 'a::linorder. -greaterThan k = atMost k" | 
| 26072 
f65a7fa2da6c
<= and < on nat no longer depend on wellfounded relations
 haftmann parents: 
25919diff
changeset | 105 | by (auto simp add: greaterThan_def atMost_def) | 
| 13735 | 106 | |
| 13850 | 107 | lemma Compl_atMost [simp]: "!!k:: 'a::linorder. -atMost k = greaterThan k" | 
| 108 | apply (subst Compl_greaterThan [symmetric]) | |
| 15418 
e28853da5df5
removed two looping simplifications in SetInterval.thy; deleted the .ML file
 paulson parents: 
15402diff
changeset | 109 | apply (rule double_complement) | 
| 13735 | 110 | done | 
| 111 | ||
| 25062 | 112 | lemma (in ord) atLeast_iff [iff]: "(i: atLeast k) = (k<=i)" | 
| 13850 | 113 | by (simp add: atLeast_def) | 
| 13735 | 114 | |
| 15418 
e28853da5df5
removed two looping simplifications in SetInterval.thy; deleted the .ML file
 paulson parents: 
15402diff
changeset | 115 | lemma Compl_atLeast [simp]: | 
| 13735 | 116 | "!!k:: 'a::linorder. -atLeast k = lessThan k" | 
| 26072 
f65a7fa2da6c
<= and < on nat no longer depend on wellfounded relations
 haftmann parents: 
25919diff
changeset | 117 | by (auto simp add: lessThan_def atLeast_def) | 
| 13735 | 118 | |
| 25062 | 119 | lemma (in ord) atMost_iff [iff]: "(i: atMost k) = (i<=k)" | 
| 13850 | 120 | by (simp add: atMost_def) | 
| 13735 | 121 | |
| 14485 | 122 | lemma atMost_Int_atLeast: "!!n:: 'a::order. atMost n Int atLeast n = {n}"
 | 
| 123 | by (blast intro: order_antisym) | |
| 13850 | 124 | |
| 50999 | 125 | lemma (in linorder) lessThan_Int_lessThan: "{ a <..} \<inter> { b <..} = { max a b <..}"
 | 
| 126 | by auto | |
| 127 | ||
| 128 | lemma (in linorder) greaterThan_Int_greaterThan: "{..< a} \<inter> {..< b} = {..< min a b}"
 | |
| 129 | by auto | |
| 13850 | 130 | |
| 60758 | 131 | subsection \<open>Logical Equivalences for Set Inclusion and Equality\<close> | 
| 13850 | 132 | |
| 63879 
15bbf6360339
simple new lemmas, mostly about sets
 paulson <lp15@cam.ac.uk> parents: 
63721diff
changeset | 133 | lemma atLeast_empty_triv [simp]: "{{}..} = UNIV"
 | 
| 
15bbf6360339
simple new lemmas, mostly about sets
 paulson <lp15@cam.ac.uk> parents: 
63721diff
changeset | 134 | by auto | 
| 
15bbf6360339
simple new lemmas, mostly about sets
 paulson <lp15@cam.ac.uk> parents: 
63721diff
changeset | 135 | |
| 
15bbf6360339
simple new lemmas, mostly about sets
 paulson <lp15@cam.ac.uk> parents: 
63721diff
changeset | 136 | lemma atMost_UNIV_triv [simp]: "{..UNIV} = UNIV"
 | 
| 
15bbf6360339
simple new lemmas, mostly about sets
 paulson <lp15@cam.ac.uk> parents: 
63721diff
changeset | 137 | by auto | 
| 
15bbf6360339
simple new lemmas, mostly about sets
 paulson <lp15@cam.ac.uk> parents: 
63721diff
changeset | 138 | |
| 13850 | 139 | lemma atLeast_subset_iff [iff]: | 
| 15418 
e28853da5df5
removed two looping simplifications in SetInterval.thy; deleted the .ML file
 paulson parents: 
15402diff
changeset | 140 | "(atLeast x \<subseteq> atLeast y) = (y \<le> (x::'a::order))" | 
| 
e28853da5df5
removed two looping simplifications in SetInterval.thy; deleted the .ML file
 paulson parents: 
15402diff
changeset | 141 | by (blast intro: order_trans) | 
| 13850 | 142 | |
| 143 | lemma atLeast_eq_iff [iff]: | |
| 15418 
e28853da5df5
removed two looping simplifications in SetInterval.thy; deleted the .ML file
 paulson parents: 
15402diff
changeset | 144 | "(atLeast x = atLeast y) = (x = (y::'a::linorder))" | 
| 13850 | 145 | by (blast intro: order_antisym order_trans) | 
| 146 | ||
| 147 | lemma greaterThan_subset_iff [iff]: | |
| 15418 
e28853da5df5
removed two looping simplifications in SetInterval.thy; deleted the .ML file
 paulson parents: 
15402diff
changeset | 148 | "(greaterThan x \<subseteq> greaterThan y) = (y \<le> (x::'a::linorder))" | 
| 
e28853da5df5
removed two looping simplifications in SetInterval.thy; deleted the .ML file
 paulson parents: 
15402diff
changeset | 149 | apply (auto simp add: greaterThan_def) | 
| 
e28853da5df5
removed two looping simplifications in SetInterval.thy; deleted the .ML file
 paulson parents: 
15402diff
changeset | 150 | apply (subst linorder_not_less [symmetric], blast) | 
| 13850 | 151 | done | 
| 152 | ||
| 153 | lemma greaterThan_eq_iff [iff]: | |
| 15418 
e28853da5df5
removed two looping simplifications in SetInterval.thy; deleted the .ML file
 paulson parents: 
15402diff
changeset | 154 | "(greaterThan x = greaterThan y) = (x = (y::'a::linorder))" | 
| 
e28853da5df5
removed two looping simplifications in SetInterval.thy; deleted the .ML file
 paulson parents: 
15402diff
changeset | 155 | apply (rule iffI) | 
| 
e28853da5df5
removed two looping simplifications in SetInterval.thy; deleted the .ML file
 paulson parents: 
15402diff
changeset | 156 | apply (erule equalityE) | 
| 29709 | 157 | apply simp_all | 
| 13850 | 158 | done | 
| 159 | ||
| 15418 
e28853da5df5
removed two looping simplifications in SetInterval.thy; deleted the .ML file
 paulson parents: 
15402diff
changeset | 160 | lemma atMost_subset_iff [iff]: "(atMost x \<subseteq> atMost y) = (x \<le> (y::'a::order))" | 
| 13850 | 161 | by (blast intro: order_trans) | 
| 162 | ||
| 15418 
e28853da5df5
removed two looping simplifications in SetInterval.thy; deleted the .ML file
 paulson parents: 
15402diff
changeset | 163 | lemma atMost_eq_iff [iff]: "(atMost x = atMost y) = (x = (y::'a::linorder))" | 
| 13850 | 164 | by (blast intro: order_antisym order_trans) | 
| 165 | ||
| 166 | lemma lessThan_subset_iff [iff]: | |
| 15418 
e28853da5df5
removed two looping simplifications in SetInterval.thy; deleted the .ML file
 paulson parents: 
15402diff
changeset | 167 | "(lessThan x \<subseteq> lessThan y) = (x \<le> (y::'a::linorder))" | 
| 
e28853da5df5
removed two looping simplifications in SetInterval.thy; deleted the .ML file
 paulson parents: 
15402diff
changeset | 168 | apply (auto simp add: lessThan_def) | 
| 
e28853da5df5
removed two looping simplifications in SetInterval.thy; deleted the .ML file
 paulson parents: 
15402diff
changeset | 169 | apply (subst linorder_not_less [symmetric], blast) | 
| 13850 | 170 | done | 
| 171 | ||
| 172 | lemma lessThan_eq_iff [iff]: | |
| 15418 
e28853da5df5
removed two looping simplifications in SetInterval.thy; deleted the .ML file
 paulson parents: 
15402diff
changeset | 173 | "(lessThan x = lessThan y) = (x = (y::'a::linorder))" | 
| 
e28853da5df5
removed two looping simplifications in SetInterval.thy; deleted the .ML file
 paulson parents: 
15402diff
changeset | 174 | apply (rule iffI) | 
| 
e28853da5df5
removed two looping simplifications in SetInterval.thy; deleted the .ML file
 paulson parents: 
15402diff
changeset | 175 | apply (erule equalityE) | 
| 29709 | 176 | apply simp_all | 
| 13735 | 177 | done | 
| 178 | ||
| 40703 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
39302diff
changeset | 179 | lemma lessThan_strict_subset_iff: | 
| 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
39302diff
changeset | 180 | fixes m n :: "'a::linorder" | 
| 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
39302diff
changeset | 181 |   shows "{..<m} < {..<n} \<longleftrightarrow> m < n"
 | 
| 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
39302diff
changeset | 182 | by (metis leD lessThan_subset_iff linorder_linear not_less_iff_gr_or_eq psubset_eq) | 
| 13735 | 183 | |
| 57448 
159e45728ceb
more equalities of topological filters; strengthen dependent_nat_choice; tuned a couple of proofs
 hoelzl parents: 
57447diff
changeset | 184 | lemma (in linorder) Ici_subset_Ioi_iff: "{a ..} \<subseteq> {b <..} \<longleftrightarrow> b < a"
 | 
| 
159e45728ceb
more equalities of topological filters; strengthen dependent_nat_choice; tuned a couple of proofs
 hoelzl parents: 
57447diff
changeset | 185 | by auto | 
| 
159e45728ceb
more equalities of topological filters; strengthen dependent_nat_choice; tuned a couple of proofs
 hoelzl parents: 
57447diff
changeset | 186 | |
| 
159e45728ceb
more equalities of topological filters; strengthen dependent_nat_choice; tuned a couple of proofs
 hoelzl parents: 
57447diff
changeset | 187 | lemma (in linorder) Iic_subset_Iio_iff: "{.. a} \<subseteq> {..< b} \<longleftrightarrow> a < b"
 | 
| 
159e45728ceb
more equalities of topological filters; strengthen dependent_nat_choice; tuned a couple of proofs
 hoelzl parents: 
57447diff
changeset | 188 | by auto | 
| 
159e45728ceb
more equalities of topological filters; strengthen dependent_nat_choice; tuned a couple of proofs
 hoelzl parents: 
57447diff
changeset | 189 | |
| 62369 | 190 | lemma (in preorder) Ioi_le_Ico: "{a <..} \<subseteq> {a ..}"
 | 
| 191 | by (auto intro: less_imp_le) | |
| 192 | ||
| 60758 | 193 | subsection \<open>Two-sided intervals\<close> | 
| 13735 | 194 | |
| 24691 | 195 | context ord | 
| 196 | begin | |
| 197 | ||
| 54147 
97a8ff4e4ac9
killed most "no_atp", to make Sledgehammer more complete
 blanchet parents: 
53374diff
changeset | 198 | lemma greaterThanLessThan_iff [simp]: | 
| 25062 | 199 |   "(i : {l<..<u}) = (l < i & i < u)"
 | 
| 13735 | 200 | by (simp add: greaterThanLessThan_def) | 
| 201 | ||
| 54147 
97a8ff4e4ac9
killed most "no_atp", to make Sledgehammer more complete
 blanchet parents: 
53374diff
changeset | 202 | lemma atLeastLessThan_iff [simp]: | 
| 25062 | 203 |   "(i : {l..<u}) = (l <= i & i < u)"
 | 
| 13735 | 204 | by (simp add: atLeastLessThan_def) | 
| 205 | ||
| 54147 
97a8ff4e4ac9
killed most "no_atp", to make Sledgehammer more complete
 blanchet parents: 
53374diff
changeset | 206 | lemma greaterThanAtMost_iff [simp]: | 
| 25062 | 207 |   "(i : {l<..u}) = (l < i & i <= u)"
 | 
| 13735 | 208 | by (simp add: greaterThanAtMost_def) | 
| 209 | ||
| 54147 
97a8ff4e4ac9
killed most "no_atp", to make Sledgehammer more complete
 blanchet parents: 
53374diff
changeset | 210 | lemma atLeastAtMost_iff [simp]: | 
| 25062 | 211 |   "(i : {l..u}) = (l <= i & i <= u)"
 | 
| 13735 | 212 | by (simp add: atLeastAtMost_def) | 
| 213 | ||
| 60758 | 214 | text \<open>The above four lemmas could be declared as iffs. Unfortunately this | 
| 52729 
412c9e0381a1
factored syntactic type classes for bot and top (by Alessandro Coglio)
 haftmann parents: 
52380diff
changeset | 215 | breaks many proofs. Since it only helps blast, it is better to leave them | 
| 60758 | 216 | alone.\<close> | 
| 32436 
10cd49e0c067
Turned "x <= y ==> sup x y = y" (and relatives) into simp rules
 nipkow parents: 
32408diff
changeset | 217 | |
| 50999 | 218 | lemma greaterThanLessThan_eq: "{ a <..< b} = { a <..} \<inter> {..< b }"
 | 
| 219 | by auto | |
| 220 | ||
| 24691 | 221 | end | 
| 13735 | 222 | |
| 60758 | 223 | subsubsection\<open>Emptyness, singletons, subset\<close> | 
| 15554 | 224 | |
| 24691 | 225 | context order | 
| 226 | begin | |
| 15554 | 227 | |
| 32400 | 228 | lemma atLeastatMost_empty[simp]: | 
| 229 |   "b < a \<Longrightarrow> {a..b} = {}"
 | |
| 230 | by(auto simp: atLeastAtMost_def atLeast_def atMost_def) | |
| 231 | ||
| 232 | lemma atLeastatMost_empty_iff[simp]: | |
| 233 |   "{a..b} = {} \<longleftrightarrow> (~ a <= b)"
 | |
| 234 | by auto (blast intro: order_trans) | |
| 235 | ||
| 236 | lemma atLeastatMost_empty_iff2[simp]: | |
| 237 |   "{} = {a..b} \<longleftrightarrow> (~ a <= b)"
 | |
| 238 | by auto (blast intro: order_trans) | |
| 239 | ||
| 240 | lemma atLeastLessThan_empty[simp]: | |
| 241 |   "b <= a \<Longrightarrow> {a..<b} = {}"
 | |
| 242 | by(auto simp: atLeastLessThan_def) | |
| 24691 | 243 | |
| 32400 | 244 | lemma atLeastLessThan_empty_iff[simp]: | 
| 245 |   "{a..<b} = {} \<longleftrightarrow> (~ a < b)"
 | |
| 246 | by auto (blast intro: le_less_trans) | |
| 247 | ||
| 248 | lemma atLeastLessThan_empty_iff2[simp]: | |
| 249 |   "{} = {a..<b} \<longleftrightarrow> (~ a < b)"
 | |
| 250 | by auto (blast intro: le_less_trans) | |
| 15554 | 251 | |
| 32400 | 252 | lemma greaterThanAtMost_empty[simp]: "l \<le> k ==> {k<..l} = {}"
 | 
| 17719 | 253 | by(auto simp:greaterThanAtMost_def greaterThan_def atMost_def) | 
| 254 | ||
| 32400 | 255 | lemma greaterThanAtMost_empty_iff[simp]: "{k<..l} = {} \<longleftrightarrow> ~ k < l"
 | 
| 256 | by auto (blast intro: less_le_trans) | |
| 257 | ||
| 258 | lemma greaterThanAtMost_empty_iff2[simp]: "{} = {k<..l} \<longleftrightarrow> ~ k < l"
 | |
| 259 | by auto (blast intro: less_le_trans) | |
| 260 | ||
| 29709 | 261 | lemma greaterThanLessThan_empty[simp]:"l \<le> k ==> {k<..<l} = {}"
 | 
| 17719 | 262 | by(auto simp:greaterThanLessThan_def greaterThan_def lessThan_def) | 
| 263 | ||
| 25062 | 264 | lemma atLeastAtMost_singleton [simp]: "{a..a} = {a}"
 | 
| 24691 | 265 | by (auto simp add: atLeastAtMost_def atMost_def atLeast_def) | 
| 266 | ||
| 36846 
0f67561ed5a6
Added atLeastAtMost_singleton_iff, atLeastAtMost_singleton'
 hoelzl parents: 
36755diff
changeset | 267 | lemma atLeastAtMost_singleton': "a = b \<Longrightarrow> {a .. b} = {a}" by simp
 | 
| 
0f67561ed5a6
Added atLeastAtMost_singleton_iff, atLeastAtMost_singleton'
 hoelzl parents: 
36755diff
changeset | 268 | |
| 32400 | 269 | lemma atLeastatMost_subset_iff[simp]: | 
| 270 |   "{a..b} <= {c..d} \<longleftrightarrow> (~ a <= b) | c <= a & b <= d"
 | |
| 271 | unfolding atLeastAtMost_def atLeast_def atMost_def | |
| 272 | by (blast intro: order_trans) | |
| 273 | ||
| 274 | lemma atLeastatMost_psubset_iff: | |
| 275 |   "{a..b} < {c..d} \<longleftrightarrow>
 | |
| 276 | ((~ a <= b) | c <= a & b <= d & (c < a | b < d)) & c <= d" | |
| 39302 
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
 nipkow parents: 
39198diff
changeset | 277 | by(simp add: psubset_eq set_eq_iff less_le_not_le)(blast intro: order_trans) | 
| 32400 | 278 | |
| 51334 | 279 | lemma Icc_eq_Icc[simp]: | 
| 280 |   "{l..h} = {l'..h'} = (l=l' \<and> h=h' \<or> \<not> l\<le>h \<and> \<not> l'\<le>h')"
 | |
| 281 | by(simp add: order_class.eq_iff)(auto intro: order_trans) | |
| 282 | ||
| 36846 
0f67561ed5a6
Added atLeastAtMost_singleton_iff, atLeastAtMost_singleton'
 hoelzl parents: 
36755diff
changeset | 283 | lemma atLeastAtMost_singleton_iff[simp]: | 
| 
0f67561ed5a6
Added atLeastAtMost_singleton_iff, atLeastAtMost_singleton'
 hoelzl parents: 
36755diff
changeset | 284 |   "{a .. b} = {c} \<longleftrightarrow> a = b \<and> b = c"
 | 
| 
0f67561ed5a6
Added atLeastAtMost_singleton_iff, atLeastAtMost_singleton'
 hoelzl parents: 
36755diff
changeset | 285 | proof | 
| 
0f67561ed5a6
Added atLeastAtMost_singleton_iff, atLeastAtMost_singleton'
 hoelzl parents: 
36755diff
changeset | 286 |   assume "{a..b} = {c}"
 | 
| 53374 
a14d2a854c02
tuned proofs -- clarified flow of facts wrt. calculation;
 wenzelm parents: 
53216diff
changeset | 287 | hence *: "\<not> (\<not> a \<le> b)" unfolding atLeastatMost_empty_iff[symmetric] by simp | 
| 60758 | 288 |   with \<open>{a..b} = {c}\<close> have "c \<le> a \<and> b \<le> c" by auto
 | 
| 53374 
a14d2a854c02
tuned proofs -- clarified flow of facts wrt. calculation;
 wenzelm parents: 
53216diff
changeset | 289 | with * show "a = b \<and> b = c" by auto | 
| 36846 
0f67561ed5a6
Added atLeastAtMost_singleton_iff, atLeastAtMost_singleton'
 hoelzl parents: 
36755diff
changeset | 290 | qed simp | 
| 
0f67561ed5a6
Added atLeastAtMost_singleton_iff, atLeastAtMost_singleton'
 hoelzl parents: 
36755diff
changeset | 291 | |
| 51334 | 292 | lemma Icc_subset_Ici_iff[simp]: | 
| 293 |   "{l..h} \<subseteq> {l'..} = (~ l\<le>h \<or> l\<ge>l')"
 | |
| 294 | by(auto simp: subset_eq intro: order_trans) | |
| 295 | ||
| 296 | lemma Icc_subset_Iic_iff[simp]: | |
| 297 |   "{l..h} \<subseteq> {..h'} = (~ l\<le>h \<or> h\<le>h')"
 | |
| 298 | by(auto simp: subset_eq intro: order_trans) | |
| 299 | ||
| 300 | lemma not_Ici_eq_empty[simp]: "{l..} \<noteq> {}"
 | |
| 301 | by(auto simp: set_eq_iff) | |
| 302 | ||
| 303 | lemma not_Iic_eq_empty[simp]: "{..h} \<noteq> {}"
 | |
| 304 | by(auto simp: set_eq_iff) | |
| 305 | ||
| 306 | lemmas not_empty_eq_Ici_eq_empty[simp] = not_Ici_eq_empty[symmetric] | |
| 307 | lemmas not_empty_eq_Iic_eq_empty[simp] = not_Iic_eq_empty[symmetric] | |
| 308 | ||
| 24691 | 309 | end | 
| 14485 | 310 | |
| 51334 | 311 | context no_top | 
| 312 | begin | |
| 313 | ||
| 314 | (* also holds for no_bot but no_top should suffice *) | |
| 315 | lemma not_UNIV_le_Icc[simp]: "\<not> UNIV \<subseteq> {l..h}"
 | |
| 316 | using gt_ex[of h] by(auto simp: subset_eq less_le_not_le) | |
| 317 | ||
| 318 | lemma not_UNIV_le_Iic[simp]: "\<not> UNIV \<subseteq> {..h}"
 | |
| 319 | using gt_ex[of h] by(auto simp: subset_eq less_le_not_le) | |
| 320 | ||
| 321 | lemma not_Ici_le_Icc[simp]: "\<not> {l..} \<subseteq> {l'..h'}"
 | |
| 322 | using gt_ex[of h'] | |
| 323 | by(auto simp: subset_eq less_le)(blast dest:antisym_conv intro: order_trans) | |
| 324 | ||
| 325 | lemma not_Ici_le_Iic[simp]: "\<not> {l..} \<subseteq> {..h'}"
 | |
| 326 | using gt_ex[of h'] | |
| 327 | by(auto simp: subset_eq less_le)(blast dest:antisym_conv intro: order_trans) | |
| 328 | ||
| 329 | end | |
| 330 | ||
| 331 | context no_bot | |
| 332 | begin | |
| 333 | ||
| 334 | lemma not_UNIV_le_Ici[simp]: "\<not> UNIV \<subseteq> {l..}"
 | |
| 335 | using lt_ex[of l] by(auto simp: subset_eq less_le_not_le) | |
| 336 | ||
| 337 | lemma not_Iic_le_Icc[simp]: "\<not> {..h} \<subseteq> {l'..h'}"
 | |
| 338 | using lt_ex[of l'] | |
| 339 | by(auto simp: subset_eq less_le)(blast dest:antisym_conv intro: order_trans) | |
| 340 | ||
| 341 | lemma not_Iic_le_Ici[simp]: "\<not> {..h} \<subseteq> {l'..}"
 | |
| 342 | using lt_ex[of l'] | |
| 343 | by(auto simp: subset_eq less_le)(blast dest:antisym_conv intro: order_trans) | |
| 344 | ||
| 345 | end | |
| 346 | ||
| 347 | ||
| 348 | context no_top | |
| 349 | begin | |
| 350 | ||
| 351 | (* also holds for no_bot but no_top should suffice *) | |
| 352 | lemma not_UNIV_eq_Icc[simp]: "\<not> UNIV = {l'..h'}"
 | |
| 353 | using gt_ex[of h'] by(auto simp: set_eq_iff less_le_not_le) | |
| 354 | ||
| 355 | lemmas not_Icc_eq_UNIV[simp] = not_UNIV_eq_Icc[symmetric] | |
| 356 | ||
| 357 | lemma not_UNIV_eq_Iic[simp]: "\<not> UNIV = {..h'}"
 | |
| 358 | using gt_ex[of h'] by(auto simp: set_eq_iff less_le_not_le) | |
| 359 | ||
| 360 | lemmas not_Iic_eq_UNIV[simp] = not_UNIV_eq_Iic[symmetric] | |
| 361 | ||
| 362 | lemma not_Icc_eq_Ici[simp]: "\<not> {l..h} = {l'..}"
 | |
| 363 | unfolding atLeastAtMost_def using not_Ici_le_Iic[of l'] by blast | |
| 364 | ||
| 365 | lemmas not_Ici_eq_Icc[simp] = not_Icc_eq_Ici[symmetric] | |
| 366 | ||
| 367 | (* also holds for no_bot but no_top should suffice *) | |
| 368 | lemma not_Iic_eq_Ici[simp]: "\<not> {..h} = {l'..}"
 | |
| 369 | using not_Ici_le_Iic[of l' h] by blast | |
| 370 | ||
| 371 | lemmas not_Ici_eq_Iic[simp] = not_Iic_eq_Ici[symmetric] | |
| 372 | ||
| 373 | end | |
| 374 | ||
| 375 | context no_bot | |
| 376 | begin | |
| 377 | ||
| 378 | lemma not_UNIV_eq_Ici[simp]: "\<not> UNIV = {l'..}"
 | |
| 379 | using lt_ex[of l'] by(auto simp: set_eq_iff less_le_not_le) | |
| 380 | ||
| 381 | lemmas not_Ici_eq_UNIV[simp] = not_UNIV_eq_Ici[symmetric] | |
| 382 | ||
| 383 | lemma not_Icc_eq_Iic[simp]: "\<not> {l..h} = {..h'}"
 | |
| 384 | unfolding atLeastAtMost_def using not_Iic_le_Ici[of h'] by blast | |
| 385 | ||
| 386 | lemmas not_Iic_eq_Icc[simp] = not_Icc_eq_Iic[symmetric] | |
| 387 | ||
| 388 | end | |
| 389 | ||
| 390 | ||
| 53216 | 391 | context dense_linorder | 
| 42891 
e2f473671937
simp rules for empty intervals on dense linear order
 hoelzl parents: 
40703diff
changeset | 392 | begin | 
| 
e2f473671937
simp rules for empty intervals on dense linear order
 hoelzl parents: 
40703diff
changeset | 393 | |
| 
e2f473671937
simp rules for empty intervals on dense linear order
 hoelzl parents: 
40703diff
changeset | 394 | lemma greaterThanLessThan_empty_iff[simp]: | 
| 
e2f473671937
simp rules for empty intervals on dense linear order
 hoelzl parents: 
40703diff
changeset | 395 |   "{ a <..< b } = {} \<longleftrightarrow> b \<le> a"
 | 
| 
e2f473671937
simp rules for empty intervals on dense linear order
 hoelzl parents: 
40703diff
changeset | 396 | using dense[of a b] by (cases "a < b") auto | 
| 
e2f473671937
simp rules for empty intervals on dense linear order
 hoelzl parents: 
40703diff
changeset | 397 | |
| 
e2f473671937
simp rules for empty intervals on dense linear order
 hoelzl parents: 
40703diff
changeset | 398 | lemma greaterThanLessThan_empty_iff2[simp]: | 
| 
e2f473671937
simp rules for empty intervals on dense linear order
 hoelzl parents: 
40703diff
changeset | 399 |   "{} = { a <..< b } \<longleftrightarrow> b \<le> a"
 | 
| 
e2f473671937
simp rules for empty intervals on dense linear order
 hoelzl parents: 
40703diff
changeset | 400 | using dense[of a b] by (cases "a < b") auto | 
| 
e2f473671937
simp rules for empty intervals on dense linear order
 hoelzl parents: 
40703diff
changeset | 401 | |
| 42901 | 402 | lemma atLeastLessThan_subseteq_atLeastAtMost_iff: | 
| 403 |   "{a ..< b} \<subseteq> { c .. d } \<longleftrightarrow> (a < b \<longrightarrow> c \<le> a \<and> b \<le> d)"
 | |
| 404 | using dense[of "max a d" "b"] | |
| 405 | by (force simp: subset_eq Ball_def not_less[symmetric]) | |
| 406 | ||
| 407 | lemma greaterThanAtMost_subseteq_atLeastAtMost_iff: | |
| 408 |   "{a <.. b} \<subseteq> { c .. d } \<longleftrightarrow> (a < b \<longrightarrow> c \<le> a \<and> b \<le> d)"
 | |
| 409 | using dense[of "a" "min c b"] | |
| 410 | by (force simp: subset_eq Ball_def not_less[symmetric]) | |
| 411 | ||
| 412 | lemma greaterThanLessThan_subseteq_atLeastAtMost_iff: | |
| 413 |   "{a <..< b} \<subseteq> { c .. d } \<longleftrightarrow> (a < b \<longrightarrow> c \<le> a \<and> b \<le> d)"
 | |
| 414 | using dense[of "a" "min c b"] dense[of "max a d" "b"] | |
| 415 | by (force simp: subset_eq Ball_def not_less[symmetric]) | |
| 416 | ||
| 43657 | 417 | lemma atLeastAtMost_subseteq_atLeastLessThan_iff: | 
| 418 |   "{a .. b} \<subseteq> { c ..< d } \<longleftrightarrow> (a \<le> b \<longrightarrow> c \<le> a \<and> b < d)"
 | |
| 419 | using dense[of "max a d" "b"] | |
| 420 | by (force simp: subset_eq Ball_def not_less[symmetric]) | |
| 62369 | 421 | |
| 61524 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61378diff
changeset | 422 | lemma greaterThanLessThan_subseteq_greaterThanLessThan: | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61378diff
changeset | 423 |   "{a <..< b} \<subseteq> {c <..< d} \<longleftrightarrow> (a < b \<longrightarrow> a \<ge> c \<and> b \<le> d)"
 | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61378diff
changeset | 424 | using dense[of "a" "min c b"] dense[of "max a d" "b"] | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61378diff
changeset | 425 | by (force simp: subset_eq Ball_def not_less[symmetric]) | 
| 43657 | 426 | |
| 427 | lemma greaterThanAtMost_subseteq_atLeastLessThan_iff: | |
| 428 |   "{a <.. b} \<subseteq> { c ..< d } \<longleftrightarrow> (a < b \<longrightarrow> c \<le> a \<and> b < d)"
 | |
| 429 | using dense[of "a" "min c b"] | |
| 430 | by (force simp: subset_eq Ball_def not_less[symmetric]) | |
| 431 | ||
| 432 | lemma greaterThanLessThan_subseteq_atLeastLessThan_iff: | |
| 433 |   "{a <..< b} \<subseteq> { c ..< d } \<longleftrightarrow> (a < b \<longrightarrow> c \<le> a \<and> b \<le> d)"
 | |
| 434 | using dense[of "a" "min c b"] dense[of "max a d" "b"] | |
| 435 | by (force simp: subset_eq Ball_def not_less[symmetric]) | |
| 436 | ||
| 56328 | 437 | lemma greaterThanLessThan_subseteq_greaterThanAtMost_iff: | 
| 438 |   "{a <..< b} \<subseteq> { c <.. d } \<longleftrightarrow> (a < b \<longrightarrow> c \<le> a \<and> b \<le> d)"
 | |
| 439 | using dense[of "a" "min c b"] dense[of "max a d" "b"] | |
| 440 | by (force simp: subset_eq Ball_def not_less[symmetric]) | |
| 441 | ||
| 42891 
e2f473671937
simp rules for empty intervals on dense linear order
 hoelzl parents: 
40703diff
changeset | 442 | end | 
| 
e2f473671937
simp rules for empty intervals on dense linear order
 hoelzl parents: 
40703diff
changeset | 443 | |
| 51329 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 444 | context no_top | 
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 445 | begin | 
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 446 | |
| 51334 | 447 | lemma greaterThan_non_empty[simp]: "{x <..} \<noteq> {}"
 | 
| 51329 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 448 | using gt_ex[of x] by auto | 
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 449 | |
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 450 | end | 
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 451 | |
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 452 | context no_bot | 
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 453 | begin | 
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 454 | |
| 51334 | 455 | lemma lessThan_non_empty[simp]: "{..< x} \<noteq> {}"
 | 
| 51329 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 456 | using lt_ex[of x] by auto | 
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 457 | |
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 458 | end | 
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 459 | |
| 32408 | 460 | lemma (in linorder) atLeastLessThan_subset_iff: | 
| 461 |   "{a..<b} <= {c..<d} \<Longrightarrow> b <= a | c<=a & b<=d"
 | |
| 462 | apply (auto simp:subset_eq Ball_def) | |
| 463 | apply(frule_tac x=a in spec) | |
| 464 | apply(erule_tac x=d in allE) | |
| 465 | apply (simp add: less_imp_le) | |
| 466 | done | |
| 467 | ||
| 40703 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
39302diff
changeset | 468 | lemma atLeastLessThan_inj: | 
| 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
39302diff
changeset | 469 | fixes a b c d :: "'a::linorder" | 
| 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
39302diff
changeset | 470 |   assumes eq: "{a ..< b} = {c ..< d}" and "a < b" "c < d"
 | 
| 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
39302diff
changeset | 471 | shows "a = c" "b = d" | 
| 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
39302diff
changeset | 472 | using assms by (metis atLeastLessThan_subset_iff eq less_le_not_le linorder_antisym_conv2 subset_refl)+ | 
| 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
39302diff
changeset | 473 | |
| 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
39302diff
changeset | 474 | lemma atLeastLessThan_eq_iff: | 
| 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
39302diff
changeset | 475 | fixes a b c d :: "'a::linorder" | 
| 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
39302diff
changeset | 476 | assumes "a < b" "c < d" | 
| 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
39302diff
changeset | 477 |   shows "{a ..< b} = {c ..< d} \<longleftrightarrow> a = c \<and> b = d"
 | 
| 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
39302diff
changeset | 478 | using atLeastLessThan_inj assms by auto | 
| 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
39302diff
changeset | 479 | |
| 57447 
87429bdecad5
import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
 hoelzl parents: 
57418diff
changeset | 480 | lemma (in linorder) Ioc_inj: "{a <.. b} = {c <.. d} \<longleftrightarrow> (b \<le> a \<and> d \<le> c) \<or> a = c \<and> b = d"
 | 
| 
87429bdecad5
import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
 hoelzl parents: 
57418diff
changeset | 481 | by (metis eq_iff greaterThanAtMost_empty_iff2 greaterThanAtMost_iff le_cases not_le) | 
| 
87429bdecad5
import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
 hoelzl parents: 
57418diff
changeset | 482 | |
| 
87429bdecad5
import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
 hoelzl parents: 
57418diff
changeset | 483 | lemma (in order) Iio_Int_singleton: "{..<k} \<inter> {x} = (if x < k then {x} else {})"
 | 
| 
87429bdecad5
import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
 hoelzl parents: 
57418diff
changeset | 484 | by auto | 
| 
87429bdecad5
import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
 hoelzl parents: 
57418diff
changeset | 485 | |
| 
87429bdecad5
import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
 hoelzl parents: 
57418diff
changeset | 486 | lemma (in linorder) Ioc_subset_iff: "{a<..b} \<subseteq> {c<..d} \<longleftrightarrow> (b \<le> a \<or> c \<le> a \<and> b \<le> d)"
 | 
| 
87429bdecad5
import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
 hoelzl parents: 
57418diff
changeset | 487 | by (auto simp: subset_eq Ball_def) (metis less_le not_less) | 
| 
87429bdecad5
import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
 hoelzl parents: 
57418diff
changeset | 488 | |
| 52729 
412c9e0381a1
factored syntactic type classes for bot and top (by Alessandro Coglio)
 haftmann parents: 
52380diff
changeset | 489 | lemma (in order_bot) atLeast_eq_UNIV_iff: "{x..} = UNIV \<longleftrightarrow> x = bot"
 | 
| 51334 | 490 | by (auto simp: set_eq_iff intro: le_bot) | 
| 51328 
d63ec23c9125
move auxiliary lemmas from Library/Extended_Reals to HOL image
 hoelzl parents: 
51152diff
changeset | 491 | |
| 52729 
412c9e0381a1
factored syntactic type classes for bot and top (by Alessandro Coglio)
 haftmann parents: 
52380diff
changeset | 492 | lemma (in order_top) atMost_eq_UNIV_iff: "{..x} = UNIV \<longleftrightarrow> x = top"
 | 
| 51334 | 493 | by (auto simp: set_eq_iff intro: top_le) | 
| 51328 
d63ec23c9125
move auxiliary lemmas from Library/Extended_Reals to HOL image
 hoelzl parents: 
51152diff
changeset | 494 | |
| 51334 | 495 | lemma (in bounded_lattice) atLeastAtMost_eq_UNIV_iff: | 
| 496 |   "{x..y} = UNIV \<longleftrightarrow> (x = bot \<and> y = top)"
 | |
| 497 | by (auto simp: set_eq_iff intro: top_le le_bot) | |
| 51328 
d63ec23c9125
move auxiliary lemmas from Library/Extended_Reals to HOL image
 hoelzl parents: 
51152diff
changeset | 498 | |
| 56949 | 499 | lemma Iio_eq_empty_iff: "{..< n::'a::{linorder, order_bot}} = {} \<longleftrightarrow> n = bot"
 | 
| 500 | by (auto simp: set_eq_iff not_less le_bot) | |
| 501 | ||
| 502 | lemma Iio_eq_empty_iff_nat: "{..< n::nat} = {} \<longleftrightarrow> n = 0"
 | |
| 503 | by (simp add: Iio_eq_empty_iff bot_nat_def) | |
| 504 | ||
| 58970 | 505 | lemma mono_image_least: | 
| 506 |   assumes f_mono: "mono f" and f_img: "f ` {m ..< n} = {m' ..< n'}" "m < n"
 | |
| 507 | shows "f m = m'" | |
| 508 | proof - | |
| 509 |   from f_img have "{m' ..< n'} \<noteq> {}"
 | |
| 510 | by (metis atLeastLessThan_empty_iff image_is_empty) | |
| 511 |   with f_img have "m' \<in> f ` {m ..< n}" by auto
 | |
| 512 | then obtain k where "f k = m'" "m \<le> k" by auto | |
| 513 | moreover have "m' \<le> f m" using f_img by auto | |
| 514 | ultimately show "f m = m'" | |
| 515 | using f_mono by (auto elim: monoE[where x=m and y=k]) | |
| 516 | qed | |
| 517 | ||
| 51328 
d63ec23c9125
move auxiliary lemmas from Library/Extended_Reals to HOL image
 hoelzl parents: 
51152diff
changeset | 518 | |
| 60758 | 519 | subsection \<open>Infinite intervals\<close> | 
| 56328 | 520 | |
| 521 | context dense_linorder | |
| 522 | begin | |
| 523 | ||
| 524 | lemma infinite_Ioo: | |
| 525 | assumes "a < b" | |
| 526 |   shows "\<not> finite {a<..<b}"
 | |
| 527 | proof | |
| 528 |   assume fin: "finite {a<..<b}"
 | |
| 529 |   moreover have ne: "{a<..<b} \<noteq> {}"
 | |
| 60758 | 530 | using \<open>a < b\<close> by auto | 
| 56328 | 531 |   ultimately have "a < Max {a <..< b}" "Max {a <..< b} < b"
 | 
| 532 |     using Max_in[of "{a <..< b}"] by auto
 | |
| 533 |   then obtain x where "Max {a <..< b} < x" "x < b"
 | |
| 534 |     using dense[of "Max {a<..<b}" b] by auto
 | |
| 535 |   then have "x \<in> {a <..< b}"
 | |
| 60758 | 536 |     using \<open>a < Max {a <..< b}\<close> by auto
 | 
| 56328 | 537 |   then have "x \<le> Max {a <..< b}"
 | 
| 538 | using fin by auto | |
| 60758 | 539 |   with \<open>Max {a <..< b} < x\<close> show False by auto
 | 
| 56328 | 540 | qed | 
| 541 | ||
| 542 | lemma infinite_Icc: "a < b \<Longrightarrow> \<not> finite {a .. b}"
 | |
| 543 | using greaterThanLessThan_subseteq_atLeastAtMost_iff[of a b a b] infinite_Ioo[of a b] | |
| 544 | by (auto dest: finite_subset) | |
| 545 | ||
| 546 | lemma infinite_Ico: "a < b \<Longrightarrow> \<not> finite {a ..< b}"
 | |
| 547 | using greaterThanLessThan_subseteq_atLeastLessThan_iff[of a b a b] infinite_Ioo[of a b] | |
| 548 | by (auto dest: finite_subset) | |
| 549 | ||
| 550 | lemma infinite_Ioc: "a < b \<Longrightarrow> \<not> finite {a <.. b}"
 | |
| 551 | using greaterThanLessThan_subseteq_greaterThanAtMost_iff[of a b a b] infinite_Ioo[of a b] | |
| 552 | by (auto dest: finite_subset) | |
| 553 | ||
| 63967 
2aa42596edc3
new material on paths, etc. Also rationalisation
 paulson <lp15@cam.ac.uk> parents: 
63935diff
changeset | 554 | lemma infinite_Ioo_iff [simp]: "infinite {a<..<b} \<longleftrightarrow> a < b"
 | 
| 
2aa42596edc3
new material on paths, etc. Also rationalisation
 paulson <lp15@cam.ac.uk> parents: 
63935diff
changeset | 555 | using not_less_iff_gr_or_eq by (fastforce simp: infinite_Ioo) | 
| 
2aa42596edc3
new material on paths, etc. Also rationalisation
 paulson <lp15@cam.ac.uk> parents: 
63935diff
changeset | 556 | |
| 
2aa42596edc3
new material on paths, etc. Also rationalisation
 paulson <lp15@cam.ac.uk> parents: 
63935diff
changeset | 557 | lemma infinite_Icc_iff [simp]: "infinite {a .. b} \<longleftrightarrow> a < b"
 | 
| 
2aa42596edc3
new material on paths, etc. Also rationalisation
 paulson <lp15@cam.ac.uk> parents: 
63935diff
changeset | 558 | using not_less_iff_gr_or_eq by (fastforce simp: infinite_Icc) | 
| 
2aa42596edc3
new material on paths, etc. Also rationalisation
 paulson <lp15@cam.ac.uk> parents: 
63935diff
changeset | 559 | |
| 
2aa42596edc3
new material on paths, etc. Also rationalisation
 paulson <lp15@cam.ac.uk> parents: 
63935diff
changeset | 560 | lemma infinite_Ico_iff [simp]: "infinite {a..<b} \<longleftrightarrow> a < b"
 | 
| 
2aa42596edc3
new material on paths, etc. Also rationalisation
 paulson <lp15@cam.ac.uk> parents: 
63935diff
changeset | 561 | using not_less_iff_gr_or_eq by (fastforce simp: infinite_Ico) | 
| 
2aa42596edc3
new material on paths, etc. Also rationalisation
 paulson <lp15@cam.ac.uk> parents: 
63935diff
changeset | 562 | |
| 
2aa42596edc3
new material on paths, etc. Also rationalisation
 paulson <lp15@cam.ac.uk> parents: 
63935diff
changeset | 563 | lemma infinite_Ioc_iff [simp]: "infinite {a<..b} \<longleftrightarrow> a < b"
 | 
| 
2aa42596edc3
new material on paths, etc. Also rationalisation
 paulson <lp15@cam.ac.uk> parents: 
63935diff
changeset | 564 | using not_less_iff_gr_or_eq by (fastforce simp: infinite_Ioc) | 
| 
2aa42596edc3
new material on paths, etc. Also rationalisation
 paulson <lp15@cam.ac.uk> parents: 
63935diff
changeset | 565 | |
| 56328 | 566 | end | 
| 567 | ||
| 568 | lemma infinite_Iio: "\<not> finite {..< a :: 'a :: {no_bot, linorder}}"
 | |
| 569 | proof | |
| 570 |   assume "finite {..< a}"
 | |
| 571 |   then have *: "\<And>x. x < a \<Longrightarrow> Min {..< a} \<le> x"
 | |
| 572 | by auto | |
| 573 | obtain x where "x < a" | |
| 574 | using lt_ex by auto | |
| 575 | ||
| 576 |   obtain y where "y < Min {..< a}"
 | |
| 577 | using lt_ex by auto | |
| 578 |   also have "Min {..< a} \<le> x"
 | |
| 60758 | 579 | using \<open>x < a\<close> by fact | 
| 580 | also note \<open>x < a\<close> | |
| 56328 | 581 |   finally have "Min {..< a} \<le> y"
 | 
| 582 | by fact | |
| 60758 | 583 |   with \<open>y < Min {..< a}\<close> show False by auto
 | 
| 56328 | 584 | qed | 
| 585 | ||
| 586 | lemma infinite_Iic: "\<not> finite {.. a :: 'a :: {no_bot, linorder}}"
 | |
| 587 |   using infinite_Iio[of a] finite_subset[of "{..< a}" "{.. a}"]
 | |
| 588 | by (auto simp: subset_eq less_imp_le) | |
| 589 | ||
| 590 | lemma infinite_Ioi: "\<not> finite {a :: 'a :: {no_top, linorder} <..}"
 | |
| 591 | proof | |
| 592 |   assume "finite {a <..}"
 | |
| 593 |   then have *: "\<And>x. a < x \<Longrightarrow> x \<le> Max {a <..}"
 | |
| 594 | by auto | |
| 595 | ||
| 596 |   obtain y where "Max {a <..} < y"
 | |
| 597 | using gt_ex by auto | |
| 598 | ||
| 63540 | 599 | obtain x where x: "a < x" | 
| 56328 | 600 | using gt_ex by auto | 
| 63540 | 601 |   also from x have "x \<le> Max {a <..}"
 | 
| 56328 | 602 | by fact | 
| 60758 | 603 |   also note \<open>Max {a <..} < y\<close>
 | 
| 56328 | 604 |   finally have "y \<le> Max { a <..}"
 | 
| 605 | by fact | |
| 60758 | 606 |   with \<open>Max {a <..} < y\<close> show False by auto
 | 
| 56328 | 607 | qed | 
| 608 | ||
| 609 | lemma infinite_Ici: "\<not> finite {a :: 'a :: {no_top, linorder} ..}"
 | |
| 610 |   using infinite_Ioi[of a] finite_subset[of "{a <..}" "{a ..}"]
 | |
| 611 | by (auto simp: subset_eq less_imp_le) | |
| 612 | ||
| 60758 | 613 | subsubsection \<open>Intersection\<close> | 
| 32456 
341c83339aeb
tuned the simp rules for Int involving insert and intervals.
 nipkow parents: 
32436diff
changeset | 614 | |
| 
341c83339aeb
tuned the simp rules for Int involving insert and intervals.
 nipkow parents: 
32436diff
changeset | 615 | context linorder | 
| 
341c83339aeb
tuned the simp rules for Int involving insert and intervals.
 nipkow parents: 
32436diff
changeset | 616 | begin | 
| 
341c83339aeb
tuned the simp rules for Int involving insert and intervals.
 nipkow parents: 
32436diff
changeset | 617 | |
| 
341c83339aeb
tuned the simp rules for Int involving insert and intervals.
 nipkow parents: 
32436diff
changeset | 618 | lemma Int_atLeastAtMost[simp]: "{a..b} Int {c..d} = {max a c .. min b d}"
 | 
| 
341c83339aeb
tuned the simp rules for Int involving insert and intervals.
 nipkow parents: 
32436diff
changeset | 619 | by auto | 
| 
341c83339aeb
tuned the simp rules for Int involving insert and intervals.
 nipkow parents: 
32436diff
changeset | 620 | |
| 
341c83339aeb
tuned the simp rules for Int involving insert and intervals.
 nipkow parents: 
32436diff
changeset | 621 | lemma Int_atLeastAtMostR1[simp]: "{..b} Int {c..d} = {c .. min b d}"
 | 
| 
341c83339aeb
tuned the simp rules for Int involving insert and intervals.
 nipkow parents: 
32436diff
changeset | 622 | by auto | 
| 
341c83339aeb
tuned the simp rules for Int involving insert and intervals.
 nipkow parents: 
32436diff
changeset | 623 | |
| 
341c83339aeb
tuned the simp rules for Int involving insert and intervals.
 nipkow parents: 
32436diff
changeset | 624 | lemma Int_atLeastAtMostR2[simp]: "{a..} Int {c..d} = {max a c .. d}"
 | 
| 
341c83339aeb
tuned the simp rules for Int involving insert and intervals.
 nipkow parents: 
32436diff
changeset | 625 | by auto | 
| 
341c83339aeb
tuned the simp rules for Int involving insert and intervals.
 nipkow parents: 
32436diff
changeset | 626 | |
| 
341c83339aeb
tuned the simp rules for Int involving insert and intervals.
 nipkow parents: 
32436diff
changeset | 627 | lemma Int_atLeastAtMostL1[simp]: "{a..b} Int {..d} = {a .. min b d}"
 | 
| 
341c83339aeb
tuned the simp rules for Int involving insert and intervals.
 nipkow parents: 
32436diff
changeset | 628 | by auto | 
| 
341c83339aeb
tuned the simp rules for Int involving insert and intervals.
 nipkow parents: 
32436diff
changeset | 629 | |
| 
341c83339aeb
tuned the simp rules for Int involving insert and intervals.
 nipkow parents: 
32436diff
changeset | 630 | lemma Int_atLeastAtMostL2[simp]: "{a..b} Int {c..} = {max a c .. b}"
 | 
| 
341c83339aeb
tuned the simp rules for Int involving insert and intervals.
 nipkow parents: 
32436diff
changeset | 631 | by auto | 
| 
341c83339aeb
tuned the simp rules for Int involving insert and intervals.
 nipkow parents: 
32436diff
changeset | 632 | |
| 
341c83339aeb
tuned the simp rules for Int involving insert and intervals.
 nipkow parents: 
32436diff
changeset | 633 | lemma Int_atLeastLessThan[simp]: "{a..<b} Int {c..<d} = {max a c ..< min b d}"
 | 
| 
341c83339aeb
tuned the simp rules for Int involving insert and intervals.
 nipkow parents: 
32436diff
changeset | 634 | by auto | 
| 
341c83339aeb
tuned the simp rules for Int involving insert and intervals.
 nipkow parents: 
32436diff
changeset | 635 | |
| 
341c83339aeb
tuned the simp rules for Int involving insert and intervals.
 nipkow parents: 
32436diff
changeset | 636 | lemma Int_greaterThanAtMost[simp]: "{a<..b} Int {c<..d} = {max a c <.. min b d}"
 | 
| 
341c83339aeb
tuned the simp rules for Int involving insert and intervals.
 nipkow parents: 
32436diff
changeset | 637 | by auto | 
| 
341c83339aeb
tuned the simp rules for Int involving insert and intervals.
 nipkow parents: 
32436diff
changeset | 638 | |
| 
341c83339aeb
tuned the simp rules for Int involving insert and intervals.
 nipkow parents: 
32436diff
changeset | 639 | lemma Int_greaterThanLessThan[simp]: "{a<..<b} Int {c<..<d} = {max a c <..< min b d}"
 | 
| 
341c83339aeb
tuned the simp rules for Int involving insert and intervals.
 nipkow parents: 
32436diff
changeset | 640 | by auto | 
| 
341c83339aeb
tuned the simp rules for Int involving insert and intervals.
 nipkow parents: 
32436diff
changeset | 641 | |
| 50417 | 642 | lemma Int_atMost[simp]: "{..a} \<inter> {..b} = {.. min a b}"
 | 
| 643 | by (auto simp: min_def) | |
| 644 | ||
| 57447 
87429bdecad5
import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
 hoelzl parents: 
57418diff
changeset | 645 | lemma Ioc_disjoint: "{a<..b} \<inter> {c<..d} = {} \<longleftrightarrow> b \<le> a \<or> d \<le> c \<or> b \<le> c \<or> d \<le> a"
 | 
| 63092 | 646 | by auto | 
| 57447 
87429bdecad5
import more stuff from the CLT proof; base the lborel measure on interval_measure; remove lebesgue measure
 hoelzl parents: 
57418diff
changeset | 647 | |
| 32456 
341c83339aeb
tuned the simp rules for Int involving insert and intervals.
 nipkow parents: 
32436diff
changeset | 648 | end | 
| 
341c83339aeb
tuned the simp rules for Int involving insert and intervals.
 nipkow parents: 
32436diff
changeset | 649 | |
| 51329 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 650 | context complete_lattice | 
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 651 | begin | 
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 652 | |
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 653 | lemma | 
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 654 |   shows Sup_atLeast[simp]: "Sup {x ..} = top"
 | 
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 655 |     and Sup_greaterThanAtLeast[simp]: "x < top \<Longrightarrow> Sup {x <..} = top"
 | 
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 656 |     and Sup_atMost[simp]: "Sup {.. y} = y"
 | 
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 657 |     and Sup_atLeastAtMost[simp]: "x \<le> y \<Longrightarrow> Sup { x .. y} = y"
 | 
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 658 |     and Sup_greaterThanAtMost[simp]: "x < y \<Longrightarrow> Sup { x <.. y} = y"
 | 
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 659 | by (auto intro!: Sup_eqI) | 
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 660 | |
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 661 | lemma | 
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 662 |   shows Inf_atMost[simp]: "Inf {.. x} = bot"
 | 
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 663 |     and Inf_atMostLessThan[simp]: "top < x \<Longrightarrow> Inf {..< x} = bot"
 | 
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 664 |     and Inf_atLeast[simp]: "Inf {x ..} = x"
 | 
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 665 |     and Inf_atLeastAtMost[simp]: "x \<le> y \<Longrightarrow> Inf { x .. y} = x"
 | 
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 666 |     and Inf_atLeastLessThan[simp]: "x < y \<Longrightarrow> Inf { x ..< y} = x"
 | 
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 667 | by (auto intro!: Inf_eqI) | 
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 668 | |
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 669 | end | 
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 670 | |
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 671 | lemma | 
| 53216 | 672 |   fixes x y :: "'a :: {complete_lattice, dense_linorder}"
 | 
| 51329 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 673 |   shows Sup_lessThan[simp]: "Sup {..< y} = y"
 | 
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 674 |     and Sup_atLeastLessThan[simp]: "x < y \<Longrightarrow> Sup { x ..< y} = y"
 | 
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 675 |     and Sup_greaterThanLessThan[simp]: "x < y \<Longrightarrow> Sup { x <..< y} = y"
 | 
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 676 |     and Inf_greaterThan[simp]: "Inf {x <..} = x"
 | 
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 677 |     and Inf_greaterThanAtMost[simp]: "x < y \<Longrightarrow> Inf { x <.. y} = x"
 | 
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 678 |     and Inf_greaterThanLessThan[simp]: "x < y \<Longrightarrow> Inf { x <..< y} = x"
 | 
| 
4a3c453f99a1
split dense into inner_dense_order and no_top/no_bot
 hoelzl parents: 
51328diff
changeset | 679 | by (auto intro!: Inf_eqI Sup_eqI intro: dense_le dense_le_bounded dense_ge dense_ge_bounded) | 
| 32456 
341c83339aeb
tuned the simp rules for Int involving insert and intervals.
 nipkow parents: 
32436diff
changeset | 680 | |
| 60758 | 681 | subsection \<open>Intervals of natural numbers\<close> | 
| 14485 | 682 | |
| 60758 | 683 | subsubsection \<open>The Constant @{term lessThan}\<close>
 | 
| 15047 | 684 | |
| 14485 | 685 | lemma lessThan_0 [simp]: "lessThan (0::nat) = {}"
 | 
| 686 | by (simp add: lessThan_def) | |
| 687 | ||
| 688 | lemma lessThan_Suc: "lessThan (Suc k) = insert k (lessThan k)" | |
| 689 | by (simp add: lessThan_def less_Suc_eq, blast) | |
| 690 | ||
| 60758 | 691 | text \<open>The following proof is convenient in induction proofs where | 
| 39072 | 692 | new elements get indices at the beginning. So it is used to transform | 
| 60758 | 693 | @{term "{..<Suc n}"} to @{term "0::nat"} and @{term "{..< n}"}.\<close>
 | 
| 39072 | 694 | |
| 59000 | 695 | lemma zero_notin_Suc_image: "0 \<notin> Suc ` A" | 
| 696 | by auto | |
| 697 | ||
| 39072 | 698 | lemma lessThan_Suc_eq_insert_0: "{..<Suc n} = insert 0 (Suc ` {..<n})"
 | 
| 59000 | 699 | by (auto simp: image_iff less_Suc_eq_0_disj) | 
| 39072 | 700 | |
| 14485 | 701 | lemma lessThan_Suc_atMost: "lessThan (Suc k) = atMost k" | 
| 702 | by (simp add: lessThan_def atMost_def less_Suc_eq_le) | |
| 703 | ||
| 59000 | 704 | lemma Iic_Suc_eq_insert_0: "{.. Suc n} = insert 0 (Suc ` {.. n})"
 | 
| 705 | unfolding lessThan_Suc_atMost[symmetric] lessThan_Suc_eq_insert_0[of "Suc n"] .. | |
| 706 | ||
| 14485 | 707 | lemma UN_lessThan_UNIV: "(UN m::nat. lessThan m) = UNIV" | 
| 708 | by blast | |
| 709 | ||
| 60758 | 710 | subsubsection \<open>The Constant @{term greaterThan}\<close>
 | 
| 15047 | 711 | |
| 65273 
917ae0ba03a2
Removal of [simp] status for greaterThan_0. Moved two theorems into main HOL.
 paulson <lp15@cam.ac.uk> parents: 
64773diff
changeset | 712 | lemma greaterThan_0: "greaterThan 0 = range Suc" | 
| 14485 | 713 | apply (simp add: greaterThan_def) | 
| 714 | apply (blast dest: gr0_conv_Suc [THEN iffD1]) | |
| 715 | done | |
| 716 | ||
| 717 | lemma greaterThan_Suc: "greaterThan (Suc k) = greaterThan k - {Suc k}"
 | |
| 718 | apply (simp add: greaterThan_def) | |
| 719 | apply (auto elim: linorder_neqE) | |
| 720 | done | |
| 721 | ||
| 722 | lemma INT_greaterThan_UNIV: "(INT m::nat. greaterThan m) = {}"
 | |
| 723 | by blast | |
| 724 | ||
| 60758 | 725 | subsubsection \<open>The Constant @{term atLeast}\<close>
 | 
| 15047 | 726 | |
| 14485 | 727 | lemma atLeast_0 [simp]: "atLeast (0::nat) = UNIV" | 
| 728 | by (unfold atLeast_def UNIV_def, simp) | |
| 729 | ||
| 730 | lemma atLeast_Suc: "atLeast (Suc k) = atLeast k - {k}"
 | |
| 731 | apply (simp add: atLeast_def) | |
| 732 | apply (simp add: Suc_le_eq) | |
| 733 | apply (simp add: order_le_less, blast) | |
| 734 | done | |
| 735 | ||
| 736 | lemma atLeast_Suc_greaterThan: "atLeast (Suc k) = greaterThan k" | |
| 737 | by (auto simp add: greaterThan_def atLeast_def less_Suc_eq_le) | |
| 738 | ||
| 739 | lemma UN_atLeast_UNIV: "(UN m::nat. atLeast m) = UNIV" | |
| 740 | by blast | |
| 741 | ||
| 60758 | 742 | subsubsection \<open>The Constant @{term atMost}\<close>
 | 
| 15047 | 743 | |
| 14485 | 744 | lemma atMost_0 [simp]: "atMost (0::nat) = {0}"
 | 
| 745 | by (simp add: atMost_def) | |
| 746 | ||
| 747 | lemma atMost_Suc: "atMost (Suc k) = insert (Suc k) (atMost k)" | |
| 748 | apply (simp add: atMost_def) | |
| 749 | apply (simp add: less_Suc_eq order_le_less, blast) | |
| 750 | done | |
| 751 | ||
| 752 | lemma UN_atMost_UNIV: "(UN m::nat. atMost m) = UNIV" | |
| 753 | by blast | |
| 754 | ||
| 60758 | 755 | subsubsection \<open>The Constant @{term atLeastLessThan}\<close>
 | 
| 15047 | 756 | |
| 60758 | 757 | text\<open>The orientation of the following 2 rules is tricky. The lhs is | 
| 24449 | 758 | defined in terms of the rhs. Hence the chosen orientation makes sense | 
| 759 | in this theory --- the reverse orientation complicates proofs (eg | |
| 760 | nontermination). But outside, when the definition of the lhs is rarely | |
| 761 | used, the opposite orientation seems preferable because it reduces a | |
| 60758 | 762 | specific concept to a more general one.\<close> | 
| 28068 | 763 | |
| 63417 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 764 | lemma atLeast0LessThan [code_abbrev]: "{0::nat..<n} = {..<n}"
 | 
| 15042 | 765 | by(simp add:lessThan_def atLeastLessThan_def) | 
| 24449 | 766 | |
| 63417 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 767 | lemma atLeast0AtMost [code_abbrev]: "{0..n::nat} = {..n}"
 | 
| 28068 | 768 | by(simp add:atMost_def atLeastAtMost_def) | 
| 769 | ||
| 63417 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 770 | lemma lessThan_atLeast0: | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 771 |   "{..<n} = {0::nat..<n}"
 | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 772 | by (simp add: atLeast0LessThan) | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 773 | |
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 774 | lemma atMost_atLeast0: | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 775 |   "{..n} = {0::nat..n}"
 | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 776 | by (simp add: atLeast0AtMost) | 
| 24449 | 777 | |
| 778 | lemma atLeastLessThan0: "{m..<0::nat} = {}"
 | |
| 15047 | 779 | by (simp add: atLeastLessThan_def) | 
| 24449 | 780 | |
| 63417 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 781 | lemma atLeast0_lessThan_Suc: | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 782 |   "{0..<Suc n} = insert n {0..<n}"
 | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 783 | by (simp add: atLeast0LessThan lessThan_Suc) | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 784 | |
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 785 | lemma atLeast0_lessThan_Suc_eq_insert_0: | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 786 |   "{0..<Suc n} = insert 0 (Suc ` {0..<n})"
 | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 787 | by (simp add: atLeast0LessThan lessThan_Suc_eq_insert_0) | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 788 | |
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 789 | |
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 790 | subsubsection \<open>The Constant @{term atLeastAtMost}\<close>
 | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 791 | |
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 792 | lemma atLeast0_atMost_Suc: | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 793 |   "{0..Suc n} = insert (Suc n) {0..n}"
 | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 794 | by (simp add: atLeast0AtMost atMost_Suc) | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 795 | |
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 796 | lemma atLeast0_atMost_Suc_eq_insert_0: | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 797 |   "{0..Suc n} = insert 0 (Suc ` {0..n})"
 | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 798 | by (simp add: atLeast0AtMost Iic_Suc_eq_insert_0) | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 799 | |
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 800 | |
| 60758 | 801 | subsubsection \<open>Intervals of nats with @{term Suc}\<close>
 | 
| 15047 | 802 | |
| 60758 | 803 | text\<open>Not a simprule because the RHS is too messy.\<close> | 
| 15047 | 804 | lemma atLeastLessThanSuc: | 
| 805 |     "{m..<Suc n} = (if m \<le> n then insert n {m..<n} else {})"
 | |
| 15418 
e28853da5df5
removed two looping simplifications in SetInterval.thy; deleted the .ML file
 paulson parents: 
15402diff
changeset | 806 | by (auto simp add: atLeastLessThan_def) | 
| 15047 | 807 | |
| 15418 
e28853da5df5
removed two looping simplifications in SetInterval.thy; deleted the .ML file
 paulson parents: 
15402diff
changeset | 808 | lemma atLeastLessThan_singleton [simp]: "{m..<Suc m} = {m}"
 | 
| 15047 | 809 | by (auto simp add: atLeastLessThan_def) | 
| 16041 | 810 | (* | 
| 15047 | 811 | lemma atLeast_sum_LessThan [simp]: "{m + k..<k::nat} = {}"
 | 
| 812 | by (induct k, simp_all add: atLeastLessThanSuc) | |
| 813 | ||
| 814 | lemma atLeastSucLessThan [simp]: "{Suc n..<n} = {}"
 | |
| 815 | by (auto simp add: atLeastLessThan_def) | |
| 16041 | 816 | *) | 
| 15045 | 817 | lemma atLeastLessThanSuc_atLeastAtMost: "{l..<Suc u} = {l..u}"
 | 
| 14485 | 818 | by (simp add: lessThan_Suc_atMost atLeastAtMost_def atLeastLessThan_def) | 
| 819 | ||
| 15418 
e28853da5df5
removed two looping simplifications in SetInterval.thy; deleted the .ML file
 paulson parents: 
15402diff
changeset | 820 | lemma atLeastSucAtMost_greaterThanAtMost: "{Suc l..u} = {l<..u}"
 | 
| 
e28853da5df5
removed two looping simplifications in SetInterval.thy; deleted the .ML file
 paulson parents: 
15402diff
changeset | 821 | by (simp add: atLeast_Suc_greaterThan atLeastAtMost_def | 
| 14485 | 822 | greaterThanAtMost_def) | 
| 823 | ||
| 15418 
e28853da5df5
removed two looping simplifications in SetInterval.thy; deleted the .ML file
 paulson parents: 
15402diff
changeset | 824 | lemma atLeastSucLessThan_greaterThanLessThan: "{Suc l..<u} = {l<..<u}"
 | 
| 
e28853da5df5
removed two looping simplifications in SetInterval.thy; deleted the .ML file
 paulson parents: 
15402diff
changeset | 825 | by (simp add: atLeast_Suc_greaterThan atLeastLessThan_def | 
| 14485 | 826 | greaterThanLessThan_def) | 
| 827 | ||
| 15554 | 828 | lemma atLeastAtMostSuc_conv: "m \<le> Suc n \<Longrightarrow> {m..Suc n} = insert (Suc n) {m..n}"
 | 
| 829 | by (auto simp add: atLeastAtMost_def) | |
| 830 | ||
| 45932 | 831 | lemma atLeastAtMost_insertL: "m \<le> n \<Longrightarrow> insert m {Suc m..n} = {m ..n}"
 | 
| 832 | by auto | |
| 833 | ||
| 60758 | 834 | text \<open>The analogous result is useful on @{typ int}:\<close>
 | 
| 43157 | 835 | (* here, because we don't have an own int section *) | 
| 836 | lemma atLeastAtMostPlus1_int_conv: | |
| 837 |   "m <= 1+n \<Longrightarrow> {m..1+n} = insert (1+n) {m..n::int}"
 | |
| 838 | by (auto intro: set_eqI) | |
| 839 | ||
| 33044 | 840 | lemma atLeastLessThan_add_Un: "i \<le> j \<Longrightarrow> {i..<j+k} = {i..<j} \<union> {j..<j+k::nat}"
 | 
| 62369 | 841 | apply (induct k) | 
| 842 | apply (simp_all add: atLeastLessThanSuc) | |
| 33044 | 843 | done | 
| 844 | ||
| 60758 | 845 | subsubsection \<open>Intervals and numerals\<close> | 
| 57113 
7e95523302e6
New theorems to enable the simplification of certain functions when applied to specific natural number constants (such as 4)
 paulson <lp15@cam.ac.uk> parents: 
56949diff
changeset | 846 | |
| 61799 | 847 | lemma lessThan_nat_numeral: \<comment>\<open>Evaluation for specific numerals\<close> | 
| 57113 
7e95523302e6
New theorems to enable the simplification of certain functions when applied to specific natural number constants (such as 4)
 paulson <lp15@cam.ac.uk> parents: 
56949diff
changeset | 848 | "lessThan (numeral k :: nat) = insert (pred_numeral k) (lessThan (pred_numeral k))" | 
| 
7e95523302e6
New theorems to enable the simplification of certain functions when applied to specific natural number constants (such as 4)
 paulson <lp15@cam.ac.uk> parents: 
56949diff
changeset | 849 | by (simp add: numeral_eq_Suc lessThan_Suc) | 
| 
7e95523302e6
New theorems to enable the simplification of certain functions when applied to specific natural number constants (such as 4)
 paulson <lp15@cam.ac.uk> parents: 
56949diff
changeset | 850 | |
| 61799 | 851 | lemma atMost_nat_numeral: \<comment>\<open>Evaluation for specific numerals\<close> | 
| 57113 
7e95523302e6
New theorems to enable the simplification of certain functions when applied to specific natural number constants (such as 4)
 paulson <lp15@cam.ac.uk> parents: 
56949diff
changeset | 852 | "atMost (numeral k :: nat) = insert (numeral k) (atMost (pred_numeral k))" | 
| 
7e95523302e6
New theorems to enable the simplification of certain functions when applied to specific natural number constants (such as 4)
 paulson <lp15@cam.ac.uk> parents: 
56949diff
changeset | 853 | by (simp add: numeral_eq_Suc atMost_Suc) | 
| 
7e95523302e6
New theorems to enable the simplification of certain functions when applied to specific natural number constants (such as 4)
 paulson <lp15@cam.ac.uk> parents: 
56949diff
changeset | 854 | |
| 61799 | 855 | lemma atLeastLessThan_nat_numeral: \<comment>\<open>Evaluation for specific numerals\<close> | 
| 62369 | 856 | "atLeastLessThan m (numeral k :: nat) = | 
| 57113 
7e95523302e6
New theorems to enable the simplification of certain functions when applied to specific natural number constants (such as 4)
 paulson <lp15@cam.ac.uk> parents: 
56949diff
changeset | 857 | (if m \<le> (pred_numeral k) then insert (pred_numeral k) (atLeastLessThan m (pred_numeral k)) | 
| 
7e95523302e6
New theorems to enable the simplification of certain functions when applied to specific natural number constants (such as 4)
 paulson <lp15@cam.ac.uk> parents: 
56949diff
changeset | 858 |                  else {})"
 | 
| 
7e95523302e6
New theorems to enable the simplification of certain functions when applied to specific natural number constants (such as 4)
 paulson <lp15@cam.ac.uk> parents: 
56949diff
changeset | 859 | by (simp add: numeral_eq_Suc atLeastLessThanSuc) | 
| 
7e95523302e6
New theorems to enable the simplification of certain functions when applied to specific natural number constants (such as 4)
 paulson <lp15@cam.ac.uk> parents: 
56949diff
changeset | 860 | |
| 60758 | 861 | subsubsection \<open>Image\<close> | 
| 16733 
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
 nipkow parents: 
16102diff
changeset | 862 | |
| 60809 
457abb82fb9e
the Cauchy integral theorem and related material
 paulson <lp15@cam.ac.uk> parents: 
60762diff
changeset | 863 | lemma image_add_atLeastAtMost [simp]: | 
| 60615 
e5fa1d5d3952
Useful lemmas. The theorem concerning swapping the variables in a double integral.
 paulson <lp15@cam.ac.uk> parents: 
60586diff
changeset | 864 | fixes k ::"'a::linordered_semidom" | 
| 
e5fa1d5d3952
Useful lemmas. The theorem concerning swapping the variables in a double integral.
 paulson <lp15@cam.ac.uk> parents: 
60586diff
changeset | 865 |   shows "(\<lambda>n. n+k) ` {i..j} = {i+k..j+k}" (is "?A = ?B")
 | 
| 16733 
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
 nipkow parents: 
16102diff
changeset | 866 | proof | 
| 
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
 nipkow parents: 
16102diff
changeset | 867 | show "?A \<subseteq> ?B" by auto | 
| 
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
 nipkow parents: 
16102diff
changeset | 868 | next | 
| 
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
 nipkow parents: 
16102diff
changeset | 869 | show "?B \<subseteq> ?A" | 
| 
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
 nipkow parents: 
16102diff
changeset | 870 | proof | 
| 
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
 nipkow parents: 
16102diff
changeset | 871 | fix n assume a: "n : ?B" | 
| 60615 
e5fa1d5d3952
Useful lemmas. The theorem concerning swapping the variables in a double integral.
 paulson <lp15@cam.ac.uk> parents: 
60586diff
changeset | 872 |     hence "n - k : {i..j}"
 | 
| 
e5fa1d5d3952
Useful lemmas. The theorem concerning swapping the variables in a double integral.
 paulson <lp15@cam.ac.uk> parents: 
60586diff
changeset | 873 | by (auto simp: add_le_imp_le_diff add_le_add_imp_diff_le) | 
| 
e5fa1d5d3952
Useful lemmas. The theorem concerning swapping the variables in a double integral.
 paulson <lp15@cam.ac.uk> parents: 
60586diff
changeset | 874 | moreover have "n = (n - k) + k" using a | 
| 
e5fa1d5d3952
Useful lemmas. The theorem concerning swapping the variables in a double integral.
 paulson <lp15@cam.ac.uk> parents: 
60586diff
changeset | 875 | proof - | 
| 
e5fa1d5d3952
Useful lemmas. The theorem concerning swapping the variables in a double integral.
 paulson <lp15@cam.ac.uk> parents: 
60586diff
changeset | 876 | have "k + i \<le> n" | 
| 
e5fa1d5d3952
Useful lemmas. The theorem concerning swapping the variables in a double integral.
 paulson <lp15@cam.ac.uk> parents: 
60586diff
changeset | 877 | by (metis a add.commute atLeastAtMost_iff) | 
| 
e5fa1d5d3952
Useful lemmas. The theorem concerning swapping the variables in a double integral.
 paulson <lp15@cam.ac.uk> parents: 
60586diff
changeset | 878 | hence "k + (n - k) = n" | 
| 
e5fa1d5d3952
Useful lemmas. The theorem concerning swapping the variables in a double integral.
 paulson <lp15@cam.ac.uk> parents: 
60586diff
changeset | 879 | by (metis (no_types) ab_semigroup_add_class.add_ac(1) add_diff_cancel_left' le_add_diff_inverse) | 
| 
e5fa1d5d3952
Useful lemmas. The theorem concerning swapping the variables in a double integral.
 paulson <lp15@cam.ac.uk> parents: 
60586diff
changeset | 880 | thus ?thesis | 
| 
e5fa1d5d3952
Useful lemmas. The theorem concerning swapping the variables in a double integral.
 paulson <lp15@cam.ac.uk> parents: 
60586diff
changeset | 881 | by (simp add: add.commute) | 
| 
e5fa1d5d3952
Useful lemmas. The theorem concerning swapping the variables in a double integral.
 paulson <lp15@cam.ac.uk> parents: 
60586diff
changeset | 882 | qed | 
| 16733 
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
 nipkow parents: 
16102diff
changeset | 883 | ultimately show "n : ?A" by blast | 
| 
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
 nipkow parents: 
16102diff
changeset | 884 | qed | 
| 
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
 nipkow parents: 
16102diff
changeset | 885 | qed | 
| 
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
 nipkow parents: 
16102diff
changeset | 886 | |
| 60809 
457abb82fb9e
the Cauchy integral theorem and related material
 paulson <lp15@cam.ac.uk> parents: 
60762diff
changeset | 887 | lemma image_diff_atLeastAtMost [simp]: | 
| 
457abb82fb9e
the Cauchy integral theorem and related material
 paulson <lp15@cam.ac.uk> parents: 
60762diff
changeset | 888 |   fixes d::"'a::linordered_idom" shows "(op - d ` {a..b}) = {d-b..d-a}"
 | 
| 
457abb82fb9e
the Cauchy integral theorem and related material
 paulson <lp15@cam.ac.uk> parents: 
60762diff
changeset | 889 | apply auto | 
| 
457abb82fb9e
the Cauchy integral theorem and related material
 paulson <lp15@cam.ac.uk> parents: 
60762diff
changeset | 890 | apply (rule_tac x="d-x" in rev_image_eqI, auto) | 
| 
457abb82fb9e
the Cauchy integral theorem and related material
 paulson <lp15@cam.ac.uk> parents: 
60762diff
changeset | 891 | done | 
| 
457abb82fb9e
the Cauchy integral theorem and related material
 paulson <lp15@cam.ac.uk> parents: 
60762diff
changeset | 892 | |
| 
457abb82fb9e
the Cauchy integral theorem and related material
 paulson <lp15@cam.ac.uk> parents: 
60762diff
changeset | 893 | lemma image_mult_atLeastAtMost [simp]: | 
| 
457abb82fb9e
the Cauchy integral theorem and related material
 paulson <lp15@cam.ac.uk> parents: 
60762diff
changeset | 894 | fixes d::"'a::linordered_field" | 
| 
457abb82fb9e
the Cauchy integral theorem and related material
 paulson <lp15@cam.ac.uk> parents: 
60762diff
changeset | 895 |   assumes "d>0" shows "(op * d ` {a..b}) = {d*a..d*b}"
 | 
| 
457abb82fb9e
the Cauchy integral theorem and related material
 paulson <lp15@cam.ac.uk> parents: 
60762diff
changeset | 896 | using assms | 
| 
457abb82fb9e
the Cauchy integral theorem and related material
 paulson <lp15@cam.ac.uk> parents: 
60762diff
changeset | 897 | by (auto simp: field_simps mult_le_cancel_right intro: rev_image_eqI [where x="x/d" for x]) | 
| 
457abb82fb9e
the Cauchy integral theorem and related material
 paulson <lp15@cam.ac.uk> parents: 
60762diff
changeset | 898 | |
| 
457abb82fb9e
the Cauchy integral theorem and related material
 paulson <lp15@cam.ac.uk> parents: 
60762diff
changeset | 899 | lemma image_affinity_atLeastAtMost: | 
| 
457abb82fb9e
the Cauchy integral theorem and related material
 paulson <lp15@cam.ac.uk> parents: 
60762diff
changeset | 900 | fixes c :: "'a::linordered_field" | 
| 
457abb82fb9e
the Cauchy integral theorem and related material
 paulson <lp15@cam.ac.uk> parents: 
60762diff
changeset | 901 |   shows "((\<lambda>x. m*x + c) ` {a..b}) = (if {a..b}={} then {}
 | 
| 
457abb82fb9e
the Cauchy integral theorem and related material
 paulson <lp15@cam.ac.uk> parents: 
60762diff
changeset | 902 |             else if 0 \<le> m then {m*a + c .. m *b + c}
 | 
| 
457abb82fb9e
the Cauchy integral theorem and related material
 paulson <lp15@cam.ac.uk> parents: 
60762diff
changeset | 903 |             else {m*b + c .. m*a + c})"
 | 
| 
457abb82fb9e
the Cauchy integral theorem and related material
 paulson <lp15@cam.ac.uk> parents: 
60762diff
changeset | 904 | apply (case_tac "m=0", auto simp: mult_le_cancel_left) | 
| 
457abb82fb9e
the Cauchy integral theorem and related material
 paulson <lp15@cam.ac.uk> parents: 
60762diff
changeset | 905 | apply (rule_tac x="inverse m*(x-c)" in rev_image_eqI, auto simp: field_simps) | 
| 
457abb82fb9e
the Cauchy integral theorem and related material
 paulson <lp15@cam.ac.uk> parents: 
60762diff
changeset | 906 | apply (rule_tac x="inverse m*(x-c)" in rev_image_eqI, auto simp: field_simps) | 
| 
457abb82fb9e
the Cauchy integral theorem and related material
 paulson <lp15@cam.ac.uk> parents: 
60762diff
changeset | 907 | done | 
| 
457abb82fb9e
the Cauchy integral theorem and related material
 paulson <lp15@cam.ac.uk> parents: 
60762diff
changeset | 908 | |
| 
457abb82fb9e
the Cauchy integral theorem and related material
 paulson <lp15@cam.ac.uk> parents: 
60762diff
changeset | 909 | lemma image_affinity_atLeastAtMost_diff: | 
| 
457abb82fb9e
the Cauchy integral theorem and related material
 paulson <lp15@cam.ac.uk> parents: 
60762diff
changeset | 910 | fixes c :: "'a::linordered_field" | 
| 
457abb82fb9e
the Cauchy integral theorem and related material
 paulson <lp15@cam.ac.uk> parents: 
60762diff
changeset | 911 |   shows "((\<lambda>x. m*x - c) ` {a..b}) = (if {a..b}={} then {}
 | 
| 
457abb82fb9e
the Cauchy integral theorem and related material
 paulson <lp15@cam.ac.uk> parents: 
60762diff
changeset | 912 |             else if 0 \<le> m then {m*a - c .. m*b - c}
 | 
| 
457abb82fb9e
the Cauchy integral theorem and related material
 paulson <lp15@cam.ac.uk> parents: 
60762diff
changeset | 913 |             else {m*b - c .. m*a - c})"
 | 
| 
457abb82fb9e
the Cauchy integral theorem and related material
 paulson <lp15@cam.ac.uk> parents: 
60762diff
changeset | 914 | using image_affinity_atLeastAtMost [of m "-c" a b] | 
| 
457abb82fb9e
the Cauchy integral theorem and related material
 paulson <lp15@cam.ac.uk> parents: 
60762diff
changeset | 915 | by simp | 
| 
457abb82fb9e
the Cauchy integral theorem and related material
 paulson <lp15@cam.ac.uk> parents: 
60762diff
changeset | 916 | |
| 61204 | 917 | lemma image_affinity_atLeastAtMost_div: | 
| 918 | fixes c :: "'a::linordered_field" | |
| 919 |   shows "((\<lambda>x. x/m + c) ` {a..b}) = (if {a..b}={} then {}
 | |
| 920 |             else if 0 \<le> m then {a/m + c .. b/m + c}
 | |
| 921 |             else {b/m + c .. a/m + c})"
 | |
| 922 | using image_affinity_atLeastAtMost [of "inverse m" c a b] | |
| 923 | by (simp add: field_class.field_divide_inverse algebra_simps) | |
| 62369 | 924 | |
| 60809 
457abb82fb9e
the Cauchy integral theorem and related material
 paulson <lp15@cam.ac.uk> parents: 
60762diff
changeset | 925 | lemma image_affinity_atLeastAtMost_div_diff: | 
| 
457abb82fb9e
the Cauchy integral theorem and related material
 paulson <lp15@cam.ac.uk> parents: 
60762diff
changeset | 926 | fixes c :: "'a::linordered_field" | 
| 
457abb82fb9e
the Cauchy integral theorem and related material
 paulson <lp15@cam.ac.uk> parents: 
60762diff
changeset | 927 |   shows "((\<lambda>x. x/m - c) ` {a..b}) = (if {a..b}={} then {}
 | 
| 
457abb82fb9e
the Cauchy integral theorem and related material
 paulson <lp15@cam.ac.uk> parents: 
60762diff
changeset | 928 |             else if 0 \<le> m then {a/m - c .. b/m - c}
 | 
| 
457abb82fb9e
the Cauchy integral theorem and related material
 paulson <lp15@cam.ac.uk> parents: 
60762diff
changeset | 929 |             else {b/m - c .. a/m - c})"
 | 
| 
457abb82fb9e
the Cauchy integral theorem and related material
 paulson <lp15@cam.ac.uk> parents: 
60762diff
changeset | 930 | using image_affinity_atLeastAtMost_diff [of "inverse m" c a b] | 
| 
457abb82fb9e
the Cauchy integral theorem and related material
 paulson <lp15@cam.ac.uk> parents: 
60762diff
changeset | 931 | by (simp add: field_class.field_divide_inverse algebra_simps) | 
| 
457abb82fb9e
the Cauchy integral theorem and related material
 paulson <lp15@cam.ac.uk> parents: 
60762diff
changeset | 932 | |
| 16733 
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
 nipkow parents: 
16102diff
changeset | 933 | lemma image_add_atLeastLessThan: | 
| 
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
 nipkow parents: 
16102diff
changeset | 934 |   "(%n::nat. n+k) ` {i..<j} = {i+k..<j+k}" (is "?A = ?B")
 | 
| 
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
 nipkow parents: 
16102diff
changeset | 935 | proof | 
| 
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
 nipkow parents: 
16102diff
changeset | 936 | show "?A \<subseteq> ?B" by auto | 
| 
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
 nipkow parents: 
16102diff
changeset | 937 | next | 
| 
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
 nipkow parents: 
16102diff
changeset | 938 | show "?B \<subseteq> ?A" | 
| 
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
 nipkow parents: 
16102diff
changeset | 939 | proof | 
| 
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
 nipkow parents: 
16102diff
changeset | 940 | fix n assume a: "n : ?B" | 
| 20217 
25b068a99d2b
linear arithmetic splits certain operators (e.g. min, max, abs)
 webertj parents: 
19538diff
changeset | 941 |     hence "n - k : {i..<j}" by auto
 | 
| 16733 
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
 nipkow parents: 
16102diff
changeset | 942 | moreover have "n = (n - k) + k" using a by auto | 
| 
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
 nipkow parents: 
16102diff
changeset | 943 | ultimately show "n : ?A" by blast | 
| 
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
 nipkow parents: 
16102diff
changeset | 944 | qed | 
| 
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
 nipkow parents: 
16102diff
changeset | 945 | qed | 
| 
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
 nipkow parents: 
16102diff
changeset | 946 | |
| 63365 | 947 | corollary image_Suc_lessThan: | 
| 948 |   "Suc ` {..<n} = {1..n}"
 | |
| 949 | using image_add_atLeastLessThan [of 1 0 n] | |
| 950 | by (auto simp add: lessThan_Suc_atMost atLeast0LessThan) | |
| 63915 | 951 | |
| 63365 | 952 | corollary image_Suc_atMost: | 
| 953 |   "Suc ` {..n} = {1..Suc n}"
 | |
| 954 | using image_add_atLeastLessThan [of 1 0 "Suc n"] | |
| 955 | by (auto simp add: lessThan_Suc_atMost atLeast0LessThan) | |
| 956 | ||
| 16733 
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
 nipkow parents: 
16102diff
changeset | 957 | corollary image_Suc_atLeastAtMost[simp]: | 
| 
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
 nipkow parents: 
16102diff
changeset | 958 |   "Suc ` {i..j} = {Suc i..Suc j}"
 | 
| 30079 
293b896b9c25
make proofs work whether or not One_nat_def is a simp rule; replace 1 with Suc 0 in the rhs of some simp rules
 huffman parents: 
29960diff
changeset | 959 | using image_add_atLeastAtMost[where k="Suc 0"] by simp | 
| 16733 
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
 nipkow parents: 
16102diff
changeset | 960 | |
| 
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
 nipkow parents: 
16102diff
changeset | 961 | corollary image_Suc_atLeastLessThan[simp]: | 
| 
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
 nipkow parents: 
16102diff
changeset | 962 |   "Suc ` {i..<j} = {Suc i..<Suc j}"
 | 
| 30079 
293b896b9c25
make proofs work whether or not One_nat_def is a simp rule; replace 1 with Suc 0 in the rhs of some simp rules
 huffman parents: 
29960diff
changeset | 963 | using image_add_atLeastLessThan[where k="Suc 0"] by simp | 
| 16733 
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
 nipkow parents: 
16102diff
changeset | 964 | |
| 63365 | 965 | lemma atLeast1_lessThan_eq_remove0: | 
| 966 |   "{Suc 0..<n} = {..<n} - {0}"
 | |
| 967 | by auto | |
| 968 | ||
| 969 | lemma atLeast1_atMost_eq_remove0: | |
| 970 |   "{Suc 0..n} = {..n} - {0}"
 | |
| 971 | by auto | |
| 972 | ||
| 16733 
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
 nipkow parents: 
16102diff
changeset | 973 | lemma image_add_int_atLeastLessThan: | 
| 
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
 nipkow parents: 
16102diff
changeset | 974 |     "(%x. x + (l::int)) ` {0..<u-l} = {l..<u}"
 | 
| 
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
 nipkow parents: 
16102diff
changeset | 975 | apply (auto simp add: image_def) | 
| 
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
 nipkow parents: 
16102diff
changeset | 976 | apply (rule_tac x = "x - l" in bexI) | 
| 
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
 nipkow parents: 
16102diff
changeset | 977 | apply auto | 
| 
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
 nipkow parents: 
16102diff
changeset | 978 | done | 
| 
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
 nipkow parents: 
16102diff
changeset | 979 | |
| 37664 | 980 | lemma image_minus_const_atLeastLessThan_nat: | 
| 981 | fixes c :: nat | |
| 982 |   shows "(\<lambda>i. i - c) ` {x ..< y} =
 | |
| 983 |       (if c < y then {x - c ..< y - c} else if x < y then {0} else {})"
 | |
| 984 | (is "_ = ?right") | |
| 985 | proof safe | |
| 986 | fix a assume a: "a \<in> ?right" | |
| 987 |   show "a \<in> (\<lambda>i. i - c) ` {x ..< y}"
 | |
| 988 | proof cases | |
| 989 | assume "c < y" with a show ?thesis | |
| 990 | by (auto intro!: image_eqI[of _ _ "a + c"]) | |
| 991 | next | |
| 992 | assume "\<not> c < y" with a show ?thesis | |
| 62390 | 993 | by (auto intro!: image_eqI[of _ _ x] split: if_split_asm) | 
| 37664 | 994 | qed | 
| 995 | qed auto | |
| 996 | ||
| 51152 | 997 | lemma image_int_atLeastLessThan: "int ` {a..<b} = {int a..<int b}"
 | 
| 55143 
04448228381d
explicit eigen-context for attributes "where", "of", and corresponding read_instantiate, instantiate_tac;
 wenzelm parents: 
55088diff
changeset | 998 | by (auto intro!: image_eqI [where x = "nat x" for x]) | 
| 51152 | 999 | |
| 35580 | 1000 | context ordered_ab_group_add | 
| 1001 | begin | |
| 1002 | ||
| 1003 | lemma | |
| 1004 | fixes x :: 'a | |
| 1005 |   shows image_uminus_greaterThan[simp]: "uminus ` {x<..} = {..<-x}"
 | |
| 1006 |   and image_uminus_atLeast[simp]: "uminus ` {x..} = {..-x}"
 | |
| 1007 | proof safe | |
| 1008 | fix y assume "y < -x" | |
| 1009 | hence *: "x < -y" using neg_less_iff_less[of "-y" x] by simp | |
| 1010 |   have "- (-y) \<in> uminus ` {x<..}"
 | |
| 1011 | by (rule imageI) (simp add: *) | |
| 1012 |   thus "y \<in> uminus ` {x<..}" by simp
 | |
| 1013 | next | |
| 1014 | fix y assume "y \<le> -x" | |
| 1015 |   have "- (-y) \<in> uminus ` {x..}"
 | |
| 60758 | 1016 | by (rule imageI) (insert \<open>y \<le> -x\<close>[THEN le_imp_neg_le], simp) | 
| 35580 | 1017 |   thus "y \<in> uminus ` {x..}" by simp
 | 
| 1018 | qed simp_all | |
| 1019 | ||
| 1020 | lemma | |
| 1021 | fixes x :: 'a | |
| 1022 |   shows image_uminus_lessThan[simp]: "uminus ` {..<x} = {-x<..}"
 | |
| 1023 |   and image_uminus_atMost[simp]: "uminus ` {..x} = {-x..}"
 | |
| 1024 | proof - | |
| 1025 |   have "uminus ` {..<x} = uminus ` uminus ` {-x<..}"
 | |
| 1026 |     and "uminus ` {..x} = uminus ` uminus ` {-x..}" by simp_all
 | |
| 1027 |   thus "uminus ` {..<x} = {-x<..}" and "uminus ` {..x} = {-x..}"
 | |
| 1028 | by (simp_all add: image_image | |
| 1029 | del: image_uminus_greaterThan image_uminus_atLeast) | |
| 1030 | qed | |
| 1031 | ||
| 1032 | lemma | |
| 1033 | fixes x :: 'a | |
| 1034 |   shows image_uminus_atLeastAtMost[simp]: "uminus ` {x..y} = {-y..-x}"
 | |
| 1035 |   and image_uminus_greaterThanAtMost[simp]: "uminus ` {x<..y} = {-y..<-x}"
 | |
| 1036 |   and image_uminus_atLeastLessThan[simp]: "uminus ` {x..<y} = {-y<..-x}"
 | |
| 1037 |   and image_uminus_greaterThanLessThan[simp]: "uminus ` {x<..<y} = {-y<..<-x}"
 | |
| 1038 | by (simp_all add: atLeastAtMost_def greaterThanAtMost_def atLeastLessThan_def | |
| 1039 | greaterThanLessThan_def image_Int[OF inj_uminus] Int_commute) | |
| 1040 | end | |
| 16733 
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
 nipkow parents: 
16102diff
changeset | 1041 | |
| 60758 | 1042 | subsubsection \<open>Finiteness\<close> | 
| 14485 | 1043 | |
| 15045 | 1044 | lemma finite_lessThan [iff]: fixes k :: nat shows "finite {..<k}"
 | 
| 14485 | 1045 | by (induct k) (simp_all add: lessThan_Suc) | 
| 1046 | ||
| 1047 | lemma finite_atMost [iff]: fixes k :: nat shows "finite {..k}"
 | |
| 1048 | by (induct k) (simp_all add: atMost_Suc) | |
| 1049 | ||
| 1050 | lemma finite_greaterThanLessThan [iff]: | |
| 15045 | 1051 |   fixes l :: nat shows "finite {l<..<u}"
 | 
| 14485 | 1052 | by (simp add: greaterThanLessThan_def) | 
| 1053 | ||
| 1054 | lemma finite_atLeastLessThan [iff]: | |
| 15045 | 1055 |   fixes l :: nat shows "finite {l..<u}"
 | 
| 14485 | 1056 | by (simp add: atLeastLessThan_def) | 
| 1057 | ||
| 1058 | lemma finite_greaterThanAtMost [iff]: | |
| 15045 | 1059 |   fixes l :: nat shows "finite {l<..u}"
 | 
| 14485 | 1060 | by (simp add: greaterThanAtMost_def) | 
| 1061 | ||
| 1062 | lemma finite_atLeastAtMost [iff]: | |
| 1063 |   fixes l :: nat shows "finite {l..u}"
 | |
| 1064 | by (simp add: atLeastAtMost_def) | |
| 1065 | ||
| 60758 | 1066 | text \<open>A bounded set of natural numbers is finite.\<close> | 
| 14485 | 1067 | lemma bounded_nat_set_is_finite: | 
| 24853 | 1068 | "(ALL i:N. i < (n::nat)) ==> finite N" | 
| 28068 | 1069 | apply (rule finite_subset) | 
| 1070 | apply (rule_tac [2] finite_lessThan, auto) | |
| 1071 | done | |
| 1072 | ||
| 60758 | 1073 | text \<open>A set of natural numbers is finite iff it is bounded.\<close> | 
| 31044 | 1074 | lemma finite_nat_set_iff_bounded: | 
| 1075 | "finite(N::nat set) = (EX m. ALL n:N. n<m)" (is "?F = ?B") | |
| 1076 | proof | |
| 1077 | assume f:?F show ?B | |
| 60758 | 1078 | using Max_ge[OF \<open>?F\<close>, simplified less_Suc_eq_le[symmetric]] by blast | 
| 31044 | 1079 | next | 
| 60758 | 1080 | assume ?B show ?F using \<open>?B\<close> by(blast intro:bounded_nat_set_is_finite) | 
| 31044 | 1081 | qed | 
| 1082 | ||
| 1083 | lemma finite_nat_set_iff_bounded_le: | |
| 1084 | "finite(N::nat set) = (EX m. ALL n:N. n<=m)" | |
| 1085 | apply(simp add:finite_nat_set_iff_bounded) | |
| 1086 | apply(blast dest:less_imp_le_nat le_imp_less_Suc) | |
| 1087 | done | |
| 1088 | ||
| 28068 | 1089 | lemma finite_less_ub: | 
| 1090 |      "!!f::nat=>nat. (!!n. n \<le> f n) ==> finite {n. f n \<le> u}"
 | |
| 1091 | by (rule_tac B="{..u}" in finite_subset, auto intro: order_trans)
 | |
| 14485 | 1092 | |
| 64773 
223b2ebdda79
Many new theorems, and more tidying
 paulson <lp15@cam.ac.uk> parents: 
64272diff
changeset | 1093 | lemma bounded_Max_nat: | 
| 
223b2ebdda79
Many new theorems, and more tidying
 paulson <lp15@cam.ac.uk> parents: 
64272diff
changeset | 1094 | fixes P :: "nat \<Rightarrow> bool" | 
| 
223b2ebdda79
Many new theorems, and more tidying
 paulson <lp15@cam.ac.uk> parents: 
64272diff
changeset | 1095 | assumes x: "P x" and M: "\<And>x. P x \<Longrightarrow> x \<le> M" | 
| 
223b2ebdda79
Many new theorems, and more tidying
 paulson <lp15@cam.ac.uk> parents: 
64272diff
changeset | 1096 | obtains m where "P m" "\<And>x. P x \<Longrightarrow> x \<le> m" | 
| 
223b2ebdda79
Many new theorems, and more tidying
 paulson <lp15@cam.ac.uk> parents: 
64272diff
changeset | 1097 | proof - | 
| 
223b2ebdda79
Many new theorems, and more tidying
 paulson <lp15@cam.ac.uk> parents: 
64272diff
changeset | 1098 |   have "finite {x. P x}"
 | 
| 
223b2ebdda79
Many new theorems, and more tidying
 paulson <lp15@cam.ac.uk> parents: 
64272diff
changeset | 1099 | using M finite_nat_set_iff_bounded_le by auto | 
| 
223b2ebdda79
Many new theorems, and more tidying
 paulson <lp15@cam.ac.uk> parents: 
64272diff
changeset | 1100 |   then have "Max {x. P x} \<in> {x. P x}"
 | 
| 
223b2ebdda79
Many new theorems, and more tidying
 paulson <lp15@cam.ac.uk> parents: 
64272diff
changeset | 1101 | using Max_in x by auto | 
| 
223b2ebdda79
Many new theorems, and more tidying
 paulson <lp15@cam.ac.uk> parents: 
64272diff
changeset | 1102 | then show ?thesis | 
| 
223b2ebdda79
Many new theorems, and more tidying
 paulson <lp15@cam.ac.uk> parents: 
64272diff
changeset | 1103 |     by (simp add: \<open>finite {x. P x}\<close> that)
 | 
| 
223b2ebdda79
Many new theorems, and more tidying
 paulson <lp15@cam.ac.uk> parents: 
64272diff
changeset | 1104 | qed | 
| 
223b2ebdda79
Many new theorems, and more tidying
 paulson <lp15@cam.ac.uk> parents: 
64272diff
changeset | 1105 | |
| 56328 | 1106 | |
| 60758 | 1107 | text\<open>Any subset of an interval of natural numbers the size of the | 
| 1108 | subset is exactly that interval.\<close> | |
| 24853 | 1109 | |
| 1110 | lemma subset_card_intvl_is_intvl: | |
| 55085 
0e8e4dc55866
moved 'fundef_cong' attribute (and other basic 'fun' stuff) up the dependency chain
 blanchet parents: 
54606diff
changeset | 1111 |   assumes "A \<subseteq> {k..<k + card A}"
 | 
| 
0e8e4dc55866
moved 'fundef_cong' attribute (and other basic 'fun' stuff) up the dependency chain
 blanchet parents: 
54606diff
changeset | 1112 |   shows "A = {k..<k + card A}"
 | 
| 53374 
a14d2a854c02
tuned proofs -- clarified flow of facts wrt. calculation;
 wenzelm parents: 
53216diff
changeset | 1113 | proof (cases "finite A") | 
| 
a14d2a854c02
tuned proofs -- clarified flow of facts wrt. calculation;
 wenzelm parents: 
53216diff
changeset | 1114 | case True | 
| 
a14d2a854c02
tuned proofs -- clarified flow of facts wrt. calculation;
 wenzelm parents: 
53216diff
changeset | 1115 | from this and assms show ?thesis | 
| 
a14d2a854c02
tuned proofs -- clarified flow of facts wrt. calculation;
 wenzelm parents: 
53216diff
changeset | 1116 | proof (induct A rule: finite_linorder_max_induct) | 
| 24853 | 1117 | case empty thus ?case by auto | 
| 1118 | next | |
| 33434 | 1119 | case (insert b A) | 
| 53374 
a14d2a854c02
tuned proofs -- clarified flow of facts wrt. calculation;
 wenzelm parents: 
53216diff
changeset | 1120 | hence *: "b \<notin> A" by auto | 
| 55085 
0e8e4dc55866
moved 'fundef_cong' attribute (and other basic 'fun' stuff) up the dependency chain
 blanchet parents: 
54606diff
changeset | 1121 |     with insert have "A <= {k..<k + card A}" and "b = k + card A"
 | 
| 53374 
a14d2a854c02
tuned proofs -- clarified flow of facts wrt. calculation;
 wenzelm parents: 
53216diff
changeset | 1122 | by fastforce+ | 
| 
a14d2a854c02
tuned proofs -- clarified flow of facts wrt. calculation;
 wenzelm parents: 
53216diff
changeset | 1123 | with insert * show ?case by auto | 
| 24853 | 1124 | qed | 
| 1125 | next | |
| 53374 
a14d2a854c02
tuned proofs -- clarified flow of facts wrt. calculation;
 wenzelm parents: 
53216diff
changeset | 1126 | case False | 
| 
a14d2a854c02
tuned proofs -- clarified flow of facts wrt. calculation;
 wenzelm parents: 
53216diff
changeset | 1127 | with assms show ?thesis by simp | 
| 24853 | 1128 | qed | 
| 1129 | ||
| 1130 | ||
| 60758 | 1131 | subsubsection \<open>Proving Inclusions and Equalities between Unions\<close> | 
| 32596 
bd68c04dace1
New theorems for proving equalities and inclusions involving unions
 paulson parents: 
32456diff
changeset | 1132 | |
| 36755 | 1133 | lemma UN_le_eq_Un0: | 
| 1134 |   "(\<Union>i\<le>n::nat. M i) = (\<Union>i\<in>{1..n}. M i) \<union> M 0" (is "?A = ?B")
 | |
| 1135 | proof | |
| 1136 | show "?A <= ?B" | |
| 1137 | proof | |
| 1138 | fix x assume "x : ?A" | |
| 1139 | then obtain i where i: "i\<le>n" "x : M i" by auto | |
| 1140 | show "x : ?B" | |
| 1141 | proof(cases i) | |
| 1142 | case 0 with i show ?thesis by simp | |
| 1143 | next | |
| 1144 | case (Suc j) with i show ?thesis by auto | |
| 1145 | qed | |
| 1146 | qed | |
| 1147 | next | |
| 63171 | 1148 | show "?B <= ?A" by fastforce | 
| 36755 | 1149 | qed | 
| 1150 | ||
| 1151 | lemma UN_le_add_shift: | |
| 1152 |   "(\<Union>i\<le>n::nat. M(i+k)) = (\<Union>i\<in>{k..n+k}. M i)" (is "?A = ?B")
 | |
| 1153 | proof | |
| 44890 
22f665a2e91c
new fastforce replacing fastsimp - less confusing name
 nipkow parents: 
44008diff
changeset | 1154 | show "?A <= ?B" by fastforce | 
| 36755 | 1155 | next | 
| 1156 | show "?B <= ?A" | |
| 1157 | proof | |
| 1158 | fix x assume "x : ?B" | |
| 1159 |     then obtain i where i: "i : {k..n+k}" "x : M(i)" by auto
 | |
| 1160 | hence "i-k\<le>n & x : M((i-k)+k)" by auto | |
| 1161 | thus "x : ?A" by blast | |
| 1162 | qed | |
| 1163 | qed | |
| 1164 | ||
| 62369 | 1165 | lemma UN_UN_finite_eq: "(\<Union>n::nat. \<Union>i\<in>{0..<n}. A i) = (\<Union>n. A n)"
 | 
| 1166 | by (auto simp add: atLeast0LessThan) | |
| 32596 
bd68c04dace1
New theorems for proving equalities and inclusions involving unions
 paulson parents: 
32456diff
changeset | 1167 | |
| 62343 
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
 haftmann parents: 
62128diff
changeset | 1168 | lemma UN_finite_subset: | 
| 
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
 haftmann parents: 
62128diff
changeset | 1169 |   "(\<And>n::nat. (\<Union>i\<in>{0..<n}. A i) \<subseteq> C) \<Longrightarrow> (\<Union>n. A n) \<subseteq> C"
 | 
| 32596 
bd68c04dace1
New theorems for proving equalities and inclusions involving unions
 paulson parents: 
32456diff
changeset | 1170 | by (subst UN_UN_finite_eq [symmetric]) blast | 
| 
bd68c04dace1
New theorems for proving equalities and inclusions involving unions
 paulson parents: 
32456diff
changeset | 1171 | |
| 62369 | 1172 | lemma UN_finite2_subset: | 
| 62343 
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
 haftmann parents: 
62128diff
changeset | 1173 |   assumes "\<And>n::nat. (\<Union>i\<in>{0..<n}. A i) \<subseteq> (\<Union>i\<in>{0..<n + k}. B i)"
 | 
| 
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
 haftmann parents: 
62128diff
changeset | 1174 | shows "(\<Union>n. A n) \<subseteq> (\<Union>n. B n)" | 
| 
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
 haftmann parents: 
62128diff
changeset | 1175 | proof (rule UN_finite_subset, rule) | 
| 
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
 haftmann parents: 
62128diff
changeset | 1176 | fix n and a | 
| 
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
 haftmann parents: 
62128diff
changeset | 1177 |   from assms have "(\<Union>i\<in>{0..<n}. A i) \<subseteq> (\<Union>i\<in>{0..<n + k}. B i)" .
 | 
| 
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
 haftmann parents: 
62128diff
changeset | 1178 |   moreover assume "a \<in> (\<Union>i\<in>{0..<n}. A i)"
 | 
| 
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
 haftmann parents: 
62128diff
changeset | 1179 |   ultimately have "a \<in> (\<Union>i\<in>{0..<n + k}. B i)" by blast
 | 
| 
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
 haftmann parents: 
62128diff
changeset | 1180 | then show "a \<in> (\<Union>i. B i)" by (auto simp add: UN_UN_finite_eq) | 
| 
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
 haftmann parents: 
62128diff
changeset | 1181 | qed | 
| 32596 
bd68c04dace1
New theorems for proving equalities and inclusions involving unions
 paulson parents: 
32456diff
changeset | 1182 | |
| 
bd68c04dace1
New theorems for proving equalities and inclusions involving unions
 paulson parents: 
32456diff
changeset | 1183 | lemma UN_finite2_eq: | 
| 62343 
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
 haftmann parents: 
62128diff
changeset | 1184 |   "(\<And>n::nat. (\<Union>i\<in>{0..<n}. A i) = (\<Union>i\<in>{0..<n + k}. B i)) \<Longrightarrow>
 | 
| 
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
 haftmann parents: 
62128diff
changeset | 1185 | (\<Union>n. A n) = (\<Union>n. B n)" | 
| 33044 | 1186 | apply (rule subset_antisym) | 
| 1187 | apply (rule UN_finite2_subset, blast) | |
| 62343 
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
 haftmann parents: 
62128diff
changeset | 1188 | apply (rule UN_finite2_subset [where k=k]) | 
| 
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
 haftmann parents: 
62128diff
changeset | 1189 | apply (force simp add: atLeastLessThan_add_Un [of 0]) | 
| 
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
 haftmann parents: 
62128diff
changeset | 1190 | done | 
| 32596 
bd68c04dace1
New theorems for proving equalities and inclusions involving unions
 paulson parents: 
32456diff
changeset | 1191 | |
| 
bd68c04dace1
New theorems for proving equalities and inclusions involving unions
 paulson parents: 
32456diff
changeset | 1192 | |
| 60758 | 1193 | subsubsection \<open>Cardinality\<close> | 
| 14485 | 1194 | |
| 15045 | 1195 | lemma card_lessThan [simp]: "card {..<u} = u"
 | 
| 15251 | 1196 | by (induct u, simp_all add: lessThan_Suc) | 
| 14485 | 1197 | |
| 1198 | lemma card_atMost [simp]: "card {..u} = Suc u"
 | |
| 1199 | by (simp add: lessThan_Suc_atMost [THEN sym]) | |
| 1200 | ||
| 15045 | 1201 | lemma card_atLeastLessThan [simp]: "card {l..<u} = u - l"
 | 
| 57113 
7e95523302e6
New theorems to enable the simplification of certain functions when applied to specific natural number constants (such as 4)
 paulson <lp15@cam.ac.uk> parents: 
56949diff
changeset | 1202 | proof - | 
| 
7e95523302e6
New theorems to enable the simplification of certain functions when applied to specific natural number constants (such as 4)
 paulson <lp15@cam.ac.uk> parents: 
56949diff
changeset | 1203 |   have "{l..<u} = (%x. x + l) ` {..<u-l}"
 | 
| 
7e95523302e6
New theorems to enable the simplification of certain functions when applied to specific natural number constants (such as 4)
 paulson <lp15@cam.ac.uk> parents: 
56949diff
changeset | 1204 | apply (auto simp add: image_def atLeastLessThan_def lessThan_def) | 
| 
7e95523302e6
New theorems to enable the simplification of certain functions when applied to specific natural number constants (such as 4)
 paulson <lp15@cam.ac.uk> parents: 
56949diff
changeset | 1205 | apply (rule_tac x = "x - l" in exI) | 
| 
7e95523302e6
New theorems to enable the simplification of certain functions when applied to specific natural number constants (such as 4)
 paulson <lp15@cam.ac.uk> parents: 
56949diff
changeset | 1206 | apply arith | 
| 
7e95523302e6
New theorems to enable the simplification of certain functions when applied to specific natural number constants (such as 4)
 paulson <lp15@cam.ac.uk> parents: 
56949diff
changeset | 1207 | done | 
| 
7e95523302e6
New theorems to enable the simplification of certain functions when applied to specific natural number constants (such as 4)
 paulson <lp15@cam.ac.uk> parents: 
56949diff
changeset | 1208 |   then have "card {l..<u} = card {..<u-l}"
 | 
| 
7e95523302e6
New theorems to enable the simplification of certain functions when applied to specific natural number constants (such as 4)
 paulson <lp15@cam.ac.uk> parents: 
56949diff
changeset | 1209 | by (simp add: card_image inj_on_def) | 
| 
7e95523302e6
New theorems to enable the simplification of certain functions when applied to specific natural number constants (such as 4)
 paulson <lp15@cam.ac.uk> parents: 
56949diff
changeset | 1210 | then show ?thesis | 
| 
7e95523302e6
New theorems to enable the simplification of certain functions when applied to specific natural number constants (such as 4)
 paulson <lp15@cam.ac.uk> parents: 
56949diff
changeset | 1211 | by simp | 
| 
7e95523302e6
New theorems to enable the simplification of certain functions when applied to specific natural number constants (such as 4)
 paulson <lp15@cam.ac.uk> parents: 
56949diff
changeset | 1212 | qed | 
| 14485 | 1213 | |
| 15418 
e28853da5df5
removed two looping simplifications in SetInterval.thy; deleted the .ML file
 paulson parents: 
15402diff
changeset | 1214 | lemma card_atLeastAtMost [simp]: "card {l..u} = Suc u - l"
 | 
| 14485 | 1215 | by (subst atLeastLessThanSuc_atLeastAtMost [THEN sym], simp) | 
| 1216 | ||
| 15418 
e28853da5df5
removed two looping simplifications in SetInterval.thy; deleted the .ML file
 paulson parents: 
15402diff
changeset | 1217 | lemma card_greaterThanAtMost [simp]: "card {l<..u} = u - l"
 | 
| 14485 | 1218 | by (subst atLeastSucAtMost_greaterThanAtMost [THEN sym], simp) | 
| 1219 | ||
| 15045 | 1220 | lemma card_greaterThanLessThan [simp]: "card {l<..<u} = u - Suc l"
 | 
| 14485 | 1221 | by (subst atLeastSucLessThan_greaterThanLessThan [THEN sym], simp) | 
| 1222 | ||
| 63417 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1223 | lemma subset_eq_atLeast0_lessThan_finite: | 
| 63365 | 1224 | fixes n :: nat | 
| 63417 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1225 |   assumes "N \<subseteq> {0..<n}"
 | 
| 63915 | 1226 | shows "finite N" | 
| 63417 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1227 | using assms finite_atLeastLessThan by (rule finite_subset) | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1228 | |
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1229 | lemma subset_eq_atLeast0_atMost_finite: | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1230 | fixes n :: nat | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1231 |   assumes "N \<subseteq> {0..n}"
 | 
| 63915 | 1232 | shows "finite N" | 
| 63417 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1233 | using assms finite_atLeastAtMost by (rule finite_subset) | 
| 63365 | 1234 | |
| 26105 
ae06618225ec
moved bij_betw from Library/FuncSet to Fun, redistributed some lemmas, and
 nipkow parents: 
26072diff
changeset | 1235 | lemma ex_bij_betw_nat_finite: | 
| 
ae06618225ec
moved bij_betw from Library/FuncSet to Fun, redistributed some lemmas, and
 nipkow parents: 
26072diff
changeset | 1236 |   "finite M \<Longrightarrow> \<exists>h. bij_betw h {0..<card M} M"
 | 
| 
ae06618225ec
moved bij_betw from Library/FuncSet to Fun, redistributed some lemmas, and
 nipkow parents: 
26072diff
changeset | 1237 | apply(drule finite_imp_nat_seg_image_inj_on) | 
| 
ae06618225ec
moved bij_betw from Library/FuncSet to Fun, redistributed some lemmas, and
 nipkow parents: 
26072diff
changeset | 1238 | apply(auto simp:atLeast0LessThan[symmetric] lessThan_def[symmetric] card_image bij_betw_def) | 
| 
ae06618225ec
moved bij_betw from Library/FuncSet to Fun, redistributed some lemmas, and
 nipkow parents: 
26072diff
changeset | 1239 | done | 
| 
ae06618225ec
moved bij_betw from Library/FuncSet to Fun, redistributed some lemmas, and
 nipkow parents: 
26072diff
changeset | 1240 | |
| 
ae06618225ec
moved bij_betw from Library/FuncSet to Fun, redistributed some lemmas, and
 nipkow parents: 
26072diff
changeset | 1241 | lemma ex_bij_betw_finite_nat: | 
| 
ae06618225ec
moved bij_betw from Library/FuncSet to Fun, redistributed some lemmas, and
 nipkow parents: 
26072diff
changeset | 1242 |   "finite M \<Longrightarrow> \<exists>h. bij_betw h M {0..<card M}"
 | 
| 
ae06618225ec
moved bij_betw from Library/FuncSet to Fun, redistributed some lemmas, and
 nipkow parents: 
26072diff
changeset | 1243 | by (blast dest: ex_bij_betw_nat_finite bij_betw_inv) | 
| 
ae06618225ec
moved bij_betw from Library/FuncSet to Fun, redistributed some lemmas, and
 nipkow parents: 
26072diff
changeset | 1244 | |
| 31438 | 1245 | lemma finite_same_card_bij: | 
| 1246 | "finite A \<Longrightarrow> finite B \<Longrightarrow> card A = card B \<Longrightarrow> EX h. bij_betw h A B" | |
| 1247 | apply(drule ex_bij_betw_finite_nat) | |
| 1248 | apply(drule ex_bij_betw_nat_finite) | |
| 1249 | apply(auto intro!:bij_betw_trans) | |
| 1250 | done | |
| 1251 | ||
| 1252 | lemma ex_bij_betw_nat_finite_1: | |
| 1253 |   "finite M \<Longrightarrow> \<exists>h. bij_betw h {1 .. card M} M"
 | |
| 1254 | by (rule finite_same_card_bij) auto | |
| 1255 | ||
| 40703 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
39302diff
changeset | 1256 | lemma bij_betw_iff_card: | 
| 63114 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63099diff
changeset | 1257 | assumes "finite A" "finite B" | 
| 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63099diff
changeset | 1258 | shows "(\<exists>f. bij_betw f A B) \<longleftrightarrow> (card A = card B)" | 
| 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63099diff
changeset | 1259 | proof | 
| 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63099diff
changeset | 1260 | assume "card A = card B" | 
| 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63099diff
changeset | 1261 |   moreover obtain f where "bij_betw f A {0 ..< card A}"
 | 
| 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63099diff
changeset | 1262 | using assms ex_bij_betw_finite_nat by blast | 
| 40703 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
39302diff
changeset | 1263 |   moreover obtain g where "bij_betw g {0 ..< card B} B"
 | 
| 63114 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63099diff
changeset | 1264 | using assms ex_bij_betw_nat_finite by blast | 
| 40703 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
39302diff
changeset | 1265 | ultimately have "bij_betw (g o f) A B" | 
| 63114 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63099diff
changeset | 1266 | by (auto simp: bij_betw_trans) | 
| 40703 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
39302diff
changeset | 1267 | thus "(\<exists>f. bij_betw f A B)" by blast | 
| 63114 
27afe7af7379
Lots of new material for multivariate analysis
 paulson <lp15@cam.ac.uk> parents: 
63099diff
changeset | 1268 | qed (auto simp: bij_betw_same_card) | 
| 40703 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
39302diff
changeset | 1269 | |
| 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
39302diff
changeset | 1270 | lemma inj_on_iff_card_le: | 
| 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
39302diff
changeset | 1271 | assumes FIN: "finite A" and FIN': "finite B" | 
| 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
39302diff
changeset | 1272 | shows "(\<exists>f. inj_on f A \<and> f ` A \<le> B) = (card A \<le> card B)" | 
| 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
39302diff
changeset | 1273 | proof (safe intro!: card_inj_on_le) | 
| 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
39302diff
changeset | 1274 | assume *: "card A \<le> card B" | 
| 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
39302diff
changeset | 1275 |   obtain f where 1: "inj_on f A" and 2: "f ` A = {0 ..< card A}"
 | 
| 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
39302diff
changeset | 1276 | using FIN ex_bij_betw_finite_nat unfolding bij_betw_def by force | 
| 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
39302diff
changeset | 1277 |   moreover obtain g where "inj_on g {0 ..< card B}" and 3: "g ` {0 ..< card B} = B"
 | 
| 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
39302diff
changeset | 1278 | using FIN' ex_bij_betw_nat_finite unfolding bij_betw_def by force | 
| 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
39302diff
changeset | 1279 | ultimately have "inj_on g (f ` A)" using subset_inj_on[of g _ "f ` A"] * by force | 
| 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
39302diff
changeset | 1280 | hence "inj_on (g o f) A" using 1 comp_inj_on by blast | 
| 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
39302diff
changeset | 1281 | moreover | 
| 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
39302diff
changeset | 1282 |   {have "{0 ..< card A} \<le> {0 ..< card B}" using * by force
 | 
| 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
39302diff
changeset | 1283 |    with 2 have "f ` A  \<le> {0 ..< card B}" by blast
 | 
| 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
39302diff
changeset | 1284 | hence "(g o f) ` A \<le> B" unfolding comp_def using 3 by force | 
| 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
39302diff
changeset | 1285 | } | 
| 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
39302diff
changeset | 1286 | ultimately show "(\<exists>f. inj_on f A \<and> f ` A \<le> B)" by blast | 
| 
d1fc454d6735
Move some missing lemmas from Andrei Popescus 'Ordinals and Cardinals' AFP entry to the HOL-image.
 hoelzl parents: 
39302diff
changeset | 1287 | qed (insert assms, auto) | 
| 26105 
ae06618225ec
moved bij_betw from Library/FuncSet to Fun, redistributed some lemmas, and
 nipkow parents: 
26072diff
changeset | 1288 | |
| 63417 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1289 | lemma subset_eq_atLeast0_lessThan_card: | 
| 63365 | 1290 | fixes n :: nat | 
| 63417 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1291 |   assumes "N \<subseteq> {0..<n}"
 | 
| 63365 | 1292 | shows "card N \<le> n" | 
| 1293 | proof - | |
| 63417 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1294 |   from assms finite_lessThan have "card N \<le> card {0..<n}"
 | 
| 63365 | 1295 | using card_mono by blast | 
| 1296 | then show ?thesis by simp | |
| 1297 | qed | |
| 1298 | ||
| 1299 | ||
| 60758 | 1300 | subsection \<open>Intervals of integers\<close> | 
| 14485 | 1301 | |
| 15045 | 1302 | lemma atLeastLessThanPlusOne_atLeastAtMost_int: "{l..<u+1} = {l..(u::int)}"
 | 
| 14485 | 1303 | by (auto simp add: atLeastAtMost_def atLeastLessThan_def) | 
| 1304 | ||
| 15418 
e28853da5df5
removed two looping simplifications in SetInterval.thy; deleted the .ML file
 paulson parents: 
15402diff
changeset | 1305 | lemma atLeastPlusOneAtMost_greaterThanAtMost_int: "{l+1..u} = {l<..(u::int)}"
 | 
| 14485 | 1306 | by (auto simp add: atLeastAtMost_def greaterThanAtMost_def) | 
| 1307 | ||
| 15418 
e28853da5df5
removed two looping simplifications in SetInterval.thy; deleted the .ML file
 paulson parents: 
15402diff
changeset | 1308 | lemma atLeastPlusOneLessThan_greaterThanLessThan_int: | 
| 
e28853da5df5
removed two looping simplifications in SetInterval.thy; deleted the .ML file
 paulson parents: 
15402diff
changeset | 1309 |     "{l+1..<u} = {l<..<u::int}"
 | 
| 14485 | 1310 | by (auto simp add: atLeastLessThan_def greaterThanLessThan_def) | 
| 1311 | ||
| 60758 | 1312 | subsubsection \<open>Finiteness\<close> | 
| 14485 | 1313 | |
| 15418 
e28853da5df5
removed two looping simplifications in SetInterval.thy; deleted the .ML file
 paulson parents: 
15402diff
changeset | 1314 | lemma image_atLeastZeroLessThan_int: "0 \<le> u ==> | 
| 15045 | 1315 |     {(0::int)..<u} = int ` {..<nat u}"
 | 
| 14485 | 1316 | apply (unfold image_def lessThan_def) | 
| 1317 | apply auto | |
| 1318 | apply (rule_tac x = "nat x" in exI) | |
| 35216 | 1319 | apply (auto simp add: zless_nat_eq_int_zless [THEN sym]) | 
| 14485 | 1320 | done | 
| 1321 | ||
| 15045 | 1322 | lemma finite_atLeastZeroLessThan_int: "finite {(0::int)..<u}"
 | 
| 47988 | 1323 | apply (cases "0 \<le> u") | 
| 14485 | 1324 | apply (subst image_atLeastZeroLessThan_int, assumption) | 
| 1325 | apply (rule finite_imageI) | |
| 1326 | apply auto | |
| 1327 | done | |
| 1328 | ||
| 15045 | 1329 | lemma finite_atLeastLessThan_int [iff]: "finite {l..<u::int}"
 | 
| 1330 |   apply (subgoal_tac "(%x. x + l) ` {0..<u-l} = {l..<u}")
 | |
| 14485 | 1331 | apply (erule subst) | 
| 1332 | apply (rule finite_imageI) | |
| 1333 | apply (rule finite_atLeastZeroLessThan_int) | |
| 16733 
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
 nipkow parents: 
16102diff
changeset | 1334 | apply (rule image_add_int_atLeastLessThan) | 
| 14485 | 1335 | done | 
| 1336 | ||
| 15418 
e28853da5df5
removed two looping simplifications in SetInterval.thy; deleted the .ML file
 paulson parents: 
15402diff
changeset | 1337 | lemma finite_atLeastAtMost_int [iff]: "finite {l..(u::int)}"
 | 
| 14485 | 1338 | by (subst atLeastLessThanPlusOne_atLeastAtMost_int [THEN sym], simp) | 
| 1339 | ||
| 15418 
e28853da5df5
removed two looping simplifications in SetInterval.thy; deleted the .ML file
 paulson parents: 
15402diff
changeset | 1340 | lemma finite_greaterThanAtMost_int [iff]: "finite {l<..(u::int)}"
 | 
| 14485 | 1341 | by (subst atLeastPlusOneAtMost_greaterThanAtMost_int [THEN sym], simp) | 
| 1342 | ||
| 15418 
e28853da5df5
removed two looping simplifications in SetInterval.thy; deleted the .ML file
 paulson parents: 
15402diff
changeset | 1343 | lemma finite_greaterThanLessThan_int [iff]: "finite {l<..<u::int}"
 | 
| 14485 | 1344 | by (subst atLeastPlusOneLessThan_greaterThanLessThan_int [THEN sym], simp) | 
| 1345 | ||
| 24853 | 1346 | |
| 60758 | 1347 | subsubsection \<open>Cardinality\<close> | 
| 14485 | 1348 | |
| 15045 | 1349 | lemma card_atLeastZeroLessThan_int: "card {(0::int)..<u} = nat u"
 | 
| 47988 | 1350 | apply (cases "0 \<le> u") | 
| 14485 | 1351 | apply (subst image_atLeastZeroLessThan_int, assumption) | 
| 1352 | apply (subst card_image) | |
| 1353 | apply (auto simp add: inj_on_def) | |
| 1354 | done | |
| 1355 | ||
| 15045 | 1356 | lemma card_atLeastLessThan_int [simp]: "card {l..<u} = nat (u - l)"
 | 
| 1357 |   apply (subgoal_tac "card {l..<u} = card {0..<u-l}")
 | |
| 14485 | 1358 | apply (erule ssubst, rule card_atLeastZeroLessThan_int) | 
| 15045 | 1359 |   apply (subgoal_tac "(%x. x + l) ` {0..<u-l} = {l..<u}")
 | 
| 14485 | 1360 | apply (erule subst) | 
| 1361 | apply (rule card_image) | |
| 1362 | apply (simp add: inj_on_def) | |
| 16733 
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
 nipkow parents: 
16102diff
changeset | 1363 | apply (rule image_add_int_atLeastLessThan) | 
| 14485 | 1364 | done | 
| 1365 | ||
| 1366 | lemma card_atLeastAtMost_int [simp]: "card {l..u} = nat (u - l + 1)"
 | |
| 29667 | 1367 | apply (subst atLeastLessThanPlusOne_atLeastAtMost_int [THEN sym]) | 
| 1368 | apply (auto simp add: algebra_simps) | |
| 1369 | done | |
| 14485 | 1370 | |
| 15418 
e28853da5df5
removed two looping simplifications in SetInterval.thy; deleted the .ML file
 paulson parents: 
15402diff
changeset | 1371 | lemma card_greaterThanAtMost_int [simp]: "card {l<..u} = nat (u - l)"
 | 
| 29667 | 1372 | by (subst atLeastPlusOneAtMost_greaterThanAtMost_int [THEN sym], simp) | 
| 14485 | 1373 | |
| 15045 | 1374 | lemma card_greaterThanLessThan_int [simp]: "card {l<..<u} = nat (u - (l + 1))"
 | 
| 29667 | 1375 | by (subst atLeastPlusOneLessThan_greaterThanLessThan_int [THEN sym], simp) | 
| 14485 | 1376 | |
| 27656 
d4f6e64ee7cc
added verification framework for the HeapMonad and quicksort as example for this framework
 bulwahn parents: 
26105diff
changeset | 1377 | lemma finite_M_bounded_by_nat: "finite {k. P k \<and> k < (i::nat)}"
 | 
| 
d4f6e64ee7cc
added verification framework for the HeapMonad and quicksort as example for this framework
 bulwahn parents: 
26105diff
changeset | 1378 | proof - | 
| 
d4f6e64ee7cc
added verification framework for the HeapMonad and quicksort as example for this framework
 bulwahn parents: 
26105diff
changeset | 1379 |   have "{k. P k \<and> k < i} \<subseteq> {..<i}" by auto
 | 
| 
d4f6e64ee7cc
added verification framework for the HeapMonad and quicksort as example for this framework
 bulwahn parents: 
26105diff
changeset | 1380 | with finite_lessThan[of "i"] show ?thesis by (simp add: finite_subset) | 
| 
d4f6e64ee7cc
added verification framework for the HeapMonad and quicksort as example for this framework
 bulwahn parents: 
26105diff
changeset | 1381 | qed | 
| 
d4f6e64ee7cc
added verification framework for the HeapMonad and quicksort as example for this framework
 bulwahn parents: 
26105diff
changeset | 1382 | |
| 
d4f6e64ee7cc
added verification framework for the HeapMonad and quicksort as example for this framework
 bulwahn parents: 
26105diff
changeset | 1383 | lemma card_less: | 
| 
d4f6e64ee7cc
added verification framework for the HeapMonad and quicksort as example for this framework
 bulwahn parents: 
26105diff
changeset | 1384 | assumes zero_in_M: "0 \<in> M" | 
| 
d4f6e64ee7cc
added verification framework for the HeapMonad and quicksort as example for this framework
 bulwahn parents: 
26105diff
changeset | 1385 | shows "card {k \<in> M. k < Suc i} \<noteq> 0"
 | 
| 
d4f6e64ee7cc
added verification framework for the HeapMonad and quicksort as example for this framework
 bulwahn parents: 
26105diff
changeset | 1386 | proof - | 
| 
d4f6e64ee7cc
added verification framework for the HeapMonad and quicksort as example for this framework
 bulwahn parents: 
26105diff
changeset | 1387 |   from zero_in_M have "{k \<in> M. k < Suc i} \<noteq> {}" by auto
 | 
| 
d4f6e64ee7cc
added verification framework for the HeapMonad and quicksort as example for this framework
 bulwahn parents: 
26105diff
changeset | 1388 | with finite_M_bounded_by_nat show ?thesis by (auto simp add: card_eq_0_iff) | 
| 
d4f6e64ee7cc
added verification framework for the HeapMonad and quicksort as example for this framework
 bulwahn parents: 
26105diff
changeset | 1389 | qed | 
| 
d4f6e64ee7cc
added verification framework for the HeapMonad and quicksort as example for this framework
 bulwahn parents: 
26105diff
changeset | 1390 | |
| 
d4f6e64ee7cc
added verification framework for the HeapMonad and quicksort as example for this framework
 bulwahn parents: 
26105diff
changeset | 1391 | lemma card_less_Suc2: "0 \<notin> M \<Longrightarrow> card {k. Suc k \<in> M \<and> k < i} = card {k \<in> M. k < Suc i}"
 | 
| 37388 | 1392 | apply (rule card_bij_eq [of Suc _ _ "\<lambda>x. x - Suc 0"]) | 
| 27656 
d4f6e64ee7cc
added verification framework for the HeapMonad and quicksort as example for this framework
 bulwahn parents: 
26105diff
changeset | 1393 | apply auto | 
| 
d4f6e64ee7cc
added verification framework for the HeapMonad and quicksort as example for this framework
 bulwahn parents: 
26105diff
changeset | 1394 | apply (rule inj_on_diff_nat) | 
| 
d4f6e64ee7cc
added verification framework for the HeapMonad and quicksort as example for this framework
 bulwahn parents: 
26105diff
changeset | 1395 | apply auto | 
| 
d4f6e64ee7cc
added verification framework for the HeapMonad and quicksort as example for this framework
 bulwahn parents: 
26105diff
changeset | 1396 | apply (case_tac x) | 
| 
d4f6e64ee7cc
added verification framework for the HeapMonad and quicksort as example for this framework
 bulwahn parents: 
26105diff
changeset | 1397 | apply auto | 
| 
d4f6e64ee7cc
added verification framework for the HeapMonad and quicksort as example for this framework
 bulwahn parents: 
26105diff
changeset | 1398 | apply (case_tac xa) | 
| 
d4f6e64ee7cc
added verification framework for the HeapMonad and quicksort as example for this framework
 bulwahn parents: 
26105diff
changeset | 1399 | apply auto | 
| 
d4f6e64ee7cc
added verification framework for the HeapMonad and quicksort as example for this framework
 bulwahn parents: 
26105diff
changeset | 1400 | apply (case_tac xa) | 
| 
d4f6e64ee7cc
added verification framework for the HeapMonad and quicksort as example for this framework
 bulwahn parents: 
26105diff
changeset | 1401 | apply auto | 
| 
d4f6e64ee7cc
added verification framework for the HeapMonad and quicksort as example for this framework
 bulwahn parents: 
26105diff
changeset | 1402 | done | 
| 
d4f6e64ee7cc
added verification framework for the HeapMonad and quicksort as example for this framework
 bulwahn parents: 
26105diff
changeset | 1403 | |
| 
d4f6e64ee7cc
added verification framework for the HeapMonad and quicksort as example for this framework
 bulwahn parents: 
26105diff
changeset | 1404 | lemma card_less_Suc: | 
| 
d4f6e64ee7cc
added verification framework for the HeapMonad and quicksort as example for this framework
 bulwahn parents: 
26105diff
changeset | 1405 | assumes zero_in_M: "0 \<in> M" | 
| 
d4f6e64ee7cc
added verification framework for the HeapMonad and quicksort as example for this framework
 bulwahn parents: 
26105diff
changeset | 1406 |     shows "Suc (card {k. Suc k \<in> M \<and> k < i}) = card {k \<in> M. k < Suc i}"
 | 
| 
d4f6e64ee7cc
added verification framework for the HeapMonad and quicksort as example for this framework
 bulwahn parents: 
26105diff
changeset | 1407 | proof - | 
| 
d4f6e64ee7cc
added verification framework for the HeapMonad and quicksort as example for this framework
 bulwahn parents: 
26105diff
changeset | 1408 |   from assms have a: "0 \<in> {k \<in> M. k < Suc i}" by simp
 | 
| 
d4f6e64ee7cc
added verification framework for the HeapMonad and quicksort as example for this framework
 bulwahn parents: 
26105diff
changeset | 1409 |   hence c: "{k \<in> M. k < Suc i} = insert 0 ({k \<in> M. k < Suc i} - {0})"
 | 
| 
d4f6e64ee7cc
added verification framework for the HeapMonad and quicksort as example for this framework
 bulwahn parents: 
26105diff
changeset | 1410 | by (auto simp only: insert_Diff) | 
| 
d4f6e64ee7cc
added verification framework for the HeapMonad and quicksort as example for this framework
 bulwahn parents: 
26105diff
changeset | 1411 |   have b: "{k \<in> M. k < Suc i} - {0} = {k \<in> M - {0}. k < Suc i}"  by auto
 | 
| 62369 | 1412 | from finite_M_bounded_by_nat[of "\<lambda>x. x \<in> M" "Suc i"] | 
| 57113 
7e95523302e6
New theorems to enable the simplification of certain functions when applied to specific natural number constants (such as 4)
 paulson <lp15@cam.ac.uk> parents: 
56949diff
changeset | 1413 |   have "Suc (card {k. Suc k \<in> M \<and> k < i}) = card (insert 0 ({k \<in> M. k < Suc i} - {0}))"
 | 
| 27656 
d4f6e64ee7cc
added verification framework for the HeapMonad and quicksort as example for this framework
 bulwahn parents: 
26105diff
changeset | 1414 | apply (subst card_insert) | 
| 
d4f6e64ee7cc
added verification framework for the HeapMonad and quicksort as example for this framework
 bulwahn parents: 
26105diff
changeset | 1415 | apply simp_all | 
| 
d4f6e64ee7cc
added verification framework for the HeapMonad and quicksort as example for this framework
 bulwahn parents: 
26105diff
changeset | 1416 | apply (subst b) | 
| 
d4f6e64ee7cc
added verification framework for the HeapMonad and quicksort as example for this framework
 bulwahn parents: 
26105diff
changeset | 1417 | apply (subst card_less_Suc2[symmetric]) | 
| 
d4f6e64ee7cc
added verification framework for the HeapMonad and quicksort as example for this framework
 bulwahn parents: 
26105diff
changeset | 1418 | apply simp_all | 
| 
d4f6e64ee7cc
added verification framework for the HeapMonad and quicksort as example for this framework
 bulwahn parents: 
26105diff
changeset | 1419 | done | 
| 
d4f6e64ee7cc
added verification framework for the HeapMonad and quicksort as example for this framework
 bulwahn parents: 
26105diff
changeset | 1420 | with c show ?thesis by simp | 
| 
d4f6e64ee7cc
added verification framework for the HeapMonad and quicksort as example for this framework
 bulwahn parents: 
26105diff
changeset | 1421 | qed | 
| 
d4f6e64ee7cc
added verification framework for the HeapMonad and quicksort as example for this framework
 bulwahn parents: 
26105diff
changeset | 1422 | |
| 14485 | 1423 | |
| 64267 | 1424 | subsection \<open>Lemmas useful with the summation operator sum\<close> | 
| 13850 | 1425 | |
| 60758 | 1426 | text \<open>For examples, see Algebra/poly/UnivPoly2.thy\<close> | 
| 13735 | 1427 | |
| 60758 | 1428 | subsubsection \<open>Disjoint Unions\<close> | 
| 13735 | 1429 | |
| 60758 | 1430 | text \<open>Singletons and open intervals\<close> | 
| 13735 | 1431 | |
| 1432 | lemma ivl_disj_un_singleton: | |
| 15045 | 1433 |   "{l::'a::linorder} Un {l<..} = {l..}"
 | 
| 1434 |   "{..<u} Un {u::'a::linorder} = {..u}"
 | |
| 1435 |   "(l::'a::linorder) < u ==> {l} Un {l<..<u} = {l..<u}"
 | |
| 1436 |   "(l::'a::linorder) < u ==> {l<..<u} Un {u} = {l<..u}"
 | |
| 1437 |   "(l::'a::linorder) <= u ==> {l} Un {l<..u} = {l..u}"
 | |
| 1438 |   "(l::'a::linorder) <= u ==> {l..<u} Un {u} = {l..u}"
 | |
| 14398 
c5c47703f763
Efficient, graph-based reasoner for linear and partial orders.
 ballarin parents: 
13850diff
changeset | 1439 | by auto | 
| 13735 | 1440 | |
| 60758 | 1441 | text \<open>One- and two-sided intervals\<close> | 
| 13735 | 1442 | |
| 1443 | lemma ivl_disj_un_one: | |
| 15045 | 1444 |   "(l::'a::linorder) < u ==> {..l} Un {l<..<u} = {..<u}"
 | 
| 1445 |   "(l::'a::linorder) <= u ==> {..<l} Un {l..<u} = {..<u}"
 | |
| 1446 |   "(l::'a::linorder) <= u ==> {..l} Un {l<..u} = {..u}"
 | |
| 1447 |   "(l::'a::linorder) <= u ==> {..<l} Un {l..u} = {..u}"
 | |
| 1448 |   "(l::'a::linorder) <= u ==> {l<..u} Un {u<..} = {l<..}"
 | |
| 1449 |   "(l::'a::linorder) < u ==> {l<..<u} Un {u..} = {l<..}"
 | |
| 1450 |   "(l::'a::linorder) <= u ==> {l..u} Un {u<..} = {l..}"
 | |
| 1451 |   "(l::'a::linorder) <= u ==> {l..<u} Un {u..} = {l..}"
 | |
| 14398 
c5c47703f763
Efficient, graph-based reasoner for linear and partial orders.
 ballarin parents: 
13850diff
changeset | 1452 | by auto | 
| 13735 | 1453 | |
| 60758 | 1454 | text \<open>Two- and two-sided intervals\<close> | 
| 13735 | 1455 | |
| 1456 | lemma ivl_disj_un_two: | |
| 15045 | 1457 |   "[| (l::'a::linorder) < m; m <= u |] ==> {l<..<m} Un {m..<u} = {l<..<u}"
 | 
| 1458 |   "[| (l::'a::linorder) <= m; m < u |] ==> {l<..m} Un {m<..<u} = {l<..<u}"
 | |
| 1459 |   "[| (l::'a::linorder) <= m; m <= u |] ==> {l..<m} Un {m..<u} = {l..<u}"
 | |
| 1460 |   "[| (l::'a::linorder) <= m; m < u |] ==> {l..m} Un {m<..<u} = {l..<u}"
 | |
| 1461 |   "[| (l::'a::linorder) < m; m <= u |] ==> {l<..<m} Un {m..u} = {l<..u}"
 | |
| 1462 |   "[| (l::'a::linorder) <= m; m <= u |] ==> {l<..m} Un {m<..u} = {l<..u}"
 | |
| 1463 |   "[| (l::'a::linorder) <= m; m <= u |] ==> {l..<m} Un {m..u} = {l..u}"
 | |
| 1464 |   "[| (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: 
13850diff
changeset | 1465 | by auto | 
| 13735 | 1466 | |
| 60150 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60017diff
changeset | 1467 | lemma ivl_disj_un_two_touch: | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60017diff
changeset | 1468 |   "[| (l::'a::linorder) < m; m < u |] ==> {l<..m} Un {m..<u} = {l<..<u}"
 | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60017diff
changeset | 1469 |   "[| (l::'a::linorder) <= m; m < u |] ==> {l..m} Un {m..<u} = {l..<u}"
 | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60017diff
changeset | 1470 |   "[| (l::'a::linorder) < m; m <= u |] ==> {l<..m} Un {m..u} = {l<..u}"
 | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60017diff
changeset | 1471 |   "[| (l::'a::linorder) <= m; m <= u |] ==> {l..m} Un {m..u} = {l..u}"
 | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60017diff
changeset | 1472 | by auto | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60017diff
changeset | 1473 | |
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60017diff
changeset | 1474 | lemmas ivl_disj_un = ivl_disj_un_singleton ivl_disj_un_one ivl_disj_un_two ivl_disj_un_two_touch | 
| 13735 | 1475 | |
| 60758 | 1476 | subsubsection \<open>Disjoint Intersections\<close> | 
| 13735 | 1477 | |
| 60758 | 1478 | text \<open>One- and two-sided intervals\<close> | 
| 13735 | 1479 | |
| 1480 | lemma ivl_disj_int_one: | |
| 15045 | 1481 |   "{..l::'a::order} Int {l<..<u} = {}"
 | 
| 1482 |   "{..<l} Int {l..<u} = {}"
 | |
| 1483 |   "{..l} Int {l<..u} = {}"
 | |
| 1484 |   "{..<l} Int {l..u} = {}"
 | |
| 1485 |   "{l<..u} Int {u<..} = {}"
 | |
| 1486 |   "{l<..<u} Int {u..} = {}"
 | |
| 1487 |   "{l..u} Int {u<..} = {}"
 | |
| 1488 |   "{l..<u} Int {u..} = {}"
 | |
| 14398 
c5c47703f763
Efficient, graph-based reasoner for linear and partial orders.
 ballarin parents: 
13850diff
changeset | 1489 | by auto | 
| 13735 | 1490 | |
| 60758 | 1491 | text \<open>Two- and two-sided intervals\<close> | 
| 13735 | 1492 | |
| 1493 | lemma ivl_disj_int_two: | |
| 15045 | 1494 |   "{l::'a::order<..<m} Int {m..<u} = {}"
 | 
| 1495 |   "{l<..m} Int {m<..<u} = {}"
 | |
| 1496 |   "{l..<m} Int {m..<u} = {}"
 | |
| 1497 |   "{l..m} Int {m<..<u} = {}"
 | |
| 1498 |   "{l<..<m} Int {m..u} = {}"
 | |
| 1499 |   "{l<..m} Int {m<..u} = {}"
 | |
| 1500 |   "{l..<m} Int {m..u} = {}"
 | |
| 1501 |   "{l..m} Int {m<..u} = {}"
 | |
| 14398 
c5c47703f763
Efficient, graph-based reasoner for linear and partial orders.
 ballarin parents: 
13850diff
changeset | 1502 | by auto | 
| 13735 | 1503 | |
| 32456 
341c83339aeb
tuned the simp rules for Int involving insert and intervals.
 nipkow parents: 
32436diff
changeset | 1504 | lemmas ivl_disj_int = ivl_disj_int_one ivl_disj_int_two | 
| 13735 | 1505 | |
| 60758 | 1506 | subsubsection \<open>Some Differences\<close> | 
| 15542 | 1507 | |
| 1508 | lemma ivl_diff[simp]: | |
| 1509 |  "i \<le> n \<Longrightarrow> {i..<m} - {i..<n} = {n..<(m::'a::linorder)}"
 | |
| 1510 | by(auto) | |
| 1511 | ||
| 56194 | 1512 | lemma (in linorder) lessThan_minus_lessThan [simp]: | 
| 1513 |   "{..< n} - {..< m} = {m ..< n}"
 | |
| 1514 | by auto | |
| 1515 | ||
| 60762 | 1516 | lemma (in linorder) atLeastAtMost_diff_ends: | 
| 1517 |   "{a..b} - {a, b} = {a<..<b}"
 | |
| 1518 | by auto | |
| 1519 | ||
| 15542 | 1520 | |
| 60758 | 1521 | subsubsection \<open>Some Subset Conditions\<close> | 
| 15542 | 1522 | |
| 54147 
97a8ff4e4ac9
killed most "no_atp", to make Sledgehammer more complete
 blanchet parents: 
53374diff
changeset | 1523 | lemma ivl_subset [simp]: | 
| 15542 | 1524 |  "({i..<j} \<subseteq> {m..<n}) = (j \<le> i | m \<le> i & j \<le> (n::'a::linorder))"
 | 
| 1525 | apply(auto simp:linorder_not_le) | |
| 1526 | apply(rule ccontr) | |
| 1527 | apply(insert linorder_le_less_linear[of i n]) | |
| 1528 | apply(clarsimp simp:linorder_not_le) | |
| 44890 
22f665a2e91c
new fastforce replacing fastsimp - less confusing name
 nipkow parents: 
44008diff
changeset | 1529 | apply(fastforce) | 
| 15542 | 1530 | done | 
| 1531 | ||
| 15041 
a6b1f0cef7b3
Got rid of Summation and made it a translation into setsum instead.
 nipkow parents: 
14846diff
changeset | 1532 | |
| 63417 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1533 | subsection \<open>Generic big monoid operation over intervals\<close> | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1534 | |
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1535 | lemma inj_on_add_nat' [simp]: | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1536 | "inj_on (plus k) N" for k :: nat | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1537 | by rule simp | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1538 | |
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1539 | context comm_monoid_set | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1540 | begin | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1541 | |
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1542 | lemma atLeast_lessThan_shift_bounds: | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1543 | fixes m n k :: nat | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1544 |   shows "F g {m + k..<n + k} = F (g \<circ> plus k) {m..<n}"
 | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1545 | proof - | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1546 |   have "{m + k..<n + k} = plus k ` {m..<n}"
 | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1547 | by (auto simp add: image_add_atLeastLessThan [symmetric]) | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1548 |   also have "F g (plus k ` {m..<n}) = F (g \<circ> plus k) {m..<n}"
 | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1549 | by (rule reindex) simp | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1550 | finally show ?thesis . | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1551 | qed | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1552 | |
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1553 | lemma atLeast_atMost_shift_bounds: | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1554 | fixes m n k :: nat | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1555 |   shows "F g {m + k..n + k} = F (g \<circ> plus k) {m..n}"
 | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1556 | proof - | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1557 |   have "{m + k..n + k} = plus k ` {m..n}"
 | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1558 | by (auto simp del: image_add_atLeastAtMost simp add: image_add_atLeastAtMost [symmetric]) | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1559 |   also have "F g (plus k ` {m..n}) = F (g \<circ> plus k) {m..n}"
 | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1560 | by (rule reindex) simp | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1561 | finally show ?thesis . | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1562 | qed | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1563 | |
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1564 | lemma atLeast_Suc_lessThan_Suc_shift: | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1565 |   "F g {Suc m..<Suc n} = F (g \<circ> Suc) {m..<n}"
 | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1566 | using atLeast_lessThan_shift_bounds [of _ _ 1] by simp | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1567 | |
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1568 | lemma atLeast_Suc_atMost_Suc_shift: | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1569 |   "F g {Suc m..Suc n} = F (g \<circ> Suc) {m..n}"
 | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1570 | using atLeast_atMost_shift_bounds [of _ _ 1] by simp | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1571 | |
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1572 | lemma atLeast0_lessThan_Suc: | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1573 |   "F g {0..<Suc n} = F g {0..<n} \<^bold>* g n"
 | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1574 | by (simp add: atLeast0_lessThan_Suc ac_simps) | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1575 | |
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1576 | lemma atLeast0_atMost_Suc: | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1577 |   "F g {0..Suc n} = F g {0..n} \<^bold>* g (Suc n)"
 | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1578 | by (simp add: atLeast0_atMost_Suc ac_simps) | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1579 | |
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1580 | lemma atLeast0_lessThan_Suc_shift: | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1581 |   "F g {0..<Suc n} = g 0 \<^bold>* F (g \<circ> Suc) {0..<n}"
 | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1582 | by (simp add: atLeast0_lessThan_Suc_eq_insert_0 atLeast_Suc_lessThan_Suc_shift) | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1583 | |
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1584 | lemma atLeast0_atMost_Suc_shift: | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1585 |   "F g {0..Suc n} = g 0 \<^bold>* F (g \<circ> Suc) {0..n}"
 | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1586 | by (simp add: atLeast0_atMost_Suc_eq_insert_0 atLeast_Suc_atMost_Suc_shift) | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1587 | |
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1588 | lemma ivl_cong: | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1589 | "a = c \<Longrightarrow> b = d \<Longrightarrow> (\<And>x. c \<le> x \<Longrightarrow> x < d \<Longrightarrow> g x = h x) | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1590 |     \<Longrightarrow> F g {a..<b} = F h {c..<d}"
 | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1591 | by (rule cong) simp_all | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1592 | |
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1593 | lemma atLeast_lessThan_shift_0: | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1594 | fixes m n p :: nat | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1595 |   shows "F g {m..<n} = F (g \<circ> plus m) {0..<n - m}"
 | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1596 | using atLeast_lessThan_shift_bounds [of g 0 m "n - m"] | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1597 | by (cases "m \<le> n") simp_all | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1598 | |
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1599 | lemma atLeast_atMost_shift_0: | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1600 | fixes m n p :: nat | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1601 | assumes "m \<le> n" | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1602 |   shows "F g {m..n} = F (g \<circ> plus m) {0..n - m}"
 | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1603 | using assms atLeast_atMost_shift_bounds [of g 0 m "n - m"] by simp | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1604 | |
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1605 | lemma atLeast_lessThan_concat: | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1606 | fixes m n p :: nat | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1607 |   shows "m \<le> n \<Longrightarrow> n \<le> p \<Longrightarrow> F g {m..<n} \<^bold>* F g {n..<p} = F g {m..<p}"
 | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1608 | by (simp add: union_disjoint [symmetric] ivl_disj_un) | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1609 | |
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1610 | lemma atLeast_lessThan_rev: | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1611 |   "F g {n..<m} = F (\<lambda>i. g (m + n - Suc i)) {n..<m}"
 | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1612 | by (rule reindex_bij_witness [where i="\<lambda>i. m + n - Suc i" and j="\<lambda>i. m + n - Suc i"], auto) | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1613 | |
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1614 | lemma atLeast_atMost_rev: | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1615 | fixes n m :: nat | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1616 |   shows "F g {n..m} = F (\<lambda>i. g (m + n - i)) {n..m}"
 | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1617 | by (rule reindex_bij_witness [where i="\<lambda>i. m + n - i" and j="\<lambda>i. m + n - i"]) auto | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1618 | |
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1619 | lemma atLeast_lessThan_rev_at_least_Suc_atMost: | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1620 |   "F g {n..<m} = F (\<lambda>i. g (m + n - i)) {Suc n..m}"
 | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1621 | unfolding atLeast_lessThan_rev [of g n m] | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1622 | by (cases m) (simp_all add: atLeast_Suc_atMost_Suc_shift atLeastLessThanSuc_atLeastAtMost) | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1623 | |
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1624 | end | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1625 | |
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1626 | |
| 60758 | 1627 | subsection \<open>Summation indexed over intervals\<close> | 
| 15042 | 1628 | |
| 61955 
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
 wenzelm parents: 
61799diff
changeset | 1629 | syntax (ASCII) | 
| 64267 | 1630 |   "_from_to_sum" :: "idt \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> 'b"  ("(SUM _ = _.._./ _)" [0,0,0,10] 10)
 | 
| 1631 |   "_from_upto_sum" :: "idt \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> 'b"  ("(SUM _ = _..<_./ _)" [0,0,0,10] 10)
 | |
| 1632 |   "_upt_sum" :: "idt \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> 'b"  ("(SUM _<_./ _)" [0,0,10] 10)
 | |
| 1633 |   "_upto_sum" :: "idt \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> 'b"  ("(SUM _<=_./ _)" [0,0,10] 10)
 | |
| 61955 
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
 wenzelm parents: 
61799diff
changeset | 1634 | |
| 15056 | 1635 | syntax (latex_sum output) | 
| 64267 | 1636 | "_from_to_sum" :: "idt \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> 'b" | 
| 63935 
aa1fe1103ab8
raw control symbols are superseded by Latex.embed_raw;
 wenzelm parents: 
63918diff
changeset | 1637 |  ("(3\<^latex>\<open>$\\sum_{\<close>_ = _\<^latex>\<open>}^{\<close>_\<^latex>\<open>}$\<close> _)" [0,0,0,10] 10)
 | 
| 64267 | 1638 | "_from_upto_sum" :: "idt \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> 'b" | 
| 63935 
aa1fe1103ab8
raw control symbols are superseded by Latex.embed_raw;
 wenzelm parents: 
63918diff
changeset | 1639 |  ("(3\<^latex>\<open>$\\sum_{\<close>_ = _\<^latex>\<open>}^{<\<close>_\<^latex>\<open>}$\<close> _)" [0,0,0,10] 10)
 | 
| 64267 | 1640 | "_upt_sum" :: "idt \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> 'b" | 
| 63935 
aa1fe1103ab8
raw control symbols are superseded by Latex.embed_raw;
 wenzelm parents: 
63918diff
changeset | 1641 |  ("(3\<^latex>\<open>$\\sum_{\<close>_ < _\<^latex>\<open>}$\<close> _)" [0,0,10] 10)
 | 
| 64267 | 1642 | "_upto_sum" :: "idt \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> 'b" | 
| 63935 
aa1fe1103ab8
raw control symbols are superseded by Latex.embed_raw;
 wenzelm parents: 
63918diff
changeset | 1643 |  ("(3\<^latex>\<open>$\\sum_{\<close>_ \<le> _\<^latex>\<open>}$\<close> _)" [0,0,10] 10)
 | 
| 15041 
a6b1f0cef7b3
Got rid of Summation and made it a translation into setsum instead.
 nipkow parents: 
14846diff
changeset | 1644 | |
| 61955 
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
 wenzelm parents: 
61799diff
changeset | 1645 | syntax | 
| 64267 | 1646 |   "_from_to_sum" :: "idt \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> 'b"  ("(3\<Sum>_ = _.._./ _)" [0,0,0,10] 10)
 | 
| 1647 |   "_from_upto_sum" :: "idt \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> 'b"  ("(3\<Sum>_ = _..<_./ _)" [0,0,0,10] 10)
 | |
| 1648 |   "_upt_sum" :: "idt \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> 'b"  ("(3\<Sum>_<_./ _)" [0,0,10] 10)
 | |
| 1649 |   "_upto_sum" :: "idt \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> 'b"  ("(3\<Sum>_\<le>_./ _)" [0,0,10] 10)
 | |
| 61955 
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
 wenzelm parents: 
61799diff
changeset | 1650 | |
| 15048 | 1651 | translations | 
| 64267 | 1652 |   "\<Sum>x=a..b. t" == "CONST sum (\<lambda>x. t) {a..b}"
 | 
| 1653 |   "\<Sum>x=a..<b. t" == "CONST sum (\<lambda>x. t) {a..<b}"
 | |
| 1654 |   "\<Sum>i\<le>n. t" == "CONST sum (\<lambda>i. t) {..n}"
 | |
| 1655 |   "\<Sum>i<n. t" == "CONST sum (\<lambda>i. t) {..<n}"
 | |
| 15041 
a6b1f0cef7b3
Got rid of Summation and made it a translation into setsum instead.
 nipkow parents: 
14846diff
changeset | 1656 | |
| 60758 | 1657 | text\<open>The above introduces some pretty alternative syntaxes for | 
| 15056 | 1658 | summation over intervals: | 
| 15052 | 1659 | \begin{center}
 | 
| 1660 | \begin{tabular}{lll}
 | |
| 15056 | 1661 | Old & New & \LaTeX\\ | 
| 1662 | @{term[source]"\<Sum>x\<in>{a..b}. e"} & @{term"\<Sum>x=a..b. e"} & @{term[mode=latex_sum]"\<Sum>x=a..b. e"}\\
 | |
| 1663 | @{term[source]"\<Sum>x\<in>{a..<b}. e"} & @{term"\<Sum>x=a..<b. e"} & @{term[mode=latex_sum]"\<Sum>x=a..<b. e"}\\
 | |
| 16052 | 1664 | @{term[source]"\<Sum>x\<in>{..b}. e"} & @{term"\<Sum>x\<le>b. e"} & @{term[mode=latex_sum]"\<Sum>x\<le>b. e"}\\
 | 
| 15056 | 1665 | @{term[source]"\<Sum>x\<in>{..<b}. e"} & @{term"\<Sum>x<b. e"} & @{term[mode=latex_sum]"\<Sum>x<b. e"}
 | 
| 15052 | 1666 | \end{tabular}
 | 
| 1667 | \end{center}
 | |
| 15056 | 1668 | The left column shows the term before introduction of the new syntax, | 
| 1669 | the middle column shows the new (default) syntax, and the right column | |
| 1670 | shows a special syntax. The latter is only meaningful for latex output | |
| 1671 | and has to be activated explicitly by setting the print mode to | |
| 61799 | 1672 | \<open>latex_sum\<close> (e.g.\ via \<open>mode = latex_sum\<close> in | 
| 15056 | 1673 | antiquotations). It is not the default \LaTeX\ output because it only | 
| 1674 | works well with italic-style formulae, not tt-style. | |
| 15052 | 1675 | |
| 1676 | Note that for uniformity on @{typ nat} it is better to use
 | |
| 64267 | 1677 | @{term"\<Sum>x::nat=0..<n. e"} rather than \<open>\<Sum>x<n. e\<close>: \<open>sum\<close> may
 | 
| 15052 | 1678 | not provide all lemmas available for @{term"{m..<n}"} also in the
 | 
| 60758 | 1679 | special form for @{term"{..<n}"}.\<close>
 | 
| 15052 | 1680 | |
| 60758 | 1681 | text\<open>This congruence rule should be used for sums over intervals as | 
| 64267 | 1682 | the standard theorem @{text[source]sum.cong} does not work well
 | 
| 15542 | 1683 | with the simplifier who adds the unsimplified premise @{term"x:B"} to
 | 
| 60758 | 1684 | the context.\<close> | 
| 15542 | 1685 | |
| 64267 | 1686 | lemmas sum_ivl_cong = sum.ivl_cong | 
| 15041 
a6b1f0cef7b3
Got rid of Summation and made it a translation into setsum instead.
 nipkow parents: 
14846diff
changeset | 1687 | |
| 16041 | 1688 | (* FIXME why are the following simp rules but the corresponding eqns | 
| 1689 | on intervals are not? *) | |
| 1690 | ||
| 64267 | 1691 | lemma sum_atMost_Suc [simp]: | 
| 63417 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1692 | "(\<Sum>i \<le> Suc n. f i) = (\<Sum>i \<le> n. f i) + f (Suc n)" | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1693 | by (simp add: atMost_Suc ac_simps) | 
| 16052 | 1694 | |
| 64267 | 1695 | lemma sum_lessThan_Suc [simp]: | 
| 63417 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1696 | "(\<Sum>i < Suc n. f i) = (\<Sum>i < n. f i) + f n" | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1697 | by (simp add: lessThan_Suc ac_simps) | 
| 15041 
a6b1f0cef7b3
Got rid of Summation and made it a translation into setsum instead.
 nipkow parents: 
14846diff
changeset | 1698 | |
| 64267 | 1699 | lemma sum_cl_ivl_Suc [simp]: | 
| 1700 |   "sum f {m..Suc n} = (if Suc n < m then 0 else sum f {m..n} + f(Suc n))"
 | |
| 63417 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1701 | by (auto simp: ac_simps atLeastAtMostSuc_conv) | 
| 15561 | 1702 | |
| 64267 | 1703 | lemma sum_op_ivl_Suc [simp]: | 
| 1704 |   "sum f {m..<Suc n} = (if n < m then 0 else sum f {m..<n} + f(n))"
 | |
| 63417 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1705 | by (auto simp: ac_simps atLeastLessThanSuc) | 
| 16041 | 1706 | (* | 
| 64267 | 1707 | lemma sum_cl_ivl_add_one_nat: "(n::nat) <= m + 1 ==> | 
| 15561 | 1708 | (\<Sum>i=n..m+1. f i) = (\<Sum>i=n..m. f i) + f(m + 1)" | 
| 57514 
bdc2c6b40bf2
prefer ac_simps collections over separate name bindings for add and mult
 haftmann parents: 
57512diff
changeset | 1709 | by (auto simp:ac_simps atLeastAtMostSuc_conv) | 
| 16041 | 1710 | *) | 
| 28068 | 1711 | |
| 64267 | 1712 | lemma sum_head: | 
| 28068 | 1713 | fixes n :: nat | 
| 62369 | 1714 | assumes mn: "m <= n" | 
| 28068 | 1715 |   shows "(\<Sum>x\<in>{m..n}. P x) = P m + (\<Sum>x\<in>{m<..n}. P x)" (is "?lhs = ?rhs")
 | 
| 1716 | proof - | |
| 1717 | from mn | |
| 1718 |   have "{m..n} = {m} \<union> {m<..n}"
 | |
| 1719 | by (auto intro: ivl_disj_un_singleton) | |
| 1720 |   hence "?lhs = (\<Sum>x\<in>{m} \<union> {m<..n}. P x)"
 | |
| 1721 | by (simp add: atLeast0LessThan) | |
| 1722 | also have "\<dots> = ?rhs" by simp | |
| 1723 | finally show ?thesis . | |
| 1724 | qed | |
| 1725 | ||
| 64267 | 1726 | lemma sum_head_Suc: | 
| 1727 |   "m \<le> n \<Longrightarrow> sum f {m..n} = f m + sum f {Suc m..n}"
 | |
| 1728 | by (simp add: sum_head atLeastSucAtMost_greaterThanAtMost) | |
| 1729 | ||
| 1730 | lemma sum_head_upt_Suc: | |
| 1731 |   "m < n \<Longrightarrow> sum f {m..<n} = f m + sum f {Suc m..<n}"
 | |
| 1732 | apply(insert sum_head_Suc[of m "n - Suc 0" f]) | |
| 29667 | 1733 | apply (simp add: atLeastLessThanSuc_atLeastAtMost[symmetric] algebra_simps) | 
| 28068 | 1734 | done | 
| 1735 | ||
| 64267 | 1736 | lemma sum_ub_add_nat: assumes "(m::nat) \<le> n + 1" | 
| 1737 |   shows "sum f {m..n + p} = sum f {m..n} + sum f {n + 1..n + p}"
 | |
| 31501 | 1738 | proof- | 
| 60758 | 1739 |   have "{m .. n+p} = {m..n} \<union> {n+1..n+p}" using \<open>m \<le> n+1\<close> by auto
 | 
| 64267 | 1740 | thus ?thesis by (auto simp: ivl_disj_int sum.union_disjoint | 
| 31501 | 1741 | atLeastSucAtMost_greaterThanAtMost) | 
| 1742 | qed | |
| 28068 | 1743 | |
| 64267 | 1744 | lemmas sum_add_nat_ivl = sum.atLeast_lessThan_concat | 
| 1745 | ||
| 1746 | lemma sum_diff_nat_ivl: | |
| 15539 | 1747 | fixes f :: "nat \<Rightarrow> 'a::ab_group_add" | 
| 1748 | shows "\<lbrakk> m \<le> n; n \<le> p \<rbrakk> \<Longrightarrow> | |
| 64267 | 1749 |   sum f {m..<p} - sum f {m..<n} = sum f {n..<p}"
 | 
| 1750 | using sum_add_nat_ivl [of m n p f,symmetric] | |
| 57514 
bdc2c6b40bf2
prefer ac_simps collections over separate name bindings for add and mult
 haftmann parents: 
57512diff
changeset | 1751 | apply (simp add: ac_simps) | 
| 15539 | 1752 | done | 
| 1753 | ||
| 64267 | 1754 | lemma sum_natinterval_difff: | 
| 31505 | 1755 |   fixes f:: "nat \<Rightarrow> ('a::ab_group_add)"
 | 
| 64267 | 1756 |   shows  "sum (\<lambda>k. f k - f(k + 1)) {(m::nat) .. n} =
 | 
| 31505 | 1757 | (if m <= n then f m - f(n + 1) else 0)" | 
| 1758 | by (induct n, auto simp add: algebra_simps not_le le_Suc_eq) | |
| 1759 | ||
| 64267 | 1760 | lemma sum_nat_group: "(\<Sum>m<n::nat. sum f {m * k ..< m*k + k}) = sum f {..< n * k}"
 | 
| 56194 | 1761 | apply (subgoal_tac "k = 0 | 0 < k", auto) | 
| 1762 | apply (induct "n") | |
| 64267 | 1763 | apply (simp_all add: sum_add_nat_ivl add.commute atLeast0LessThan[symmetric]) | 
| 56194 | 1764 | done | 
| 28068 | 1765 | |
| 64267 | 1766 | lemma sum_triangle_reindex: | 
| 60150 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60017diff
changeset | 1767 | fixes n :: nat | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60017diff
changeset | 1768 |   shows "(\<Sum>(i,j)\<in>{(i,j). i+j < n}. f i j) = (\<Sum>k<n. \<Sum>i\<le>k. f i (k - i))"
 | 
| 64267 | 1769 | apply (simp add: sum.Sigma) | 
| 1770 | apply (rule sum.reindex_bij_witness[where j="\<lambda>(i, j). (i+j, i)" and i="\<lambda>(k, i). (i, k - i)"]) | |
| 60150 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60017diff
changeset | 1771 | apply auto | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60017diff
changeset | 1772 | done | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60017diff
changeset | 1773 | |
| 64267 | 1774 | lemma sum_triangle_reindex_eq: | 
| 60150 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60017diff
changeset | 1775 | fixes n :: nat | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60017diff
changeset | 1776 |   shows "(\<Sum>(i,j)\<in>{(i,j). i+j \<le> n}. f i j) = (\<Sum>k\<le>n. \<Sum>i\<le>k. f i (k - i))"
 | 
| 64267 | 1777 | using sum_triangle_reindex [of f "Suc n"] | 
| 60150 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60017diff
changeset | 1778 | by (simp only: Nat.less_Suc_eq_le lessThan_Suc_atMost) | 
| 
bd773c47ad0b
New material about complex transcendental functions (especially Ln, Arg) and polynomials
 paulson <lp15@cam.ac.uk> parents: 
60017diff
changeset | 1779 | |
| 64267 | 1780 | lemma nat_diff_sum_reindex: "(\<Sum>i<n. f (n - Suc i)) = (\<Sum>i<n. f i)" | 
| 1781 | by (rule sum.reindex_bij_witness[where i="\<lambda>i. n - Suc i" and j="\<lambda>i. n - Suc i"]) auto | |
| 60162 | 1782 | |
| 63417 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1783 | |
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1784 | subsubsection \<open>Shifting bounds\<close> | 
| 16733 
236dfafbeb63
linear arithmetic now takes "&" in assumptions apart.
 nipkow parents: 
16102diff
changeset | 1785 | |
| 64267 | 1786 | lemma sum_shift_bounds_nat_ivl: | 
| 1787 |   "sum f {m+k..<n+k} = sum (%i. f(i + k)){m..<n::nat}"
 | |
| 15539 | 1788 | by (induct "n", auto simp:atLeastLessThanSuc) | 
| 1789 | ||
| 64267 | 1790 | lemma sum_shift_bounds_cl_nat_ivl: | 
| 1791 |   "sum f {m+k..n+k} = sum (%i. f(i + k)){m..n::nat}"
 | |
| 1792 | by (rule sum.reindex_bij_witness[where i="\<lambda>i. i + k" and j="\<lambda>i. i - k"]) auto | |
| 1793 | ||
| 1794 | corollary sum_shift_bounds_cl_Suc_ivl: | |
| 1795 |   "sum f {Suc m..Suc n} = sum (%i. f(Suc i)){m..n}"
 | |
| 1796 | by (simp add:sum_shift_bounds_cl_nat_ivl[where k="Suc 0", simplified]) | |
| 1797 | ||
| 1798 | corollary sum_shift_bounds_Suc_ivl: | |
| 1799 |   "sum f {Suc m..<Suc n} = sum (%i. f(Suc i)){m..<n}"
 | |
| 1800 | by (simp add:sum_shift_bounds_nat_ivl[where k="Suc 0", simplified]) | |
| 1801 | ||
| 1802 | lemma sum_shift_lb_Suc0_0: | |
| 1803 |   "f(0::nat) = (0::nat) \<Longrightarrow> sum f {Suc 0..k} = sum f {0..k}"
 | |
| 1804 | by(simp add:sum_head_Suc) | |
| 1805 | ||
| 1806 | lemma sum_shift_lb_Suc0_0_upt: | |
| 1807 |   "f(0::nat) = 0 \<Longrightarrow> sum f {Suc 0..<k} = sum f {0..<k}"
 | |
| 28068 | 1808 | apply(cases k)apply simp | 
| 64267 | 1809 | apply(simp add:sum_head_upt_Suc) | 
| 28068 | 1810 | done | 
| 19022 
0e6ec4fd204c
* moved ThreeDivides from Isar_examples to better suited HOL/ex
 kleing parents: 
17719diff
changeset | 1811 | |
| 64267 | 1812 | lemma sum_atMost_Suc_shift: | 
| 52380 | 1813 | fixes f :: "nat \<Rightarrow> 'a::comm_monoid_add" | 
| 1814 | shows "(\<Sum>i\<le>Suc n. f i) = f 0 + (\<Sum>i\<le>n. f (Suc i))" | |
| 1815 | proof (induct n) | |
| 1816 | case 0 show ?case by simp | |
| 1817 | next | |
| 1818 | case (Suc n) note IH = this | |
| 1819 | have "(\<Sum>i\<le>Suc (Suc n). f i) = (\<Sum>i\<le>Suc n. f i) + f (Suc (Suc n))" | |
| 64267 | 1820 | by (rule sum_atMost_Suc) | 
| 52380 | 1821 | also have "(\<Sum>i\<le>Suc n. f i) = f 0 + (\<Sum>i\<le>n. f (Suc i))" | 
| 1822 | by (rule IH) | |
| 1823 | also have "f 0 + (\<Sum>i\<le>n. f (Suc i)) + f (Suc (Suc n)) = | |
| 1824 | f 0 + ((\<Sum>i\<le>n. f (Suc i)) + f (Suc (Suc n)))" | |
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57448diff
changeset | 1825 | by (rule add.assoc) | 
| 52380 | 1826 | also have "(\<Sum>i\<le>n. f (Suc i)) + f (Suc (Suc n)) = (\<Sum>i\<le>Suc n. f (Suc i))" | 
| 64267 | 1827 | by (rule sum_atMost_Suc [symmetric]) | 
| 52380 | 1828 | finally show ?case . | 
| 1829 | qed | |
| 1830 | ||
| 64267 | 1831 | lemma sum_lessThan_Suc_shift: | 
| 63099 
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
 eberlm parents: 
63092diff
changeset | 1832 | "(\<Sum>i<Suc n. f i) = f 0 + (\<Sum>i<n. f (Suc i))" | 
| 
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
 eberlm parents: 
63092diff
changeset | 1833 | by (induction n) (simp_all add: add_ac) | 
| 
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
 eberlm parents: 
63092diff
changeset | 1834 | |
| 64267 | 1835 | lemma sum_atMost_shift: | 
| 62379 
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
 paulson <lp15@cam.ac.uk> parents: 
62376diff
changeset | 1836 | fixes f :: "nat \<Rightarrow> 'a::comm_monoid_add" | 
| 
340738057c8c
An assortment of useful lemmas about sums, norm, etc. Also: norm_conv_dist [symmetric] is now a simprule!
 paulson <lp15@cam.ac.uk> parents: 
62376diff
changeset | 1837 | shows "(\<Sum>i\<le>n. f i) = f 0 + (\<Sum>i<n. f (Suc i))" | 
| 64267 | 1838 | by (metis atLeast0AtMost atLeast0LessThan atLeastLessThanSuc_atLeastAtMost atLeastSucAtMost_greaterThanAtMost le0 sum_head sum_shift_bounds_Suc_ivl) | 
| 1839 | ||
| 1840 | lemma sum_last_plus: fixes n::nat shows "m <= n \<Longrightarrow> (\<Sum>i = m..n. f i) = f n + (\<Sum>i = m..<n. f i)" | |
| 57512 
cc97b347b301
reduced name variants for assoc and commute on plus and mult
 haftmann parents: 
57448diff
changeset | 1841 | by (cases n) (auto simp: atLeastLessThanSuc_atLeastAtMost add.commute) | 
| 56238 
5d147e1e18d1
a few new lemmas and generalisations of old ones
 paulson <lp15@cam.ac.uk> parents: 
56215diff
changeset | 1842 | |
| 64267 | 1843 | lemma sum_Suc_diff: | 
| 56238 
5d147e1e18d1
a few new lemmas and generalisations of old ones
 paulson <lp15@cam.ac.uk> parents: 
56215diff
changeset | 1844 | fixes f :: "nat \<Rightarrow> 'a::ab_group_add" | 
| 
5d147e1e18d1
a few new lemmas and generalisations of old ones
 paulson <lp15@cam.ac.uk> parents: 
56215diff
changeset | 1845 | assumes "m \<le> Suc n" | 
| 
5d147e1e18d1
a few new lemmas and generalisations of old ones
 paulson <lp15@cam.ac.uk> parents: 
56215diff
changeset | 1846 | shows "(\<Sum>i = m..n. f(Suc i) - f i) = f (Suc n) - f m" | 
| 
5d147e1e18d1
a few new lemmas and generalisations of old ones
 paulson <lp15@cam.ac.uk> parents: 
56215diff
changeset | 1847 | using assms by (induct n) (auto simp: le_Suc_eq) | 
| 55718 
34618f031ba9
A few lemmas about summations, etc.
 paulson <lp15@cam.ac.uk> parents: 
55242diff
changeset | 1848 | |
| 65273 
917ae0ba03a2
Removal of [simp] status for greaterThan_0. Moved two theorems into main HOL.
 paulson <lp15@cam.ac.uk> parents: 
64773diff
changeset | 1849 | lemma sum_Suc_diff': | 
| 
917ae0ba03a2
Removal of [simp] status for greaterThan_0. Moved two theorems into main HOL.
 paulson <lp15@cam.ac.uk> parents: 
64773diff
changeset | 1850 | fixes f :: "nat \<Rightarrow> 'a::ab_group_add" | 
| 
917ae0ba03a2
Removal of [simp] status for greaterThan_0. Moved two theorems into main HOL.
 paulson <lp15@cam.ac.uk> parents: 
64773diff
changeset | 1851 | assumes "m \<le> n" | 
| 
917ae0ba03a2
Removal of [simp] status for greaterThan_0. Moved two theorems into main HOL.
 paulson <lp15@cam.ac.uk> parents: 
64773diff
changeset | 1852 | shows "(\<Sum>i = m..<n. f (Suc i) - f i) = f n - f m" | 
| 
917ae0ba03a2
Removal of [simp] status for greaterThan_0. Moved two theorems into main HOL.
 paulson <lp15@cam.ac.uk> parents: 
64773diff
changeset | 1853 | using assms by (induct n) (auto simp: le_Suc_eq) | 
| 
917ae0ba03a2
Removal of [simp] status for greaterThan_0. Moved two theorems into main HOL.
 paulson <lp15@cam.ac.uk> parents: 
64773diff
changeset | 1854 | |
| 64267 | 1855 | lemma nested_sum_swap: | 
| 55718 
34618f031ba9
A few lemmas about summations, etc.
 paulson <lp15@cam.ac.uk> parents: 
55242diff
changeset | 1856 | "(\<Sum>i = 0..n. (\<Sum>j = 0..<i. a i j)) = (\<Sum>j = 0..<n. \<Sum>i = Suc j..n. a i j)" | 
| 64267 | 1857 | by (induction n) (auto simp: sum.distrib) | 
| 1858 | ||
| 1859 | lemma nested_sum_swap': | |
| 56215 | 1860 | "(\<Sum>i\<le>n. (\<Sum>j<i. a i j)) = (\<Sum>j<n. \<Sum>i = Suc j..n. a i j)" | 
| 64267 | 1861 | by (induction n) (auto simp: sum.distrib) | 
| 1862 | ||
| 1863 | lemma sum_atLeast1_atMost_eq: | |
| 1864 |   "sum f {Suc 0..n} = (\<Sum>k<n. f (Suc k))"
 | |
| 63365 | 1865 | proof - | 
| 64267 | 1866 |   have "sum f {Suc 0..n} = sum f (Suc ` {..<n})"
 | 
| 63365 | 1867 | by (simp add: image_Suc_lessThan) | 
| 1868 | also have "\<dots> = (\<Sum>k<n. f (Suc k))" | |
| 64267 | 1869 | by (simp add: sum.reindex) | 
| 63365 | 1870 | finally show ?thesis . | 
| 1871 | qed | |
| 56238 
5d147e1e18d1
a few new lemmas and generalisations of old ones
 paulson <lp15@cam.ac.uk> parents: 
56215diff
changeset | 1872 | |
| 52380 | 1873 | |
| 63417 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1874 | subsubsection \<open>Telescoping\<close> | 
| 61524 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61378diff
changeset | 1875 | |
| 64267 | 1876 | lemma sum_telescope: | 
| 61524 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61378diff
changeset | 1877 | fixes f::"nat \<Rightarrow> 'a::ab_group_add" | 
| 64267 | 1878 |   shows "sum (\<lambda>i. f i - f (Suc i)) {.. i} = f 0 - f (Suc i)"
 | 
| 61524 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61378diff
changeset | 1879 | by (induct i) simp_all | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61378diff
changeset | 1880 | |
| 64267 | 1881 | lemma sum_telescope'': | 
| 61524 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61378diff
changeset | 1882 | assumes "m \<le> n" | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61378diff
changeset | 1883 |   shows   "(\<Sum>k\<in>{Suc m..n}. f k - f (k - 1)) = f n - (f m :: 'a :: ab_group_add)"
 | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61378diff
changeset | 1884 | by (rule dec_induct[OF assms]) (simp_all add: algebra_simps) | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61378diff
changeset | 1885 | |
| 64267 | 1886 | lemma sum_lessThan_telescope: | 
| 63721 | 1887 | "(\<Sum>n<m. f (Suc n) - f n :: 'a :: ab_group_add) = f m - f 0" | 
| 1888 | by (induction m) (simp_all add: algebra_simps) | |
| 1889 | ||
| 64267 | 1890 | lemma sum_lessThan_telescope': | 
| 63721 | 1891 | "(\<Sum>n<m. f n - f (Suc n) :: 'a :: ab_group_add) = f 0 - f m" | 
| 1892 | by (induction m) (simp_all add: algebra_simps) | |
| 1893 | ||
| 63417 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1894 | |
| 65578 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1895 | subsection \<open>The formula for geometric sums\<close> | 
| 17149 
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
 ballarin parents: 
16733diff
changeset | 1896 | |
| 
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
 ballarin parents: 
16733diff
changeset | 1897 | lemma geometric_sum: | 
| 36307 
1732232f9b27
sharpened constraint (c.f. 4e7f5b22dd7d); explicit is better than implicit
 haftmann parents: 
35828diff
changeset | 1898 | assumes "x \<noteq> 1" | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
55719diff
changeset | 1899 | shows "(\<Sum>i<n. x ^ i) = (x ^ n - 1) / (x - 1::'a::field)" | 
| 36307 
1732232f9b27
sharpened constraint (c.f. 4e7f5b22dd7d); explicit is better than implicit
 haftmann parents: 
35828diff
changeset | 1900 | proof - | 
| 
1732232f9b27
sharpened constraint (c.f. 4e7f5b22dd7d); explicit is better than implicit
 haftmann parents: 
35828diff
changeset | 1901 | from assms obtain y where "y = x - 1" and "y \<noteq> 0" by simp_all | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
55719diff
changeset | 1902 | moreover have "(\<Sum>i<n. (y + 1) ^ i) = ((y + 1) ^ n - 1) / y" | 
| 63417 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1903 | by (induct n) (simp_all add: field_simps \<open>y \<noteq> 0\<close>) | 
| 36307 
1732232f9b27
sharpened constraint (c.f. 4e7f5b22dd7d); explicit is better than implicit
 haftmann parents: 
35828diff
changeset | 1904 | ultimately show ?thesis by simp | 
| 
1732232f9b27
sharpened constraint (c.f. 4e7f5b22dd7d); explicit is better than implicit
 haftmann parents: 
35828diff
changeset | 1905 | qed | 
| 
1732232f9b27
sharpened constraint (c.f. 4e7f5b22dd7d); explicit is better than implicit
 haftmann parents: 
35828diff
changeset | 1906 | |
| 64267 | 1907 | lemma diff_power_eq_sum: | 
| 60162 | 1908 |   fixes y :: "'a::{comm_ring,monoid_mult}"
 | 
| 1909 | shows | |
| 1910 | "x ^ (Suc n) - y ^ (Suc n) = | |
| 1911 | (x - y) * (\<Sum>p<Suc n. (x ^ p) * y ^ (n - p))" | |
| 1912 | proof (induct n) | |
| 1913 | case (Suc n) | |
| 1914 | have "x ^ Suc (Suc n) - y ^ Suc (Suc n) = x * (x * x^n) - y * (y * y ^ n)" | |
| 63417 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1915 | by simp | 
| 60162 | 1916 | also have "... = y * (x ^ (Suc n) - y ^ (Suc n)) + (x - y) * (x * x^n)" | 
| 63417 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 1917 | by (simp add: algebra_simps) | 
| 60162 | 1918 | also have "... = y * ((x - y) * (\<Sum>p<Suc n. (x ^ p) * y ^ (n - p))) + (x - y) * (x * x^n)" | 
| 1919 | by (simp only: Suc) | |
| 1920 | also have "... = (x - y) * (y * (\<Sum>p<Suc n. (x ^ p) * y ^ (n - p))) + (x - y) * (x * x^n)" | |
| 1921 | by (simp only: mult.left_commute) | |
| 1922 | also have "... = (x - y) * (\<Sum>p<Suc (Suc n). x ^ p * y ^ (Suc n - p))" | |
| 64267 | 1923 | by (simp add: field_simps Suc_diff_le sum_distrib_right sum_distrib_left) | 
| 60162 | 1924 | finally show ?case . | 
| 1925 | qed simp | |
| 1926 | ||
| 61799 | 1927 | corollary power_diff_sumr2: \<comment>\<open>\<open>COMPLEX_POLYFUN\<close> in HOL Light\<close> | 
| 60162 | 1928 |   fixes x :: "'a::{comm_ring,monoid_mult}"
 | 
| 1929 | shows "x^n - y^n = (x - y) * (\<Sum>i<n. y^(n - Suc i) * x^i)" | |
| 64267 | 1930 | using diff_power_eq_sum[of x "n - 1" y] | 
| 60162 | 1931 | by (cases "n = 0") (simp_all add: field_simps) | 
| 1932 | ||
| 1933 | lemma power_diff_1_eq: | |
| 1934 |   fixes x :: "'a::{comm_ring,monoid_mult}"
 | |
| 1935 | shows "n \<noteq> 0 \<Longrightarrow> x^n - 1 = (x - 1) * (\<Sum>i<n. (x^i))" | |
| 64267 | 1936 | using diff_power_eq_sum [of x _ 1] | 
| 60162 | 1937 | by (cases n) auto | 
| 1938 | ||
| 1939 | lemma one_diff_power_eq': | |
| 1940 |   fixes x :: "'a::{comm_ring,monoid_mult}"
 | |
| 1941 | shows "n \<noteq> 0 \<Longrightarrow> 1 - x^n = (1 - x) * (\<Sum>i<n. x^(n - Suc i))" | |
| 64267 | 1942 | using diff_power_eq_sum [of 1 _ x] | 
| 60162 | 1943 | by (cases n) auto | 
| 1944 | ||
| 1945 | lemma one_diff_power_eq: | |
| 1946 |   fixes x :: "'a::{comm_ring,monoid_mult}"
 | |
| 1947 | shows "n \<noteq> 0 \<Longrightarrow> 1 - x^n = (1 - x) * (\<Sum>i<n. x^i)" | |
| 64267 | 1948 | by (metis one_diff_power_eq' [of n x] nat_diff_sum_reindex) | 
| 60162 | 1949 | |
| 65578 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1950 | lemma sum_gp_basic: | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1951 |   fixes x :: "'a::{comm_ring,monoid_mult}"
 | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1952 | shows "(1 - x) * (\<Sum>i\<le>n. x^i) = 1 - x^Suc n" | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1953 | by (simp only: one_diff_power_eq [of "Suc n" x] lessThan_Suc_atMost) | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1954 | |
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1955 | lemma sum_power_shift: | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1956 |   fixes x :: "'a::{comm_ring,monoid_mult}"
 | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1957 | assumes "m \<le> n" | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1958 | shows "(\<Sum>i=m..n. x^i) = x^m * (\<Sum>i\<le>n-m. x^i)" | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1959 | proof - | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1960 | have "(\<Sum>i=m..n. x^i) = x^m * (\<Sum>i=m..n. x^(i-m))" | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1961 | by (simp add: sum_distrib_left power_add [symmetric]) | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1962 | also have "(\<Sum>i=m..n. x^(i-m)) = (\<Sum>i\<le>n-m. x^i)" | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1963 | using \<open>m \<le> n\<close> by (intro sum.reindex_bij_witness[where j="\<lambda>i. i - m" and i="\<lambda>i. i + m"]) auto | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1964 | finally show ?thesis . | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1965 | qed | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1966 | |
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1967 | lemma sum_gp_multiplied: | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1968 |   fixes x :: "'a::{comm_ring,monoid_mult}"
 | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1969 | assumes "m \<le> n" | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1970 | shows "(1 - x) * (\<Sum>i=m..n. x^i) = x^m - x^Suc n" | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1971 | proof - | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1972 | have "(1 - x) * (\<Sum>i=m..n. x^i) = x^m * (1 - x) * (\<Sum>i\<le>n-m. x^i)" | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1973 | by (metis mult.assoc mult.commute assms sum_power_shift) | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1974 | also have "... =x^m * (1 - x^Suc(n-m))" | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1975 | by (metis mult.assoc sum_gp_basic) | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1976 | also have "... = x^m - x^Suc n" | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1977 | using assms | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1978 | by (simp add: algebra_simps) (metis le_add_diff_inverse power_add) | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1979 | finally show ?thesis . | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1980 | qed | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1981 | |
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1982 | lemma sum_gp: | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1983 |   fixes x :: "'a::{comm_ring,division_ring}"
 | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1984 | shows "(\<Sum>i=m..n. x^i) = | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1985 | (if n < m then 0 | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1986 | else if x = 1 then of_nat((n + 1) - m) | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1987 | else (x^m - x^Suc n) / (1 - x))" | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1988 | using sum_gp_multiplied [of m n x] apply auto | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1989 | by (metis eq_iff_diff_eq_0 mult.commute nonzero_divide_eq_eq) | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1990 | |
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1991 | subsection\<open>Geometric progressions\<close> | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1992 | |
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1993 | lemma sum_gp0: | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1994 |   fixes x :: "'a::{comm_ring,division_ring}"
 | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1995 | shows "(\<Sum>i\<le>n. x^i) = (if x = 1 then of_nat(n + 1) else (1 - x^Suc n) / (1 - x))" | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1996 | using sum_gp_basic[of x n] | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1997 | by (simp add: mult.commute divide_simps) | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1998 | |
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 1999 | lemma sum_power_add: | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 2000 |   fixes x :: "'a::{comm_ring,monoid_mult}"
 | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 2001 | shows "(\<Sum>i\<in>I. x^(m+i)) = x^m * (\<Sum>i\<in>I. x^i)" | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 2002 | by (simp add: sum_distrib_left power_add) | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 2003 | |
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 2004 | lemma sum_gp_offset: | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 2005 |   fixes x :: "'a::{comm_ring,division_ring}"
 | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 2006 | shows "(\<Sum>i=m..m+n. x^i) = | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 2007 | (if x = 1 then of_nat n + 1 else x^m * (1 - x^Suc n) / (1 - x))" | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 2008 | using sum_gp [of x m "m+n"] | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 2009 | by (auto simp: power_add algebra_simps) | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 2010 | |
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 2011 | lemma sum_gp_strict: | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 2012 |   fixes x :: "'a::{comm_ring,division_ring}"
 | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 2013 | shows "(\<Sum>i<n. x^i) = (if x = 1 then of_nat n else (1 - x^n) / (1 - x))" | 
| 
e4997c181cce
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
 paulson <lp15@cam.ac.uk> parents: 
65273diff
changeset | 2014 | by (induct n) (auto simp: algebra_simps divide_simps) | 
| 17149 
e2b19c92ef51
Lemmas on dvd, power and finite summation added or strengthened.
 ballarin parents: 
16733diff
changeset | 2015 | |
| 63417 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2016 | subsubsection \<open>The formula for arithmetic sums\<close> | 
| 19469 
958d2f2dd8d4
moved arithmetic series to geometric series in SetInterval
 kleing parents: 
19376diff
changeset | 2017 | |
| 47222 
1b7c909a6fad
rephrase lemmas about arithmetic series using numeral '2'
 huffman parents: 
47108diff
changeset | 2018 | lemma gauss_sum: | 
| 56193 
c726ecfb22b6
cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
 hoelzl parents: 
55719diff
changeset | 2019 |   "(2::'a::comm_semiring_1)*(\<Sum>i\<in>{1..n}. of_nat i) = of_nat n*((of_nat n)+1)"
 | 
| 19469 
958d2f2dd8d4
moved arithmetic series to geometric series in SetInterval
 kleing parents: 
19376diff
changeset | 2020 | proof (induct n) | 
| 
958d2f2dd8d4
moved arithmetic series to geometric series in SetInterval
 kleing parents: 
19376diff
changeset | 2021 | case 0 | 
| 
958d2f2dd8d4
moved arithmetic series to geometric series in SetInterval
 kleing parents: 
19376diff
changeset | 2022 | show ?case by simp | 
| 
958d2f2dd8d4
moved arithmetic series to geometric series in SetInterval
 kleing parents: 
19376diff
changeset | 2023 | next | 
| 
958d2f2dd8d4
moved arithmetic series to geometric series in SetInterval
 kleing parents: 
19376diff
changeset | 2024 | case (Suc n) | 
| 47222 
1b7c909a6fad
rephrase lemmas about arithmetic series using numeral '2'
 huffman parents: 
47108diff
changeset | 2025 | then show ?case | 
| 
1b7c909a6fad
rephrase lemmas about arithmetic series using numeral '2'
 huffman parents: 
47108diff
changeset | 2026 | by (simp add: algebra_simps add: one_add_one [symmetric] del: one_add_one) | 
| 
1b7c909a6fad
rephrase lemmas about arithmetic series using numeral '2'
 huffman parents: 
47108diff
changeset | 2027 | (* FIXME: make numeral cancellation simprocs work for semirings *) | 
| 19469 
958d2f2dd8d4
moved arithmetic series to geometric series in SetInterval
 kleing parents: 
19376diff
changeset | 2028 | qed | 
| 
958d2f2dd8d4
moved arithmetic series to geometric series in SetInterval
 kleing parents: 
19376diff
changeset | 2029 | |
| 
958d2f2dd8d4
moved arithmetic series to geometric series in SetInterval
 kleing parents: 
19376diff
changeset | 2030 | theorem arith_series_general: | 
| 47222 
1b7c909a6fad
rephrase lemmas about arithmetic series using numeral '2'
 huffman parents: 
47108diff
changeset | 2031 |   "(2::'a::comm_semiring_1) * (\<Sum>i\<in>{..<n}. a + of_nat i * d) =
 | 
| 19469 
958d2f2dd8d4
moved arithmetic series to geometric series in SetInterval
 kleing parents: 
19376diff
changeset | 2032 | of_nat n * (a + (a + of_nat(n - 1)*d))" | 
| 
958d2f2dd8d4
moved arithmetic series to geometric series in SetInterval
 kleing parents: 
19376diff
changeset | 2033 | proof cases | 
| 
958d2f2dd8d4
moved arithmetic series to geometric series in SetInterval
 kleing parents: 
19376diff
changeset | 2034 | assume ngt1: "n > 1" | 
| 
958d2f2dd8d4
moved arithmetic series to geometric series in SetInterval
 kleing parents: 
19376diff
changeset | 2035 | let ?I = "\<lambda>i. of_nat i" and ?n = "of_nat n" | 
| 
958d2f2dd8d4
moved arithmetic series to geometric series in SetInterval
 kleing parents: 
19376diff
changeset | 2036 | have | 
| 
958d2f2dd8d4
moved arithmetic series to geometric series in SetInterval
 kleing parents: 
19376diff
changeset | 2037 |     "(\<Sum>i\<in>{..<n}. a+?I i*d) =
 | 
| 
958d2f2dd8d4
moved arithmetic series to geometric series in SetInterval
 kleing parents: 
19376diff
changeset | 2038 |      ((\<Sum>i\<in>{..<n}. a) + (\<Sum>i\<in>{..<n}. ?I i*d))"
 | 
| 64267 | 2039 | by (rule sum.distrib) | 
| 19469 
958d2f2dd8d4
moved arithmetic series to geometric series in SetInterval
 kleing parents: 
19376diff
changeset | 2040 |   also from ngt1 have "\<dots> = ?n*a + (\<Sum>i\<in>{..<n}. ?I i*d)" by simp
 | 
| 
958d2f2dd8d4
moved arithmetic series to geometric series in SetInterval
 kleing parents: 
19376diff
changeset | 2041 |   also from ngt1 have "\<dots> = (?n*a + d*(\<Sum>i\<in>{1..<n}. ?I i))"
 | 
| 30079 
293b896b9c25
make proofs work whether or not One_nat_def is a simp rule; replace 1 with Suc 0 in the rhs of some simp rules
 huffman parents: 
29960diff
changeset | 2042 | unfolding One_nat_def | 
| 64267 | 2043 | by (simp add: sum_distrib_left atLeast0LessThan[symmetric] sum_shift_lb_Suc0_0_upt ac_simps) | 
| 47222 
1b7c909a6fad
rephrase lemmas about arithmetic series using numeral '2'
 huffman parents: 
47108diff
changeset | 2044 |   also have "2*\<dots> = 2*?n*a + d*2*(\<Sum>i\<in>{1..<n}. ?I i)"
 | 
| 
1b7c909a6fad
rephrase lemmas about arithmetic series using numeral '2'
 huffman parents: 
47108diff
changeset | 2045 | by (simp add: algebra_simps) | 
| 19469 
958d2f2dd8d4
moved arithmetic series to geometric series in SetInterval
 kleing parents: 
19376diff
changeset | 2046 |   also from ngt1 have "{1..<n} = {1..n - 1}"
 | 
| 28068 | 2047 | by (cases n) (auto simp: atLeastLessThanSuc_atLeastAtMost) | 
| 2048 | also from ngt1 | |
| 47222 
1b7c909a6fad
rephrase lemmas about arithmetic series using numeral '2'
 huffman parents: 
47108diff
changeset | 2049 |   have "2*?n*a + d*2*(\<Sum>i\<in>{1..n - 1}. ?I i) = (2*?n*a + d*?I (n - 1)*?I n)"
 | 
| 57514 
bdc2c6b40bf2
prefer ac_simps collections over separate name bindings for add and mult
 haftmann parents: 
57512diff
changeset | 2050 | by (simp only: mult.assoc gauss_sum [of "n - 1"], unfold One_nat_def) | 
| 
bdc2c6b40bf2
prefer ac_simps collections over separate name bindings for add and mult
 haftmann parents: 
57512diff
changeset | 2051 | (simp add: mult.commute trans [OF add.commute of_nat_Suc [symmetric]]) | 
| 47222 
1b7c909a6fad
rephrase lemmas about arithmetic series using numeral '2'
 huffman parents: 
47108diff
changeset | 2052 | finally show ?thesis | 
| 
1b7c909a6fad
rephrase lemmas about arithmetic series using numeral '2'
 huffman parents: 
47108diff
changeset | 2053 | unfolding mult_2 by (simp add: algebra_simps) | 
| 19469 
958d2f2dd8d4
moved arithmetic series to geometric series in SetInterval
 kleing parents: 
19376diff
changeset | 2054 | next | 
| 
958d2f2dd8d4
moved arithmetic series to geometric series in SetInterval
 kleing parents: 
19376diff
changeset | 2055 | assume "\<not>(n > 1)" | 
| 
958d2f2dd8d4
moved arithmetic series to geometric series in SetInterval
 kleing parents: 
19376diff
changeset | 2056 | hence "n = 1 \<or> n = 0" by auto | 
| 47222 
1b7c909a6fad
rephrase lemmas about arithmetic series using numeral '2'
 huffman parents: 
47108diff
changeset | 2057 | thus ?thesis by (auto simp: mult_2) | 
| 19469 
958d2f2dd8d4
moved arithmetic series to geometric series in SetInterval
 kleing parents: 
19376diff
changeset | 2058 | qed | 
| 
958d2f2dd8d4
moved arithmetic series to geometric series in SetInterval
 kleing parents: 
19376diff
changeset | 2059 | |
| 
958d2f2dd8d4
moved arithmetic series to geometric series in SetInterval
 kleing parents: 
19376diff
changeset | 2060 | lemma arith_series_nat: | 
| 47222 
1b7c909a6fad
rephrase lemmas about arithmetic series using numeral '2'
 huffman parents: 
47108diff
changeset | 2061 |   "(2::nat) * (\<Sum>i\<in>{..<n}. a+i*d) = n * (a + (a+(n - 1)*d))"
 | 
| 19469 
958d2f2dd8d4
moved arithmetic series to geometric series in SetInterval
 kleing parents: 
19376diff
changeset | 2062 | proof - | 
| 
958d2f2dd8d4
moved arithmetic series to geometric series in SetInterval
 kleing parents: 
19376diff
changeset | 2063 | have | 
| 47222 
1b7c909a6fad
rephrase lemmas about arithmetic series using numeral '2'
 huffman parents: 
47108diff
changeset | 2064 |     "2 * (\<Sum>i\<in>{..<n::nat}. a + of_nat(i)*d) =
 | 
| 19469 
958d2f2dd8d4
moved arithmetic series to geometric series in SetInterval
 kleing parents: 
19376diff
changeset | 2065 | of_nat(n) * (a + (a + of_nat(n - 1)*d))" | 
| 
958d2f2dd8d4
moved arithmetic series to geometric series in SetInterval
 kleing parents: 
19376diff
changeset | 2066 | by (rule arith_series_general) | 
| 30079 
293b896b9c25
make proofs work whether or not One_nat_def is a simp rule; replace 1 with Suc 0 in the rhs of some simp rules
 huffman parents: 
29960diff
changeset | 2067 | thus ?thesis | 
| 35216 | 2068 | unfolding One_nat_def by auto | 
| 19469 
958d2f2dd8d4
moved arithmetic series to geometric series in SetInterval
 kleing parents: 
19376diff
changeset | 2069 | qed | 
| 
958d2f2dd8d4
moved arithmetic series to geometric series in SetInterval
 kleing parents: 
19376diff
changeset | 2070 | |
| 
958d2f2dd8d4
moved arithmetic series to geometric series in SetInterval
 kleing parents: 
19376diff
changeset | 2071 | lemma arith_series_int: | 
| 47222 
1b7c909a6fad
rephrase lemmas about arithmetic series using numeral '2'
 huffman parents: 
47108diff
changeset | 2072 |   "2 * (\<Sum>i\<in>{..<n}. a + int i * d) = int n * (a + (a + int(n - 1)*d))"
 | 
| 
1b7c909a6fad
rephrase lemmas about arithmetic series using numeral '2'
 huffman parents: 
47108diff
changeset | 2073 | by (fact arith_series_general) (* FIXME: duplicate *) | 
| 15418 
e28853da5df5
removed two looping simplifications in SetInterval.thy; deleted the .ML file
 paulson parents: 
15402diff
changeset | 2074 | |
| 59416 
fde2659085e1
generalized sum_diff_distrib to setsum_subtractf_nat
 hoelzl parents: 
59000diff
changeset | 2075 | lemma sum_diff_distrib: "\<forall>x. Q x \<le> P x \<Longrightarrow> (\<Sum>x<n. P x) - (\<Sum>x<n. Q x) = (\<Sum>x<n. P x - Q x :: nat)" | 
| 64267 | 2076 | by (subst sum_subtractf_nat) auto | 
| 19022 
0e6ec4fd204c
* moved ThreeDivides from Isar_examples to better suited HOL/ex
 kleing parents: 
17719diff
changeset | 2077 | |
| 61955 
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
 wenzelm parents: 
61799diff
changeset | 2078 | |
| 63417 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2079 | subsubsection \<open>Division remainder\<close> | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2080 | |
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2081 | lemma range_mod: | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2082 | fixes n :: nat | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2083 | assumes "n > 0" | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2084 |   shows "range (\<lambda>m. m mod n) = {0..<n}" (is "?A = ?B")
 | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2085 | proof (rule set_eqI) | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2086 | fix m | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2087 | show "m \<in> ?A \<longleftrightarrow> m \<in> ?B" | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2088 | proof | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2089 | assume "m \<in> ?A" | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2090 | with assms show "m \<in> ?B" | 
| 63915 | 2091 | by auto | 
| 63417 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2092 | next | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2093 | assume "m \<in> ?B" | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2094 | moreover have "m mod n \<in> ?A" | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2095 | by (rule rangeI) | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2096 | ultimately show "m \<in> ?A" | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2097 | by simp | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2098 | qed | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2099 | qed | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2100 | |
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2101 | |
| 60758 | 2102 | subsection \<open>Products indexed over intervals\<close> | 
| 29960 
9d5c6f376768
 Syntactic support for products over set intervals
 paulson parents: 
29920diff
changeset | 2103 | |
| 61955 
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
 wenzelm parents: 
61799diff
changeset | 2104 | syntax (ASCII) | 
| 64272 | 2105 |   "_from_to_prod" :: "idt \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> 'b"  ("(PROD _ = _.._./ _)" [0,0,0,10] 10)
 | 
| 2106 |   "_from_upto_prod" :: "idt \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> 'b"  ("(PROD _ = _..<_./ _)" [0,0,0,10] 10)
 | |
| 2107 |   "_upt_prod" :: "idt \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> 'b"  ("(PROD _<_./ _)" [0,0,10] 10)
 | |
| 2108 |   "_upto_prod" :: "idt \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> 'b"  ("(PROD _<=_./ _)" [0,0,10] 10)
 | |
| 61955 
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
 wenzelm parents: 
61799diff
changeset | 2109 | |
| 29960 
9d5c6f376768
 Syntactic support for products over set intervals
 paulson parents: 
29920diff
changeset | 2110 | syntax (latex_prod output) | 
| 64272 | 2111 | "_from_to_prod" :: "idt \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> 'b" | 
| 63935 
aa1fe1103ab8
raw control symbols are superseded by Latex.embed_raw;
 wenzelm parents: 
63918diff
changeset | 2112 |  ("(3\<^latex>\<open>$\\prod_{\<close>_ = _\<^latex>\<open>}^{\<close>_\<^latex>\<open>}$\<close> _)" [0,0,0,10] 10)
 | 
| 64272 | 2113 | "_from_upto_prod" :: "idt \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> 'b" | 
| 63935 
aa1fe1103ab8
raw control symbols are superseded by Latex.embed_raw;
 wenzelm parents: 
63918diff
changeset | 2114 |  ("(3\<^latex>\<open>$\\prod_{\<close>_ = _\<^latex>\<open>}^{<\<close>_\<^latex>\<open>}$\<close> _)" [0,0,0,10] 10)
 | 
| 64272 | 2115 | "_upt_prod" :: "idt \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> 'b" | 
| 63935 
aa1fe1103ab8
raw control symbols are superseded by Latex.embed_raw;
 wenzelm parents: 
63918diff
changeset | 2116 |  ("(3\<^latex>\<open>$\\prod_{\<close>_ < _\<^latex>\<open>}$\<close> _)" [0,0,10] 10)
 | 
| 64272 | 2117 | "_upto_prod" :: "idt \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> 'b" | 
| 63935 
aa1fe1103ab8
raw control symbols are superseded by Latex.embed_raw;
 wenzelm parents: 
63918diff
changeset | 2118 |  ("(3\<^latex>\<open>$\\prod_{\<close>_ \<le> _\<^latex>\<open>}$\<close> _)" [0,0,10] 10)
 | 
| 29960 
9d5c6f376768
 Syntactic support for products over set intervals
 paulson parents: 
29920diff
changeset | 2119 | |
| 61955 
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
 wenzelm parents: 
61799diff
changeset | 2120 | syntax | 
| 64272 | 2121 |   "_from_to_prod" :: "idt \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> 'b"  ("(3\<Prod>_ = _.._./ _)" [0,0,0,10] 10)
 | 
| 2122 |   "_from_upto_prod" :: "idt \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> 'b"  ("(3\<Prod>_ = _..<_./ _)" [0,0,0,10] 10)
 | |
| 2123 |   "_upt_prod" :: "idt \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> 'b"  ("(3\<Prod>_<_./ _)" [0,0,10] 10)
 | |
| 2124 |   "_upto_prod" :: "idt \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> 'b"  ("(3\<Prod>_\<le>_./ _)" [0,0,10] 10)
 | |
| 61955 
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
 wenzelm parents: 
61799diff
changeset | 2125 | |
| 29960 
9d5c6f376768
 Syntactic support for products over set intervals
 paulson parents: 
29920diff
changeset | 2126 | translations | 
| 64272 | 2127 |   "\<Prod>x=a..b. t" \<rightleftharpoons> "CONST prod (\<lambda>x. t) {a..b}"
 | 
| 2128 |   "\<Prod>x=a..<b. t" \<rightleftharpoons> "CONST prod (\<lambda>x. t) {a..<b}"
 | |
| 2129 |   "\<Prod>i\<le>n. t" \<rightleftharpoons> "CONST prod (\<lambda>i. t) {..n}"
 | |
| 2130 |   "\<Prod>i<n. t" \<rightleftharpoons> "CONST prod (\<lambda>i. t) {..<n}"
 | |
| 2131 | ||
| 2132 | lemma prod_int_plus_eq: "prod int {i..i+j} =  \<Prod>{int i..int (i+j)}"
 | |
| 55242 
413ec965f95d
Number_Theory: prime is no longer overloaded, but only for nat. Automatic coercion to int enabled.
 paulson <lp15@cam.ac.uk> parents: 
55143diff
changeset | 2133 | by (induct j) (auto simp add: atLeastAtMostSuc_conv atLeastAtMostPlus1_int_conv) | 
| 
413ec965f95d
Number_Theory: prime is no longer overloaded, but only for nat. Automatic coercion to int enabled.
 paulson <lp15@cam.ac.uk> parents: 
55143diff
changeset | 2134 | |
| 64272 | 2135 | lemma prod_int_eq: "prod int {i..j} =  \<Prod>{int i..int j}"
 | 
| 55242 
413ec965f95d
Number_Theory: prime is no longer overloaded, but only for nat. Automatic coercion to int enabled.
 paulson <lp15@cam.ac.uk> parents: 
55143diff
changeset | 2136 | proof (cases "i \<le> j") | 
| 
413ec965f95d
Number_Theory: prime is no longer overloaded, but only for nat. Automatic coercion to int enabled.
 paulson <lp15@cam.ac.uk> parents: 
55143diff
changeset | 2137 | case True | 
| 
413ec965f95d
Number_Theory: prime is no longer overloaded, but only for nat. Automatic coercion to int enabled.
 paulson <lp15@cam.ac.uk> parents: 
55143diff
changeset | 2138 | then show ?thesis | 
| 64272 | 2139 | by (metis le_iff_add prod_int_plus_eq) | 
| 55242 
413ec965f95d
Number_Theory: prime is no longer overloaded, but only for nat. Automatic coercion to int enabled.
 paulson <lp15@cam.ac.uk> parents: 
55143diff
changeset | 2140 | next | 
| 
413ec965f95d
Number_Theory: prime is no longer overloaded, but only for nat. Automatic coercion to int enabled.
 paulson <lp15@cam.ac.uk> parents: 
55143diff
changeset | 2141 | case False | 
| 
413ec965f95d
Number_Theory: prime is no longer overloaded, but only for nat. Automatic coercion to int enabled.
 paulson <lp15@cam.ac.uk> parents: 
55143diff
changeset | 2142 | then show ?thesis | 
| 
413ec965f95d
Number_Theory: prime is no longer overloaded, but only for nat. Automatic coercion to int enabled.
 paulson <lp15@cam.ac.uk> parents: 
55143diff
changeset | 2143 | by auto | 
| 
413ec965f95d
Number_Theory: prime is no longer overloaded, but only for nat. Automatic coercion to int enabled.
 paulson <lp15@cam.ac.uk> parents: 
55143diff
changeset | 2144 | qed | 
| 
413ec965f95d
Number_Theory: prime is no longer overloaded, but only for nat. Automatic coercion to int enabled.
 paulson <lp15@cam.ac.uk> parents: 
55143diff
changeset | 2145 | |
| 61524 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61378diff
changeset | 2146 | |
| 63417 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2147 | subsubsection \<open>Shifting bounds\<close> | 
| 61524 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61378diff
changeset | 2148 | |
| 64272 | 2149 | lemma prod_shift_bounds_nat_ivl: | 
| 2150 |   "prod f {m+k..<n+k} = prod (%i. f(i + k)){m..<n::nat}"
 | |
| 61524 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61378diff
changeset | 2151 | by (induct "n", auto simp:atLeastLessThanSuc) | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61378diff
changeset | 2152 | |
| 64272 | 2153 | lemma prod_shift_bounds_cl_nat_ivl: | 
| 2154 |   "prod f {m+k..n+k} = prod (%i. f(i + k)){m..n::nat}"
 | |
| 2155 | by (rule prod.reindex_bij_witness[where i="\<lambda>i. i + k" and j="\<lambda>i. i - k"]) auto | |
| 2156 | ||
| 2157 | corollary prod_shift_bounds_cl_Suc_ivl: | |
| 2158 |   "prod f {Suc m..Suc n} = prod (%i. f(Suc i)){m..n}"
 | |
| 2159 | by (simp add:prod_shift_bounds_cl_nat_ivl[where k="Suc 0", simplified]) | |
| 2160 | ||
| 2161 | corollary prod_shift_bounds_Suc_ivl: | |
| 2162 |   "prod f {Suc m..<Suc n} = prod (%i. f(Suc i)){m..<n}"
 | |
| 2163 | by (simp add:prod_shift_bounds_nat_ivl[where k="Suc 0", simplified]) | |
| 2164 | ||
| 2165 | lemma prod_lessThan_Suc: "prod f {..<Suc n} = prod f {..<n} * f n"
 | |
| 61524 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61378diff
changeset | 2166 | by (simp add: lessThan_Suc mult.commute) | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61378diff
changeset | 2167 | |
| 64272 | 2168 | lemma prod_lessThan_Suc_shift:"(\<Prod>i<Suc n. f i) = f 0 * (\<Prod>i<n. f (Suc i))" | 
| 63317 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63171diff
changeset | 2169 | by (induction n) (simp_all add: lessThan_Suc mult_ac) | 
| 
ca187a9f66da
Various additions to polynomials, FPSs, Gamma function
 eberlm parents: 
63171diff
changeset | 2170 | |
| 64272 | 2171 | lemma prod_atLeastLessThan_Suc: "a \<le> b \<Longrightarrow> prod f {a..<Suc b} = prod f {a..<b} * f b"
 | 
| 61524 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61378diff
changeset | 2172 | by (simp add: atLeastLessThanSuc mult.commute) | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61378diff
changeset | 2173 | |
| 64272 | 2174 | lemma prod_nat_ivl_Suc': | 
| 61524 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61378diff
changeset | 2175 | assumes "m \<le> Suc n" | 
| 64272 | 2176 |   shows   "prod f {m..Suc n} = f (Suc n) * prod f {m..n}"
 | 
| 61524 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61378diff
changeset | 2177 | proof - | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61378diff
changeset | 2178 |   from assms have "{m..Suc n} = insert (Suc n) {m..n}" by auto
 | 
| 64272 | 2179 |   also have "prod f \<dots> = f (Suc n) * prod f {m..n}" by simp
 | 
| 61524 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61378diff
changeset | 2180 | finally show ?thesis . | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61378diff
changeset | 2181 | qed | 
| 
f2e51e704a96
added many small lemmas about setsum/setprod/powr/...
 eberlm parents: 
61378diff
changeset | 2182 | |
| 62128 
3201ddb00097
Integrated some material from Algebraic_Numbers AFP entry to Polynomials; generalised some polynomial stuff.
 eberlm parents: 
61955diff
changeset | 2183 | |
| 
3201ddb00097
Integrated some material from Algebraic_Numbers AFP entry to Polynomials; generalised some polynomial stuff.
 eberlm parents: 
61955diff
changeset | 2184 | subsection \<open>Efficient folding over intervals\<close> | 
| 
3201ddb00097
Integrated some material from Algebraic_Numbers AFP entry to Polynomials; generalised some polynomial stuff.
 eberlm parents: 
61955diff
changeset | 2185 | |
| 
3201ddb00097
Integrated some material from Algebraic_Numbers AFP entry to Polynomials; generalised some polynomial stuff.
 eberlm parents: 
61955diff
changeset | 2186 | function fold_atLeastAtMost_nat where | 
| 
3201ddb00097
Integrated some material from Algebraic_Numbers AFP entry to Polynomials; generalised some polynomial stuff.
 eberlm parents: 
61955diff
changeset | 2187 | [simp del]: "fold_atLeastAtMost_nat f a (b::nat) acc = | 
| 
3201ddb00097
Integrated some material from Algebraic_Numbers AFP entry to Polynomials; generalised some polynomial stuff.
 eberlm parents: 
61955diff
changeset | 2188 | (if a > b then acc else fold_atLeastAtMost_nat f (a+1) b (f a acc))" | 
| 
3201ddb00097
Integrated some material from Algebraic_Numbers AFP entry to Polynomials; generalised some polynomial stuff.
 eberlm parents: 
61955diff
changeset | 2189 | by pat_completeness auto | 
| 
3201ddb00097
Integrated some material from Algebraic_Numbers AFP entry to Polynomials; generalised some polynomial stuff.
 eberlm parents: 
61955diff
changeset | 2190 | termination by (relation "measure (\<lambda>(_,a,b,_). Suc b - a)") auto | 
| 
3201ddb00097
Integrated some material from Algebraic_Numbers AFP entry to Polynomials; generalised some polynomial stuff.
 eberlm parents: 
61955diff
changeset | 2191 | |
| 
3201ddb00097
Integrated some material from Algebraic_Numbers AFP entry to Polynomials; generalised some polynomial stuff.
 eberlm parents: 
61955diff
changeset | 2192 | lemma fold_atLeastAtMost_nat: | 
| 
3201ddb00097
Integrated some material from Algebraic_Numbers AFP entry to Polynomials; generalised some polynomial stuff.
 eberlm parents: 
61955diff
changeset | 2193 | assumes "comp_fun_commute f" | 
| 
3201ddb00097
Integrated some material from Algebraic_Numbers AFP entry to Polynomials; generalised some polynomial stuff.
 eberlm parents: 
61955diff
changeset | 2194 |   shows   "fold_atLeastAtMost_nat f a b acc = Finite_Set.fold f acc {a..b}"
 | 
| 
3201ddb00097
Integrated some material from Algebraic_Numbers AFP entry to Polynomials; generalised some polynomial stuff.
 eberlm parents: 
61955diff
changeset | 2195 | using assms | 
| 
3201ddb00097
Integrated some material from Algebraic_Numbers AFP entry to Polynomials; generalised some polynomial stuff.
 eberlm parents: 
61955diff
changeset | 2196 | proof (induction f a b acc rule: fold_atLeastAtMost_nat.induct, goal_cases) | 
| 
3201ddb00097
Integrated some material from Algebraic_Numbers AFP entry to Polynomials; generalised some polynomial stuff.
 eberlm parents: 
61955diff
changeset | 2197 | case (1 f a b acc) | 
| 
3201ddb00097
Integrated some material from Algebraic_Numbers AFP entry to Polynomials; generalised some polynomial stuff.
 eberlm parents: 
61955diff
changeset | 2198 | interpret comp_fun_commute f by fact | 
| 
3201ddb00097
Integrated some material from Algebraic_Numbers AFP entry to Polynomials; generalised some polynomial stuff.
 eberlm parents: 
61955diff
changeset | 2199 | show ?case | 
| 
3201ddb00097
Integrated some material from Algebraic_Numbers AFP entry to Polynomials; generalised some polynomial stuff.
 eberlm parents: 
61955diff
changeset | 2200 | proof (cases "a > b") | 
| 
3201ddb00097
Integrated some material from Algebraic_Numbers AFP entry to Polynomials; generalised some polynomial stuff.
 eberlm parents: 
61955diff
changeset | 2201 | case True | 
| 
3201ddb00097
Integrated some material from Algebraic_Numbers AFP entry to Polynomials; generalised some polynomial stuff.
 eberlm parents: 
61955diff
changeset | 2202 | thus ?thesis by (subst fold_atLeastAtMost_nat.simps) auto | 
| 
3201ddb00097
Integrated some material from Algebraic_Numbers AFP entry to Polynomials; generalised some polynomial stuff.
 eberlm parents: 
61955diff
changeset | 2203 | next | 
| 
3201ddb00097
Integrated some material from Algebraic_Numbers AFP entry to Polynomials; generalised some polynomial stuff.
 eberlm parents: 
61955diff
changeset | 2204 | case False | 
| 
3201ddb00097
Integrated some material from Algebraic_Numbers AFP entry to Polynomials; generalised some polynomial stuff.
 eberlm parents: 
61955diff
changeset | 2205 | with 1 show ?thesis | 
| 
3201ddb00097
Integrated some material from Algebraic_Numbers AFP entry to Polynomials; generalised some polynomial stuff.
 eberlm parents: 
61955diff
changeset | 2206 | by (subst fold_atLeastAtMost_nat.simps) | 
| 
3201ddb00097
Integrated some material from Algebraic_Numbers AFP entry to Polynomials; generalised some polynomial stuff.
 eberlm parents: 
61955diff
changeset | 2207 | (auto simp: atLeastAtMost_insertL[symmetric] fold_fun_left_comm) | 
| 
3201ddb00097
Integrated some material from Algebraic_Numbers AFP entry to Polynomials; generalised some polynomial stuff.
 eberlm parents: 
61955diff
changeset | 2208 | qed | 
| 
3201ddb00097
Integrated some material from Algebraic_Numbers AFP entry to Polynomials; generalised some polynomial stuff.
 eberlm parents: 
61955diff
changeset | 2209 | qed | 
| 
3201ddb00097
Integrated some material from Algebraic_Numbers AFP entry to Polynomials; generalised some polynomial stuff.
 eberlm parents: 
61955diff
changeset | 2210 | |
| 64267 | 2211 | lemma sum_atLeastAtMost_code: | 
| 2212 |   "sum f {a..b} = fold_atLeastAtMost_nat (\<lambda>a acc. f a + acc) a b 0"
 | |
| 62128 
3201ddb00097
Integrated some material from Algebraic_Numbers AFP entry to Polynomials; generalised some polynomial stuff.
 eberlm parents: 
61955diff
changeset | 2213 | proof - | 
| 
3201ddb00097
Integrated some material from Algebraic_Numbers AFP entry to Polynomials; generalised some polynomial stuff.
 eberlm parents: 
61955diff
changeset | 2214 | have "comp_fun_commute (\<lambda>a. op + (f a))" | 
| 
3201ddb00097
Integrated some material from Algebraic_Numbers AFP entry to Polynomials; generalised some polynomial stuff.
 eberlm parents: 
61955diff
changeset | 2215 | by unfold_locales (auto simp: o_def add_ac) | 
| 
3201ddb00097
Integrated some material from Algebraic_Numbers AFP entry to Polynomials; generalised some polynomial stuff.
 eberlm parents: 
61955diff
changeset | 2216 | thus ?thesis | 
| 64267 | 2217 | by (simp add: sum.eq_fold fold_atLeastAtMost_nat o_def) | 
| 62128 
3201ddb00097
Integrated some material from Algebraic_Numbers AFP entry to Polynomials; generalised some polynomial stuff.
 eberlm parents: 
61955diff
changeset | 2218 | qed | 
| 
3201ddb00097
Integrated some material from Algebraic_Numbers AFP entry to Polynomials; generalised some polynomial stuff.
 eberlm parents: 
61955diff
changeset | 2219 | |
| 64272 | 2220 | lemma prod_atLeastAtMost_code: | 
| 2221 |   "prod f {a..b} = fold_atLeastAtMost_nat (\<lambda>a acc. f a * acc) a b 1"
 | |
| 62128 
3201ddb00097
Integrated some material from Algebraic_Numbers AFP entry to Polynomials; generalised some polynomial stuff.
 eberlm parents: 
61955diff
changeset | 2222 | proof - | 
| 
3201ddb00097
Integrated some material from Algebraic_Numbers AFP entry to Polynomials; generalised some polynomial stuff.
 eberlm parents: 
61955diff
changeset | 2223 | have "comp_fun_commute (\<lambda>a. op * (f a))" | 
| 
3201ddb00097
Integrated some material from Algebraic_Numbers AFP entry to Polynomials; generalised some polynomial stuff.
 eberlm parents: 
61955diff
changeset | 2224 | by unfold_locales (auto simp: o_def mult_ac) | 
| 
3201ddb00097
Integrated some material from Algebraic_Numbers AFP entry to Polynomials; generalised some polynomial stuff.
 eberlm parents: 
61955diff
changeset | 2225 | thus ?thesis | 
| 64272 | 2226 | by (simp add: prod.eq_fold fold_atLeastAtMost_nat o_def) | 
| 62128 
3201ddb00097
Integrated some material from Algebraic_Numbers AFP entry to Polynomials; generalised some polynomial stuff.
 eberlm parents: 
61955diff
changeset | 2227 | qed | 
| 
3201ddb00097
Integrated some material from Algebraic_Numbers AFP entry to Polynomials; generalised some polynomial stuff.
 eberlm parents: 
61955diff
changeset | 2228 | |
| 
3201ddb00097
Integrated some material from Algebraic_Numbers AFP entry to Polynomials; generalised some polynomial stuff.
 eberlm parents: 
61955diff
changeset | 2229 | (* TODO: Add support for more kinds of intervals here *) | 
| 
3201ddb00097
Integrated some material from Algebraic_Numbers AFP entry to Polynomials; generalised some polynomial stuff.
 eberlm parents: 
61955diff
changeset | 2230 | |
| 63417 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2231 | |
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2232 | subsection \<open>Transfer setup\<close> | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2233 | |
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2234 | lemma transfer_nat_int_set_functions: | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2235 |     "{..n} = nat ` {0..int n}"
 | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2236 |     "{m..n} = nat ` {int m..int n}"  (* need all variants of these! *)
 | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2237 | apply (auto simp add: image_def) | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2238 | apply (rule_tac x = "int x" in bexI) | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2239 | apply auto | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2240 | apply (rule_tac x = "int x" in bexI) | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2241 | apply auto | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2242 | done | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2243 | |
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2244 | lemma transfer_nat_int_set_function_closures: | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2245 |     "x >= 0 \<Longrightarrow> nat_set {x..y}"
 | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2246 | by (simp add: nat_set_def) | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2247 | |
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2248 | declare transfer_morphism_nat_int[transfer add | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2249 | return: transfer_nat_int_set_functions | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2250 | transfer_nat_int_set_function_closures | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2251 | ] | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2252 | |
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2253 | lemma transfer_int_nat_set_functions: | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2254 |     "is_nat m \<Longrightarrow> is_nat n \<Longrightarrow> {m..n} = int ` {nat m..nat n}"
 | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2255 | by (simp only: is_nat_def transfer_nat_int_set_functions | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2256 | transfer_nat_int_set_function_closures | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2257 | transfer_nat_int_set_return_embed nat_0_le | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2258 | cong: transfer_nat_int_set_cong) | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2259 | |
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2260 | lemma transfer_int_nat_set_function_closures: | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2261 |     "is_nat x \<Longrightarrow> nat_set {x..y}"
 | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2262 | by (simp only: transfer_nat_int_set_function_closures is_nat_def) | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2263 | |
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2264 | declare transfer_morphism_int_nat[transfer add | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2265 | return: transfer_int_nat_set_functions | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2266 | transfer_int_nat_set_function_closures | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2267 | ] | 
| 
c184ec919c70
more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
 haftmann parents: 
63365diff
changeset | 2268 | |
| 8924 | 2269 | end |